From 25da813b40c032032e21f8d82235b18c4ef1eca9 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Fri, 23 Jan 2026 17:49:37 +1300 Subject: [PATCH] Extend GL reflection matching to SPIRV reflection for resource arrays GL resource arrays are expanded in the GL reflection i.e. texture[0], texture[1] but they are collapsed in the SPIRV reflection. For SPIRV resource arrays if matching the full name fails then try to match by the expanded name i.e. texture[] --- .../driver/gl/wrappers/gl_shader_funcs.cpp | 54 +++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp index 4f3bfe251..354d112b2 100644 --- a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp @@ -462,12 +462,28 @@ void WrappedOpenGL::ShaderData::ProcessCompilation(WrappedOpenGL &drv, ResourceI for(size_t j = 0; j < spvReflection.readOnlyResources.size(); j++) { if(reflection->readOnlyResources[i].name == spvReflection.readOnlyResources[j].name) + { + found = true; + } + else if((spvReflection.readOnlyResources[j].bindArraySize > 1)) + { + rdcstr &baseName = spvReflection.readOnlyResources[j].name; + for(uint32_t idx = 0; idx < spvReflection.readOnlyResources[j].bindArraySize; idx++) + { + rdcstr resName = StringFormat::Fmt("%s[%u]", baseName.c_str(), idx); + if(reflection->readOnlyResources[i].name == resName) + { + found = true; + break; + } + } + } + if(found) { convertedPatchData.roInterface.resize_for_index(i); convertedPatchData.roInterface[i] = spvPatchData.roInterface[j]; convertedRefl.readOnlyResources.resize_for_index(i); convertedRefl.readOnlyResources[i] = spvReflection.readOnlyResources[j]; - found = true; break; } } @@ -490,12 +506,28 @@ void WrappedOpenGL::ShaderData::ProcessCompilation(WrappedOpenGL &drv, ResourceI for(size_t j = 0; j < spvReflection.readWriteResources.size(); j++) { if(reflection->readWriteResources[i].name == spvReflection.readWriteResources[j].name) + { + found = true; + } + else if((spvReflection.readWriteResources[j].bindArraySize > 1)) + { + rdcstr &baseName = spvReflection.readWriteResources[j].name; + for(uint32_t idx = 0; idx < spvReflection.readWriteResources[j].bindArraySize; idx++) + { + rdcstr resName = StringFormat::Fmt("%s[%u]", baseName.c_str(), idx); + if(reflection->readWriteResources[i].name == resName) + { + found = true; + break; + } + } + } + if(found) { convertedPatchData.rwInterface.resize_for_index(i); convertedPatchData.rwInterface[i] = spvPatchData.rwInterface[j]; convertedRefl.readWriteResources.resize_for_index(i); convertedRefl.readWriteResources[i] = spvReflection.readWriteResources[j]; - found = true; break; } } @@ -560,12 +592,28 @@ void WrappedOpenGL::ShaderData::ProcessCompilation(WrappedOpenGL &drv, ResourceI for(size_t j = 0; j < spvReflection.samplers.size(); j++) { if(reflection->samplers[i].name == spvReflection.samplers[j].name) + { + found = true; + } + else if((spvReflection.samplers[j].bindArraySize > 1)) + { + rdcstr &baseName = spvReflection.samplers[j].name; + for(uint32_t idx = 0; idx < spvReflection.samplers[j].bindArraySize; idx++) + { + rdcstr resName = StringFormat::Fmt("%s[%u]", baseName.c_str(), idx); + if(reflection->samplers[i].name == resName) + { + found = true; + break; + } + } + } + if(found) { convertedPatchData.samplerInterface.resize_for_index(i); convertedPatchData.samplerInterface[i] = spvPatchData.samplerInterface[j]; convertedRefl.samplers.resize_for_index(i); convertedRefl.samplers[i] = spvReflection.samplers[j]; - found = true; break; } }