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)
This commit is contained in:
Gregory Hainaut 2016-10-09 13:20:31 +02:00
parent 357dcdb55e
commit 7ca9ca9465
13 changed files with 34 additions and 21 deletions

View File

@ -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++)
{

View File

@ -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();

View File

@ -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)

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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:

View File

@ -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)

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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)
{

View File

@ -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)
{