summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/D3D/XFBEncoder.cpp
diff options
context:
space:
mode:
authorDolphin Bot <dolphin-emu-bot@users.noreply.github.com>2014-12-11 23:38:35 +0100
committerDolphin Bot <dolphin-emu-bot@users.noreply.github.com>2014-12-11 23:38:35 +0100
commit971a95aecef1c4fc3e5aa8799a296d2734526cfc (patch)
tree0b1d3a4f8bdd82f276f490c08c4854dedd553fa9 /Source/Core/VideoBackends/D3D/XFBEncoder.cpp
parentfe6723066355788a8877f484a8711524a80430e7 (diff)
parente90604c5ed4e78780cb56bf969cc80eec57c0199 (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/XFBEncoder.cpp')
-rw-r--r--Source/Core/VideoBackends/D3D/XFBEncoder.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/Source/Core/VideoBackends/D3D/XFBEncoder.cpp b/Source/Core/VideoBackends/D3D/XFBEncoder.cpp
index 50524d8a3d..fb56363e31 100644
--- a/Source/Core/VideoBackends/D3D/XFBEncoder.cpp
+++ b/Source/Core/VideoBackends/D3D/XFBEncoder.cpp
@@ -280,22 +280,21 @@ void XFBEncoder::Encode(u8* dst, u32 width, u32 height, const EFBRectangle& srcR
// Set up all the state for XFB encoding
- D3D::context->PSSetShader(m_pShader, nullptr, 0);
- D3D::context->VSSetShader(m_vShader, nullptr, 0);
+ D3D::stateman->SetPixelShader(m_pShader);
+ D3D::stateman->SetVertexShader(m_vShader);
D3D::stateman->PushBlendState(m_xfbEncodeBlendState);
D3D::stateman->PushDepthState(m_xfbEncodeDepthState);
D3D::stateman->PushRasterizerState(m_xfbEncodeRastState);
- D3D::stateman->Apply();
D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, FLOAT(width/2), FLOAT(height));
D3D::context->RSSetViewports(1, &vp);
- D3D::context->IASetInputLayout(m_quadLayout);
- D3D::context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+ D3D::stateman->SetInputLayout(m_quadLayout);
+ D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
UINT stride = sizeof(QuadVertex);
UINT offset = 0;
- D3D::context->IASetVertexBuffers(0, 1, &m_quad, &stride, &offset);
+ D3D::stateman->SetVertexBuffer(m_quad, stride, offset);
TargetRectangle targetRect = g_renderer->ConvertEFBRectangle(srcRect);
@@ -309,18 +308,18 @@ void XFBEncoder::Encode(u8* dst, u32 width, u32 height, const EFBRectangle& srcR
params.Gamma = gamma;
D3D::context->UpdateSubresource(m_encodeParams, 0, nullptr, &params, 0, 0);
- D3D::context->VSSetConstantBuffers(0, 1, &m_encodeParams);
-
D3D::context->OMSetRenderTargets(1, &m_outRTV, nullptr);
ID3D11ShaderResourceView* pEFB = FramebufferManager::GetEFBColorTexture()->GetSRV();
- D3D::context->PSSetConstantBuffers(0, 1, &m_encodeParams);
- D3D::context->PSSetShaderResources(0, 1, &pEFB);
- D3D::context->PSSetSamplers(0, 1, &m_efbSampler);
+ D3D::stateman->SetVertexConstants(m_encodeParams);
+ D3D::stateman->SetPixelConstants(m_encodeParams);
+ D3D::stateman->SetTexture(0, pEFB);
+ D3D::stateman->SetSampler(0, m_efbSampler);
// Encode!
+ D3D::stateman->Apply();
D3D::context->Draw(4, 0);
// Copy to staging buffer
@@ -330,23 +329,20 @@ void XFBEncoder::Encode(u8* dst, u32 width, u32 height, const EFBRectangle& srcR
// Clean up state
- IUnknown* nullDummy = nullptr;
-
- D3D::context->PSSetSamplers(0, 1, (ID3D11SamplerState**)&nullDummy);
- D3D::context->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&nullDummy);
- D3D::context->PSSetConstantBuffers(0, 1, (ID3D11Buffer**)&nullDummy);
-
D3D::context->OMSetRenderTargets(0, nullptr, nullptr);
- D3D::context->VSSetConstantBuffers(0, 1, (ID3D11Buffer**)&nullDummy);
+ D3D::stateman->SetSampler(0, nullptr);
+ D3D::stateman->SetTexture(0, nullptr);
+ D3D::stateman->SetPixelConstants(nullptr);
+ D3D::stateman->SetVertexConstants(nullptr);
+
+ D3D::stateman->SetPixelShader(nullptr);
+ D3D::stateman->SetVertexShader(nullptr);
D3D::stateman->PopRasterizerState();
D3D::stateman->PopDepthState();
D3D::stateman->PopBlendState();
- D3D::context->PSSetShader(nullptr, nullptr, 0);
- D3D::context->VSSetShader(nullptr, nullptr, 0);
-
// Transfer staging buffer to GameCube/Wii RAM
D3D11_MAPPED_SUBRESOURCE map = { 0 };