-
Notifications
You must be signed in to change notification settings - Fork 827
[SM6.10] Complete ClusterID implementation #8065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
simoll
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
simoll:sm610_clusterid_impl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+627
−8
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
tools/clang/test/CodeGenDXIL/hlsl/intrinsics/clusterid.hlsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // REQUIRES: dxil-1-10 | ||
| // RUN: %dxc -T lib_6_10 %s | FileCheck %s | ||
| // RUN: %dxc -T lib_6_10 %s -ast-dump-implicit | FileCheck %s --check-prefix AST | ||
| // RUN: %dxc -T lib_6_10 %s -fcgl | FileCheck %s --check-prefix FCGL | ||
|
|
||
| // Test ClusterID intrinsics for SM 6.10 | ||
|
|
||
| // AST: `-CXXMethodDecl {{.*}} used GetClusterID 'unsigned int ()' extern | ||
| // AST-NEXT: {{.*}}|-TemplateArgument type 'unsigned int' | ||
| // AST-NEXT: {{.*}}|-HLSLIntrinsicAttr {{.*}} Implicit "op" "" 400 | ||
| // AST-NEXT: {{.*}}|-ConstAttr {{.*}} Implicit | ||
| // AST-NEXT: {{.*}}`-AvailabilityAttr {{.*}} Implicit 6.10 0 0 "" | ||
|
|
||
| // AST: `-CXXMethodDecl {{.*}} used CandidateClusterID 'unsigned int ()' extern | ||
| // AST-NEXT: {{.*}}|-TemplateArgument type 'unsigned int' | ||
| // AST-NEXT: {{.*}}|-HLSLIntrinsicAttr {{.*}} Implicit "op" "" 398 | ||
| // AST-NEXT: {{.*}}|-PureAttr {{.*}} Implicit | ||
| // AST-NEXT: {{.*}}`-AvailabilityAttr {{.*}} Implicit 6.10 0 0 "" | ||
|
|
||
| // AST: `-CXXMethodDecl {{.*}} used CommittedClusterID 'unsigned int ()' extern | ||
| // AST-NEXT: {{.*}}|-TemplateArgument type 'unsigned int' | ||
| // AST-NEXT: {{.*}}|-HLSLIntrinsicAttr {{.*}} Implicit "op" "" 399 | ||
| // AST-NEXT: {{.*}}|-PureAttr {{.*}} Implicit | ||
| // AST-NEXT: {{.*}}`-AvailabilityAttr {{.*}} Implicit 6.10 0 0 "" | ||
|
|
||
| // AST: -FunctionDecl {{.*}} implicit used ClusterID 'unsigned int ()' extern | ||
| // AST-NEXT: {{.*}}|-HLSLIntrinsicAttr {{.*}} Implicit "op" "" 397 | ||
| // AST-NEXT: {{.*}}|-ConstAttr {{.*}} Implicit | ||
| // AST-NEXT: {{.*}}|-AvailabilityAttr {{.*}} Implicit 6.10 0 0 "" | ||
| // AST-NEXT: {{.*}}`-HLSLBuiltinCallAttr {{.*}} Implicit | ||
|
|
||
| RWByteAddressBuffer outbuf : register(u0); | ||
|
|
||
| struct [raypayload] Payload { | ||
| float dummy : read(caller, closesthit, miss, anyhit) : write(caller, closesthit, miss, anyhit); | ||
| }; | ||
|
|
||
| // Global ClusterID intrinsic | ||
| // CHECK-LABEL: define void @{{.*}}test_cluster_id{{.*}}( | ||
| // CHECK: call i32 @dx.op.clusterID(i32 -2147483645) | ||
| // CHECK: call void @dx.op.rawBufferStore.i32 | ||
|
|
||
| // FCGL-LABEL: define void @{{.*}}test_cluster_id{{.*}}( | ||
| // FCGL: call i32 @"dx.hl.op.rn.i32 (i32)"(i32 397) | ||
| [shader("closesthit")] | ||
| void test_cluster_id(inout Payload payload, in BuiltInTriangleIntersectionAttributes attr) { | ||
| uint cid = ClusterID(); | ||
| outbuf.Store(0, cid); | ||
| } | ||
|
|
||
| // RayQuery CandidateClusterID | ||
| // CHECK-LABEL: define void @{{.*}}test_rayquery_candidate_cluster_id{{.*}}( | ||
| // CHECK: call i32 @dx.op.rayQuery_StateScalar.i32(i32 -2147483644 | ||
| // CHECK: call void @dx.op.rawBufferStore.i32 | ||
|
|
||
| // FCGL-LABEL: define void @{{.*}}test_rayquery_candidate_cluster_id{{.*}}( | ||
| // FCGL: call i32 @"dx.hl.op.ro.i32 (i32, %{{.*}}"(i32 398 | ||
| [shader("raygeneration")] | ||
| void test_rayquery_candidate_cluster_id() { | ||
| RayQuery<RAY_FLAG_NONE> rq; | ||
| RaytracingAccelerationStructure as; | ||
| RayDesc ray; | ||
| ray.Origin = float3(0, 0, 0); | ||
| ray.Direction = float3(0, 0, 1); | ||
| ray.TMin = 0.0; | ||
| ray.TMax = 1000.0; | ||
|
|
||
| rq.TraceRayInline(as, 0, 0xff, ray); | ||
| rq.Proceed(); | ||
| uint cid = rq.CandidateClusterID(); | ||
| outbuf.Store(4, cid); | ||
| } | ||
|
|
||
| // RayQuery CommittedClusterID | ||
| // CHECK-LABEL: define void @{{.*}}test_rayquery_committed_cluster_id{{.*}}( | ||
| // CHECK: call i32 @dx.op.rayQuery_StateScalar.i32(i32 -2147483643 | ||
| // CHECK: call void @dx.op.rawBufferStore.i32 | ||
|
|
||
| // FCGL-LABEL: define void @{{.*}}test_rayquery_committed_cluster_id{{.*}}( | ||
| // FCGL: call i32 @"dx.hl.op.ro.i32 (i32, %{{.*}}"(i32 399 | ||
| [shader("raygeneration")] | ||
| void test_rayquery_committed_cluster_id() { | ||
| RayQuery<RAY_FLAG_NONE> rq; | ||
| RaytracingAccelerationStructure as; | ||
| RayDesc ray; | ||
| ray.Origin = float3(0, 0, 0); | ||
| ray.Direction = float3(0, 0, 1); | ||
| ray.TMin = 0.0; | ||
| ray.TMax = 1000.0; | ||
|
|
||
| rq.TraceRayInline(as, 0, 0xff, ray); | ||
| uint cid = rq.CommittedClusterID(); | ||
| outbuf.Store(8, cid); | ||
| } | ||
|
|
||
| // HitObject GetClusterID | ||
| // CHECK-LABEL: define void @{{.*}}test_hitobject_cluster_id{{.*}}( | ||
| // CHECK: call i32 @dx.op.hitObject_StateScalar.i32(i32 -2147483642 | ||
| // CHECK: call void @dx.op.rawBufferStore.i32 | ||
|
|
||
| // FCGL-LABEL: define void @{{.*}}test_hitobject_cluster_id{{.*}}( | ||
| // FCGL: call i32 @"dx.hl.op.rn.i32 (i32, %dx.types.HitObject{{.*}}"(i32 400 | ||
| [shader("raygeneration")] | ||
| void test_hitobject_cluster_id() { | ||
| dx::HitObject ho = dx::HitObject::MakeNop(); | ||
| uint cid = ho.GetClusterID(); | ||
| outbuf.Store(12, cid); | ||
| } | ||
|
|
37 changes: 37 additions & 0 deletions
37
tools/clang/test/CodeGenDXIL/hlsl/intrinsics/clusterid_invalid_constant.hlsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // REQUIRES: dxil-1-10 | ||
| // RUN: %dxc -T lib_6_10 %s | FileCheck %s | ||
|
|
||
| // Test CLUSTER_ID_INVALID constant | ||
|
|
||
| RWByteAddressBuffer outbuf : register(u0); | ||
|
|
||
| struct [raypayload] Payload { | ||
| float dummy : read(caller, closesthit, miss, anyhit) : write(caller, closesthit, miss, anyhit); | ||
| }; | ||
|
|
||
| // CHECK-LABEL: define void @{{.*}}test_cluster_id_invalid{{.*}}( | ||
| // CHECK: %[[CID:[0-9]+]] = call i32 @dx.op.clusterID(i32 -2147483645) | ||
| // CHECK: %[[CMP:[0-9]+]] = icmp eq i32 %[[CID]], -1 | ||
| // CHECK: br i1 %[[CMP]] | ||
| // CHECK: call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %{{[0-9]+}}, i32 0, i32 undef, i32 -1, i32 undef, i32 undef, i32 undef, i8 1, i32 4) | ||
| // CHECK: call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %{{[0-9]+}}, i32 0, i32 undef, i32 %[[CID]], i32 undef, i32 undef, i32 undef, i8 1, i32 4) | ||
| [shader("closesthit")] | ||
| void test_cluster_id_invalid(inout Payload payload, in BuiltInTriangleIntersectionAttributes attr) { | ||
| uint cid = ClusterID(); | ||
|
|
||
| // Test the CLUSTER_ID_INVALID constant (0xffffffff = -1 as signed) | ||
| if (cid == CLUSTER_ID_INVALID) { | ||
| outbuf.Store(0, CLUSTER_ID_INVALID); | ||
| } else { | ||
| outbuf.Store(0, cid); | ||
| } | ||
| } | ||
|
|
||
| // CHECK-LABEL: define void @{{.*}}test_constant_value{{.*}}( | ||
| // CHECK: call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %{{[0-9]+}}, i32 0, i32 undef, i32 -1, i32 undef, i32 undef, i32 undef, i8 1, i32 4) | ||
| [shader("raygeneration")] | ||
| void test_constant_value() { | ||
| // Verify the constant value is 0xffffffff | ||
| outbuf.Store(0, CLUSTER_ID_INVALID); | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.