glsl: Add support for float16 types in the IR tree
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> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "main/macros.h"
|
||||
#include "util/hash_table.h"
|
||||
#include "util/u_string.h"
|
||||
#include "util/half_float.h"
|
||||
|
||||
static void print_type(FILE *f, const glsl_type *t);
|
||||
|
||||
@@ -460,6 +461,19 @@ void ir_print_visitor::visit(ir_assignment *ir)
|
||||
fprintf(f, ") ");
|
||||
}
|
||||
|
||||
static void
|
||||
print_float_constant(FILE *f, float val)
|
||||
{
|
||||
if (val == 0.0f)
|
||||
/* 0.0 == -0.0, so print with %f to get the proper sign. */
|
||||
fprintf(f, "%f", val);
|
||||
else if (fabs(val) < 0.000001f)
|
||||
fprintf(f, "%a", val);
|
||||
else if (fabs(val) > 1000000.0f)
|
||||
fprintf(f, "%e", val);
|
||||
else
|
||||
fprintf(f, "%f", val);
|
||||
}
|
||||
|
||||
void ir_print_visitor::visit(ir_constant *ir)
|
||||
{
|
||||
@@ -484,15 +498,10 @@ void ir_print_visitor::visit(ir_constant *ir)
|
||||
case GLSL_TYPE_UINT: fprintf(f, "%u", ir->value.u[i]); break;
|
||||
case GLSL_TYPE_INT: fprintf(f, "%d", ir->value.i[i]); break;
|
||||
case GLSL_TYPE_FLOAT:
|
||||
if (ir->value.f[i] == 0.0f)
|
||||
/* 0.0 == -0.0, so print with %f to get the proper sign. */
|
||||
fprintf(f, "%f", ir->value.f[i]);
|
||||
else if (fabs(ir->value.f[i]) < 0.000001f)
|
||||
fprintf(f, "%a", ir->value.f[i]);
|
||||
else if (fabs(ir->value.f[i]) > 1000000.0f)
|
||||
fprintf(f, "%e", ir->value.f[i]);
|
||||
else
|
||||
fprintf(f, "%f", ir->value.f[i]);
|
||||
print_float_constant(f, ir->value.f[i]);
|
||||
break;
|
||||
case GLSL_TYPE_FLOAT16:
|
||||
print_float_constant(f, _mesa_half_to_float(ir->value.f16[i]));
|
||||
break;
|
||||
case GLSL_TYPE_SAMPLER:
|
||||
case GLSL_TYPE_IMAGE:
|
||||
|
Reference in New Issue
Block a user