From: Alyssa Rosenzweig Date: Tue, 9 Jun 2020 22:15:20 +0000 (-0400) Subject: panfrost: Demote mediump varyings to fp16 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1c1782c6b555ffc9fe75306a326d907c28e6e116;p=mesa.git panfrost: Demote mediump varyings to fp16 Likewise lowp. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index 7d0f07a0dd1..8a6caead34c 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -77,7 +77,7 @@ pan_format_from_nir_size(nir_alu_type base, unsigned size) } static enum mali_format -pan_format_from_glsl(const struct glsl_type *type, unsigned frac) +pan_format_from_glsl(const struct glsl_type *type, unsigned precision, unsigned frac) { const struct glsl_type *column = glsl_without_array_or_matrix(type); enum glsl_base_type glsl_base = glsl_get_base_type(column); @@ -95,6 +95,19 @@ pan_format_from_glsl(const struct glsl_type *type, unsigned frac) unsigned base = nir_alu_type_get_base_type(t); unsigned size = nir_alu_type_get_type_size(t); + /* Demote to fp16 where possible. int16 varyings are TODO as the hw + * will saturate instead of wrap which is not conformant, so we need to + * insert i2i16/u2u16 instructions before the st_vary_32i/32u to get + * the intended behaviour */ + + bool is_16 = (precision == GLSL_PRECISION_MEDIUM) + || (precision == GLSL_PRECISION_LOW); + + if (is_16 && base == nir_type_float) + size = 16; + else + size = 32; + return pan_format_from_nir_base(base) | pan_format_from_nir_size(base, size) | MALI_NR_CHANNELS(chan); @@ -263,7 +276,8 @@ panfrost_shader_compile(struct panfrost_context *ctx, for (int c = 0; c < sz; ++c) { state->varyings_loc[loc + c] = var->data.location + c; - state->varyings[loc + c] = pan_format_from_glsl(var->type, var->data.location_frac); + state->varyings[loc + c] = pan_format_from_glsl(var->type, + var->data.precision, var->data.location_frac); } } }