[d3d11] Don't template methods that restore shader bindings

This was only needed because Bind* methods were also templated.
This commit is contained in:
Philip Rebohle 2025-02-19 13:36:37 +01:00 committed by Philip Rebohle
parent 771f14c466
commit 9d890c75ac
2 changed files with 30 additions and 40 deletions

View file

@ -4880,29 +4880,16 @@ namespace dxvk {
for (uint32_t i = 0; i < m_state.so.targets.size(); i++) for (uint32_t i = 0; i < m_state.so.targets.size(); i++)
BindXfbBuffer(i, m_state.so.targets[i].buffer.ptr(), ~0u); BindXfbBuffer(i, m_state.so.targets[i].buffer.ptr(), ~0u);
RestoreConstantBuffers<DxbcProgramType::VertexShader>(); for (uint32_t i = 0; i < uint32_t(DxbcProgramType::Count); i++) {
RestoreConstantBuffers<DxbcProgramType::HullShader>(); auto stage = DxbcProgramType(i);
RestoreConstantBuffers<DxbcProgramType::DomainShader>();
RestoreConstantBuffers<DxbcProgramType::GeometryShader>();
RestoreConstantBuffers<DxbcProgramType::PixelShader>();
RestoreConstantBuffers<DxbcProgramType::ComputeShader>();
RestoreShaderResources<DxbcProgramType::VertexShader>(); RestoreConstantBuffers(stage);
RestoreShaderResources<DxbcProgramType::HullShader>(); RestoreShaderResources(stage);
RestoreShaderResources<DxbcProgramType::DomainShader>(); RestoreSamplers(stage);
RestoreShaderResources<DxbcProgramType::GeometryShader>(); }
RestoreShaderResources<DxbcProgramType::PixelShader>();
RestoreShaderResources<DxbcProgramType::ComputeShader>();
RestoreUnorderedAccessViews<DxbcProgramType::PixelShader>(); RestoreUnorderedAccessViews(DxbcProgramType::PixelShader);
RestoreUnorderedAccessViews<DxbcProgramType::ComputeShader>(); RestoreUnorderedAccessViews(DxbcProgramType::ComputeShader);
RestoreSamplers<DxbcProgramType::VertexShader>();
RestoreSamplers<DxbcProgramType::HullShader>();
RestoreSamplers<DxbcProgramType::DomainShader>();
RestoreSamplers<DxbcProgramType::GeometryShader>();
RestoreSamplers<DxbcProgramType::PixelShader>();
RestoreSamplers<DxbcProgramType::ComputeShader>();
// Draw buffer bindings aren't persistent at the API level, and // Draw buffer bindings aren't persistent at the API level, and
// we can't meaningfully track them. Just reset this state here // we can't meaningfully track them. Just reset this state here
@ -4912,9 +4899,10 @@ namespace dxvk {
template<typename ContextType> template<typename ContextType>
template<DxbcProgramType Stage> void D3D11CommonContext<ContextType>::RestoreConstantBuffers(
void D3D11CommonContext<ContextType>::RestoreConstantBuffers() { DxbcProgramType Stage) {
const auto& bindings = m_state.cbv[Stage]; const auto& bindings = m_state.cbv[Stage];
for (uint32_t i = 0; i < bindings.maxCount; i++) { for (uint32_t i = 0; i < bindings.maxCount; i++) {
BindConstantBuffer(Stage, i, bindings.buffers[i].buffer.ptr(), BindConstantBuffer(Stage, i, bindings.buffers[i].buffer.ptr(),
bindings.buffers[i].constantOffset, bindings.buffers[i].constantBound); bindings.buffers[i].constantOffset, bindings.buffers[i].constantBound);
@ -4923,26 +4911,28 @@ namespace dxvk {
template<typename ContextType> template<typename ContextType>
template<DxbcProgramType Stage> void D3D11CommonContext<ContextType>::RestoreSamplers(
void D3D11CommonContext<ContextType>::RestoreSamplers() { DxbcProgramType Stage) {
const auto& bindings = m_state.samplers[Stage]; const auto& bindings = m_state.samplers[Stage];
for (uint32_t i = 0; i < bindings.maxCount; i++) for (uint32_t i = 0; i < bindings.maxCount; i++)
BindSampler(Stage, i, bindings.samplers[i]); BindSampler(Stage, i, bindings.samplers[i]);
} }
template<typename ContextType> template<typename ContextType>
template<DxbcProgramType Stage> void D3D11CommonContext<ContextType>::RestoreShaderResources(
void D3D11CommonContext<ContextType>::RestoreShaderResources() { DxbcProgramType Stage) {
const auto& bindings = m_state.srv[Stage]; const auto& bindings = m_state.srv[Stage];
for (uint32_t i = 0; i < bindings.maxCount; i++) for (uint32_t i = 0; i < bindings.maxCount; i++)
BindShaderResource(Stage, i, bindings.views[i].ptr()); BindShaderResource(Stage, i, bindings.views[i].ptr());
} }
template<typename ContextType> template<typename ContextType>
template<DxbcProgramType Stage> void D3D11CommonContext<ContextType>::RestoreUnorderedAccessViews(
void D3D11CommonContext<ContextType>::RestoreUnorderedAccessViews() { DxbcProgramType Stage) {
const auto& views = Stage == DxbcProgramType::ComputeShader const auto& views = Stage == DxbcProgramType::ComputeShader
? m_state.uav.views ? m_state.uav.views
: m_state.om.uavs; : m_state.om.uavs;

View file

@ -1014,18 +1014,18 @@ namespace dxvk {
void RestoreCommandListState(); void RestoreCommandListState();
template<DxbcProgramType Stage> void RestoreConstantBuffers(
void RestoreConstantBuffers(); DxbcProgramType Stage);
template<DxbcProgramType Stage>
void RestoreSamplers();
template<DxbcProgramType Stage>
void RestoreShaderResources();
template<DxbcProgramType Stage>
void RestoreUnorderedAccessViews();
void RestoreSamplers(
DxbcProgramType Stage);
void RestoreShaderResources(
DxbcProgramType Stage);
void RestoreUnorderedAccessViews(
DxbcProgramType Stage);
template<DxbcProgramType ShaderStage> template<DxbcProgramType ShaderStage>
void SetConstantBuffers( void SetConstantBuffers(
UINT StartSlot, UINT StartSlot,