[PATCH 1/5] wined3d: Only drop WINED3D_MAP_DISCARD right before mapping the buffer object in wined3d_buffer_map().

Henri Verbeet hverbeet at codeweavers.com
Wed Mar 29 16:17:27 CDT 2017


Dropping WINED3D_MAP_DISCARD too early means we go through the system memory
path unnecessarily. Worse, as mentioned in an earlier comment, Darkstar One
depends on the entire buffer being uploaded in case of WINED3D_MAP_DISCARD
maps, and dropping the flag too early prevents that as well. This fixes a
regression introduced by commit 15d53761a5fbfc12fc5f9974c029dace00eab33d.

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/buffer.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 4e8569c..cb3cbbd 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1004,14 +1004,6 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
 
     TRACE("buffer %p, offset %u, size %u, data %p, flags %#x.\n", buffer, offset, size, data, flags);
 
-    /* Filter redundant WINED3D_MAP_DISCARD maps. The 3DMark2001 multitexture
-     * fill rate test seems to depend on this. When we map a buffer with
-     * GL_MAP_INVALIDATE_BUFFER_BIT, the driver is free to discard the
-     * previous contents of the buffer. The r600g driver only does this when
-     * the buffer is currently in use, while the proprietary NVIDIA driver
-     * appears to do this unconditionally. */
-    if (buffer->flags & WINED3D_BUFFER_DISCARD)
-        flags &= ~WINED3D_MAP_DISCARD;
     count = ++buffer->resource.map_count;
 
     if (buffer->buffer_object)
@@ -1064,6 +1056,16 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
             {
                 buffer_bind(buffer, context);
 
+                /* Filter redundant WINED3D_MAP_DISCARD maps. The 3DMark2001
+                 * multitexture fill rate test seems to depend on this. When
+                 * we map a buffer with GL_MAP_INVALIDATE_BUFFER_BIT, the
+                 * driver is free to discard the previous contents of the
+                 * buffer. The r600g driver only does this when the buffer is
+                 * currently in use, while the proprietary NVIDIA driver
+                 * appears to do this unconditionally. */
+                if (buffer->flags & WINED3D_BUFFER_DISCARD)
+                    flags &= ~WINED3D_MAP_DISCARD;
+
                 if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
                 {
                     GLbitfield mapflags = wined3d_resource_gl_map_flags(flags);
-- 
2.1.4




More information about the wine-patches mailing list