Skip to content

Commit caa9a93

Browse files
committed
add parsing for maxAnisotropy
1 parent 4002195 commit caa9a93

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
@@ -380,6 +380,9 @@ std::optional<StaticSampler> RootSignatureParser::parseStaticSampler() {
380380
if (Params->MipLODBias.has_value())
381381
Sampler.MipLODBias = Params->MipLODBias.value();
382382

383+
if (Params->MaxAnisotropy.has_value())
384+
Sampler.MaxAnisotropy= Params->MaxAnisotropy.value();
385+
383386
if (consumeExpectedToken(TokenKind::pu_r_paren,
384387
diag::err_hlsl_unexpected_end_of_params,
385388
/*param of=*/TokenKind::kw_StaticSampler))
@@ -682,6 +685,23 @@ RootSignatureParser::parseStaticSamplerParams() {
682685
return std::nullopt;
683686
Params.MipLODBias = MipLODBias;
684687
}
688+
689+
// `maxAnisotropy` `=` POS_INT
690+
if (tryConsumeExpectedToken(TokenKind::kw_maxAnisotropy)) {
691+
if (Params.MaxAnisotropy.has_value()) {
692+
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
693+
<< CurToken.TokKind;
694+
return std::nullopt;
695+
}
696+
697+
if (consumeExpectedToken(TokenKind::pu_equal))
698+
return std::nullopt;
699+
700+
auto MaxAnisotropy = parseUIntParam();
701+
if (!MaxAnisotropy.has_value())
702+
return std::nullopt;
703+
Params.MaxAnisotropy = MaxAnisotropy;
704+
}
685705
} while (tryConsumeExpectedToken(TokenKind::pu_comma));
686706

687707
return Params;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ raw_ostream &operator<<(raw_ostream &OS, const DescriptorTableClause &Clause);
162162
struct StaticSampler {
163163
Register Reg;
164164
float MipLODBias = 0.f;
165+
uint32_t MaxAnisotropy = 16;
165166
};
166167

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

0 commit comments

Comments
 (0)