-
Notifications
You must be signed in to change notification settings - Fork 808
Allow derivatives in coalescing nodes #7942
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,17 @@ | ||
| // RUN: %dxc -DSTAGE=1 -T cs_6_6 %s | FileCheck %s | ||
| // RUN: %dxc -DSTAGE=2 -T as_6_6 %s | FileCheck %s -check-prefixes=CHECK,ASMSCHECK | ||
| // RUN: %dxc -DSTAGE=3 -T ms_6_6 %s | FileCheck %s -check-prefixes=CHECK,ASMSCHECK | ||
| // RUN: %dxc -DSTAGE=4 -T lib_6_8 %s | FileCheck %s | ||
| // RUN: %dxc -DSTAGE=5 -T lib_6_8 %s | FileCheck %s | ||
| // RUN: %dxilver 1.6 | %dxc -DSTAGE=1 -T cs_6_5 -Wno-hlsl-availability %s | FileCheck %s -check-prefix=ERRCHECK | ||
| // RUN: %dxilver 1.6 | %dxc -DSTAGE=2 -T as_6_5 -Wno-hlsl-availability %s | FileCheck %s -check-prefix=ERRCHECK | ||
| // RUN: %dxilver 1.6 | %dxc -DSTAGE=3 -T ms_6_5 -Wno-hlsl-availability %s | FileCheck %s -check-prefix=ERRCHECK | ||
|
|
||
| #define CS 1 | ||
| #define AS 2 | ||
| #define MS 3 | ||
| #define BNS 4 | ||
| #define CNS 5 | ||
|
|
||
| // Test 6.6 feature allowing derivative operations in compute shaders | ||
|
|
||
|
|
@@ -20,13 +24,31 @@ SamplerState samp : register(s5); | |
| SamplerComparisonState cmpSamp : register(s6); | ||
| float cmpVal; | ||
|
|
||
|
|
||
| struct NodeRecord { | ||
| uint w, h; | ||
| }; | ||
|
|
||
|
|
||
| [numthreads( 8, 8, 1 )] | ||
| #if STAGE==MS | ||
| [outputtopology("triangle")] | ||
| #elif STAGE==BNS | ||
| [Shader("node")] | ||
| [NodeLaunch("broadcasting")] | ||
| [NodeDispatchGrid(1, 1, 1)] | ||
| #elif STAGE==CNS | ||
| [Shader("node")] | ||
| [NodeLaunch("coalescing")] | ||
| #endif | ||
| void main( uint GI : SV_GroupIndex, uint2 GTid : SV_GroupThreadID | ||
| #if STAGE==BNS | ||
| , DispatchNodeInputRecord<NodeRecord> inputData | ||
| #elif STAGE==CNS | ||
| , [MaxRecords(4)] GroupNodeInputRecords<NodeRecord> inputRecords | ||
| #endif | ||
| void main( uint GI : SV_GroupIndex, uint3 DTid : SV_DispatchThreadID ) | ||
| { | ||
| float2 uv = DTid.xy/float2(8, 8); | ||
| ) { | ||
| float2 uv = GTid.xy/float2(8, 8); | ||
| float4 res = 0; | ||
| uint status = 0; | ||
|
|
||
|
|
@@ -100,8 +122,8 @@ void main( uint GI : SV_GroupIndex, uint3 DTid : SV_DispatchThreadID ) | |
| // ERRCHECK: error: opcode 'Derivatives in CS/MS/AS' should only be used in 'Shader Model 6.6+' | ||
| res += input.SampleCmp(cmpSamp, uv, cmpVal); | ||
| res += input.SampleCmp(cmpSamp, uv, cmpVal, uint2(-3, 4)); | ||
| res += input.SampleCmp(cmpSamp, uv, cmpVal, uint2(-4, 6), DTid.z); | ||
| res += input.SampleCmp(cmpSamp, uv, cmpVal, uint2(-5, 7), DTid.z, status); | ||
| res += input.SampleCmp(cmpSamp, uv, cmpVal, uint2(-4, 6), GI); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was this needed?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose it wasn't if I just converted the GTid that replaced DTid with uint3. That replacement took place because all launch types support that semantic value and coalescing doesn't support DispatchThreadID. The uses are pretty arbitrary, just using what values are available. |
||
| res += input.SampleCmp(cmpSamp, uv, cmpVal, uint2(-5, 7), GI, status); | ||
| res *= status; | ||
|
|
||
| #if STAGE == AS | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an error check if we try to use derivatives with Thread Launch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same thought! But that test already exists: https://github.com/microsoft/DirectXShaderCompiler/blob/main/tools/clang/test/HLSLFileCheck/validation/callgraph/deriv-in-nested-fn-node-lib68-launch.ll#L6