OSDN Git Service

st/nine: Optimize managed buffer upload
authorAxel Davy <axel.davy@ens.fr>
Thu, 1 Dec 2016 21:50:22 +0000 (22:50 +0100)
committerAxel Davy <axel.davy@ens.fr>
Tue, 20 Dec 2016 22:47:08 +0000 (23:47 +0100)
Do the upload in the other thread.

Usually managed buffers are used once per frame.
It is then very likely pending_upload is 0 at Lock
time.

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

index 086985b..c745d77 100644 (file)
@@ -223,11 +223,14 @@ NineBuffer9_Lock( struct NineBuffer9 *This,
 
     if (This->base.pool == D3DPOOL_MANAGED) {
         /* READONLY doesn't dirty the buffer */
+        /* Tests on Win: READONLY doesn't wait for the upload */
         if (!(Flags & D3DLOCK_READONLY)) {
             if (!This->managed.dirty) {
                 assert(LIST_IS_EMPTY(&This->managed.list));
                 This->managed.dirty = TRUE;
                 This->managed.dirty_box = box;
+                if (p_atomic_read(&This->managed.pending_upload))
+                    nine_csmt_process(This->base.base.device);
             } else
                 u_box_union_2d(&This->managed.dirty_box, &This->managed.dirty_box, &box);
         }
index d8024e4..e9ee31e 100644 (file)
@@ -25,6 +25,7 @@
 #define _NINE_BUFFER9_H_
 
 #include "device9.h"
+#include "nine_state.h"
 #include "resource9.h"
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
@@ -57,6 +58,7 @@ struct NineBuffer9
         struct pipe_box dirty_box;
         struct list_head list; /* for update_buffers */
         struct list_head list2; /* for managed_buffers */
+        unsigned pending_upload; /* for uploads */
     } managed;
 };
 static inline struct NineBuffer9 *
@@ -92,13 +94,13 @@ NineBuffer9_Unlock( struct NineBuffer9 *This );
 static inline void
 NineBuffer9_Upload( struct NineBuffer9 *This )
 {
-    struct pipe_context *pipe = NineDevice9_GetPipe(This->base.base.device);
+    struct NineDevice9 *device = This->base.base.device;
 
     assert(This->base.pool == D3DPOOL_MANAGED && This->managed.dirty);
-    pipe->buffer_subdata(pipe, This->base.resource, 0,
-                         This->managed.dirty_box.x,
-                         This->managed.dirty_box.width,
-                         (char *)This->managed.data + This->managed.dirty_box.x);
+    nine_context_range_upload(device, &This->managed.pending_upload, This->base.resource,
+                              This->managed.dirty_box.x,
+                              This->managed.dirty_box.width,
+                              (char *)This->managed.data + This->managed.dirty_box.x);
     This->managed.dirty = FALSE;
 }