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
2 changes: 1 addition & 1 deletion docs/DXIL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3289,7 +3289,7 @@ SM.HSINPUTCONTROLPOINTCOUNTRANGE HS input control p
SM.HULLPASSTHRUCONTROLPOINTCOUNTMATCH For pass thru hull shader, input control point count must match output control point count
SM.INCOMPATIBLECALLINENTRY Features used in internal function calls must be compatible with entry
SM.INCOMPATIBLEDERIVINCOMPUTESHADERMODEL Derivatives in compute-model shaders require shader model 6.6 and above
SM.INCOMPATIBLEDERIVLAUNCH Node shaders only support derivatives in broadcasting launch mode
SM.INCOMPATIBLEDERIVLAUNCH Node shaders only support derivatives in broadcasting and coalescing launch modes
SM.INCOMPATIBLEOPERATION Operations used in entry function must be compatible with shader stage and other properties
SM.INCOMPATIBLEREQUIRESGROUP Functions requiring groupshared memory must be called from shaders with a visible group
SM.INCOMPATIBLESHADERMODEL Functions may only use features available in the current shader model
Expand Down
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

// Test 6.6 feature allowing derivative operations in compute shaders

Expand All @@ -20,13 +24,26 @@ 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, uint3 DTid : SV_DispatchThreadID )
{
float2 uv = DTid.xy/float2(8, 8);
void main( uint GI : SV_GroupIndex, uint2 GTid : SV_GroupThreadID
) {
float2 uv = GTid.xy/float2(8, 8);
float4 res = 0;
uint status = 0;

Expand Down Expand Up @@ -100,8 +117,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);
res += input.SampleCmp(cmpSamp, uv, cmpVal, uint2(-5, 7), GI, status);
res *= status;

#if STAGE == AS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
; Sample called from node shader is not allowed with thread launch.

; CHECK: Function: main: error: Entry function calls one or more functions using incompatible features. See other errors for details.
; CHECK: Function: {{.*}}fn_sample{{.*}}: error: Function called from Thread launch node shader uses derivatives; only broadcasting launch supports derivatives.
; CHECK: Function: {{.*}}fn_sample{{.*}}: error: Function called from Thread launch node shader uses derivatives; only broadcasting and coalescing launch modes support derivatives.
; CHECK: Function: {{.*}}fn_sample{{.*}}: error: Function uses derivatives in compute-model shader with NumThreads (1, 1, 1); derivatives require NumThreads to be 1D and a multiple of 4, or 2D/3D with X and Y both being a multiple of 2.

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"
Expand Down
4 changes: 2 additions & 2 deletions utils/hct/hctdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8962,8 +8962,8 @@ def build_valrules(self):
)
self.add_valrule_msg(
"Sm.IncompatibleDerivLaunch",
"Node shaders only support derivatives in broadcasting launch mode",
"Function called from %0 launch node shader uses derivatives; only broadcasting launch supports derivatives.",
"Node shaders only support derivatives in broadcasting and coalescing launch modes",
"Function called from %0 launch node shader uses derivatives; only broadcasting and coalescing launch modes support derivatives.",
)

# Assign sensible category names and build up an enumeration description
Expand Down