Mesa (master): u_prim_restart: handle user buffers in util_translate_prim_restart_ib()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 10 12:06:44 UTC 2020


Module: Mesa
Branch: master
Commit: e66e0c0c2d017722f6ffba114a140fec683652e0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e66e0c0c2d017722f6ffba114a140fec683652e0

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Jul  2 16:08:44 2020 -0400

u_prim_restart: handle user buffers in util_translate_prim_restart_ib()

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5806>

---

 src/gallium/auxiliary/util/u_prim_restart.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_prim_restart.c b/src/gallium/auxiliary/util/u_prim_restart.c
index 10e39e240db..188f49e34c4 100644
--- a/src/gallium/auxiliary/util/u_prim_restart.c
+++ b/src/gallium/auxiliary/util/u_prim_restart.c
@@ -52,9 +52,6 @@ util_translate_prim_restart_ib(struct pipe_context *context,
    dst_index_size = MAX2(2, info->index_size);
    assert(dst_index_size == 2 || dst_index_size == 4);
 
-   /* no user buffers for now */
-   assert(!info->has_user_indices);
-
    /* Create new index buffer */
    *dst_buffer = pipe_buffer_create(screen, PIPE_BIND_INDEX_BUFFER,
                                     PIPE_USAGE_STREAM,
@@ -68,12 +65,15 @@ util_translate_prim_restart_ib(struct pipe_context *context,
    if (!dst_map)
       goto error;
 
-   /* Map original / src index buffer */
-   src_map = pipe_buffer_map_range(context, info->index.resource,
-                                   info->start * src_index_size,
-                                   info->count * src_index_size,
-                                   PIPE_TRANSFER_READ,
-                                   &src_transfer);
+   if (info->has_user_indices)
+      src_map = (unsigned char*)info->index.user + info->start * src_index_size;
+   else
+      /* Map original / src index buffer */
+      src_map = pipe_buffer_map_range(context, info->index.resource,
+                                      info->start * src_index_size,
+                                      info->count * src_index_size,
+                                      PIPE_TRANSFER_READ,
+                                      &src_transfer);
    if (!src_map)
       goto error;
 
@@ -104,7 +104,8 @@ util_translate_prim_restart_ib(struct pipe_context *context,
       }
    }
 
-   pipe_buffer_unmap(context, src_transfer);
+   if (src_transfer)
+      pipe_buffer_unmap(context, src_transfer);
    pipe_buffer_unmap(context, dst_transfer);
 
    return PIPE_OK;



More information about the mesa-commit mailing list