From e1283a744046a80336eb81dcfd649a986b41a504 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 10 May 2024 10:29:33 +0100 Subject: [PATCH] Handle root signature ranges that bind a subset of a binding array --- renderdoc/driver/d3d12/d3d12_commands.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index 5fa3b68ec..9f49af2a1 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -2089,8 +2089,16 @@ void D3D12CommandData::AddUsageForBindInRootSig(const D3D12RenderState &state, bool allInRange = (bind >= range.BaseShaderRegister && rangeSize <= range.NumDescriptors); - // move to the first descriptor in the range which is in the binding we want - desc += (bind - range.BaseShaderRegister); + // move to the first descriptor in the range which is in the binding we want, if the binding + // is later on in the range. + // + // It's also possible that the range is later on in the binding (e.g. if the binding is at + // base register 5 and is 1000000 in length, the range could start at register 10. In that + // case we just consume as much of the range as still fits in the bind + if(bind > range.BaseShaderRegister) + desc += (bind - range.BaseShaderRegister); + if(range.BaseShaderRegister > bind) + rangeSize -= (range.BaseShaderRegister - bind); if(range.RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_CBV) {