Skip to content
Open
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
7 changes: 4 additions & 3 deletions tools/clang/lib/SPIRV/AstTypeProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,12 +1141,13 @@ bool isOpaqueType(QualType type) {
if (name == "RaytracingAccelerationStructure")
return true;

if (name == "RayQuery")
return true;

if (name == "SubpassInput")
return true;
}

if (hlsl::IsHLSLRayQueryType(type))
return true;

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion tools/clang/lib/SPIRV/LowerTypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ LowerTypeVisitor::lowerResourceType(QualType type, SpirvLayoutRule rule,
return spvContext.getAccelerationStructureTypeNV();
}

if (name == "RayQuery")
if (hlsl::IsHLSLRayQueryType(type))
return spvContext.getRayQueryTypeKHR();

if (name == "StructuredBuffer" || name == "RWStructuredBuffer" ||
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// RUN: %dxc -T cs_6_6 -E MainRayGenShader -fcgl -spirv %s | FileCheck %s

// A user-defined struct named "RayQuery" that shadows the reserved intrinsic
// name must be lowered as an ordinary struct, not as the opaque ray query
// type. Previously this crashed the SPIR-V backend.
// See https://github.com/microsoft/DirectXShaderCompiler/issues/8601

namespace UnifiedRT {
struct RayQuery {
float4 foo;
};
} // namespace UnifiedRT

// The shadowing struct is lowered to an ordinary struct with a float4 field,
// and the local variable uses that struct type in the Function storage class.
// CHECK: %RayQuery = OpTypeStruct %v4float
// CHECK: %_ptr_Function_RayQuery = OpTypePointer Function %RayQuery
// CHECK: %rayQuery = OpVariable %_ptr_Function_RayQuery Function

// It must not be lowered to the opaque ray query type.
// CHECK-NOT: OpTypeRayQueryKHR

StructuredBuffer<uint> _UnifiedRT_DispatchDims;

[numthreads(128, 1, 1)]
void MainRayGenShader(in uint3 gidx : SV_DispatchThreadID,
in uint lidx : SV_GroupIndex) {
if (gidx.x >= _UnifiedRT_DispatchDims[0] ||
gidx.y >= _UnifiedRT_DispatchDims[1] ||
gidx.z >= _UnifiedRT_DispatchDims[2])
return;

UnifiedRT::RayQuery rayQuery;
rayQuery.foo = float4(1.0, 1.0, 1.0, 1.0);
}
Loading