Skip to content

Commit 1b337ea

Browse files
committed
add parsing for maxLOD
1 parent 4ed8cdd commit 1b337ea

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
@@ -114,6 +114,7 @@ class RootSignatureParser {
114114
std::optional<float> MipLODBias;
115115
std::optional<uint32_t> MaxAnisotropy;
116116
std::optional<float> MinLOD;
117+
std::optional<float> MaxLOD;
117118
};
118119
std::optional<ParsedStaticSamplerParams> parseStaticSamplerParams();
119120

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ std::optional<StaticSampler> RootSignatureParser::parseStaticSampler() {
390390
if (Params->MinLOD.has_value())
391391
Sampler.MinLOD= Params->MinLOD.value();
392392

393+
if (Params->MaxLOD.has_value())
394+
Sampler.MaxLOD= Params->MaxLOD.value();
395+
393396
if (consumeExpectedToken(TokenKind::pu_r_paren,
394397
diag::err_hlsl_unexpected_end_of_params,
395398
/*param of=*/TokenKind::kw_StaticSampler))
@@ -726,6 +729,23 @@ RootSignatureParser::parseStaticSamplerParams() {
726729
return std::nullopt;
727730
Params.MinLOD = MinLOD;
728731
}
732+
733+
// `maxLOD` `=` NUMBER
734+
if (tryConsumeExpectedToken(TokenKind::kw_maxLOD)) {
735+
if (Params.MaxLOD.has_value()) {
736+
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
737+
<< CurToken.TokKind;
738+
return std::nullopt;
739+
}
740+
741+
if (consumeExpectedToken(TokenKind::pu_equal))
742+
return std::nullopt;
743+
744+
auto MaxLOD= parseFloatParam();
745+
if (!MaxLOD.has_value())
746+
return std::nullopt;
747+
Params.MaxLOD = MaxLOD;
748+
}
729749
} while (tryConsumeExpectedToken(TokenKind::pu_comma));
730750

731751
return Params;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ struct StaticSampler {
163163
float MipLODBias = 0.f;
164164
uint32_t MaxAnisotropy = 16;
165165
float MinLOD = 0.f;
166+
float MaxLOD = 3.402823466e+38f;
166167
};
167168

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

0 commit comments

Comments
 (0)