From 805cedd2077782be329b53bbe8a986301b28d0d6 Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Sat, 27 Mar 2021 22:33:06 +0100 Subject: [PATCH] st/nine: Have NOOVERWRITE win over DISCARD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I held for a long time the belief DISCARD wins over NOOVERWRITE, backed by experiments. But probably both behaviours are ok. For perf it is better to have NOOVERWRITE win. Signed-off-by: Axel Davy Acked-by: Timur Kristóf Part-of: --- src/gallium/frontends/nine/buffer9.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/nine/buffer9.c b/src/gallium/frontends/nine/buffer9.c index 0cdc6185d41..54f93c6c537 100644 --- a/src/gallium/frontends/nine/buffer9.c +++ b/src/gallium/frontends/nine/buffer9.c @@ -338,8 +338,15 @@ NineBuffer9_Lock( struct NineBuffer9 *This, * Our tests: On win 7 nvidia, D3DLOCK_DONOTWAIT does return * D3DERR_WASSTILLDRAWING if the resource is in use, except for DYNAMIC. * Our tests: some apps do use both DISCARD and NOOVERWRITE at the same - * time. On windows it seems to return different pointer, thus indicating - * DISCARD is taken into account. */ + * time. On windows it seems to return different pointer in some conditions, + * creation flags and drivers. However these tests indicate having + * NOOVERWRITE win is a valid behaviour (NVidia). + */ + + /* Have NOOVERWRITE win over DISCARD. This is allowed (see above) and + * it prevents overconsuming buffers if apps do use both at the same time. */ + if ((Flags & (D3DLOCK_DISCARD | D3DLOCK_NOOVERWRITE)) == (D3DLOCK_DISCARD | D3DLOCK_NOOVERWRITE)) + Flags &= ~D3DLOCK_DISCARD; if (Flags & D3DLOCK_DISCARD) usage = PIPE_MAP_WRITE | PIPE_MAP_DISCARD_WHOLE_RESOURCE;