wined3d: Send texture destruction through the command stream.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
229616a5fa
commit
1184237640
|
@ -468,6 +468,24 @@ static void wined3d_texture_unload_gl_texture(struct wined3d_texture *texture)
|
|||
resource_unload(&texture->resource);
|
||||
}
|
||||
|
||||
static void wined3d_texture_sub_resources_destroyed(struct wined3d_texture *texture)
|
||||
{
|
||||
unsigned int sub_count = texture->level_count * texture->layer_count;
|
||||
struct wined3d_texture_sub_resource *sub_resource;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sub_count; ++i)
|
||||
{
|
||||
sub_resource = &texture->sub_resources[i];
|
||||
if (sub_resource->parent)
|
||||
{
|
||||
TRACE("sub-resource %u.\n", i);
|
||||
sub_resource->parent_ops->wined3d_object_destroyed(sub_resource->parent);
|
||||
sub_resource->parent = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void wined3d_texture_cleanup(struct wined3d_texture *texture)
|
||||
{
|
||||
unsigned int sub_count = texture->level_count * texture->layer_count;
|
||||
|
@ -499,19 +517,8 @@ static void wined3d_texture_cleanup(struct wined3d_texture *texture)
|
|||
if (context)
|
||||
context_release(context);
|
||||
|
||||
for (i = 0; i < sub_count; ++i)
|
||||
{
|
||||
struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[i];
|
||||
if (sub_resource->parent)
|
||||
{
|
||||
TRACE("sub-resource %u.\n", i);
|
||||
sub_resource->parent_ops->wined3d_object_destroyed(sub_resource->parent);
|
||||
}
|
||||
}
|
||||
|
||||
texture->texture_ops->texture_cleanup_sub_resources(texture);
|
||||
wined3d_texture_unload_gl_texture(texture);
|
||||
resource_cleanup(&texture->resource);
|
||||
}
|
||||
|
||||
void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined3d_swapchain *swapchain)
|
||||
|
@ -805,6 +812,19 @@ ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture)
|
|||
return refcount;
|
||||
}
|
||||
|
||||
static void wined3d_texture_cleanup_sync(struct wined3d_texture *texture)
|
||||
{
|
||||
wined3d_texture_sub_resources_destroyed(texture);
|
||||
resource_cleanup(&texture->resource);
|
||||
wined3d_texture_cleanup(texture);
|
||||
}
|
||||
|
||||
static void wined3d_texture_destroy_object(void *object)
|
||||
{
|
||||
wined3d_texture_cleanup(object);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
}
|
||||
|
||||
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
|
||||
{
|
||||
ULONG refcount;
|
||||
|
@ -819,9 +839,10 @@ ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
|
|||
|
||||
if (!refcount)
|
||||
{
|
||||
wined3d_texture_cleanup(texture);
|
||||
wined3d_texture_sub_resources_destroyed(texture);
|
||||
texture->resource.parent_ops->wined3d_object_destroyed(texture->resource.parent);
|
||||
HeapFree(GetProcessHeap(), 0, texture);
|
||||
resource_cleanup(&texture->resource);
|
||||
wined3d_cs_emit_destroy_object(texture->resource.device->cs, wined3d_texture_destroy_object, texture);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -1993,7 +2014,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
|
|||
if (level_count > ~(SIZE_T)0 / layer_count
|
||||
|| !(surfaces = wined3d_calloc(level_count * layer_count, sizeof(*surfaces))))
|
||||
{
|
||||
wined3d_texture_cleanup(texture);
|
||||
wined3d_texture_cleanup_sync(texture);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
@ -2037,7 +2058,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
|
|||
{
|
||||
WARN("Failed to create surface parent, hr %#x.\n", hr);
|
||||
sub_resource->parent = NULL;
|
||||
wined3d_texture_cleanup(texture);
|
||||
wined3d_texture_cleanup_sync(texture);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -2048,7 +2069,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
|
|||
if (((desc->usage & WINED3DUSAGE_OWNDC) || (device->wined3d->flags & WINED3D_NO3D))
|
||||
&& FAILED(hr = wined3d_surface_create_dc(surface)))
|
||||
{
|
||||
wined3d_texture_cleanup(texture);
|
||||
wined3d_texture_cleanup_sync(texture);
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
@ -2257,7 +2278,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
|
|||
|
||||
if (!(volumes = wined3d_calloc(level_count, sizeof(*volumes))))
|
||||
{
|
||||
wined3d_texture_cleanup(texture);
|
||||
wined3d_texture_cleanup_sync(texture);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
@ -2280,7 +2301,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
|
|||
{
|
||||
WARN("Failed to create volume parent, hr %#x.\n", hr);
|
||||
sub_resource->parent = NULL;
|
||||
wined3d_texture_cleanup(texture);
|
||||
wined3d_texture_cleanup_sync(texture);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -2585,7 +2606,7 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
|
|||
* in this case. */
|
||||
if (data && FAILED(hr = wined3d_texture_upload_data(object, data)))
|
||||
{
|
||||
wined3d_texture_cleanup(object);
|
||||
wined3d_texture_cleanup_sync(object);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
return hr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue