[Mesa-dev] [PATCH] st/nine: Upload on secondary context for Draw*Up

Axel Davy axel.davy at ens.fr
Sun Dec 18 18:22:30 UTC 2016


Avoid synchronization by using the secondary context
for uploading the vertex data for Draw*Up.

Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/device9.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 9f2575309a..9af9b5b578 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -473,12 +473,12 @@ NineDevice9_ctor( struct NineDevice9 *This,
     This->driver_caps.user_sw_cbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS);
 
     if (!This->driver_caps.user_vbufs)
-        This->vertex_uploader = u_upload_create(This->context.pipe, 65536,
+        This->vertex_uploader = u_upload_create(This->pipe_secondary, 65536,
                                                 PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM);
     This->vertex_sw_uploader = u_upload_create(This->pipe_sw, 65536,
                                             PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM);
     if (!This->driver_caps.user_ibufs)
-        This->index_uploader = u_upload_create(This->context.pipe, 128 * 1024,
+        This->index_uploader = u_upload_create(This->pipe_secondary, 128 * 1024,
                                                PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM);
     if (!This->driver_caps.user_cbufs) {
         This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT);
@@ -2835,8 +2835,6 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
     vtxbuf.user_buffer = pVertexStreamZeroData;
 
     if (!This->driver_caps.user_vbufs) {
-        /* Implicit use of context pipe */
-        (void)NineDevice9_GetPipe(This);
         u_upload_data(This->vertex_uploader,
                       0,
                       (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * VertexStreamZeroStride, /* XXX */
@@ -2846,6 +2844,9 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
                       &vtxbuf.buffer);
         u_upload_unmap(This->vertex_uploader);
         vtxbuf.user_buffer = NULL;
+        /* Flush to make sure u_upload_unmap, which is on pipe_secondary,
+         * is visible to context pipe. */
+        This->pipe_secondary->flush(This->pipe_secondary, NULL, 0);
     }
 
     NineBeforeDraw(This);
@@ -2900,8 +2901,6 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
 
     if (!This->driver_caps.user_vbufs) {
         const unsigned base = MinVertexIndex * VertexStreamZeroStride;
-        /* Implicit use of context pipe */
-        (void)NineDevice9_GetPipe(This);
         u_upload_data(This->vertex_uploader,
                       base,
                       NumVertices * VertexStreamZeroStride, /* XXX */
@@ -2915,8 +2914,6 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
         vbuf.user_buffer = NULL;
     }
     if (!This->driver_caps.user_ibufs) {
-        /* Implicit use of context pipe */
-        (void)NineDevice9_GetPipe(This);
         u_upload_data(This->index_uploader,
                       0,
                       (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * ibuf.index_size,
@@ -2928,6 +2925,11 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
         ibuf.user_buffer = NULL;
     }
 
+    if (!This->driver_caps.user_vbufs || !This->driver_caps.user_ibufs)
+        /* Flush to make sure u_upload_unmap, which is on pipe_secondary,
+         * is visible to context pipe. */
+        This->pipe_secondary->flush(This->pipe_secondary, NULL, 0);
+
     NineBeforeDraw(This);
     nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(This, PrimitiveType,
                                                            MinVertexIndex,
-- 
2.11.0



More information about the mesa-dev mailing list