diff --git a/tools/clang/lib/SPIRV/SpirvEmitter.cpp b/tools/clang/lib/SPIRV/SpirvEmitter.cpp index 7337a33b01..4aeaceeb5a 100644 --- a/tools/clang/lib/SPIRV/SpirvEmitter.cpp +++ b/tools/clang/lib/SPIRV/SpirvEmitter.cpp @@ -7081,14 +7081,17 @@ SpirvInstruction *SpirvEmitter::reconstructValue(SpirvInstruction *srcVal, // Structs if (const auto *recordType = valType->getAs()) { - assert(recordType->isStructureType()); - if (isTypeInVkNamespace(recordType) && - recordType->getDecl()->getName().equals("BufferPointer")) { - // Uniquely among structs, vk::BufferPointer lowers to a pointer type. + (recordType->getDecl()->getName().equals("BufferPointer") || + recordType->getDecl()->getName().equals("SpirvType") || + recordType->getDecl()->getName().equals("SpirvOpaqueType"))) { + // vk::BufferPointer 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 = diff --git a/tools/clang/test/CodeGenSPIRV/intrinsics.vkrawbufferload.hlsl b/tools/clang/test/CodeGenSPIRV/intrinsics.vkrawbufferload.hlsl index 7be0713e48..c2892cfc29 100644 --- a/tools/clang/test/CodeGenSPIRV/intrinsics.vkrawbufferload.hlsl +++ b/tools/clang/test/CodeGenSPIRV/intrinsics.vkrawbufferload.hlsl @@ -12,7 +12,16 @@ struct BufferData { float3 v; }; +using MyInt = vk::SpirvType< + /*spv::OpTypeInt*/21, + 1,1, // size and alignment + vk::Literal >, // bits + vk::Literal > // 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]] @@ -50,5 +59,10 @@ float4 main() : SV_Target0 { // CHECK-NEXT: [[load:%[0-9]+]] = OpLoad %BufferData_0 [[buf]] Aligned 4 d = vk::RawBufferLoad(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(0); + return float4(w.x, x, y, z); }