From 174dd4e0dd5957be90b5658eb1f82a6b2fe2eef7 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sat, 23 Jan 2016 16:17:07 +0100 Subject: [PATCH] Ignore any non-builtins in a builtin structure from output signature * Works around a bug encountered where the 'gl_PerVertex' struct had some legacy members like gl_FrontColor and such. --- .../shaders/spirv/spirv_disassemble.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp b/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp index bd8f5fcc8..971afb640 100644 --- a/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp @@ -3026,8 +3026,50 @@ void AddSignatureParameter(uint32_t id, uint32_t childIdx, string varName, SPVTy { // we don't support nested structs yet RDCASSERT(childIdx == ~0U); + + // it's invalid to include built-in and 'normal' outputs in the same struct. One + // way this can happen is if a SPIR-V generator incorrectly puts in legacy elements + // into an implicit gl_PerVertex struct, but they don't have a builtin to associate + // with. We can safely skip these parameters + + // check to see if this struct contains some builtins + bool hasBuiltins = false; + for(size_t c=0; c < type->childDecorations.size(); c++) + { + for(size_t d=0; d < type->childDecorations[c].size(); d++) + { + if(type->childDecorations[c][d].decoration == spv::DecorationBuiltIn) + { + hasBuiltins = true; + break; + } + } + } + for(size_t c=0; c < type->children.size(); c++) + { + // if this struct has builtins, see if this child is a builtin + if(hasBuiltins) + { + bool isBuiltin = false; + + for(size_t d=0; d < type->childDecorations[c].size(); d++) + { + if(type->childDecorations[c][d].decoration == spv::DecorationBuiltIn) + { + isBuiltin = true; + break; + } + } + + // if it's not a builtin, then skip it + if(!isBuiltin) + continue; + } + AddSignatureParameter(id, (uint32_t)c, varName + "." + type->children[c].second, type->children[c].first, type->childDecorations[c], sigarray); + } + return; }