These conversions handle half-floats within the shader.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
break;
}
+ case nir_op_f2f16: {
+ assert(src_bitsize == 32);
+
+ op = midgard_alu_op_fmov;
+ dest_override = midgard_dest_override_lower;
+ break;
+ }
+
+ case nir_op_f2f32: {
+ assert(src_bitsize == 16);
+
+ op = midgard_alu_op_fmov;
+ half_2 = true;
+ reg_mode++;
+ break;
+ }
+
+
/* For greater-or-equal, we lower to less-or-equal and flip the
* arguments */
(('u2u8', 'a@32'), ('u2u8', ('u2u16', a))),
(('i2i32', 'a@8'), ('i2i32', ('i2i16', a))),
- (('u2u32', 'a@8'), ('u2u32', ('u2u16', a)))
+ (('u2u32', 'a@8'), ('u2u32', ('u2u16', a))),
+
+ (('f2i32', 'a@16'), ('f2i32', ('f2f32', a))),
+ (('f2u32', 'a@16'), ('f2u32', ('f2f32', a))),
]
# Midgard scales fsin/fcos arguments by pi.
static nir_ssa_def *
nir_float_to_native(nir_builder *b, nir_ssa_def *c_float)
{
- /* First, we scale from [0, 1] to [0, 255.0] */
- nir_ssa_def *scaled = nir_fmul_imm(b, nir_fsat(b, c_float), 255.0);
+ /* First, we degrade quality to fp16; we don't need the extra bits */
+ nir_ssa_def *degraded = nir_f2f16(b, c_float);
+
+ /* Scale from [0, 1] to [0, 255.0] */
+ nir_ssa_def *scaled = nir_fmul_imm(b, nir_fsat(b, degraded), 255.0);
/* Next, we type convert */
nir_ssa_def *converted = nir_u2u8(b, nir_f2u32(b,