diff --git a/renderdoc/driver/shaders/spirv/spirv_processor.cpp b/renderdoc/driver/shaders/spirv/spirv_processor.cpp index 80c7cce73..b1c349d3a 100644 --- a/renderdoc/driver/shaders/spirv/spirv_processor.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_processor.cpp @@ -524,7 +524,8 @@ void Processor::RegisterOp(Iter it) else if(opdata.op == Op::EntryPoint) { OpEntryPoint decoded(it); - entries.push_back(EntryPoint(decoded.executionModel, decoded.entryPoint, decoded.name)); + entries.push_back( + EntryPoint(decoded.executionModel, decoded.entryPoint, decoded.name, decoded.iface)); } else if(opdata.op == Op::ExecutionMode) { diff --git a/renderdoc/driver/shaders/spirv/spirv_processor.h b/renderdoc/driver/shaders/spirv/spirv_processor.h index cbc6672ec..a3eb4dc43 100644 --- a/renderdoc/driver/shaders/spirv/spirv_processor.h +++ b/renderdoc/driver/shaders/spirv/spirv_processor.h @@ -418,11 +418,15 @@ struct ExecutionModes struct EntryPoint { EntryPoint() = default; - EntryPoint(ExecutionModel e, Id i, rdcstr n) : executionModel(e), id(i), name(n) {} + EntryPoint(ExecutionModel e, Id i, rdcstr n, const rdcarray &ids) + : executionModel(e), id(i), name(n), usedIds(ids) + { + } ExecutionModel executionModel; Id id; rdcstr name; ExecutionModes executionModes; + rdcarray usedIds; bool operator<(const EntryPoint &o) const { diff --git a/renderdoc/driver/shaders/spirv/spirv_reflect.cpp b/renderdoc/driver/shaders/spirv/spirv_reflect.cpp index 07ee04e60..ce7ed53ca 100644 --- a/renderdoc/driver/shaders/spirv/spirv_reflect.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_reflect.cpp @@ -737,6 +737,15 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st } } + if(m_MajorVersion > 1 || m_MinorVersion >= 4) + { + // from SPIR-V 1.4 onwards we can trust the entry point interface list to give us all used + // global variables. We still use the above heuristic so we can remove unused members of + // gl_PerVertex in structs. + usedIds.clear(); + usedIds.insert(entry->usedIds.begin(), entry->usedIds.end()); + } + // arrays of elements, which can be appended to in any order and then sorted rdcarray inputs; rdcarray outputs;