From 34f30969bf9d45bb3212d7b1ee90d229cbf89c28 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sat, 7 Nov 2009 17:50:48 +0000 Subject: [PATCH] GSdx: likely fix for the infamous DX10 memleak and resume/loadstate instabilities. Likely because I don't have DX10 capabilities, so I'm coding blindly as usual. ;) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2150 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDevice10.cpp | 81 +++++++++++++++++++++++++ plugins/GSdx/GSDevice10.h | 8 +++ plugins/GSdx/GSDevice11.cpp | 82 ++++++++++++++++++++++++++ plugins/GSdx/GSDevice11.h | 8 +++ plugins/GSdx/GSDevice9.cpp | 65 ++++++++++++++++++++ plugins/GSdx/GSDevice9.h | 8 +++ plugins/GSdx/GSDeviceDX.h | 2 + plugins/GSdx/GSRendererDX.h | 23 +++++++- plugins/GSdx/GSRendererDX10.cpp | 101 -------------------------------- plugins/GSdx/GSRendererDX10.h | 7 --- plugins/GSdx/GSRendererDX11.cpp | 101 -------------------------------- plugins/GSdx/GSRendererDX11.h | 8 --- plugins/GSdx/GSRendererDX9.cpp | 81 ------------------------- plugins/GSdx/GSRendererDX9.h | 7 --- 14 files changed, 275 insertions(+), 307 deletions(-) diff --git a/plugins/GSdx/GSDevice10.cpp b/plugins/GSdx/GSDevice10.cpp index 42fc3c7304..267aa4d05f 100644 --- a/plugins/GSdx/GSDevice10.cpp +++ b/plugins/GSdx/GSDevice10.cpp @@ -237,6 +237,33 @@ bool GSDevice10::Create(GSWnd* wnd) CreateTextureFX(); + // + + memset(&dsd, 0, sizeof(dsd)); + + dsd.DepthEnable = false; + dsd.StencilEnable = true; + dsd.StencilReadMask = 1; + dsd.StencilWriteMask = 1; + dsd.FrontFace.StencilFunc = D3D10_COMPARISON_ALWAYS; + dsd.FrontFace.StencilPassOp = D3D10_STENCIL_OP_REPLACE; + dsd.FrontFace.StencilFailOp = D3D10_STENCIL_OP_KEEP; + dsd.FrontFace.StencilDepthFailOp = D3D10_STENCIL_OP_KEEP; + dsd.BackFace.StencilFunc = D3D10_COMPARISON_ALWAYS; + dsd.BackFace.StencilPassOp = D3D10_STENCIL_OP_REPLACE; + dsd.BackFace.StencilFailOp = D3D10_STENCIL_OP_KEEP; + dsd.BackFace.StencilDepthFailOp = D3D10_STENCIL_OP_KEEP; + + m_dev->CreateDepthStencilState(&dsd, &m_date.dss); + + D3D10_BLEND_DESC blend; + + memset(&blend, 0, sizeof(blend)); + + m_dev->CreateBlendState(&blend, &m_date.bs); + + // + return true; } @@ -538,6 +565,60 @@ void GSDevice10::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool line StretchRect(st, sr, dt, dr, m_interlace.ps[shader], m_interlace.cb, linear); } +void GSDevice10::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm) +{ + const GSVector2i& size = rt->GetSize(); + + if(GSTexture* t = CreateRenderTarget(size.x, size.y, rt->IsMSAA())) + { + // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows + + BeginScene(); + + ClearStencil(ds, 0); + + // om + + OMSetDepthStencilState(m_date.dss, 1); + OMSetBlendState(m_date.bs, 0); + OMSetRenderTargets(t, ds); + + // ia + + IASetVertexBuffer(iaVertices, sizeof(iaVertices[0]), countof(iaVertices)); + IASetInputLayout(m_convert.il); + IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + + // vs + + VSSetShader(m_convert.vs, NULL); + + // gs + + GSSetShader(NULL); + + // ps + + GSTexture* rt2 = rt->IsMSAA() ? Resolve(rt) : rt; + + PSSetShaderResources(rt2, NULL); + PSSetShader(m_convert.ps[datm ? 2 : 3], NULL); + PSSetSamplerState(m_convert.pt, NULL); + + // + + DrawPrimitive(); + + // + + EndScene(); + + Recycle(t); + + if(rt2 != rt) Recycle(rt2); + } +} + void GSDevice10::IASetVertexBuffer(const void* vertices, size_t stride, size_t count) { ASSERT(m_vertices.count == 0); diff --git a/plugins/GSdx/GSDevice10.h b/plugins/GSdx/GSDevice10.h index 58b6fa1e27..7c2de7a21e 100644 --- a/plugins/GSdx/GSDevice10.h +++ b/plugins/GSdx/GSDevice10.h @@ -88,6 +88,14 @@ public: // TODO CComPtr cb; } m_interlace; + struct + { + CComPtr dss; + CComPtr bs; + } m_date; + + void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm); + CComPtr m_il; hash_map > m_vs; CComPtr m_vs_cb; diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index 2e2d788901..57c0814432 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -228,6 +228,34 @@ bool GSDevice11::Create(GSWnd* wnd) // CreateTextureFX(); + + // + + memset(&dsd, 0, sizeof(dsd)); + + dsd.DepthEnable = false; + dsd.StencilEnable = true; + dsd.StencilReadMask = 1; + dsd.StencilWriteMask = 1; + dsd.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + dsd.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; + dsd.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + dsd.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + dsd.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + dsd.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; + dsd.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + dsd.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; + + m_dev->CreateDepthStencilState(&dsd, &m_date.dss); + + D3D11_BLEND_DESC blend; + + memset(&blend, 0, sizeof(blend)); + + m_dev->CreateBlendState(&blend, &m_date.bs); + + // + return true; } @@ -529,6 +557,60 @@ void GSDevice11::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool line StretchRect(st, sr, dt, dr, m_interlace.ps[shader], m_interlace.cb, linear); } +void GSDevice11::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm) +{ + const GSVector2i& size = rt->GetSize(); + + if(GSTexture* t = CreateRenderTarget(size.x, size.y, rt->IsMSAA())) + { + // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows + + BeginScene(); + + ClearStencil(ds, 0); + + // om + + OMSetDepthStencilState(m_date.dss, 1); + OMSetBlendState(m_date.bs, 0); + OMSetRenderTargets(t, ds); + + // ia + + IASetVertexBuffer(iaVertices, sizeof(iaVertices[0]), countof(iaVertices)); + IASetInputLayout(m_convert.il); + IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + + // vs + + VSSetShader(m_convert.vs, NULL); + + // gs + + GSSetShader(NULL); + + // ps + + GSTexture* rt2 = rt->IsMSAA() ? Resolve(rt) : rt; + + PSSetShaderResources(rt2, NULL); + PSSetShader(m_convert.ps[datm ? 2 : 3], NULL); + PSSetSamplerState(m_convert.pt, NULL); + + // + + DrawPrimitive(); + + // + + EndScene(); + + Recycle(t); + + if(rt2 != rt) Recycle(rt2); + } +} + void GSDevice11::IASetVertexBuffer(const void* vertices, size_t stride, size_t count) { ASSERT(m_vertices.count == 0); diff --git a/plugins/GSdx/GSDevice11.h b/plugins/GSdx/GSDevice11.h index 427cf2331e..d562ce346c 100644 --- a/plugins/GSdx/GSDevice11.h +++ b/plugins/GSdx/GSDevice11.h @@ -89,6 +89,14 @@ public: // TODO CComPtr cb; } m_interlace; + struct + { + CComPtr dss; + CComPtr bs; + } m_date; + + void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm); + // Shaders... CComPtr m_il; diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 4c088aaf20..72133c4450 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -221,6 +221,21 @@ bool GSDevice9::Create(GSWnd* wnd) SetupVS(sel, &cb); + // + + memset(&m_date.dss, 0, sizeof(m_date.dss)); + + m_date.dss.StencilEnable = true; + m_date.dss.StencilReadMask = 1; + m_date.dss.StencilWriteMask = 1; + m_date.dss.StencilFunc = D3DCMP_ALWAYS; + m_date.dss.StencilPassOp = D3DSTENCILOP_REPLACE; + m_date.dss.StencilRef = 1; + + memset(&m_date.bs, 0, sizeof(m_date.bs)); + + // + return true; } @@ -729,6 +744,56 @@ void GSDevice9::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linea StretchRect(st, sr, dt, dr, m_interlace.ps[shader], (const float*)&cb, 1, linear); } +void GSDevice9::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm) +{ + const GSVector2i& size = rt->GetSize(); + + if(GSTexture* t = CreateRenderTarget(size.x, size.y, rt->IsMSAA())) + { + // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows + + BeginScene(); + + ClearStencil(ds, 0); + + // om + + OMSetDepthStencilState(&m_date.dss); + OMSetBlendState(&m_date.bs, 0); + OMSetRenderTargets(t, ds); + + // ia + + IASetVertexBuffer(iaVertices, sizeof(iaVertices[0]), countof(iaVertices)); + IASetInputLayout(m_convert.il); + IASetPrimitiveTopology(D3DPT_TRIANGLESTRIP); + + // vs + + VSSetShader(m_convert.vs, NULL, 0); + + // ps + + GSTexture* rt2 = rt->IsMSAA() ? Resolve(rt) : rt; + + PSSetShaderResources(rt2, NULL); + PSSetShader(m_convert.ps[datm ? 2 : 3], NULL, 0); + PSSetSamplerState(&m_convert.pt); + + // + + DrawPrimitive(); + + // + + EndScene(); + + Recycle(t); + + if(rt2 != rt) Recycle(rt2); + } +} + void GSDevice9::IASetVertexBuffer(const void* vertices, size_t stride, size_t count) { ASSERT(m_vertices.count == 0); diff --git a/plugins/GSdx/GSDevice9.h b/plugins/GSdx/GSDevice9.h index 36734feb28..58d0831c9d 100644 --- a/plugins/GSdx/GSDevice9.h +++ b/plugins/GSdx/GSDevice9.h @@ -124,6 +124,14 @@ public: // TODO CComPtr ps[4]; } m_interlace; + struct + { + Direct3DDepthStencilState9 dss; + Direct3DBlendState9 bs; + } m_date; + + void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm); + // Shaders... CComPtr m_il; diff --git a/plugins/GSdx/GSDeviceDX.h b/plugins/GSdx/GSDeviceDX.h index eb2d906a90..78a478f038 100644 --- a/plugins/GSdx/GSDeviceDX.h +++ b/plugins/GSdx/GSDeviceDX.h @@ -280,4 +280,6 @@ public: virtual void SetupGS(GSSelector sel) = 0; virtual void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel) = 0; virtual void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix) = 0; + + virtual void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm)=0; }; diff --git a/plugins/GSdx/GSRendererDX.h b/plugins/GSdx/GSRendererDX.h index 105f5b2771..cb1422dd52 100644 --- a/plugins/GSdx/GSRendererDX.h +++ b/plugins/GSdx/GSRendererDX.h @@ -35,7 +35,6 @@ class GSRendererDX : public GSRendererHW protected: int m_topology; - virtual void SetupDATE(GSTexture* rt, GSTexture* ds) {} virtual void UpdateFBA(GSTexture* rt) {} public: @@ -67,11 +66,31 @@ public: GSDrawingEnvironment& env = m_env; GSDrawingContext* context = m_context; + assert(m_dev != NULL); + GSDeviceDX& dev = (GSDeviceDX&)*m_dev; // + if(m_context->TEST.DATE) + { + const GSVector2i& size = rt->GetSize(); - SetupDATE(rt, ds); + GSVector4 s = GSVector4(rt->GetScale().x / size.x, rt->GetScale().y / size.y); + GSVector4 o = GSVector4(-1.0f, 1.0f); + + GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); + GSVector4 dst = src * 2.0f + o.xxxx(); + + GSVertexPT1 vertices[] = + { + {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)}, + {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)}, + {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)}, + {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, + }; + + dev.SetupDATE(rt, ds, vertices, m_context->TEST.DATM ); + } // diff --git a/plugins/GSdx/GSRendererDX10.cpp b/plugins/GSdx/GSRendererDX10.cpp index 32bebe2cca..3f63d86ce8 100644 --- a/plugins/GSdx/GSRendererDX10.cpp +++ b/plugins/GSdx/GSRendererDX10.cpp @@ -35,35 +35,6 @@ bool GSRendererDX10::CreateDevice(GSDevice* dev) if(!__super::CreateDevice(dev)) return false; - // - - D3D10_DEPTH_STENCIL_DESC dsd; - - memset(&dsd, 0, sizeof(dsd)); - - dsd.DepthEnable = false; - dsd.StencilEnable = true; - dsd.StencilReadMask = 1; - dsd.StencilWriteMask = 1; - dsd.FrontFace.StencilFunc = D3D10_COMPARISON_ALWAYS; - dsd.FrontFace.StencilPassOp = D3D10_STENCIL_OP_REPLACE; - dsd.FrontFace.StencilFailOp = D3D10_STENCIL_OP_KEEP; - dsd.FrontFace.StencilDepthFailOp = D3D10_STENCIL_OP_KEEP; - dsd.BackFace.StencilFunc = D3D10_COMPARISON_ALWAYS; - dsd.BackFace.StencilPassOp = D3D10_STENCIL_OP_REPLACE; - dsd.BackFace.StencilFailOp = D3D10_STENCIL_OP_KEEP; - dsd.BackFace.StencilDepthFailOp = D3D10_STENCIL_OP_KEEP; - - (*(GSDevice10*)m_dev)->CreateDepthStencilState(&dsd, &m_date.dss); - - D3D10_BLEND_DESC bd; - - memset(&bd, 0, sizeof(bd)); - - (*(GSDevice10*)m_dev)->CreateBlendState(&bd, &m_date.bs); - - // - return true; } @@ -192,75 +163,3 @@ void GSRendererDX10::Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* __super::Draw(rt, ds, tex); } - -void GSRendererDX10::SetupDATE(GSTexture* rt, GSTexture* ds) -{ - if(!m_context->TEST.DATE) return; // || (::GetAsyncKeyState(VK_CONTROL) & 0x8000) - - GSDevice10* dev = (GSDevice10*)m_dev; - - const GSVector2i& size = rt->GetSize(); - - if(GSTexture* t = dev->CreateRenderTarget(size.x, size.y, rt->IsMSAA())) - { - // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows - - dev->BeginScene(); - - dev->ClearStencil(ds, 0); - - // om - - dev->OMSetDepthStencilState(m_date.dss, 1); - dev->OMSetBlendState(m_date.bs, 0); - dev->OMSetRenderTargets(t, ds); - - // ia - - GSVector4 s = GSVector4(rt->GetScale().x / size.x, rt->GetScale().y / size.y); - GSVector4 o = GSVector4(-1.0f, 1.0f); - - GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); - GSVector4 dst = src * 2.0f + o.xxxx(); - - GSVertexPT1 vertices[] = - { - {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)}, - {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)}, - {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)}, - {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, - }; - - dev->IASetVertexBuffer(vertices, sizeof(vertices[0]), countof(vertices)); - dev->IASetInputLayout(dev->m_convert.il); - dev->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - - // vs - - dev->VSSetShader(dev->m_convert.vs, NULL); - - // gs - - dev->GSSetShader(NULL); - - // ps - - GSTexture* rt2 = rt->IsMSAA() ? dev->Resolve(rt) : rt; - - dev->PSSetShaderResources(rt2, NULL); - dev->PSSetShader(dev->m_convert.ps[m_context->TEST.DATM ? 2 : 3], NULL); - dev->PSSetSamplerState(dev->m_convert.pt, NULL); - - // - - dev->DrawPrimitive(); - - // - - dev->EndScene(); - - dev->Recycle(t); - - if(rt2 != rt) dev->Recycle(rt2); - } -} diff --git a/plugins/GSdx/GSRendererDX10.h b/plugins/GSdx/GSRendererDX10.h index c3899a1792..7f386b5e6d 100644 --- a/plugins/GSdx/GSRendererDX10.h +++ b/plugins/GSdx/GSRendererDX10.h @@ -28,14 +28,7 @@ class GSRendererDX10 : public GSRendererDX { protected: - struct - { - CComPtr dss; - CComPtr bs; - } m_date; - void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex); - void SetupDATE(GSTexture* rt, GSTexture* ds); public: GSRendererDX10(); diff --git a/plugins/GSdx/GSRendererDX11.cpp b/plugins/GSdx/GSRendererDX11.cpp index d7eeb0a46c..4106eee355 100644 --- a/plugins/GSdx/GSRendererDX11.cpp +++ b/plugins/GSdx/GSRendererDX11.cpp @@ -35,35 +35,6 @@ bool GSRendererDX11::CreateDevice(GSDevice* dev) if(!__super::CreateDevice(dev)) return false; - // - - D3D11_DEPTH_STENCIL_DESC dsd; - - memset(&dsd, 0, sizeof(dsd)); - - dsd.DepthEnable = false; - dsd.StencilEnable = true; - dsd.StencilReadMask = 1; - dsd.StencilWriteMask = 1; - dsd.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - dsd.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; - dsd.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; - dsd.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - dsd.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - dsd.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; - dsd.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; - dsd.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; - - (*(GSDevice11*)m_dev)->CreateDepthStencilState(&dsd, &m_date.dss); - - D3D11_BLEND_DESC bd; - - memset(&bd, 0, sizeof(bd)); - - (*(GSDevice11*)m_dev)->CreateBlendState(&bd, &m_date.bs); - - // - return true; } @@ -192,75 +163,3 @@ void GSRendererDX11::Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* __super::Draw(rt, ds, tex); } - -void GSRendererDX11::SetupDATE(GSTexture* rt, GSTexture* ds) -{ - if(!m_context->TEST.DATE) return; // || (::GetAsyncKeyState(VK_CONTROL) & 0x8000) - - GSDevice11* dev = (GSDevice11*)m_dev; - - const GSVector2i& size = rt->GetSize(); - - if(GSTexture* t = dev->CreateRenderTarget(size.x, size.y, rt->IsMSAA())) - { - // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows - - dev->BeginScene(); - - dev->ClearStencil(ds, 0); - - // om - - dev->OMSetDepthStencilState(m_date.dss, 1); - dev->OMSetBlendState(m_date.bs, 0); - dev->OMSetRenderTargets(t, ds); - - // ia - - GSVector4 s = GSVector4(rt->GetScale().x / size.x, rt->GetScale().y / size.y); - GSVector4 o = GSVector4(-1.0f, 1.0f); - - GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); - GSVector4 dst = src * 2.0f + o.xxxx(); - - GSVertexPT1 vertices[] = - { - {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)}, - {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)}, - {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)}, - {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, - }; - - dev->IASetVertexBuffer(vertices, sizeof(vertices[0]), countof(vertices)); - dev->IASetInputLayout(dev->m_convert.il); - dev->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - - // vs - - dev->VSSetShader(dev->m_convert.vs, NULL); - - // gs - - dev->GSSetShader(NULL); - - // ps - - GSTexture* rt2 = rt->IsMSAA() ? dev->Resolve(rt) : rt; - - dev->PSSetShaderResources(rt2, NULL); - dev->PSSetShader(dev->m_convert.ps[m_context->TEST.DATM ? 2 : 3], NULL); - dev->PSSetSamplerState(dev->m_convert.pt, NULL); - - // - - dev->DrawPrimitive(); - - // - - dev->EndScene(); - - dev->Recycle(t); - - if(rt2 != rt) dev->Recycle(rt2); - } -} diff --git a/plugins/GSdx/GSRendererDX11.h b/plugins/GSdx/GSRendererDX11.h index f1e5290891..0f564a88cc 100644 --- a/plugins/GSdx/GSRendererDX11.h +++ b/plugins/GSdx/GSRendererDX11.h @@ -30,14 +30,6 @@ class GSRendererDX11 : public GSRendererDX protected: void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex); - struct - { - CComPtr dss; - CComPtr bs; - } m_date; - - void SetupDATE(GSTexture* rt, GSTexture* ds); - public: GSRendererDX11(); virtual ~GSRendererDX11() {} diff --git a/plugins/GSdx/GSRendererDX9.cpp b/plugins/GSdx/GSRendererDX9.cpp index 78135c2742..b1cc135e59 100644 --- a/plugins/GSdx/GSRendererDX9.cpp +++ b/plugins/GSdx/GSRendererDX9.cpp @@ -37,19 +37,6 @@ bool GSRendererDX9::CreateDevice(GSDevice* dev) // - memset(&m_date.dss, 0, sizeof(m_date.dss)); - - m_date.dss.StencilEnable = true; - m_date.dss.StencilReadMask = 1; - m_date.dss.StencilWriteMask = 1; - m_date.dss.StencilFunc = D3DCMP_ALWAYS; - m_date.dss.StencilPassOp = D3DSTENCILOP_REPLACE; - m_date.dss.StencilRef = 1; - - memset(&m_date.bs, 0, sizeof(m_date.bs)); - - // - memset(&m_fba.dss, 0, sizeof(m_fba.dss)); m_fba.dss.StencilEnable = true; @@ -210,74 +197,6 @@ void GSRendererDX9::Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t __super::Draw(rt, ds, tex); } -void GSRendererDX9::SetupDATE(GSTexture* rt, GSTexture* ds) -{ - if(!m_context->TEST.DATE) return; // || (::GetAsyncKeyState(VK_CONTROL) & 0x8000) - - GSDevice9* dev = (GSDevice9*)m_dev; - - const GSVector2i& size = rt->GetSize(); - - if(GSTexture* t = dev->CreateRenderTarget(size.x, size.y, rt->IsMSAA())) - { - // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows - - dev->BeginScene(); - - dev->ClearStencil(ds, 0); - - // om - - dev->OMSetDepthStencilState(&m_date.dss); - dev->OMSetBlendState(&m_date.bs, 0); - dev->OMSetRenderTargets(t, ds); - - // ia - - GSVector4 s = GSVector4(rt->GetScale().x / size.x, rt->GetScale().y / size.y); - GSVector4 o = GSVector4(-1.0f, 1.0f); - - GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); - GSVector4 dst = src * 2.0f + o.xxxx(); - - GSVertexPT1 vertices[] = - { - {GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)}, - {GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)}, - {GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)}, - {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, - }; - - dev->IASetVertexBuffer(vertices, sizeof(vertices[0]), countof(vertices)); - dev->IASetInputLayout(dev->m_convert.il); - dev->IASetPrimitiveTopology(D3DPT_TRIANGLESTRIP); - - // vs - - dev->VSSetShader(dev->m_convert.vs, NULL, 0); - - // ps - - GSTexture* rt2 = rt->IsMSAA() ? dev->Resolve(rt) : rt; - - dev->PSSetShaderResources(rt2, NULL); - dev->PSSetShader(dev->m_convert.ps[m_context->TEST.DATM ? 2 : 3], NULL, 0); - dev->PSSetSamplerState(&dev->m_convert.pt); - - // - - dev->DrawPrimitive(); - - // - - dev->EndScene(); - - dev->Recycle(t); - - if(rt2 != rt) dev->Recycle(rt2); - } -} - void GSRendererDX9::UpdateFBA(GSTexture* rt) { GSDevice9* dev = (GSDevice9*)m_dev; diff --git a/plugins/GSdx/GSRendererDX9.h b/plugins/GSdx/GSRendererDX9.h index a94575a028..8c6b099292 100644 --- a/plugins/GSdx/GSRendererDX9.h +++ b/plugins/GSdx/GSRendererDX9.h @@ -28,12 +28,6 @@ class GSRendererDX9 : public GSRendererDX { protected: - struct - { - Direct3DDepthStencilState9 dss; - Direct3DBlendState9 bs; - } m_date; - struct { Direct3DDepthStencilState9 dss; @@ -41,7 +35,6 @@ protected: } m_fba; void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex); - void SetupDATE(GSTexture* rt, GSTexture* ds); void UpdateFBA(GSTexture* rt); public: