|
| 1 | +; RUN: %dxopt %s -hlsl-passes-resume -dxilgen -S | FileCheck %s |
| 2 | + |
| 3 | +; Based on tools/clang/test/CodeGenDXIL/hlsl/objects/RayQuery/tracerayinline_cb_raydesc.hlsl |
| 4 | + |
| 5 | +; Capture CB, RTAS, and RayQuery |
| 6 | +; CHECK-DAG: %[[CB:[^ ,]+]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %"$Globals", %dx.types.ResourceProperties { i32 13, i32 32 }) |
| 7 | +; CHECK-DAG: %[[RTAS:[^ ,]+]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %{{[^ ,]+}}, %dx.types.ResourceProperties { i32 16, i32 0 }) |
| 8 | +; CHECK-DAG: %[[RQ:[^ ,]+]] = call i32 @dx.op.allocateRayQuery(i32 178, i32 513) |
| 9 | + |
| 10 | +; Load RayDesc.Origin |
| 11 | +; CHECK: %[[ORIG_CB_LD:[^ ,]+]] = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %[[CB]], i32 0) |
| 12 | +; CHECK: %[[ORIG_EX0:[^ ,]+]] = extractvalue %dx.types.CBufRet.f32 %[[ORIG_CB_LD]], 0 |
| 13 | +; CHECK: %[[ORIG_VX:[^ ,]+]] = insertelement <3 x float> undef, float %[[ORIG_EX0]], i64 0 |
| 14 | +; CHECK: %[[ORIG_EX1:[^ ,]+]] = extractvalue %dx.types.CBufRet.f32 %[[ORIG_CB_LD]], 1 |
| 15 | +; CHECK: %[[ORIG_VXY:[^ ,]+]] = insertelement <3 x float> %[[ORIG_VX]], float %[[ORIG_EX1]], i64 1 |
| 16 | +; CHECK: %[[ORIG_EX2:[^ ,]+]] = extractvalue %dx.types.CBufRet.f32 %[[ORIG_CB_LD]], 2 |
| 17 | +; CHECK: %[[ORIG_VXYZ:[^ ,]+]] = insertelement <3 x float> %[[ORIG_VXY]], float %[[ORIG_EX2]], i64 2 |
| 18 | + |
| 19 | +; Load RayDesc.TMin |
| 20 | +; CHECK: %[[TMIN_CB_LD:[^ ,]+]] = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %[[CB]], i32 0) |
| 21 | +; CHECK: %[[TMIN:[^ ,]+]] = extractvalue %dx.types.CBufRet.f32 %[[TMIN_CB_LD]], 3 |
| 22 | + |
| 23 | +; Load RayDesc.Direction |
| 24 | +; CHECK: %[[DIR_CB_LD:[^ ,]+]] = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %[[CB]], i32 1) |
| 25 | +; CHECK: %[[DIR_EX0:[^ ,]+]] = extractvalue %dx.types.CBufRet.f32 %[[DIR_CB_LD]], 0 |
| 26 | +; CHECK: %[[DIR_VX:[^ ,]+]] = insertelement <3 x float> undef, float %[[DIR_EX0]], i64 0 |
| 27 | +; CHECK: %[[DIR_EX1:[^ ,]+]] = extractvalue %dx.types.CBufRet.f32 %[[DIR_CB_LD]], 1 |
| 28 | +; CHECK: %[[DIR_VXY:[^ ,]+]] = insertelement <3 x float> %[[DIR_VX]], float %[[DIR_EX1]], i64 1 |
| 29 | +; CHECK: %[[DIR_EX2:[^ ,]+]] = extractvalue %dx.types.CBufRet.f32 %[[DIR_CB_LD]], 2 |
| 30 | +; CHECK: %[[DIR_VXYZ:[^ ,]+]] = insertelement <3 x float> %[[DIR_VXY]], float %[[DIR_EX2]], i64 2 |
| 31 | + |
| 32 | +; Load RayDesc.TMax |
| 33 | +; CHECK: %21 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %[[CB]], i32 1) |
| 34 | +; CHECK: %22 = extractvalue %dx.types.CBufRet.f32 %21, 3 |
| 35 | + |
| 36 | +; Extract RayDesc vector fields |
| 37 | +; CHECK: %[[ORIGX:[^ ,]+]] = extractelement <3 x float> %[[ORIG_VXYZ]], i64 0 |
| 38 | +; CHECK: %[[ORIGY:[^ ,]+]] = extractelement <3 x float> %[[ORIG_VXYZ]], i64 1 |
| 39 | +; CHECK: %[[ORIGZ:[^ ,]+]] = extractelement <3 x float> %[[ORIG_VXYZ]], i64 2 |
| 40 | +; CHECK: %[[DIRX:[^ ,]+]] = extractelement <3 x float> %[[DIR_VXYZ]], i64 0 |
| 41 | +; CHECK: %[[DIRY:[^ ,]+]] = extractelement <3 x float> %[[DIR_VXYZ]], i64 1 |
| 42 | +; CHECK: %[[DIRZ:[^ ,]+]] = extractelement <3 x float> %[[DIR_VXYZ]], i64 2 |
| 43 | + |
| 44 | +; Call TraceRayInline |
| 45 | +; CHECK: call void @dx.op.rayQuery_TraceRayInline(i32 179, i32 %[[RQ]], %dx.types.Handle %[[RTAS]], i32 1, i32 2, float %[[ORIGX]], float %[[ORIGY]], float %[[ORIGZ]], float %[[TMIN]], float %[[DIRX]], float %[[DIRY]], float %[[DIRZ]], float %22) |
| 46 | + |
| 47 | +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" |
| 48 | +target triple = "dxil-ms-dx" |
| 49 | + |
| 50 | +%struct.RaytracingAccelerationStructure = type { i32 } |
| 51 | +%"$Globals" = type { %struct.RayDesc } |
| 52 | +%struct.RayDesc = type { <3 x float>, float, <3 x float>, float } |
| 53 | +%dx.types.Handle = type { i8* } |
| 54 | +%dx.types.ResourceProperties = type { i32, i32 } |
| 55 | +%"class.RayQuery<513, 0>" = type { i32 } |
| 56 | + |
| 57 | +@"\01?RTAS@@3URaytracingAccelerationStructure@@A" = external global %struct.RaytracingAccelerationStructure, align 4 |
| 58 | +@"$Globals" = external constant %"$Globals" |
| 59 | + |
| 60 | +; Function Attrs: nounwind |
| 61 | +define void @main() #0 { |
| 62 | +entry: |
| 63 | + %0 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %\22$Globals\22*, i32)"(i32 0, %"$Globals"* @"$Globals", i32 0) |
| 64 | + %1 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %\22$Globals\22)"(i32 14, %dx.types.Handle %0, %dx.types.ResourceProperties { i32 13, i32 32 }, %"$Globals" undef) |
| 65 | + %2 = call %"$Globals"* @"dx.hl.subscript.cb.rn.%\22$Globals\22* (i32, %dx.types.Handle, i32)"(i32 6, %dx.types.Handle %1, i32 0) |
| 66 | + %3 = getelementptr inbounds %"$Globals", %"$Globals"* %2, i32 0, i32 0 |
| 67 | + %rayQuery1 = call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 4, i32 513, i32 0), !dbg !34 ; line:12 col:71 |
| 68 | + %4 = load %struct.RaytracingAccelerationStructure, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !dbg !38 ; line:13 col:3 |
| 69 | + %5 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32 0, %struct.RaytracingAccelerationStructure %4), !dbg !38 ; line:13 col:3 |
| 70 | + %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 !38 ; line:13 col:3 |
| 71 | + %7 = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %3, i32 0, i32 0, !dbg !38 ; line:13 col:3 |
| 72 | + %8 = load <3 x float>, <3 x float>* %7, !dbg !38 ; line:13 col:3 |
| 73 | + %9 = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %3, i32 0, i32 1, !dbg !38 ; line:13 col:3 |
| 74 | + %10 = load float, float* %9, !dbg !38 ; line:13 col:3 |
| 75 | + %11 = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %3, i32 0, i32 2, !dbg !38 ; line:13 col:3 |
| 76 | + %12 = load <3 x float>, <3 x float>* %11, !dbg !38 ; line:13 col:3 |
| 77 | + %13 = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %3, i32 0, i32 3, !dbg !38 ; line:13 col:3 |
| 78 | + %14 = load float, float* %13, !dbg !38 ; line:13 col:3 |
| 79 | + call void @"dx.hl.op..void (i32, i32, %dx.types.Handle, i32, i32, <3 x float>, float, <3 x float>, float)"(i32 325, i32 %rayQuery1, %dx.types.Handle %6, i32 1, i32 2, <3 x float> %8, float %10, <3 x float> %12, float %14), !dbg !38 ; line:13 col:3 |
| 80 | + ret void, !dbg !39 ; line:14 col:1 |
| 81 | +} |
| 82 | + |
| 83 | +; Function Attrs: nounwind readnone |
| 84 | +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32, %struct.RaytracingAccelerationStructure) #1 |
| 85 | + |
| 86 | +; Function Attrs: nounwind readnone |
| 87 | +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 |
| 88 | + |
| 89 | +; Function Attrs: nounwind readnone |
| 90 | +declare %"$Globals"* @"dx.hl.subscript.cb.rn.%\22$Globals\22* (i32, %dx.types.Handle, i32)"(i32, %dx.types.Handle, i32) #1 |
| 91 | + |
| 92 | +; Function Attrs: nounwind readnone |
| 93 | +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %\22$Globals\22*, i32)"(i32, %"$Globals"*, i32) #1 |
| 94 | + |
| 95 | +; Function Attrs: nounwind readnone |
| 96 | +declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %\22$Globals\22)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %"$Globals") #1 |
| 97 | + |
| 98 | +; Function Attrs: nounwind |
| 99 | +declare i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32, i32, i32) #0 |
| 100 | + |
| 101 | +; Function Attrs: nounwind |
| 102 | +declare void @"dx.hl.op..void (i32, i32, %dx.types.Handle, i32, i32, <3 x float>, float, <3 x float>, float)"(i32, i32, %dx.types.Handle, i32, i32, <3 x float>, float, <3 x float>, float) #0 |
| 103 | + |
| 104 | +attributes #0 = { nounwind } |
| 105 | +attributes #1 = { nounwind readnone } |
| 106 | + |
| 107 | +!llvm.module.flags = !{!0} |
| 108 | +!pauseresume = !{!1} |
| 109 | +!llvm.ident = !{!2} |
| 110 | +!dx.version = !{!3} |
| 111 | +!dx.valver = !{!4} |
| 112 | +!dx.shaderModel = !{!5} |
| 113 | +!dx.typeAnnotations = !{!6, !20} |
| 114 | +!dx.entryPoints = !{!24} |
| 115 | +!dx.fnprops = !{!31} |
| 116 | +!dx.options = !{!32, !33} |
| 117 | + |
| 118 | +!0 = !{i32 2, !"Debug Info Version", i32 3} |
| 119 | +!1 = !{!"hlsl-hlemit", !"hlsl-hlensure"} |
| 120 | +!2 = !{!"dxc(private) 1.8.0.14861 (main, 33bc44a3d)"} |
| 121 | +!3 = !{i32 1, i32 5} |
| 122 | +!4 = !{i32 1, i32 9} |
| 123 | +!5 = !{!"vs", i32 6, i32 5} |
| 124 | +!6 = !{i32 0, %struct.RayDesc undef, !7, %"class.RayQuery<513, 0>" undef, !12, %"$Globals" undef, !18} |
| 125 | +!7 = !{i32 32, !8, !9, !10, !11} |
| 126 | +!8 = !{i32 6, !"Origin", i32 3, i32 0, i32 7, i32 9} |
| 127 | +!9 = !{i32 6, !"TMin", i32 3, i32 12, i32 7, i32 9} |
| 128 | +!10 = !{i32 6, !"Direction", i32 3, i32 16, i32 7, i32 9} |
| 129 | +!11 = !{i32 6, !"TMax", i32 3, i32 28, i32 7, i32 9} |
| 130 | +!12 = !{i32 4, !13, !14} |
| 131 | +!13 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 5} |
| 132 | +!14 = !{i32 0, !15} |
| 133 | +!15 = !{!16, !17} |
| 134 | +!16 = !{i32 1, i64 513} |
| 135 | +!17 = !{i32 1, i64 0} |
| 136 | +!18 = !{i32 32, !19} |
| 137 | +!19 = !{i32 6, !"rayDesc", i32 3, i32 0} |
| 138 | +!20 = !{i32 1, void ()* @main, !21} |
| 139 | +!21 = !{!22} |
| 140 | +!22 = !{i32 1, !23, !23} |
| 141 | +!23 = !{} |
| 142 | +!24 = !{void ()* @main, !"main", null, !25, null} |
| 143 | +!25 = !{!26, null, !29, null} |
| 144 | +!26 = !{!27} |
| 145 | +!27 = !{i32 0, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !"RTAS", i32 -1, i32 -1, i32 1, i32 16, i32 0, !28} |
| 146 | +!28 = !{i32 0, i32 4} |
| 147 | +!29 = !{!30} |
| 148 | +!30 = !{i32 0, %"$Globals"* @"$Globals", !"$Globals", i32 0, i32 -1, i32 1, i32 32, null} |
| 149 | +!31 = !{void ()* @main, i32 1} |
| 150 | +!32 = !{i32 64} |
| 151 | +!33 = !{i32 -1} |
| 152 | +!34 = !DILocation(line: 12, column: 71, scope: !35) |
| 153 | +!35 = !DISubprogram(name: "main", scope: !36, file: !36, line: 11, type: !37, isLocal: false, isDefinition: true, scopeLine: 11, flags: DIFlagPrototyped, isOptimized: false, function: void ()* @main) |
| 154 | +!36 = !DIFile(filename: "tools/clang/test/CodeGenDXIL/hlsl/objects/RayQuery/tracerayinline_cb_raydesc.hlsl", directory: "") |
| 155 | +!37 = !DISubroutineType(types: !23) |
| 156 | +!38 = !DILocation(line: 13, column: 3, scope: !35) |
| 157 | +!39 = !DILocation(line: 14, column: 1, scope: !35) |
0 commit comments