diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index ddd2d8386ac..121a8eea0fc 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1162,9 +1162,6 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) /* Unload resources */ 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("Unloading resource %p.\n", resource); resource->resource_ops->resource_unload(resource); } @@ -4531,10 +4528,6 @@ void CDECL wined3d_device_evict_managed_resources(struct wined3d_device *device) { TRACE("Checking resource %p for eviction.\n", resource); - /* These are handled by the texture they're part of. */ - if (resource->type == WINED3D_RTYPE_SURFACE || resource->type == WINED3D_RTYPE_VOLUME) - continue; - if (resource->pool == WINED3D_POOL_MANAGED && !resource->map_count) { TRACE("Evicting %p.\n", resource); @@ -4558,9 +4551,6 @@ static void delete_opengl_contexts(struct wined3d_device *device, struct wined3d 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("Unloading resource %p.\n", resource); resource->resource_ops->resource_unload(resource); } @@ -4697,9 +4687,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, { 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); if (FAILED(hr = callback(resource))) return hr; diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 1bb71821440..1ff8d43bd7d 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -4729,12 +4729,6 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad if (adapter_idx >= wined3d->adapter_count) return WINED3DERR_INVALIDCALL; - if (resource_type == WINED3D_RTYPE_SURFACE || resource_type == WINED3D_RTYPE_VOLUME) - { - WARN("Invalid resource_type %s.\n", debug_d3dresourcetype(resource_type)); - return WINED3DERR_INVALIDCALL; - } - switch (resource_type) { case WINED3D_RTYPE_TEXTURE_2D: diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 493c835b314..8463666eaea 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -36,48 +36,6 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_perf); static const DWORD surface_simple_locations = WINED3D_LOCATION_SYSMEM | WINED3D_LOCATION_USER_MEMORY | WINED3D_LOCATION_BUFFER; -void wined3d_surface_cleanup(struct wined3d_surface *surface) -{ - struct wined3d_surface *overlay, *cur; - - TRACE("surface %p.\n", surface); - - if (!list_empty(&surface->renderbuffers)) - { - struct wined3d_device *device = surface->container->resource.device; - struct wined3d_renderbuffer_entry *entry, *entry2; - const struct wined3d_gl_info *gl_info; - struct wined3d_context *context; - - context = context_acquire(device, NULL); - gl_info = context->gl_info; - - LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &surface->renderbuffers, struct wined3d_renderbuffer_entry, entry) - { - TRACE("Deleting renderbuffer %u.\n", entry->id); - context_gl_resource_released(device, entry->id, TRUE); - gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id); - HeapFree(GetProcessHeap(), 0, entry); - } - - context_release(context); - } - - if (surface->dc) - wined3d_surface_destroy_dc(surface); - - if (surface->overlay_dest) - list_remove(&surface->overlay_entry); - - LIST_FOR_EACH_ENTRY_SAFE(overlay, cur, &surface->overlays, struct wined3d_surface, overlay_entry) - { - list_remove(&overlay->overlay_entry); - overlay->overlay_dest = NULL; - } - - resource_cleanup(&surface->resource); -} - void surface_get_drawable_size(const struct wined3d_surface *surface, const struct wined3d_context *context, unsigned int *width, unsigned int *height) { @@ -794,51 +752,6 @@ static HRESULT wined3d_surface_depth_blt(struct wined3d_surface *src_surface, DW return WINED3D_OK; } -static ULONG surface_resource_incref(struct wined3d_resource *resource) -{ - struct wined3d_surface *surface = surface_from_resource(resource); - - TRACE("surface %p, container %p.\n", surface, surface->container); - - return wined3d_texture_incref(surface->container); -} - -static ULONG surface_resource_decref(struct wined3d_resource *resource) -{ - struct wined3d_surface *surface = surface_from_resource(resource); - - TRACE("surface %p, container %p.\n", surface, surface->container); - - return wined3d_texture_decref(surface->container); -} - -static void surface_unload(struct wined3d_resource *resource) -{ - ERR("Not supported on sub-resources.\n"); -} - -static HRESULT surface_resource_sub_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx, - struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) -{ - ERR("Not supported on sub-resources.\n"); - return WINED3DERR_INVALIDCALL; -} - -static HRESULT surface_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) -{ - ERR("Not supported on sub-resources.\n"); - return WINED3DERR_INVALIDCALL; -} - -static const struct wined3d_resource_ops surface_resource_ops = -{ - surface_resource_incref, - surface_resource_decref, - surface_unload, - surface_resource_sub_resource_map, - surface_resource_sub_resource_unmap, -}; - /* This call just downloads data, the caller is responsible for binding the * correct texture. */ /* Context activation is done by the caller. */ @@ -4309,35 +4222,6 @@ cpu: src_texture, src_sub_resource_idx, &src_box, flags, fx, filter); } -HRESULT wined3d_surface_init(struct wined3d_surface *surface, struct wined3d_texture *container, - const struct wined3d_resource_desc *desc, GLenum target, unsigned int level, unsigned int layer) -{ - struct wined3d_device *device = container->resource.device; - const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; - const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format); - UINT multisample_quality = desc->multisample_quality; - HRESULT hr; - - if (FAILED(hr = resource_init(&surface->resource, device, WINED3D_RTYPE_SURFACE, - format, desc->multisample_type, multisample_quality, desc->usage, desc->pool, desc->width, desc->height, - 1, 0, NULL, &wined3d_null_parent_ops, &surface_resource_ops))) - { - WARN("Failed to initialize resource, returning %#x.\n", hr); - return hr; - } - surface->resource.access_flags = container->resource.access_flags; - - surface->container = container; - surface->texture_target = target; - surface->texture_level = level; - surface->texture_layer = layer; - - list_init(&surface->renderbuffers); - list_init(&surface->overlays); - - return hr; -} - /* Context activation is done by the caller. Context may be NULL in * WINED3D_NO3D mode. */ void wined3d_surface_prepare(struct wined3d_surface *surface, struct wined3d_context *context, DWORD location) diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 149b5e3982c..f1896fdcc40 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1022,12 +1022,6 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT texture->resource.width = width; texture->resource.height = height; texture->resource.size = texture->slice_pitch; - - sub_resource->resource->format = format; - sub_resource->resource->multisample_type = multisample_type; - sub_resource->resource->multisample_quality = multisample_quality; - sub_resource->resource->width = width; - sub_resource->resource->height = height; sub_resource->size = texture->slice_pitch; sub_resource->locations = WINED3D_LOCATION_DISCARDED; @@ -1423,21 +1417,53 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi static void texture2d_cleanup_sub_resources(struct wined3d_texture *texture) { unsigned int sub_count = texture->level_count * texture->layer_count; + struct wined3d_device *device = texture->resource.device; struct wined3d_texture_sub_resource *sub_resource; + struct wined3d_renderbuffer_entry *entry, *entry2; + const struct wined3d_gl_info *gl_info = NULL; + struct wined3d_context *context = NULL; + struct wined3d_surface *overlay, *cur; struct wined3d_surface *surface; unsigned int i; for (i = 0; i < sub_count; ++i) { sub_resource = &texture->sub_resources[i]; - if ((surface = sub_resource->u.surface)) - { - TRACE("surface %p.\n", surface); + if (!(surface = sub_resource->u.surface)) + continue; - wined3d_surface_cleanup(surface); - sub_resource->parent_ops->wined3d_object_destroyed(sub_resource->parent); + TRACE("surface %p.\n", surface); + + if (!context && !list_empty(&surface->renderbuffers)) + { + context = context_acquire(device, NULL); + gl_info = context->gl_info; } + + LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &surface->renderbuffers, struct wined3d_renderbuffer_entry, entry) + { + TRACE("Deleting renderbuffer %u.\n", entry->id); + context_gl_resource_released(device, entry->id, TRUE); + gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id); + HeapFree(GetProcessHeap(), 0, entry); + } + + if (surface->dc) + wined3d_surface_destroy_dc(surface); + + if (surface->overlay_dest) + list_remove(&surface->overlay_entry); + + LIST_FOR_EACH_ENTRY_SAFE(overlay, cur, &surface->overlays, struct wined3d_surface, overlay_entry) + { + list_remove(&overlay->overlay_entry); + overlay->overlay_dest = NULL; + } + + sub_resource->parent_ops->wined3d_object_destroyed(sub_resource->parent); } + if (context) + context_release(context); HeapFree(GetProcessHeap(), 0, texture->sub_resources[0].u.surface); } @@ -1516,8 +1542,6 @@ static void wined3d_texture_unload(struct wined3d_resource *resource) list_init(&surface->renderbuffers); surface->current_renderbuffer = NULL; } - - resource_unload(sub_resource->resource); } context_release(context); @@ -1747,7 +1771,6 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 { struct wined3d_device_parent *device_parent = device->device_parent; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; - struct wined3d_resource_desc surface_desc; struct wined3d_surface *surfaces; UINT pow2_width, pow2_height; unsigned int i, j; @@ -1898,8 +1921,6 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 } /* Generate all the surfaces. */ - surface_desc = *desc; - surface_desc.resource_type = WINED3D_RTYPE_SURFACE; for (i = 0; i < texture->level_count; ++i) { for (j = 0; j < texture->layer_count; ++j) @@ -1913,24 +1934,20 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, }; - GLenum target = desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP ? cube_targets[j] : texture->target; struct wined3d_texture_sub_resource *sub_resource; unsigned int idx = j * texture->level_count + i; struct wined3d_surface *surface; surface = &surfaces[idx]; - if (FAILED(hr = wined3d_surface_init(surface, texture, &surface_desc, target, i, j))) - { - WARN("Failed to initialize surface, returning %#x.\n", hr); - wined3d_texture_cleanup(texture); - if (!idx) - HeapFree(GetProcessHeap(), 0, surfaces); - return hr; - } + surface->container = texture; + surface->texture_target = desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP ? cube_targets[j] : texture->target; + surface->texture_level = i; + surface->texture_layer = j; + list_init(&surface->renderbuffers); + list_init(&surface->overlays); sub_resource = &texture->sub_resources[idx]; sub_resource->locations = WINED3D_LOCATION_DISCARDED; - sub_resource->resource = &surface->resource; sub_resource->u.surface = surface; if (!(texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL)) { @@ -1942,7 +1959,6 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 texture, idx, &sub_resource->parent, &sub_resource->parent_ops))) { WARN("Failed to create surface parent, hr %#x.\n", hr); - wined3d_surface_cleanup(surface); wined3d_texture_cleanup(texture); return hr; } @@ -1958,9 +1974,6 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 return hr; } } - /* Calculate the next mipmap level. */ - surface_desc.width = max(1, surface_desc.width >> 1); - surface_desc.height = max(1, surface_desc.height >> 1); } return WINED3D_OK; @@ -2025,7 +2038,6 @@ static void texture3d_cleanup_sub_resources(struct wined3d_texture *texture) { TRACE("volume %p.\n", volume); - wined3d_volume_cleanup(volume); sub_resource->parent_ops->wined3d_object_destroyed(sub_resource->parent); } } @@ -2074,7 +2086,6 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct { struct wined3d_device_parent *device_parent = device->device_parent; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; - struct wined3d_resource_desc volume_desc; struct wined3d_volume *volumes; unsigned int i; HRESULT hr; @@ -2170,33 +2181,23 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct } /* Generate all the surfaces. */ - volume_desc = *desc; - volume_desc.resource_type = WINED3D_RTYPE_VOLUME; for (i = 0; i < texture->level_count; ++i) { struct wined3d_texture_sub_resource *sub_resource; struct wined3d_volume *volume; volume = &volumes[i]; - if (FAILED(hr = wined3d_volume_init(volume, texture, &volume_desc, i))) - { - WARN("Failed to initialize volume, returning %#x.\n", hr); - wined3d_texture_cleanup(texture); - if (!i) - HeapFree(GetProcessHeap(), 0, volumes); - return hr; - } + volume->container = texture; + volume->texture_level = i; sub_resource = &texture->sub_resources[i]; sub_resource->locations = WINED3D_LOCATION_DISCARDED; - sub_resource->resource = &volume->resource; sub_resource->u.volume = volume; if (FAILED(hr = device_parent->ops->volume_created(device_parent, texture, i, &sub_resource->parent, &sub_resource->parent_ops))) { WARN("Failed to create volume parent, hr %#x.\n", hr); - wined3d_volume_cleanup(volume); wined3d_texture_cleanup(texture); return hr; } @@ -2204,11 +2205,6 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct TRACE("parent %p, parent_ops %p.\n", parent, parent_ops); TRACE("Created volume level %u @ %p.\n", i, volume); - - /* Calculate the next mipmap level. */ - volume_desc.width = max(1, volume_desc.width >> 1); - volume_desc.height = max(1, volume_desc.height >> 1); - volume_desc.depth = max(1, volume_desc.depth >> 1); } return WINED3D_OK; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 2eca094990f..341e12be4e8 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -3656,8 +3656,6 @@ const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type) switch (resource_type) { #define WINED3D_TO_STR(x) case x: return #x - WINED3D_TO_STR(WINED3D_RTYPE_SURFACE); - WINED3D_TO_STR(WINED3D_RTYPE_VOLUME); WINED3D_TO_STR(WINED3D_RTYPE_BUFFER); WINED3D_TO_STR(WINED3D_RTYPE_TEXTURE_2D); WINED3D_TO_STR(WINED3D_RTYPE_TEXTURE_3D); diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index 41a45f18465..3106ac77c2f 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -292,75 +292,3 @@ done: return TRUE; } - -void wined3d_volume_cleanup(struct wined3d_volume *volume) -{ - TRACE("volume %p.\n", volume); - - resource_cleanup(&volume->resource); -} - -static void volume_unload(struct wined3d_resource *resource) -{ - ERR("Not supported on sub-resources.\n"); -} - -static ULONG volume_resource_incref(struct wined3d_resource *resource) -{ - struct wined3d_volume *volume = volume_from_resource(resource); - TRACE("Forwarding to container %p.\n", volume->container); - - return wined3d_texture_incref(volume->container); -} - -static ULONG volume_resource_decref(struct wined3d_resource *resource) -{ - struct wined3d_volume *volume = volume_from_resource(resource); - TRACE("Forwarding to container %p.\n", volume->container); - - return wined3d_texture_decref(volume->container); -} - -static HRESULT volume_resource_sub_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx, - struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) -{ - ERR("Not supported on sub-resources.\n"); - return WINED3DERR_INVALIDCALL; -} - -static HRESULT volume_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) -{ - ERR("Not supported on sub-resources.\n"); - return WINED3DERR_INVALIDCALL; -} - -static const struct wined3d_resource_ops volume_resource_ops = -{ - volume_resource_incref, - volume_resource_decref, - volume_unload, - volume_resource_sub_resource_map, - volume_resource_sub_resource_unmap, -}; - -HRESULT wined3d_volume_init(struct wined3d_volume *volume, struct wined3d_texture *container, - const struct wined3d_resource_desc *desc, UINT level) -{ - struct wined3d_device *device = container->resource.device; - const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; - const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format); - HRESULT hr; - - if (FAILED(hr = resource_init(&volume->resource, device, WINED3D_RTYPE_VOLUME, format, - WINED3D_MULTISAMPLE_NONE, 0, desc->usage, desc->pool, desc->width, desc->height, desc->depth, - 0, NULL, &wined3d_null_parent_ops, &volume_resource_ops))) - { - WARN("Failed to initialize resource, returning %#x.\n", hr); - return hr; - } - - volume->texture_level = level; - volume->container = container; - - return WINED3D_OK; -} diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 7863c8cb1e1..2c19e7e31e7 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2500,8 +2500,6 @@ struct wined3d_texture struct wined3d_texture_sub_resource { - struct wined3d_resource *resource; - void *parent; const struct wined3d_parent_ops *parent_ops; @@ -2606,20 +2604,11 @@ const char *wined3d_debug_location(DWORD location) DECLSPEC_HIDDEN; struct wined3d_volume { - struct wined3d_resource resource; struct wined3d_texture *container; GLint texture_level; }; -static inline struct wined3d_volume *volume_from_resource(struct wined3d_resource *resource) -{ - return CONTAINING_RECORD(resource, struct wined3d_volume, resource); -} - -void wined3d_volume_cleanup(struct wined3d_volume *volume) DECLSPEC_HIDDEN; -HRESULT wined3d_volume_init(struct wined3d_volume *volume, struct wined3d_texture *container, - const struct wined3d_resource_desc *desc, UINT level) DECLSPEC_HIDDEN; BOOL wined3d_volume_load_location(struct wined3d_volume *volume, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN; void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context, @@ -2659,7 +2648,6 @@ struct fbo_entry struct wined3d_surface { - struct wined3d_resource resource; struct wined3d_texture *container; GLenum texture_target; @@ -2682,11 +2670,6 @@ struct wined3d_surface struct list overlay_entry; }; -static inline struct wined3d_surface *surface_from_resource(struct wined3d_resource *resource) -{ - return CONTAINING_RECORD(resource, struct wined3d_surface, resource); -} - static inline BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context) { return !context->gl_info->supported[EXT_TEXTURE_SRGB_DECODE] @@ -2713,16 +2696,12 @@ static inline GLuint surface_get_texture_name(const struct wined3d_surface *surf HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst_rect, struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags, const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN; -void wined3d_surface_cleanup(struct wined3d_surface *surface) DECLSPEC_HIDDEN; HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const struct wined3d_color *color) DECLSPEC_HIDDEN; HRESULT wined3d_surface_create_dc(struct wined3d_surface *surface) DECLSPEC_HIDDEN; void wined3d_surface_destroy_dc(struct wined3d_surface *surface) DECLSPEC_HIDDEN; void surface_get_drawable_size(const struct wined3d_surface *surface, const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN; -HRESULT wined3d_surface_init(struct wined3d_surface *surface, - struct wined3d_texture *container, const struct wined3d_resource_desc *desc, - GLenum target, unsigned int level, unsigned int layer) DECLSPEC_HIDDEN; void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct wined3d_context *context) DECLSPEC_HIDDEN; HRESULT surface_load_location(struct wined3d_surface *surface, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index e9c8cb93bce..88a0d067d14 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -660,11 +660,9 @@ enum wined3d_texture_filter_type enum wined3d_resource_type { - WINED3D_RTYPE_SURFACE = 1, - WINED3D_RTYPE_VOLUME = 2, - WINED3D_RTYPE_BUFFER = 3, - WINED3D_RTYPE_TEXTURE_2D = 4, - WINED3D_RTYPE_TEXTURE_3D = 5, + WINED3D_RTYPE_BUFFER = 1, + WINED3D_RTYPE_TEXTURE_2D = 2, + WINED3D_RTYPE_TEXTURE_3D = 3, }; enum wined3d_pool