[RFC 4/6] wined3d: replace wined3d_{surface, volume}_(un)map with wined3d_texture_sub_resource_(un)map

Riccardo Bortolato rikyz619 at gmail.com
Fri Sep 11 02:08:08 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/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)
-- 
1.9.1




More information about the wine-devel mailing list