return _mesa_float_to_half(x);
}
+/**
+ * Evaluate one component of unpackHalf2x16.
+ */
+static float
+unpack_half_1x16_flush_to_zero(uint16_t u)
+{
+ if (0 == (u & 0x7c00))
+ u &= 0x8000;
+ return _mesa_half_to_float(u);
+}
+
/**
* Evaluate one component of unpackHalf2x16.
*/
*/
return NULL;
+ case nir_op_unpack_half_2x16_flush_to_zero:
case nir_op_unpack_half_2x16: {
if (!b->shader->options->lower_unpack_half_2x16)
return NULL;
nir_ssa_def *packed = nir_ssa_for_alu_src(b, alu, 0);
- return nir_vec2(b, nir_unpack_half_2x16_split_x(b, packed),
- nir_unpack_half_2x16_split_y(b, packed));
+ if (alu->op == nir_op_unpack_half_2x16_flush_to_zero) {
+ return nir_vec2(b,
+ nir_unpack_half_2x16_split_x_flush_to_zero(b,
+ packed),
+ nir_unpack_half_2x16_split_y_flush_to_zero(b,
+ packed));
+ } else {
+ return nir_vec2(b,
+ nir_unpack_half_2x16_split_x(b, packed),
+ nir_unpack_half_2x16_split_y(b, packed));
+ }
}
case nir_op_pack_uvec2_to_uint: {
unop_horiz("unpack_32_2x16", 2, tuint16, 1, tuint32,
"dst.x = src0.x; dst.y = src0.x >> 16;")
-# Lowered floating point unpacking operations.
+unop_horiz("unpack_half_2x16_flush_to_zero", 2, tfloat32, 1, tuint32, """
+dst.x = unpack_half_1x16_flush_to_zero((uint16_t)(src0.x & 0xffff));
+dst.y = unpack_half_1x16_flush_to_zero((uint16_t)(src0.x << 16));
+""")
+# Lowered floating point unpacking operations.
unop_convert("unpack_half_2x16_split_x", tfloat32, tuint32,
"unpack_half_1x16((uint16_t)(src0 & 0xffff))")
unop_convert("unpack_half_2x16_split_y", tfloat32, tuint32,
"unpack_half_1x16((uint16_t)(src0 >> 16))")
+unop_convert("unpack_half_2x16_split_x_flush_to_zero", tfloat32, tuint32,
+ "unpack_half_1x16_flush_to_zero((uint16_t)(src0 & 0xffff))")
+unop_convert("unpack_half_2x16_split_y_flush_to_zero", tfloat32, tuint32,
+ "unpack_half_1x16_flush_to_zero((uint16_t)(src0 >> 16))")
+
unop_convert("unpack_32_2x16_split_x", tuint16, tuint32, "src0")
unop_convert("unpack_32_2x16_split_y", tuint16, tuint32, "src0 >> 16")
static nir_op
vtn_nir_alu_op_for_spirv_glsl_opcode(struct vtn_builder *b,
- enum GLSLstd450 opcode)
+ enum GLSLstd450 opcode,
+ unsigned execution_mode)
{
switch (opcode) {
case GLSLstd450Round: return nir_op_fround_even;
case GLSLstd450UnpackUnorm4x8: return nir_op_unpack_unorm_4x8;
case GLSLstd450UnpackSnorm2x16: return nir_op_unpack_snorm_2x16;
case GLSLstd450UnpackUnorm2x16: return nir_op_unpack_unorm_2x16;
- case GLSLstd450UnpackHalf2x16: return nir_op_unpack_half_2x16;
+ case GLSLstd450UnpackHalf2x16:
+ if (execution_mode & FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP16)
+ return nir_op_unpack_half_2x16_flush_to_zero;
+ else
+ return nir_op_unpack_half_2x16;
case GLSLstd450UnpackDouble2x32: return nir_op_unpack_64_2x32;
default:
return;
}
- default:
+ default: {
+ unsigned execution_mode =
+ b->shader->info.float_controls_execution_mode;
val->ssa->def =
nir_build_alu(&b->nb,
- vtn_nir_alu_op_for_spirv_glsl_opcode(b, entrypoint),
+ vtn_nir_alu_op_for_spirv_glsl_opcode(b, entrypoint, execution_mode),
src[0], src[1], src[2], NULL);
return;
}
+ }
}
static void