Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/DxilValidation/DxilValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5449,12 +5449,11 @@ struct CompatibilityChecker {
MaskForDeriv |=
static_cast<uint32_t>(ConflictFlags::DerivInComputeShaderModel);
} else if (ShaderKind == DXIL::ShaderKind::Node) {
// Only broadcasting launch supports derivatives.
if (Props.Node.LaunchType != DXIL::NodeLaunchType::Broadcasting)
MaskForDeriv |= static_cast<uint32_t>(ConflictFlags::DerivLaunch);
// Thread launch node has no group.
if (Props.Node.LaunchType == DXIL::NodeLaunchType::Thread)
// Thread launch node has no group and doesn't support derivatives.
if (Props.Node.LaunchType == DXIL::NodeLaunchType::Thread) {
MaskForGroup |= static_cast<uint32_t>(ConflictFlags::RequiresGroup);
MaskForDeriv |= static_cast<uint32_t>(ConflictFlags::DerivLaunch);
}
}

if (ShaderKind == DXIL::ShaderKind::Mesh ||
Expand Down
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
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Test 6.6 feature allowing derivative operations in compute shaders

Expand All @@ -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;

Expand Down Expand Up @@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
Expand Down