Skip to content

Commit 2084643

Browse files
authored
[spirv] Corrects output node index parameter. (#7517)
The node index parameter of `OpAllocateNodePayloadsAMDX` was being set to the value of the NodeId index argument (which is captured in the `PayloadNodeBaseIndexAMDX` decoration). Instead, it should be set to the node's index in the node array, if any, or zero for a single node.
1 parent 50f53c6 commit 2084643

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11256,17 +11256,9 @@ SpirvInstruction *SpirvEmitter::processIntrinsicGetNodeOutputRecords(
1125611256

1125711257
const auto *declRefExpr = dyn_cast<DeclRefExpr>(baseExpr->IgnoreImpCasts());
1125811258
const auto *paramDecl = dyn_cast<ParmVarDecl>(declRefExpr->getDecl());
11259-
const auto *nodeID = paramDecl->getAttr<HLSLNodeIdAttr>();
11260-
StringRef nodeName = paramDecl->getName();
11261-
unsigned nodeIndex = 0;
11262-
if (nodeID) {
11263-
nodeName = nodeID->getName();
11264-
nodeIndex = nodeID->getArrayIndex();
11265-
}
11266-
1126711259
if (!shaderIndex) {
11268-
shaderIndex = spvBuilder.getConstantInt(astContext.UnsignedIntTy,
11269-
llvm::APInt(32, nodeIndex));
11260+
shaderIndex =
11261+
spvBuilder.getConstantInt(astContext.UnsignedIntTy, llvm::APInt(32, 0));
1127011262
}
1127111263

1127211264
LowerTypeVisitor lowerTypeVisitor(astContext, spvContext, spirvOptions,

tools/clang/test/CodeGenSPIRV/node.renamed.hlsl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ struct RECORD {
1212
[NodeIsProgramEntry]
1313
void node017_renamed_node([NodeID("output_node_name", 2)] NodeOutput<RECORD> r)
1414
{
15-
r.GetThreadNodeOutputRecords(1);
15+
ThreadNodeOutputRecords<RECORD> records = r.GetThreadNodeOutputRecords(1);
16+
records.OutputComplete();
1617
}
1718

1819
// CHECK: OpEntryPoint GLCompute %{{[^ ]*}} "node017_renamed_node"
1920
// CHECK-DAG: OpDecorateId [[TYPE:%[^ ]*]] PayloadNodeNameAMDX [[STR:%[0-9A-Za-z_]*]]
2021
// CHECK-DAG: OpDecorateId [[TYPE]] PayloadNodeBaseIndexAMDX [[U2:%[0-9A-Za-z_]*]]
2122
// CHECK: [[UINT:%[^ ]*]] = OpTypeInt 32 0
2223
// CHECK-DAG: [[STR]] = OpConstantStringAMDX "output_node_name"
24+
// CHECK-DAG: [[U0:%[_0-9A-Za-z]*]] = OpConstant [[UINT]] 0
25+
// CHECK-DAG: [[U1:%[_0-9A-Za-z]*]] = OpConstant [[UINT]] 1
2326
// CHECK-DAG: [[U2]] = OpConstant [[UINT]] 2
27+
// CHECK-DAG: [[U4:%[_0-9A-Za-z]*]] = OpConstant [[UINT]] 4
28+
// CHECK: OpAllocateNodePayloadsAMDX %{{[^ ]*}} [[U4]] [[U1]] [[U0]]

0 commit comments

Comments
 (0)