Henri Verbeet : wined3d: Pass a texture and sub-resource index to texture2d_destroy_dc().
Alexandre Julliard
julliard at winehq.org
Tue Mar 13 17:10:52 CDT 2018
Module: wine
Branch: master
Commit: 56464f5e074897a607b7b3f98c591537adca55cf
URL: https://source.winehq.org/git/wine.git/?a=commit;h=56464f5e074897a607b7b3f98c591537adca55cf
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Tue Mar 13 14:11:04 2018 +0330
wined3d: Pass a texture and sub-resource index to texture2d_destroy_dc().
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/texture.c | 28 +++++++++++++++++-----------
dlls/wined3d/wined3d_private.h | 8 --------
2 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 07c08d8..6abc7e7 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1406,18 +1406,20 @@ static void texture2d_create_dc(void *object)
static void texture2d_destroy_dc(void *object)
{
- struct wined3d_surface *surface = object;
+ const struct wined3d_texture_idx *idx = object;
D3DKMT_DESTROYDCFROMMEMORY destroy_desc;
struct wined3d_context *context = NULL;
struct wined3d_texture *texture;
+ struct wined3d_surface *surface;
struct wined3d_bo_address data;
unsigned int sub_resource_idx;
struct wined3d_device *device;
NTSTATUS status;
- texture = surface->container;
- sub_resource_idx = surface_get_sub_resource_idx(surface);
+ texture = idx->texture;
+ sub_resource_idx = idx->sub_resource_idx;
device = texture->resource.device;
+ surface = texture->sub_resources[sub_resource_idx].u.surface;
if (!surface->dc)
{
@@ -1453,7 +1455,6 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id, texture->resource.usage);
UINT resource_size = wined3d_format_calculate_size(format, device->surface_alignment, width, height, 1);
struct wined3d_texture_sub_resource *sub_resource;
- struct wined3d_surface *surface;
DWORD valid_location = 0;
BOOL create_dib = FALSE;
@@ -1500,10 +1501,11 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
wined3d_resource_wait_idle(&texture->resource);
sub_resource = &texture->sub_resources[0];
- surface = sub_resource->u.surface;
- if (surface->dc)
+ if (sub_resource->u.surface->dc)
{
- wined3d_cs_destroy_object(device->cs, texture2d_destroy_dc, surface);
+ struct wined3d_texture_idx texture_idx = {texture, 0};
+
+ wined3d_cs_destroy_object(device->cs, texture2d_destroy_dc, &texture_idx);
device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
create_dib = TRUE;
}
@@ -1889,7 +1891,11 @@ static void texture2d_cleanup_sub_resources(struct wined3d_texture *texture)
TRACE("surface %p.\n", surface);
if (surface->dc)
- texture2d_destroy_dc(surface);
+ {
+ struct wined3d_texture_idx texture_idx = {texture, i};
+
+ texture2d_destroy_dc(&texture_idx);
+ }
}
if (context)
context_release(context);
@@ -2360,8 +2366,6 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
surface = &surfaces[idx];
surface->container = texture;
- surface->texture_level = i;
- surface->texture_layer = j;
sub_resource = &texture->sub_resources[idx];
sub_resource->locations = WINED3D_LOCATION_DISCARDED;
@@ -3224,7 +3228,9 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign
if (!(texture->resource.usage & WINED3DUSAGE_OWNDC) && !(device->wined3d->flags & WINED3D_NO3D))
{
- wined3d_cs_destroy_object(device->cs, texture2d_destroy_dc, surface);
+ struct wined3d_texture_idx texture_idx = {texture, sub_resource_idx};
+
+ wined3d_cs_destroy_object(device->cs, texture2d_destroy_dc, &texture_idx);
device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 247e712..9dc193a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3335,19 +3335,11 @@ struct wined3d_surface
{
struct wined3d_texture *container;
- unsigned int texture_level;
- unsigned int texture_layer;
-
/* For GetDC */
HBITMAP bitmap;
HDC dc;
};
-static inline unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
-{
- return surface->texture_layer * surface->container->level_count + surface->texture_level;
-}
-
void wined3d_surface_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_gl_info *gl_info, const struct wined3d_format *format, const RECT *src_rect,
unsigned int src_pitch, const POINT *dst_point, BOOL srgb,
More information about the wine-cvs
mailing list