Commit 36dbac6c authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Set the volume container in volume_init().

parent 5db26f7b
...@@ -1110,15 +1110,13 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct ...@@ -1110,15 +1110,13 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
{ {
struct wined3d_volume *volume; 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); ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr);
wined3d_texture_cleanup(texture); wined3d_texture_cleanup(texture);
return hr; return hr;
} }
/* Set its container to this texture. */
volume_set_container(volume, texture);
texture->sub_resources[i] = &volume->resource; texture->sub_resources[i] = &volume->resource;
/* Calculate the next mipmap level. */ /* Calculate the next mipmap level. */
......
...@@ -812,9 +812,10 @@ static const struct wined3d_resource_ops volume_resource_ops = ...@@ -812,9 +812,10 @@ static const struct wined3d_resource_ops volume_resource_ops =
volume_unload, volume_unload,
}; };
static HRESULT volume_init(struct wined3d_volume *volume, const struct wined3d_resource_desc *desc, static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_texture *container,
struct wined3d_device *device, UINT level) 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_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format); const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format);
HRESULT hr; HRESULT hr;
...@@ -855,36 +856,40 @@ static HRESULT volume_init(struct wined3d_volume *volume, const struct wined3d_r ...@@ -855,36 +856,40 @@ static HRESULT volume_init(struct wined3d_volume *volume, const struct wined3d_r
volume->flags |= WINED3D_VFLAG_PBO; volume->flags |= WINED3D_VFLAG_PBO;
} }
volume_set_container(volume, container);
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT wined3d_volume_create(struct wined3d_device *device, void *container_parent, HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wined3d_resource_desc *desc,
const struct wined3d_resource_desc *desc, unsigned int level, struct wined3d_volume **volume) 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; const struct wined3d_parent_ops *parent_ops;
struct wined3d_volume *object; struct wined3d_volume *object;
void *parent; void *parent;
HRESULT hr; 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", "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); desc->usage, debug_d3dpool(desc->pool), volume);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY; 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); WARN("Failed to initialize volume, returning %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
return hr; return hr;
} }
if (FAILED(hr = device->device_parent->ops->volume_created(device->device_parent, if (FAILED(hr = device_parent->ops->volume_created(device_parent,
container_parent, object, &parent, &parent_ops))) wined3d_texture_get_parent(container), object, &parent, &parent_ops)))
{ {
WARN("Failed to create volume parent, hr %#x.\n", hr); WARN("Failed to create volume parent, hr %#x.\n", hr);
volume_set_container(object, NULL);
wined3d_volume_decref(object); wined3d_volume_decref(object);
return hr; return hr;
} }
......
...@@ -2133,8 +2133,8 @@ static inline struct wined3d_volume *volume_from_resource(struct wined3d_resourc ...@@ -2133,8 +2133,8 @@ static inline struct wined3d_volume *volume_from_resource(struct wined3d_resourc
return CONTAINING_RECORD(resource, struct wined3d_volume, resource); return CONTAINING_RECORD(resource, struct wined3d_volume, resource);
} }
HRESULT wined3d_volume_create(struct wined3d_device *device, void *container_parent, HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wined3d_resource_desc *desc,
const struct wined3d_resource_desc *desc, unsigned int level, struct wined3d_volume **volume) DECLSPEC_HIDDEN; unsigned int level, struct wined3d_volume **volume) DECLSPEC_HIDDEN;
void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context, void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context,
BOOL srgb_mode) DECLSPEC_HIDDEN; BOOL srgb_mode) DECLSPEC_HIDDEN;
void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture *container) DECLSPEC_HIDDEN; void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture *container) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment