|
| 1 | +// REQUIRES: dxil-1-10 |
| 2 | +// RUN: %dxc -T lib_6_10 %s | FileCheck %s |
| 3 | +// RUN: %dxc -T lib_6_10 %s -ast-dump-implicit | FileCheck %s --check-prefix AST |
| 4 | +// RUN: %dxc -T lib_6_10 %s -fcgl | FileCheck %s --check-prefix FCGL |
| 5 | + |
| 6 | +// Test ClusterID intrinsics for SM 6.10 |
| 7 | + |
| 8 | +// AST: `-CXXMethodDecl {{.*}} used GetClusterID 'unsigned int ()' extern |
| 9 | +// AST-NEXT: {{.*}}|-TemplateArgument type 'unsigned int' |
| 10 | +// AST-NEXT: {{.*}}|-HLSLIntrinsicAttr {{.*}} Implicit "op" "" 400 |
| 11 | +// AST-NEXT: {{.*}}|-ConstAttr {{.*}} Implicit |
| 12 | +// AST-NEXT: {{.*}}`-AvailabilityAttr {{.*}} Implicit 6.10 0 0 "" |
| 13 | + |
| 14 | +// AST: `-CXXMethodDecl {{.*}} used CandidateClusterID 'unsigned int ()' extern |
| 15 | +// AST-NEXT: {{.*}}|-TemplateArgument type 'unsigned int' |
| 16 | +// AST-NEXT: {{.*}}|-HLSLIntrinsicAttr {{.*}} Implicit "op" "" 398 |
| 17 | +// AST-NEXT: {{.*}}|-PureAttr {{.*}} Implicit |
| 18 | +// AST-NEXT: {{.*}}`-AvailabilityAttr {{.*}} Implicit 6.10 0 0 "" |
| 19 | + |
| 20 | +// AST: `-CXXMethodDecl {{.*}} used CommittedClusterID 'unsigned int ()' extern |
| 21 | +// AST-NEXT: {{.*}}|-TemplateArgument type 'unsigned int' |
| 22 | +// AST-NEXT: {{.*}}|-HLSLIntrinsicAttr {{.*}} Implicit "op" "" 399 |
| 23 | +// AST-NEXT: {{.*}}|-PureAttr {{.*}} Implicit |
| 24 | +// AST-NEXT: {{.*}}`-AvailabilityAttr {{.*}} Implicit 6.10 0 0 "" |
| 25 | + |
| 26 | +// AST: -FunctionDecl {{.*}} implicit used ClusterID 'unsigned int ()' extern |
| 27 | +// AST-NEXT: {{.*}}|-HLSLIntrinsicAttr {{.*}} Implicit "op" "" 397 |
| 28 | +// AST-NEXT: {{.*}}|-ConstAttr {{.*}} Implicit |
| 29 | +// AST-NEXT: {{.*}}|-AvailabilityAttr {{.*}} Implicit 6.10 0 0 "" |
| 30 | +// AST-NEXT: {{.*}}`-HLSLBuiltinCallAttr {{.*}} Implicit |
| 31 | + |
| 32 | +RWByteAddressBuffer outbuf : register(u0); |
| 33 | + |
| 34 | +struct [raypayload] Payload { |
| 35 | + float dummy : read(caller, closesthit, miss, anyhit) : write(caller, closesthit, miss, anyhit); |
| 36 | +}; |
| 37 | + |
| 38 | +// Global ClusterID intrinsic |
| 39 | +// CHECK-LABEL: define void @{{.*}}test_cluster_id{{.*}}( |
| 40 | +// CHECK: call i32 @dx.op.clusterID(i32 -2147483645) |
| 41 | +// CHECK: call void @dx.op.rawBufferStore.i32 |
| 42 | + |
| 43 | +// FCGL-LABEL: define void @{{.*}}test_cluster_id{{.*}}( |
| 44 | +// FCGL: call i32 @"dx.hl.op.rn.i32 (i32)"(i32 397) |
| 45 | +[shader("closesthit")] |
| 46 | +void test_cluster_id(inout Payload payload, in BuiltInTriangleIntersectionAttributes attr) { |
| 47 | + uint cid = ClusterID(); |
| 48 | + outbuf.Store(0, cid); |
| 49 | +} |
| 50 | + |
| 51 | +// RayQuery CandidateClusterID |
| 52 | +// CHECK-LABEL: define void @{{.*}}test_rayquery_candidate_cluster_id{{.*}}( |
| 53 | +// CHECK: call i32 @dx.op.rayQuery_StateScalar.i32(i32 -2147483644 |
| 54 | +// CHECK: call void @dx.op.rawBufferStore.i32 |
| 55 | + |
| 56 | +// FCGL-LABEL: define void @{{.*}}test_rayquery_candidate_cluster_id{{.*}}( |
| 57 | +// FCGL: call i32 @"dx.hl.op.ro.i32 (i32, %{{.*}}"(i32 398 |
| 58 | +[shader("raygeneration")] |
| 59 | +void test_rayquery_candidate_cluster_id() { |
| 60 | + RayQuery<RAY_FLAG_NONE> rq; |
| 61 | + RaytracingAccelerationStructure as; |
| 62 | + RayDesc ray; |
| 63 | + ray.Origin = float3(0, 0, 0); |
| 64 | + ray.Direction = float3(0, 0, 1); |
| 65 | + ray.TMin = 0.0; |
| 66 | + ray.TMax = 1000.0; |
| 67 | + |
| 68 | + rq.TraceRayInline(as, 0, 0xff, ray); |
| 69 | + rq.Proceed(); |
| 70 | + uint cid = rq.CandidateClusterID(); |
| 71 | + outbuf.Store(4, cid); |
| 72 | +} |
| 73 | + |
| 74 | +// RayQuery CommittedClusterID |
| 75 | +// CHECK-LABEL: define void @{{.*}}test_rayquery_committed_cluster_id{{.*}}( |
| 76 | +// CHECK: call i32 @dx.op.rayQuery_StateScalar.i32(i32 -2147483643 |
| 77 | +// CHECK: call void @dx.op.rawBufferStore.i32 |
| 78 | + |
| 79 | +// FCGL-LABEL: define void @{{.*}}test_rayquery_committed_cluster_id{{.*}}( |
| 80 | +// FCGL: call i32 @"dx.hl.op.ro.i32 (i32, %{{.*}}"(i32 399 |
| 81 | +[shader("raygeneration")] |
| 82 | +void test_rayquery_committed_cluster_id() { |
| 83 | + RayQuery<RAY_FLAG_NONE> rq; |
| 84 | + RaytracingAccelerationStructure as; |
| 85 | + RayDesc ray; |
| 86 | + ray.Origin = float3(0, 0, 0); |
| 87 | + ray.Direction = float3(0, 0, 1); |
| 88 | + ray.TMin = 0.0; |
| 89 | + ray.TMax = 1000.0; |
| 90 | + |
| 91 | + rq.TraceRayInline(as, 0, 0xff, ray); |
| 92 | + uint cid = rq.CommittedClusterID(); |
| 93 | + outbuf.Store(8, cid); |
| 94 | +} |
| 95 | + |
| 96 | +// HitObject GetClusterID |
| 97 | +// CHECK-LABEL: define void @{{.*}}test_hitobject_cluster_id{{.*}}( |
| 98 | +// CHECK: call i32 @dx.op.hitObject_StateScalar.i32(i32 -2147483642 |
| 99 | +// CHECK: call void @dx.op.rawBufferStore.i32 |
| 100 | + |
| 101 | +// FCGL-LABEL: define void @{{.*}}test_hitobject_cluster_id{{.*}}( |
| 102 | +// FCGL: call i32 @"dx.hl.op.rn.i32 (i32, %dx.types.HitObject{{.*}}"(i32 400 |
| 103 | +[shader("raygeneration")] |
| 104 | +void test_hitobject_cluster_id() { |
| 105 | + dx::HitObject ho = dx::HitObject::MakeNop(); |
| 106 | + uint cid = ho.GetClusterID(); |
| 107 | + outbuf.Store(12, cid); |
| 108 | +} |
| 109 | + |
0 commit comments