From 1a1437ee19e475d72ad700380e40b06400009493 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 25 Jun 2024 17:03:16 +0100 Subject: [PATCH] Fix ExecuteIndirect state decoding not properly respecting stride * It was also broken even for tightly packed argument signatures because it wasn't incrementing the data pointer over the dispatch/draw arguments. --- 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 44d6d0375..2db5c2295 100644 --- a/renderdoc/driver/d3d12/d3d12_state.cpp +++ b/renderdoc/driver/d3d12/d3d12_state.cpp @@ -80,12 +80,12 @@ void D3D12RenderState::ResolvePendingIndirectState(WrappedID3D12Device *device) { byte *data = mapPtr + indirectState.argsOffs; - mapPtr += comSig->sig.ByteStride; for(uint32_t argIdx = 0; argIdx < indirectState.argsToProcess; argIdx++) { - uint32_t a = argIdx % comSig->sig.arguments.size(); - const D3D12_INDIRECT_ARGUMENT_DESC &arg = comSig->sig.arguments[a]; + size_t execIdx = argIdx / comSig->sig.arguments.size(); + uint32_t argWithinExecIdx = argIdx % comSig->sig.arguments.size(); + const D3D12_INDIRECT_ARGUMENT_DESC &arg = comSig->sig.arguments[argWithinExecIdx]; switch(arg.Type) { @@ -93,7 +93,14 @@ void D3D12RenderState::ResolvePendingIndirectState(WrappedID3D12Device *device) case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED: case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH: case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH: - case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS: break; + case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS: + { + // we know this is the final argument in the signature. Set the data pointer to the start + // of the next execute with the proper stride. This may be unused if we are only + // processing one execute's worth of arguments + data = mapPtr + indirectState.argsOffs + comSig->sig.ByteStride * (execIdx + 1); + break; + } case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT: { size_t argSize = sizeof(uint32_t) * arg.Constant.Num32BitValuesToSet;