diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index b847ab51c3..d426b955f2 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -37,6 +37,9 @@ line upon naming the release. Refer to previous for appropriate section names. - `dx::IsDebuggerPresent()` returns true if a debugger is attached. - SPIR-V: `DebugBreak()` emits `NonSemantic.DebugBreak` extended instruction; `IsDebuggerPresent()` is not supported. +#### Other Changes +- Fixed mesh shader semantics that were incorrectly case sensitive. + ### Version 1.9.2602 #### Shader Model 6.9 Release diff --git a/tools/clang/lib/Sema/SemaHLSL.cpp b/tools/clang/lib/Sema/SemaHLSL.cpp index d41816a8a2..5af89051da 100644 --- a/tools/clang/lib/Sema/SemaHLSL.cpp +++ b/tools/clang/lib/Sema/SemaHLSL.cpp @@ -14,6 +14,7 @@ #include "VkConstantsTables.h" #include "dxc/DXIL/DxilConstants.h" #include "dxc/DXIL/DxilFunctionProps.h" +#include "dxc/DXIL/DxilSemantic.h" #include "dxc/DXIL/DxilShaderModel.h" #include "dxc/DXIL/DxilUtil.h" #include "dxc/HLSL/HLOperations.h" @@ -11721,7 +11722,6 @@ void hlsl::DiagnoseRegisterType(clang::Sema *self, clang::SourceLocation loc, // FIXME: DiagnoseSVForLaunchType is wrong in multiple ways: // - It doesn't handle system values inside structs -// - It doesn't account for the fact that semantics are case-insensitive // - It doesn't account for optional index at the end of semantic name // - It permits any `SV_*` for Broadcasting launch, not just the legal ones // - It doesn't prevent multiple system values with the same semantic @@ -11731,15 +11731,19 @@ void hlsl::DiagnoseRegisterType(clang::Sema *self, clang::SourceLocation loc, static void DiagnoseSVForLaunchType(const FunctionDecl *FD, DXIL::NodeLaunchType LaunchTy, DiagnosticsEngine &Diags) { + // Validate Compute Shader system value inputs per launch mode for (ParmVarDecl *param : FD->parameters()) { for (const hlsl::UnusualAnnotation *it : param->getUnusualAnnotations()) { if (it->getKind() == hlsl::UnusualAnnotation::UA_SemanticDecl) { const hlsl::SemanticDecl *sd = cast(it); + const auto *semantic = hlsl::Semantic::GetByName(sd->SemanticName); + assert(semantic->GetKind() != hlsl::Semantic::Kind::Invalid); + // if the node launch type is Thread, then there are no system values // allowed if (LaunchTy == DXIL::NodeLaunchType::Thread) { - if (sd->SemanticName.startswith("SV_")) { + if (semantic->GetKind() != hlsl::Semantic::Kind::Arbitrary) { // emit diagnostic unsigned DiagID = Diags.getCustomDiagID( DiagnosticsEngine::Error, @@ -11752,8 +11756,8 @@ static void DiagnoseSVForLaunchType(const FunctionDecl *FD, // if the node launch type is Coalescing, then only // SV_GroupIndex and SV_GroupThreadID are allowed else if (LaunchTy == DXIL::NodeLaunchType::Coalescing) { - if (!(sd->SemanticName.equals("SV_GroupIndex") || - sd->SemanticName.equals("SV_GroupThreadID"))) { + if (semantic->GetKind() != hlsl::Semantic::Kind::GroupIndex && + semantic->GetKind() != hlsl::Semantic::Kind::GroupThreadID) { // emit diagnostic unsigned DiagID = Diags.getCustomDiagID( DiagnosticsEngine::Error, diff --git a/tools/clang/test/SemaHLSL/hlsl/workgraph/node_input_semantic.hlsl b/tools/clang/test/SemaHLSL/hlsl/workgraph/node_input_semantic.hlsl new file mode 100644 index 0000000000..59845e1873 --- /dev/null +++ b/tools/clang/test/SemaHLSL/hlsl/workgraph/node_input_semantic.hlsl @@ -0,0 +1,29 @@ +// RUN: %dxc -Tlib_6_8 -verify %s + +[Shader("node")] +[NodeLaunch("coalescing")] +[NumThreads(1024, 1, 1)] +[NodeIsProgramEntry] +void foo(uint3 tid : SV_GroupThreadId) +{ } + +[Shader("node")] +[NodeLaunch("coalescing")] +[NumThreads(1024, 1, 1)] +[NodeIsProgramEntry] +void bar(uint3 tid : SV_GroupThreadID) +{ } + +[Shader("node")] +[NodeLaunch("coalescing")] +[NumThreads(1024, 1, 1)] +[NodeIsProgramEntry] +void baz(uint3 tid : SV_VertexID) // expected-error {{Invalid system value semantic 'SV_VertexID' for launchtype 'Coalescing'}} +{ } + +[Shader("node")] +[NodeLaunch("coalescing")] +[NumThreads(1024, 1, 1)] +[NodeIsProgramEntry] +void buz(uint tid : SV_GROUPINDEX) +{ }