@@ -1697,6 +1697,7 @@ static void AddTaskShaderPayloadStores(const rdcarray<SpecConstant> &specInfo,
16971697 }
16981698
16991699 rdcarray<rdcspv::Id> newGlobals;
1700+ rdcarray<rdcspv::Id> requiredBuiltInInputs;
17001701
17011702 newGlobals.push_back (outSlotAddr);
17021703
@@ -1708,6 +1709,7 @@ static void AddTaskShaderPayloadStores(const rdcarray<SpecConstant> &specInfo,
17081709 ops, ShaderStage::Mesh, rdcspv::BuiltIn::LocalInvocationIndex, uint32Type);
17091710 if (newGlobal != rdcspv::Id ())
17101711 newGlobals.push_back (newGlobal);
1712+ requiredBuiltInInputs.push_back (editor.GetBuiltInVariable (rdcspv::BuiltIn::LocalInvocationIndex));
17111713 }
17121714
17131715 // calculate base address for our task group's data
@@ -1727,6 +1729,8 @@ static void AddTaskShaderPayloadStores(const rdcarray<SpecConstant> &specInfo,
17271729 if (newGlobal != rdcspv::Id ())
17281730 newGlobals.push_back (newGlobal);
17291731
1732+ requiredBuiltInInputs.push_back (editor.GetBuiltInVariable (rdcspv::BuiltIn::WorkgroupId));
1733+ requiredBuiltInInputs.push_back (editor.GetBuiltInVariable (rdcspv::BuiltIn::NumWorkgroups));
17301734 // x + y * xsize + z * xsize * ysize
17311735
17321736 rdcspv::Id xsize = locationCalculate.add (
@@ -1799,6 +1803,12 @@ static void AddTaskShaderPayloadStores(const rdcarray<SpecConstant> &specInfo,
17991803 editor.Remove (it);
18001804
18011805 entry.iface .append (newGlobals);
1806+ for (rdcspv::Id id : requiredBuiltInInputs)
1807+ {
1808+ if (entry.iface .contains (id))
1809+ continue ;
1810+ entry.iface .push_back (id);
1811+ }
18021812
18031813 editor.AddOperation (it, entry);
18041814 }
@@ -1909,6 +1919,7 @@ static void ConvertToFixedTaskFeeder(const rdcarray<SpecConstant> &specInfo,
19091919 editor.SetName (baseAddrId, " baseAddr" );
19101920
19111921 rdcarray<rdcspv::Id> newGlobals;
1922+ rdcarray<rdcspv::Id> requiredBuiltInInputs;
19121923
19131924 rdcspv::Id entryID;
19141925
@@ -2037,6 +2048,9 @@ static void ConvertToFixedTaskFeeder(const rdcarray<SpecConstant> &specInfo,
20372048 if (newGlobal != rdcspv::Id ())
20382049 newGlobals.push_back (newGlobal);
20392050
2051+ requiredBuiltInInputs.push_back (editor.GetBuiltInVariable (rdcspv::BuiltIn::WorkgroupId));
2052+ requiredBuiltInInputs.push_back (editor.GetBuiltInVariable (rdcspv::BuiltIn::NumWorkgroups));
2053+
20402054 // x + y * xsize + z * xsize * ysize
20412055
20422056 rdcspv::Id xsize =
@@ -2164,6 +2178,12 @@ static void ConvertToFixedTaskFeeder(const rdcarray<SpecConstant> &specInfo,
21642178 editor.Remove (it);
21652179
21662180 entry.iface .append (newGlobals);
2181+ for (rdcspv::Id id : requiredBuiltInInputs)
2182+ {
2183+ if (entry.iface .contains (id))
2184+ continue ;
2185+ entry.iface .push_back (id);
2186+ }
21672187
21682188 editor.AddOperation (it, entry);
21692189 }
@@ -2211,6 +2231,7 @@ static void AddMeshShaderOutputStores(const ShaderReflection &refl,
22112231 editor.SetName (baseAddrId, " baseAddr" );
22122232
22132233 rdcarray<rdcspv::Id> newGlobals;
2234+ rdcarray<rdcspv::Id> requiredBuiltInInputs;
22142235
22152236 newGlobals.push_back (outSlotAddr);
22162237
@@ -2608,6 +2629,8 @@ static void AddMeshShaderOutputStores(const ShaderReflection &refl,
26082629 if (newGlobal != rdcspv::Id ())
26092630 newGlobals.push_back (newGlobal);
26102631
2632+ requiredBuiltInInputs.push_back (editor.GetBuiltInVariable (rdcspv::BuiltIn::WorkgroupId));
2633+ requiredBuiltInInputs.push_back (editor.GetBuiltInVariable (rdcspv::BuiltIn::NumWorkgroups));
26112634 // x + y * xsize + z * xsize * ysize
26122635
26132636 rdcspv::Id xsize = locationCalculate.add (
@@ -2689,6 +2712,7 @@ static void AddMeshShaderOutputStores(const ShaderReflection &refl,
26892712 ops, ShaderStage::Mesh, rdcspv::BuiltIn::LocalInvocationIndex, uint32Type);
26902713 if (newGlobal != rdcspv::Id ())
26912714 newGlobals.push_back (newGlobal);
2715+ requiredBuiltInInputs.push_back (editor.GetBuiltInVariable (rdcspv::BuiltIn::LocalInvocationIndex));
26922716 }
26932717
26942718 // add the globals we registered
@@ -2702,6 +2726,12 @@ static void AddMeshShaderOutputStores(const ShaderReflection &refl,
27022726 editor.Remove (it);
27032727
27042728 entry.iface .append (newGlobals);
2729+ for (rdcspv::Id id : requiredBuiltInInputs)
2730+ {
2731+ if (entry.iface .contains (id))
2732+ continue ;
2733+ entry.iface .push_back (id);
2734+ }
27052735
27062736 editor.AddOperation (it, entry);
27072737 }
0 commit comments