From 716282da485b575457f3de06e1a9cece5cb90535 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Wed, 4 Feb 2026 13:24:50 +1300 Subject: [PATCH] Add required builtin inputs to the PostVS Task/Mesh entry points If the SPIRV module contains multiple entry points then checking for the existance of the builtin variable is not enough to guarantee it is in the entry point inputs --- renderdoc/driver/vulkan/vk_postvs.cpp | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/renderdoc/driver/vulkan/vk_postvs.cpp b/renderdoc/driver/vulkan/vk_postvs.cpp index 6a574d467..70b9311a4 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -1697,6 +1697,7 @@ static void AddTaskShaderPayloadStores(const rdcarray &specInfo, } rdcarray newGlobals; + rdcarray requiredBuiltInInputs; newGlobals.push_back(outSlotAddr); @@ -1708,6 +1709,7 @@ static void AddTaskShaderPayloadStores(const rdcarray &specInfo, ops, ShaderStage::Mesh, rdcspv::BuiltIn::LocalInvocationIndex, uint32Type); if(newGlobal != rdcspv::Id()) newGlobals.push_back(newGlobal); + requiredBuiltInInputs.push_back(editor.GetBuiltInVariable(rdcspv::BuiltIn::LocalInvocationIndex)); } // calculate base address for our task group's data @@ -1727,6 +1729,8 @@ static void AddTaskShaderPayloadStores(const rdcarray &specInfo, if(newGlobal != rdcspv::Id()) newGlobals.push_back(newGlobal); + requiredBuiltInInputs.push_back(editor.GetBuiltInVariable(rdcspv::BuiltIn::WorkgroupId)); + requiredBuiltInInputs.push_back(editor.GetBuiltInVariable(rdcspv::BuiltIn::NumWorkgroups)); // x + y * xsize + z * xsize * ysize rdcspv::Id xsize = locationCalculate.add( @@ -1799,6 +1803,12 @@ static void AddTaskShaderPayloadStores(const rdcarray &specInfo, editor.Remove(it); entry.iface.append(newGlobals); + for(rdcspv::Id id : requiredBuiltInInputs) + { + if(entry.iface.contains(id)) + continue; + entry.iface.push_back(id); + } editor.AddOperation(it, entry); } @@ -1909,6 +1919,7 @@ static void ConvertToFixedTaskFeeder(const rdcarray &specInfo, editor.SetName(baseAddrId, "baseAddr"); rdcarray newGlobals; + rdcarray requiredBuiltInInputs; rdcspv::Id entryID; @@ -2037,6 +2048,9 @@ static void ConvertToFixedTaskFeeder(const rdcarray &specInfo, if(newGlobal != rdcspv::Id()) newGlobals.push_back(newGlobal); + requiredBuiltInInputs.push_back(editor.GetBuiltInVariable(rdcspv::BuiltIn::WorkgroupId)); + requiredBuiltInInputs.push_back(editor.GetBuiltInVariable(rdcspv::BuiltIn::NumWorkgroups)); + // x + y * xsize + z * xsize * ysize rdcspv::Id xsize = @@ -2164,6 +2178,12 @@ static void ConvertToFixedTaskFeeder(const rdcarray &specInfo, editor.Remove(it); entry.iface.append(newGlobals); + for(rdcspv::Id id : requiredBuiltInInputs) + { + if(entry.iface.contains(id)) + continue; + entry.iface.push_back(id); + } editor.AddOperation(it, entry); } @@ -2211,6 +2231,7 @@ static void AddMeshShaderOutputStores(const ShaderReflection &refl, editor.SetName(baseAddrId, "baseAddr"); rdcarray newGlobals; + rdcarray requiredBuiltInInputs; newGlobals.push_back(outSlotAddr); @@ -2608,6 +2629,8 @@ static void AddMeshShaderOutputStores(const ShaderReflection &refl, if(newGlobal != rdcspv::Id()) newGlobals.push_back(newGlobal); + requiredBuiltInInputs.push_back(editor.GetBuiltInVariable(rdcspv::BuiltIn::WorkgroupId)); + requiredBuiltInInputs.push_back(editor.GetBuiltInVariable(rdcspv::BuiltIn::NumWorkgroups)); // x + y * xsize + z * xsize * ysize rdcspv::Id xsize = locationCalculate.add( @@ -2689,6 +2712,7 @@ static void AddMeshShaderOutputStores(const ShaderReflection &refl, ops, ShaderStage::Mesh, rdcspv::BuiltIn::LocalInvocationIndex, uint32Type); if(newGlobal != rdcspv::Id()) newGlobals.push_back(newGlobal); + requiredBuiltInInputs.push_back(editor.GetBuiltInVariable(rdcspv::BuiltIn::LocalInvocationIndex)); } // add the globals we registered @@ -2702,6 +2726,12 @@ static void AddMeshShaderOutputStores(const ShaderReflection &refl, editor.Remove(it); entry.iface.append(newGlobals); + for(rdcspv::Id id : requiredBuiltInInputs) + { + if(entry.iface.contains(id)) + continue; + entry.iface.push_back(id); + } editor.AddOperation(it, entry); }