[d3d11] Move *SetSamplers methods to D3D11CommonContext

This commit is contained in:
Philip Rebohle 2022-08-03 20:02:23 +02:00
parent 3af5b3ba7b
commit 159eed825f
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 263 additions and 249 deletions

View File

@ -1284,139 +1284,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11DeviceContext::VSSetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState* const* ppSamplers) {
D3D10DeviceLock lock = LockContext();
SetSamplers<DxbcProgramType::VertexShader>(
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<DxbcProgramType::HullShader>(
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<DxbcProgramType::DomainShader>(
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<DxbcProgramType::GeometryShader>(
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<DxbcProgramType::PixelShader>(
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<DxbcProgramType::ComputeShader>(
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<DxbcProgramType ShaderStage>
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<D3D11SamplerState*>(ppSamplers[i]);
if (Bindings[StartSlot + i] != sampler) {
Bindings[StartSlot + i] = sampler;
BindSampler<ShaderStage>(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

View File

@ -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<DxbcProgramType ShaderStage>
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();

View File

@ -311,6 +311,20 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::VSSetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState* const* ppSamplers) {
D3D10DeviceLock lock = LockContext();
SetSamplers<DxbcProgramType::VertexShader>(
m_state.vs.samplers,
StartSlot, NumSamplers,
ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::VSGetShader(
ID3D11VertexShader** ppVertexShader,
@ -371,6 +385,18 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::VSGetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState** ppSamplers) {
D3D10DeviceLock lock = LockContext();
GetSamplers(m_state.vs.samplers,
StartSlot, NumSamplers, ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::HSSetShader(
ID3D11HullShader* pHullShader,
@ -437,6 +463,20 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::HSSetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState* const* ppSamplers) {
D3D10DeviceLock lock = LockContext();
SetSamplers<DxbcProgramType::HullShader>(
m_state.hs.samplers,
StartSlot, NumSamplers,
ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::HSGetShader(
ID3D11HullShader** ppHullShader,
@ -497,6 +537,18 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::HSGetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState** ppSamplers) {
D3D10DeviceLock lock = LockContext();
GetSamplers(m_state.hs.samplers,
StartSlot, NumSamplers, ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::DSSetShader(
ID3D11DomainShader* pDomainShader,
@ -563,6 +615,20 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::DSSetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState* const* ppSamplers) {
D3D10DeviceLock lock = LockContext();
SetSamplers<DxbcProgramType::DomainShader>(
m_state.ds.samplers,
StartSlot, NumSamplers,
ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::DSGetShader(
ID3D11DomainShader** ppDomainShader,
@ -623,6 +689,18 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::DSGetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState** ppSamplers) {
D3D10DeviceLock lock = LockContext();
GetSamplers(m_state.ds.samplers,
StartSlot, NumSamplers, ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::GSSetShader(
ID3D11GeometryShader* pShader,
@ -689,6 +767,20 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::GSSetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState* const* ppSamplers) {
D3D10DeviceLock lock = LockContext();
SetSamplers<DxbcProgramType::GeometryShader>(
m_state.gs.samplers,
StartSlot, NumSamplers,
ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::GSGetShader(
ID3D11GeometryShader** ppGeometryShader,
@ -749,6 +841,18 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::GSGetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState** ppSamplers) {
D3D10DeviceLock lock = LockContext();
GetSamplers(m_state.gs.samplers,
StartSlot, NumSamplers, ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::PSSetShader(
ID3D11PixelShader* pPixelShader,
@ -815,6 +919,20 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::PSSetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState* const* ppSamplers) {
D3D10DeviceLock lock = LockContext();
SetSamplers<DxbcProgramType::PixelShader>(
m_state.ps.samplers,
StartSlot, NumSamplers,
ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::PSGetShader(
ID3D11PixelShader** ppPixelShader,
@ -875,6 +993,18 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::PSGetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState** ppSamplers) {
D3D10DeviceLock lock = LockContext();
GetSamplers(m_state.ps.samplers,
StartSlot, NumSamplers, ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::CSSetShader(
ID3D11ComputeShader* pComputeShader,
@ -941,6 +1071,20 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::CSSetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState* const* ppSamplers) {
D3D10DeviceLock lock = LockContext();
SetSamplers<DxbcProgramType::ComputeShader>(
m_state.cs.samplers,
StartSlot, NumSamplers,
ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::CSGetShader(
ID3D11ComputeShader** ppComputeShader,
@ -1001,6 +1145,18 @@ namespace dxvk {
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::CSGetSamplers(
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState** ppSamplers) {
D3D10DeviceLock lock = LockContext();
GetSamplers(m_state.cs.samplers,
StartSlot, NumSamplers, ppSamplers);
}
template<typename ContextType>
void STDMETHODCALLTYPE D3D11CommonContext<ContextType>::OMSetRenderTargets(
UINT NumViews,
@ -1475,6 +1631,20 @@ namespace dxvk {
}
template<typename ContextType>
void D3D11CommonContext<ContextType>::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<typename ContextType>
template<DxbcProgramType ShaderStage, typename T>
void D3D11CommonContext<ContextType>::ResolveSrvHazards(
@ -1703,6 +1873,26 @@ namespace dxvk {
}
template<typename ContextType>
template<DxbcProgramType ShaderStage>
void D3D11CommonContext<ContextType>::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<D3D11SamplerState*>(ppSamplers[i]);
if (Bindings[StartSlot + i] != sampler) {
Bindings[StartSlot + i] = sampler;
BindSampler<ShaderStage>(slotId + i, sampler);
}
}
}
template<typename ContextType>
void D3D11CommonContext<ContextType>::SetRenderTargetsAndUnorderedAccessViews(
UINT NumRTVs,

View File

@ -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<DxbcProgramType ShaderStage, typename T>
void ResolveSrvHazards(
T* pView,
@ -549,6 +615,13 @@ namespace dxvk {
UINT NumResources,
ID3D11ShaderResourceView* const* ppResources);
template<DxbcProgramType ShaderStage>
void SetSamplers(
D3D11SamplerBindings& Bindings,
UINT StartSlot,
UINT NumSamplers,
ID3D11SamplerState* const* ppSamplers);
void SetRenderTargetsAndUnorderedAccessViews(
UINT NumRTVs,
ID3D11RenderTargetView* const* ppRenderTargetViews,