From cd5a2e4cc5fafc85343da629b805dc9797008866 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Mon, 24 Jan 2011 09:27:16 +0000 Subject: [PATCH] DX11 code maintenance, part 3: Move rasterizer state management from EmuGfxState to Renderer. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6904 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugins/Plugin_VideoDX11/Src/GfxState.cpp | 12 ------------ Source/Plugins/Plugin_VideoDX11/Src/GfxState.h | 2 -- Source/Plugins/Plugin_VideoDX11/Src/Render.cpp | 18 +++++++++++++++--- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp b/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp index 4ebcda6426..b9002f0a44 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp @@ -40,9 +40,6 @@ EmuGfxState::EmuGfxState() : vertexshader(NULL), vsbytecode(NULL), pixelshader(N blenddesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; blenddesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - // this probably must be changed once multisampling support gets added - rastdesc = CD3D11_RASTERIZER_DESC(D3D11_FILL_SOLID, D3D11_CULL_NONE, false, 0, 0.f, 0, false, true, false, false); - pscbuf = NULL; vscbuf = NULL; vshaderchanged = false; @@ -162,14 +159,6 @@ void EmuGfxState::ApplyState() SetDebugObjectName((ID3D11DeviceChild*)blstate, "a blend state of EmuGfxState"); SAFE_RELEASE(blstate); - rastdesc.FillMode = (g_ActiveConfig.bWireFrame) ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID; - ID3D11RasterizerState* raststate; - hr = device->CreateRasterizerState(&rastdesc, &raststate); - if (FAILED(hr)) PanicAlert("Failed to create rasterizer state at %s %d\n", __FILE__, __LINE__); - SetDebugObjectName((ID3D11DeviceChild*)raststate, "a rasterizer state of EmuGfxState"); - stateman->PushRasterizerState(raststate); - SAFE_RELEASE(raststate); - context->PSSetShader(pixelshader, NULL, 0); context->VSSetShader(vertexshader, NULL, 0); @@ -181,7 +170,6 @@ void EmuGfxState::Reset() if (apply_called) { stateman->PopBlendState(); - stateman->PopRasterizerState(); apply_called = false; } } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/GfxState.h b/Source/Plugins/Plugin_VideoDX11/Src/GfxState.h index b495dcce7a..e360110b95 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/GfxState.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/GfxState.h @@ -50,8 +50,6 @@ public: void SetDstAlpha(bool enable); - D3D11_RASTERIZER_DESC rastdesc; - float psconstants[C_PENVCONST_END*4]; float vsconstants[C_VENVCONST_END*4]; bool vscbufchanged; diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp index d28d189714..5b52516d1a 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp @@ -69,6 +69,7 @@ struct { D3D11_SAMPLER_DESC sampdc[8]; D3D11_DEPTH_STENCIL_DESC depthdc; + D3D11_RASTERIZER_DESC rastdc; } gx_state; bool reset_called = false; @@ -354,6 +355,9 @@ Renderer::Renderer() gx_state.depthdc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK; gx_state.depthdc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK; + // TODO: Do we need to enable multisampling here? + gx_state.rastdc = CD3D11_RASTERIZER_DESC(D3D11_FILL_SOLID, D3D11_CULL_NONE, false, 0, 0.f, 0, false, true, false, false); + for (unsigned int k = 0;k < 8;k++) { float border[4] = {0.f, 0.f, 0.f, 0.f}; @@ -375,7 +379,6 @@ Renderer::Renderer() D3D::context->RSSetViewports(1, &vp); D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), FramebufferManager::GetEFBDepthTexture()->GetDSV()); D3D::BeginFrame(); - D3D::gfxstate->rastdesc.ScissorEnable = TRUE; reset_called = false; } @@ -1108,6 +1111,14 @@ void Renderer::ApplyState() D3D::stateman->PushDepthState(depth_state); SAFE_RELEASE(depth_state); + gx_state.rastdc.FillMode = (g_ActiveConfig.bWireFrame) ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID; + ID3D11RasterizerState* raststate; + hr = D3D::device->CreateRasterizerState(&gx_state.rastdc, &raststate); + if (FAILED(hr)) PanicAlert("Failed to create rasterizer state at %s %d\n", __FILE__, __LINE__); + D3D::SetDebugObjectName((ID3D11DeviceChild*)raststate, "rasterizer state used to emulate the GX pipeline"); + D3D::stateman->PushRasterizerState(raststate); + SAFE_RELEASE(raststate); + ID3D11SamplerState* samplerstate[8]; for (unsigned int stage = 0; stage < 8; stage++) { @@ -1134,12 +1145,13 @@ void Renderer::RestoreState() D3D::context->PSSetShaderResources(0, 8, shader_resources); D3D::stateman->PopDepthState(); + D3D::stateman->PopRasterizerState(); } void Renderer::SetGenerationMode() { - // rastdesc.FrontCounterClockwise must be false for this to work - D3D::gfxstate->rastdesc.CullMode = d3dCullModes[bpmem.genMode.cullmode]; + // rastdc.FrontCounterClockwise must be false for this to work + gx_state.rastdc.CullMode = d3dCullModes[bpmem.genMode.cullmode]; } void Renderer::SetDepthMode()