diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 9e521762d..48f36906c 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1284,139 +1284,6 @@ namespace dxvk { } - void STDMETHODCALLTYPE D3D11DeviceContext::VSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - SetSamplers( - m_state.vs.samplers, - StartSlot, NumSamplers, - ppSamplers); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::VSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - GetSamplers(m_state.vs.samplers, - StartSlot, NumSamplers, ppSamplers); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::HSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - SetSamplers( - m_state.hs.samplers, - StartSlot, NumSamplers, - ppSamplers); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::HSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - GetSamplers(m_state.hs.samplers, - StartSlot, NumSamplers, ppSamplers); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::DSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - SetSamplers( - m_state.ds.samplers, - StartSlot, NumSamplers, - ppSamplers); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::DSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - GetSamplers(m_state.ds.samplers, - StartSlot, NumSamplers, ppSamplers); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::GSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - SetSamplers( - m_state.gs.samplers, - StartSlot, NumSamplers, - ppSamplers); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::GSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - GetSamplers(m_state.gs.samplers, - StartSlot, NumSamplers, ppSamplers); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::PSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - SetSamplers( - m_state.ps.samplers, - StartSlot, NumSamplers, - ppSamplers); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::PSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - GetSamplers(m_state.ps.samplers, - StartSlot, NumSamplers, ppSamplers); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::CSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - SetSamplers( - m_state.cs.samplers, - StartSlot, NumSamplers, - ppSamplers); - } - - void STDMETHODCALLTYPE D3D11DeviceContext::CSSetUnorderedAccessViews( UINT StartSlot, UINT NumUAVs, @@ -1473,17 +1340,6 @@ namespace dxvk { } - void STDMETHODCALLTYPE D3D11DeviceContext::CSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers) { - D3D10DeviceLock lock = LockContext(); - - GetSamplers(m_state.cs.samplers, - StartSlot, NumSamplers, ppSamplers); - } - - void STDMETHODCALLTYPE D3D11DeviceContext::CSGetUnorderedAccessViews( UINT StartSlot, UINT NumUAVs, @@ -2794,38 +2650,6 @@ namespace dxvk { } - template - void D3D11DeviceContext::SetSamplers( - D3D11SamplerBindings& Bindings, - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers) { - uint32_t slotId = computeSamplerBinding(ShaderStage, StartSlot); - - for (uint32_t i = 0; i < NumSamplers; i++) { - auto sampler = static_cast(ppSamplers[i]); - - if (Bindings[StartSlot + i] != sampler) { - Bindings[StartSlot + i] = sampler; - BindSampler(slotId + i, sampler); - } - } - } - - - 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 d975da86a..bf093c0b0 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -208,72 +208,12 @@ namespace dxvk { ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs); - void STDMETHODCALLTYPE VSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers); - - void STDMETHODCALLTYPE VSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers); - - void STDMETHODCALLTYPE HSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers); - - void STDMETHODCALLTYPE HSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers); - - void STDMETHODCALLTYPE DSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers); - - void STDMETHODCALLTYPE DSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers); - - void STDMETHODCALLTYPE GSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers); - - void STDMETHODCALLTYPE GSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers); - - void STDMETHODCALLTYPE PSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers); - - void STDMETHODCALLTYPE PSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers); - - void STDMETHODCALLTYPE CSSetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers); - void STDMETHODCALLTYPE CSSetUnorderedAccessViews( UINT StartSlot, UINT NumUAVs, ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, const UINT* pUAVInitialCounts); - void STDMETHODCALLTYPE CSGetSamplers( - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers); - void STDMETHODCALLTYPE CSGetUnorderedAccessViews( UINT StartSlot, UINT NumUAVs, @@ -478,19 +418,6 @@ namespace dxvk { ID3D11Buffer* pBufferForArgs, ID3D11Buffer* pBufferForCount); - template - void SetSamplers( - D3D11SamplerBindings& Bindings, - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState* const* ppSamplers); - - void GetSamplers( - const D3D11SamplerBindings& Bindings, - UINT StartSlot, - UINT NumSamplers, - ID3D11SamplerState** ppSamplers); - void ResetState(); void RestoreState(); diff --git a/src/d3d11/d3d11_context_common.cpp b/src/d3d11/d3d11_context_common.cpp index 27adbdbc1..832c806c7 100644 --- a/src/d3d11/d3d11_context_common.cpp +++ b/src/d3d11/d3d11_context_common.cpp @@ -311,6 +311,20 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::VSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + SetSamplers( + m_state.vs.samplers, + StartSlot, NumSamplers, + ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::VSGetShader( ID3D11VertexShader** ppVertexShader, @@ -371,6 +385,18 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::VSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + GetSamplers(m_state.vs.samplers, + StartSlot, NumSamplers, ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::HSSetShader( ID3D11HullShader* pHullShader, @@ -437,6 +463,20 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::HSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + SetSamplers( + m_state.hs.samplers, + StartSlot, NumSamplers, + ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::HSGetShader( ID3D11HullShader** ppHullShader, @@ -497,6 +537,18 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::HSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + GetSamplers(m_state.hs.samplers, + StartSlot, NumSamplers, ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::DSSetShader( ID3D11DomainShader* pDomainShader, @@ -563,6 +615,20 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::DSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + SetSamplers( + m_state.ds.samplers, + StartSlot, NumSamplers, + ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::DSGetShader( ID3D11DomainShader** ppDomainShader, @@ -623,6 +689,18 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::DSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + GetSamplers(m_state.ds.samplers, + StartSlot, NumSamplers, ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::GSSetShader( ID3D11GeometryShader* pShader, @@ -689,6 +767,20 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::GSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + SetSamplers( + m_state.gs.samplers, + StartSlot, NumSamplers, + ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::GSGetShader( ID3D11GeometryShader** ppGeometryShader, @@ -749,6 +841,18 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::GSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + GetSamplers(m_state.gs.samplers, + StartSlot, NumSamplers, ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::PSSetShader( ID3D11PixelShader* pPixelShader, @@ -815,6 +919,20 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::PSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + SetSamplers( + m_state.ps.samplers, + StartSlot, NumSamplers, + ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::PSGetShader( ID3D11PixelShader** ppPixelShader, @@ -875,6 +993,18 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::PSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + GetSamplers(m_state.ps.samplers, + StartSlot, NumSamplers, ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::CSSetShader( ID3D11ComputeShader* pComputeShader, @@ -941,6 +1071,20 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::CSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + SetSamplers( + m_state.cs.samplers, + StartSlot, NumSamplers, + ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::CSGetShader( ID3D11ComputeShader** ppComputeShader, @@ -1001,6 +1145,18 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::CSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers) { + D3D10DeviceLock lock = LockContext(); + + GetSamplers(m_state.cs.samplers, + StartSlot, NumSamplers, ppSamplers); + } + + template void STDMETHODCALLTYPE D3D11CommonContext::OMSetRenderTargets( UINT NumViews, @@ -1475,6 +1631,20 @@ namespace dxvk { } + template + void D3D11CommonContext::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; + } + } + + template template void D3D11CommonContext::ResolveSrvHazards( @@ -1703,6 +1873,26 @@ namespace dxvk { } + template + template + void D3D11CommonContext::SetSamplers( + D3D11SamplerBindings& Bindings, + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers) { + uint32_t slotId = computeSamplerBinding(ShaderStage, StartSlot); + + for (uint32_t i = 0; i < NumSamplers; i++) { + auto sampler = static_cast(ppSamplers[i]); + + if (Bindings[StartSlot + i] != sampler) { + Bindings[StartSlot + i] = sampler; + BindSampler(slotId + i, sampler); + } + } + } + + template void D3D11CommonContext::SetRenderTargetsAndUnorderedAccessViews( UINT NumRTVs, diff --git a/src/d3d11/d3d11_context_common.h b/src/d3d11/d3d11_context_common.h index 28ae115c9..450218cad 100644 --- a/src/d3d11/d3d11_context_common.h +++ b/src/d3d11/d3d11_context_common.h @@ -143,6 +143,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView* const* ppShaderResourceViews); + void STDMETHODCALLTYPE VSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers); + void STDMETHODCALLTYPE VSGetShader( ID3D11VertexShader** ppVertexShader, ID3D11ClassInstance** ppClassInstances, @@ -165,6 +170,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews); + void STDMETHODCALLTYPE VSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers); + void STDMETHODCALLTYPE HSSetShader( ID3D11HullShader* pHullShader, ID3D11ClassInstance* const* ppClassInstances, @@ -187,6 +197,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView* const* ppShaderResourceViews); + void STDMETHODCALLTYPE HSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers); + void STDMETHODCALLTYPE HSGetShader( ID3D11HullShader** ppHullShader, ID3D11ClassInstance** ppClassInstances, @@ -209,6 +224,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews); + void STDMETHODCALLTYPE HSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers); + void STDMETHODCALLTYPE DSSetShader( ID3D11DomainShader* pDomainShader, ID3D11ClassInstance* const* ppClassInstances, @@ -231,6 +251,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView* const* ppShaderResourceViews); + void STDMETHODCALLTYPE DSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers); + void STDMETHODCALLTYPE DSGetShader( ID3D11DomainShader** ppDomainShader, ID3D11ClassInstance** ppClassInstances, @@ -253,6 +278,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews); + void STDMETHODCALLTYPE DSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers); + void STDMETHODCALLTYPE GSSetShader( ID3D11GeometryShader* pShader, ID3D11ClassInstance* const* ppClassInstances, @@ -275,6 +305,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView* const* ppShaderResourceViews); + void STDMETHODCALLTYPE GSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers); + void STDMETHODCALLTYPE GSGetShader( ID3D11GeometryShader** ppGeometryShader, ID3D11ClassInstance** ppClassInstances, @@ -297,6 +332,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews); + void STDMETHODCALLTYPE GSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers); + void STDMETHODCALLTYPE PSSetShader( ID3D11PixelShader* pPixelShader, ID3D11ClassInstance* const* ppClassInstances, @@ -319,6 +359,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView* const* ppShaderResourceViews); + void STDMETHODCALLTYPE PSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers); + void STDMETHODCALLTYPE PSGetShader( ID3D11PixelShader** ppPixelShader, ID3D11ClassInstance** ppClassInstances, @@ -341,6 +386,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews); + void STDMETHODCALLTYPE PSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers); + void STDMETHODCALLTYPE CSSetShader( ID3D11ComputeShader* pComputeShader, ID3D11ClassInstance* const* ppClassInstances, @@ -363,6 +413,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView* const* ppShaderResourceViews); + void STDMETHODCALLTYPE CSSetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers); + void STDMETHODCALLTYPE CSGetShader( ID3D11ComputeShader** ppComputeShader, ID3D11ClassInstance** ppClassInstances, @@ -385,6 +440,11 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews); + void STDMETHODCALLTYPE CSGetSamplers( + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers); + void STDMETHODCALLTYPE OMSetRenderTargets( UINT NumViews, ID3D11RenderTargetView* const* ppRenderTargetViews, @@ -507,6 +567,12 @@ namespace dxvk { UINT NumViews, ID3D11ShaderResourceView** ppShaderResourceViews); + void GetSamplers( + const D3D11SamplerBindings& Bindings, + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState** ppSamplers); + template void ResolveSrvHazards( T* pView, @@ -549,6 +615,13 @@ namespace dxvk { UINT NumResources, ID3D11ShaderResourceView* const* ppResources); + template + void SetSamplers( + D3D11SamplerBindings& Bindings, + UINT StartSlot, + UINT NumSamplers, + ID3D11SamplerState* const* ppSamplers); + void SetRenderTargetsAndUnorderedAccessViews( UINT NumRTVs, ID3D11RenderTargetView* const* ppRenderTargetViews,