From 69d47fdd7a43615837180c4a9c181b4c786121c4 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 21 May 2021 05:57:17 -0400 Subject: [PATCH] util/prim_restart: pre-trim degenerate primitives during draw rewrite these will be eliminated by drivers anyway Reviewed-by: Erik Faye-Lund Part-of: --- src/gallium/auxiliary/util/u_prim_restart.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_prim_restart.c b/src/gallium/auxiliary/util/u_prim_restart.c index 514d33f9c62..3e59ce50bb1 100644 --- a/src/gallium/auxiliary/util/u_prim_restart.c +++ b/src/gallium/auxiliary/util/u_prim_restart.c @@ -28,6 +28,7 @@ #include "u_inlines.h" #include "util/u_memory.h" #include "u_prim_restart.h" +#include "u_prim.h" typedef struct { uint32_t count; @@ -184,8 +185,12 @@ struct range_info { * \return true for success, false if out of memory */ static boolean -add_range(struct range_info *info, unsigned start, unsigned count) +add_range(enum pipe_prim_type mode, struct range_info *info, unsigned start, unsigned count) { + /* degenerate primitive: ignore */ + if (!u_trim_pipe_prim(mode, (unsigned*)&count)) + return TRUE; + if (info->max == 0) { info->max = 10; info->ranges = MALLOC(info->max * sizeof(struct range)); @@ -285,7 +290,7 @@ util_draw_vbo_without_prim_restart(struct pipe_context *context, ((const TYPE *) src_map)[i] == info->restart_index) { \ /* cut / restart */ \ if (count > 0) { \ - if (!add_range(&ranges, info_start + start, count)) { \ + if (!add_range(info->mode, &ranges, info_start + start, count)) { \ if (src_transfer) \ pipe_buffer_unmap(context, src_transfer); \ return PIPE_ERROR_OUT_OF_MEMORY; \