From 87ff61169fc8bfd3355b240d7304ab134d0e9917 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 25 Jun 2018 16:30:14 +0100 Subject: [PATCH] Take IDs of input variables from SPIR-V patch data * If we try and match up input variables by location, and the shader has multiple variables mapped to a single location, we end up leaving one variable unmapped. We already have the information so we don't have to do this inaccurate lookup. --- renderdoc/driver/vulkan/vk_postvs.cpp | 49 ++++----------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/renderdoc/driver/vulkan/vk_postvs.cpp b/renderdoc/driver/vulkan/vk_postvs.cpp index 2f7452fa4..467b98ff0 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -267,28 +267,8 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, // remove any builtin decorations if(it.opcode() == spv::OpDecorate && it.word(2) == spv::DecorationBuiltIn) { - SPIRVId id = it.word(1); - - if(outputs.find(id) != outputs.end()) - { - // outputs we don't have to do anything, discard the builtin information - } - else if(inputs.find(id) != inputs.end()) - { - // for inputs, record the variable ID for this builtin - for(size_t i = 0; i < refl.inputSignature.size(); i++) - { - const SigParameter &sig = refl.inputSignature[i]; - - if(sig.systemValue == - BuiltInToSystemAttribute(ShaderStage::Vertex, (spv::BuiltIn)it.word(3))) - { - ins[i].variableID = id; - break; - } - } - } - + // we don't have to do anything, the ID mapping is in the SPIRVPatchData, so just discard the + // location information editor.Remove(it); } @@ -312,27 +292,8 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, if(it.opcode() == spv::OpDecorate && it.word(2) == spv::DecorationLocation) { - SPIRVId id = it.word(1); - - if(outputs.find(id) != outputs.end()) - { - // outputs we don't have to do anything, discard the location information - } - else if(inputs.find(id) != inputs.end()) - { - // for inputs, record the variable ID for this location - for(size_t i = 0; i < refl.inputSignature.size(); i++) - { - const SigParameter &sig = refl.inputSignature[i]; - - if(sig.systemValue == ShaderBuiltin::Undefined && sig.regIndex == it.word(3)) - { - ins[i].variableID = id; - break; - } - } - } - + // we don't have to do anything, the ID mapping is in the SPIRVPatchData, so just discard the + // location information editor.Remove(it); } } @@ -420,6 +381,8 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, // constant for this index io.constID = editor.AddConstantImmediate(i); + io.variableID = patchData.inputs[i].ID; + SPIRVScalar scalarType = scalar(); // base type - either a scalar or a vector, since matrix outputs are decayed to vectors