diff --git a/include/dxc/HLSL/HLOperations.h b/include/dxc/HLSL/HLOperations.h index 970ddd3e85..0e9b8c2710 100644 --- a/include/dxc/HLSL/HLOperations.h +++ b/include/dxc/HLSL/HLOperations.h @@ -441,6 +441,10 @@ const unsigned kHitObjectMakeMissRayDescOpIdx = 4; const unsigned kHitObjectTraceRay_RayDescOpIdx = 8; const unsigned kHitObjectTraceRay_NumOp = 10; +// HitObject::FromRayQuery +const unsigned kHitObjectFromRayQuery_WithAttrs_AttributeOpIdx = 4; +const unsigned kHitObjectFromRayQuery_WithAttrs_NumOp = 5; + } // namespace HLOperandIndex llvm::Function *GetOrCreateHLFunction(llvm::Module &M, diff --git a/lib/HLSL/HLOperationLower.cpp b/lib/HLSL/HLOperationLower.cpp index f8a9f528cc..4ef7591e89 100644 --- a/lib/HLSL/HLOperationLower.cpp +++ b/lib/HLSL/HLOperationLower.cpp @@ -6312,7 +6312,32 @@ Value *TranslateHitObjectFromRayQuery(CallInst *CI, IntrinsicOp IOP, HLOperationLowerHelper &Helper, HLObjectOperationLowerHelper *pObjHelper, bool &Translated) { - return UndefValue::get(CI->getType()); // TODO: Merge SER DXIL patches + hlsl::OP *OP = &Helper.hlslOP; + IRBuilder<> Builder(CI); + + unsigned SrcIdx = 1; + Value *HitObjectPtr = CI->getArgOperand(SrcIdx++); + Value *RayQuery = CI->getArgOperand(SrcIdx++); + + if (CI->getNumArgOperands() == + HLOperandIndex::kHitObjectFromRayQuery_WithAttrs_NumOp) { + Value *HitKind = CI->getArgOperand(SrcIdx++); + Value *AttribSrc = CI->getArgOperand(SrcIdx++); + DXASSERT_NOMSG(SrcIdx == CI->getNumArgOperands()); + OpCode = DXIL::OpCode::HitObject_FromRayQueryWithAttrs; + Type *AttrTy = AttribSrc->getType(); + Value *OutHitObject = TrivialDxilOperation( + OpCode, {nullptr, RayQuery, HitKind, AttribSrc}, AttrTy, CI, OP); + Builder.CreateStore(OutHitObject, HitObjectPtr); + return nullptr; + } + + DXASSERT_NOMSG(SrcIdx == CI->getNumArgOperands()); + OpCode = DXIL::OpCode::HitObject_FromRayQuery; + Value *OutHitObject = + TrivialDxilOperation(OpCode, {nullptr, RayQuery}, Helper.voidTy, CI, OP); + Builder.CreateStore(OutHitObject, HitObjectPtr); + return nullptr; } Value *TranslateHitObjectTraceRay(CallInst *CI, IntrinsicOp IOP, diff --git a/lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp b/lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp index b13e9a0f5d..20265af40a 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp @@ -2795,6 +2795,31 @@ void SROA_Helper::RewriteCall(CallInst *CI) { } } LLVM_FALLTHROUGH; + case IntrinsicOp::MOP_DxHitObject_FromRayQuery: { + const bool IsWithAttrs = + CI->getNumArgOperands() == + HLOperandIndex::kHitObjectFromRayQuery_WithAttrs_NumOp; + if (IsWithAttrs && + (OldVal == + CI->getArgOperand( + HLOperandIndex:: + kHitObjectFromRayQuery_WithAttrs_AttributeOpIdx))) { + RewriteCallArg( + CI, + HLOperandIndex::kHitObjectFromRayQuery_WithAttrs_AttributeOpIdx, + /*bIn*/ true, /*bOut*/ false); + break; + } + + // For RayQuery methods, we want to replace the RayQuery this pointer + // with a load and use of the underlying handle value. + // This will allow elimination of RayQuery types earlier. + RewriteWithFlattenedHLIntrinsicCall(CI, OldVal, NewElts, + /*loadElts*/ true); + DeadInsts.push_back(CI); + break; + } + LLVM_FALLTHROUGH; default: // RayQuery this pointer replacement. if (OldVal->getType()->isPointerTy() && diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index 6eadfeaac9..5131d39f44 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -12093,6 +12093,7 @@ void Sema::DiagnoseReachableHLSLCall(CallExpr *CE, const hlsl::ShaderModel *SM, case hlsl::IntrinsicOp::MOP_TraceRayInline: DiagnoseTraceRayInline(*this, CE); break; + case hlsl::IntrinsicOp::MOP_DxHitObject_FromRayQuery: case hlsl::IntrinsicOp::MOP_DxHitObject_Invoke: case hlsl::IntrinsicOp::MOP_DxHitObject_MakeMiss: case hlsl::IntrinsicOp::MOP_DxHitObject_MakeNop: diff --git a/tools/clang/test/CodeGenDXIL/hlsl/objects/HitObject/hitobject_fromrayquery.hlsl b/tools/clang/test/CodeGenDXIL/hlsl/objects/HitObject/hitobject_fromrayquery.hlsl new file mode 100644 index 0000000000..33ea2719be --- /dev/null +++ b/tools/clang/test/CodeGenDXIL/hlsl/objects/HitObject/hitobject_fromrayquery.hlsl @@ -0,0 +1,37 @@ +// RUN: %dxc -T lib_6_9 -E main %s | FileCheck %s --check-prefix DXIL + +// DXIL: %{{[^ ]+}} = call %dx.types.HitObject @dx.op.hitObject_FromRayQuery(i32 263, i32 %[[RQ:[^ ]+]]) ; HitObject_FromRayQuery(rayQueryHandle) +// DXIL: %{{[^ ]+}} = call %dx.types.HitObject @dx.op.hitObject_FromRayQueryWithAttrs.struct.CustomAttrs(i32 264, i32 %[[RQ]], i32 16, %struct.CustomAttrs* nonnull %{{[^ ]+}}) ; HitObject_FromRayQueryWithAttrs(rayQueryHandle,HitKind,CommittedAttribs) + +RaytracingAccelerationStructure RTAS; +RWStructuredBuffer UAV : register(u0); + +RayDesc MakeRayDesc() { + RayDesc desc; + desc.Origin = float3(0, 0, 0); + desc.Direction = float3(1, 0, 0); + desc.TMin = 0.0f; + desc.TMax = 9999.0; + return desc; +} + +struct CustomAttrs { + float x; + float y; +}; + +void Use(in dx::HitObject hit) { + dx::MaybeReorderThread(hit); +} + +[shader("raygeneration")] +void main() { + RayQuery q; + RayDesc ray = MakeRayDesc(); + q.TraceRayInline(RTAS, RAY_FLAG_NONE, 0xFF, ray); + + Use(dx::HitObject::FromRayQuery(q)); + + CustomAttrs attrs = {1.f, 2.f}; + Use(dx::HitObject::FromRayQuery(q, 16, attrs)); +} diff --git a/tools/clang/test/DXC/Passes/DxilGen/hitobject_fromrayquery_dxilgen.ll b/tools/clang/test/DXC/Passes/DxilGen/hitobject_fromrayquery_dxilgen.ll new file mode 100644 index 0000000000..0ae8e36fa7 --- /dev/null +++ b/tools/clang/test/DXC/Passes/DxilGen/hitobject_fromrayquery_dxilgen.ll @@ -0,0 +1,146 @@ +; RUN: %dxopt %s -hlsl-passes-resume -dxilgen -S | FileCheck %s +; REQUIRES: dxil-1-9 + +; +; Buffer Definitions: +; +; +; Resource Bindings: +; +; Name Type Format Dim ID HLSL Bind Count +; ------------------------------ ---------- ------- ----------- ------- -------------- ------ +; RTAS texture i32 ras T0t4294967295,space4294967295 1 +; +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" +target triple = "dxil-ms-dx" + +%struct.RaytracingAccelerationStructure = type { i32 } +%struct.CustomAttrs = type { float, float } +%dx.types.HitObject = type { i8* } +%dx.types.Handle = type { i8* } +%dx.types.ResourceProperties = type { i32, i32 } +%"class.RWStructuredBuffer" = type { float } +%struct.RayDesc = type { <3 x float>, float, <3 x float>, float } +%"class.dx::HitObject" = type { i32 } +%"class.RayQuery<5, 0>" = type { i32 } + +@"\01?RTAS@@3URaytracingAccelerationStructure@@A" = external global %struct.RaytracingAccelerationStructure, align 4 + +; CHECK: %[[ATTRA:[^ ]+]] = alloca %struct.CustomAttrs +; CHECK: call void @dx.op.rayQuery_TraceRayInline(i32 179, i32 %[[RQH:[^ ]+]], %dx.types.Handle %{{[^ ]+}}, i32 0, i32 255, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 9.999000e+03) +; CHECK: %{{[^ ]+}} = call %dx.types.HitObject @dx.op.hitObject_FromRayQuery(i32 263, i32 %[[RQH]]) +; CHECK: %{{[^ ]+}} = call %dx.types.HitObject @dx.op.hitObject_FromRayQueryWithAttrs.struct.CustomAttrs(i32 264, i32 %[[RQH]], i32 16, %struct.CustomAttrs* %[[ATTRA]]) + +; Function Attrs: nounwind +define void @"\01?main@@YAXXZ"() #0 { +entry: + %0 = alloca %struct.CustomAttrs + %agg.tmp = alloca %dx.types.HitObject, align 4 + %agg.tmp1 = alloca %dx.types.HitObject, align 4 + %q2 = call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 4, i32 5, i32 0), !dbg !38 ; line:29 col:78 + %1 = load %struct.RaytracingAccelerationStructure, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !dbg !42 ; line:31 col:3 + %2 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32 0, %struct.RaytracingAccelerationStructure %1), !dbg !42 ; line:31 col:3 + %3 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure)"(i32 14, %dx.types.Handle %2, %dx.types.ResourceProperties { i32 16, i32 0 }, %struct.RaytracingAccelerationStructure zeroinitializer), !dbg !42 ; line:31 col:3 + call void @"dx.hl.op..void (i32, i32, %dx.types.Handle, i32, i32, <3 x float>, float, <3 x float>, float)"(i32 325, i32 %q2, %dx.types.Handle %3, i32 0, i32 255, <3 x float> zeroinitializer, float 0.000000e+00, <3 x float> , float 9.999000e+03), !dbg !42 ; line:31 col:3 + call void @"dx.hl.op..void (i32, %dx.types.HitObject*, i32)"(i32 363, %dx.types.HitObject* %agg.tmp, i32 %q2), !dbg !43 ; line:33 col:7 + call void @"dx.hl.op..void (i32, %dx.types.HitObject*)"(i32 359, %dx.types.HitObject* %agg.tmp) #0, !dbg !44 ; line:24 col:3 + %.0 = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %0, i32 0, i32 0 + store float 1.000000e+00, float* %.0 + %.1 = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %0, i32 0, i32 1 + store float 2.000000e+00, float* %.1, align 4 + call void @"dx.hl.op..void (i32, %dx.types.HitObject*, i32, i32, %struct.CustomAttrs*)"(i32 363, %dx.types.HitObject* %agg.tmp1, i32 %q2, i32 16, %struct.CustomAttrs* %0), !dbg !47 ; line:36 col:7 + call void @"dx.hl.op..void (i32, %dx.types.HitObject*)"(i32 359, %dx.types.HitObject* %agg.tmp1) #0, !dbg !48 ; line:24 col:3 + ret void, !dbg !49 ; line:37 col:1 +} + +; Function Attrs: nounwind +declare void @llvm.lifetime.start(i64, i8* nocapture) #0 + +; Function Attrs: nounwind +declare void @llvm.lifetime.end(i64, i8* nocapture) #0 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, %dx.types.HitObject*)"(i32, %dx.types.HitObject*) #0 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32, %struct.RaytracingAccelerationStructure) #1 + +; Function Attrs: nounwind readnone +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 + +; Function Attrs: nounwind +declare i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32, i32, i32) #0 + +; Function Attrs: nounwind +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 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, %dx.types.HitObject*, i32, i32, %struct.CustomAttrs*)"(i32, %dx.types.HitObject*, i32, i32, %struct.CustomAttrs*) #0 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, %dx.types.HitObject*, i32)"(i32, %dx.types.HitObject*, i32) #0 + +attributes #0 = { nounwind } +attributes #1 = { nounwind readnone } + +!llvm.module.flags = !{!0} +!pauseresume = !{!1} +!dx.version = !{!2} +!dx.valver = !{!2} +!dx.shaderModel = !{!3} +!dx.typeAnnotations = !{!4, !26} +!dx.entryPoints = !{!30} +!dx.fnprops = !{!35} +!dx.options = !{!36, !37} + +!0 = !{i32 2, !"Debug Info Version", i32 3} +!1 = !{!"hlsl-hlemit", !"hlsl-hlensure"} +!2 = !{i32 1, i32 9} +!3 = !{!"lib", i32 6, i32 9} +!4 = !{i32 0, %"class.RWStructuredBuffer" undef, !5, %struct.RayDesc undef, !10, %"class.dx::HitObject" undef, !15, %"class.RayQuery<5, 0>" undef, !17, %struct.CustomAttrs undef, !23} +!5 = !{i32 4, !6, !7} +!6 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 9} +!7 = !{i32 0, !8} +!8 = !{!9} +!9 = !{i32 0, float undef} +!10 = !{i32 32, !11, !12, !13, !14} +!11 = !{i32 6, !"Origin", i32 3, i32 0, i32 7, i32 9, i32 13, i32 3} +!12 = !{i32 6, !"TMin", i32 3, i32 12, i32 7, i32 9} +!13 = !{i32 6, !"Direction", i32 3, i32 16, i32 7, i32 9, i32 13, i32 3} +!14 = !{i32 6, !"TMax", i32 3, i32 28, i32 7, i32 9} +!15 = !{i32 4, !16} +!16 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 4} +!17 = !{i32 4, !18, !19} +!18 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 5} +!19 = !{i32 0, !20} +!20 = !{!21, !22} +!21 = !{i32 1, i64 5} +!22 = !{i32 1, i64 0} +!23 = !{i32 8, !24, !25} +!24 = !{i32 6, !"x", i32 3, i32 0, i32 7, i32 9} +!25 = !{i32 6, !"y", i32 3, i32 4, i32 7, i32 9} +!26 = !{i32 1, void ()* @"\01?main@@YAXXZ", !27} +!27 = !{!28} +!28 = !{i32 1, !29, !29} +!29 = !{} +!30 = !{null, !"", null, !31, null} +!31 = !{!32, null, null, null} +!32 = !{!33} +!33 = !{i32 0, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !"RTAS", i32 -1, i32 -1, i32 1, i32 16, i32 0, !34} +!34 = !{i32 0, i32 4} +!35 = !{void ()* @"\01?main@@YAXXZ", i32 7} +!36 = !{i32 -2147483584} +!37 = !{i32 -1} +!38 = !DILocation(line: 29, column: 78, scope: !39) +!39 = !DISubprogram(name: "main", scope: !40, file: !40, line: 28, type: !41, isLocal: false, isDefinition: true, scopeLine: 28, flags: DIFlagPrototyped, isOptimized: false, function: void ()* @"\01?main@@YAXXZ") +!40 = !DIFile(filename: "tools/clang/test/CodeGenDXIL/hlsl/objects/HitObject/hitobject_fromrayquery.hlsl", directory: "") +!41 = !DISubroutineType(types: !29) +!42 = !DILocation(line: 31, column: 3, scope: !39) +!43 = !DILocation(line: 33, column: 7, scope: !39) +!44 = !DILocation(line: 24, column: 3, scope: !45, inlinedAt: !46) +!45 = !DISubprogram(name: "Use", scope: !40, file: !40, line: 23, type: !41, isLocal: false, isDefinition: true, scopeLine: 23, flags: DIFlagPrototyped, isOptimized: false) +!46 = distinct !DILocation(line: 33, column: 3, scope: !39) +!47 = !DILocation(line: 36, column: 7, scope: !39) +!48 = !DILocation(line: 24, column: 3, scope: !45, inlinedAt: !49) +!49 = distinct !DILocation(line: 36, column: 3, scope: !39) +!50 = !DILocation(line: 37, column: 1, scope: !39) diff --git a/tools/clang/test/DXC/Passes/ScalarReplHLSL/hitobject_fromrayquery_scalarrepl.ll b/tools/clang/test/DXC/Passes/ScalarReplHLSL/hitobject_fromrayquery_scalarrepl.ll new file mode 100644 index 0000000000..5afd30b524 --- /dev/null +++ b/tools/clang/test/DXC/Passes/ScalarReplHLSL/hitobject_fromrayquery_scalarrepl.ll @@ -0,0 +1,383 @@ +; RUN: %dxopt %s -hlsl-passes-resume -scalarrepl-param-hlsl -S | FileCheck %s + +; COM: Original HLSL code +; COM: RaytracingAccelerationStructure RTAS; +; COM: RWStructuredBuffer UAV : register(u0); +; COM: RWByteAddressBuffer inbuf; +; COM: RWByteAddressBuffer outbuf; +; COM: +; COM: RayDesc MakeRayDesc() { +; COM: RayDesc desc; +; COM: desc.Origin = float3(0, 0, 0); +; COM: desc.Direction = float3(1, 0, 0); +; COM: desc.TMin = 0.0f; +; COM: desc.TMax = 9999.0; +; COM: return desc; +; COM: } +; COM: +; COM: struct CustomAttrs { +; COM: float x; +; COM: float y; +; COM: }; +; COM: +; COM: void Use(in dx::HitObject hit) { +; COM: dx::MaybeReorderThread(hit); +; COM: } +; COM: +; COM: [shader("raygeneration")] +; COM: void main() { +; COM: RayQuery q; +; COM: RayDesc ray = MakeRayDesc(); +; COM: q.TraceRayInline(RTAS, RAY_FLAG_NONE, 0xFF, ray); +; COM: +; COM: Use(dx::HitObject::FromRayQuery(q)); +; COM: +; COM: CustomAttrs attrs; +; COM: attrs.x = inbuf.Load(0); +; COM: attrs.y = inbuf.Load(4); +; COM: Use(dx::HitObject::FromRayQuery(q, 16, attrs)); +; COM: +; COM: attrs.x = inbuf.Load(8); +; COM: attrs.y = inbuf.Load(12); +; COM: Use(dx::HitObject::FromRayQuery(q, 17, attrs)); +; COM: +; COM: outbuf.Store(0, attrs.x); +; COM: outbuf.Store(4, attrs.y); +; COM: } + +; +; Buffer Definitions: +; +; cbuffer $Globals +; { +; +; [0 x i8] (type annotation not present) +; +; } +; +; Resource bind info for UAV +; { +; +; float $Element; ; Offset: 0 Size: 4 +; +; } +; +; +; Resource Bindings: +; +; Name Type Format Dim ID HLSL Bind Count +; ------------------------------ ---------- ------- ----------- ------- -------------- ------ +; $Globals cbuffer NA NA CB0 cb4294967295 1 +; RTAS texture i32 ras T0t4294967295,space4294967295 1 +; UAV UAV struct r/w U0 u0 1 +; inbuf UAV byte r/w U1u4294967295,space4294967295 1 +; outbuf UAV byte r/w U2u4294967295,space4294967295 1 +; +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" +target triple = "dxil-ms-dx" + +%struct.RaytracingAccelerationStructure = type { i32 } +%"class.RWStructuredBuffer" = type { float } +%struct.RWByteAddressBuffer = type { i32 } +%ConstantBuffer = type opaque +%"class.RayQuery<5, 0>" = type { i32 } +%struct.RayDesc = type { <3 x float>, float, <3 x float>, float } +%dx.types.HitObject = type { i8* } +%struct.CustomAttrs = type { float, float } +%dx.types.Handle = type { i8* } +%dx.types.ResourceProperties = type { i32, i32 } +%"class.dx::HitObject" = type { i32 } + +@"\01?RTAS@@3URaytracingAccelerationStructure@@A" = external global %struct.RaytracingAccelerationStructure, align 4 +@"\01?UAV@@3V?$RWStructuredBuffer@M@@A" = external global %"class.RWStructuredBuffer", align 4 +@"\01?inbuf@@3URWByteAddressBuffer@@A" = external global %struct.RWByteAddressBuffer, align 4 +@"\01?outbuf@@3URWByteAddressBuffer@@A" = external global %struct.RWByteAddressBuffer, align 4 +@"$Globals" = external constant %ConstantBuffer + +; CHECK: %[[RQA:[^ ]+]] = alloca i32 +; CHECK: %[[ATTRA0:[^ ]+]] = alloca %struct.CustomAttrs +; CHECK: %[[ATTRA1:[^ ]+]] = alloca %struct.CustomAttrs +; CHECK: %[[XATTRA:[^ ]+]] = alloca float +; CHECK: %[[YATTRA:[^ ]+]] = alloca float + +; COM: Check same query handle used for TraceRayInline and the FromRayQuery calls +; CHECK: %[[RQH:[^ ]+]] = load i32, i32* %[[RQA]] +; CHECK: call void @"dx.hl.op..void (i32, i32, %dx.types.Handle, i32, i32, <3 x float>, float, <3 x float>, float)"(i32 325, i32 %[[RQH]], + +; COM: Check RQ handle loaded for first FromRayQuery call +; CHECK: %[[RQH0:[^ ]+]] = load i32, i32* %[[RQA]] +; CHECK: call void @"dx.hl.op..void (i32, %dx.types.HitObject*, i32)"(i32 363, %dx.types.HitObject* %{{[^ ]+}}, i32 %[[RQH0]]) + +; COM: Check buffer loads for first FromRayQuery-with-attrs call +; CHECK: %[[XI0:[^ ]+]] = call i32 @"dx.hl.op.ro.i32 (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %{{[^ ]+}}, i32 0) +; CHECK: %[[XF0:[^ ]+]] = uitofp i32 %[[XI0]] to float +; CHECK: store float %[[XF0]], float* %[[XATTRA]], align 4 +; CHECK: %[[YI0:[^ ]+]] = call i32 @"dx.hl.op.ro.i32 (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %{{[^ ]+}}, i32 4) +; CHECK: %[[YF0:[^ ]+]] = uitofp i32 %[[YI0]] to float +; CHECK: store float %[[YF0]], float* %[[YATTRA]], align 4 + +; COM: Check that values from buffer flow into first FromRayQuery-with-attrs call +; CHECK: %[[XPTR0:[^ ]+]] = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %[[ATTRA0]], i32 0, i32 0 +; CHECK: %[[XF1:[^ ]+]] = load float, float* %[[XATTRA]] +; CHECK: store float %[[XF1]], float* %[[XPTR0]] +; CHECK: %[[YPTR0:[^ ]+]] = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %[[ATTRA0]], i32 0, i32 1 +; CHECK: %[[YF1:[^ ]+]] = load float, float* %[[YATTRA]] +; CHECK: store float %[[YF1]], float* %[[YPTR0]], align 4 +; CHECK: %[[RQH1:[^ ]+]] = load i32, i32* %[[RQA]] +; CHECK: call void @"dx.hl.op..void (i32, %dx.types.HitObject*, i32, i32, %struct.CustomAttrs*)"(i32 363, %dx.types.HitObject* %{{[^ ]+}}, i32 %[[RQH1]], i32 16, %struct.CustomAttrs* %[[ATTRA0]]) + +; COM: Check buffer loads for second FromRayQuery-with-attrs call +; CHECK: %[[XI1:[^ ]+]] = call i32 @"dx.hl.op.ro.i32 (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %{{[^ ]+}}, i32 8) +; CHECK: %[[XF1:[^ ]+]] = uitofp i32 %[[XI1]] to float +; CHECK: store float %[[XF1]], float* %[[XATTRA]], align 4 +; CHECK: %[[YI1:[^ ]+]] = call i32 @"dx.hl.op.ro.i32 (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %{{[^ ]+}}, i32 12) +; CHECK: %[[YF1:[^ ]+]] = uitofp i32 %[[YI1]] to float +; CHECK: store float %[[YF1]], float* %[[YATTRA]], align 4 + +; COM: Check that values from buffer flow into second FromRayQuery-with-attrs call +; CHECK: %[[XPTR1:[^ ]+]] = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %[[ATTRA1]], i32 0, i32 0 +; CHECK: %[[XF2:[^ ]+]] = load float, float* %[[XATTRA]] +; CHECK: store float %[[XF2]], float* %[[XPTR1]] +; CHECK: %[[YPTR1:[^ ]+]] = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %[[ATTRA1]], i32 0, i32 1 +; CHECK: %[[YF2:[^ ]+]] = load float, float* %[[YATTRA]] +; CHECK: store float %[[YF2]], float* %[[YPTR1]], align 4 +; CHECK: %[[RQH2:[^ ]+]] = load i32, i32* %[[RQA]] +; CHECK: call void @"dx.hl.op..void (i32, %dx.types.HitObject*, i32, i32, %struct.CustomAttrs*)"(i32 363, %dx.types.HitObject* %{{[^ ]+}}, i32 %[[RQH2]], i32 17, %struct.CustomAttrs* %[[ATTRA1]]) + + +; Function Attrs: nounwind +define void @"\01?main@@YAXXZ"() #0 { +entry: + %q = alloca %"class.RayQuery<5, 0>", align 4 + %ray = alloca %struct.RayDesc, align 4 + %agg.tmp = alloca %dx.types.HitObject, align 4 + %attrs = alloca %struct.CustomAttrs, align 4 + %agg.tmp4 = alloca %dx.types.HitObject, align 4 + %agg.tmp11 = alloca %dx.types.HitObject, align 4 + %0 = bitcast %"class.RayQuery<5, 0>"* %q to i8*, !dbg !45 ; line:26 col:3 + call void @llvm.lifetime.start(i64 4, i8* %0) #0, !dbg !45 ; line:26 col:3 + %q14 = call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 4, i32 5, i32 0), !dbg !49 ; line:26 col:78 + %1 = getelementptr inbounds %"class.RayQuery<5, 0>", %"class.RayQuery<5, 0>"* %q, i32 0, i32 0, !dbg !49 ; line:26 col:78 + store i32 %q14, i32* %1, !dbg !49 ; line:26 col:78 + %2 = bitcast %struct.RayDesc* %ray to i8*, !dbg !50 ; line:27 col:3 + call void @llvm.lifetime.start(i64 32, i8* %2) #0, !dbg !50 ; line:27 col:3 + %Origin.i = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %ray, i32 0, i32 0, !dbg !51 ; line:8 col:8 + store <3 x float> zeroinitializer, <3 x float>* %Origin.i, align 4, !dbg !54, !tbaa !55, !alias.scope !58 ; line:8 col:15 + %Direction.i = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %ray, i32 0, i32 2, !dbg !61 ; line:9 col:8 + store <3 x float> , <3 x float>* %Direction.i, align 4, !dbg !62, !tbaa !55, !alias.scope !58 ; line:9 col:18 + %TMin.i = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %ray, i32 0, i32 1, !dbg !63 ; line:10 col:8 + store float 0.000000e+00, float* %TMin.i, align 4, !dbg !64, !tbaa !65, !alias.scope !58 ; line:10 col:13 + %TMax.i = getelementptr inbounds %struct.RayDesc, %struct.RayDesc* %ray, i32 0, i32 3, !dbg !67 ; line:11 col:8 + store float 9.999000e+03, float* %TMax.i, align 4, !dbg !68, !tbaa !65, !alias.scope !58 ; line:11 col:13 + %3 = load %struct.RaytracingAccelerationStructure, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !dbg !69 ; line:28 col:3 + %4 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32 0, %struct.RaytracingAccelerationStructure %3), !dbg !69 ; line:28 col:3 + %5 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RaytracingAccelerationStructure)"(i32 14, %dx.types.Handle %4, %dx.types.ResourceProperties { i32 16, i32 0 }, %struct.RaytracingAccelerationStructure undef), !dbg !69 ; line:28 col:3 + call void @"dx.hl.op..void (i32, %\22class.RayQuery<5, 0>\22*, %dx.types.Handle, i32, i32, %struct.RayDesc*)"(i32 325, %"class.RayQuery<5, 0>"* %q, %dx.types.Handle %5, i32 0, i32 255, %struct.RayDesc* %ray), !dbg !69 ; line:28 col:3 + call void @"dx.hl.op..void (i32, %dx.types.HitObject*, %\22class.RayQuery<5, 0>\22*)"(i32 363, %dx.types.HitObject* %agg.tmp, %"class.RayQuery<5, 0>"* %q), !dbg !70 ; line:30 col:7 + call void @"dx.hl.op..void (i32, %dx.types.HitObject*)"(i32 359, %dx.types.HitObject* %agg.tmp) #0, !dbg !71 ; line:21 col:3 + %6 = bitcast %struct.CustomAttrs* %attrs to i8*, !dbg !74 ; line:32 col:3 + call void @llvm.lifetime.start(i64 8, i8* %6) #0, !dbg !74 ; line:32 col:3 + %7 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?inbuf@@3URWByteAddressBuffer@@A", !dbg !75 ; line:33 col:13 + %8 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %7), !dbg !75 ; line:33 col:13 + %9 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %8, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer undef), !dbg !75 ; line:33 col:13 + %10 = call i32 @"dx.hl.op.ro.i32 (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %9, i32 0), !dbg !75 ; line:33 col:13 + %conv = uitofp i32 %10 to float, !dbg !75 ; line:33 col:13 + %x = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %attrs, i32 0, i32 0, !dbg !76 ; line:33 col:9 + store float %conv, float* %x, align 4, !dbg !77, !tbaa !65 ; line:33 col:11 + %11 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?inbuf@@3URWByteAddressBuffer@@A", !dbg !78 ; line:34 col:13 + %12 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %11), !dbg !78 ; line:34 col:13 + %13 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %12, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer undef), !dbg !78 ; line:34 col:13 + %14 = call i32 @"dx.hl.op.ro.i32 (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %13, i32 4), !dbg !78 ; line:34 col:13 + %conv3 = uitofp i32 %14 to float, !dbg !78 ; line:34 col:13 + %y = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %attrs, i32 0, i32 1, !dbg !79 ; line:34 col:9 + store float %conv3, float* %y, align 4, !dbg !80, !tbaa !65 ; line:34 col:11 + call void @"dx.hl.op..void (i32, %dx.types.HitObject*, %\22class.RayQuery<5, 0>\22*, i32, %struct.CustomAttrs*)"(i32 363, %dx.types.HitObject* %agg.tmp4, %"class.RayQuery<5, 0>"* %q, i32 16, %struct.CustomAttrs* %attrs), !dbg !81 ; line:35 col:7 + call void @"dx.hl.op..void (i32, %dx.types.HitObject*)"(i32 359, %dx.types.HitObject* %agg.tmp4) #0, !dbg !82 ; line:21 col:3 + %15 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?inbuf@@3URWByteAddressBuffer@@A", !dbg !84 ; line:37 col:13 + %16 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %15), !dbg !84 ; line:37 col:13 + %17 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %16, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer undef), !dbg !84 ; line:37 col:13 + %18 = call i32 @"dx.hl.op.ro.i32 (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %17, i32 8), !dbg !84 ; line:37 col:13 + %conv6 = uitofp i32 %18 to float, !dbg !84 ; line:37 col:13 + %x7 = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %attrs, i32 0, i32 0, !dbg !85 ; line:37 col:9 + store float %conv6, float* %x7, align 4, !dbg !86, !tbaa !65 ; line:37 col:11 + %19 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?inbuf@@3URWByteAddressBuffer@@A", !dbg !87 ; line:38 col:13 + %20 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %19), !dbg !87 ; line:38 col:13 + %21 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %20, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer undef), !dbg !87 ; line:38 col:13 + %22 = call i32 @"dx.hl.op.ro.i32 (i32, %dx.types.Handle, i32)"(i32 231, %dx.types.Handle %21, i32 12), !dbg !87 ; line:38 col:13 + %conv9 = uitofp i32 %22 to float, !dbg !87 ; line:38 col:13 + %y10 = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %attrs, i32 0, i32 1, !dbg !88 ; line:38 col:9 + store float %conv9, float* %y10, align 4, !dbg !89, !tbaa !65 ; line:38 col:11 + call void @"dx.hl.op..void (i32, %dx.types.HitObject*, %\22class.RayQuery<5, 0>\22*, i32, %struct.CustomAttrs*)"(i32 363, %dx.types.HitObject* %agg.tmp11, %"class.RayQuery<5, 0>"* %q, i32 17, %struct.CustomAttrs* %attrs), !dbg !90 ; line:39 col:7 + call void @"dx.hl.op..void (i32, %dx.types.HitObject*)"(i32 359, %dx.types.HitObject* %agg.tmp11) #0, !dbg !91 ; line:21 col:3 + %x12 = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %attrs, i32 0, i32 0, !dbg !93 ; line:41 col:25 + %23 = load float, float* %x12, align 4, !dbg !93, !tbaa !65 ; line:41 col:25 + %24 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?outbuf@@3URWByteAddressBuffer@@A", !dbg !94 ; line:41 col:3 + %25 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %24), !dbg !94 ; line:41 col:3 + %26 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %25, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer undef), !dbg !94 ; line:41 col:3 + call void @"dx.hl.op..void (i32, %dx.types.Handle, i32, float)"(i32 277, %dx.types.Handle %26, i32 0, float %23), !dbg !94 ; line:41 col:3 + %y13 = getelementptr inbounds %struct.CustomAttrs, %struct.CustomAttrs* %attrs, i32 0, i32 1, !dbg !95 ; line:42 col:25 + %27 = load float, float* %y13, align 4, !dbg !95, !tbaa !65 ; line:42 col:25 + %28 = load %struct.RWByteAddressBuffer, %struct.RWByteAddressBuffer* @"\01?outbuf@@3URWByteAddressBuffer@@A", !dbg !96 ; line:42 col:3 + %29 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32 0, %struct.RWByteAddressBuffer %28), !dbg !96 ; line:42 col:3 + %30 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32 14, %dx.types.Handle %29, %dx.types.ResourceProperties { i32 4107, i32 0 }, %struct.RWByteAddressBuffer undef), !dbg !96 ; line:42 col:3 + call void @"dx.hl.op..void (i32, %dx.types.Handle, i32, float)"(i32 277, %dx.types.Handle %30, i32 4, float %27), !dbg !96 ; line:42 col:3 + %31 = bitcast %struct.CustomAttrs* %attrs to i8*, !dbg !97 ; line:43 col:1 + call void @llvm.lifetime.end(i64 8, i8* %31) #0, !dbg !97 ; line:43 col:1 + %32 = bitcast %struct.RayDesc* %ray to i8*, !dbg !97 ; line:43 col:1 + call void @llvm.lifetime.end(i64 32, i8* %32) #0, !dbg !97 ; line:43 col:1 + %33 = bitcast %"class.RayQuery<5, 0>"* %q to i8*, !dbg !97 ; line:43 col:1 + call void @llvm.lifetime.end(i64 4, i8* %33) #0, !dbg !97 ; line:43 col:1 + ret void, !dbg !97 ; line:43 col:1 +} + +; Function Attrs: nounwind +declare void @llvm.lifetime.start(i64, i8* nocapture) #0 + +; Function Attrs: nounwind +declare void @llvm.lifetime.end(i64, i8* nocapture) #0 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, %dx.types.HitObject*)"(i32, %dx.types.HitObject*) #0 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, %\22class.RayQuery<5, 0>\22*, %dx.types.Handle, i32, i32, %struct.RayDesc*)"(i32, %"class.RayQuery<5, 0>"*, %dx.types.Handle, i32, i32, %struct.RayDesc*) #0 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RaytracingAccelerationStructure)"(i32, %struct.RaytracingAccelerationStructure) #1 + +; Function Attrs: nounwind readnone +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 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, %dx.types.HitObject*, %\22class.RayQuery<5, 0>\22*)"(i32, %dx.types.HitObject*, %"class.RayQuery<5, 0>"*) #0 + +; Function Attrs: nounwind readonly +declare i32 @"dx.hl.op.ro.i32 (i32, %dx.types.Handle, i32)"(i32, %dx.types.Handle, i32) #2 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %struct.RWByteAddressBuffer)"(i32, %struct.RWByteAddressBuffer) #1 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %struct.RWByteAddressBuffer) #1 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, %dx.types.HitObject*, %\22class.RayQuery<5, 0>\22*, i32, %struct.CustomAttrs*)"(i32, %dx.types.HitObject*, %"class.RayQuery<5, 0>"*, i32, %struct.CustomAttrs*) #0 + +; Function Attrs: nounwind +declare void @"dx.hl.op..void (i32, %dx.types.Handle, i32, float)"(i32, %dx.types.Handle, i32, float) #0 + +; Function Attrs: nounwind +declare i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32, i32, i32) #0 + +attributes #0 = { nounwind } +attributes #1 = { nounwind readnone } +attributes #2 = { nounwind readonly } + +!llvm.module.flags = !{!0} +!pauseresume = !{!1} +!dx.version = !{!2} +!dx.valver = !{!2} +!dx.shaderModel = !{!3} +!dx.typeAnnotations = !{!4, !26} +!dx.entryPoints = !{!30} +!dx.fnprops = !{!42} +!dx.options = !{!43, !44} + +!0 = !{i32 2, !"Debug Info Version", i32 3} +!1 = !{!"hlsl-hlemit", !"hlsl-hlensure"} +!2 = !{i32 1, i32 9} +!3 = !{!"lib", i32 6, i32 9} +!4 = !{i32 0, %"class.RWStructuredBuffer" undef, !5, %struct.RayDesc undef, !10, %"class.dx::HitObject" undef, !15, %"class.RayQuery<5, 0>" undef, !17, %struct.CustomAttrs undef, !23} +!5 = !{i32 4, !6, !7} +!6 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 9} +!7 = !{i32 0, !8} +!8 = !{!9} +!9 = !{i32 0, float undef} +!10 = !{i32 32, !11, !12, !13, !14} +!11 = !{i32 6, !"Origin", i32 3, i32 0, i32 7, i32 9, i32 13, i32 3} +!12 = !{i32 6, !"TMin", i32 3, i32 12, i32 7, i32 9} +!13 = !{i32 6, !"Direction", i32 3, i32 16, i32 7, i32 9, i32 13, i32 3} +!14 = !{i32 6, !"TMax", i32 3, i32 28, i32 7, i32 9} +!15 = !{i32 4, !16} +!16 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 4} +!17 = !{i32 4, !18, !19} +!18 = !{i32 6, !"h", i32 3, i32 0, i32 7, i32 5} +!19 = !{i32 0, !20} +!20 = !{!21, !22} +!21 = !{i32 1, i64 5} +!22 = !{i32 1, i64 0} +!23 = !{i32 8, !24, !25} +!24 = !{i32 6, !"x", i32 3, i32 0, i32 7, i32 9} +!25 = !{i32 6, !"y", i32 3, i32 4, i32 7, i32 9} +!26 = !{i32 1, void ()* @"\01?main@@YAXXZ", !27} +!27 = !{!28} +!28 = !{i32 1, !29, !29} +!29 = !{} +!30 = !{null, !"", null, !31, null} +!31 = !{!32, !35, !40, null} +!32 = !{!33} +!33 = !{i32 0, %struct.RaytracingAccelerationStructure* @"\01?RTAS@@3URaytracingAccelerationStructure@@A", !"RTAS", i32 -1, i32 -1, i32 1, i32 16, i32 0, !34} +!34 = !{i32 0, i32 4} +!35 = !{!36, !38, !39} +!36 = !{i32 0, %"class.RWStructuredBuffer"* @"\01?UAV@@3V?$RWStructuredBuffer@M@@A", !"UAV", i32 0, i32 0, i32 1, i32 12, i1 false, i1 false, i1 false, !37} +!37 = !{i32 1, i32 4} +!38 = !{i32 1, %struct.RWByteAddressBuffer* @"\01?inbuf@@3URWByteAddressBuffer@@A", !"inbuf", i32 -1, i32 -1, i32 1, i32 11, i1 false, i1 false, i1 false, null} +!39 = !{i32 2, %struct.RWByteAddressBuffer* @"\01?outbuf@@3URWByteAddressBuffer@@A", !"outbuf", i32 -1, i32 -1, i32 1, i32 11, i1 false, i1 false, i1 false, null} +!40 = !{!41} +!41 = !{i32 0, %ConstantBuffer* @"$Globals", !"$Globals", i32 0, i32 -1, i32 1, i32 0, null} +!42 = !{void ()* @"\01?main@@YAXXZ", i32 7} +!43 = !{i32 -2147483584} +!44 = !{i32 -1} +!45 = !DILocation(line: 26, column: 3, scope: !46) +!46 = !DISubprogram(name: "main", scope: !47, file: !47, line: 25, type: !48, isLocal: false, isDefinition: true, scopeLine: 25, flags: DIFlagPrototyped, isOptimized: false, function: void ()* @"\01?main@@YAXXZ") +!47 = !DIFile(filename: "hitobject_fromrayquery_scalarrepl.hlsl", directory: "") +!48 = !DISubroutineType(types: !29) +!49 = !DILocation(line: 26, column: 78, scope: !46) +!50 = !DILocation(line: 27, column: 3, scope: !46) +!51 = !DILocation(line: 8, column: 8, scope: !52, inlinedAt: !53) +!52 = !DISubprogram(name: "MakeRayDesc", scope: !47, file: !47, line: 6, type: !48, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false) +!53 = distinct !DILocation(line: 27, column: 17, scope: !46) +!54 = !DILocation(line: 8, column: 15, scope: !52, inlinedAt: !53) +!55 = !{!56, !56, i64 0} +!56 = !{!"omnipotent char", !57, i64 0} +!57 = !{!"Simple C/C++ TBAA"} +!58 = !{!59} +!59 = distinct !{!59, !60, !"\01?MakeRayDesc@@YA?AURayDesc@@XZ: %agg.result"} +!60 = distinct !{!60, !"\01?MakeRayDesc@@YA?AURayDesc@@XZ"} +!61 = !DILocation(line: 9, column: 8, scope: !52, inlinedAt: !53) +!62 = !DILocation(line: 9, column: 18, scope: !52, inlinedAt: !53) +!63 = !DILocation(line: 10, column: 8, scope: !52, inlinedAt: !53) +!64 = !DILocation(line: 10, column: 13, scope: !52, inlinedAt: !53) +!65 = !{!66, !66, i64 0} +!66 = !{!"float", !56, i64 0} +!67 = !DILocation(line: 11, column: 8, scope: !52, inlinedAt: !53) +!68 = !DILocation(line: 11, column: 13, scope: !52, inlinedAt: !53) +!69 = !DILocation(line: 28, column: 3, scope: !46) +!70 = !DILocation(line: 30, column: 7, scope: !46) +!71 = !DILocation(line: 21, column: 3, scope: !72, inlinedAt: !73) +!72 = !DISubprogram(name: "Use", scope: !47, file: !47, line: 20, type: !48, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: false) +!73 = distinct !DILocation(line: 30, column: 3, scope: !46) +!74 = !DILocation(line: 32, column: 3, scope: !46) +!75 = !DILocation(line: 33, column: 13, scope: !46) +!76 = !DILocation(line: 33, column: 9, scope: !46) +!77 = !DILocation(line: 33, column: 11, scope: !46) +!78 = !DILocation(line: 34, column: 13, scope: !46) +!79 = !DILocation(line: 34, column: 9, scope: !46) +!80 = !DILocation(line: 34, column: 11, scope: !46) +!81 = !DILocation(line: 35, column: 7, scope: !46) +!82 = !DILocation(line: 21, column: 3, scope: !72, inlinedAt: !83) +!83 = distinct !DILocation(line: 35, column: 3, scope: !46) +!84 = !DILocation(line: 37, column: 13, scope: !46) +!85 = !DILocation(line: 37, column: 9, scope: !46) +!86 = !DILocation(line: 37, column: 11, scope: !46) +!87 = !DILocation(line: 38, column: 13, scope: !46) +!88 = !DILocation(line: 38, column: 9, scope: !46) +!89 = !DILocation(line: 38, column: 11, scope: !46) +!90 = !DILocation(line: 39, column: 7, scope: !46) +!91 = !DILocation(line: 21, column: 3, scope: !72, inlinedAt: !92) +!92 = distinct !DILocation(line: 39, column: 3, scope: !46) +!93 = !DILocation(line: 41, column: 25, scope: !46) +!94 = !DILocation(line: 41, column: 3, scope: !46) +!95 = !DILocation(line: 42, column: 25, scope: !46) +!96 = !DILocation(line: 42, column: 3, scope: !46) +!97 = !DILocation(line: 43, column: 1, scope: !46) diff --git a/tools/clang/test/SemaHLSL/hlsl/objects/HitObject/hitobject_fromrayquery.hlsl b/tools/clang/test/SemaHLSL/hlsl/objects/HitObject/hitobject_fromrayquery.hlsl new file mode 100644 index 0000000000..004d25156a --- /dev/null +++ b/tools/clang/test/SemaHLSL/hlsl/objects/HitObject/hitobject_fromrayquery.hlsl @@ -0,0 +1,72 @@ +// RUN: %dxc -T lib_6_9 -E main %s -fcgl | FileCheck %s --check-prefix FCGL +// RUN: %dxc -T lib_6_9 -E main %s -ast-dump-implicit | FileCheck %s --check-prefix AST + +// AST: | | |-FunctionTemplateDecl {{[^ ]+}} <> FromRayQuery +// AST-NEXT: | | | |-TemplateTypeParmDecl {{[^ ]+}} <> class TResult +// AST-NEXT: | | | |-TemplateTypeParmDecl {{[^ ]+}} <> class Trq +// AST-NEXT: | | | |-CXXMethodDecl {{[^ ]+}} <> implicit FromRayQuery 'TResult (Trq) const' static +// AST-NEXT: | | | | `-ParmVarDecl {{[^ ]+}} <> rq 'Trq' +// AST-NEXT: | | | `-CXXMethodDecl {{[^ ]+}} <> used FromRayQuery 'dx::HitObject (RayQuery)' static +// AST-NEXT: | | | |-TemplateArgument type 'dx::HitObject' +// AST-NEXT: | | | |-TemplateArgument type 'RayQuery':'RayQuery<5, 0>' +// AST-NEXT: | | | |-ParmVarDecl {{[^ ]+}} <> FromRayQuery 'RayQuery':'RayQuery<5, 0>' +// AST-NEXT: | | | |-HLSLIntrinsicAttr {{[^ ]+}} <> Implicit "op" "" 363 +// AST-NEXT: | | | `-AvailabilityAttr {{[^ ]+}} <> Implicit 6.9 0 0 "" + +// AST: | | |-FunctionTemplateDecl {{[^ ]+}} <> FromRayQuery +// AST-NEXT: | | | |-TemplateTypeParmDecl {{[^ ]+}} <> class TResult +// AST-NEXT: | | | |-TemplateTypeParmDecl {{[^ ]+}} <> class Trq +// AST-NEXT: | | | |-TemplateTypeParmDecl {{[^ ]+}} <> class THitKind +// AST-NEXT: | | | |-TemplateTypeParmDecl {{[^ ]+}} <> class TAttributes +// AST-NEXT: | | | |-CXXMethodDecl {{[^ ]+}} <> implicit FromRayQuery 'TResult (Trq, THitKind, TAttributes) const' static +// AST-NEXT: | | | | |-ParmVarDecl {{[^ ]+}} <> rq 'Trq' +// AST-NEXT: | | | | |-ParmVarDecl {{[^ ]+}} <> HitKind 'THitKind' +// AST-NEXT: | | | | `-ParmVarDecl {{[^ ]+}} <> Attributes 'TAttributes' +// AST-NEXT: | | | `-CXXMethodDecl {{[^ ]+}} <> used FromRayQuery 'dx::HitObject (RayQuery, unsigned int, CustomAttrs)' static +// AST-NEXT: | | | |-TemplateArgument type 'dx::HitObject' +// AST-NEXT: | | | |-TemplateArgument type 'RayQuery':'RayQuery<5, 0>' +// AST-NEXT: | | | |-TemplateArgument type 'unsigned int' +// AST-NEXT: | | | |-TemplateArgument type 'CustomAttrs' +// AST-NEXT: | | | |-ParmVarDecl {{[^ ]+}} <> FromRayQuery 'RayQuery':'RayQuery<5, 0>' +// AST-NEXT: | | | |-ParmVarDecl {{[^ ]+}} <> rq 'unsigned int' +// AST-NEXT: | | | |-ParmVarDecl {{[^ ]+}} <> HitKind 'CustomAttrs' +// AST-NEXT: | | | |-HLSLIntrinsicAttr {{[^ ]+}} <> Implicit "op" "" 363 +// AST-NEXT: | | | `-AvailabilityAttr {{[^ ]+}} <> Implicit 6.9 0 0 "" + +// FCGL: call void @"dx.hl.op..void (i32, %dx.types.HitObject*, %\22class.RayQuery<5, 0>\22*)"(i32 363, %dx.types.HitObject* %[[HITPTR0:[^ ]+]], %"class.RayQuery<5, 0>"* %[[RQ:[^ ]+]]) +// FCGL-NEXT: call void @"\01?Use@@YAXVHitObject@dx@@@Z"(%dx.types.HitObject* %[[HITPTR0]]) +// FCGL: call void @"dx.hl.op..void (i32, %dx.types.HitObject*, %\22class.RayQuery<5, 0>\22*, i32, %struct.CustomAttrs*)"(i32 363, %dx.types.HitObject* %[[HITPTR1:[^ ]+]], %"class.RayQuery<5, 0>"* %[[RQ]], i32 16, %struct.CustomAttrs* %{{[^ ]+}}) +// FCGL-NEXT: call void @"\01?Use@@YAXVHitObject@dx@@@Z"(%dx.types.HitObject* %[[HITPTR1]]) + +RaytracingAccelerationStructure RTAS; +RWStructuredBuffer UAV : register(u0); + +RayDesc MakeRayDesc() { + RayDesc desc; + desc.Origin = float3(0, 0, 0); + desc.Direction = float3(1, 0, 0); + desc.TMin = 0.0f; + desc.TMax = 9999.0; + return desc; +} + +struct CustomAttrs { + float x; + float y; +}; + +void Use(in dx::HitObject hit) { + dx::MaybeReorderThread(hit); +} + +[shader("raygeneration")] +void main() { + RayQuery q; + RayDesc ray = MakeRayDesc(); + q.TraceRayInline(RTAS, RAY_FLAG_NONE, 0xFF, ray); + + Use(dx::HitObject::FromRayQuery(q)); + + CustomAttrs attrs = {1.f, 2.f}; + Use(dx::HitObject::FromRayQuery(q, 16, attrs)); +}