Skip to content

Commit 18f9ef6

Browse files
committed
add a resource to try and circumvent any issues
1 parent 6fdaf77 commit 18f9ef6

2 files changed

Lines changed: 133 additions & 62 deletions

File tree

tools/clang/test/CodeGenDXIL/hlsl/objects/RayQuery/allocateRayQuery2.hlsl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55
// RUN: %dxc -T vs_6_9 %s | FileCheck %s
66
// RUN: %dxc -T vs_6_9 -fcgl %s | FileCheck -check-prefix=FCGL %s
77

8+
StructuredBuffer<float3> vertexOffsets : register(t0);
9+
10+
struct VSInput {
11+
float3 pos : POSITION;
12+
uint id : SV_VertexID;
13+
};
14+
15+
struct VSOutput {
16+
float4 pos : SV_POSITION;
17+
};
818

919
RaytracingAccelerationStructure RTAS;
1020
[shader("vertex")]
11-
void main(RayDesc rayDesc : RAYDESC) {
21+
VSOutput main(VSInput input, RayDesc rayDesc : RAYDESC) {
1222

1323
// CHECK: call i32 @dx.op.allocateRayQuery2(i32 258, i32 1024, i32 1)
1424
// FCGL: call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 4, i32 1024, i32 1)
@@ -20,4 +30,11 @@ void main(RayDesc rayDesc : RAYDESC) {
2030
// FCGL: call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 4, i32 1, i32 0)
2131
RayQuery<RAY_FLAG_FORCE_OPAQUE> rayQuery2;
2232
rayQuery2.TraceRayInline(RTAS, 0, 2, rayDesc);
33+
34+
VSOutput output;
35+
36+
// Add an offset from the buffer to the vertex position
37+
output.pos = float4(input.pos + vertexOffsets[input.id], 1.0);
38+
39+
return output;
2340
}

tools/clang/test/DXC/Passes/DxilGenerationPass/LowerAllocateRayQuery2.ll

Lines changed: 115 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22
; generated the IR with:
33
; ExtractIRForPassTest.py -p dxilgen -o LowerAllocateRayQuery2.ll tools\clang\test\CodeGenDXIL\hlsl\objects\RayQuery\allocateRayQuery2.hlsl -- -T lib_6_9
44

5+
; RUN: %dxopt %s -hlsl-passes-resume -dxilgen -S | FileCheck %s
6+
57
target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64"
68
target triple = "dxil-ms-dx"
79

10+
%"class.StructuredBuffer<vector<float, 3> >" = type { <3 x float> }
811
%struct.RaytracingAccelerationStructure = type { i32 }
912
%dx.types.Handle = type { i8* }
1013
%dx.types.ResourceProperties = type { i32, i32 }
14+
%struct.VSOutput = type { <4 x float> }
15+
%struct.VSInput = type { <3 x float>, i32 }
1116
%struct.RayDesc = type { <3 x float>, float, <3 x float>, float }
1217
%"class.RayQuery<1024, 1>" = type { i32 }
1318
%"class.RayQuery<1, 0>" = type { i32 }
1419

20+
@"\01?vertexOffsets@@3V?$StructuredBuffer@V?$vector@M$02@@@@A" = external global %"class.StructuredBuffer<vector<float, 3> >", align 4
1521
@"\01?RTAS@@3URaytracingAccelerationStructure@@A" = external global %struct.RaytracingAccelerationStructure, align 4
1622

1723
; Function Attrs: nounwind
@@ -26,26 +32,49 @@ declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.Ra
2632
; Function Attrs: nounwind readnone
2733
declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure) #1
2834

35+
; Function Attrs: nounwind readnone
36+
declare <3 x float>* @"dx.hl.subscript.[].rn.<3 x float>* (i32, %dx.types.Handle, i32)"(i32, %dx.types.Handle, i32) #1
37+
38+
; Function Attrs: nounwind readnone
39+
declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %\22class.StructuredBuffer<vector<float, 3> >\22)"(i32, %"class.StructuredBuffer<vector<float, 3> >") #1
40+
41+
; Function Attrs: nounwind readnone
42+
declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %\22class.StructuredBuffer<vector<float, 3> >\22)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %"class.StructuredBuffer<vector<float, 3> >") #1
43+
2944
; Function Attrs: nounwind
3045
declare i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32, i32, i32) #0
3146

3247
; Function Attrs: nounwind
33-
define void @main(<3 x float>, float, <3 x float>, float) #0 {
48+
define void @main(<4 x float>* noalias, <3 x float>, i32, <3 x float>, float, <3 x float>, float) #0 {
3449
entry:
3550
; CHECK: call i32 @dx.op.allocateRayQuery2(i32 258, i32 1024, i32 1)
36-
%rayQuery12 = call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 4, i32 1024, i32 1), !dbg !42 ; line:15 col:79
37-
%4 = load %struct.RaytracingAccelerationStructure, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !dbg !46 ; line:17 col:3
38-
%5 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32 0, %struct.RaytracingAccelerationStructure %4), !dbg !46 ; line:17 col:3
39-
%6 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure)"(i32 14, %dx.types.Handle %5, %dx.types.ResourceProperties { i32 16, i32 0 }, %struct.RaytracingAccelerationStructure zeroinitializer), !dbg !46 ; line:17 col:3
40-
call void @"dx.hl.op..void (i32, i32, %dx.types.Handle, i32, i32, <3 x float>, float, <3 x float>, float)"(i32 320, i32 %rayQuery12, %dx.types.Handle %6, i32 1024, i32 2, <3 x float> %0, float %1, <3 x float> %2, float %3), !dbg !46 ; line:17 col:3
51+
%rayQuery14 = call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 4, i32 1024, i32 1), !dbg !60 ; line:25 col:79
52+
%7 = load %struct.RaytracingAccelerationStructure, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !dbg !64 ; line:27 col:3
53+
%8 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32 0, %struct.RaytracingAccelerationStructure %7), !dbg !64 ; line:27 col:3
54+
%9 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure)"(i32 14, %dx.types.Handle %8, %dx.types.ResourceProperties { i32 16, i32 0 }, %struct.RaytracingAccelerationStructure zeroinitializer), !dbg !64 ; line:27 col:3
55+
call void @"dx.hl.op..void (i32, i32, %dx.types.Handle, i32, i32, <3 x float>, float, <3 x float>, float)"(i32 320, i32 %rayQuery14, %dx.types.Handle %9, i32 1024, i32 2, <3 x float> %3, float %4, <3 x float> %5, float %6), !dbg !64 ; line:27 col:3
4156

4257
; CHECK: call i32 @dx.op.allocateRayQuery(i32 178, i32 1)
43-
%rayQuery23 = call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 4, i32 1, i32 0), !dbg !47 ; line:21 col:35
44-
%7 = load %struct.RaytracingAccelerationStructure, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !dbg !48 ; line:22 col:3
45-
%8 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32 0, %struct.RaytracingAccelerationStructure %7), !dbg !48 ; line:22 col:3
46-
%9 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure)"(i32 14, %dx.types.Handle %8, %dx.types.ResourceProperties { i32 16, i32 0 }, %struct.RaytracingAccelerationStructure zeroinitializer), !dbg !48 ; line:22 col:3
47-
call void @"dx.hl.op..void (i32, i32, %dx.types.Handle, i32, i32, <3 x float>, float, <3 x float>, float)"(i32 320, i32 %rayQuery23, %dx.types.Handle %9, i32 0, i32 2, <3 x float> %0, float %1, <3 x float> %2, float %3), !dbg !48 ; line:22 col:3
48-
ret void, !dbg !49 ; line:23 col:1
58+
%rayQuery25 = call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 4, i32 1, i32 0), !dbg !65 ; line:31 col:35
59+
%10 = load %struct.RaytracingAccelerationStructure, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !dbg !66 ; line:32 col:3
60+
%11 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32 0, %struct.RaytracingAccelerationStructure %10), !dbg !66 ; line:32 col:3
61+
%12 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure)"(i32 14, %dx.types.Handle %11, %dx.types.ResourceProperties { i32 16, i32 0 }, %struct.RaytracingAccelerationStructure zeroinitializer), !dbg !66 ; line:32 col:3
62+
call void @"dx.hl.op..void (i32, i32, %dx.types.Handle, i32, i32, <3 x float>, float, <3 x float>, float)"(i32 320, i32 %rayQuery25, %dx.types.Handle %12, i32 0, i32 2, <3 x float> %3, float %4, <3 x float> %5, float %6), !dbg !66 ; line:32 col:3
63+
%13 = load %"class.StructuredBuffer<vector<float, 3> >", %"class.StructuredBuffer<vector<float, 3> >"* @"\01?vertexOffsets@@3V?$StructuredBuffer@V?$vector@M$02@@@@A", !dbg !67 ; line:37 col:35
64+
%14 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %\22class.StructuredBuffer<vector<float, 3> >\22)"(i32 0, %"class.StructuredBuffer<vector<float, 3> >" %13), !dbg !67 ; line:37 col:35
65+
%15 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %\22class.StructuredBuffer<vector<float, 3> >\22)"(i32 14, %dx.types.Handle %14, %dx.types.ResourceProperties { i32 12, i32 12 }, %"class.StructuredBuffer<vector<float, 3> >" zeroinitializer), !dbg !67 ; line:37 col:35
66+
%16 = call <3 x float>* @"dx.hl.subscript.[].rn.<3 x float>* (i32, %dx.types.Handle, i32)"(i32 0, %dx.types.Handle %15, i32 %2), !dbg !67 ; line:37 col:35
67+
%17 = load <3 x float>, <3 x float>* %16, !dbg !67, !tbaa !68 ; line:37 col:35
68+
%add = fadd <3 x float> %1, %17, !dbg !71 ; line:37 col:33
69+
%18 = extractelement <3 x float> %add, i64 0, !dbg !72 ; line:37 col:22
70+
%19 = extractelement <3 x float> %add, i64 1, !dbg !72 ; line:37 col:22
71+
%20 = extractelement <3 x float> %add, i64 2, !dbg !72 ; line:37 col:22
72+
%21 = insertelement <4 x float> undef, float %18, i64 0, !dbg !72 ; line:37 col:22
73+
%22 = insertelement <4 x float> %21, float %19, i64 1, !dbg !72 ; line:37 col:22
74+
%23 = insertelement <4 x float> %22, float %20, i64 2, !dbg !72 ; line:37 col:22
75+
%24 = insertelement <4 x float> %23, float 1.000000e+00, i64 3, !dbg !72 ; line:37 col:22
76+
store <4 x float> %24, <4 x float>* %0, !dbg !73 ; line:39 col:10
77+
ret void, !dbg !74 ; line:40 col:1
4978
}
5079

5180
; Function Attrs: nounwind
@@ -60,58 +89,83 @@ attributes #1 = { nounwind readnone }
6089
!dx.version = !{!3}
6190
!dx.valver = !{!3}
6291
!dx.shaderModel = !{!4}
63-
!dx.typeAnnotations = !{!5, !21}
64-
!dx.entryPoints = !{!34}
65-
!dx.fnprops = !{!39}
66-
!dx.options = !{!40, !41}
92+
!dx.typeAnnotations = !{!5, !31}
93+
!dx.entryPoints = !{!50}
94+
!dx.fnprops = !{!57}
95+
!dx.options = !{!58, !59}
6796

6897
!0 = !{i32 2, !"Debug Info Version", i32 3}
6998
!1 = !{!"hlsl-hlemit", !"hlsl-hlensure"}
7099
!2 = !{!"dxc(private) 1.8.0.4853 (lowerOMM, ca5df957eb33-dirty)"}
71100
!3 = !{i32 1, i32 9}
72101
!4 = !{!"lib", i32 6, i32 9}
73-
!5 = !{i32 0, %struct.RayDesc undef, !6, %"class.RayQuery<1024, 1>" undef, !11, %"class.RayQuery<1, 0>" undef, !17}
74-
!6 = !{i32 32, !7, !8, !9, !10}
75-
!7 = !{i32 6, !"Origin", i32 3, i32 0, i32 7, i32 9, i32 13, i32 3}
76-
!8 = !{i32 6, !"TMin", i32 3, i32 12, i32 7, i32 9}
77-
!9 = !{i32 6, !"Direction", i32 3, i32 16, i32 7, i32 9, i32 13, i32 3}
78-
!10 = !{i32 6, !"TMax", i32 3, i32 28, i32 7, i32 9}
79-
!11 = !{i32 4, !12, !13}
80-
!12 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 5}
81-
!13 = !{i32 0, !14}
82-
!14 = !{!15, !16}
83-
!15 = !{i32 1, i64 1024}
84-
!16 = !{i32 1, i64 1}
85-
!17 = !{i32 4, !12, !18}
86-
!18 = !{i32 0, !19}
87-
!19 = !{!16, !20}
88-
!20 = !{i32 1, i64 0}
89-
!21 = !{i32 1, void (<3 x float>, float, <3 x float>, float)* @main, !22}
90-
!22 = !{!23, !25, !28, !30, !32}
91-
!23 = !{i32 0, !24, !24}
92-
!24 = !{}
93-
!25 = !{i32 0, !26, !27}
94-
!26 = !{i32 4, !"RAYDESC", i32 7, i32 9}
95-
!27 = !{i32 0}
96-
!28 = !{i32 0, !26, !29}
97-
!29 = !{i32 1}
98-
!30 = !{i32 0, !26, !31}
99-
!31 = !{i32 2}
100-
!32 = !{i32 0, !26, !33}
101-
!33 = !{i32 3}
102-
!34 = !{null, !"", null, !35, null}
103-
!35 = !{!36, null, null, null}
104-
!36 = !{!37}
105-
!37 = !{i32 0, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !"RTAS", i32 -1, i32 -1, i32 1, i32 16, i32 0, !38}
106-
!38 = !{i32 0, i32 4}
107-
!39 = !{void (<3 x float>, float, <3 x float>, float)* @main, i32 1}
108-
!40 = !{i32 -2147483584}
109-
!41 = !{i32 -1}
110-
!42 = !DILocation(line: 15, column: 79, scope: !43)
111-
!43 = !DISubprogram(name: "main", scope: !44, file: !44, line: 11, type: !45, isLocal: false, isDefinition: true, scopeLine: 11, flags: DIFlagPrototyped, isOptimized: false, function: void (<3 x float>, float, <3 x float>, float)* @main)
112-
!44 = !DIFile(filename: "tools\5Cclang\5Ctest\5CCodeGenDXIL\5Chlsl\5Cobjects\5CRayQuery\5CallocateRayQuery2.hlsl", directory: "")
113-
!45 = !DISubroutineType(types: !24)
114-
!46 = !DILocation(line: 17, column: 3, scope: !43)
115-
!47 = !DILocation(line: 21, column: 35, scope: !43)
116-
!48 = !DILocation(line: 22, column: 3, scope: !43)
117-
!49 = !DILocation(line: 23, column: 1, scope: !43)
102+
!5 = !{i32 0, %"class.StructuredBuffer<vector<float, 3> >" undef, !6, %struct.VSOutput undef, !11, %struct.VSInput undef, !13, %struct.RayDesc undef, !16, %"class.RayQuery<1024, 1>" undef, !21, %"class.RayQuery<1, 0>" undef, !27}
103+
!6 = !{i32 12, !7, !8}
104+
!7 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 9, i32 13, i32 3}
105+
!8 = !{i32 0, !9}
106+
!9 = !{!10}
107+
!10 = !{i32 0, <3 x float> undef}
108+
!11 = !{i32 16, !12}
109+
!12 = !{i32 6, !"pos", i32 3, i32 0, i32 4, !"SV_POSITION", i32 7, i32 9, i32 13, i32 4}
110+
!13 = !{i32 16, !14, !15}
111+
!14 = !{i32 6, !"pos", i32 3, i32 0, i32 4, !"POSITION", i32 7, i32 9, i32 13, i32 3}
112+
!15 = !{i32 6, !"id", i32 3, i32 12, i32 4, !"SV_VertexID", i32 7, i32 5}
113+
!16 = !{i32 32, !17, !18, !19, !20}
114+
!17 = !{i32 6, !"Origin", i32 3, i32 0, i32 7, i32 9, i32 13, i32 3}
115+
!18 = !{i32 6, !"TMin", i32 3, i32 12, i32 7, i32 9}
116+
!19 = !{i32 6, !"Direction", i32 3, i32 16, i32 7, i32 9, i32 13, i32 3}
117+
!20 = !{i32 6, !"TMax", i32 3, i32 28, i32 7, i32 9}
118+
!21 = !{i32 4, !22, !23}
119+
!22 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 5}
120+
!23 = !{i32 0, !24}
121+
!24 = !{!25, !26}
122+
!25 = !{i32 1, i64 1024}
123+
!26 = !{i32 1, i64 1}
124+
!27 = !{i32 4, !22, !28}
125+
!28 = !{i32 0, !29}
126+
!29 = !{!26, !30}
127+
!30 = !{i32 1, i64 0}
128+
!31 = !{i32 1, void (<4 x float>*, <3 x float>, i32, <3 x float>, float, <3 x float>, float)* @main, !32}
129+
!32 = !{!33, !35, !38, !40, !42, !44, !46, !48}
130+
!33 = !{i32 0, !34, !34}
131+
!34 = !{}
132+
!35 = !{i32 1, !36, !37}
133+
!36 = !{i32 4, !"SV_POSITION", i32 7, i32 9}
134+
!37 = !{i32 0}
135+
!38 = !{i32 0, !39, !37}
136+
!39 = !{i32 4, !"POSITION", i32 7, i32 9}
137+
!40 = !{i32 0, !41, !37}
138+
!41 = !{i32 4, !"SV_VertexID", i32 7, i32 5}
139+
!42 = !{i32 0, !43, !37}
140+
!43 = !{i32 4, !"RAYDESC", i32 7, i32 9}
141+
!44 = !{i32 0, !43, !45}
142+
!45 = !{i32 1}
143+
!46 = !{i32 0, !43, !47}
144+
!47 = !{i32 2}
145+
!48 = !{i32 0, !43, !49}
146+
!49 = !{i32 3}
147+
!50 = !{null, !"", null, !51, null}
148+
!51 = !{!52, null, null, null}
149+
!52 = !{!53, !55}
150+
!53 = !{i32 0, %"class.StructuredBuffer<vector<float, 3> >"* @"\01?vertexOffsets@@3V?$StructuredBuffer@V?$vector@M$02@@@@A", !"vertexOffsets", i32 0, i32 0, i32 1, i32 12, i32 0, !54}
151+
!54 = !{i32 1, i32 12}
152+
!55 = !{i32 1, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !"RTAS", i32 -1, i32 -1, i32 1, i32 16, i32 0, !56}
153+
!56 = !{i32 0, i32 4}
154+
!57 = !{void (<4 x float>*, <3 x float>, i32, <3 x float>, float, <3 x float>, float)* @main, i32 1}
155+
!58 = !{i32 -2147483584}
156+
!59 = !{i32 -1}
157+
!60 = !DILocation(line: 25, column: 79, scope: !61)
158+
!61 = !DISubprogram(name: "main", scope: !62, file: !62, line: 21, type: !63, isLocal: false, isDefinition: true, scopeLine: 21, flags: DIFlagPrototyped, isOptimized: false, function: void (<4 x float>*, <3 x float>, i32, <3 x float>, float, <3 x float>, float)* @main)
159+
!62 = !DIFile(filename: "tools\5Cclang\5Ctest\5CCodeGenDXIL\5Chlsl\5Cobjects\5CRayQuery\5CallocateRayQuery2.hlsl", directory: "")
160+
!63 = !DISubroutineType(types: !34)
161+
!64 = !DILocation(line: 27, column: 3, scope: !61)
162+
!65 = !DILocation(line: 31, column: 35, scope: !61)
163+
!66 = !DILocation(line: 32, column: 3, scope: !61)
164+
!67 = !DILocation(line: 37, column: 35, scope: !61)
165+
!68 = !{!69, !69, i64 0}
166+
!69 = !{!"omnipotent char", !70, i64 0}
167+
!70 = !{!"Simple C/C++ TBAA"}
168+
!71 = !DILocation(line: 37, column: 33, scope: !61)
169+
!72 = !DILocation(line: 37, column: 22, scope: !61)
170+
!73 = !DILocation(line: 39, column: 10, scope: !61)
171+
!74 = !DILocation(line: 40, column: 1, scope: !61)

0 commit comments

Comments
 (0)