From 7ca9ca9465439b6bd0ba18775aed5394e2806fd4 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sun, 9 Oct 2016 13:20:31 +0200 Subject: [PATCH] gsdx: new parameter for merge virtual function * Add full PMODE register to replace slbg/mmod * Add full EXTBUF register (will allow to emulate write feedback) * Add a third source (which will actually be the destination of the write feedback) --- plugins/GSdx/GSDevice.cpp | 6 +++--- plugins/GSdx/GSDevice.h | 4 ++-- plugins/GSdx/GSDevice11.cpp | 5 ++++- plugins/GSdx/GSDevice11.h | 2 +- plugins/GSdx/GSDevice9.cpp | 5 ++++- plugins/GSdx/GSDevice9.h | 2 +- plugins/GSdx/GSDeviceNull.h | 2 +- plugins/GSdx/GSDeviceOGL.cpp | 6 ++++-- plugins/GSdx/GSDeviceOGL.h | 2 +- plugins/GSdx/GSDeviceSW.cpp | 5 ++++- plugins/GSdx/GSDeviceSW.h | 2 +- plugins/GSdx/GSRenderer.cpp | 7 +++---- plugins/GSdx/PSX/GPURenderer.cpp | 7 +++++-- 13 files changed, 34 insertions(+), 21 deletions(-) diff --git a/plugins/GSdx/GSDevice.cpp b/plugins/GSdx/GSDevice.cpp index 1f4183296d..7f182e6a32 100644 --- a/plugins/GSdx/GSDevice.cpp +++ b/plugins/GSdx/GSDevice.cpp @@ -243,7 +243,7 @@ GSTexture* GSDevice::GetCurrent() return m_current; } -void GSDevice::Merge(GSTexture* sTex[2], GSVector4* sRect, GSVector4* dRect, const GSVector2i& fs, bool slbg, bool mmod, const GSVector4& c) +void GSDevice::Merge(GSTexture* sTex[3], GSVector4* sRect, GSVector4* dRect, const GSVector2i& fs, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) { if(m_merge == NULL || m_merge->GetSize() != fs) { @@ -260,7 +260,7 @@ void GSDevice::Merge(GSTexture* sTex[2], GSVector4* sRect, GSVector4* dRect, con if(m_merge) { - GSTexture* tex[2] = {NULL, NULL}; + GSTexture* tex[3] = {NULL, NULL, NULL}; for(size_t i = 0; i < countof(tex); i++) { @@ -270,7 +270,7 @@ void GSDevice::Merge(GSTexture* sTex[2], GSVector4* sRect, GSVector4* dRect, con } } - DoMerge(tex, sRect, m_merge, dRect, slbg, mmod, c); + DoMerge(tex, sRect, m_merge, dRect, PMODE, EXTBUF, c); for(size_t i = 0; i < countof(tex); i++) { diff --git a/plugins/GSdx/GSDevice.h b/plugins/GSdx/GSDevice.h index aaf1a450ce..7d32b28830 100644 --- a/plugins/GSdx/GSDevice.h +++ b/plugins/GSdx/GSDevice.h @@ -122,7 +122,7 @@ protected: virtual GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format) = 0; virtual GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format); - virtual void DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c) = 0; + virtual void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) = 0; virtual void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset) = 0; virtual void DoFXAA(GSTexture* sTex, GSTexture* dTex) {} virtual void DoShadeBoost(GSTexture* sTex, GSTexture* dTex) {} @@ -176,7 +176,7 @@ public: GSTexture* GetCurrent(); - void Merge(GSTexture* sTex[2], GSVector4* sRect, GSVector4* dRect, const GSVector2i& fs, bool slbg, bool mmod, const GSVector4& c); + void Merge(GSTexture* sTex[3], GSVector4* sRect, GSVector4* dRect, const GSVector2i& fs, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c); void Interlace(const GSVector2i& ds, int field, int mode, float yoffset); void FXAA(); void ShadeBoost(); diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index 459c4cc474..73c1931363 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -722,8 +722,11 @@ void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* PSSetShaderResources(NULL, NULL); } -void GSDevice11::DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c) +void GSDevice11::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) { + bool slbg = PMODE.SLBG; + bool mmod = PMODE.MMOD; + ClearRenderTarget(dTex, c); if(sTex[1] && !slbg) diff --git a/plugins/GSdx/GSDevice11.h b/plugins/GSdx/GSDevice11.h index b5763b7f20..4912476f6a 100644 --- a/plugins/GSdx/GSDevice11.h +++ b/plugins/GSdx/GSDevice11.h @@ -34,7 +34,7 @@ class GSDevice11 : public GSDeviceDX { GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format); - void DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c); + void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c); void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset = 0); void DoFXAA(GSTexture* sTex, GSTexture* dTex); void DoShadeBoost(GSTexture* sTex, GSTexture* dTex); diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 7d2c1181d1..04a15f706e 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -904,8 +904,11 @@ void GSDevice9::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* EndScene(); } -void GSDevice9::DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c) +void GSDevice9::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) { + bool slbg = PMODE.SLBG; + bool mmod = PMODE.MMOD; + ClearRenderTarget(dTex, c); if(sTex[1] && !slbg) diff --git a/plugins/GSdx/GSDevice9.h b/plugins/GSdx/GSDevice9.h index 6578a97475..ff0ed4659b 100644 --- a/plugins/GSdx/GSDevice9.h +++ b/plugins/GSdx/GSDevice9.h @@ -74,7 +74,7 @@ class GSDevice9 : public GSDeviceDX { GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format); - void DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c); + void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c); void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset = 0); void DoFXAA(GSTexture* sTex, GSTexture* dTex); void DoShadeBoost(GSTexture* sTex, GSTexture* dTex); diff --git a/plugins/GSdx/GSDeviceNull.h b/plugins/GSdx/GSDeviceNull.h index c61312ab1a..e4423dfb1b 100644 --- a/plugins/GSdx/GSDeviceNull.h +++ b/plugins/GSdx/GSDeviceNull.h @@ -29,7 +29,7 @@ class GSDeviceNull : public GSDevice private: GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format); - void DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c) {} + void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) {} void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset = 0) {} public: diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 58080d1edc..a38fc2ed6b 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -1389,12 +1389,14 @@ void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture EndScene(); } -void GSDeviceOGL::DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c) +void GSDeviceOGL::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) { GL_PUSH("DoMerge"); - OMSetColorMaskState(); + bool slbg = PMODE.SLBG; + bool mmod = PMODE.MMOD; + OMSetColorMaskState(); ClearRenderTarget(dTex, c); if(sTex[1] && !slbg) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 2a0f8b1023..a1aa2f5a23 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -482,7 +482,7 @@ public: GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format); GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format); - void DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c) final; + void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) final; void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset = 0) final; void DoFXAA(GSTexture* sTex, GSTexture* dTex) final; void DoShadeBoost(GSTexture* sTex, GSTexture* dTex) final; diff --git a/plugins/GSdx/GSDeviceSW.cpp b/plugins/GSdx/GSDeviceSW.cpp index 948b57ee87..49efe93f54 100644 --- a/plugins/GSdx/GSDeviceSW.cpp +++ b/plugins/GSdx/GSDeviceSW.cpp @@ -349,8 +349,11 @@ void GSDeviceSW::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector // -void GSDeviceSW::DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c) +void GSDeviceSW::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) { + bool slbg = PMODE.SLBG; + bool mmod = PMODE.MMOD; + ClearRenderTarget(dTex, c); if(sTex[1] && !slbg) diff --git a/plugins/GSdx/GSDeviceSW.h b/plugins/GSdx/GSDeviceSW.h index 16e2ac3bd8..0334f829d4 100644 --- a/plugins/GSdx/GSDeviceSW.h +++ b/plugins/GSdx/GSDeviceSW.h @@ -28,7 +28,7 @@ class GSDeviceSW : public GSDevice { GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format); - void DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c); + void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c); void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset = 0); void Clear(GSTexture* t, uint32 c); diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index 67ac0c71b7..6a147b9964 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -196,8 +196,8 @@ bool GSRenderer::Merge(int field) GSVector2i fs(0, 0); GSVector2i ds(0, 0); - GSTexture* tex[2] = {NULL, NULL}; - int y_offset[2] = {0, 0}; + GSTexture* tex[3] = {NULL, NULL, NULL}; + int y_offset[3] = {0, 0, 0}; s_n++; @@ -272,7 +272,6 @@ bool GSRenderer::Merge(int field) m_real_size = ds; bool slbg = m_regs->PMODE.SLBG; - bool mmod = m_regs->PMODE.MMOD; if(tex[0] || tex[1]) { @@ -285,7 +284,7 @@ bool GSRenderer::Merge(int field) GSVector4 c = GSVector4((int)m_regs->BGCOLOR.R, (int)m_regs->BGCOLOR.G, (int)m_regs->BGCOLOR.B, (int)m_regs->PMODE.ALP) / 255; - m_dev->Merge(tex, src_hw, dst, fs, slbg, mmod, c); + m_dev->Merge(tex, src_hw, dst, fs, m_regs->PMODE, m_regs->EXTBUF, c); if(m_regs->SMODE2.INT && m_interlace > 0) { diff --git a/plugins/GSdx/PSX/GPURenderer.cpp b/plugins/GSdx/PSX/GPURenderer.cpp index db84940f3b..c594fd2a29 100644 --- a/plugins/GSdx/PSX/GPURenderer.cpp +++ b/plugins/GSdx/PSX/GPURenderer.cpp @@ -104,7 +104,7 @@ bool GPURenderer::Create(void* hWnd) bool GPURenderer::Merge() { - GSTexture* st[2] = {GetOutput(), NULL}; + GSTexture* st[3] = {GetOutput(), NULL, NULL}; if(!st[0]) { @@ -119,7 +119,10 @@ bool GPURenderer::Merge() sr[0] = GSVector4(0, 0, 1, 1); dr[0] = GSVector4(0, 0, s.x, s.y); - m_dev->Merge(st, sr, dr, s, 1, 1, GSVector4(0, 0, 0, 1)); + GSRegPMODE PMODE = {0}; + PMODE.u32[0] = 0xFFFFFFFF; + GSRegEXTBUF EXTBUF = {0}; + m_dev->Merge(st, sr, dr, s, PMODE, EXTBUF, GSVector4(0, 0, 0, 1)); if(m_shadeboost) {