summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAxel Davy <axel.davy@ens.fr>2016-02-25 19:07:37 +0100
committerEmil Velikov <emil.l.velikov@gmail.com>2016-03-04 11:52:18 +0000
commitd29f41e1ba4414f4d3ed324ec44e389f6fceb51a (patch)
tree1214f3b657c56cffd09fe3949053c4bf5682efa7
parenteda0880f77217233c2cb1acc538d55a6227da834 (diff)
st/nine: Fix Multithreading issue with MANAGED buffers
d3d calls are protected by mutexes, however if app is doing in two threads: Thread 1: buffer Lock Thread 2: Draw call Thread 1: writes data Thread 1: Unlock Then before this patch, the Draw call would begin to upload the buffer. Solves this by moving the moment we add the buffer to the queue of things to upload (We move it from Lock time to Unlock time). Cc: "11.2" <mesa-stable@lists.freedesktop.org> Signed-off-by: Axel Davy <axel.davy@ens.fr> (cherry picked from commit 44246fe99d4c880b70a58043624bf023237009f5)
-rw-r--r--src/gallium/state_trackers/nine/buffer9.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/nine/buffer9.c b/src/gallium/state_trackers/nine/buffer9.c
index 8efb4cefb1..6d5d9d691f 100644
--- a/src/gallium/state_trackers/nine/buffer9.c
+++ b/src/gallium/state_trackers/nine/buffer9.c
@@ -178,7 +178,6 @@ NineBuffer9_Lock( struct NineBuffer9 *This,
if (!(Flags & D3DLOCK_READONLY)) {
if (!This->managed.dirty) {
assert(LIST_IS_EMPTY(&This->managed.list));
- list_add(&This->managed.list, &This->base.base.device->update_buffers);
This->managed.dirty = TRUE;
This->managed.dirty_box = box;
} else {
@@ -232,8 +231,13 @@ NineBuffer9_Unlock( struct NineBuffer9 *This )
user_assert(This->nmaps > 0, D3DERR_INVALIDCALL);
if (This->base.pool != D3DPOOL_MANAGED)
This->pipe->transfer_unmap(This->pipe, This->maps[--(This->nmaps)]);
- else
+ else {
This->nmaps--;
+ /* TODO: Fix this to upload at the first draw call needing the data,
+ * instead of at the next draw call */
+ if (!This->nmaps && This->managed.dirty && LIST_IS_EMPTY(&This->managed.list))
+ list_add(&This->managed.list, &This->base.base.device->update_buffers);
+ }
return D3D_OK;
}