Here is a follow up on the small fixes I sent the other day.
I'm storing the wined3d texture and sub level in the d3dX surfaces/volumes and this allows to go further with the removal of surfaces/volumes from the public api.
With these commits I also introduce a temporary function to handle mapping for surfaces and volumes which I hope it will gradually handle more of that eventually delegating only bound checks (and maybe other minor things) to helper functions.
Finally the remaining volume-related exported functions are removed.
What to do with buffers is still unclear to me.
Ciao, Riccardo
--- dlls/d3d11/device.c | 12 ++++++------ dlls/d3d8/d3d8_private.h | 6 ++++-- dlls/d3d8/device.c | 16 ++++++++-------- dlls/d3d8/surface.c | 3 ++- dlls/d3d8/volume.c | 3 ++- dlls/d3d9/d3d9_private.h | 6 ++++-- dlls/d3d9/device.c | 16 ++++++++-------- dlls/d3d9/surface.c | 3 ++- dlls/d3d9/volume.c | 3 ++- dlls/ddraw/ddraw.c | 14 +++++++------- dlls/ddraw/ddraw_private.h | 4 ++-- dlls/ddraw/surface.c | 7 +++---- dlls/wined3d/surface.c | 3 ++- dlls/wined3d/volume.c | 2 +- include/wine/wined3d.h | 4 ++-- 15 files changed, 55 insertions(+), 47 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index dcaa49c..316c268 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -2927,10 +2927,10 @@ 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, - const struct wined3d_parent_ops **parent_ops) + const struct wined3d_parent_ops **parent_ops, UINT idx) { - 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, container_parent %p, surface %p, parent %p, parent_ops %p, index %u.\n", + device_parent, container_parent, surface, parent, parent_ops, idx);
*parent = NULL; *parent_ops = &d3d10_null_wined3d_parent_ops; @@ -2940,10 +2940,10 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
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) + const struct wined3d_parent_ops **parent_ops, UINT idx) { - TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n", - device_parent, container_parent, volume, parent, parent_ops); + TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, index %u.\n", + device_parent, container_parent, volume, parent, parent_ops, idx);
*parent = NULL; *parent_ops = &d3d10_null_wined3d_parent_ops; diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 6283c8d..6573435 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -206,10 +206,11 @@ struct d3d8_volume struct d3d8_resource resource; struct wined3d_volume *wined3d_volume; struct d3d8_texture *texture; + UINT sub_resource_idx; };
void volume_init(struct d3d8_volume *volume, struct d3d8_texture *texture, - struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, UINT idx) DECLSPEC_HIDDEN;
struct d3d8_swapchain { @@ -232,11 +233,12 @@ struct d3d8_surface IDirect3DDevice8 *parent_device; IUnknown *container; struct d3d8_texture *texture; + UINT sub_resource_idx; };
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, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) DECLSPEC_HIDDEN; struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN;
struct d3d8_vertexbuffer diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index e899b34..7cf0f91 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2999,17 +2999,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, void **parent, - const struct wined3d_parent_ops **parent_ops) + const struct wined3d_parent_ops **parent_ops, UINT idx) { 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, container_parent %p, surface %p, parent %p, parent_ops %p, index %u.\n", + device_parent, container_parent, surface, parent, parent_ops, idx);
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, container_parent, surface, parent_ops, idx); *parent = d3d_surface; TRACE("Created surface %p.\n", d3d_surface);
@@ -3018,17 +3018,17 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
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) + const struct wined3d_parent_ops **parent_ops, UINT idx) { 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); + TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, index %u.\n", + device_parent, container_parent, volume, parent, parent_ops, idx);
if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) return E_OUTOFMEMORY;
- volume_init(d3d_volume, container_parent, volume, parent_ops); + volume_init(d3d_volume, container_parent, volume, parent_ops, idx); *parent = d3d_volume; TRACE("Created volume %p.\n", d3d_volume);
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index 7779a56..714102d 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -293,7 +293,7 @@ static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops = };
void surface_init(struct d3d8_surface *surface, IUnknown *container_parent, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) { IDirect3DBaseTexture8 *texture;
@@ -303,6 +303,7 @@ void surface_init(struct d3d8_surface *surface, IUnknown *container_parent, surface->wined3d_surface = wined3d_surface; list_init(&surface->rtv_entry); surface->container = container_parent; + surface->sub_resource_idx = idx;
if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent, &IID_IDirect3DBaseTexture8, (void **)&texture))) diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c index d116b16..f5c27e5 100644 --- a/dlls/d3d8/volume.c +++ b/dlls/d3d8/volume.c @@ -202,13 +202,14 @@ static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops = };
void volume_init(struct d3d8_volume *volume, struct d3d8_texture *texture, - struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, UINT idx) { volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl; d3d8_resource_init(&volume->resource); volume->resource.refcount = 0; volume->wined3d_volume = wined3d_volume; volume->texture = texture; + volume->sub_resource_idx = idx;
*parent_ops = &d3d8_volume_wined3d_parent_ops; } diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index d12805f..506cb59 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -193,10 +193,11 @@ struct d3d9_volume struct d3d9_resource resource; struct wined3d_volume *wined3d_volume; struct d3d9_texture *texture; + UINT sub_resource_idx; };
void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture, - struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, UINT idx) DECLSPEC_HIDDEN;
struct d3d9_swapchain { @@ -220,11 +221,12 @@ struct d3d9_surface IUnknown *container; struct d3d9_texture *texture; BOOL getdc_supported; + UINT sub_resource_idx; };
struct wined3d_rendertarget_view *d3d9_surface_get_rendertarget_view(struct d3d9_surface *surface) DECLSPEC_HIDDEN; void surface_init(struct d3d9_surface *surface, IUnknown *container_parent, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) DECLSPEC_HIDDEN; struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
struct d3d9_vertexbuffer diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 3a0376d..092ed10 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3535,17 +3535,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, void **parent, - const struct wined3d_parent_ops **parent_ops) + const struct wined3d_parent_ops **parent_ops, UINT idx) { 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, container_parent %p, surface %p, parent %p, parent_ops %p, index %u.\n", + device_parent, container_parent, surface, parent, parent_ops, idx);
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, container_parent, surface, parent_ops, idx); *parent = d3d_surface; TRACE("Created surface %p.\n", d3d_surface);
@@ -3554,17 +3554,17 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
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) + const struct wined3d_parent_ops **parent_ops, UINT idx) { 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); + TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, index %u.\n", + device_parent, container_parent, volume, parent, parent_ops, idx);
if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) return E_OUTOFMEMORY;
- volume_init(d3d_volume, container_parent, volume, parent_ops); + volume_init(d3d_volume, container_parent, volume, parent_ops, idx); *parent = d3d_volume; TRACE("Created volume %p.\n", d3d_volume);
diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index e5eb11f..b1f0a11 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -346,7 +346,7 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops = };
void surface_init(struct d3d9_surface *surface, IUnknown *container_parent, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) { struct wined3d_resource_desc desc; IDirect3DBaseTexture9 *texture; @@ -357,6 +357,7 @@ void surface_init(struct d3d9_surface *surface, IUnknown *container_parent, surface->wined3d_surface = wined3d_surface; list_init(&surface->rtv_entry); surface->container = container_parent; + surface->sub_resource_idx = idx;
if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent, &IID_IDirect3DBaseTexture9, (void **)&texture))) diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index 4b22f20..8df829c 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -202,13 +202,14 @@ static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops = };
void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture, - struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, UINT idx) { volume->IDirect3DVolume9_iface.lpVtbl = &d3d9_volume_vtbl; d3d9_resource_init(&volume->resource); volume->resource.refcount = 0; volume->wined3d_volume = wined3d_volume; volume->texture = texture; + volume->sub_resource_idx = idx;
*parent_ops = &d3d9_volume_wined3d_parent_ops; } diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index c94bfee..6f35b23 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4713,13 +4713,13 @@ 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, const struct wined3d_parent_ops **parent_ops) + void **parent, const struct wined3d_parent_ops **parent_ops, UINT idx) { 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, container_parent %p, surface %p, parent %p, parent_ops %p, index %u.\n", + device_parent, container_parent, surface, parent, parent_ops, idx);
/* We have a swapchain or wined3d internal texture. */ if (!container_parent || container_parent == ddraw) @@ -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, container_parent, surface, parent_ops, idx); *parent = ddraw_surface; list_add_head(&ddraw->surface_list, &ddraw_surface->surface_list_entry);
@@ -4747,10 +4747,10 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
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) + void **parent, const struct wined3d_parent_ops **parent_ops, UINT idx) { - TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n", - device_parent, container_parent, volume, parent, parent_ops); + TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, index %u.\n", + device_parent, container_parent, volume, parent, parent_ops, idx);
*parent = NULL; *parent_ops = &ddraw_null_wined3d_parent_ops; diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index bb0a3f8..ff0621b 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -186,7 +186,7 @@ struct ddraw_surface DDSURFACEDESC2 surface_desc;
/* Misc things */ - UINT mipmap_level; + UINT sub_resource_idx;
/* Clipper objects */ struct ddraw_clipper *clipper; @@ -210,7 +210,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ struct ddraw_surface **surface, IUnknown *outer_unknown, unsigned int version) DECLSPEC_HIDDEN; struct wined3d_rendertarget_view *ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface) DECLSPEC_HIDDEN; void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) DECLSPEC_HIDDEN; ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN; HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface, const RECT *rect, BOOL read) DECLSPEC_HIDDEN; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 6b6ddb9..0e66a1b 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -777,7 +777,6 @@ static HRESULT WINAPI ddraw_surface7_GetAttachedSurface(IDirectDrawSurface7 *ifa */
TRACE("(%p): Returning surface %p\n", This, surf); - TRACE("(%p): mipmapcount=%d\n", This, surf->mipmap_level); *Surface = &surf->IDirectDrawSurface7_iface; ddraw_surface7_AddRef(*Surface); wined3d_mutex_unlock(); @@ -5101,8 +5100,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu struct ddraw_palette *dst_pal, *src_pal; DDSURFACEDESC *src_desc, *dst_desc;
- TRACE("Copying surface %p to surface %p (mipmap level %d).\n", - src_surface, dst_surface, src_surface->mipmap_level); + TRACE("Copying surface %p to surface %p.\n", src_surface, dst_surface);
/* Suppress the ALLOCONLOAD flag */ dst_surface->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD; @@ -6229,7 +6227,7 @@ fail: }
void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) { DDSURFACEDESC2 *desc = &surface->surface_desc; struct wined3d_resource_desc wined3d_desc; @@ -6246,6 +6244,7 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, stru surface->iface_count = 1; surface->version = version; surface->ddraw = ddraw; + surface->sub_resource_idx = idx;
if (version == 7) { diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 999423d..0676948 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -5395,6 +5395,7 @@ HRESULT wined3d_surface_create(struct wined3d_texture *container, const struct w struct wined3d_surface *object; void *parent; HRESULT hr; + UINT idx = layer * container->level_count + level;
TRACE("container %p, width %u, height %u, format %s, usage %s (%#x), pool %s, " "multisample_type %#x, multisample_quality %u, target %#x, level %u, layer %u, flags %#x, surface %p.\n", @@ -5413,7 +5414,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))) + wined3d_texture_get_parent(container), object, &parent, &parent_ops, idx))) { WARN("Failed to create surface parent, hr %#x.\n", hr); wined3d_surface_destroy(object); diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index 2daa55e..047251a 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -796,7 +796,7 @@ HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wi }
if (FAILED(hr = device_parent->ops->volume_created(device_parent, - wined3d_texture_get_parent(container), object, &parent, &parent_ops))) + wined3d_texture_get_parent(container), object, &parent, &parent_ops, level))) { WARN("Failed to create volume parent, hr %#x.\n", hr); wined3d_volume_destroy(object); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index ac1e59e..adec90a 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2031,9 +2031,9 @@ struct wined3d_device_parent_ops 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, - struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops); + struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops, UINT idx); 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); + struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops, UINT idx); HRESULT (__cdecl *create_swapchain_texture)(struct wined3d_device_parent *device_parent, void *parent, const struct wined3d_resource_desc *desc, struct wined3d_texture **texture); HRESULT (__cdecl *create_swapchain)(struct wined3d_device_parent *device_parent,
--- dlls/d3d11/device.c | 10 +++++----- dlls/d3d8/d3d8_private.h | 8 ++++++-- dlls/d3d8/device.c | 17 +++++++++-------- dlls/d3d8/surface.c | 4 +++- dlls/d3d8/volume.c | 4 +++- dlls/d3d9/d3d9_private.h | 8 ++++++-- dlls/d3d9/device.c | 17 +++++++++-------- dlls/d3d9/surface.c | 4 +++- dlls/d3d9/volume.c | 4 +++- dlls/ddraw/ddraw.c | 14 +++++++------- dlls/ddraw/ddraw_private.h | 3 ++- dlls/ddraw/surface.c | 4 +++- dlls/wined3d/surface.c | 2 +- dlls/wined3d/volume.c | 2 +- include/wine/wined3d.h | 6 ++++-- 15 files changed, 65 insertions(+), 42 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 316c268..3203f30 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -2927,10 +2927,10 @@ 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, - const struct wined3d_parent_ops **parent_ops, UINT idx) + const struct wined3d_parent_ops **parent_ops, struct wined3d_texture *texture, UINT idx) { - TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p, index %u.\n", - device_parent, container_parent, surface, parent, parent_ops, idx); + TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p, texture %p, index %u.\n", + device_parent, container_parent, surface, parent, parent_ops, texture, idx);
*parent = NULL; *parent_ops = &d3d10_null_wined3d_parent_ops; @@ -2940,9 +2940,9 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
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, UINT idx) + const struct wined3d_parent_ops **parent_ops, struct wined3d_texture *texture, UINT idx) { - TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, index %u.\n", + TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, texture %p, index %u.\n", device_parent, container_parent, volume, parent, parent_ops, idx);
*parent = NULL; diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 6573435..b0fb9db 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -206,11 +206,13 @@ struct d3d8_volume struct d3d8_resource resource; struct wined3d_volume *wined3d_volume; struct d3d8_texture *texture; + struct wined3d_texture *wined3d_texture; UINT sub_resource_idx; };
void volume_init(struct d3d8_volume *volume, struct d3d8_texture *texture, - struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, UINT idx) DECLSPEC_HIDDEN; + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *wined3d_texture, UINT idx) DECLSPEC_HIDDEN;
struct d3d8_swapchain { @@ -233,12 +235,14 @@ struct d3d8_surface IDirect3DDevice8 *parent_device; IUnknown *container; struct d3d8_texture *texture; + struct wined3d_texture *wined3d_texture; UINT sub_resource_idx; };
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, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) DECLSPEC_HIDDEN; + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *texture, UINT idx) DECLSPEC_HIDDEN; struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN;
struct d3d8_vertexbuffer diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 7cf0f91..ba67ba5 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -981,6 +981,7 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width sub_resource = wined3d_texture_get_sub_resource(texture, 0); surface_impl = wined3d_resource_get_parent(sub_resource); surface_impl->parent_device = &device->IDirect3DDevice8_iface; + surface_impl->wined3d_texture = texture; *surface = &surface_impl->IDirect3DSurface8_iface; IDirect3DSurface8_AddRef(*surface); wined3d_texture_decref(texture); @@ -2999,17 +3000,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, void **parent, - const struct wined3d_parent_ops **parent_ops, UINT idx) + const struct wined3d_parent_ops **parent_ops, struct wined3d_texture *texture, UINT idx) { struct d3d8_surface *d3d_surface;
- TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p, index %u.\n", - device_parent, container_parent, surface, parent, parent_ops, idx); + TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p, texture %p, index %u.\n", + device_parent, container_parent, surface, parent, parent_ops, texture, idx);
if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface)))) return E_OUTOFMEMORY;
- surface_init(d3d_surface, container_parent, surface, parent_ops, idx); + surface_init(d3d_surface, container_parent, surface, parent_ops, texture, idx); *parent = d3d_surface; TRACE("Created surface %p.\n", d3d_surface);
@@ -3018,17 +3019,17 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
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, UINT idx) + const struct wined3d_parent_ops **parent_ops, struct wined3d_texture *texture, UINT idx) { struct d3d8_volume *d3d_volume;
- TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, index %u.\n", - device_parent, container_parent, volume, parent, parent_ops, idx); + TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, texture %p, index %u.\n", + device_parent, container_parent, volume, parent, parent_ops, texture, idx);
if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) return E_OUTOFMEMORY;
- volume_init(d3d_volume, container_parent, volume, parent_ops, idx); + volume_init(d3d_volume, container_parent, volume, parent_ops, texture, idx); *parent = d3d_volume; TRACE("Created volume %p.\n", d3d_volume);
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index 714102d..81b75e1 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -293,7 +293,8 @@ static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops = };
void surface_init(struct d3d8_surface *surface, IUnknown *container_parent, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *wined3d_texture, UINT idx) { IDirect3DBaseTexture8 *texture;
@@ -303,6 +304,7 @@ void surface_init(struct d3d8_surface *surface, IUnknown *container_parent, surface->wined3d_surface = wined3d_surface; list_init(&surface->rtv_entry); surface->container = container_parent; + surface->wined3d_texture = wined3d_texture; surface->sub_resource_idx = idx;
if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent, diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c index f5c27e5..0cc6403 100644 --- a/dlls/d3d8/volume.c +++ b/dlls/d3d8/volume.c @@ -202,13 +202,15 @@ static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops = };
void volume_init(struct d3d8_volume *volume, struct d3d8_texture *texture, - struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, UINT idx) + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *wined3d_texture, UINT idx) { volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl; d3d8_resource_init(&volume->resource); volume->resource.refcount = 0; volume->wined3d_volume = wined3d_volume; volume->texture = texture; + volume->wined3d_texture = wined3d_texture; volume->sub_resource_idx = idx;
*parent_ops = &d3d8_volume_wined3d_parent_ops; diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index 506cb59..4532cb3 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -193,11 +193,13 @@ struct d3d9_volume struct d3d9_resource resource; struct wined3d_volume *wined3d_volume; struct d3d9_texture *texture; + struct wined3d_texture *wined3d_texture; UINT sub_resource_idx; };
void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture, - struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, UINT idx) DECLSPEC_HIDDEN; + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *wined3d_texture, UINT idx) DECLSPEC_HIDDEN;
struct d3d9_swapchain { @@ -221,12 +223,14 @@ struct d3d9_surface IUnknown *container; struct d3d9_texture *texture; BOOL getdc_supported; + struct wined3d_texture *wined3d_texture; UINT sub_resource_idx; };
struct wined3d_rendertarget_view *d3d9_surface_get_rendertarget_view(struct d3d9_surface *surface) DECLSPEC_HIDDEN; void surface_init(struct d3d9_surface *surface, IUnknown *container_parent, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) DECLSPEC_HIDDEN; + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *wined3d_texture, UINT idx) DECLSPEC_HIDDEN; struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
struct d3d9_vertexbuffer diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 092ed10..c60cbba 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1121,6 +1121,7 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width sub_resource = wined3d_texture_get_sub_resource(texture, 0); surface_impl = wined3d_resource_get_parent(sub_resource); surface_impl->parent_device = &device->IDirect3DDevice9Ex_iface; + surface_impl->wined3d_texture = texture; *surface = &surface_impl->IDirect3DSurface9_iface; IDirect3DSurface9_AddRef(*surface);
@@ -3535,17 +3536,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, void **parent, - const struct wined3d_parent_ops **parent_ops, UINT idx) + const struct wined3d_parent_ops **parent_ops, struct wined3d_texture *texture, UINT idx) { struct d3d9_surface *d3d_surface;
- TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p, index %u.\n", - device_parent, container_parent, surface, parent, parent_ops, idx); + TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p, texture %p, index %u.\n", + device_parent, container_parent, surface, parent, parent_ops, texture, idx);
if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface)))) return E_OUTOFMEMORY;
- surface_init(d3d_surface, container_parent, surface, parent_ops, idx); + surface_init(d3d_surface, container_parent, surface, parent_ops, texture, idx); *parent = d3d_surface; TRACE("Created surface %p.\n", d3d_surface);
@@ -3554,17 +3555,17 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
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, UINT idx) + const struct wined3d_parent_ops **parent_ops, struct wined3d_texture *texture, UINT idx) { struct d3d9_volume *d3d_volume;
- TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, index %u.\n", - device_parent, container_parent, volume, parent, parent_ops, idx); + TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, texture %p, index %u.\n", + device_parent, container_parent, volume, parent, parent_ops, texture, idx);
if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) return E_OUTOFMEMORY;
- volume_init(d3d_volume, container_parent, volume, parent_ops, idx); + volume_init(d3d_volume, container_parent, volume, parent_ops, texture, idx); *parent = d3d_volume; TRACE("Created volume %p.\n", d3d_volume);
diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index b1f0a11..602ffec 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -346,7 +346,8 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops = };
void surface_init(struct d3d9_surface *surface, IUnknown *container_parent, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *wined3d_texture, UINT idx) { struct wined3d_resource_desc desc; IDirect3DBaseTexture9 *texture; @@ -357,6 +358,7 @@ void surface_init(struct d3d9_surface *surface, IUnknown *container_parent, surface->wined3d_surface = wined3d_surface; list_init(&surface->rtv_entry); surface->container = container_parent; + surface->wined3d_texture = wined3d_texture; surface->sub_resource_idx = idx;
if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent, diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index 8df829c..2795ab7 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -202,13 +202,15 @@ static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops = };
void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture, - struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, UINT idx) + struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *wined3d_texture, UINT idx) { volume->IDirect3DVolume9_iface.lpVtbl = &d3d9_volume_vtbl; d3d9_resource_init(&volume->resource); volume->resource.refcount = 0; volume->wined3d_volume = wined3d_volume; volume->texture = texture; + volume->wined3d_texture = wined3d_texture; volume->sub_resource_idx = idx;
*parent_ops = &d3d9_volume_wined3d_parent_ops; diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 6f35b23..9c8d337 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4713,13 +4713,13 @@ 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, const struct wined3d_parent_ops **parent_ops, UINT idx) + void **parent, const struct wined3d_parent_ops **parent_ops, struct wined3d_texture *texture, UINT idx) { 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, index %u.\n", - device_parent, container_parent, surface, parent, parent_ops, idx); + TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p, texture %p, index %u.\n", + device_parent, container_parent, surface, parent, parent_ops, texture, idx);
/* We have a swapchain or wined3d internal texture. */ if (!container_parent || container_parent == ddraw) @@ -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, idx); + ddraw_surface_init(ddraw_surface, ddraw, container_parent, surface, parent_ops, texture, idx); *parent = ddraw_surface; list_add_head(&ddraw->surface_list, &ddraw_surface->surface_list_entry);
@@ -4747,10 +4747,10 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
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, UINT idx) + void **parent, const struct wined3d_parent_ops **parent_ops, struct wined3d_texture *texture, UINT idx) { - TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, index %u.\n", - device_parent, container_parent, volume, parent, parent_ops, idx); + TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p, texture %p, index %u.\n", + device_parent, container_parent, volume, parent, parent_ops, texture, idx);
*parent = NULL; *parent_ops = &ddraw_null_wined3d_parent_ops; diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index ff0621b..f6dd3ad 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -210,7 +210,8 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ struct ddraw_surface **surface, IUnknown *outer_unknown, unsigned int version) DECLSPEC_HIDDEN; struct wined3d_rendertarget_view *ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface) DECLSPEC_HIDDEN; void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) DECLSPEC_HIDDEN; + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *wined3d_texture, UINT idx) DECLSPEC_HIDDEN; ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN; HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface, const RECT *rect, BOOL read) DECLSPEC_HIDDEN; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 0e66a1b..ada8372 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -6227,7 +6227,8 @@ fail: }
void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture, - struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, UINT idx) + struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *wined3d_texture, UINT idx) { DDSURFACEDESC2 *desc = &surface->surface_desc; struct wined3d_resource_desc wined3d_desc; @@ -6244,6 +6245,7 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, stru surface->iface_count = 1; surface->version = version; surface->ddraw = ddraw; + surface->wined3d_texture = wined3d_texture; surface->sub_resource_idx = idx;
if (version == 7) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 0676948..654b917 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -5414,7 +5414,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, idx))) + wined3d_texture_get_parent(container), object, &parent, &parent_ops, container, idx))) { WARN("Failed to create surface parent, hr %#x.\n", hr); wined3d_surface_destroy(object); diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index 047251a..6a7600d 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -796,7 +796,7 @@ HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wi }
if (FAILED(hr = device_parent->ops->volume_created(device_parent, - wined3d_texture_get_parent(container), object, &parent, &parent_ops, level))) + wined3d_texture_get_parent(container), object, &parent, &parent_ops, container, level))) { WARN("Failed to create volume parent, hr %#x.\n", hr); wined3d_volume_destroy(object); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index adec90a..00d666c 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2031,9 +2031,11 @@ struct wined3d_device_parent_ops 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, - struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops, UINT idx); + struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *texture, UINT idx); 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, UINT idx); + struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops, + struct wined3d_texture *texture, UINT idx); HRESULT (__cdecl *create_swapchain_texture)(struct wined3d_device_parent *device_parent, void *parent, const struct wined3d_resource_desc *desc, struct wined3d_texture **texture); HRESULT (__cdecl *create_swapchain)(struct wined3d_device_parent *device_parent,
--- dlls/wined3d/texture.c | 29 +++++++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 2 ++ include/wine/wined3d.h | 3 +++ 3 files changed, 34 insertions(+)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index b369809..21cd262 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1465,3 +1465,32 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
return WINED3D_OK; } + +HRESULT CDECL wined3d_texture_sub_resource_map(struct wined3d_texture *texture, UINT sub_resource_idx, + struct wined3d_map_desc *map_desc, const void *rect_or_box, DWORD flags) +{ + struct wined3d_resource *sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx); + + if (!sub_resource) + return WINED3DERR_INVALIDCALL; + + if (texture->resource.type == WINED3D_RTYPE_VOLUME_TEXTURE) + return wined3d_volume_map(wined3d_volume_from_resource(sub_resource), + map_desc, (const struct wined3d_box *)rect_or_box, flags); + else + return wined3d_surface_map(wined3d_surface_from_resource(sub_resource), + map_desc, (const RECT *)rect_or_box, flags); +} + +HRESULT CDECL wined3d_texture_sub_resource_unmap(struct wined3d_texture *texture, UINT sub_resource_idx) +{ + struct wined3d_resource *sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx); + + if (!sub_resource) + return WINED3DERR_INVALIDCALL; + + if (texture->resource.type == WINED3D_RTYPE_VOLUME_TEXTURE) + return wined3d_volume_unmap(wined3d_volume_from_resource(sub_resource)); + else + return wined3d_surface_unmap(wined3d_surface_from_resource(sub_resource)); +} diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 9531dd3..4c2dd9e 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -273,6 +273,8 @@ @ cdecl wined3d_texture_set_autogen_filter_type(ptr long) @ cdecl wined3d_texture_set_color_key(ptr long ptr) @ cdecl wined3d_texture_set_lod(ptr long) +@ cdecl wined3d_texture_sub_resource_map(ptr long ptr ptr long) +@ cdecl wined3d_texture_sub_resource_unmap(ptr long) @ cdecl wined3d_texture_update_desc(ptr long long long long long ptr long)
@ cdecl wined3d_vertex_declaration_create(ptr ptr long ptr ptr ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 00d666c..e8d99e7 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2551,6 +2551,9 @@ HRESULT __cdecl wined3d_texture_set_autogen_filter_type(struct wined3d_texture * HRESULT __cdecl wined3d_texture_set_color_key(struct wined3d_texture *texture, DWORD flags, const struct wined3d_color_key *color_key); DWORD __cdecl wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod); +HRESULT __cdecl wined3d_texture_sub_resource_map(struct wined3d_texture *texture, UINT sub_resource_idx, + struct wined3d_map_desc *map_desc, const void *rect_or_box, DWORD flags); +HRESULT __cdecl wined3d_texture_sub_resource_unmap(struct wined3d_texture *texture, UINT sub_resource_idx); HRESULT __cdecl wined3d_texture_update_desc(struct wined3d_texture *texture, UINT width, UINT height, enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type, UINT multisample_quality,
--- dlls/d3d11/texture.c | 28 ++++------------------------ dlls/d3d8/surface.c | 5 +++-- dlls/d3d8/volume.c | 5 +++-- dlls/d3d9/surface.c | 5 +++-- dlls/d3d9/volume.c | 5 +++-- dlls/ddraw/surface.c | 14 +++++++------- dlls/wined3d/wined3d.spec | 4 ---- dlls/wined3d/wined3d_private.h | 6 ++++++ include/wine/wined3d.h | 6 ------ 9 files changed, 29 insertions(+), 49 deletions(-)
diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c index 85d001f..ed2a5d6 100644 --- a/dlls/d3d11/texture.c +++ b/dlls/d3d11/texture.c @@ -357,7 +357,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN { struct d3d_texture2d *texture = impl_from_ID3D10Texture2D(iface); struct wined3d_map_desc wined3d_map_desc; - struct wined3d_resource *sub_resource; HRESULT hr;
TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n", @@ -367,9 +366,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN FIXME("Ignoring map_flags %#x.\n", map_flags);
wined3d_mutex_lock(); - if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx))) - hr = E_INVALIDARG; - else if (SUCCEEDED(hr = wined3d_surface_map(wined3d_surface_from_resource(sub_resource), + if (SUCCEEDED(hr = wined3d_texture_sub_resource_map(texture->wined3d_texture, sub_resource_idx, &wined3d_map_desc, NULL, wined3d_map_flags_from_d3d10_map_type(map_type)))) { mapped_texture->pData = wined3d_map_desc.data; @@ -383,18 +380,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_Map(ID3D10Texture2D *iface, UIN static void STDMETHODCALLTYPE d3d10_texture2d_Unmap(ID3D10Texture2D *iface, UINT sub_resource_idx) { struct d3d_texture2d *texture = impl_from_ID3D10Texture2D(iface); - struct wined3d_resource *sub_resource;
TRACE("iface %p, sub_resource_idx %u.\n", iface, sub_resource_idx);
wined3d_mutex_lock(); - if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx))) - { - wined3d_mutex_unlock(); - return; - } - - wined3d_surface_unmap(wined3d_surface_from_resource(sub_resource)); + wined3d_texture_sub_resource_unmap(texture->wined3d_texture, sub_resource_idx); wined3d_mutex_unlock(); }
@@ -824,7 +814,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN { struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface); struct wined3d_map_desc wined3d_map_desc; - struct wined3d_resource *sub_resource; HRESULT hr;
TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n", @@ -834,9 +823,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN FIXME("Ignoring map_flags %#x.\n", map_flags);
wined3d_mutex_lock(); - if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx))) - hr = E_INVALIDARG; - else if (SUCCEEDED(hr = wined3d_volume_map(wined3d_volume_from_resource(sub_resource), + if (SUCCEEDED(hr = wined3d_texture_sub_resource_map(texture->wined3d_texture, sub_resource_idx, &wined3d_map_desc, NULL, wined3d_map_flags_from_d3d10_map_type(map_type)))) { mapped_texture->pData = wined3d_map_desc.data; @@ -851,18 +838,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UIN static void STDMETHODCALLTYPE d3d10_texture3d_Unmap(ID3D10Texture3D *iface, UINT sub_resource_idx) { struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface); - struct wined3d_resource *sub_resource;
TRACE("iface %p, sub_resource_idx %u.\n", iface, sub_resource_idx);
wined3d_mutex_lock(); - if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx))) - { - wined3d_mutex_unlock(); - return; - } - - wined3d_volume_unmap(wined3d_volume_from_resource(sub_resource)); + wined3d_texture_sub_resource_unmap(texture->wined3d_texture, sub_resource_idx); wined3d_mutex_unlock(); }
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index 81b75e1..61365b9 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -227,7 +227,8 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface, } }
- hr = wined3d_surface_map(surface->wined3d_surface, &map_desc, rect, flags); + hr = wined3d_texture_sub_resource_map(surface->wined3d_texture, surface->sub_resource_idx, + &map_desc, rect, flags); wined3d_mutex_unlock();
if (SUCCEEDED(hr)) @@ -252,7 +253,7 @@ static HRESULT WINAPI d3d8_surface_UnlockRect(IDirect3DSurface8 *iface) TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); - hr = wined3d_surface_unmap(surface->wined3d_surface); + hr = wined3d_texture_sub_resource_unmap(surface->wined3d_texture, surface->sub_resource_idx); wined3d_mutex_unlock();
switch(hr) diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c index 0cc6403..8e4f27c 100644 --- a/dlls/d3d8/volume.c +++ b/dlls/d3d8/volume.c @@ -148,7 +148,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, iface, locked_box, box, flags);
wined3d_mutex_lock(); - hr = wined3d_volume_map(volume->wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags); + hr = wined3d_texture_sub_resource_map(volume->wined3d_texture, volume->sub_resource_idx, + &map_desc, (const struct wined3d_box *)box, flags); wined3d_mutex_unlock();
locked_box->RowPitch = map_desc.row_pitch; @@ -166,7 +167,7 @@ static HRESULT WINAPI d3d8_volume_UnlockBox(IDirect3DVolume8 *iface) TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); - hr = wined3d_volume_unmap(volume->wined3d_volume); + hr = wined3d_texture_sub_resource_unmap(volume->wined3d_texture, volume->sub_resource_idx); wined3d_mutex_unlock();
return hr; diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index 602ffec..b69954f 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -240,7 +240,8 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface, iface, locked_rect, wine_dbgstr_rect(rect), flags);
wined3d_mutex_lock(); - hr = wined3d_surface_map(surface->wined3d_surface, &map_desc, rect, flags); + hr = wined3d_texture_sub_resource_map(surface->wined3d_texture, surface->sub_resource_idx, + &map_desc, rect, flags); wined3d_mutex_unlock();
if (SUCCEEDED(hr)) @@ -260,7 +261,7 @@ static HRESULT WINAPI d3d9_surface_UnlockRect(IDirect3DSurface9 *iface) TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); - hr = wined3d_surface_unmap(surface->wined3d_surface); + hr = wined3d_texture_sub_resource_unmap(surface->wined3d_texture, surface->sub_resource_idx); wined3d_mutex_unlock();
switch(hr) diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index 2795ab7..2ca6627 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -148,7 +148,8 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface, iface, locked_box, box, flags);
wined3d_mutex_lock(); - hr = wined3d_volume_map(volume->wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags); + hr = wined3d_texture_sub_resource_map(volume->wined3d_texture, volume->sub_resource_idx, + &map_desc, (const struct wined3d_box *)box, flags); wined3d_mutex_unlock();
locked_box->RowPitch = map_desc.row_pitch; @@ -166,7 +167,7 @@ static HRESULT WINAPI d3d9_volume_UnlockBox(IDirect3DVolume9 *iface) TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); - hr = wined3d_volume_unmap(volume->wined3d_volume); + hr = wined3d_texture_sub_resource_unmap(volume->wined3d_texture, volume->sub_resource_idx); wined3d_mutex_unlock();
return hr; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index ada8372..90448f9 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -989,7 +989,7 @@ static HRESULT surface_lock(struct ddraw_surface *This, if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) hr = ddraw_surface_update_frontbuffer(This, Rect, TRUE); if (SUCCEEDED(hr)) - hr = wined3d_surface_map(This->wined3d_surface, &map_desc, Rect, Flags); + hr = wined3d_texture_sub_resource_map(This->wined3d_texture, This->sub_resource_idx, &map_desc, Rect, Flags); if (FAILED(hr)) { wined3d_mutex_unlock(); @@ -1162,7 +1162,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Unlock(IDirectDrawSurface TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(pRect));
wined3d_mutex_lock(); - hr = wined3d_surface_unmap(surface->wined3d_surface); + wined3d_texture_sub_resource_unmap(surface->wined3d_texture, surface->sub_resource_idx); if (SUCCEEDED(hr) && surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) hr = ddraw_surface_update_frontbuffer(surface, &surface->ddraw->primary_lock, FALSE); wined3d_mutex_unlock(); @@ -5148,7 +5148,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu /* Copy the main memory texture into the surface that corresponds * to the OpenGL texture object. */
- hr = wined3d_surface_map(src_surface->wined3d_surface, &src_map_desc, NULL, 0); + hr = wined3d_texture_sub_resource_map(src_surface->wined3d_texture, src_surface->sub_resource_idx, &src_map_desc, NULL, 0); if (FAILED(hr)) { ERR("Failed to lock source surface, hr %#x.\n", hr); @@ -5156,11 +5156,11 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu return D3DERR_TEXTURE_LOAD_FAILED; }
- hr = wined3d_surface_map(dst_surface->wined3d_surface, &dst_map_desc, NULL, 0); + hr = wined3d_texture_sub_resource_map(dst_surface->wined3d_texture, dst_surface->sub_resource_idx, &dst_map_desc, NULL, 0); if (FAILED(hr)) { ERR("Failed to lock destination surface, hr %#x.\n", hr); - wined3d_surface_unmap(src_surface->wined3d_surface); + wined3d_texture_sub_resource_unmap(src_surface->wined3d_texture, src_surface->sub_resource_idx); wined3d_mutex_unlock(); return D3DERR_TEXTURE_LOAD_FAILED; } @@ -5170,8 +5170,8 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu else memcpy(dst_map_desc.data, src_map_desc.data, src_map_desc.row_pitch * src_desc->dwHeight);
- wined3d_surface_unmap(src_surface->wined3d_surface); - wined3d_surface_unmap(dst_surface->wined3d_surface); + wined3d_texture_sub_resource_unmap(src_surface->wined3d_texture, src_surface->sub_resource_idx); + wined3d_texture_sub_resource_unmap(dst_surface->wined3d_texture, dst_surface->sub_resource_idx); }
if (src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 4c2dd9e..88f95d0 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -232,12 +232,10 @@ @ cdecl wined3d_surface_getdc(ptr ptr) @ cdecl wined3d_surface_incref(ptr) @ cdecl wined3d_surface_is_lost(ptr) -@ cdecl wined3d_surface_map(ptr ptr ptr long) @ cdecl wined3d_surface_preload(ptr) @ cdecl wined3d_surface_releasedc(ptr ptr) @ cdecl wined3d_surface_restore(ptr) @ cdecl wined3d_surface_set_overlay_position(ptr long long) -@ cdecl wined3d_surface_unmap(ptr) @ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr) @ cdecl wined3d_surface_update_overlay_z_order(ptr long ptr)
@@ -285,5 +283,3 @@
@ cdecl wined3d_volume_from_resource(ptr) @ cdecl wined3d_volume_get_resource(ptr) -@ cdecl wined3d_volume_map(ptr ptr ptr long) -@ cdecl wined3d_volume_unmap(ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 758af54..515ba3b 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2332,6 +2332,9 @@ void wined3d_volume_get_pitch(const struct wined3d_volume *volume, UINT *row_pit void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context, BOOL srgb_mode) DECLSPEC_HIDDEN; void wined3d_volume_invalidate_location(struct wined3d_volume *volume, DWORD location) DECLSPEC_HIDDEN; +HRESULT __cdecl wined3d_volume_map(struct wined3d_volume *volume, + struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) DECLSPEC_HIDDEN; +HRESULT __cdecl wined3d_volume_unmap(struct wined3d_volume *volume) DECLSPEC_HIDDEN; void wined3d_volume_validate_location(struct wined3d_volume *volume, DWORD location) DECLSPEC_HIDDEN; void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context, const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN; @@ -2449,6 +2452,9 @@ HRESULT wined3d_surface_create(struct wined3d_texture *container, const struct w GLenum target, unsigned int level, unsigned int layer, DWORD flags, struct wined3d_surface **surface) DECLSPEC_HIDDEN; void wined3d_surface_destroy(struct wined3d_surface *surface) DECLSPEC_HIDDEN; +HRESULT wined3d_surface_map(struct wined3d_surface *surface, + struct wined3d_map_desc *map_desc, const RECT *rect, DWORD flags); DECLSPEC_HIDDEN; +HRESULT wined3d_surface_unmap(struct wined3d_surface *surface); DECLSPEC_HIDDEN; void surface_prepare_map_memory(struct wined3d_surface *surface) DECLSPEC_HIDDEN; void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, const struct wined3d_format *format, const RECT *src_rect, UINT src_pitch, const POINT *dst_point, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index e8d99e7..1b8028e 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2489,13 +2489,10 @@ struct wined3d_resource * __cdecl wined3d_surface_get_resource(struct wined3d_su HRESULT __cdecl wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc); ULONG __cdecl wined3d_surface_incref(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_is_lost(const struct wined3d_surface *surface); -HRESULT __cdecl wined3d_surface_map(struct wined3d_surface *surface, - struct wined3d_map_desc *map_desc, const RECT *rect, DWORD flags); void __cdecl wined3d_surface_preload(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc); HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y); -HRESULT __cdecl wined3d_surface_unmap(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_update_overlay(struct wined3d_surface *surface, const RECT *src_rect, struct wined3d_surface *dst_surface, const RECT *dst_rect, DWORD flags, const WINEDDOVERLAYFX *fx); HRESULT __cdecl wined3d_surface_update_overlay_z_order(struct wined3d_surface *surface, @@ -2571,9 +2568,6 @@ ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaratio
struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource); struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume); -HRESULT __cdecl wined3d_volume_map(struct wined3d_volume *volume, - struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags); -HRESULT __cdecl wined3d_volume_unmap(struct wined3d_volume *volume);
/* Return the integer base-2 logarithm of x. Undefined for x == 0. */ static inline unsigned int wined3d_log2i(unsigned int x)
--- dlls/wined3d/wined3d.spec | 1 - dlls/wined3d/wined3d_private.h | 1 + include/wine/wined3d.h | 1 - 3 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 88f95d0..bc3f790 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -281,5 +281,4 @@ @ cdecl wined3d_vertex_declaration_get_parent(ptr) @ cdecl wined3d_vertex_declaration_incref(ptr)
-@ cdecl wined3d_volume_from_resource(ptr) @ cdecl wined3d_volume_get_resource(ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 515ba3b..85c4603 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2328,6 +2328,7 @@ BOOL volume_prepare_system_memory(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_destroy(struct wined3d_volume *volume) DECLSPEC_HIDDEN; +struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource) DECLSPEC_HIDDEN; void wined3d_volume_get_pitch(const struct wined3d_volume *volume, UINT *row_pitch, UINT *slice_pitch) DECLSPEC_HIDDEN; void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context, BOOL srgb_mode) DECLSPEC_HIDDEN; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 1b8028e..12c57f8 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2566,7 +2566,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);
-struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource); struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume);
/* Return the integer base-2 logarithm of x. Undefined for x == 0. */
--- dlls/d3d8/volume.c | 2 +- dlls/d3d9/volume.c | 2 +- dlls/wined3d/wined3d.spec | 2 -- dlls/wined3d/wined3d_private.h | 1 + include/wine/wined3d.h | 2 -- 5 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c index 8e4f27c..00ff1f2 100644 --- a/dlls/d3d8/volume.c +++ b/dlls/d3d8/volume.c @@ -121,7 +121,7 @@ static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DES TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock(); - wined3d_resource = wined3d_volume_get_resource(volume->wined3d_volume); + wined3d_resource = wined3d_texture_get_sub_resource(volume->texture->wined3d_texture, volume->sub_resource_idx); wined3d_resource_get_desc(wined3d_resource, &wined3d_desc); wined3d_mutex_unlock();
diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index 2ca6627..b7a6542 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -122,7 +122,7 @@ static HRESULT WINAPI d3d9_volume_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DES TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock(); - wined3d_resource = wined3d_volume_get_resource(volume->wined3d_volume); + wined3d_resource = wined3d_texture_get_sub_resource(volume->texture->wined3d_texture, volume->sub_resource_idx); wined3d_resource_get_desc(wined3d_resource, &wined3d_desc); wined3d_mutex_unlock();
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index bc3f790..7654b22 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -280,5 +280,3 @@ @ cdecl wined3d_vertex_declaration_decref(ptr) @ cdecl wined3d_vertex_declaration_get_parent(ptr) @ cdecl wined3d_vertex_declaration_incref(ptr) - -@ cdecl wined3d_volume_get_resource(ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 85c4603..1c82fbc 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2330,6 +2330,7 @@ HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wi void wined3d_volume_destroy(struct wined3d_volume *volume) DECLSPEC_HIDDEN; struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource) DECLSPEC_HIDDEN; void wined3d_volume_get_pitch(const struct wined3d_volume *volume, UINT *row_pitch, UINT *slice_pitch) DECLSPEC_HIDDEN; +struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume) DECLSPEC_HIDDEN; void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context, BOOL srgb_mode) DECLSPEC_HIDDEN; void wined3d_volume_invalidate_location(struct wined3d_volume *volume, DWORD location) DECLSPEC_HIDDEN; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 12c57f8..257abe8 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2566,8 +2566,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);
-struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume); - /* Return the integer base-2 logarithm of x. Undefined for x == 0. */ static inline unsigned int wined3d_log2i(unsigned int x) {
On 11 September 2015 at 09:08, Riccardo Bortolato rikyz619@gmail.com wrote:
Here is a follow up on the small fixes I sent the other day.
I'm storing the wined3d texture and sub level in the d3dX surfaces/volumes and this allows to go further with the removal of surfaces/volumes from the public api.
With these commits I also introduce a temporary function to handle mapping for surfaces and volumes which I hope it will gradually handle more of that eventually delegating only bound checks (and maybe other minor things) to helper functions.
Finally the remaining volume-related exported functions are removed.
At first sight this looks mostly ok. You may want to merge patches 1/6 and 2/6, since they mostly seem to be touching the same places and are closely related anyway. Once you pass the wined3d texture to device_parent_surface_created()/device_parent_volume_created() you no longer need to pass "container_parent", since you can just call wined3d_texture_get_parent() on the wined3d texture to get it. You'll probably want to rename "idx" to "sub_resource_idx" and just make it unsigned int.
In patch 3/6 the decision to use wined3d_volume_map() or wined3d_surface_map() should probably go through wined3d_texture_ops. Just pass a wined3d_box structure insead of a void pointer. (And passing a wined3d_box structure to wined3d_surface_map() should probably be a preparation patch for that.) Usage and introduction should go together in patches 3/6 and 4/6, but you can do map() and unmap() in separate patches. You could also potentially further split that per-dll/sub-resource type (E.g. "d3d9: Use wined3d_texture_map() in d3d9_surface_LockRect()."), although I don't think the patch is excessively large as it is. wined3d_texture_map()/wined3d_texture_unmap() is fine for the function names, no need for the extra "sub_resource" there.
- hr = wined3d_surface_unmap(surface->wined3d_surface);
- wined3d_texture_sub_resource_unmap(surface->wined3d_texture, surface->sub_resource_idx); if (SUCCEEDED(hr) && surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
You're dropping the return code here.
You can drop the __cdecl in patch 5/6. I think wined3d_volume_get_resource() should be unused after patch 6/6, and I think you should be able to just use volume->wined3d_texture instead of volume->texture->wined3d_texture.
What to do with buffers is still unclear to me.
I think it's mostly of later concern, after surfaces and volumes are unified, but the idea is to eventually have something like wined3d_resource_map() that just ignores the sub-resource index for buffers. (Or perhaps requires it to be 0.)
2015-09-11 16:48 GMT+02:00 Henri Verbeet hverbeet@gmail.com:
On 11 September 2015 at 09:08, Riccardo Bortolato rikyz619@gmail.com wrote:
Here is a follow up on the small fixes I sent the other day.
I'm storing the wined3d texture and sub level in the d3dX surfaces/volumes and this allows to go further with the removal of surfaces/volumes from the public api.
With these commits I also introduce a temporary function to handle mapping for surfaces and volumes which I hope it will gradually handle more of that eventually delegating only bound checks (and maybe other minor things) to helper functions.
Finally the remaining volume-related exported functions are removed.
At first sight this looks mostly ok. You may want to merge patches 1/6 and 2/6, since they mostly seem to be touching the same places and are closely related anyway. Once you pass the wined3d texture to device_parent_surface_created()/device_parent_volume_created() you no longer need to pass "container_parent", since you can just call wined3d_texture_get_parent() on the wined3d texture to get it. You'll probably want to rename "idx" to "sub_resource_idx" and just make it unsigned int.
all right
In patch 3/6 the decision to use wined3d_volume_map() or wined3d_surface_map() should probably go through wined3d_texture_ops.
ok
Just pass a wined3d_box structure insead of a void pointer. (And passing a wined3d_box structure to wined3d_surface_map() should probably be a preparation patch for that.)
I kept the RECT * because I get 24 hits in wined3d_private.h, it felt like the change was too big and needed better thinking but I can reverse the decision and pass around a wined3d_box * instead.
Usage and introduction should go together in patches 3/6 and 4/6, but you can do map() and unmap() in separate patches. You could also potentially further split that per-dll/sub-resource type (E.g. "d3d9: Use wined3d_texture_map() in d3d9_surface_LockRect()."), although I don't think the patch is excessively large as it is. wined3d_texture_map()/wined3d_texture_unmap() is fine for the function names, no need for the extra "sub_resource" there.
- hr = wined3d_surface_unmap(surface->wined3d_surface);
- wined3d_texture_sub_resource_unmap(surface->wined3d_texture, surface->sub_resource_idx); if (SUCCEEDED(hr) && surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
You're dropping the return code here.
You can drop the __cdecl in patch 5/6. I think wined3d_volume_get_resource() should be unused after patch 6/6, and I think you should be able to just use volume->wined3d_texture instead of volume->texture->wined3d_texture.
What to do with buffers is still unclear to me.
I think it's mostly of later concern, after surfaces and volumes are unified, but the idea is to eventually have something like wined3d_resource_map() that just ignores the sub-resource index for buffers. (Or perhaps requires it to be 0.)
OK. I'll do the RECT to wined3d_box changes and then re-apply those with your suggested changes.
Greets, Riccardo
On 11 September 2015 at 18:34, Riccardo Bortolato rikyz619@gmail.com wrote:
Just pass a wined3d_box structure insead of a void pointer. (And passing a wined3d_box structure to wined3d_surface_map() should probably be a preparation patch for that.)
I kept the RECT * because I get 24 hits in wined3d_private.h, it felt like the change was too big and needed better thinking but I can reverse the decision and pass around a wined3d_box * instead.
We'll probably want to consistently use wined3d_box at some point, but just changing wined3d_surface_map() shouldn't be too hard. We'd probably like a debug function along the lines of wine_dbgstr_rect() for boxes, but we don't currently have that for wined3d_volume_map() either.
My issue was with surface_check_block_align (used by tons of functions) but I guess I'll (temporary) convert back to RECT and then finally implement a wined3d_texture_check_block_align(tex, sub_idx, box ..).
Ciao, Riccardo
2015-09-11 19:24 GMT+02:00 Henri Verbeet hverbeet@gmail.com:
On 11 September 2015 at 18:34, Riccardo Bortolato rikyz619@gmail.com wrote:
Just pass a wined3d_box structure insead of a void pointer. (And passing a wined3d_box structure to wined3d_surface_map() should probably be a preparation patch for that.)
I kept the RECT * because I get 24 hits in wined3d_private.h, it felt like the change was too big and needed better thinking but I can reverse the decision and pass around a wined3d_box * instead.
We'll probably want to consistently use wined3d_box at some point, but just changing wined3d_surface_map() shouldn't be too hard. We'd probably like a debug function along the lines of wine_dbgstr_rect() for boxes, but we don't currently have that for wined3d_volume_map() either.
On 11 September 2015 at 19:28, Riccardo Bortolato rikyz619@gmail.com wrote:
My issue was with surface_check_block_align (used by tons of functions) but I guess I'll (temporary) convert back to RECT and then finally implement a wined3d_texture_check_block_align(tex, sub_idx, box ..).
I'm not sure we'll ever need that to be generic, just renaming the existing one to something like surface_check_block_align_rect() and then introducing a new surface_check_block_align() that takes a box should work. The rect variant should then eventually just go away.
Hi Henri,
In patch 3/6 the decision to use wined3d_volume_map() or wined3d_surface_map() should probably go through wined3d_texture_ops.
About this one, what did you have in mind? an intermediate function that casts the correct type from a resource and calls the proper mapping function?
Ciao, Riccardo
2015-09-11 19:38 GMT+02:00 Henri Verbeet hverbeet@gmail.com:
On 11 September 2015 at 19:28, Riccardo Bortolato rikyz619@gmail.com wrote:
My issue was with surface_check_block_align (used by tons of functions) but I guess I'll (temporary) convert back to RECT and then finally implement a wined3d_texture_check_block_align(tex, sub_idx, box ..).
I'm not sure we'll ever need that to be generic, just renaming the existing one to something like surface_check_block_align_rect() and then introducing a new surface_check_block_align() that takes a box should work. The rect variant should then eventually just go away.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Am 2015-09-14 um 11:12 schrieb Riccardo Bortolato:
About this one, what did you have in mind? an intermediate function that casts the correct type from a resource and calls the proper mapping function?
See
static const struct wined3d_texture_ops texture2d_ops = ... static const struct wined3d_texture_ops texture3d_ops = ...
You'd have two implementations of the function. One is used for texture2d_ops, and it calls wined3d_surface, the other one is used for texture3d_ops and calls wined3d_volume.
Note that texture2d_ops is used for 2D and cube textures. That shouldn't be an issue since cube textures are built out of surfaces as well (just 6 per level instead of 1 per level).
On 14 September 2015 at 11:12, Riccardo Bortolato rikyz619@gmail.com wrote:
In patch 3/6 the decision to use wined3d_volume_map() or wined3d_surface_map() should probably go through wined3d_texture_ops.
About this one, what did you have in mind? an intermediate function that casts the correct type from a resource and calls the proper mapping function?
More or less. You'd have e.g. a texture2d_sub_resource_map() function that would call wined3d_surface_map(surface_from_resource(sub_resource), ...). And then eventually wined3d_surface_map() would just get merged into texture2d_sub_resource_map().