Skip to content

Commit 79d817f

Browse files
committed
add parsing for maxAnisotropy
1 parent d6148b7 commit 79d817f

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class RootSignatureParser {
112112
struct ParsedStaticSamplerParams {
113113
std::optional<llvm::hlsl::rootsig::Register> Reg;
114114
std::optional<float> MipLODBias;
115+
std::optional<uint32_t> MaxAnisotropy;
115116
};
116117
std::optional<ParsedStaticSamplerParams> parseStaticSamplerParams();
117118

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ std::optional<StaticSampler> RootSignatureParser::parseStaticSampler() {
384384
if (Params->MipLODBias.has_value())
385385
Sampler.MipLODBias = Params->MipLODBias.value();
386386

387+
if (Params->MaxAnisotropy.has_value())
388+
Sampler.MaxAnisotropy= Params->MaxAnisotropy.value();
389+
387390
if (consumeExpectedToken(TokenKind::pu_r_paren,
388391
diag::err_hlsl_unexpected_end_of_params,
389392
/*param of=*/TokenKind::kw_StaticSampler))
@@ -686,6 +689,23 @@ RootSignatureParser::parseStaticSamplerParams() {
686689
return std::nullopt;
687690
Params.MipLODBias = (float)*MipLODBias;
688691
}
692+
693+
// `maxAnisotropy` `=` POS_INT
694+
if (tryConsumeExpectedToken(TokenKind::kw_maxAnisotropy)) {
695+
if (Params.MaxAnisotropy.has_value()) {
696+
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
697+
<< CurToken.TokKind;
698+
return std::nullopt;
699+
}
700+
701+
if (consumeExpectedToken(TokenKind::pu_equal))
702+
return std::nullopt;
703+
704+
auto MaxAnisotropy = parseUIntParam();
705+
if (!MaxAnisotropy.has_value())
706+
return std::nullopt;
707+
Params.MaxAnisotropy = MaxAnisotropy;
708+
}
689709
} while (tryConsumeExpectedToken(TokenKind::pu_comma));
690710

691711
return Params;

llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ struct DescriptorTableClause {
161161
struct StaticSampler {
162162
Register Reg;
163163
float MipLODBias = 0.f;
164+
uint32_t MaxAnisotropy = 16;
164165
};
165166

166167
/// Models RootElement : RootFlags | RootConstants | RootParam

0 commit comments

Comments
 (0)