diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index d0796ae9..cff7d2e1 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1885,8 +1885,8 @@ namespace dxvk { ID3D11SamplerState** ppSamplers) { D3D10DeviceLock lock = LockContext(); - for (uint32_t i = 0; i < NumSamplers; i++) - ppSamplers[i] = ref(m_state.vs.samplers[StartSlot + i]); + GetSamplers(m_state.vs.samplers, + StartSlot, NumSamplers, ppSamplers); } @@ -2027,8 +2027,8 @@ namespace dxvk { ID3D11SamplerState** ppSamplers) { D3D10DeviceLock lock = LockContext(); - for (uint32_t i = 0; i < NumSamplers; i++) - ppSamplers[i] = ref(m_state.hs.samplers[StartSlot + i]); + GetSamplers(m_state.hs.samplers, + StartSlot, NumSamplers, ppSamplers); } @@ -2169,8 +2169,8 @@ namespace dxvk { ID3D11SamplerState** ppSamplers) { D3D10DeviceLock lock = LockContext(); - for (uint32_t i = 0; i < NumSamplers; i++) - ppSamplers[i] = ref(m_state.ds.samplers[StartSlot + i]); + GetSamplers(m_state.ds.samplers, + StartSlot, NumSamplers, ppSamplers); } @@ -2311,8 +2311,8 @@ namespace dxvk { ID3D11SamplerState** ppSamplers) { D3D10DeviceLock lock = LockContext(); - for (uint32_t i = 0; i < NumSamplers; i++) - ppSamplers[i] = ref(m_state.gs.samplers[StartSlot + i]); + GetSamplers(m_state.gs.samplers, + StartSlot, NumSamplers, ppSamplers); } @@ -2453,8 +2453,8 @@ namespace dxvk { ID3D11SamplerState** ppSamplers) { D3D10DeviceLock lock = LockContext(); - for (uint32_t i = 0; i < NumSamplers; i++) - ppSamplers[i] = ref(m_state.ps.samplers[StartSlot + i]); + GetSamplers(m_state.ps.samplers, + StartSlot, NumSamplers, ppSamplers); } @@ -2651,8 +2651,8 @@ namespace dxvk { ID3D11SamplerState** ppSamplers) { D3D10DeviceLock lock = LockContext(); - for (uint32_t i = 0; i < NumSamplers; i++) - ppSamplers[i] = ref(m_state.cs.samplers[StartSlot + i]); + GetSamplers(m_state.cs.samplers, + StartSlot, NumSamplers, ppSamplers); } @@ -3798,6 +3798,19 @@ namespace dxvk { } + void D3D11DeviceContext::GetSamplers( + const D3D11SamplerBindings& Bindings, + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers) { + for (uint32_t i = 0; i < NumSamplers; i++) { + ppSamplers[i] = StartSlot + i < Bindings.size() + ? ref(Bindings[StartSlot + i]) + : nullptr; + } + } + + void D3D11DeviceContext::ResetState() { EmitCs([] (DxvkContext* ctx) { // Reset render targets diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 125b0e5d..4aff746f 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -829,7 +829,13 @@ namespace dxvk { ID3D11Buffer** ppConstantBuffers, UINT* pFirstConstant, UINT* pNumConstants); - + + void GetSamplers( + const D3D11SamplerBindings& Bindings, + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers); + void ResetState(); void RestoreState();