From 763fbcf63d1b41762c8da5b413bff748b7aba8c6 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 8 Oct 2024 11:58:16 +0100 Subject: [PATCH] Only set new dynamic states if pipeline uses them --- renderdoc/driver/d3d12/d3d12_state.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_state.cpp b/renderdoc/driver/d3d12/d3d12_state.cpp index f74a86974..4654be3fa 100644 --- a/renderdoc/driver/d3d12/d3d12_state.cpp +++ b/renderdoc/driver/d3d12/d3d12_state.cpp @@ -214,8 +214,12 @@ void D3D12RenderState::ApplyState(WrappedID3D12Device *dev, ID3D12GraphicsComman { D3D12_COMMAND_LIST_TYPE type = cmd->GetType(); + ID3D12PipelineState *pipeState = NULL; if(pipe != ResourceId()) - cmd->SetPipelineState(GetResourceManager()->GetCurrentAs(pipe)); + { + pipeState = GetResourceManager()->GetCurrentAs(pipe); + cmd->SetPipelineState(pipeState); + } if(stateobj != ResourceId()) cmd->SetPipelineState1(GetResourceManager()->GetCurrentAs(stateobj)); @@ -270,14 +274,17 @@ void D3D12RenderState::ApplyState(WrappedID3D12Device *dev, ID3D12GraphicsComman } } - if(GetWrapped(cmd)->GetReal9()) + if(GetWrapped(cmd)->GetReal9() && pipeState) { - if(dev->GetOpts15().DynamicIndexBufferStripCutSupported) + WrappedID3D12PipelineState *wrappedPipe = (WrappedID3D12PipelineState *)pipeState; + if(dev->GetOpts15().DynamicIndexBufferStripCutSupported && wrappedPipe->IsGraphics() && + (wrappedPipe->graphics->Flags & D3D12_PIPELINE_STATE_FLAG_DYNAMIC_INDEX_BUFFER_STRIP_CUT)) { cmd->IASetIndexBufferStripCutValue(cutValue); } - if(dev->GetOpts16().DynamicDepthBiasSupported) + if(dev->GetOpts16().DynamicDepthBiasSupported && wrappedPipe->IsGraphics() && + (wrappedPipe->graphics->Flags & D3D12_PIPELINE_STATE_FLAG_DYNAMIC_DEPTH_BIAS)) { cmd->RSSetDepthBias(depthBias, depthBiasClamp, slopeScaledDepthBias); }