Commit 9c00f968 authored by Riccardo Bortolato's avatar Riccardo Bortolato Committed by Alexandre Julliard

d3d8: Make use of wined3d_texture_map in d3d8_surface_LockRect.

Pass wined3d_texture and sub_resource idx to device_parent_surface_created callback. Store wined3d_texture and sub_resource in d3d8_surface. Also updated d3d9, d3d11, ddraw callbacks accordingly. Signed-off-by: 's avatarRiccardo Bortolato <rikyz619@gmail.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 2f375f31
......@@ -3989,11 +3989,11 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
}
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_surface *surface, void **parent,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_surface *surface, void **parent,
const struct wined3d_parent_ops **parent_ops)
{
TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, surface, parent, parent_ops);
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, surface %p, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, surface, parent, parent_ops);
*parent = NULL;
*parent_ops = &d3d_null_wined3d_parent_ops;
......
......@@ -227,6 +227,8 @@ struct d3d8_surface
{
IDirect3DSurface8 IDirect3DSurface8_iface;
struct d3d8_resource resource;
struct wined3d_texture *wined3d_texture;
unsigned int sub_resource_idx;
struct wined3d_surface *wined3d_surface;
struct list rtv_entry;
struct wined3d_rendertarget_view *wined3d_rtv;
......@@ -236,7 +238,7 @@ struct d3d8_surface
};
struct wined3d_rendertarget_view *d3d8_surface_get_rendertarget_view(struct d3d8_surface *surface) DECLSPEC_HIDDEN;
void surface_init(struct d3d8_surface *surface, IUnknown *container_parent,
void surface_init(struct d3d8_surface *surface, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN;
......
......@@ -2999,18 +2999,18 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
}
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_surface *surface, void **parent,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_surface *surface, void **parent,
const struct wined3d_parent_ops **parent_ops)
{
struct d3d8_surface *d3d_surface;
TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, surface, parent, parent_ops);
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, surface %p, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, surface, parent, parent_ops);
if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
return E_OUTOFMEMORY;
surface_init(d3d_surface, container_parent, surface, parent_ops);
surface_init(d3d_surface, wined3d_texture, sub_resource_idx, surface, parent_ops);
*parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface);
......
......@@ -234,7 +234,8 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface,
box.back = 1;
}
hr = wined3d_surface_map(surface->wined3d_surface, &map_desc, rect ? &box : NULL, flags);
hr = wined3d_texture_map(surface->wined3d_texture, surface->sub_resource_idx,
&map_desc, rect ? &box : NULL, flags);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
......@@ -299,7 +300,7 @@ static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops =
surface_wined3d_object_destroyed,
};
void surface_init(struct d3d8_surface *surface, IUnknown *container_parent,
void surface_init(struct d3d8_surface *surface, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops)
{
IDirect3DBaseTexture8 *texture;
......@@ -309,9 +310,11 @@ void surface_init(struct d3d8_surface *surface, IUnknown *container_parent,
surface->resource.refcount = 0;
surface->wined3d_surface = wined3d_surface;
list_init(&surface->rtv_entry);
surface->container = container_parent;
surface->container = wined3d_texture_get_parent(wined3d_texture);
surface->wined3d_texture = wined3d_texture;
surface->sub_resource_idx = sub_resource_idx;
if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent,
if (surface->container && SUCCEEDED(IUnknown_QueryInterface(surface->container,
&IID_IDirect3DBaseTexture8, (void **)&texture)))
{
surface->texture = unsafe_impl_from_IDirect3DBaseTexture8(texture);
......
......@@ -3534,18 +3534,18 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
}
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_surface *surface, void **parent,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_surface *surface, void **parent,
const struct wined3d_parent_ops **parent_ops)
{
struct d3d9_surface *d3d_surface;
TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, surface, parent, parent_ops);
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, surface %p, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, surface, parent, parent_ops);
if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
return E_OUTOFMEMORY;
surface_init(d3d_surface, container_parent, surface, parent_ops);
surface_init(d3d_surface, wined3d_texture_get_parent(wined3d_texture), surface, parent_ops);
*parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface);
......
......@@ -4712,17 +4712,17 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
}
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_surface *surface,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_surface *surface,
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, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, surface, parent, parent_ops);
TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, surface %p, parent %p, parent_ops %p.\n",
device_parent, wined3d_texture, sub_resource_idx, surface, parent, parent_ops);
/* We have a swapchain or wined3d internal texture. */
if (!container_parent || container_parent == ddraw)
if (!wined3d_texture_get_parent(wined3d_texture) || wined3d_texture_get_parent(wined3d_texture) == ddraw)
{
*parent = NULL;
*parent_ops = &ddraw_null_wined3d_parent_ops;
......@@ -4736,7 +4736,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
return DDERR_OUTOFVIDEOMEMORY;
}
ddraw_surface_init(ddraw_surface, ddraw, container_parent, surface, parent_ops);
ddraw_surface_init(ddraw_surface, ddraw, wined3d_texture_get_parent(wined3d_texture), surface, parent_ops);
*parent = ddraw_surface;
list_add_head(&ddraw->surface_list, &ddraw_surface->surface_list_entry);
......
......@@ -5421,7 +5421,7 @@ HRESULT wined3d_surface_create(struct wined3d_texture *container, const struct w
}
if (FAILED(hr = device_parent->ops->surface_created(device_parent,
wined3d_texture_get_parent(container), object, &parent, &parent_ops)))
container, layer * container->level_count + level, object, &parent, &parent_ops)))
{
WARN("Failed to create surface parent, hr %#x.\n", hr);
wined3d_surface_destroy(object);
......
......@@ -2029,7 +2029,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, void *container_parent,
HRESULT (__cdecl *surface_created)(struct wined3d_device_parent *device_parent,
struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_surface *surface, 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,
......
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