wined3d: Try to avoid allocating sysmem for GPU buffers with initial data.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-09-06 22:02:00 +02:00 committed by Alexandre Julliard
parent 8abb76f4b1
commit eec2f1db5d
1 changed files with 7 additions and 3 deletions

View File

@ -1379,9 +1379,6 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
buffer->bind_flags = bind_flags;
buffer->locations = data ? WINED3D_LOCATION_DISCARDED : WINED3D_LOCATION_SYSMEM;
if (!wined3d_resource_allocate_sysmem(&buffer->resource))
return E_OUTOFMEMORY;
TRACE("buffer %p, size %#x, usage %#x, format %s, memory @ %p.\n",
buffer, buffer->resource.size, buffer->resource.usage,
debug_d3dformat(buffer->resource.format->id), buffer->resource.heap_memory);
@ -1394,6 +1391,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
* the buffer to provide the same behavior to the application. */
TRACE("Pinning system memory.\n");
buffer->flags |= WINED3D_BUFFER_PIN_SYSMEM;
buffer->locations = WINED3D_LOCATION_SYSMEM;
}
/* Observations show that draw_primitive_immediate_mode() is faster on
@ -1418,6 +1416,12 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
buffer->flags |= WINED3D_BUFFER_USE_BO;
}
if (buffer->locations & WINED3D_LOCATION_SYSMEM || !(buffer->flags & WINED3D_BUFFER_USE_BO))
{
if (!wined3d_resource_allocate_sysmem(&buffer->resource))
return E_OUTOFMEMORY;
}
if (!(buffer->maps = heap_alloc(sizeof(*buffer->maps))))
{
ERR("Out of memory.\n");