Skip to content

Commit

Permalink
make invalid launch type return empty str instead of invalid, check i…
Browse files Browse the repository at this point in the history
…f shaderkind is node before setting launchtype
  • Loading branch information
bob80905 committed Jan 8, 2024
1 parent 6755a9b commit d9a25cc
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/HLSL/DxilValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2144,9 +2144,11 @@ std::string GetLaunchTypeStr(DXIL::NodeLaunchType LT) {
return "Thread";
case DXIL::NodeLaunchType::Invalid:
case DXIL::NodeLaunchType::LastEntry:
return "Invalid";
return "";

default:
return "";
}
llvm_unreachable("invalid launch type");
}

static void ValidateDxilOperationCallInProfile(CallInst *CI,
Expand All @@ -2160,8 +2162,10 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI,
if (DXIL::ShaderKind::Library == shaderKind) {
if (ValCtx.DxilMod.HasDxilFunctionProps(F)) {
DxilEntryProps &entryProps = ValCtx.DxilMod.GetDxilEntryProps(F);
nodeLaunchType = entryProps.props.Node.LaunchType;
shaderKind = ValCtx.DxilMod.GetDxilFunctionProps(F).shaderKind;
if (shaderKind == DXIL::ShaderKind::Node)
nodeLaunchType = entryProps.props.Node.LaunchType;

} else if (ValCtx.DxilMod.IsPatchConstantShader(F))
shaderKind = DXIL::ShaderKind::Hull;
}
Expand Down
39 changes: 39 additions & 0 deletions tools/clang/test/HLSLFileCheck/dxil/intrinsics/launch_types.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// RUN: %dxc -T lib_6_3 -D e1 %s | FileCheck -check-prefix=CHECK_ENTRY1 %s
// RUN: %dxc -T lib_6_3 -D e2 %s
// RUN: %dxc -T lib_6_3 -D e3 %s | FileCheck -check-prefix=CHECK_ENTRY3 %s


#ifdef e1
// CHECK_ENTRY1: error: Invalid system value semantic 'SV_DispatchThreadID' for launchtype 'Thread'
// CHECK_ENTRY1: error: Invalid system value semantic 'SV_GroupID' for launchtype 'Thread'
// CHECK_ENTRY1: error: Invalid system value semantic 'SV_GroupThreadID' for launchtype 'Thread'
// CHECK_ENTRY1: error: Invalid system value semantic 'SV_GroupIndex' for launchtype 'Thread'
[shader("node")]
[NodeLaunch("thread")]
[numthreads(1,1,1)]
void entry( uint2 tid : SV_DispatchThreadID, uint2 gid : SV_GroupID, uint2 gtid : SV_GroupThreadID, uint gidx : SV_GroupIndex )
{
}
#endif

#ifdef e2
// no expected errors
[shader("node")]
[NodeDispatchGrid(1,1,1)]
[NodeLaunch("broadcasting")]
[numthreads(1,1,1)]
void entry2( uint2 tid : SV_DispatchThreadID, uint2 gid : SV_GroupID, uint2 gtid : SV_GroupThreadID, uint gidx : SV_GroupIndex )
{
}
#endif

#ifdef e3
// CHECK_ENTRY3: error: Invalid system value semantic 'SV_DispatchThreadID' for launchtype 'Coalescing'
// CHECK_ENTRY3: error: Invalid system value semantic 'SV_GroupID' for launchtype 'Coalescing'
[shader("node")]
[NodeLaunch("coalescing")]
[numthreads(1,1,1)]
void entry3( uint2 tid : SV_DispatchThreadID, uint2 gid : SV_GroupID, uint2 gtid : SV_GroupThreadID, uint gidx : SV_GroupIndex )
{
}
#endif

0 comments on commit d9a25cc

Please sign in to comment.