diff --git a/renderdoc/driver/d3d12/d3d12_state.cpp b/renderdoc/driver/d3d12/d3d12_state.cpp index 8b7b98397..7868e2610 100644 --- a/renderdoc/driver/d3d12/d3d12_state.cpp +++ b/renderdoc/driver/d3d12/d3d12_state.cpp @@ -152,7 +152,7 @@ void D3D12RenderState::ApplyState(ID3D12GraphicsCommandList *cmd) GetResourceManager()->GetCurrentAs(graphics.rootsig)); for(size_t i = 0; i < graphics.sigelems.size(); i++) - graphics.sigelems[i].SetToCommandList(GetResourceManager(), cmd, (UINT)i); + graphics.sigelems[i].SetToGraphics(GetResourceManager(), cmd, (UINT)i); } if(compute.rootsig != ResourceId()) @@ -161,6 +161,6 @@ void D3D12RenderState::ApplyState(ID3D12GraphicsCommandList *cmd) GetResourceManager()->GetCurrentAs(compute.rootsig)); for(size_t i = 0; i < compute.sigelems.size(); i++) - compute.sigelems[i].SetToCommandList(GetResourceManager(), cmd, (UINT)i); + compute.sigelems[i].SetToCompute(GetResourceManager(), cmd, (UINT)i); } } \ No newline at end of file diff --git a/renderdoc/driver/d3d12/d3d12_state.h b/renderdoc/driver/d3d12/d3d12_state.h index 62b0f6eaf..087aebfbe 100644 --- a/renderdoc/driver/d3d12/d3d12_state.h +++ b/renderdoc/driver/d3d12/d3d12_state.h @@ -60,7 +60,8 @@ struct D3D12RenderState SignatureElement(SignatureElementType t, ResourceId i, UINT64 o) : type(t), id(i), offset(o) {} SignatureElement(UINT offs, UINT val) : type(eRootConst), offset(offs) { - constants.push_back(val); + type = eRootConst; + SetValues(1, &val, offs); } SignatureElement(UINT numVals, const void *vals, UINT offs) { @@ -76,7 +77,7 @@ struct D3D12RenderState memcpy(&constants[offs], vals, numVals * sizeof(UINT)); } - void SetToCommandList(D3D12ResourceManager *rm, ID3D12GraphicsCommandList *cmd, UINT slot) + void SetToGraphics(D3D12ResourceManager *rm, ID3D12GraphicsCommandList *cmd, UINT slot) { if(type == eRootConst) { @@ -113,6 +114,40 @@ struct D3D12RenderState } } + void SetToCompute(D3D12ResourceManager *rm, ID3D12GraphicsCommandList *cmd, UINT slot) + { + if(type == eRootConst) + { + cmd->SetComputeRoot32BitConstants(slot, (UINT)constants.size(), &constants[0], 0); + } + else if(type == eRootTable) + { + D3D12_GPU_DESCRIPTOR_HANDLE handle = + rm->GetCurrentAs(id)->GetGPUDescriptorHandleForHeapStart(); + handle.ptr += sizeof(D3D12Descriptor) * offset; + cmd->SetComputeRootDescriptorTable(slot, handle); + } + else if(type == eRootCBV) + { + ID3D12Resource *res = rm->GetCurrentAs(id); + cmd->SetComputeRootConstantBufferView(slot, res->GetGPUVirtualAddress() + offset); + } + else if(type == eRootSRV) + { + ID3D12Resource *res = rm->GetCurrentAs(id); + cmd->SetComputeRootShaderResourceView(slot, res->GetGPUVirtualAddress() + offset); + } + else if(type == eRootUAV) + { + ID3D12Resource *res = rm->GetCurrentAs(id); + cmd->SetComputeRootUnorderedAccessView(slot, res->GetGPUVirtualAddress() + offset); + } + else + { + RDCWARN("Unexpected root signature element of type '%u' - skipping.", type); + } + } + SignatureElementType type; ResourceId id;