You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit is mainly to allow OpTypeNodePayloadArrayAMDX to be
duplicated in SPIRV when using WorkGraphs.
AMD spec requires that there should be dedicated type declaration with
OpTypeNodePayloadArrayAMDX for each "node". And each of them should be
decorated with PayloadNodeNameAMDX.
https://docs.vulkan.org/features/latest/features/proposals/VK_AMDX_shader_enqueue.html
This behavior is very different from how "types" are declared. Normally
types are declared only once and they are shared across the whole
program. But for the work-graphs, each "RecordType" belongs to each node
and they need to be declared for each node.
Consider the following HLSL example where a producer triggers two
consumer nodes. Each node will be differentiated by "NodeID" attribute.
```
[Shader("node")]
[NodeLaunch("broadcasting")]
[NumThreads(4,1,1)]
void myFancyNode(...,
[NodeID("myNode1")] NodeOutput<MY_RECORD> myRecords1,
[NodeID("myNode2")] NodeOutput<MY_RECORD> myRecords2,
...)
{
ThreadNodeOutputRecords<MY_RECORD> myRecord1 = myRecords1.GetThreadNodeOutputRecords(1);
myRecord1.myData = 1;
myRecord1.OutputCompelete();
ThreadNodeOutputRecords<MY_RECORD> myRecord2 = myRecords2.GetThreadNodeOutputRecords(1);
myRecord2.myData = 1;
myRecord2.OutputCompelete();
}
```
Even though both are using the same type, "MY_RECORD", each of them
needs to be declared separately. The generated SPIR-V code for the
HLSL above is something like the following,
```
%str_node1 = OpConstantStringAMDX "myNode1";
%str_node2 = OpConstantStringAMDX "myNode1";
%type_node1 = OpTypeNodePayloadArrayAMDX %type_myRecord;
%type_node2 = OpTypeNodePayloadArrayAMDX %type_myRecord;
OpDecorateId %type_node1 PayloadNodeNameAMDX %str_node1;
OpDecorateId %type_node2 PayloadNodeNameAMDX %str_node2;
```
Note that `%type_node1` and `%type_node2` are equivalent, but they must
be declared separately because each of them will be decorated with
different nodeID string.
0 commit comments