mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-25 22:09:35 +00:00
Replace direct call of Postprocessor methods by list of available postprocessing functions.
This commit is contained in:
parent
9705f5d520
commit
ae67c77c9d
|
@ -929,7 +929,9 @@ void FrameBufferList::_renderScreenSizeBuffer()
|
|||
GraphicsDrawer & drawer = wnd.getDrawer();
|
||||
FrameBuffer *pBuffer = &m_list.back();
|
||||
PostProcessor & postProcessor = PostProcessor::get();
|
||||
FrameBuffer * pFilteredBuffer = postProcessor.doGammaCorrection(postProcessor.doFXAA(postProcessor.doOrientationCorrection(pBuffer)));
|
||||
FrameBuffer * pFilteredBuffer = pBuffer;
|
||||
for (const auto & f : postProcessor.getPostprocessingList())
|
||||
pFilteredBuffer = f(postProcessor, pFilteredBuffer);
|
||||
CachedTexture * pBufferTexture = pFilteredBuffer->m_pTexture;
|
||||
|
||||
const u32 wndWidth = wnd.getWidth();
|
||||
|
@ -1329,7 +1331,9 @@ void FrameBufferList::renderBuffer()
|
|||
srcY1 = srcY0 + srcHeight;
|
||||
}
|
||||
PostProcessor & postProcessor = PostProcessor::get();
|
||||
FrameBuffer * pFilteredBuffer = postProcessor.doGammaCorrection(postProcessor.doFXAA(postProcessor.doOrientationCorrection(pBuffer)));
|
||||
FrameBuffer * pFilteredBuffer = pBuffer;
|
||||
for (const auto & f : postProcessor.getPostprocessingList())
|
||||
pFilteredBuffer = f(postProcessor, pFilteredBuffer);
|
||||
|
||||
if (rdpRes.vi_fsaa && rdpRes.vi_divot)
|
||||
Xdivot = 1;
|
||||
|
@ -1401,7 +1405,9 @@ void FrameBufferList::renderBuffer()
|
|||
|
||||
if (pNextBuffer != nullptr) {
|
||||
pNextBuffer->m_isMainBuffer = true;
|
||||
pFilteredBuffer = postProcessor.doGammaCorrection(postProcessor.doOrientationCorrection(pNextBuffer));
|
||||
pFilteredBuffer = pNextBuffer;
|
||||
for (const auto & f : postProcessor.getPostprocessingList())
|
||||
pFilteredBuffer = f(postProcessor, pFilteredBuffer);
|
||||
srcY1 = srcPartHeight;
|
||||
dstY0 = dstY1;
|
||||
dstY1 = dstY0 + dstPartHeight;
|
||||
|
|
|
@ -66,20 +66,31 @@ void PostProcessor::_createResultBuffer(const FrameBuffer * _pMainBuffer)
|
|||
void PostProcessor::init()
|
||||
{
|
||||
m_gammaCorrectionProgram.reset(gfxContext.createGammaCorrectionShader());
|
||||
if (config.video.fxaa != 0)
|
||||
m_postprocessingList.emplace_front(std::mem_fn(&PostProcessor::_doGammaCorrection)); // std::mem_fn to fix compilation with VS 2013
|
||||
if (config.video.fxaa != 0) {
|
||||
m_FXAAProgram.reset(gfxContext.createFXAAShader());
|
||||
if (config.generalEmulation.enableBlitScreenWorkaround != 0)
|
||||
m_postprocessingList.emplace_front(std::mem_fn(&PostProcessor::_doFXAA));
|
||||
}
|
||||
if (config.generalEmulation.enableBlitScreenWorkaround != 0) {
|
||||
m_orientationCorrectionProgram.reset(gfxContext.createOrientationCorrectionShader());
|
||||
m_postprocessingList.emplace_front(std::mem_fn(&PostProcessor::_doOrientationCorrection));
|
||||
}
|
||||
}
|
||||
|
||||
void PostProcessor::destroy()
|
||||
{
|
||||
m_postprocessingList.clear();
|
||||
m_gammaCorrectionProgram.reset();
|
||||
m_FXAAProgram.reset();
|
||||
m_orientationCorrectionProgram.reset();
|
||||
m_pResultBuffer.reset();
|
||||
}
|
||||
|
||||
const PostProcessor::PostprocessingList & PostProcessor::getPostprocessingList() const
|
||||
{
|
||||
return m_postprocessingList;
|
||||
}
|
||||
|
||||
PostProcessor & PostProcessor::get()
|
||||
{
|
||||
static PostProcessor processor;
|
||||
|
@ -140,7 +151,7 @@ FrameBuffer * PostProcessor::_doPostProcessing(FrameBuffer * _pBuffer, graphics:
|
|||
return m_pResultBuffer.get();
|
||||
}
|
||||
|
||||
FrameBuffer * PostProcessor::doGammaCorrection(FrameBuffer * _pBuffer)
|
||||
FrameBuffer * PostProcessor::_doGammaCorrection(FrameBuffer * _pBuffer)
|
||||
{
|
||||
if (_pBuffer == nullptr)
|
||||
return nullptr;
|
||||
|
@ -151,7 +162,7 @@ FrameBuffer * PostProcessor::doGammaCorrection(FrameBuffer * _pBuffer)
|
|||
return _doPostProcessing(_pBuffer, m_gammaCorrectionProgram.get());
|
||||
}
|
||||
|
||||
FrameBuffer * PostProcessor::doOrientationCorrection(FrameBuffer * _pBuffer)
|
||||
FrameBuffer * PostProcessor::_doOrientationCorrection(FrameBuffer * _pBuffer)
|
||||
{
|
||||
if (_pBuffer == nullptr)
|
||||
return nullptr;
|
||||
|
@ -162,7 +173,7 @@ FrameBuffer * PostProcessor::doOrientationCorrection(FrameBuffer * _pBuffer)
|
|||
return _doPostProcessing(_pBuffer, m_orientationCorrectionProgram.get());
|
||||
}
|
||||
|
||||
FrameBuffer * PostProcessor::doFXAA(FrameBuffer * _pBuffer)
|
||||
FrameBuffer * PostProcessor::_doFXAA(FrameBuffer * _pBuffer)
|
||||
{
|
||||
if (_pBuffer == nullptr)
|
||||
return nullptr;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef POST_PROCESSOR_H
|
||||
#define POST_PROCESSOR_H
|
||||
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include "Types.h"
|
||||
#include "Textures.h"
|
||||
|
@ -17,9 +19,9 @@ public:
|
|||
void init();
|
||||
void destroy();
|
||||
|
||||
FrameBuffer * doGammaCorrection(FrameBuffer * _pBuffer);
|
||||
FrameBuffer * doOrientationCorrection(FrameBuffer * _pBuffer);
|
||||
FrameBuffer * doFXAA(FrameBuffer * _pBuffer);
|
||||
using PostprocessingFunc = std::function<FrameBuffer*(PostProcessor&, FrameBuffer*)>;
|
||||
using PostprocessingList = std::list<PostprocessingFunc>;
|
||||
const PostprocessingList & getPostprocessingList() const;
|
||||
|
||||
static PostProcessor & get();
|
||||
|
||||
|
@ -27,6 +29,10 @@ private:
|
|||
PostProcessor();
|
||||
PostProcessor(const PostProcessor & _other) = delete;
|
||||
|
||||
FrameBuffer * _doGammaCorrection(FrameBuffer * _pBuffer);
|
||||
FrameBuffer * _doOrientationCorrection(FrameBuffer * _pBuffer);
|
||||
FrameBuffer * _doFXAA(FrameBuffer * _pBuffer);
|
||||
|
||||
void _createResultBuffer(const FrameBuffer * _pMainBuffer);
|
||||
void _preDraw(FrameBuffer * _pBuffer);
|
||||
void _postDraw();
|
||||
|
@ -37,6 +43,7 @@ private:
|
|||
std::unique_ptr<graphics::ShaderProgram> m_FXAAProgram;
|
||||
std::unique_ptr<FrameBuffer> m_pResultBuffer;
|
||||
CachedTexture * m_pTextureOriginal;
|
||||
PostprocessingList m_postprocessingList;
|
||||
};
|
||||
|
||||
#endif // POST_PROCESSOR_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user