Skip to content

Commit

Permalink
add extra default visibility testcase
Browse files Browse the repository at this point in the history
- also catches a small error for no clauses edge case
  • Loading branch information
inbelic committed Jan 14, 2025
1 parent d5b19cb commit ab390a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clang/lib/Parse/ParseHLSLRootSignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool RootSignatureParser::ParseDescriptorTable() {
HasComma = !TryConsumeExpectedToken(TokenKind::pu_comma);
}

if (HasComma)
if (HasComma && Table.NumClauses != 0)
return ReportError(); // report 'comma' denotes a required extra item

if (ConsumeExpectedToken(TokenKind::pu_r_paren))
Expand Down
11 changes: 9 additions & 2 deletions clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ TEST_F(ParseHLSLRootSignatureTest, ParseValidDTClausesTest) {
| Descriptors_Static_Keeping_Buffer_Bounds_Checks
),
visibility = Shader_Visibility_Pixel
)
),
DescriptorTable()
)cc";

TrivialModuleLoader ModLoader;
Expand All @@ -155,7 +156,7 @@ TEST_F(ParseHLSLRootSignatureTest, ParseValidDTClausesTest) {
RootSignatureParser Parser(Elements, Tokens);

ASSERT_FALSE(Parser.Parse());
ASSERT_EQ((int)Elements.size(), 5);
ASSERT_EQ((int)Elements.size(), 6);

// Test default values are set correctly
RootElement Elem = Elements[0];
Expand Down Expand Up @@ -209,6 +210,12 @@ TEST_F(ParseHLSLRootSignatureTest, ParseValidDTClausesTest) {
ASSERT_EQ(Elem.Table.NumClauses, (uint32_t)4);
ASSERT_EQ(Elem.Table.Visibility, ShaderVisibility::Pixel);

// Test generated DescriptorTable start has correct default values
Elem = Elements[5];
ASSERT_EQ(Elem.Tag, RootElement::ElementType::DescriptorTable);
ASSERT_EQ(Elem.Table.NumClauses, (uint32_t)0);
ASSERT_EQ(Elem.Table.Visibility, ShaderVisibility::All);

delete PP;
}

Expand Down

0 comments on commit ab390a2

Please sign in to comment.