wined3d: Don't enumerate sub-resources in wined3d_device_reset().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2016-04-20 19:29:13 +02:00 committed by Alexandre Julliard
parent 3b96ac290d
commit 58a1796d83
11 changed files with 79 additions and 89 deletions

View File

@ -613,44 +613,34 @@ static HRESULT WINAPI d3d8_device_CreateAdditionalSwapChain(IDirect3DDevice8 *if
static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource) static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
{ {
struct wined3d_resource_desc desc; struct wined3d_resource_desc desc;
IDirect3DBaseTexture8 *texture;
struct d3d8_surface *surface;
IUnknown *parent;
wined3d_resource_get_desc(resource, &desc); wined3d_resource_get_desc(resource, &desc);
if (desc.pool == WINED3D_POOL_DEFAULT) if (desc.pool != WINED3D_POOL_DEFAULT)
return D3D_OK;
if (desc.resource_type != WINED3D_RTYPE_TEXTURE_2D)
{ {
struct d3d8_surface *surface; WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource);
return D3DERR_DEVICELOST;
if (desc.resource_type == WINED3D_RTYPE_TEXTURE_2D)
{
IUnknown *parent = wined3d_resource_get_parent(resource);
IDirect3DBaseTexture8 *texture;
if (SUCCEEDED(IUnknown_QueryInterface(parent, &IID_IDirect3DBaseTexture8, (void **)&texture)))
{
IDirect3DBaseTexture8_Release(texture);
WARN("Texture %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", texture, resource);
return D3DERR_DEVICELOST;
}
return D3D_OK;
}
if (desc.resource_type != WINED3D_RTYPE_SURFACE)
{
WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource);
return D3DERR_DEVICELOST;
}
surface = wined3d_resource_get_parent(resource);
if (surface->resource.refcount)
{
WARN("Surface %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface, resource);
return D3DERR_DEVICELOST;
}
WARN("Surface %p (resource %p) is an implicit resource with ref 0.\n", surface, resource);
} }
return D3D_OK; parent = wined3d_resource_get_parent(resource);
if (parent && SUCCEEDED(IUnknown_QueryInterface(parent, &IID_IDirect3DBaseTexture8, (void **)&texture)))
{
IDirect3DBaseTexture8_Release(texture);
WARN("Texture %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", texture, resource);
return D3DERR_DEVICELOST;
}
surface = wined3d_texture_get_sub_resource_parent(wined3d_texture_from_resource(resource), 0);
if (!surface->resource.refcount)
return D3D_OK;
WARN("Surface %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface);
return D3DERR_DEVICELOST;
} }
static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface, static HRESULT WINAPI d3d8_device_Reset(IDirect3DDevice8 *iface,

View File

@ -605,44 +605,34 @@ static UINT WINAPI d3d9_device_GetNumberOfSwapChains(IDirect3DDevice9Ex *iface)
static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource) static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
{ {
struct wined3d_resource_desc desc; struct wined3d_resource_desc desc;
IDirect3DBaseTexture9 *texture;
struct d3d9_surface *surface;
IUnknown *parent;
wined3d_resource_get_desc(resource, &desc); wined3d_resource_get_desc(resource, &desc);
if (desc.pool == WINED3D_POOL_DEFAULT) if (desc.pool != WINED3D_POOL_DEFAULT)
return D3D_OK;
if (desc.resource_type != WINED3D_RTYPE_TEXTURE_2D)
{ {
struct d3d9_surface *surface; WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource);
return D3DERR_INVALIDCALL;
if (desc.resource_type == WINED3D_RTYPE_TEXTURE_2D)
{
IUnknown *parent = wined3d_resource_get_parent(resource);
IDirect3DBaseTexture9 *texture;
if (SUCCEEDED(IUnknown_QueryInterface(parent, &IID_IDirect3DBaseTexture9, (void **)&texture)))
{
IDirect3DBaseTexture9_Release(texture);
WARN("Texture %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", texture, resource);
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
if (desc.resource_type != WINED3D_RTYPE_SURFACE)
{
WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource);
return D3DERR_INVALIDCALL;
}
surface = wined3d_resource_get_parent(resource);
if (surface->resource.refcount)
{
WARN("Surface %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface, resource);
return D3DERR_INVALIDCALL;
}
WARN("Surface %p (resource %p) is an implicit resource with ref 0.\n", surface, resource);
} }
return D3D_OK; parent = wined3d_resource_get_parent(resource);
if (parent && SUCCEEDED(IUnknown_QueryInterface(parent, &IID_IDirect3DBaseTexture9, (void **)&texture)))
{
IDirect3DBaseTexture9_Release(texture);
WARN("Texture %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", texture, resource);
return D3DERR_INVALIDCALL;
}
surface = wined3d_texture_get_sub_resource_parent(wined3d_texture_from_resource(resource), 0);
if (!surface->resource.refcount)
return D3D_OK;
WARN("Surface %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface);
return D3DERR_INVALIDCALL;
} }
static HRESULT d3d9_device_get_swapchains(struct d3d9_device *device) static HRESULT d3d9_device_get_swapchains(struct d3d9_device *device)

View File

@ -353,7 +353,7 @@ static inline DWORD context_generate_rt_mask_from_resource(struct wined3d_resour
return 0; return 0;
} }
return (1u << 31) | wined3d_texture_get_gl_buffer(wined3d_texture_from_resource(resource)); return (1u << 31) | wined3d_texture_get_gl_buffer(texture_from_resource(resource));
} }
static inline void context_set_fbo_key_for_surface(const struct wined3d_context *context, static inline void context_set_fbo_key_for_surface(const struct wined3d_context *context,
@ -884,7 +884,7 @@ void context_resource_released(const struct wined3d_device *device,
{ {
case WINED3D_RTYPE_TEXTURE_2D: case WINED3D_RTYPE_TEXTURE_2D:
case WINED3D_RTYPE_TEXTURE_3D: case WINED3D_RTYPE_TEXTURE_3D:
texture = wined3d_texture_from_resource(resource); texture = texture_from_resource(resource);
for (i = 0; i < device->context_count; ++i) for (i = 0; i < device->context_count; ++i)
{ {
@ -3265,7 +3265,7 @@ static void context_load_shader_resources(struct wined3d_context *context, const
if (view->resource->type == WINED3D_RTYPE_BUFFER) if (view->resource->type == WINED3D_RTYPE_BUFFER)
buffer_internal_preload(buffer_from_resource(view->resource), context, state); buffer_internal_preload(buffer_from_resource(view->resource), context, state);
else else
wined3d_texture_load(wined3d_texture_from_resource(view->resource), context, FALSE); wined3d_texture_load(texture_from_resource(view->resource), context, FALSE);
} }
} }
} }
@ -3337,7 +3337,7 @@ static void context_bind_shader_resources(struct wined3d_context *context, const
continue; continue;
} }
texture = wined3d_texture_from_resource(view->resource); texture = texture_from_resource(view->resource);
context_active_texture(context, gl_info, shader_types[i].base_idx + entry->bind_idx); context_active_texture(context, gl_info, shader_types[i].base_idx + entry->bind_idx);
wined3d_texture_bind(texture, context, FALSE); wined3d_texture_bind(texture, context, FALSE);

View File

@ -413,7 +413,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
continue; continue;
} }
texture = wined3d_texture_from_resource(rtv->resource); texture = texture_from_resource(rtv->resource);
wined3d_texture_validate_location(texture, rtv->sub_resource_idx, rtv->resource->draw_binding); wined3d_texture_validate_location(texture, rtv->sub_resource_idx, rtv->resource->draw_binding);
wined3d_texture_invalidate_location(texture, rtv->sub_resource_idx, ~rtv->resource->draw_binding); wined3d_texture_invalidate_location(texture, rtv->sub_resource_idx, ~rtv->resource->draw_binding);
} }
@ -2039,7 +2039,7 @@ static void resolve_depth_buffer(struct wined3d_state *state)
SetRect(&dst_rect, 0, 0, dst_texture->resource.width, dst_texture->resource.height); SetRect(&dst_rect, 0, 0, dst_texture->resource.width, dst_texture->resource.height);
SetRect(&src_rect, 0, 0, src_view->width, src_view->height); SetRect(&src_rect, 0, 0, src_view->width, src_view->height);
wined3d_texture_blt(dst_texture, 0, &dst_rect, wined3d_texture_from_resource(src_view->resource), wined3d_texture_blt(dst_texture, 0, &dst_rect, texture_from_resource(src_view->resource),
src_view->sub_resource_idx, &src_rect, 0, NULL, WINED3D_TEXF_POINT); src_view->sub_resource_idx, &src_rect, 0, NULL, WINED3D_TEXF_POINT);
} }
@ -3913,8 +3913,8 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
return; return;
} }
dst_texture = wined3d_texture_from_resource(dst_resource); dst_texture = texture_from_resource(dst_resource);
src_texture = wined3d_texture_from_resource(src_resource); src_texture = texture_from_resource(src_resource);
if (src_texture->layer_count != dst_texture->layer_count if (src_texture->layer_count != dst_texture->layer_count
|| src_texture->level_count != dst_texture->level_count) || src_texture->level_count != dst_texture->level_count)
@ -4034,8 +4034,8 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
dst_texture = wined3d_texture_from_resource(dst_resource); dst_texture = texture_from_resource(dst_resource);
src_texture = wined3d_texture_from_resource(src_resource); src_texture = texture_from_resource(src_resource);
if (src_box) if (src_box)
{ {
@ -4099,7 +4099,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
return; return;
} }
texture = wined3d_texture_from_resource(resource); texture = texture_from_resource(resource);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx))) if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
{ {
WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx); WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx);
@ -4695,6 +4695,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
{ {
LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry) LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry)
{ {
if (resource->type == WINED3D_RTYPE_SURFACE || resource->type == WINED3D_RTYPE_VOLUME)
continue;
TRACE("Enumerating resource %p.\n", resource); TRACE("Enumerating resource %p.\n", resource);
if (FAILED(hr = callback(resource))) if (FAILED(hr = callback(resource)))
return hr; return hr;
@ -5037,7 +5040,7 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso
case WINED3D_RTYPE_TEXTURE_3D: case WINED3D_RTYPE_TEXTURE_3D:
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{ {
struct wined3d_texture *texture = wined3d_texture_from_resource(resource); struct wined3d_texture *texture = texture_from_resource(resource);
if (device->state.textures[i] == texture) if (device->state.textures[i] == texture)
{ {

View File

@ -414,7 +414,7 @@ BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
return TRUE; return TRUE;
/* Not on a swapchain - must be offscreen */ /* Not on a swapchain - must be offscreen */
if (!(swapchain = wined3d_texture_from_resource(resource)->swapchain)) if (!(swapchain = texture_from_resource(resource)->swapchain))
return TRUE; return TRUE;
/* The front buffer is always onscreen */ /* The front buffer is always onscreen */

View File

@ -3945,7 +3945,7 @@ static HRESULT cpu_blit_color_fill(struct wined3d_device *device, struct wined3d
struct wined3d_blt_fx fx; struct wined3d_blt_fx fx;
fx.fill_color = wined3d_format_convert_from_float(view->format, color); fx.fill_color = wined3d_format_convert_from_float(view->format, color);
return surface_cpu_blt(wined3d_texture_from_resource(view->resource), view->sub_resource_idx, return surface_cpu_blt(texture_from_resource(view->resource), view->sub_resource_idx,
&box, NULL, 0, &src_box, WINED3D_BLT_COLOR_FILL, &fx, WINED3D_TEXF_POINT); &box, NULL, 0, &src_box, WINED3D_BLT_COLOR_FILL, &fx, WINED3D_TEXF_POINT);
} }

View File

@ -1447,19 +1447,24 @@ static const struct wined3d_texture_ops texture2d_ops =
texture2d_cleanup_sub_resources, texture2d_cleanup_sub_resources,
}; };
struct wined3d_texture * __cdecl wined3d_texture_from_resource(struct wined3d_resource *resource)
{
return texture_from_resource(resource);
}
static ULONG texture_resource_incref(struct wined3d_resource *resource) static ULONG texture_resource_incref(struct wined3d_resource *resource)
{ {
return wined3d_texture_incref(wined3d_texture_from_resource(resource)); return wined3d_texture_incref(texture_from_resource(resource));
} }
static ULONG texture_resource_decref(struct wined3d_resource *resource) static ULONG texture_resource_decref(struct wined3d_resource *resource)
{ {
return wined3d_texture_decref(wined3d_texture_from_resource(resource)); return wined3d_texture_decref(texture_from_resource(resource));
} }
static void wined3d_texture_unload(struct wined3d_resource *resource) static void wined3d_texture_unload(struct wined3d_resource *resource)
{ {
struct wined3d_texture *texture = wined3d_texture_from_resource(resource); struct wined3d_texture *texture = texture_from_resource(resource);
UINT sub_count = texture->level_count * texture->layer_count; UINT sub_count = texture->level_count * texture->layer_count;
struct wined3d_device *device = resource->device; struct wined3d_device *device = resource->device;
const struct wined3d_gl_info *gl_info; const struct wined3d_gl_info *gl_info;
@ -1537,7 +1542,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n", TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
resource, sub_resource_idx, map_desc, debug_box(box), flags); resource, sub_resource_idx, map_desc, debug_box(box), flags);
texture = wined3d_texture_from_resource(resource); texture = texture_from_resource(resource);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx))) if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
return E_INVALIDARG; return E_INVALIDARG;
@ -1684,7 +1689,7 @@ static HRESULT texture_resource_sub_resource_unmap(struct wined3d_resource *reso
TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx); TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx);
texture = wined3d_texture_from_resource(resource); texture = texture_from_resource(resource);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx))) if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
return E_INVALIDARG; return E_INVALIDARG;

View File

@ -67,7 +67,7 @@ void * CDECL wined3d_rendertarget_view_get_sub_resource_parent(const struct wine
if (view->resource->type == WINED3D_RTYPE_BUFFER) if (view->resource->type == WINED3D_RTYPE_BUFFER)
return wined3d_buffer_get_parent(buffer_from_resource(view->resource)); return wined3d_buffer_get_parent(buffer_from_resource(view->resource));
texture = wined3d_texture_from_resource(view->resource); texture = texture_from_resource(view->resource);
return wined3d_resource_get_parent(texture->sub_resources[view->sub_resource_idx].resource); return wined3d_resource_get_parent(texture->sub_resources[view->sub_resource_idx].resource);
} }
@ -108,7 +108,7 @@ static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *
} }
else else
{ {
struct wined3d_texture *texture = wined3d_texture_from_resource(resource); struct wined3d_texture *texture = texture_from_resource(resource);
if (desc->u.texture.level_idx >= texture->level_count if (desc->u.texture.level_idx >= texture->level_count
|| desc->u.texture.layer_idx >= texture->layer_count || desc->u.texture.layer_idx >= texture->layer_count

View File

@ -243,6 +243,7 @@
@ cdecl wined3d_texture_blt(ptr long ptr ptr long ptr long ptr long) @ cdecl wined3d_texture_blt(ptr long ptr ptr long ptr long ptr long)
@ cdecl wined3d_texture_create(ptr ptr long long ptr ptr ptr ptr) @ cdecl wined3d_texture_create(ptr ptr long long ptr ptr ptr ptr)
@ cdecl wined3d_texture_decref(ptr) @ cdecl wined3d_texture_decref(ptr)
@ cdecl wined3d_texture_from_resource(ptr)
@ cdecl wined3d_texture_generate_mipmaps(ptr) @ cdecl wined3d_texture_generate_mipmaps(ptr)
@ cdecl wined3d_texture_get_autogen_filter_type(ptr) @ cdecl wined3d_texture_get_autogen_filter_type(ptr)
@ cdecl wined3d_texture_get_dc(ptr long ptr) @ cdecl wined3d_texture_get_dc(ptr long ptr)

View File

@ -2514,7 +2514,7 @@ struct wined3d_texture
} sub_resources[1]; } sub_resources[1];
}; };
static inline struct wined3d_texture *wined3d_texture_from_resource(struct wined3d_resource *resource) static inline struct wined3d_texture *texture_from_resource(struct wined3d_resource *resource)
{ {
return CONTAINING_RECORD(resource, struct wined3d_texture, resource); return CONTAINING_RECORD(resource, struct wined3d_texture, resource);
} }
@ -3027,7 +3027,7 @@ static inline struct wined3d_surface *wined3d_rendertarget_view_get_surface(
if (!view || view->resource->type != WINED3D_RTYPE_TEXTURE_2D) if (!view || view->resource->type != WINED3D_RTYPE_TEXTURE_2D)
return NULL; return NULL;
texture = wined3d_texture_from_resource(view->resource); texture = texture_from_resource(view->resource);
return texture->sub_resources[view->sub_resource_idx].u.surface; return texture->sub_resources[view->sub_resource_idx].u.surface;
} }

View File

@ -2450,6 +2450,7 @@ HRESULT __cdecl wined3d_texture_blt(struct wined3d_texture *dst_texture, unsigne
HRESULT __cdecl wined3d_texture_create(struct wined3d_device *device, const struct wined3d_resource_desc *desc, HRESULT __cdecl wined3d_texture_create(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
UINT level_count, DWORD flags, const struct wined3d_sub_resource_data *data, void *parent, UINT level_count, DWORD flags, const struct wined3d_sub_resource_data *data, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture); const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
struct wined3d_texture * __cdecl wined3d_texture_from_resource(struct wined3d_resource *resource);
ULONG __cdecl wined3d_texture_decref(struct wined3d_texture *texture); ULONG __cdecl wined3d_texture_decref(struct wined3d_texture *texture);
void __cdecl wined3d_texture_generate_mipmaps(struct wined3d_texture *texture); void __cdecl wined3d_texture_generate_mipmaps(struct wined3d_texture *texture);
enum wined3d_texture_filter_type __cdecl wined3d_texture_get_autogen_filter_type(const struct wined3d_texture *texture); enum wined3d_texture_filter_type __cdecl wined3d_texture_get_autogen_filter_type(const struct wined3d_texture *texture);