panfrost: Inline panfrost_vt_set_draw_info
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 25 Aug 2020 17:25:29 +0000 (13:25 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 28 Aug 2020 14:53:53 +0000 (14:53 +0000)
Not happy about the monster routine, but we'll get simplification having
everything together. (I hope.)

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

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

index 87b3372c4098b787c9813317b1574431c2e35758..a11290187e284aabaac00bc690464c5a0e0c0e20 100644 (file)
@@ -89,7 +89,7 @@ panfrost_vt_update_primitive_size(struct panfrost_context *ctx,
         }
 }
 
-static unsigned
+unsigned
 panfrost_translate_index_size(unsigned size)
 {
         switch (size) {
@@ -113,7 +113,7 @@ panfrost_translate_index_size(unsigned size)
  * these operations together because there are natural optimizations which
  * require them to be together. */
 
-static mali_ptr
+mali_ptr
 panfrost_get_index_buffer_bounded(struct panfrost_context *ctx,
                                   const struct pipe_draw_info *info,
                                   unsigned *min_index, unsigned *max_index)
@@ -169,74 +169,6 @@ panfrost_get_index_buffer_bounded(struct panfrost_context *ctx,
         return out;
 }
 
-void
-panfrost_vt_set_draw_info(struct panfrost_context *ctx,
-                          const struct pipe_draw_info *info,
-                          enum mali_draw_mode draw_mode,
-                          struct mali_vertex_tiler_postfix *vertex_postfix,
-                          struct mali_vertex_tiler_prefix *tiler_prefix,
-                          struct mali_vertex_tiler_postfix *tiler_postfix,
-                          unsigned *vertex_count,
-                          unsigned *padded_count)
-{
-        tiler_prefix->draw_mode = draw_mode;
-
-        unsigned draw_flags = 0;
-
-        if (panfrost_writes_point_size(ctx))
-                draw_flags |= MALI_DRAW_VARYING_SIZE;
-
-        if (info->primitive_restart)
-                draw_flags |= MALI_DRAW_PRIMITIVE_RESTART_FIXED_INDEX;
-
-        /* These doesn't make much sense */
-
-        draw_flags |= 0x3000;
-
-        if (info->index_size) {
-                unsigned min_index = 0, max_index = 0;
-
-                tiler_prefix->indices = panfrost_get_index_buffer_bounded(ctx,
-                                                                       info,
-                                                                       &min_index,
-                                                                       &max_index);
-
-                /* Use the corresponding values */
-                *vertex_count = max_index - min_index + 1;
-                tiler_postfix->offset_start = vertex_postfix->offset_start = min_index + info->index_bias;
-                tiler_prefix->offset_bias_correction = -min_index;
-                tiler_prefix->index_count = MALI_POSITIVE(info->count);
-                draw_flags |= panfrost_translate_index_size(info->index_size);
-        } else {
-                tiler_prefix->indices = 0;
-                *vertex_count = ctx->vertex_count;
-                tiler_postfix->offset_start = vertex_postfix->offset_start = info->start;
-                tiler_prefix->offset_bias_correction = 0;
-                tiler_prefix->index_count = MALI_POSITIVE(ctx->vertex_count);
-        }
-
-        tiler_prefix->unknown_draw = draw_flags;
-        ctx->offset_start = vertex_postfix->offset_start;
-
-        /* Encode the padded vertex count */
-
-        if (info->instance_count > 1) {
-                *padded_count = panfrost_padded_vertex_count(*vertex_count);
-
-                unsigned shift = __builtin_ctz(ctx->padded_count);
-                unsigned k = ctx->padded_count >> (shift + 1);
-
-                tiler_postfix->instance_shift = vertex_postfix->instance_shift = shift;
-                tiler_postfix->instance_odd = vertex_postfix->instance_odd = k;
-        } else {
-                *padded_count = *vertex_count;
-
-                /* Reset instancing state */
-                tiler_postfix->instance_shift = vertex_postfix->instance_shift = 0;
-                tiler_postfix->instance_odd = vertex_postfix->instance_odd = 0;
-        }
-}
-
 static unsigned
 translate_tex_wrap(enum pipe_tex_wrap w)
 {
index 4c396cbec74f35ee37328876c47ac9faef889c69..1f390024767cd5b8a2fb713a53f0cd61896c8bcf 100644 (file)
 void panfrost_sampler_desc_init(const struct pipe_sampler_state *cso, struct mali_midgard_sampler_packed *hw);
 void panfrost_sampler_desc_init_bifrost(const struct pipe_sampler_state *cso, struct mali_bifrost_sampler_packed *hw);
 
-void
-panfrost_vt_set_draw_info(struct panfrost_context *ctx,
-                          const struct pipe_draw_info *info,
-                          enum mali_draw_mode draw_mode,
-                          struct mali_vertex_tiler_postfix *vertex_postfix,
-                          struct mali_vertex_tiler_prefix *tiler_prefix,
-                          struct mali_vertex_tiler_postfix *tiler_postfix,
-                          unsigned *vertex_count,
-                          unsigned *padded_count);
-
 mali_ptr
 panfrost_emit_compute_shader_meta(struct panfrost_batch *batch, enum pipe_shader_type stage);
 
@@ -78,6 +68,14 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
 mali_ptr
 panfrost_vt_emit_shared_memory(struct panfrost_batch *batch);
 
+unsigned
+panfrost_translate_index_size(unsigned size);
+
+mali_ptr
+panfrost_get_index_buffer_bounded(struct panfrost_context *ctx,
+                                  const struct pipe_draw_info *info,
+                                  unsigned *min_index, unsigned *max_index);
+
 void
 panfrost_emit_varying_descriptor(struct panfrost_batch *batch,
                                  unsigned vertex_count,
index b096bc0e90861bf793dd6a29cb832cfbf7a94726..7b433a51d7776c6aa181037dba140014810d4204 100644 (file)
@@ -183,7 +183,7 @@ panfrost_texture_barrier(struct pipe_context *pipe, unsigned flags)
 #define DEFINE_CASE(c) case PIPE_PRIM_##c: return MALI_DRAW_MODE_##c;
 
 static int
-g2m_draw_mode(enum pipe_prim_type mode)
+pan_draw_mode(enum pipe_prim_type mode)
 {
         switch (mode) {
                 DEFINE_CASE(POINTS);
@@ -336,10 +336,52 @@ panfrost_draw_vbo(
         SET_BIT(tiler_prefix.unknown_draw, MALI_DRAW_FLATSHADE_FIRST,
                 rast->flatshade_first);
 
-        panfrost_vt_set_draw_info(ctx, info, g2m_draw_mode(mode),
-                                  &vertex_postfix, &tiler_prefix,
-                                  &tiler_postfix, &vertex_count,
-                                  &ctx->padded_count);
+        tiler_prefix.draw_mode = pan_draw_mode(mode);
+
+        unsigned draw_flags = 0x3000;
+
+        if (panfrost_writes_point_size(ctx))
+                draw_flags |= MALI_DRAW_VARYING_SIZE;
+
+        if (info->primitive_restart)
+                draw_flags |= MALI_DRAW_PRIMITIVE_RESTART_FIXED_INDEX;
+
+        if (info->index_size) {
+                unsigned min_index = 0, max_index = 0;
+
+                tiler_prefix.indices = panfrost_get_index_buffer_bounded(ctx,
+                                                                       info,
+                                                                       &min_index,
+                                                                       &max_index);
+
+                /* Use the corresponding values */
+                vertex_count = max_index - min_index + 1;
+                tiler_postfix.offset_start = vertex_postfix.offset_start = min_index + info->index_bias;
+                tiler_prefix.offset_bias_correction = -min_index;
+                tiler_prefix.index_count = MALI_POSITIVE(info->count);
+                draw_flags |= panfrost_translate_index_size(info->index_size);
+        } else {
+                vertex_count = ctx->vertex_count;
+                tiler_postfix.offset_start = vertex_postfix.offset_start = info->start;
+                tiler_prefix.index_count = MALI_POSITIVE(ctx->vertex_count);
+        }
+
+        tiler_prefix.unknown_draw = draw_flags;
+        ctx->offset_start = vertex_postfix.offset_start;
+
+        /* Encode the padded vertex count */
+
+        if (info->instance_count > 1) {
+                ctx->padded_count = panfrost_padded_vertex_count(vertex_count);
+
+                unsigned shift = __builtin_ctz(ctx->padded_count);
+                unsigned k = ctx->padded_count >> (shift + 1);
+
+                tiler_postfix.instance_shift = vertex_postfix.instance_shift = shift;
+                tiler_postfix.instance_odd = vertex_postfix.instance_odd = k;
+        } else {
+                ctx->padded_count = vertex_count;
+        }
 
         panfrost_statistics_record(ctx, info);