From 36dbac6cb83141a9db334ccf18f8d470ae3ea225 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 6 Dec 2013 11:09:55 +0100 Subject: [PATCH] wined3d: Set the volume container in volume_init(). --- dlls/wined3d/texture.c | 4 +--- dlls/wined3d/volume.c | 23 ++++++++++++++--------- dlls/wined3d/wined3d_private.h | 4 ++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index e9d9b8bb6be..31eb2b0272e 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1110,15 +1110,13 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct { struct wined3d_volume *volume; - if (FAILED(hr = wined3d_volume_create(device, parent, &volume_desc, i, &volume))) + if (FAILED(hr = wined3d_volume_create(texture, &volume_desc, i, &volume))) { ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr); wined3d_texture_cleanup(texture); return hr; } - /* Set its container to this texture. */ - volume_set_container(volume, texture); texture->sub_resources[i] = &volume->resource; /* Calculate the next mipmap level. */ diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index b981374ea54..817fe7ef2f4 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -812,9 +812,10 @@ static const struct wined3d_resource_ops volume_resource_ops = volume_unload, }; -static HRESULT volume_init(struct wined3d_volume *volume, const struct wined3d_resource_desc *desc, - struct wined3d_device *device, UINT level) +static HRESULT 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; @@ -855,36 +856,40 @@ static HRESULT volume_init(struct wined3d_volume *volume, const struct wined3d_r volume->flags |= WINED3D_VFLAG_PBO; } + volume_set_container(volume, container); + return WINED3D_OK; } -HRESULT wined3d_volume_create(struct wined3d_device *device, void *container_parent, - const struct wined3d_resource_desc *desc, unsigned int level, struct wined3d_volume **volume) +HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wined3d_resource_desc *desc, + unsigned int level, struct wined3d_volume **volume) { + struct wined3d_device_parent *device_parent = container->resource.device->device_parent; const struct wined3d_parent_ops *parent_ops; struct wined3d_volume *object; void *parent; HRESULT hr; - TRACE("device %p, container_parent %p, width %u, height %u, depth %u, level %u, format %s, " + TRACE("container %p, width %u, height %u, depth %u, level %u, format %s, " "usage %#x, pool %s, volume %p.\n", - device, container_parent, desc->width, desc->height, desc->depth, level, debug_d3dformat(desc->format), + container, desc->width, desc->height, desc->depth, level, debug_d3dformat(desc->format), desc->usage, debug_d3dpool(desc->pool), volume); if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) return E_OUTOFMEMORY; - if (FAILED(hr = volume_init(object, desc, device, level))) + if (FAILED(hr = volume_init(object, container, desc, level))) { WARN("Failed to initialize volume, returning %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); return hr; } - if (FAILED(hr = device->device_parent->ops->volume_created(device->device_parent, - container_parent, object, &parent, &parent_ops))) + if (FAILED(hr = device_parent->ops->volume_created(device_parent, + wined3d_texture_get_parent(container), object, &parent, &parent_ops))) { WARN("Failed to create volume parent, hr %#x.\n", hr); + volume_set_container(object, NULL); wined3d_volume_decref(object); return hr; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b011a69c73e..ad9b347d662 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2133,8 +2133,8 @@ static inline struct wined3d_volume *volume_from_resource(struct wined3d_resourc return CONTAINING_RECORD(resource, struct wined3d_volume, resource); } -HRESULT wined3d_volume_create(struct wined3d_device *device, void *container_parent, - const struct wined3d_resource_desc *desc, unsigned int level, struct wined3d_volume **volume) DECLSPEC_HIDDEN; +HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wined3d_resource_desc *desc, + unsigned int level, struct wined3d_volume **volume) DECLSPEC_HIDDEN; void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context, BOOL srgb_mode) DECLSPEC_HIDDEN; void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture *container) DECLSPEC_HIDDEN;