-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[HLSL][RootSignature] Add space, visibility enums to StaticSampler #140306
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
Open
inbelic
wants to merge
1
commit into
llvm:users/inbelic/pr-140305
Choose a base branch
from
inbelic:inbelic/rs-final-sampler
base: users/inbelic/pr-140305
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[HLSL][RootSignature] Add space, visibility enums to StaticSampler #140306
inbelic
wants to merge
1
commit into
llvm:users/inbelic/pr-140305
from
inbelic:inbelic/rs-final-sampler
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28c7adf
to
da75749
Compare
@llvm/pr-subscribers-clang Author: Finn Plummer (inbelic) Changes
Part 7 and Resolves #126574 Full diff: https://github.com/llvm/llvm-project/pull/140306.diff 4 Files Affected:
diff --git a/clang/include/clang/Parse/ParseHLSLRootSignature.h b/clang/include/clang/Parse/ParseHLSLRootSignature.h
index 21df9d0da4a53..34d59d7fb66f4 100644
--- a/clang/include/clang/Parse/ParseHLSLRootSignature.h
+++ b/clang/include/clang/Parse/ParseHLSLRootSignature.h
@@ -121,6 +121,8 @@ class RootSignatureParser {
std::optional<llvm::hlsl::rootsig::StaticBorderColor> BorderColor;
std::optional<float> MinLOD;
std::optional<float> MaxLOD;
+ std::optional<uint32_t> Space;
+ std::optional<llvm::hlsl::rootsig::ShaderVisibility> Visibility;
};
std::optional<ParsedStaticSamplerParams> parseStaticSamplerParams();
diff --git a/clang/lib/Parse/ParseHLSLRootSignature.cpp b/clang/lib/Parse/ParseHLSLRootSignature.cpp
index 07bd10d00dfad..bd0f9abb5ff1b 100644
--- a/clang/lib/Parse/ParseHLSLRootSignature.cpp
+++ b/clang/lib/Parse/ParseHLSLRootSignature.cpp
@@ -411,6 +411,12 @@ std::optional<StaticSampler> RootSignatureParser::parseStaticSampler() {
if (Params->MaxLOD.has_value())
Sampler.MaxLOD = Params->MaxLOD.value();
+ if (Params->Space.has_value())
+ Sampler.Space = Params->Space.value();
+
+ if (Params->Visibility.has_value())
+ Sampler.Visibility = Params->Visibility.value();
+
if (consumeExpectedToken(TokenKind::pu_r_paren,
diag::err_hlsl_unexpected_end_of_params,
/*param of=*/TokenKind::kw_StaticSampler))
@@ -866,6 +872,40 @@ RootSignatureParser::parseStaticSamplerParams() {
return std::nullopt;
Params.MaxLOD = MaxLOD;
}
+
+ // `space` `=` POS_INT
+ if (tryConsumeExpectedToken(TokenKind::kw_space)) {
+ if (Params.Space.has_value()) {
+ getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
+ << CurToken.TokKind;
+ return std::nullopt;
+ }
+
+ if (consumeExpectedToken(TokenKind::pu_equal))
+ return std::nullopt;
+
+ auto Space = parseUIntParam();
+ if (!Space.has_value())
+ return std::nullopt;
+ Params.Space = Space;
+ }
+
+ // `visibility` `=` SHADER_VISIBILITY
+ if (tryConsumeExpectedToken(TokenKind::kw_visibility)) {
+ if (Params.Visibility.has_value()) {
+ getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
+ << CurToken.TokKind;
+ return std::nullopt;
+ }
+
+ if (consumeExpectedToken(TokenKind::pu_equal))
+ return std::nullopt;
+
+ auto Visibility = parseShaderVisibility();
+ if (!Visibility.has_value())
+ return std::nullopt;
+ Params.Visibility = Visibility;
+ }
} while (tryConsumeExpectedToken(TokenKind::pu_comma));
return Params;
diff --git a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
index 6343d9feb4411..3eede0dbed61b 100644
--- a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
+++ b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
@@ -226,7 +226,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
const llvm::StringLiteral Source = R"cc(
StaticSampler(s0),
- StaticSampler(s0, maxAnisotropy = 3,
+ StaticSampler(s0, maxAnisotropy = 3, space = 4,
+ visibility = SHADER_VISIBILITY_DOMAIN,
minLOD = 4.2f, mipLODBias = 0.23e+3,
addressW = TEXTURE_ADDRESS_CLAMP,
addressV = TEXTURE_ADDRESS_BORDER,
@@ -269,6 +270,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
StaticBorderColor::OpaqueWhite);
ASSERT_EQ(std::get<StaticSampler>(Elem).MinLOD, 0.f);
ASSERT_EQ(std::get<StaticSampler>(Elem).MaxLOD, 3.402823466e+38f);
+ ASSERT_EQ(std::get<StaticSampler>(Elem).Space, 0u);
+ ASSERT_EQ(std::get<StaticSampler>(Elem).Visibility, ShaderVisibility::All);
// Check values can be set as expected
Elem = Elements[1];
@@ -288,6 +291,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
StaticBorderColor::OpaqueBlackUint);
ASSERT_EQ(std::get<StaticSampler>(Elem).MinLOD, 4.2f);
ASSERT_EQ(std::get<StaticSampler>(Elem).MaxLOD, 9000.f);
+ ASSERT_EQ(std::get<StaticSampler>(Elem).Space, 4u);
+ ASSERT_EQ(std::get<StaticSampler>(Elem).Visibility, ShaderVisibility::Domain);
ASSERT_TRUE(Consumer->isSatisfied());
}
diff --git a/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h b/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
index 025e96ec93c2a..ee65722e68556 100644
--- a/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
+++ b/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
@@ -236,6 +236,8 @@ struct StaticSampler {
StaticBorderColor BorderColor = StaticBorderColor::OpaqueWhite;
float MinLOD = 0.f;
float MaxLOD = 3.402823466e+38f; // FLT_MAX
+ uint32_t Space = 0;
+ ShaderVisibility Visibility = ShaderVisibility::All;
};
/// Models RootElement : RootFlags | RootConstants | RootParam
|
@llvm/pr-subscribers-hlsl Author: Finn Plummer (inbelic) Changes
Part 7 and Resolves #126574 Full diff: https://github.com/llvm/llvm-project/pull/140306.diff 4 Files Affected:
diff --git a/clang/include/clang/Parse/ParseHLSLRootSignature.h b/clang/include/clang/Parse/ParseHLSLRootSignature.h
index 21df9d0da4a53..34d59d7fb66f4 100644
--- a/clang/include/clang/Parse/ParseHLSLRootSignature.h
+++ b/clang/include/clang/Parse/ParseHLSLRootSignature.h
@@ -121,6 +121,8 @@ class RootSignatureParser {
std::optional<llvm::hlsl::rootsig::StaticBorderColor> BorderColor;
std::optional<float> MinLOD;
std::optional<float> MaxLOD;
+ std::optional<uint32_t> Space;
+ std::optional<llvm::hlsl::rootsig::ShaderVisibility> Visibility;
};
std::optional<ParsedStaticSamplerParams> parseStaticSamplerParams();
diff --git a/clang/lib/Parse/ParseHLSLRootSignature.cpp b/clang/lib/Parse/ParseHLSLRootSignature.cpp
index 07bd10d00dfad..bd0f9abb5ff1b 100644
--- a/clang/lib/Parse/ParseHLSLRootSignature.cpp
+++ b/clang/lib/Parse/ParseHLSLRootSignature.cpp
@@ -411,6 +411,12 @@ std::optional<StaticSampler> RootSignatureParser::parseStaticSampler() {
if (Params->MaxLOD.has_value())
Sampler.MaxLOD = Params->MaxLOD.value();
+ if (Params->Space.has_value())
+ Sampler.Space = Params->Space.value();
+
+ if (Params->Visibility.has_value())
+ Sampler.Visibility = Params->Visibility.value();
+
if (consumeExpectedToken(TokenKind::pu_r_paren,
diag::err_hlsl_unexpected_end_of_params,
/*param of=*/TokenKind::kw_StaticSampler))
@@ -866,6 +872,40 @@ RootSignatureParser::parseStaticSamplerParams() {
return std::nullopt;
Params.MaxLOD = MaxLOD;
}
+
+ // `space` `=` POS_INT
+ if (tryConsumeExpectedToken(TokenKind::kw_space)) {
+ if (Params.Space.has_value()) {
+ getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
+ << CurToken.TokKind;
+ return std::nullopt;
+ }
+
+ if (consumeExpectedToken(TokenKind::pu_equal))
+ return std::nullopt;
+
+ auto Space = parseUIntParam();
+ if (!Space.has_value())
+ return std::nullopt;
+ Params.Space = Space;
+ }
+
+ // `visibility` `=` SHADER_VISIBILITY
+ if (tryConsumeExpectedToken(TokenKind::kw_visibility)) {
+ if (Params.Visibility.has_value()) {
+ getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
+ << CurToken.TokKind;
+ return std::nullopt;
+ }
+
+ if (consumeExpectedToken(TokenKind::pu_equal))
+ return std::nullopt;
+
+ auto Visibility = parseShaderVisibility();
+ if (!Visibility.has_value())
+ return std::nullopt;
+ Params.Visibility = Visibility;
+ }
} while (tryConsumeExpectedToken(TokenKind::pu_comma));
return Params;
diff --git a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
index 6343d9feb4411..3eede0dbed61b 100644
--- a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
+++ b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
@@ -226,7 +226,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
const llvm::StringLiteral Source = R"cc(
StaticSampler(s0),
- StaticSampler(s0, maxAnisotropy = 3,
+ StaticSampler(s0, maxAnisotropy = 3, space = 4,
+ visibility = SHADER_VISIBILITY_DOMAIN,
minLOD = 4.2f, mipLODBias = 0.23e+3,
addressW = TEXTURE_ADDRESS_CLAMP,
addressV = TEXTURE_ADDRESS_BORDER,
@@ -269,6 +270,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
StaticBorderColor::OpaqueWhite);
ASSERT_EQ(std::get<StaticSampler>(Elem).MinLOD, 0.f);
ASSERT_EQ(std::get<StaticSampler>(Elem).MaxLOD, 3.402823466e+38f);
+ ASSERT_EQ(std::get<StaticSampler>(Elem).Space, 0u);
+ ASSERT_EQ(std::get<StaticSampler>(Elem).Visibility, ShaderVisibility::All);
// Check values can be set as expected
Elem = Elements[1];
@@ -288,6 +291,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
StaticBorderColor::OpaqueBlackUint);
ASSERT_EQ(std::get<StaticSampler>(Elem).MinLOD, 4.2f);
ASSERT_EQ(std::get<StaticSampler>(Elem).MaxLOD, 9000.f);
+ ASSERT_EQ(std::get<StaticSampler>(Elem).Space, 4u);
+ ASSERT_EQ(std::get<StaticSampler>(Elem).Visibility, ShaderVisibility::Domain);
ASSERT_TRUE(Consumer->isSatisfied());
}
diff --git a/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h b/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
index 025e96ec93c2a..ee65722e68556 100644
--- a/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
+++ b/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
@@ -236,6 +236,8 @@ struct StaticSampler {
StaticBorderColor BorderColor = StaticBorderColor::OpaqueWhite;
float MinLOD = 0.f;
float MaxLOD = 3.402823466e+38f; // FLT_MAX
+ uint32_t Space = 0;
+ ShaderVisibility Visibility = ShaderVisibility::All;
};
/// Models RootElement : RootFlags | RootConstants | RootParam
|
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
HLSL
HLSL Language Support
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
space
andvisibility
parameters to StaticSamplerPart 7 and Resolves #126574