From: Alyssa Rosenzweig Date: Tue, 25 Aug 2020 17:25:29 +0000 (-0400) Subject: panfrost: Inline panfrost_vt_set_draw_info X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3a4d9305715e1a45ec25bac2114ec22c19cfae79;p=mesa.git panfrost: Inline panfrost_vt_set_draw_info Not happy about the monster routine, but we'll get simplification having everything together. (I hope.) Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 87b3372c409..a11290187e2 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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) { diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.h b/src/gallium/drivers/panfrost/pan_cmdstream.h index 4c396cbec74..1f390024767 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.h +++ b/src/gallium/drivers/panfrost/pan_cmdstream.h @@ -35,16 +35,6 @@ 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, diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index b096bc0e908..7b433a51d77 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -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);