diff options
author | Neil Roberts <[email protected]> | 2019-06-07 08:52:14 +0200 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-09 16:31:08 +0000 |
commit | 83e20139db7e55c40a7658a0bdcb115e790bd138 (patch) | |
tree | f3fe1c9c14737f1eb04fef2f250caa00109f8abf /src/compiler/glsl/opt_minmax.cpp | |
parent | e3cc81e86cc71259626a52b057d67c4a77c19839 (diff) |
glsl/opt_minmax: Add support for float16
Reviewed-by: Marek Olšák <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
Diffstat (limited to 'src/compiler/glsl/opt_minmax.cpp')
-rw-r--r-- | src/compiler/glsl/opt_minmax.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/compiler/glsl/opt_minmax.cpp b/src/compiler/glsl/opt_minmax.cpp index 9f64db9c07e..36fe0a9f05b 100644 --- a/src/compiler/glsl/opt_minmax.cpp +++ b/src/compiler/glsl/opt_minmax.cpp @@ -38,6 +38,7 @@ #include "program/prog_instruction.h" #include "compiler/glsl_types.h" #include "main/macros.h" +#include "util/half_float.h" using namespace ir_builder; @@ -125,6 +126,17 @@ compare_components(ir_constant *a, ir_constant *b) else foundequal = true; break; + case GLSL_TYPE_FLOAT16: { + float af = _mesa_half_to_float(a->value.f16[c0]); + float bf = _mesa_half_to_float(b->value.f16[c1]); + if (af < bf) + foundless = true; + else if (af > bf) + foundgreater = true; + else + foundequal = true; + break; + } case GLSL_TYPE_FLOAT: if (a->value.f[c0] < b->value.f[c1]) foundless = true; @@ -181,6 +193,13 @@ combine_constant(bool ismin, ir_constant *a, ir_constant *b) (!ismin && b->value.i[i] > c->value.i[i])) c->value.i[i] = b->value.i[i]; break; + case GLSL_TYPE_FLOAT16: { + float bf = _mesa_half_to_float(b->value.f16[i]); + float cf = _mesa_half_to_float(c->value.f16[i]); + if ((ismin && bf < cf) || (!ismin && bf > cf)) + c->value.f16[i] = b->value.f16[i]; + break; + } case GLSL_TYPE_FLOAT: if ((ismin && b->value.f[i] < c->value.f[i]) || (!ismin && b->value.f[i] > c->value.f[i])) |