[llvm-branch-commits] [clang] [llvm] [HLSL][RootSignature] Add parsing of floats for StaticSampler (PR #140181)
Justin Bogner via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue May 27 10:02:38 PDT 2025
================
@@ -711,6 +734,35 @@ std::optional<Register> RootSignatureParser::parseRegister() {
return Reg;
}
+std::optional<float> RootSignatureParser::parseFloatParam() {
+ assert(CurToken.TokKind == TokenKind::pu_equal &&
+ "Expects to only be invoked starting at given keyword");
+ // Consume sign modifier
+ bool Signed =
+ tryConsumeExpectedToken({TokenKind::pu_plus, TokenKind::pu_minus});
+ bool Negated = Signed && CurToken.TokKind == TokenKind::pu_minus;
+
+ // DXC will treat a postive signed integer as unsigned
+ if (!Negated && tryConsumeExpectedToken(TokenKind::int_literal)) {
+ auto UInt = handleUIntLiteral();
+ if (!UInt.has_value())
+ return std::nullopt;
+ return (float)UInt.value();
----------------
bogner wrote:
Better to use a function-style cast (that is, `float(UInt.value())`) rather than a C-style cast here (and later in this function). In general it's better to use C++'s casts over C-style casts, as they're a lot more specific about what types of conversion are expected.
https://github.com/llvm/llvm-project/pull/140181
More information about the llvm-branch-commits
mailing list