wined3d: Create volumes inside wined3d.

This commit is contained in:
Henri Verbeet 2013-12-06 11:09:53 +01:00 committed by Alexandre Julliard
parent da3549315f
commit 15c1a26b55
13 changed files with 127 additions and 188 deletions

View File

@ -1843,6 +1843,19 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
return S_OK;
}
static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_volume *volume, void **parent,
const struct wined3d_parent_ops **parent_ops)
{
TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, volume, parent, parent_ops);
*parent = container_parent;
*parent_ops = &d3d10_null_wined3d_parent_ops;
return S_OK;
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
void *container_parent, const struct wined3d_resource_desc *wined3d_desc, struct wined3d_surface **surface)
{
@ -1885,30 +1898,6 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
return S_OK;
}
static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
void *container_parent, UINT width, UINT height, UINT depth, UINT level,
enum wined3d_format_id format, enum wined3d_pool pool, DWORD usage,
struct wined3d_volume **volume)
{
HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
"format %#x, pool %#x, usage %#x, volume %p.\n",
device_parent, container_parent, width, height, depth,
format, pool, usage, volume);
hr = wined3d_volume_create(device_from_wined3d_device_parent(device_parent)->wined3d_device,
width, height, depth, level, usage, format, pool, NULL, &d3d10_subresource_parent_ops,
volume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);
return hr;
}
return S_OK;
}
static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
{
@ -1942,8 +1931,8 @@ static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_surface_created,
device_parent_volume_created,
device_parent_create_swapchain_surface,
device_parent_create_volume,
device_parent_create_swapchain,
};

View File

@ -183,9 +183,8 @@ struct d3d8_volume
IUnknown *forwardReference;
};
HRESULT volume_init(struct d3d8_volume *volume, struct d3d8_device *device, UINT width, UINT height,
UINT depth, UINT level, DWORD usage, enum wined3d_format_id format,
enum wined3d_pool pool) DECLSPEC_HIDDEN;
void volume_init(struct d3d8_volume *volume, struct wined3d_volume *wined3d_volume,
const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
struct d3d8_swapchain
{

View File

@ -2951,6 +2951,30 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
return D3D_OK;
}
static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_volume *volume, void **parent,
const struct wined3d_parent_ops **parent_ops)
{
struct d3d8_volume *d3d_volume;
TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, volume, parent, parent_ops);
if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume))))
return E_OUTOFMEMORY;
volume_init(d3d_volume, volume, parent_ops);
*parent = d3d_volume;
TRACE("Created volume %p.\n", d3d_volume);
d3d_volume->container = container_parent;
IDirect3DVolume8_Release(&d3d_volume->IDirect3DVolume8_iface);
d3d_volume->forwardReference = container_parent;
return D3D_OK;
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
void *container_parent, const struct wined3d_resource_desc *desc, struct wined3d_surface **surface)
{
@ -2983,48 +3007,6 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
return hr;
}
static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
void *container_parent, UINT width, UINT height, UINT depth, UINT level,
enum wined3d_format_id format, enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
{
struct d3d8_device *device = device_from_device_parent(device_parent);
struct d3d8_volume *object;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
"format %#x, pool %#x, usage %#x, volume %p.\n",
device_parent, container_parent, width, height, depth,
format, pool, usage, volume);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
FIXME("Allocation of memory failed\n");
*volume = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
hr = volume_init(object, device, width, height, depth, level, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize volume, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
*volume = object->wined3d_volume;
wined3d_volume_incref(*volume);
IDirect3DVolume8_Release(&object->IDirect3DVolume8_iface);
object->container = container_parent;
object->forwardReference = container_parent;
TRACE("Created volume %p.\n", object);
return hr;
}
static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
{
@ -3053,8 +3035,8 @@ static const struct wined3d_device_parent_ops d3d8_wined3d_device_parent_ops =
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_surface_created,
device_parent_volume_created,
device_parent_create_swapchain_surface,
device_parent_create_volume,
device_parent_create_swapchain,
};

View File

@ -283,21 +283,13 @@ static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
volume_wined3d_object_destroyed,
};
HRESULT volume_init(struct d3d8_volume *volume, struct d3d8_device *device, UINT width, UINT height,
UINT depth, UINT level, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool)
void volume_init(struct d3d8_volume *volume, struct wined3d_volume *wined3d_volume,
const struct wined3d_parent_ops **parent_ops)
{
HRESULT hr;
volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl;
volume->refcount = 1;
wined3d_volume_incref(wined3d_volume);
volume->wined3d_volume = wined3d_volume;
hr = wined3d_volume_create(device->wined3d_device, width, height, depth, level, usage,
format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wined3d_volume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);
return hr;
}
return D3D_OK;
*parent_ops = &d3d8_volume_wined3d_parent_ops;
}

View File

@ -175,9 +175,8 @@ struct d3d9_volume
IUnknown *forwardReference;
};
HRESULT volume_init(struct d3d9_volume *volume, struct d3d9_device *device, UINT width, UINT height,
UINT depth, UINT level, DWORD usage, enum wined3d_format_id format,
enum wined3d_pool pool) DECLSPEC_HIDDEN;
void volume_init(struct d3d9_volume *volume, struct wined3d_volume *wined3d_volume,
const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
struct d3d9_swapchain
{

View File

@ -3337,6 +3337,30 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
return D3D_OK;
}
static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_volume *volume, void **parent,
const struct wined3d_parent_ops **parent_ops)
{
struct d3d9_volume *d3d_volume;
TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, volume, parent, parent_ops);
if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume))))
return E_OUTOFMEMORY;
volume_init(d3d_volume, volume, parent_ops);
*parent = d3d_volume;
TRACE("Created volume %p.\n", d3d_volume);
d3d_volume->container = container_parent;
IDirect3DVolume9_Release(&d3d_volume->IDirect3DVolume9_iface);
d3d_volume->forwardReference = container_parent;
return D3D_OK;
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
void *container_parent, const struct wined3d_resource_desc *desc, struct wined3d_surface **surface)
{
@ -3372,48 +3396,6 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
return hr;
}
static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
void *container_parent, UINT width, UINT height, UINT depth, UINT level,
enum wined3d_format_id format, enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
{
struct d3d9_device *device = device_from_device_parent(device_parent);
struct d3d9_volume *object;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
"format %#x, pool %#x, usage %#x, volume %p\n",
device_parent, container_parent, width, height, depth,
format, pool, usage, volume);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
FIXME("Allocation of memory failed\n");
*volume = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
hr = volume_init(object, device, width, height, depth, level, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize volume, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
*volume = object->wined3d_volume;
wined3d_volume_incref(*volume);
IDirect3DVolume9_Release(&object->IDirect3DVolume9_iface);
object->container = container_parent;
object->forwardReference = container_parent;
TRACE("Created volume %p.\n", object);
return hr;
}
static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
{
@ -3443,8 +3425,8 @@ static const struct wined3d_device_parent_ops d3d9_wined3d_device_parent_ops =
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_surface_created,
device_parent_volume_created,
device_parent_create_swapchain_surface,
device_parent_create_volume,
device_parent_create_swapchain,
};

View File

@ -274,22 +274,13 @@ static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops =
volume_wined3d_object_destroyed,
};
HRESULT volume_init(struct d3d9_volume *volume, struct d3d9_device *device, UINT width, UINT height,
UINT depth, UINT level, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool)
void volume_init(struct d3d9_volume *volume, struct wined3d_volume *wined3d_volume,
const struct wined3d_parent_ops **parent_ops)
{
HRESULT hr;
volume->IDirect3DVolume9_iface.lpVtbl = &d3d9_volume_vtbl;
volume->refcount = 1;
wined3d_volume_incref(wined3d_volume);
volume->wined3d_volume = wined3d_volume;
hr = wined3d_volume_create(device->wined3d_device, width, height, depth, level,
usage & WINED3DUSAGE_MASK, format, pool, volume, &d3d9_volume_wined3d_parent_ops,
&volume->wined3d_volume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);
return hr;
}
return D3D_OK;
*parent_ops = &d3d9_volume_wined3d_parent_ops;
}

View File

@ -4736,6 +4736,19 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
return DD_OK;
}
static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_volume *volume,
void **parent, const struct wined3d_parent_ops **parent_ops)
{
TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, volume, parent, parent_ops);
*parent = NULL;
*parent_ops = &ddraw_null_wined3d_parent_ops;
return DD_OK;
}
static void STDMETHODCALLTYPE ddraw_frontbuffer_destroyed(void *parent)
{
struct ddraw *ddraw = parent;
@ -4781,21 +4794,6 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
return hr;
}
static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
void *container_parent, UINT width, UINT height, UINT depth, UINT level,
enum wined3d_format_id format, enum wined3d_pool pool, DWORD usage,
struct wined3d_volume **volume)
{
TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
"format %#x, pool %#x, usage %#x, volume %p.\n",
device_parent, container_parent, width, height, depth,
format, pool, usage, volume);
ERR("Not implemented!\n");
return E_NOTIMPL;
}
static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
{
@ -4822,8 +4820,8 @@ static const struct wined3d_device_parent_ops ddraw_wined3d_device_parent_ops =
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_surface_created,
device_parent_volume_created,
device_parent_create_swapchain_surface,
device_parent_create_volume,
device_parent_create_swapchain,
};

View File

@ -1112,10 +1112,8 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
{
struct wined3d_volume *volume;
/* Create the volume. */
hr = device->device_parent->ops->create_volume(device->device_parent, parent,
tmp_w, tmp_h, tmp_d, i, desc->format, desc->pool, desc->usage, &volume);
if (FAILED(hr))
if (FAILED(hr = wined3d_volume_create(device, parent, tmp_w, tmp_h, tmp_d, i,
desc->format, desc->usage, desc->pool, &volume)))
{
ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr);
wined3d_texture_cleanup(texture);

View File

@ -812,9 +812,8 @@ static const struct wined3d_resource_ops volume_resource_ops =
volume_unload,
};
static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_device *device, UINT width,
UINT height, UINT depth, UINT level, DWORD usage, enum wined3d_format_id format_id,
enum wined3d_pool pool, void *parent, const struct wined3d_parent_ops *parent_ops)
static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_device *device, UINT width, UINT height,
UINT depth, UINT level, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
@ -837,10 +836,9 @@ static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_device
size = wined3d_format_calculate_size(format, device->surface_alignment, width, height, depth);
hr = resource_init(&volume->resource, device, WINED3D_RTYPE_VOLUME, format,
if (FAILED(hr = resource_init(&volume->resource, device, WINED3D_RTYPE_VOLUME, format,
WINED3D_MULTISAMPLE_NONE, 0, usage, pool, width, height, depth,
size, parent, parent_ops, &volume_resource_ops);
if (FAILED(hr))
size, NULL, &wined3d_null_parent_ops, &volume_resource_ops)))
{
WARN("Failed to initialize resource, returning %#x.\n", hr);
return hr;
@ -860,16 +858,19 @@ static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_device
return WINED3D_OK;
}
HRESULT CDECL wined3d_volume_create(struct wined3d_device *device, UINT width, UINT height,
UINT depth, UINT level, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_volume **volume)
HRESULT CDECL wined3d_volume_create(struct wined3d_device *device, void *container_parent,
UINT width, UINT height, UINT depth, UINT level, enum wined3d_format_id format_id,
DWORD usage, enum wined3d_pool pool, struct wined3d_volume **volume)
{
const struct wined3d_parent_ops *parent_ops;
struct wined3d_volume *object;
void *parent;
HRESULT hr;
TRACE("device %p, width %u, height %u, depth %u, usage %#x, format %s, pool %s\n",
device, width, height, depth, usage, debug_d3dformat(format_id), debug_d3dpool(pool));
TRACE("parent %p, parent_ops %p, volume %p.\n", parent, parent_ops, volume);
TRACE("device %p, container_parent %p, width %u, height %u, depth %u, level %u, format %s, "
"usage %#x, pool %s, volume %p.\n",
device, container_parent, width, height, depth, level, debug_d3dformat(format_id),
usage, debug_d3dpool(pool), volume);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
@ -878,16 +879,25 @@ HRESULT CDECL wined3d_volume_create(struct wined3d_device *device, UINT width, U
return WINED3DERR_OUTOFVIDEOMEMORY;
}
hr = volume_init(object, device, width, height, depth, level,
usage, format_id, pool, parent, parent_ops);
if (FAILED(hr))
if (FAILED(hr = volume_init(object, device, width, height, depth, level, usage, format_id, pool)))
{
WARN("Failed to initialize volume, returning %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created volume %p.\n", object);
if (FAILED(hr = device->device_parent->ops->volume_created(device->device_parent,
container_parent, object, &parent, &parent_ops)))
{
WARN("Failed to create volume parent, hr %#x.\n", hr);
wined3d_volume_decref(object);
return hr;
}
TRACE("Created volume %p, parent %p, parent_ops %p.\n", object, parent, parent_ops);
object->resource.parent = parent;
object->resource.parent_ops = parent_ops;
*volume = object;
return WINED3D_OK;

View File

@ -272,7 +272,6 @@
@ cdecl wined3d_vertex_declaration_get_parent(ptr)
@ cdecl wined3d_vertex_declaration_incref(ptr)
@ cdecl wined3d_volume_create(ptr long long long long long long long ptr ptr ptr)
@ cdecl wined3d_volume_decref(ptr)
@ cdecl wined3d_volume_from_resource(ptr)
@ cdecl wined3d_volume_get_parent(ptr)

View File

@ -2133,7 +2133,11 @@ static inline struct wined3d_volume *volume_from_resource(struct wined3d_resourc
return CONTAINING_RECORD(resource, struct wined3d_volume, resource);
}
void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context, BOOL srgb_mode) DECLSPEC_HIDDEN;
HRESULT wined3d_volume_create(struct wined3d_device *device, void *container_parent,
UINT width, UINT height, UINT depth, UINT level, enum wined3d_format_id format_id,
DWORD usage, enum wined3d_pool pool, struct wined3d_volume **volume);
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;
void wined3d_volume_invalidate_location(struct wined3d_volume *volume, DWORD location) DECLSPEC_HIDDEN;
void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context,

View File

@ -1982,11 +1982,10 @@ struct wined3d_device_parent_ops
void (__cdecl *mode_changed)(struct wined3d_device_parent *device_parent);
HRESULT (__cdecl *surface_created)(struct wined3d_device_parent *device_parent, void *container_parent,
struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops);
HRESULT (__cdecl *volume_created)(struct wined3d_device_parent *device_parent, void *container_parent,
struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops);
HRESULT (__cdecl *create_swapchain_surface)(struct wined3d_device_parent *device_parent, void *container_parent,
const struct wined3d_resource_desc *desc, struct wined3d_surface **surface);
HRESULT (__cdecl *create_volume)(struct wined3d_device_parent *device_parent, void *container_parent,
UINT width, UINT height, UINT depth, UINT level, enum wined3d_format_id format_id,
enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume);
HRESULT (__cdecl *create_swapchain)(struct wined3d_device_parent *device_parent,
struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain);
};
@ -2396,9 +2395,6 @@ ULONG __cdecl wined3d_vertex_declaration_decref(struct wined3d_vertex_declaratio
void * __cdecl wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration);
ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration);
HRESULT __cdecl wined3d_volume_create(struct wined3d_device *device, UINT width, UINT height, UINT depth,
UINT level, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_volume **volume);
ULONG __cdecl wined3d_volume_decref(struct wined3d_volume *volume);
struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource);
void * __cdecl wined3d_volume_get_parent(const struct wined3d_volume *volume);