mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-23 09:40:29 +01:00
spirv: support float8 conversions
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35434>
This commit is contained in:
parent
30ec9ed1cf
commit
e19ccb00f2
1 changed files with 37 additions and 0 deletions
|
|
@ -683,6 +683,7 @@ vtn_handle_convert(struct vtn_builder *b, SpvOp opcode,
|
|||
*
|
||||
* For now we are limiting exposure of bfloat16 in NIR, so apply the
|
||||
* extra conversions directly here.
|
||||
* The same applies to E4M3 and E5M2.
|
||||
*/
|
||||
if (glsl_type_is_bfloat_16(glsl_src_type)) {
|
||||
nir_def *src_as_float = nir_bf2f(&b->nb, src);
|
||||
|
|
@ -699,6 +700,42 @@ vtn_handle_convert(struct vtn_builder *b, SpvOp opcode,
|
|||
src_as_float = vtn_handle_convert(b, opcode, dest_val, glsl_float_type(),
|
||||
glsl_src_type, src);
|
||||
return nir_f2bf(&b->nb, src_as_float);
|
||||
} else if (glsl_type_is_e4m3fn(glsl_src_type)) {
|
||||
nir_def *src_as_float = nir_e4m3fn2f(&b->nb, src);
|
||||
if (glsl_type_is_float(glsl_dest_type))
|
||||
return src_as_float;
|
||||
return vtn_handle_convert(b, opcode, dest_val, glsl_dest_type,
|
||||
glsl_float_type(), src_as_float);
|
||||
|
||||
} else if (glsl_type_is_e4m3fn(glsl_dest_type)) {
|
||||
nir_def *src_as_float;
|
||||
if (glsl_type_is_float(glsl_src_type))
|
||||
src_as_float = src;
|
||||
else
|
||||
src_as_float = vtn_handle_convert(b, opcode, dest_val, glsl_float_type(),
|
||||
glsl_src_type, src);
|
||||
if (vtn_has_decoration(b, dest_val, SpvDecorationSaturatedToLargestFloat8NormalConversionEXT))
|
||||
return nir_f2e4m3fn_sat(&b->nb, src_as_float);
|
||||
else
|
||||
return nir_f2e4m3fn(&b->nb, src_as_float);
|
||||
} else if (glsl_type_is_e5m2(glsl_src_type)) {
|
||||
nir_def *src_as_float = nir_e5m22f(&b->nb, src);
|
||||
if (glsl_type_is_float(glsl_dest_type))
|
||||
return src_as_float;
|
||||
return vtn_handle_convert(b, opcode, dest_val, glsl_dest_type,
|
||||
glsl_float_type(), src_as_float);
|
||||
|
||||
} else if (glsl_type_is_e5m2(glsl_dest_type)) {
|
||||
nir_def *src_as_float;
|
||||
if (glsl_type_is_float(glsl_src_type))
|
||||
src_as_float = src;
|
||||
else
|
||||
src_as_float = vtn_handle_convert(b, opcode, dest_val, glsl_float_type(),
|
||||
glsl_src_type, src);
|
||||
if (vtn_has_decoration(b, dest_val, SpvDecorationSaturatedToLargestFloat8NormalConversionEXT))
|
||||
return nir_f2e5m2_sat(&b->nb, src_as_float);
|
||||
else
|
||||
return nir_f2e5m2(&b->nb, src_as_float);
|
||||
}
|
||||
|
||||
/* Use bit_size from NIR source instead of from the original src type,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue