wined3d: Filter redundant WINED3D_MAP_DISCARD buffer maps.

This commit is contained in:
Henri Verbeet 2014-03-04 10:21:33 +01:00 committed by Alexandre Julliard
parent 9f9fb6b7f1
commit c1032e977b
4 changed files with 16 additions and 31 deletions

View File

@ -543,8 +543,6 @@ struct d3d_vertex_buffer
DWORD fvf;
DWORD size;
BOOL dynamic;
BOOL read_since_last_map;
};
HRESULT d3d_vertex_buffer_create(struct d3d_vertex_buffer **buffer, struct ddraw *ddraw,

View File

@ -4268,9 +4268,6 @@ static HRESULT d3d_device7_DrawPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVE
wined3d_device_set_primitive_type(device->wined3d_device, PrimitiveType);
hr = wined3d_device_draw_primitive(device->wined3d_device, StartVertex, NumVertices);
if (SUCCEEDED(hr))
vb->read_since_last_map = TRUE;
wined3d_mutex_unlock();
return hr;
@ -4396,9 +4393,6 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
hr = wined3d_device_draw_indexed_primitive(This->wined3d_device, ib_pos / sizeof(WORD), IndexCount);
if (SUCCEEDED(hr))
vb->read_since_last_map = TRUE;
wined3d_mutex_unlock();
return hr;

View File

@ -245,7 +245,7 @@ static HRESULT WINAPI d3d_vertex_buffer7_Lock(IDirect3DVertexBuffer7 *iface,
wined3d_flags |= WINED3D_MAP_READONLY;
if (flags & DDLOCK_NOOVERWRITE)
wined3d_flags |= WINED3D_MAP_NOOVERWRITE;
if (flags & DDLOCK_DISCARDCONTENTS && buffer->read_since_last_map)
if (flags & DDLOCK_DISCARDCONTENTS)
{
wined3d_flags |= WINED3D_MAP_DISCARD;
@ -279,9 +279,6 @@ static HRESULT WINAPI d3d_vertex_buffer7_Lock(IDirect3DVertexBuffer7 *iface,
hr = wined3d_buffer_map(buffer->wineD3DVertexBuffer, 0, 0, (BYTE **)data, wined3d_flags);
if (SUCCEEDED(hr))
buffer->read_since_last_map = FALSE;
wined3d_mutex_unlock();
return hr;

View File

@ -944,13 +944,20 @@ struct wined3d_resource * CDECL wined3d_buffer_get_resource(struct wined3d_buffe
HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UINT size, BYTE **data, DWORD flags)
{
BOOL dirty = buffer_is_dirty(buffer);
LONG count;
BYTE *base;
TRACE("buffer %p, offset %u, size %u, data %p, flags %#x\n", buffer, offset, size, data, flags);
flags = wined3d_resource_sanitize_map_flags(&buffer->resource, 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)
@ -1026,25 +1033,14 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
context_release(context);
}
}
else
{
if (dirty)
{
if (buffer->flags & WINED3D_BUFFER_NOSYNC && !(flags & WINED3D_MAP_NOOVERWRITE))
{
buffer->flags &= ~WINED3D_BUFFER_NOSYNC;
}
}
else if(flags & WINED3D_MAP_NOOVERWRITE)
{
buffer->flags |= WINED3D_BUFFER_NOSYNC;
}
if (flags & WINED3D_MAP_DISCARD)
{
buffer->flags |= WINED3D_BUFFER_DISCARD;
}
}
if (flags & WINED3D_MAP_DISCARD)
buffer->flags |= WINED3D_BUFFER_DISCARD;
if (!(flags & WINED3D_MAP_NOOVERWRITE))
buffer->flags &= ~WINED3D_BUFFER_NOSYNC;
else if (!buffer_is_dirty(buffer))
buffer->flags |= WINED3D_BUFFER_NOSYNC;
}
base = buffer->map_ptr ? buffer->map_ptr : buffer->resource.heap_memory;