diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 7c310411b..054560088 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -4880,29 +4880,16 @@ namespace dxvk { for (uint32_t i = 0; i < m_state.so.targets.size(); i++) BindXfbBuffer(i, m_state.so.targets[i].buffer.ptr(), ~0u); - RestoreConstantBuffers(); - RestoreConstantBuffers(); - RestoreConstantBuffers(); - RestoreConstantBuffers(); - RestoreConstantBuffers(); - RestoreConstantBuffers(); + for (uint32_t i = 0; i < uint32_t(DxbcProgramType::Count); i++) { + auto stage = DxbcProgramType(i); - RestoreShaderResources(); - RestoreShaderResources(); - RestoreShaderResources(); - RestoreShaderResources(); - RestoreShaderResources(); - RestoreShaderResources(); + RestoreConstantBuffers(stage); + RestoreShaderResources(stage); + RestoreSamplers(stage); + } - RestoreUnorderedAccessViews(); - RestoreUnorderedAccessViews(); - - RestoreSamplers(); - RestoreSamplers(); - RestoreSamplers(); - RestoreSamplers(); - RestoreSamplers(); - RestoreSamplers(); + RestoreUnorderedAccessViews(DxbcProgramType::PixelShader); + RestoreUnorderedAccessViews(DxbcProgramType::ComputeShader); // Draw buffer bindings aren't persistent at the API level, and // we can't meaningfully track them. Just reset this state here @@ -4912,9 +4899,10 @@ namespace dxvk { template - template - void D3D11CommonContext::RestoreConstantBuffers() { + void D3D11CommonContext::RestoreConstantBuffers( + DxbcProgramType Stage) { const auto& bindings = m_state.cbv[Stage]; + for (uint32_t i = 0; i < bindings.maxCount; i++) { BindConstantBuffer(Stage, i, bindings.buffers[i].buffer.ptr(), bindings.buffers[i].constantOffset, bindings.buffers[i].constantBound); @@ -4923,26 +4911,28 @@ namespace dxvk { template - template - void D3D11CommonContext::RestoreSamplers() { + void D3D11CommonContext::RestoreSamplers( + DxbcProgramType Stage) { const auto& bindings = m_state.samplers[Stage]; + for (uint32_t i = 0; i < bindings.maxCount; i++) BindSampler(Stage, i, bindings.samplers[i]); } template - template - void D3D11CommonContext::RestoreShaderResources() { + void D3D11CommonContext::RestoreShaderResources( + DxbcProgramType Stage) { const auto& bindings = m_state.srv[Stage]; + for (uint32_t i = 0; i < bindings.maxCount; i++) BindShaderResource(Stage, i, bindings.views[i].ptr()); } template - template - void D3D11CommonContext::RestoreUnorderedAccessViews() { + void D3D11CommonContext::RestoreUnorderedAccessViews( + DxbcProgramType Stage) { const auto& views = Stage == DxbcProgramType::ComputeShader ? m_state.uav.views : m_state.om.uavs; diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 8196de0bd..0f95ed414 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -1014,18 +1014,18 @@ namespace dxvk { void RestoreCommandListState(); - template - void RestoreConstantBuffers(); - - template - void RestoreSamplers(); - - template - void RestoreShaderResources(); - - template - void RestoreUnorderedAccessViews(); + void RestoreConstantBuffers( + DxbcProgramType Stage); + void RestoreSamplers( + DxbcProgramType Stage); + + void RestoreShaderResources( + DxbcProgramType Stage); + + void RestoreUnorderedAccessViews( + DxbcProgramType Stage); + template void SetConstantBuffers( UINT StartSlot,