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
This commit is contained in:
NeoBrainX 2011-01-24 09:27:16 +00:00
parent 50c1baf8de
commit cd5a2e4cc5
3 changed files with 15 additions and 17 deletions

View File

@ -40,9 +40,6 @@ EmuGfxState::EmuGfxState() : vertexshader(NULL), vsbytecode(NULL), pixelshader(N
blenddesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; blenddesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
blenddesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; 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; pscbuf = NULL;
vscbuf = NULL; vscbuf = NULL;
vshaderchanged = false; vshaderchanged = false;
@ -162,14 +159,6 @@ void EmuGfxState::ApplyState()
SetDebugObjectName((ID3D11DeviceChild*)blstate, "a blend state of EmuGfxState"); SetDebugObjectName((ID3D11DeviceChild*)blstate, "a blend state of EmuGfxState");
SAFE_RELEASE(blstate); 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->PSSetShader(pixelshader, NULL, 0);
context->VSSetShader(vertexshader, NULL, 0); context->VSSetShader(vertexshader, NULL, 0);
@ -181,7 +170,6 @@ void EmuGfxState::Reset()
if (apply_called) if (apply_called)
{ {
stateman->PopBlendState(); stateman->PopBlendState();
stateman->PopRasterizerState();
apply_called = false; apply_called = false;
} }
} }

View File

@ -50,8 +50,6 @@ public:
void SetDstAlpha(bool enable); void SetDstAlpha(bool enable);
D3D11_RASTERIZER_DESC rastdesc;
float psconstants[C_PENVCONST_END*4]; float psconstants[C_PENVCONST_END*4];
float vsconstants[C_VENVCONST_END*4]; float vsconstants[C_VENVCONST_END*4];
bool vscbufchanged; bool vscbufchanged;

View File

@ -69,6 +69,7 @@ struct
{ {
D3D11_SAMPLER_DESC sampdc[8]; D3D11_SAMPLER_DESC sampdc[8];
D3D11_DEPTH_STENCIL_DESC depthdc; D3D11_DEPTH_STENCIL_DESC depthdc;
D3D11_RASTERIZER_DESC rastdc;
} gx_state; } gx_state;
bool reset_called = false; bool reset_called = false;
@ -354,6 +355,9 @@ Renderer::Renderer()
gx_state.depthdc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK; gx_state.depthdc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
gx_state.depthdc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_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++) for (unsigned int k = 0;k < 8;k++)
{ {
float border[4] = {0.f, 0.f, 0.f, 0.f}; float border[4] = {0.f, 0.f, 0.f, 0.f};
@ -375,7 +379,6 @@ Renderer::Renderer()
D3D::context->RSSetViewports(1, &vp); D3D::context->RSSetViewports(1, &vp);
D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), FramebufferManager::GetEFBDepthTexture()->GetDSV()); D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), FramebufferManager::GetEFBDepthTexture()->GetDSV());
D3D::BeginFrame(); D3D::BeginFrame();
D3D::gfxstate->rastdesc.ScissorEnable = TRUE;
reset_called = false; reset_called = false;
} }
@ -1108,6 +1111,14 @@ void Renderer::ApplyState()
D3D::stateman->PushDepthState(depth_state); D3D::stateman->PushDepthState(depth_state);
SAFE_RELEASE(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]; ID3D11SamplerState* samplerstate[8];
for (unsigned int stage = 0; stage < 8; stage++) for (unsigned int stage = 0; stage < 8; stage++)
{ {
@ -1134,12 +1145,13 @@ void Renderer::RestoreState()
D3D::context->PSSetShaderResources(0, 8, shader_resources); D3D::context->PSSetShaderResources(0, 8, shader_resources);
D3D::stateman->PopDepthState(); D3D::stateman->PopDepthState();
D3D::stateman->PopRasterizerState();
} }
void Renderer::SetGenerationMode() void Renderer::SetGenerationMode()
{ {
// rastdesc.FrontCounterClockwise must be false for this to work // rastdc.FrontCounterClockwise must be false for this to work
D3D::gfxstate->rastdesc.CullMode = d3dCullModes[bpmem.genMode.cullmode]; gx_state.rastdc.CullMode = d3dCullModes[bpmem.genMode.cullmode];
} }
void Renderer::SetDepthMode() void Renderer::SetDepthMode()