mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-14 08:40:30 +01:00
glsl/opt_minmax: Add support for float16
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
This commit is contained in:
parent
e3cc81e86c
commit
83e20139db
1 changed files with 19 additions and 0 deletions
|
|
@ -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]))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue