From deb55340ca55a712c97886d21b405a53b33046bb Mon Sep 17 00:00:00 2001 From: Jose Maria Casanova Crespo Date: Tue, 31 Aug 2021 18:41:53 +0200 Subject: [PATCH] vc4: remove primconvert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are losing the optimization of converting a single quad to a triangle fan reusing the same four vertex in the buffer. Maybe this optimization can be ported to primconvert, QUADS are always converted to TRIANGLES with primconvert. And i965, crocus and svga have similar optimizations. V3D doesn't implement this optimization and according to when it was introduced on 230e646a4013 ("broadcom/vc4: Decompose single QUADs to a TRIANGLE_FAN."): "No significant difference in the minetest replay, but it should reduce overhead by not requiring that we write quad indices to index buffers that we repeatedly re-upload (and making the draw packet smaller, as well)." v2: Commit log includes more detail about the removed optimization. (Alejandro Piñeiro) Reference: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5277 Suggested-by: Mike Blumenkrantz Acked-By: Mike Blumenkrantz Reviewed-by: Alejandro Piñeiro Part-of: --- src/gallium/drivers/vc4/vc4_context.c | 9 --------- src/gallium/drivers/vc4/vc4_context.h | 2 -- src/gallium/drivers/vc4/vc4_draw.c | 18 ------------------ 3 files changed, 29 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_context.c b/src/gallium/drivers/vc4/vc4_context.c index 94969dcb133..75d82f3e3a7 100644 --- a/src/gallium/drivers/vc4/vc4_context.c +++ b/src/gallium/drivers/vc4/vc4_context.c @@ -30,7 +30,6 @@ #include "util/u_memory.h" #include "util/u_blitter.h" #include "util/u_upload_mgr.h" -#include "indices/u_primconvert.h" #include "pipe/p_screen.h" #include "vc4_screen.h" @@ -124,9 +123,6 @@ vc4_context_destroy(struct pipe_context *pctx) if (vc4->blitter) util_blitter_destroy(vc4->blitter); - if (vc4->primconvert) - util_primconvert_destroy(vc4->primconvert); - if (vc4->uploader) u_upload_destroy(vc4->uploader); @@ -206,11 +202,6 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) if (!vc4->blitter) goto fail; - vc4->primconvert = util_primconvert_create(pctx, - (1 << PIPE_PRIM_QUADS) - 1); - if (!vc4->primconvert) - goto fail; - vc4_debug |= saved_shaderdb_flag; vc4->sample_mask = (1 << VC4_MAX_SAMPLES) - 1; diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h index 6fb54d56b90..f4713537188 100644 --- a/src/gallium/drivers/vc4/vc4_context.h +++ b/src/gallium/drivers/vc4/vc4_context.h @@ -328,8 +328,6 @@ struct vc4_context { /** bitfield of VC4_DIRTY_* */ uint32_t dirty; - struct primconvert_context *primconvert; - struct hash_table *fs_cache, *vs_cache; struct set *fs_inputs_set; uint32_t next_uncompiled_program_id; diff --git a/src/gallium/drivers/vc4/vc4_draw.c b/src/gallium/drivers/vc4/vc4_draw.c index d01a1c27273..ebaddae7624 100644 --- a/src/gallium/drivers/vc4/vc4_draw.c +++ b/src/gallium/drivers/vc4/vc4_draw.c @@ -29,7 +29,6 @@ #include "util/u_pack_color.h" #include "util/u_split_draw.h" #include "util/u_upload_mgr.h" -#include "indices/u_primconvert.h" #include "vc4_context.h" #include "vc4_resource.h" @@ -304,29 +303,12 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, return; struct vc4_context *vc4 = vc4_context(pctx); - struct pipe_draw_info local_info; if (!indirect && !info->primitive_restart && !u_trim_pipe_prim(info->mode, (unsigned*)&draws[0].count)) return; - if (info->mode >= PIPE_PRIM_QUADS) { - if (info->mode == PIPE_PRIM_QUADS && - draws[0].count == 4 && - !vc4->rasterizer->base.flatshade) { - local_info = *info; - local_info.mode = PIPE_PRIM_TRIANGLE_FAN; - info = &local_info; - } else { - util_primconvert_save_rasterizer_state(vc4->primconvert, &vc4->rasterizer->base); - util_primconvert_draw_vbo(vc4->primconvert, info, drawid_offset, indirect, draws, num_draws); - perf_debug("Fallback conversion for %d %s vertices\n", - draws[0].count, u_prim_name(info->mode)); - return; - } - } - /* Before setting up the draw, do any fixup blits necessary. */ vc4_predraw_check_textures(pctx, &vc4->verttex); vc4_predraw_check_textures(pctx, &vc4->fragtex);