wined3d: Do not allocate system memory for resources by default.

Avoids allocating system memory for depth/stencil and 3D textures.

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-04-10 12:29:55 +02:00 committed by Alexandre Julliard
parent 6c42e742b3
commit 409f32ffa3
3 changed files with 18 additions and 18 deletions

View File

@ -615,10 +615,7 @@ static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
return TRUE;
if (!wined3d_resource_allocate_sysmem(&buffer->resource))
{
ERR("Failed to allocate system memory.\n");
return FALSE;
}
return TRUE;
case WINED3D_LOCATION_BUFFER:
@ -1359,6 +1356,9 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
buffer->bind_flags = bind_flags;
buffer->locations = 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);

View File

@ -191,12 +191,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
resource->parent_ops = parent_ops;
resource->resource_ops = resource_ops;
resource->map_binding = WINED3D_LOCATION_SYSMEM;
if (!wined3d_resource_allocate_sysmem(resource))
{
ERR("Failed to allocate system memory.\n");
return E_OUTOFMEMORY;
}
resource->heap_memory = NULL;
if (!(usage & WINED3DUSAGE_PRIVATE))
{
@ -205,8 +200,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
{
if (size > wined3d_device_get_available_texture_mem(device))
{
ERR("Out of adapter memory\n");
wined3d_resource_free_sysmem(resource);
ERR("Out of adapter memory.\n");
return WINED3DERR_OUTOFVIDEOMEMORY;
}
adapter_adjust_memory(device->adapter, size);
@ -383,7 +377,10 @@ BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
void *mem;
if (!(mem = heap_alloc_zero(resource->size + align)))
{
ERR("Failed to allocate system memory.\n");
return FALSE;
}
p = (void **)(((ULONG_PTR)mem + align) & ~(RESOURCE_ALIGNMENT - 1)) - 1;
*p = mem;

View File

@ -1683,10 +1683,7 @@ BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned
return TRUE;
if (!wined3d_resource_allocate_sysmem(&texture->resource))
{
ERR("Failed to allocate system memory.\n");
return FALSE;
}
return TRUE;
case WINED3D_LOCATION_USER_MEMORY:
@ -2674,11 +2671,17 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
TRACE("x scale %.8e, y scale %.8e.\n", texture->pow2_matrix[0], texture->pow2_matrix[5]);
if (wined3d_texture_use_pbo(texture, gl_info))
{
if (desc->resource_type == WINED3D_RTYPE_TEXTURE_3D
|| (texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL))
wined3d_resource_free_sysmem(&texture->resource);
texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
if ((desc->resource_type != WINED3D_RTYPE_TEXTURE_3D
&& !(texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL))
|| !wined3d_texture_use_pbo(texture, gl_info))
{
if (!wined3d_resource_allocate_sysmem(&texture->resource))
{
wined3d_texture_cleanup_sync(texture);
return E_OUTOFMEMORY;
}
}
sub_count = level_count * layer_count;