summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-05-23 05:03:27 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:36 +0200
commitac7b0ebcb77f6c99d054e9d10412e669eefa0de6 (patch)
tree322952f22d0c1cac6c4ae6423e73aeb124403498 /src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp
parentglsl: FP function fixes (diff)
downloadyuzu-ac7b0ebcb77f6c99d054e9d10412e669eefa0de6.tar
yuzu-ac7b0ebcb77f6c99d054e9d10412e669eefa0de6.tar.gz
yuzu-ac7b0ebcb77f6c99d054e9d10412e669eefa0de6.tar.bz2
yuzu-ac7b0ebcb77f6c99d054e9d10412e669eefa0de6.tar.lz
yuzu-ac7b0ebcb77f6c99d054e9d10412e669eefa0de6.tar.xz
yuzu-ac7b0ebcb77f6c99d054e9d10412e669eefa0de6.tar.zst
yuzu-ac7b0ebcb77f6c99d054e9d10412e669eefa0de6.zip
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp
index 2aa9f2cd3..19a3c236d 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp
@@ -161,12 +161,12 @@ void EmitFPSaturate16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::In
void EmitFPSaturate32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value) {
- ctx.AddF32("{}=clamp({},0.0,1.0);", inst, value);
+ ctx.AddF32("{}=min(max({},0.0),1.0);", inst, value);
}
void EmitFPSaturate64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value) {
- ctx.AddF64("{}=clamp({},0.0,1.0);", inst, value);
+ ctx.AddF64("{}=min(max({},0.0),1.0);", inst, value);
}
void EmitFPClamp16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
@@ -180,14 +180,16 @@ void EmitFPClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst&
[[maybe_unused]] std::string_view value,
[[maybe_unused]] std::string_view min_value,
[[maybe_unused]] std::string_view max_value) {
- ctx.AddF32("{}=clamp({},float({}),float({}));", inst, value, min_value, max_value);
+ // GLSL's clamp does not produce desirable results
+ ctx.AddF32("{}=min(max({},float({})),float({}));", inst, value, min_value, max_value);
}
void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
[[maybe_unused]] std::string_view value,
[[maybe_unused]] std::string_view min_value,
[[maybe_unused]] std::string_view max_value) {
- ctx.AddF64("{}=clamp({},double({}),double({}));", inst, value, min_value, max_value);
+ // GLSL's clamp does not produce desirable results
+ ctx.AddF64("{}=min(max({},double({})),double({}));", inst, value, min_value, max_value);
}
void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,