wined3d: Only drop WINED3D_MAP_DISCARD right before mapping the buffer object in wined3d_buffer_map().

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 15d53761a5.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2017-03-29 23:17:27 +02:00 committed by Alexandre Julliard
parent 4bfa0d829f
commit cd4223b0a4
1 changed files with 10 additions and 8 deletions

View File

@ -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); 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; count = ++buffer->resource.map_count;
if (buffer->buffer_object) if (buffer->buffer_object)
@ -1064,6 +1056,16 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
{ {
buffer_bind(buffer, context); 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]) if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
{ {
GLbitfield mapflags = wined3d_resource_gl_map_flags(flags); GLbitfield mapflags = wined3d_resource_gl_map_flags(flags);