[Mesa-dev] [PATCH] swr: Remove need to allocate vertex buffer scratch space all in one go.

Rowley, Timothy O timothy.o.rowley at intel.com
Thu Jun 29 17:00:17 UTC 2017


Reviewed-by: Tim Rowley <timothy.o.rowley at intel.com<mailto:timothy.o.rowley at intel.com>>

On Jun 28, 2017, at 1:42 PM, Bruce Cherniak <bruce.cherniak at intel.com<mailto:bruce.cherniak at intel.com>> wrote:

Deferred deletion (via "fence_work") has obsoleted the need to allocate
all client vertex buffer scratch space in a single chunk.  Scratch
allocations are now valid until the referenced fence is complete.
---
src/gallium/drivers/swr/swr_state.cpp | 25 ++-----------------------
1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp
index 6dc06ed156..7a8786d96f 100644
--- a/src/gallium/drivers/swr/swr_state.cpp
+++ b/src/gallium/drivers/swr/swr_state.cpp
@@ -1219,32 +1219,12 @@ swr_update_derived(struct pipe_context *pipe,
    */
   if (ctx->dirty & SWR_NEW_VERTEX ||
      (p_draw_info && p_draw_info->index_size)) {
-      uint32_t scratch_total;
-      uint8_t *scratch = NULL;

      /* If being called by swr_draw_vbo, copy draw details */
      struct pipe_draw_info info = {0};
      if (p_draw_info)
         info = *p_draw_info;

-      /* We must get all the scratch space in one go */
-      scratch_total = 0;
-      for (UINT i = 0; i < ctx->num_vertex_buffers; i++) {
-         struct pipe_vertex_buffer *vb = &ctx->vertex_buffer[i];
-
-         if (!vb->is_user_buffer)
-            continue;
-
-         uint32_t elems, base, size;
-         swr_user_vbuf_range(&info, ctx->velems, vb, i, &elems, &base, &size);
-         scratch_total += AlignUp(size, 4);
-      }
-
-      if (scratch_total) {
-         scratch = (uint8_t *)swr_copy_to_scratch_space(
-               ctx, &ctx->scratch->vertex_buffer, NULL, scratch_total);
-      }
-
      /* vertex buffers */
      SWR_VERTEX_BUFFER_STATE swrVertexBuffers[PIPE_MAX_ATTRIBS];
      for (UINT i = 0; i < ctx->num_vertex_buffers; i++) {
@@ -1289,9 +1269,8 @@ swr_update_derived(struct pipe_context *pipe,
            /* Copy only needed vertices to scratch space */
            size = AlignUp(size, 4);
            const void *ptr = (const uint8_t *) vb->buffer.user + base;
-            memcpy(scratch, ptr, size);
-            ptr = scratch;
-            scratch += size;
+            ptr = (uint8_t *)swr_copy_to_scratch_space(
+               ctx, &ctx->scratch->vertex_buffer, ptr, size);
            p_data = (const uint8_t *)ptr - base;
         }

--
2.11.0

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org<mailto:mesa-dev at lists.freedesktop.org>
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170629/b8389ffb/attachment-0001.html>


More information about the mesa-dev mailing list