summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/reg_alloc.cpp
diff options
context:
space:
mode:
authorGravatar ameerj2021-05-29 18:08:19 -0400
committerGravatar ameerj2021-07-22 21:51:36 -0400
commit3047eb66889a9782fadfbe479c33e6a8bfc5bf53 (patch)
tree9491643b07576e354844b39d5dffb321491aadf9 /src/shader_recompiler/backend/glsl/reg_alloc.cpp
parentglsl: TLD4 implementation (diff)
downloadyuzu-3047eb66889a9782fadfbe479c33e6a8bfc5bf53.tar.gz
yuzu-3047eb66889a9782fadfbe479c33e6a8bfc5bf53.tar.xz
yuzu-3047eb66889a9782fadfbe479c33e6a8bfc5bf53.zip
glsl: Implement TXQ and other misc changes
Diffstat (limited to 'src/shader_recompiler/backend/glsl/reg_alloc.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/reg_alloc.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/shader_recompiler/backend/glsl/reg_alloc.cpp b/src/shader_recompiler/backend/glsl/reg_alloc.cpp
index ecb550095..b1de022d4 100644
--- a/src/shader_recompiler/backend/glsl/reg_alloc.cpp
+++ b/src/shader_recompiler/backend/glsl/reg_alloc.cpp
@@ -37,9 +37,14 @@ std::string FormatFloat(std::string_view value, IR::Type type) {
37 return "uintBitsToFloat(0xff800000)"; 37 return "uintBitsToFloat(0xff800000)";
38 } 38 }
39 } 39 }
40 const bool needs_dot = value.find_first_of('.') == std::string_view::npos; 40 if (value.find_first_of('e') != std::string_view::npos) {
41 const bool needs_suffix = !value.ends_with('f'); 41 // scientific notation
42 const auto suffix = type == IR::Type::F32 ? "f" : "lf"; 42 const auto cast{type == IR::Type::F32 ? "float" : "double"};
43 return fmt::format("{}({})", cast, value);
44 }
45 const bool needs_dot{value.find_first_of('.') == std::string_view::npos};
46 const bool needs_suffix{!value.ends_with('f')};
47 const auto suffix{type == IR::Type::F32 ? "f" : "lf"};
43 return fmt::format("{}{}{}", value, needs_dot ? "." : "", needs_suffix ? suffix : ""); 48 return fmt::format("{}{}{}", value, needs_dot ? "." : "", needs_suffix ? suffix : "");
44} 49}
45 50