Commit 0a354365 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Merge the surface_created() and volume_created() wined3d_device_parent_ops callbacks.

parent b5b3146e
......@@ -5786,12 +5786,12 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
TRACE("device_parent %p, activate %#x.\n", device_parent, activate);
}
static HRESULT CDECL device_parent_sub_resource_created(struct wined3d_device_parent *device_parent,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, void **parent,
const struct wined3d_parent_ops **parent_ops)
static HRESULT CDECL device_parent_texture_sub_resource_created(struct wined3d_device_parent *device_parent,
enum wined3d_resource_type type, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
void **parent, const struct wined3d_parent_ops **parent_ops)
{
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, type, wined3d_texture, sub_resource_idx, parent, parent_ops);
*parent = NULL;
*parent_ops = &d3d_null_wined3d_parent_ops;
......@@ -5881,8 +5881,7 @@ static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops =
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_activate,
device_parent_sub_resource_created,
device_parent_sub_resource_created,
device_parent_texture_sub_resource_created,
device_parent_create_swapchain_texture,
device_parent_create_swapchain,
};
......
......@@ -3269,40 +3269,40 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
InterlockedCompareExchange(&device->device_state, D3D8_DEVICE_STATE_NOT_RESET, D3D8_DEVICE_STATE_LOST);
}
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
static HRESULT CDECL device_parent_texture_sub_resource_created(struct wined3d_device_parent *device_parent,
enum wined3d_resource_type type, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
void **parent, const struct wined3d_parent_ops **parent_ops)
{
struct d3d8_surface *d3d_surface;
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
if (!(d3d_surface = heap_alloc_zero(sizeof(*d3d_surface))))
return E_OUTOFMEMORY;
surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops);
*parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface);
TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, type, wined3d_texture, sub_resource_idx, parent, parent_ops);
return D3D_OK;
}
if (type == WINED3D_RTYPE_TEXTURE_2D)
{
struct d3d8_surface *d3d_surface;
static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
void **parent, const struct wined3d_parent_ops **parent_ops)
{
struct d3d8_volume *d3d_volume;
if (!(d3d_surface = heap_alloc_zero(sizeof(*d3d_surface))))
return E_OUTOFMEMORY;
TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops);
*parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface);
}
else if (type == WINED3D_RTYPE_TEXTURE_3D)
{
struct d3d8_volume *d3d_volume;
if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume))))
return E_OUTOFMEMORY;
if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume))))
return E_OUTOFMEMORY;
volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops);
*parent = d3d_volume;
TRACE("Created volume %p.\n", d3d_volume);
volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops);
*parent = d3d_volume;
TRACE("Created volume %p.\n", d3d_volume);
}
else
{
ERR("Unhandled resource type %#x.\n", type);
return E_FAIL;
}
return D3D_OK;
}
......@@ -3360,8 +3360,7 @@ static const struct wined3d_device_parent_ops d3d8_wined3d_device_parent_ops =
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_activate,
device_parent_surface_created,
device_parent_volume_created,
device_parent_texture_sub_resource_created,
device_parent_create_swapchain_texture,
device_parent_create_swapchain,
};
......
......@@ -4107,40 +4107,40 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
InterlockedCompareExchange(&device->device_state, D3D9_DEVICE_STATE_NOT_RESET, D3D9_DEVICE_STATE_LOST);
}
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
static HRESULT CDECL device_parent_texture_sub_resource_created(struct wined3d_device_parent *device_parent,
enum wined3d_resource_type type, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
void **parent, const struct wined3d_parent_ops **parent_ops)
{
struct d3d9_surface *d3d_surface;
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, type, wined3d_texture, sub_resource_idx, parent, parent_ops);
if (!(d3d_surface = heap_alloc_zero(sizeof(*d3d_surface))))
return E_OUTOFMEMORY;
if (type == WINED3D_RTYPE_TEXTURE_2D)
{
struct d3d9_surface *d3d_surface;
surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops);
*parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface);
if (!(d3d_surface = heap_alloc_zero(sizeof(*d3d_surface))))
return E_OUTOFMEMORY;
return D3D_OK;
}
static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
void **parent, const struct wined3d_parent_ops **parent_ops)
{
struct d3d9_volume *d3d_volume;
TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops);
*parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface);
}
else if (type == WINED3D_RTYPE_TEXTURE_3D)
{
struct d3d9_volume *d3d_volume;
if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume))))
return E_OUTOFMEMORY;
if (!(d3d_volume = heap_alloc_zero(sizeof(*d3d_volume))))
return E_OUTOFMEMORY;
volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops);
*parent = d3d_volume;
TRACE("Created volume %p.\n", d3d_volume);
volume_init(d3d_volume, wined3d_texture, sub_resource_idx, parent_ops);
*parent = d3d_volume;
TRACE("Created volume %p.\n", d3d_volume);
}
else
{
ERR("Unhandled resource type %#x.\n", type);
return E_FAIL;
}
return D3D_OK;
}
......@@ -4205,8 +4205,7 @@ static const struct wined3d_device_parent_ops d3d9_wined3d_device_parent_ops =
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_activate,
device_parent_surface_created,
device_parent_volume_created,
device_parent_texture_sub_resource_created,
device_parent_create_swapchain_texture,
device_parent_create_swapchain,
};
......
......@@ -4800,18 +4800,19 @@ void ddraw_update_lost_surfaces(struct ddraw *ddraw)
ddraw->device_state = DDRAW_DEVICE_STATE_OK;
}
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
static HRESULT CDECL device_parent_texture_sub_resource_created(struct wined3d_device_parent *device_parent,
enum wined3d_resource_type type, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
void **parent, const struct wined3d_parent_ops **parent_ops)
{
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
struct ddraw_surface *ddraw_surface;
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops);
TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, type, wined3d_texture, sub_resource_idx, parent, parent_ops);
/* We have a swapchain or wined3d internal texture. */
if (!wined3d_texture_get_parent(wined3d_texture) || wined3d_texture_get_parent(wined3d_texture) == ddraw)
if (type != WINED3D_RTYPE_TEXTURE_2D || !wined3d_texture_get_parent(wined3d_texture)
|| wined3d_texture_get_parent(wined3d_texture) == ddraw)
{
*parent = NULL;
*parent_ops = &ddraw_null_wined3d_parent_ops;
......@@ -4836,19 +4837,6 @@ 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,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
void **parent, const struct wined3d_parent_ops **parent_ops)
{
TRACE("device_parent %p, texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, 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;
......@@ -4914,8 +4902,7 @@ static const struct wined3d_device_parent_ops ddraw_wined3d_device_parent_ops =
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_activate,
device_parent_surface_created,
device_parent_volume_created,
device_parent_texture_sub_resource_created,
device_parent_create_swapchain_texture,
device_parent_create_swapchain,
};
......
......@@ -2367,8 +2367,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
wined3d_texture_invalidate_location(texture, i, ~WINED3D_LOCATION_SYSMEM);
}
if (FAILED(hr = device_parent->ops->surface_created(device_parent,
texture, i, &sub_resource->parent, &sub_resource->parent_ops)))
if (FAILED(hr = device_parent->ops->texture_sub_resource_created(device_parent,
desc->resource_type, texture, i, &sub_resource->parent, &sub_resource->parent_ops)))
{
WARN("Failed to create sub-resource parent, hr %#x.\n", hr);
sub_resource->parent = NULL;
......@@ -2769,8 +2769,8 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
sub_resource = &texture->sub_resources[i];
sub_resource->locations = WINED3D_LOCATION_DISCARDED;
if (FAILED(hr = device_parent->ops->volume_created(device_parent,
texture, i, &sub_resource->parent, &sub_resource->parent_ops)))
if (FAILED(hr = device_parent->ops->texture_sub_resource_created(device_parent,
desc->resource_type, texture, i, &sub_resource->parent, &sub_resource->parent_ops)))
{
WARN("Failed to create volume parent, hr %#x.\n", hr);
sub_resource->parent = NULL;
......
......@@ -2114,11 +2114,8 @@ struct wined3d_device_parent_ops
void (__cdecl *wined3d_device_created)(struct wined3d_device_parent *device_parent, struct wined3d_device *device);
void (__cdecl *mode_changed)(struct wined3d_device_parent *device_parent);
void (__cdecl *activate)(struct wined3d_device_parent *device_parent, BOOL activate);
HRESULT (__cdecl *surface_created)(struct wined3d_device_parent *device_parent,
struct wined3d_texture *texture, unsigned int sub_resource_idx,
void **parent, const struct wined3d_parent_ops **parent_ops);
HRESULT (__cdecl *volume_created)(struct wined3d_device_parent *device_parent,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
HRESULT (__cdecl *texture_sub_resource_created)(struct wined3d_device_parent *device_parent,
enum wined3d_resource_type type, struct wined3d_texture *texture, unsigned int sub_resource_idx,
void **parent, const struct wined3d_parent_ops **parent_ops);
HRESULT (__cdecl *create_swapchain_texture)(struct wined3d_device_parent *device_parent, void *parent,
const struct wined3d_resource_desc *desc, DWORD texture_flags, struct wined3d_texture **texture);
......
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