Skip to content

Commit 4cfc2a5

Browse files
committed
Fix SPIRV error for WorkGraphs
This commit resolves an error message that is caused while emitting SPIRV code. The cause was on the fact that there is no corresponding IRInst for one of SPIRV instructions when emitting, ``` %in_payload_t = OpTypeNodePayloadArrayAMDX $$T; %in_payload_ptr_t = OpTypePointer NodePayloadAMDX %in_payload_t; ``` There is an IRInst for `OpTypePointer` but there isn't IRInst corresponding to `OpTypeNodePayloadArrayAMDX`. When Slang emits `OpTypePointer` with its second operand `OpTypeNodePayloadArrayAMDX`, it is going to be emitted without a matching IRInst.
1 parent ca592d2 commit 4cfc2a5

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

source/slang/hlsl.meta.slang

+1-3
Original file line numberDiff line numberDiff line change
@@ -24407,9 +24407,7 @@ struct DispatchNodeInputRecord
2440724407
case spirv:
2440824408
return spirv_asm
2440924409
{
24410-
%in_payload_t = OpTypeNodePayloadArrayAMDX $$T;
24411-
%in_payload_ptr_t = OpTypePointer NodePayloadAMDX %in_payload_t;
24412-
%var = OpVariable %in_payload_ptr_t NodePayloadAMDX;
24410+
%var = OpVariable $$NodePayloadPtr<T> NodePayloadAMDX;
2441324411
result : $$NodePayloadPtr<T> = OpAccessChain %var $index;
2441424412
};
2441524413
}

source/slang/slang-emit-spirv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
15421542
else if (storageClass == SpvStorageClassNodePayloadAMDX)
15431543
{
15441544
auto spvValueType = ensureInst(valueType);
1545-
auto spvNodePayloadType = emitOpTypeNodePayloadArray(inst, spvValueType);
1545+
auto spvNodePayloadType = emitOpTypeNodePayloadArray(nullptr, spvValueType);
15461546
valueTypeId = getID(spvNodePayloadType);
15471547
}
15481548
else

tests/workgraphs/consumer.slang

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ void main(uint3 dispatchThreadId : SV_GroupThreadID)
2020
int myData = recordData.myData;
2121
}
2222

23+
//CHK: OpCapability ShaderEnqueueAMDX
24+
//CHK: OpExtension "SPV_AMDX_shader_enqueue"
25+
2326
//CHK: ; Types, variables and constants
2427
//CHK: [[MemberType:%[a-zA-Z_0-9]+]] = OpTypeInt 32 1
2528
//CHK: [[StructType:%[a-zA-Z_0-9]+]] = OpTypeStruct [[MemberType]]

0 commit comments

Comments
 (0)