summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-12-11 13:49:28 -0800
committerEric Anholt <[email protected]>2018-12-13 12:24:26 -0800
commit4407e688cdf65b1a25f09bcfdb577d5c175aeb9a (patch)
tree7979fc31f121d8eccfec099e5a4122ad52b3dfee /src/compiler/nir
parent3a417a044e9ce3ab2ee6f1647e9be24cf9d310f5 (diff)
nir: Move intel's half-float image store lowering to to nir_format.h.
I needed the same function for v3d. This was originally in d3e046e76c06 ("nir: Pull some of intel's image load/store format conversion to nir_format.h") before we made am istake about simplifying the function. Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir_format_convert.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_format_convert.h b/src/compiler/nir/nir_format_convert.h
index 7ebb7d50ca4..9c8d0d21e0a 100644
--- a/src/compiler/nir/nir_format_convert.h
+++ b/src/compiler/nir/nir_format_convert.h
@@ -256,6 +256,19 @@ nir_format_float_to_snorm(nir_builder *b, nir_ssa_def *f, const unsigned *bits)
return nir_f2i32(b, nir_fround_even(b, nir_fmul(b, f, factor)));
}
+/* Converts a vector of floats to a vector of half-floats packed in the low 16
+ * bits.
+ */
+static inline nir_ssa_def *
+nir_format_float_to_half(nir_builder *b, nir_ssa_def *f)
+{
+ nir_ssa_def *zero = nir_imm_float(b, 0);
+ nir_ssa_def *f16comps[4];
+ for (unsigned i = 0; i < f->num_components; i++)
+ f16comps[i] = nir_pack_half_2x16_split(b, nir_channel(b, f, i), zero);
+ return nir_vec(b, f16comps, f->num_components);
+}
+
static inline nir_ssa_def *
nir_format_linear_to_srgb(nir_builder *b, nir_ssa_def *c)
{