diff options
| author | Dolphin Bot <dolphin-emu-bot@users.noreply.github.com> | 2014-12-11 23:38:35 +0100 |
|---|---|---|
| committer | Dolphin Bot <dolphin-emu-bot@users.noreply.github.com> | 2014-12-11 23:38:35 +0100 |
| commit | 971a95aecef1c4fc3e5aa8799a296d2734526cfc (patch) | |
| tree | 0b1d3a4f8bdd82f276f490c08c4854dedd553fa9 /Source/Core/VideoBackends/D3D/Render.cpp | |
| parent | fe6723066355788a8877f484a8711524a80430e7 (diff) | |
| parent | e90604c5ed4e78780cb56bf969cc80eec57c0199 (diff) | |
Merge pull request #1503 from kayru/d3d_optimization_cache
D3D: Filter redundant API calls by caching state in StateManager
Diffstat (limited to 'Source/Core/VideoBackends/D3D/Render.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/D3D/Render.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index c393afeb50..9d5802ebd8 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -357,7 +357,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) // depth buffers can only be completely CopySubresourceRegion'ed, so we're using drawShadedTexQuad instead D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, 1.f, 1.f); D3D::context->RSSetViewports(1, &vp); - D3D::context->PSSetConstantBuffers(0, 1, &access_efb_cbuf); + D3D::stateman->SetPixelConstants(0, access_efb_cbuf); D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBDepthReadTexture()->GetRTV(), nullptr); D3D::SetPointCopySampler(); D3D::drawShadedTexQuad(FramebufferManager::GetEFBDepthTexture()->GetSRV(), @@ -1007,15 +1007,12 @@ void Renderer::ApplyState(bool bUseDstAlpha) gx_state.raster.wireframe = g_ActiveConfig.bWireFrame; D3D::stateman->PushRasterizerState(gx_state_cache.Get(gx_state.raster)); - ID3D11SamplerState* samplerstate[8]; for (unsigned int stage = 0; stage < 8; stage++) { + // TODO: cache SamplerState directly, not d3d object gx_state.sampler[stage].max_anisotropy = g_ActiveConfig.iMaxAnisotropy; - samplerstate[stage] = gx_state_cache.Get(gx_state.sampler[stage]); + D3D::stateman->SetSampler(stage, gx_state_cache.Get(gx_state.sampler[stage])); } - D3D::context->PSSetSamplers(0, 8, samplerstate); - - D3D::stateman->Apply(); if (bUseDstAlpha) { @@ -1024,12 +1021,14 @@ void Renderer::ApplyState(bool bUseDstAlpha) SetLogicOpMode(); } - ID3D11Buffer* const_buffers[2] = {PixelShaderCache::GetConstantBuffer(), VertexShaderCache::GetConstantBuffer()}; - D3D::context->PSSetConstantBuffers(0, 1 + g_ActiveConfig.bEnablePixelLighting, const_buffers); - D3D::context->VSSetConstantBuffers(0, 1, const_buffers+1); + ID3D11Buffer* vertexConstants = VertexShaderCache::GetConstantBuffer(); + ID3D11Buffer* pixelConstants = PixelShaderCache::GetConstantBuffer(); + + D3D::stateman->SetPixelConstants(pixelConstants, g_ActiveConfig.bEnablePixelLighting ? vertexConstants : nullptr); + D3D::stateman->SetVertexConstants(vertexConstants); - D3D::context->PSSetShader(PixelShaderCache::GetActiveShader(), nullptr, 0); - D3D::context->VSSetShader(VertexShaderCache::GetActiveShader(), nullptr, 0); + D3D::stateman->SetPixelShader(PixelShaderCache::GetActiveShader()); + D3D::stateman->SetVertexShader(VertexShaderCache::GetActiveShader()); } void Renderer::RestoreState() @@ -1046,8 +1045,6 @@ void Renderer::ApplyCullDisable() ID3D11RasterizerState* raststate = gx_state_cache.Get(rast); D3D::stateman->PushRasterizerState(raststate); - - D3D::stateman->Apply(); } void Renderer::RestoreCull() |
