st/nine: Fix user vertex data uploader with csmt
authorAxel Davy <axel.davy@ens.fr>
Wed, 15 Mar 2017 21:29:12 +0000 (22:29 +0100)
committerAxel Davy <axel.davy@ens.fr>
Sun, 26 Mar 2017 21:10:38 +0000 (23:10 +0200)
Fix regression caused by
abb1c645c476b5dd289ce3efae0594f8796f9cf8

The patch made csmt use context.pipe instead of
secondary_pipe, leading to thread safety issues.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/device9.c
src/gallium/state_trackers/nine/device9.h

index 8437162..4943658 100644 (file)
@@ -476,6 +476,7 @@ NineDevice9_ctor( struct NineDevice9 *This,
     This->driver_caps.user_cbufs = GET_PCAP(USER_CONSTANT_BUFFERS);
     This->driver_caps.user_sw_vbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_VERTEX_BUFFERS);
     This->driver_caps.user_sw_cbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS);
+    This->vertex_uploader = This->csmt_active ? This->pipe_secondary->stream_uploader : This->context.pipe->stream_uploader;
     if (!This->driver_caps.user_cbufs)
         This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT);
     This->driver_caps.window_space_position_support = GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION);
@@ -2817,17 +2818,15 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
     vtxbuf.buffer = NULL;
     vtxbuf.user_buffer = pVertexStreamZeroData;
 
-    /* csmt is unactive when user vertex or index buffers are used, thus no
-     * need to call NineDevice9_GetPipe. */
     if (!This->driver_caps.user_vbufs) {
-        u_upload_data(This->context.pipe->stream_uploader,
+        u_upload_data(This->vertex_uploader,
                       0,
                       (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * VertexStreamZeroStride, /* XXX */
                       4,
                       vtxbuf.user_buffer,
                       &vtxbuf.buffer_offset,
                       &vtxbuf.buffer);
-        u_upload_unmap(This->context.pipe->stream_uploader);
+        u_upload_unmap(This->vertex_uploader);
         vtxbuf.user_buffer = NULL;
     }
 
@@ -2883,27 +2882,27 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
 
     if (!This->driver_caps.user_vbufs) {
         const unsigned base = MinVertexIndex * VertexStreamZeroStride;
-        u_upload_data(This->context.pipe->stream_uploader,
+        u_upload_data(This->vertex_uploader,
                       base,
                       NumVertices * VertexStreamZeroStride, /* XXX */
                       4,
                       (const uint8_t *)vbuf.user_buffer + base,
                       &vbuf.buffer_offset,
                       &vbuf.buffer);
-        u_upload_unmap(This->context.pipe->stream_uploader);
+        u_upload_unmap(This->vertex_uploader);
         /* Won't be used: */
         vbuf.buffer_offset -= base;
         vbuf.user_buffer = NULL;
     }
     if (This->csmt_active) {
-        u_upload_data(This->context.pipe->stream_uploader,
+        u_upload_data(This->pipe_secondary->stream_uploader,
                       0,
                       (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * ibuf.index_size,
                       4,
                       ibuf.user_buffer,
                       &ibuf.offset,
                       &ibuf.buffer);
-        u_upload_unmap(This->context.pipe->stream_uploader);
+        u_upload_unmap(This->pipe_secondary->stream_uploader);
         ibuf.user_buffer = NULL;
     }
 
index 4b1630c..c5fd8f7 100644 (file)
@@ -140,6 +140,7 @@ struct NineDevice9
         boolean buggy_barycentrics;
     } driver_bugs;
 
+    struct u_upload_mgr *vertex_uploader;
     unsigned constbuf_alignment;
 
     struct nine_range_pool range_pool;