[PATCH 4/7] wined3d: replace wined3d_{surface, volume}_(un)map with wined3d_texture_(un)map
Riccardo Bortolato
rikyz619 at gmail.com
Mon Sep 14 06:14:01 CDT 2015
---
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/surface.c | 4 ++--
dlls/wined3d/volume.c | 4 ++--
dlls/wined3d/wined3d.spec | 4 ----
dlls/wined3d/wined3d_private.h | 10 ++++++++++
include/wine/wined3d.h | 6 ------
11 files changed, 37 insertions(+), 53 deletions(-)
diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c
index 85d001f..cd6b2fd 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_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_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_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_unmap(texture->wined3d_texture, sub_resource_idx);
wined3d_mutex_unlock();
}
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c
index be5d338..4f16a20 100644
--- a/dlls/d3d8/surface.c
+++ b/dlls/d3d8/surface.c
@@ -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 ? (const struct wined3d_box *)&box : NULL, flags);
+ hr = wined3d_texture_map(surface->wined3d_texture, surface->sub_resource_idx,
+ &map_desc, rect ? (const struct wined3d_box *)&box : NULL, flags);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
@@ -259,7 +260,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_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 d66c770..e43e355 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_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_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 ea1f8b3..fa68850 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -250,7 +250,8 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface,
box.back = 1;
}
wined3d_mutex_lock();
- hr = wined3d_surface_map(surface->wined3d_surface, &map_desc, rect ? (const struct wined3d_box *)&box : NULL, flags);
+ hr = wined3d_texture_map(surface->wined3d_texture, surface->sub_resource_idx,
+ &map_desc, rect ? (const struct wined3d_box *)&box : NULL, flags);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
@@ -270,7 +271,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_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 83eaa7c..45e192b 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_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_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 dac8e5d..ec0ee22 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -996,7 +996,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 ? (const struct wined3d_box *)&box : NULL, Flags);
+ hr = wined3d_texture_map(This->wined3d_texture, This->sub_resource_idx, &map_desc, Rect ? (const struct wined3d_box *)&box : NULL, Flags);
if (FAILED(hr))
{
wined3d_mutex_unlock();
@@ -1169,7 +1169,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);
+ hr = wined3d_texture_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();
@@ -5155,7 +5155,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_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);
@@ -5163,11 +5163,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_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_unmap(src_surface->wined3d_texture, src_surface->sub_resource_idx);
wined3d_mutex_unlock();
return D3DERR_TEXTURE_LOAD_FAILED;
}
@@ -5177,8 +5177,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_unmap(src_surface->wined3d_texture, src_surface->sub_resource_idx);
+ wined3d_texture_unmap(dst_surface->wined3d_texture, dst_surface->sub_resource_idx);
}
if (src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 280fe49..e3def02 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2461,7 +2461,7 @@ struct wined3d_surface * CDECL wined3d_surface_from_resource(struct wined3d_reso
return surface_from_resource(resource);
}
-HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface)
+HRESULT wined3d_surface_unmap(struct wined3d_surface *surface)
{
TRACE("surface %p.\n", surface);
@@ -2477,7 +2477,7 @@ HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface)
return WINED3D_OK;
}
-HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
+HRESULT wined3d_surface_map(struct wined3d_surface *surface,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
{
const struct wined3d_format *format = surface->resource.format;
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 5582cb0..8ca6ca7 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -531,7 +531,7 @@ static BOOL wined3d_volume_check_box_dimensions(const struct wined3d_volume *vol
return TRUE;
}
-HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume,
+HRESULT wined3d_volume_map(struct wined3d_volume *volume,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
{
struct wined3d_device *device = volume->resource.device;
@@ -681,7 +681,7 @@ struct wined3d_volume * CDECL wined3d_volume_from_resource(struct wined3d_resour
return volume_from_resource(resource);
}
-HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume)
+HRESULT wined3d_volume_unmap(struct wined3d_volume *volume)
{
TRACE("volume %p.\n", volume);
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index a39d946..b101f83 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..7fb136d 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2220,6 +2220,10 @@ struct wined3d_texture_ops
const struct wined3d_context *context, const struct wined3d_sub_resource_data *data);
void (*texture_prepare_texture)(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb);
+ HRESULT (*texture_sub_resource_map)(struct wined3d_resource *sub_resource,
+ struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
+ HRESULT (*texture_sub_resource_unmap)(struct wined3d_resource *sub_resource);
+
};
#define WINED3D_TEXTURE_COND_NP2 0x00000001
@@ -2332,6 +2336,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 wined3d_volume_map(struct wined3d_volume *volume,
+ struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) DECLSPEC_HIDDEN;
+HRESULT 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;
@@ -2450,6 +2457,9 @@ HRESULT wined3d_surface_create(struct wined3d_texture *container, const struct w
struct wined3d_surface **surface) DECLSPEC_HIDDEN;
void wined3d_surface_destroy(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
void surface_prepare_map_memory(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
+HRESULT wined3d_surface_map(struct wined3d_surface *surface,
+ struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) DECLSPEC_HIDDEN;
+HRESULT wined3d_surface_unmap(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,
BOOL srgb, const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 23eb1ed..db28b29 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2489,9 +2489,6 @@ 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 struct wined3d_box *box, 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);
@@ -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)
--
1.9.1
More information about the wine-patches
mailing list