Mesa (master): panfrost: Demote mediump varyings to fp16

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 12 14:59:54 UTC 2020


Module: Mesa
Branch: master
Commit: 1c1782c6b555ffc9fe75306a326d907c28e6e116
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1c1782c6b555ffc9fe75306a326d907c28e6e116

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Tue Jun  9 18:15:20 2020 -0400

panfrost: Demote mediump varyings to fp16

Likewise lowp.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5423>

---

 src/gallium/drivers/panfrost/pan_assemble.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

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);
                 }
         }
 }



More information about the mesa-commit mailing list