Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion tools/clang/lib/SPIRV/EmitVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,13 @@ bool EmitVisitor::visit(SpirvIntrinsicInstruction *inst) {
}
}

finalizeInstruction(&mainBinary);
auto opcode = static_cast<spv::Op>(inst->getInstruction());
if ((opcode == spv::Op::OpSpecConstant || opcode == spv::Op::OpConstant) &&
!inst->getInstructionSet()) {
finalizeInstruction(&typeConstantBinary);
} else {
finalizeInstruction(&mainBinary);
}
return true;
}

Expand Down
13 changes: 13 additions & 0 deletions tools/clang/test/CodeGenSPIRV/spv.intrinsicConstantValue.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %dxc -Od -T cs_6_8 -spirv -fcgl %s | FileCheck %s

// CHECK: %spirvIntrinsicType = OpTypeInt 8 0
using uint8_t [[vk::ext_capability(/* Int8 */ 39)]] =
vk::SpirvType</* OpTypeInt */ 21, 8, 8, vk::Literal<vk::integral_constant<uint, 8> >,
vk::Literal<vk::integral_constant<bool, false> > >;

[[vk::ext_instruction(/* OpConstant */ 43)]] uint8_t mkconsant([[vk::ext_literal]] int v);

// CHECK: OpConstant %spirvIntrinsicType 42
static const uint8_t K = mkconsant(42);

[numthreads(1, 1, 1)] void main() {}