From 583ca8b78efb0cc0f6a1cdcace2070801e3a9c4c Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 4 Oct 2015 00:22:56 +0200 Subject: [PATCH] Set whether a bind id referenced & get better names for constant blocks --- .../shaders/spirv/spirv_disassemble.cpp | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp b/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp index 82f693a7c..a525c08d7 100644 --- a/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp @@ -1857,13 +1857,17 @@ void SPVModule::MakeReflection(ShaderReflection *reflection, ShaderBindpointMapp { ConstantBlock cblock; - cblock.name = inst->str.empty() ? StringFormat::Fmt("uniforms%u", inst->id) : inst->str; + if(!inst->str.empty()) + cblock.name = inst->str; + else if(!type->name.empty()) + cblock.name = type->name; + else + cblock.name = StringFormat::Fmt("uniforms%u", inst->id); cblock.bufferBacked = true; cblock.bindPoint = (int32_t)cblocks.size(); BindpointMap bindmap = {0}; - // TODO this needs to go through the bindpoint mapping for(size_t d=0; d < inst->decorations.size(); d++) { if(inst->decorations[d].decoration == spv::DecorationDescriptorSet) @@ -1876,7 +1880,23 @@ void SPVModule::MakeReflection(ShaderReflection *reflection, ShaderBindpointMapp cblocks.push_back(cblock); - bindmap.used = true; // VKTODOLOW see if this declared struct is used anywhere in the code + bindmap.used = false; + + for(size_t o=0; o < operations.size(); o++) + { + if(operations[o]->op) + { + for(size_t a=0; a < operations[o]->op->arguments.size(); a++) + { + if(operations[o]->op->arguments[a] == inst) + { + bindmap.used = true; + break; + } + } + } + } + cblockmap.push_back(bindmap); } else @@ -1925,7 +1945,6 @@ void SPVModule::MakeReflection(ShaderReflection *reflection, ShaderBindpointMapp BindpointMap bindmap = {0}; - // TODO this needs to go through the bindpoint mapping for(size_t d=0; d < inst->decorations.size(); d++) { if(inst->decorations[d].decoration == spv::DecorationDescriptorSet) @@ -1933,8 +1952,23 @@ void SPVModule::MakeReflection(ShaderReflection *reflection, ShaderBindpointMapp if(inst->decorations[d].decoration == spv::DecorationBinding) bindmap.bind = (int32_t)inst->decorations[d].val; } - - bindmap.used = true; // VKTODOLOW see if this declared resource is used anywhere in the code + + bindmap.used = false; + + for(size_t o=0; o < operations.size(); o++) + { + if(operations[o]->op) + { + for(size_t a=0; a < operations[o]->op->arguments.size(); a++) + { + if(operations[o]->op->arguments[a] == inst) + { + bindmap.used = true; + break; + } + } + } + } resources.push_back(res); resmap.push_back(bindmap);