mirror of https://github.com/PCSX2/pcsx2.git
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
This commit is contained in:
parent
d114d698a2
commit
34f30969bf
|
@ -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);
|
||||
|
|
|
@ -88,6 +88,14 @@ public: // TODO
|
|||
CComPtr<ID3D10Buffer> cb;
|
||||
} m_interlace;
|
||||
|
||||
struct
|
||||
{
|
||||
CComPtr<ID3D10DepthStencilState> dss;
|
||||
CComPtr<ID3D10BlendState> bs;
|
||||
} m_date;
|
||||
|
||||
void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm);
|
||||
|
||||
CComPtr<ID3D10InputLayout> m_il;
|
||||
hash_map<uint32, CComPtr<ID3D10VertexShader> > m_vs;
|
||||
CComPtr<ID3D10Buffer> m_vs_cb;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -89,6 +89,14 @@ public: // TODO
|
|||
CComPtr<ID3D11Buffer> cb;
|
||||
} m_interlace;
|
||||
|
||||
struct
|
||||
{
|
||||
CComPtr<ID3D11DepthStencilState> dss;
|
||||
CComPtr<ID3D11BlendState> bs;
|
||||
} m_date;
|
||||
|
||||
void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm);
|
||||
|
||||
// Shaders...
|
||||
|
||||
CComPtr<ID3D11InputLayout> m_il;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -124,6 +124,14 @@ public: // TODO
|
|||
CComPtr<IDirect3DPixelShader9> 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<IDirect3DVertexDeclaration9> m_il;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -35,7 +35,6 @@ class GSRendererDX : public GSRendererHW<Vertex>
|
|||
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 );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,14 +28,7 @@
|
|||
class GSRendererDX10 : public GSRendererDX<GSVertexHW10>
|
||||
{
|
||||
protected:
|
||||
struct
|
||||
{
|
||||
CComPtr<ID3D10DepthStencilState> dss;
|
||||
CComPtr<ID3D10BlendState> bs;
|
||||
} m_date;
|
||||
|
||||
void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex);
|
||||
void SetupDATE(GSTexture* rt, GSTexture* ds);
|
||||
|
||||
public:
|
||||
GSRendererDX10();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,14 +30,6 @@ class GSRendererDX11 : public GSRendererDX<GSVertexHW11>
|
|||
protected:
|
||||
void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex);
|
||||
|
||||
struct
|
||||
{
|
||||
CComPtr<ID3D11DepthStencilState> dss;
|
||||
CComPtr<ID3D11BlendState> bs;
|
||||
} m_date;
|
||||
|
||||
void SetupDATE(GSTexture* rt, GSTexture* ds);
|
||||
|
||||
public:
|
||||
GSRendererDX11();
|
||||
virtual ~GSRendererDX11() {}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -28,12 +28,6 @@
|
|||
class GSRendererDX9 : public GSRendererDX<GSVertexHW9>
|
||||
{
|
||||
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:
|
||||
|
|
Loading…
Reference in New Issue