Skip to content

Commit 58b3508

Browse files
committed
Corrects SPIR-V decoration emitted for node base index.
1 parent 5520a28 commit 58b3508

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tools/clang/lib/SPIRV/EmitVisitor.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,29 +2956,29 @@ void EmitTypeHandler::emitDecorationsForNodePayloadArrayTypes(
29562956
// Emit decorations
29572957
const ParmVarDecl *nodeDecl = npaType->getNodeDecl();
29582958
if (hlsl::IsHLSLNodeOutputType(nodeDecl->getType())) {
2959-
StringRef name = nodeDecl->getName();
2960-
unsigned index = 0;
2959+
StringRef name;
2960+
llvm::Optional<unsigned> index;
29612961
if (auto nodeID = nodeDecl->getAttr<HLSLNodeIdAttr>()) {
29622962
name = nodeID->getName();
2963-
index = nodeID->getArrayIndex();
2963+
index = getAttrArgInstr(astContext, nodeID->getArrayIndex());
2964+
} else {
2965+
name = nodeDecl->getName();
2966+
index = llvm::None;
29642967
}
29652968

29662969
auto *str = new (context) SpirvConstantString(name);
29672970
uint32_t nodeName = getOrCreateConstantString(str);
29682971
emitDecoration(id, spv::Decoration::PayloadNodeNameAMDX, {nodeName},
29692972
llvm::None, true);
2970-
if (index) {
2971-
uint32_t baseIndex = getOrCreateConstantInt(
2972-
llvm::APInt(32, index), context.getUIntType(32), false);
2973-
emitDecoration(id, spv::Decoration::PayloadNodeBaseIndexAMDX, {baseIndex},
2974-
llvm::None, true);
2973+
if (index.hasValue()) {
2974+
emitDecoration(id, spv::Decoration::PayloadNodeBaseIndexAMDX,
2975+
{index.getValue()}, llvm::None, true);
29752976
}
29762977
}
29772978

29782979
uint32_t maxRecords;
29792980
if (const auto *attr = nodeDecl->getAttr<HLSLMaxRecordsAttr>()) {
2980-
maxRecords = getOrCreateConstantInt(llvm::APInt(32, attr->getMaxCount()),
2981-
context.getUIntType(32), false);
2981+
maxRecords = getAttrArgInstr(astContext, attr->getMaxCount(), 1);
29822982
} else {
29832983
maxRecords = getOrCreateConstantInt(llvm::APInt(32, 1),
29842984
context.getUIntType(32), false);

0 commit comments

Comments
 (0)