st/nine: Optimize a bit writeonly buffers
authorAxel Davy <davyaxel0@gmail.com>
Wed, 24 Apr 2019 21:24:40 +0000 (23:24 +0200)
committerAxel Davy <davyaxel0@gmail.com>
Tue, 30 Apr 2019 17:18:52 +0000 (19:18 +0200)
Optimize writeonly by passing PIPE_TRANSFER_WRITE
for these buffers instead of the safer
PIPE_TRANSFER_READ_WRITE.

This seems to improve the performance of d3d8 games
using d3d8to9.

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
src/gallium/state_trackers/nine/buffer9.c

index 30066f11c831f2512c89ca512ddc69d215d28dc3..f93abaa5c84ab807f743aa252413380298ed2b3e 100644 (file)
@@ -283,7 +283,12 @@ NineBuffer9_Lock( struct NineBuffer9 *This,
     else if (Flags & D3DLOCK_NOOVERWRITE)
         usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_UNSYNCHRONIZED;
     else
-        usage = PIPE_TRANSFER_READ_WRITE;
+        /* Do not ask for READ if writeonly and default pool (should be safe enough,
+         * as the doc says app shouldn't expect reading to work with writeonly).
+         * Ignore for Systemmem as it has special behaviours. */
+        usage = ((This->base.usage & D3DUSAGE_WRITEONLY) && This->base.pool == D3DPOOL_DEFAULT) ?
+            PIPE_TRANSFER_WRITE :
+            PIPE_TRANSFER_READ_WRITE;
     if (Flags & D3DLOCK_DONOTWAIT && !(This->base.usage & D3DUSAGE_DYNAMIC))
         usage |= PIPE_TRANSFER_DONTBLOCK;