Don't process unused bindings when debugging vulkan shaders

* These will not be in the reflection data, so we can't try to process them and
  fill out their variables as there won't be anything to map to.
* Signature elements which are 'unused' by not being referenced but are present
  in a pre-1.4 SPIR-V module will be considered used still.
This commit is contained in:
baldurk
2024-04-22 13:01:13 +01:00
parent 020efd7fd7
commit c244c1fdda
3 changed files with 18 additions and 0 deletions
@@ -1076,6 +1076,9 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s
else if(v.storage == StorageClass::Uniform || v.storage == StorageClass::StorageBuffer ||
v.storage == StorageClass::PushConstant)
{
if(!patchData.usedIds.contains(v.id))
continue;
ShaderVariable var;
var.name = GetRawName(v.id);
@@ -1261,6 +1264,9 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s
}
else if(v.storage == StorageClass::UniformConstant)
{
if(!patchData.usedIds.contains(v.id))
continue;
// only images/samplers are allowed to be in UniformConstant
ShaderVariable var;
var.rows = 1;
@@ -1146,6 +1146,15 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
usedIds.clear();
usedIds.insert(entry->usedIds.begin(), entry->usedIds.end());
}
else
{
// before that, still consider all entry interface used just not exclusively
usedIds.insert(entry->usedIds.begin(), entry->usedIds.end());
}
patchData.usedIds.reserve(usedIds.size());
for(Id id : usedIds)
patchData.usedIds.push_back(id);
// arrays of elements, which can be appended to in any order and then sorted
rdcarray<SigParameter> inputs;
@@ -68,6 +68,9 @@ struct SPIRVPatchData
rdcarray<rdcspv::Id> rwInterface;
rdcarray<rdcspv::Id> samplerInterface;
// set of used IDs
rdcarray<rdcspv::Id> usedIds;
// the spec IDs in order - these are the order of constants encountered while parsing, and are
// used for byte offsets into the resulting data blob (each constant takes 64-bits).
// The shader constants reported already have the write offset, but this allows looking up the