From 3cc425e27df6b14b6b9fb5363861d83e53d0b362 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 10 Jun 2020 15:48:33 -0400 Subject: [PATCH] panfrost: Only store varying formats This reduces linking complexity. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_assemble.c | 59 +++----------------- src/gallium/drivers/panfrost/pan_cmdstream.c | 2 +- src/gallium/drivers/panfrost/pan_context.h | 2 +- 3 files changed, 10 insertions(+), 53 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index a274a5bc0bb..dfda97f9463 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -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; } } diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index b572431d8b5..b3a628b6137 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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); diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index aafb6ad138f..22bc981181c 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -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; -- 2.30.2