gallium/indices: translate primitive-restart values
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 25 Jun 2020 10:26:54 +0000 (12:26 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 18 Aug 2020 12:12:27 +0000 (12:12 +0000)
This adds a config-option to u_primconvert that translates primitive
restart values to the max-values for the index size. This allows us to
support arbitrary primitive-restart indices on hardware that only
supports fixed restart-indices.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5976>

src/gallium/auxiliary/indices/u_primconvert.c
src/gallium/auxiliary/indices/u_primconvert.h

index 5b3c66a838cfc98d0a5690cd3c1b9fe662b86224..d0a1a78e40eded8bfc4420b0e038be9a90f725ad 100644 (file)
@@ -44,6 +44,7 @@
 #include "util/u_draw.h"
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
+#include "util/u_prim_restart.h"
 #include "util/u_upload_mgr.h"
 
 #include "indices/u_indices.h"
@@ -152,6 +153,14 @@ util_primconvert_draw_vbo(struct primconvert_context *pc,
 
    if (info->index_size) {
       trans_func(src, info->start, info->count, new_info.count, info->restart_index, dst);
+
+      if (pc->cfg.fixed_prim_restart && info->primitive_restart) {
+         new_info.restart_index = (1ull << (new_info.index_size * 8)) - 1;
+         if (info->restart_index != new_info.restart_index)
+            util_translate_prim_restart_data(new_info.index_size, dst, dst,
+                                             new_info.count,
+                                             info->restart_index);
+      }
    }
    else {
       gen_func(info->start, new_info.count, dst);
index dfec9f975cb03881c687a93e112db5cb0d8385e2..80d25a49313b117e49d208576f56247f253d11b5 100644 (file)
@@ -33,6 +33,7 @@ struct primconvert_context;
 
 struct primconvert_config {
    uint32_t primtypes_mask;
+   bool fixed_prim_restart;
 };
 
 struct primconvert_context *util_primconvert_create(struct pipe_context *pipe,