From 53c529fdaf4ea1084cc9cded949428a73054b94b Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 12 Sep 2022 13:47:15 +0100 Subject: [PATCH] Handle OpAccessChain only for a global resource array index * If we have an OpAccessChain which only looks up a resource index and not anything else, we need to ensure that both we don't consume the first index next time, AND that we preserve the resource index for future access chains. --- renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp index 742f04803..d59de5f91 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp @@ -1981,9 +1981,14 @@ ShaderVariable Debugger::MakeCompositePointer(const ShaderVariable &base, Id id, bool isArray = false; + // if this is an arrayed opaque binding, the first index is a 'virtual' array index into the + // binding. + // We only take this if this is the FIRST dereference from the global pointer. + // If the SPIR-V does something like structType *_1234 = if((leaf->type == VarType::ReadWriteResource || leaf->type == VarType::ReadOnlyResource || leaf->type == VarType::Sampler) && - checkPointerFlags(*leaf, PointerFlags::GlobalArrayBinding)) + checkPointerFlags(*leaf, PointerFlags::GlobalArrayBinding) && + getBufferTypeId(base) == rdcspv::Id()) { isArray = true; } @@ -2015,6 +2020,10 @@ ShaderVariable Debugger::MakeCompositePointer(const ShaderVariable &base, Id id, setBindArrayIndex(ret, indices[i++]); type = &dataTypes[type->InnerType()]; } + else + { + setBindArrayIndex(ret, getBindArrayIndex(base)); + } Decorations curDecorations = decorations[type->id];