summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_builder.h
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-10-22 14:08:44 -0500
committerJason Ekstrand <[email protected]>2018-10-26 11:45:29 -0500
commit6e32115bd673221420fbdf1500c60dcda402622d (patch)
treedefa3a90e0c956c5c5e7861806c5395f1687ad75 /src/compiler/nir/nir_builder.h
parentff45649bc2fc3b048a8ae19cd67ec1e8e8eeb7a8 (diff)
nir/builder: Handle 16-bit floats in nir_imm_floatN_t
Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_builder.h')
-rw-r--r--src/compiler/nir/nir_builder.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 5ea0a5a2637..3271a480520 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -25,6 +25,7 @@
#define NIR_BUILDER_H
#include "nir_control_flow.h"
+#include "util/half_float.h"
struct exec_list;
@@ -229,6 +230,17 @@ nir_imm_false(nir_builder *build)
}
static inline nir_ssa_def *
+nir_imm_float16(nir_builder *build, float x)
+{
+ nir_const_value v;
+
+ memset(&v, 0, sizeof(v));
+ v.u16[0] = _mesa_float_to_half(x);
+
+ return nir_build_imm(build, 1, 16, v);
+}
+
+static inline nir_ssa_def *
nir_imm_float(nir_builder *build, float x)
{
nir_const_value v;
@@ -254,6 +266,8 @@ static inline nir_ssa_def *
nir_imm_floatN_t(nir_builder *build, double x, unsigned bit_size)
{
switch (bit_size) {
+ case 16:
+ return nir_imm_float16(build, x);
case 32:
return nir_imm_float(build, x);
case 64: