Skip to content

[HLSL] make semantic matching case insensitive #129773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -4724,21 +4724,21 @@ def HLSLNumThreads: InheritableAttr {
}

def HLSLSV_GroupThreadID: HLSLAnnotationAttr {
let Spellings = [HLSLAnnotation<"SV_GroupThreadID">];
let Spellings = [HLSLAnnotation<"sv_groupthreadid">];
let Subjects = SubjectList<[ParmVar, Field]>;
let LangOpts = [HLSL];
let Documentation = [HLSLSV_GroupThreadIDDocs];
}

def HLSLSV_GroupID: HLSLAnnotationAttr {
let Spellings = [HLSLAnnotation<"SV_GroupID">];
let Spellings = [HLSLAnnotation<"sv_groupid">];
let Subjects = SubjectList<[ParmVar, Field]>;
let LangOpts = [HLSL];
let Documentation = [HLSLSV_GroupIDDocs];
}

def HLSLSV_GroupIndex: HLSLAnnotationAttr {
let Spellings = [HLSLAnnotation<"SV_GroupIndex">];
let Spellings = [HLSLAnnotation<"sv_groupindex">];
let Subjects = SubjectList<[ParmVar, GlobalVar]>;
let LangOpts = [HLSL];
let Documentation = [HLSLSV_GroupIndexDocs];
Expand Down Expand Up @@ -4790,7 +4790,7 @@ def HLSLPackOffset: HLSLAnnotationAttr {
}

def HLSLSV_DispatchThreadID: HLSLAnnotationAttr {
let Spellings = [HLSLAnnotation<"SV_DispatchThreadID">];
let Spellings = [HLSLAnnotation<"sv_dispatchthreadid">];
let Subjects = SubjectList<[ParmVar, Field]>;
let LangOpts = [HLSL];
let Documentation = [HLSLSV_DispatchThreadIDDocs];
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Parse/ParseHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ void Parser::ParseHLSLAnnotations(ParsedAttributes &Attrs,
return;
}

II = PP.getIdentifierInfo(II->getName().lower());

SourceLocation Loc = ConsumeToken();
if (EndLoc)
*EndLoc = Tok.getLocation();
Expand Down
2 changes: 1 addition & 1 deletion clang/test/ParserHLSL/semantic_parsing.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
// expected-error@+1 {{expected HLSL Semantic identifier}}
void Entry(int GI : ) { }

// expected-error@+1 {{unknown HLSL semantic 'SV_IWantAPony'}}
// expected-error@+1 {{unknown HLSL semantic 'sv_iwantapony'}}
void Pony(int GI : SV_IWantAPony) { }
12 changes: 6 additions & 6 deletions clang/test/SemaHLSL/Semantics/groupindex.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
[shader("compute")][numthreads(32,1,1)]
void compute(int GI : SV_GroupIndex) {}

// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'pixel' shaders}}
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'pixel' shaders}}
[shader("pixel")]
void pixel(int GI : SV_GroupIndex) {}

// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'vertex' shaders}}
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'vertex' shaders}}
[shader("vertex")]
void vertex(int GI : SV_GroupIndex) {}

// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'geometry' shaders}}
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'geometry' shaders}}
[shader("geometry")]
void geometry(int GI : SV_GroupIndex) {}

// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'domain' shaders}}
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'domain' shaders}}
[shader("domain")]
void domain(int GI : SV_GroupIndex) {}

// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'amplification' shaders}}
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'amplification' shaders}}
[shader("amplification")][numthreads(32,1,1)]
void amplification(int GI : SV_GroupIndex) {}

// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'mesh' shaders}}
// expected-error@+2 {{attribute 'sv_groupindex' is unsupported in 'mesh' shaders}}
[shader("mesh")][numthreads(32,1,1)]
void mesh(int GI : SV_GroupIndex) {}
32 changes: 16 additions & 16 deletions clang/test/SemaHLSL/Semantics/invalid_entry_parameter.hlsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -x hlsl -ast-dump -verify -o - %s

[numthreads(8,8,1)]
// expected-error@+1 {{attribute 'SV_DispatchThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
// expected-error@+1 {{attribute 'sv_dispatchthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain(float ID : SV_DispatchThreadID) {

}
Expand All @@ -11,71 +11,71 @@ struct ST {
float b;
};
[numthreads(8,8,1)]
// expected-error@+1 {{attribute 'SV_DispatchThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
// expected-error@+1 {{attribute 'sv_dispatchthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain2(ST ID : SV_DispatchThreadID) {

}

void foo() {
// expected-warning@+1 {{'SV_DispatchThreadID' attribute only applies to parameters and non-static data members}}
// expected-warning@+1 {{'sv_dispatchthreadid' attribute only applies to parameters and non-static data members}}
uint V : SV_DispatchThreadID;

}

struct ST2 {
// expected-warning@+1 {{'SV_DispatchThreadID' attribute only applies to parameters and non-static data members}}
// expected-warning@+1 {{'sv_dispatchthreadid' attribute only applies to parameters and non-static data members}}
static uint X : SV_DispatchThreadID;
uint s : SV_DispatchThreadID;
};

[numthreads(8,8,1)]
// expected-error@+1 {{attribute 'SV_GroupID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
// expected-error@+1 {{attribute 'sv_groupid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain_GID(float ID : SV_GroupID) {
}

[numthreads(8,8,1)]
// expected-error@+1 {{attribute 'SV_GroupID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
// expected-error@+1 {{attribute 'sv_groupid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain2_GID(ST GID : SV_GroupID) {

}

void foo_GID() {
// expected-warning@+1 {{'SV_GroupID' attribute only applies to parameters and non-static data members}}
// expected-warning@+1 {{'sv_groupid' attribute only applies to parameters and non-static data members}}
uint GIS : SV_GroupID;
}

struct ST2_GID {
// expected-warning@+1 {{'SV_GroupID' attribute only applies to parameters and non-static data members}}
// expected-warning@+1 {{'sv_groupid' attribute only applies to parameters and non-static data members}}
static uint GID : SV_GroupID;
uint s_gid : SV_GroupID;
};

[numthreads(8,8,1)]
// expected-error@+1 {{attribute 'SV_GroupThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
// expected-error@+1 {{attribute 'sv_groupthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain_GThreadID(float ID : SV_GroupThreadID) {
}

[numthreads(8,8,1)]
// expected-error@+1 {{attribute 'SV_GroupThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
// expected-error@+1 {{attribute 'sv_groupthreadid' only applies to a field or parameter of type 'uint/uint2/uint3'}}
void CSMain2_GThreadID(ST GID : SV_GroupThreadID) {

}

void foo_GThreadID() {
// expected-warning@+1 {{'SV_GroupThreadID' attribute only applies to parameters and non-static data members}}
// expected-warning@+1 {{'sv_groupthreadid' attribute only applies to parameters and non-static data members}}
uint GThreadIS : SV_GroupThreadID;
}

struct ST2_GThreadID {
// expected-warning@+1 {{'SV_GroupThreadID' attribute only applies to parameters and non-static data members}}
// expected-warning@+1 {{'sv_groupthreadid' attribute only applies to parameters and non-static data members}}
static uint GThreadID : SV_GroupThreadID;
uint s_gthreadid : SV_GroupThreadID;
};


[shader("vertex")]
// expected-error@+4 {{attribute 'SV_GroupIndex' is unsupported in 'vertex' shaders, requires compute}}
// expected-error@+3 {{attribute 'SV_DispatchThreadID' is unsupported in 'vertex' shaders, requires compute}}
// expected-error@+2 {{attribute 'SV_GroupID' is unsupported in 'vertex' shaders, requires compute}}
// expected-error@+1 {{attribute 'SV_GroupThreadID' is unsupported in 'vertex' shaders, requires compute}}
// expected-error@+4 {{attribute 'sv_groupindex' is unsupported in 'vertex' shaders, requires compute}}
// expected-error@+3 {{attribute 'sv_dispatchthreadid' is unsupported in 'vertex' shaders, requires compute}}
// expected-error@+2 {{attribute 'sv_groupid' is unsupported in 'vertex' shaders, requires compute}}
// expected-error@+1 {{attribute 'sv_groupthreadid' is unsupported in 'vertex' shaders, requires compute}}
void vs_main(int GI : SV_GroupIndex, uint ID : SV_DispatchThreadID, uint GID : SV_GroupID, uint GThreadID : SV_GroupThreadID) {}
18 changes: 18 additions & 0 deletions clang/test/SemaHLSL/Semantics/valid_entry_parameter.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ void CSMain3(uint3 : SV_DispatchThreadID) {
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:20 'uint3'
// CHECK-NEXT: HLSLSV_DispatchThreadIDAttr
}
[numthreads(8,8,1)]
void CSMain4(uint3 : SV_DispatchThreadId) {
// CHECK: FunctionDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> line:[[@LINE-1]]:6 CSMain4 'void (uint3)'
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:20 'uint3'
// CHECK-NEXT: HLSLSV_DispatchThreadIDAttr
}

[numthreads(8,8,1)]
void CSMain_GID(uint ID : SV_GroupID) {
Expand All @@ -49,6 +55,12 @@ void CSMain3_GID(uint3 : SV_GroupID) {
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:24 'uint3'
// CHECK-NEXT: HLSLSV_GroupIDAttr
}
[numthreads(8,8,1)]
void CSMain4_GID(uint3 : Sv_GroupId) {
// CHECK: FunctionDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> line:[[@LINE-1]]:6 CSMain4_GID 'void (uint3)'
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:24 'uint3'
// CHECK-NEXT: HLSLSV_GroupIDAttr
}

[numthreads(8,8,1)]
void CSMain_GThreadID(uint ID : SV_GroupThreadID) {
Expand All @@ -74,3 +86,9 @@ void CSMain3_GThreadID(uint3 : SV_GroupThreadID) {
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:30 'uint3'
// CHECK-NEXT: HLSLSV_GroupThreadIDAttr
}
[numthreads(8,8,1)]
void CSMain4_GThreadID(uint3 : sv_GroupThreadid) {
// CHECK: FunctionDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> line:[[@LINE-1]]:6 CSMain4_GThreadID 'void (uint3)'
// CHECK-NEXT: ParmVarDecl 0x{{[0-9a-fA-F]+}} <{{.*}}> col:30 'uint3'
// CHECK-NEXT: HLSLSV_GroupThreadIDAttr
}
Loading