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
11 changes: 7 additions & 4 deletions tools/clang/lib/SPIRV/SpirvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7081,14 +7081,17 @@ SpirvInstruction *SpirvEmitter::reconstructValue(SpirvInstruction *srcVal,

// Structs
if (const auto *recordType = valType->getAs<RecordType>()) {
assert(recordType->isStructureType());

if (isTypeInVkNamespace(recordType) &&
recordType->getDecl()->getName().equals("BufferPointer")) {
// Uniquely among structs, vk::BufferPointer<T> lowers to a pointer type.
(recordType->getDecl()->getName().equals("BufferPointer") ||
recordType->getDecl()->getName().equals("SpirvType") ||
recordType->getDecl()->getName().equals("SpirvOpaqueType"))) {
// vk::BufferPointer<T> lowers to a pointer type. No need to reconstruct
// the value. The vk::Spirv*Type should be treated an opaque type. All we
// can do is leave it the same.
return srcVal;
}

assert(recordType->isStructureType());
LowerTypeVisitor lowerTypeVisitor(astContext, spvContext, spirvOptions,
spvBuilder);
const StructType *spirvStructType =
Expand Down
14 changes: 14 additions & 0 deletions tools/clang/test/CodeGenSPIRV/intrinsics.vkrawbufferload.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ struct BufferData {
float3 v;
};

using MyInt = vk::SpirvType<
/*spv::OpTypeInt*/21,
1,1, // size and alignment
vk::Literal<vk::integral_constant<uint,16> >, // bits
vk::Literal<vk::integral_constant<uint,1> > // signed
>;

uint64_t Address;

[[vk::ext_capability(/* Int16 */ 22)]]
float4 main() : SV_Target0 {
// CHECK: [[addr:%[0-9]+]] = OpLoad %ulong
// CHECK-NEXT: [[buf:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_float [[addr]]
Expand Down Expand Up @@ -50,5 +59,10 @@ float4 main() : SV_Target0 {
// CHECK-NEXT: [[load:%[0-9]+]] = OpLoad %BufferData_0 [[buf]] Aligned 4
d = vk::RawBufferLoad<BufferData>(0);

// CHECK: [[buf:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_spirvIntrinsicType %ulong_0
// CHECK-NEXT: [[load:%[0-9]+]] = OpLoad %spirvIntrinsicType [[buf]] Aligned 4
// CHECK-NEXT: OpStore %mi [[load]]
MyInt mi = vk::RawBufferLoad<MyInt>(0);

return float4(w.x, x, y, z);
}