summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2021-05-18 19:55:01 -0400
committerEric Engestrom <eric@engestrom.ch>2021-05-31 22:48:16 +0200
commita0cfc718fbcc4c30bdce0c167b269d56909926cc (patch)
tree89db5be9b8863d9c216e53d67932e6af90fb962d
parent71e14df4f9f7dcb0fb0ff5545de1514bf35467a0 (diff)
util/prim_restart: fix util_translate_prim_restart_ib
this was broken for the indirect case if the indirect draw count or firstIndex was nonzero and also would rewrite the index buffer onto the wrong offset of the dst buffer Fixes: 0c85d6c523f ("gallium/util: factor out primitive-restart rewriting logic") Fixes: 330d0607ed6 ("gallium: remove pipe_index_buffer and set_index_buffer") Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10909> (cherry picked from commit 1272c2e05246cad647324ffdccf56435b97dec1c)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/auxiliary/util/u_prim_restart.c9
2 files changed, 6 insertions, 5 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 3cc27a7ad81..404623d3824 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -877,7 +877,7 @@
"description": "util/prim_restart: fix util_translate_prim_restart_ib",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "0c85d6c523f137571768ab3bb190a201ae294421"
},
diff --git a/src/gallium/auxiliary/util/u_prim_restart.c b/src/gallium/auxiliary/util/u_prim_restart.c
index 8d1640969f8..9224bb396e3 100644
--- a/src/gallium/auxiliary/util/u_prim_restart.c
+++ b/src/gallium/auxiliary/util/u_prim_restart.c
@@ -125,13 +125,14 @@ util_translate_prim_restart_ib(struct pipe_context *context,
/* Create new index buffer */
*dst_buffer = pipe_buffer_create(screen, PIPE_BIND_INDEX_BUFFER,
PIPE_USAGE_STREAM,
- count * dst_index_size);
+ (start + count) * dst_index_size);
if (!*dst_buffer)
goto error;
/* Map new / dest index buffer */
- dst_map = pipe_buffer_map(context, *dst_buffer,
- PIPE_MAP_WRITE, &dst_transfer);
+ dst_map = pipe_buffer_map_range(context, *dst_buffer,
+ start * dst_index_size, count * dst_index_size,
+ PIPE_MAP_WRITE, &dst_transfer);
if (!dst_map)
goto error;
@@ -148,7 +149,7 @@ util_translate_prim_restart_ib(struct pipe_context *context,
goto error;
util_translate_prim_restart_data(src_index_size, src_map, dst_map,
- draw->count, info->restart_index);
+ count, info->restart_index);
if (src_transfer)
pipe_buffer_unmap(context, src_transfer);