panfrost: Only store varying formats
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 10 Jun 2020 19:48:33 +0000 (15:48 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 12 Jun 2020 14:45:50 +0000 (14:45 +0000)
This reduces linking complexity.

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

src/gallium/drivers/panfrost/pan_assemble.c
src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_context.h

index a274a5bc0bb259df933df2bd4854c5cb0ecae8bc..dfda97f9463f1eae09e66c7d6c0cb620aed0c5ac 100644 (file)
@@ -249,25 +249,8 @@ panfrost_shader_compile(struct panfrost_context *ctx,
                 for (unsigned i = 0; i < BIFROST_MAX_RENDER_TARGET_COUNT; i++)
                         state->blend_types[i] = bifrost_blend_type_from_nir(program.blend_types[i]);
 
-        unsigned default_vec1_swizzle;
-        unsigned default_vec2_swizzle;
-        unsigned default_vec4_swizzle;
-
-        if (dev->quirks & HAS_SWIZZLES) {
-                default_vec1_swizzle = panfrost_get_default_swizzle(1);
-                default_vec2_swizzle = panfrost_get_default_swizzle(2);
-                default_vec4_swizzle = panfrost_get_default_swizzle(4);
-        } else {
-                default_vec1_swizzle = panfrost_bifrost_swizzle(1);
-                default_vec2_swizzle = panfrost_bifrost_swizzle(2);
-                default_vec4_swizzle = panfrost_bifrost_swizzle(4);
-        }
-
         /* Record the varying mapping for the command stream's bookkeeping */
 
-        unsigned p_varyings[32];
-        enum mali_format p_varying_type[32];
-
         struct exec_list *l_varyings =
                         stage == MESA_SHADER_VERTEX ? &s->outputs : &s->inputs;
 
@@ -276,47 +259,21 @@ panfrost_shader_compile(struct panfrost_context *ctx,
                 unsigned sz = glsl_count_attribute_slots(var->type, FALSE);
 
                 for (int c = 0; c < sz; ++c) {
-                        p_varyings[loc + c] = var->data.location + c;
-                        p_varying_type[loc + c] = pan_format_from_glsl(var->type, var->data.location_frac);
+                        state->varyings_loc[loc + c] = var->data.location + c;
+                        state->varyings[loc + c] = pan_format_from_glsl(var->type, var->data.location_frac);
                 }
         }
 
-        /* Iterate the varyings and emit the corresponding descriptor */
         for (unsigned i = 0; i < state->varying_count; ++i) {
-                unsigned location = p_varyings[i];
-
-                /* Default to a vec4 varying */
-                struct mali_attr_meta v = {
-                        .format = p_varying_type[i],
-                        .swizzle = default_vec4_swizzle,
-                        .unknown1 = dev->quirks & IS_BIFROST ? 0x0 : 0x2,
-                };
-
-                /* Check for special cases, otherwise assume general varying */
-
-                if (location == VARYING_SLOT_POS) {
-                        if (stage == MESA_SHADER_FRAGMENT)
-                                state->reads_frag_coord = true;
-                        else
-                                v.format = MALI_VARYING_POS;
-                } else if (location == VARYING_SLOT_PSIZ) {
-                        v.format = MALI_R16F;
-                        v.swizzle = default_vec1_swizzle;
+                unsigned location = state->varyings_loc[i];
 
+                if (location == VARYING_SLOT_POS && stage == MESA_SHADER_FRAGMENT)
+                        state->reads_frag_coord = true;
+                else if (location == VARYING_SLOT_PSIZ)
                         state->writes_point_size = true;
-                } else if (location == VARYING_SLOT_PNTC) {
-                        v.format = MALI_RG16F;
-                        v.swizzle = default_vec2_swizzle;
-
+                else if (location == VARYING_SLOT_PNTC)
                         state->reads_point_coord = true;
-                } else if (location == VARYING_SLOT_FACE) {
-                        v.format = MALI_R32I;
-                        v.swizzle = default_vec1_swizzle;
-
+                else if (location == VARYING_SLOT_FACE)
                         state->reads_face = true;
-                }
-
-                state->varyings[i] = v;
-                state->varyings_loc[i] = location;
         }
 }
index b572431d8b5360bc0cf05c91bb372f298bc62e6a..b3a628b6137c36884c1f087b5967f7f7bc0195a8 100644 (file)
@@ -1912,7 +1912,7 @@ panfrost_emit_varying(
                 bool is_fragment)
 {
         gl_varying_slot loc = stage->varyings_loc[idx];
-        enum mali_format format = stage->varyings[idx].format;
+        enum mali_format format = stage->varyings[idx];
 
         if (has_point_coord(stage->point_sprite_mask, loc)) {
                 return pan_emit_vary_special(present, PAN_VARY_PNTCOORD, quirks);
index aafb6ad138f5efba57b6a3f51f6c8186053a8ff5..22bc981181cd20c486ea8dd88b1c176061ea9ed0 100644 (file)
@@ -204,7 +204,7 @@ struct panfrost_shader_state {
         enum bifrost_shader_type blend_types[BIFROST_MAX_RENDER_TARGET_COUNT];
 
         unsigned int varying_count;
-        struct mali_attr_meta varyings[PIPE_MAX_ATTRIBS];
+        enum mali_format varyings[PIPE_MAX_ATTRIBS];
         gl_varying_slot varyings_loc[PIPE_MAX_ATTRIBS];
         struct pipe_stream_output_info stream_output;
         uint64_t so_mask;