1414#include "VkConstantsTables.h"
1515#include "dxc/DXIL/DxilConstants.h"
1616#include "dxc/DXIL/DxilFunctionProps.h"
17+ #include "dxc/DXIL/DxilSemantic.h"
1718#include "dxc/DXIL/DxilShaderModel.h"
1819#include "dxc/DXIL/DxilUtil.h"
1920#include "dxc/HLSL/HLOperations.h"
@@ -11721,7 +11722,6 @@ void hlsl::DiagnoseRegisterType(clang::Sema *self, clang::SourceLocation loc,
1172111722
1172211723// FIXME: DiagnoseSVForLaunchType is wrong in multiple ways:
1172311724// - It doesn't handle system values inside structs
11724- // - It doesn't account for the fact that semantics are case-insensitive
1172511725// - It doesn't account for optional index at the end of semantic name
1172611726// - It permits any `SV_*` for Broadcasting launch, not just the legal ones
1172711727// - It doesn't prevent multiple system values with the same semantic
@@ -11731,15 +11731,19 @@ void hlsl::DiagnoseRegisterType(clang::Sema *self, clang::SourceLocation loc,
1173111731static void DiagnoseSVForLaunchType(const FunctionDecl *FD,
1173211732 DXIL::NodeLaunchType LaunchTy,
1173311733 DiagnosticsEngine &Diags) {
11734+
1173411735 // Validate Compute Shader system value inputs per launch mode
1173511736 for (ParmVarDecl *param : FD->parameters()) {
1173611737 for (const hlsl::UnusualAnnotation *it : param->getUnusualAnnotations()) {
1173711738 if (it->getKind() == hlsl::UnusualAnnotation::UA_SemanticDecl) {
1173811739 const hlsl::SemanticDecl *sd = cast<hlsl::SemanticDecl>(it);
11740+ const auto *semantic = hlsl::Semantic::GetByName(sd->SemanticName);
11741+ assert(semantic->GetKind() != hlsl::Semantic::Kind::Invalid);
11742+
1173911743 // if the node launch type is Thread, then there are no system values
1174011744 // allowed
1174111745 if (LaunchTy == DXIL::NodeLaunchType::Thread) {
11742- if (sd->SemanticName.startswith("SV_") ) {
11746+ if (semantic->GetKind() != hlsl::Semantic::Kind::Arbitrary ) {
1174311747 // emit diagnostic
1174411748 unsigned DiagID = Diags.getCustomDiagID(
1174511749 DiagnosticsEngine::Error,
@@ -11752,8 +11756,8 @@ static void DiagnoseSVForLaunchType(const FunctionDecl *FD,
1175211756 // if the node launch type is Coalescing, then only
1175311757 // SV_GroupIndex and SV_GroupThreadID are allowed
1175411758 else if (LaunchTy == DXIL::NodeLaunchType::Coalescing) {
11755- if (!(sd->SemanticName.equals("SV_GroupIndex") ||
11756- sd->SemanticName.equals("SV_GroupThreadID")) ) {
11759+ if (semantic->GetKind() != hlsl::Semantic::Kind::GroupIndex &&
11760+ semantic->GetKind() != hlsl::Semantic::Kind::GroupThreadID ) {
1175711761 // emit diagnostic
1175811762 unsigned DiagID = Diags.getCustomDiagID(
1175911763 DiagnosticsEngine::Error,
0 commit comments