[Mesa-dev] [PATCH 4/6] svga: Map vertex- index- and constant buffers ansynchronously when reading

Thomas Hellström (VMware) thomas at shipmail.org
Wed Jun 19 08:34:43 UTC 2019


From: Thomas Hellstrom <thellstrom at vmware.com>

With SWTNL and index translation we're mapping buffers for reading. These
buffers are commonly upload_mgr buffers that might already be referenced
by another submitted or unsubmitted GPU command. A synchronous map will
then trigger a flush and sync, at least on Linux that doesn't distinguish
between read- and write referencing. So map these buffers async. If they
for some obscure reason happen to be dirty (stream-output, buffer-copy),
the resource_buffer code will read-back and sync anyway. For persistent /
coherent buffers a corresponding read-back and sync will happen in the
kernel fault handler.

Testing: Piglit quick. No regressions.

Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
---
 src/gallium/drivers/svga/svga_draw_elements.c | 4 +++-
 src/gallium/drivers/svga/svga_swtnl_draw.c    | 9 ++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c
index b955b2f77e2..41cd4d18993 100644
--- a/src/gallium/drivers/svga/svga_draw_elements.c
+++ b/src/gallium/drivers/svga/svga_draw_elements.c
@@ -120,7 +120,9 @@ translate_indices(struct svga_hwtnl *hwtnl,
          goto fail;
 
       *out_offset = 0;
-      src_map = pipe_buffer_map(pipe, info->index.resource, PIPE_TRANSFER_READ,
+      src_map = pipe_buffer_map(pipe, info->index.resource,
+                                PIPE_TRANSFER_READ |
+                                PIPE_TRANSFER_UNSYNCHRONIZED,
                                 &src_transfer);
       if (!src_map)
          goto fail;
diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c
index a7db73e02ee..1aa15d8cd26 100644
--- a/src/gallium/drivers/svga/svga_swtnl_draw.c
+++ b/src/gallium/drivers/svga/svga_swtnl_draw.c
@@ -73,7 +73,8 @@ svga_swtnl_draw_vbo(struct svga_context *svga,
       if (svga->curr.vb[i].buffer.resource) {
          map = pipe_buffer_map(&svga->pipe,
                                svga->curr.vb[i].buffer.resource,
-                               PIPE_TRANSFER_READ,
+                               PIPE_TRANSFER_READ |
+                               PIPE_TRANSFER_UNSYNCHRONIZED,
                                &vb_transfer[i]);
 
          draw_set_mapped_vertex_buffer(draw, i, map, ~0);
@@ -88,7 +89,8 @@ svga_swtnl_draw_vbo(struct svga_context *svga,
          map = (ubyte *) info->index.user;
       } else {
          map = pipe_buffer_map(&svga->pipe, info->index.resource,
-                               PIPE_TRANSFER_READ, &ib_transfer);
+                               PIPE_TRANSFER_READ |
+                               PIPE_TRANSFER_UNSYNCHRONIZED, &ib_transfer);
       }
       draw_set_indexes(draw,
                        (const ubyte *) map,
@@ -103,7 +105,8 @@ svga_swtnl_draw_vbo(struct svga_context *svga,
 
       map = pipe_buffer_map(&svga->pipe,
                             svga->curr.constbufs[PIPE_SHADER_VERTEX][i].buffer,
-                            PIPE_TRANSFER_READ,
+                            PIPE_TRANSFER_READ |
+                            PIPE_TRANSFER_UNSYNCHRONIZED,
                             &cb_transfer[i]);
       assert(map);
       draw_set_mapped_constant_buffer(
-- 
2.20.1



More information about the mesa-dev mailing list