[PATCH 08/10] wined3d: make wined3d_device_update_surface operate with wined3d_texture and sub_resource_idx

Riccardo Bortolato rikyz619 at gmail.com
Mon Oct 19 12:07:36 CDT 2015


updated all calls in wined3d and d3d9

Signed-off-by: Riccardo Bortolato <rikyz619 at gmail.com>
---
 dlls/d3d9/device.c        |  4 ++--
 dlls/wined3d/device.c     | 41 ++++++++++++++++++++++-------------------
 dlls/wined3d/wined3d.spec |  2 +-
 include/wine/wined3d.h    |  4 ++--
 4 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 1432e47..ae3a15a 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1233,8 +1233,8 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface,
             iface, src_surface, src_rect, dst_surface, dst_point);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_update_surface(device->wined3d_device, src->wined3d_surface, src_rect,
-            dst->wined3d_surface, dst_point);
+    hr = wined3d_device_update_surface(device->wined3d_device, src->wined3d_texture, src->sub_resource_idx, src_rect,
+            dst->wined3d_texture, dst->sub_resource_idx, dst_point);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 087dc33..63a1b1e 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3563,15 +3563,10 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
     {
         case WINED3D_RTYPE_TEXTURE:
         {
-            struct wined3d_surface *src_surface;
-            struct wined3d_surface *dst_surface;
-
             for (i = 0; i < level_count; ++i)
             {
-                src_surface = surface_from_resource(wined3d_texture_get_sub_resource(src_texture,
-                        i + src_skip_levels));
-                dst_surface = surface_from_resource(wined3d_texture_get_sub_resource(dst_texture, i));
-                hr = wined3d_device_update_surface(device, src_surface, NULL, dst_surface, NULL);
+                hr = wined3d_device_update_surface(device, src_texture, i + src_skip_levels, NULL,
+                        dst_texture, i, NULL);
                 if (FAILED(hr))
                 {
                     WARN("Failed to update surface, hr %#x.\n", hr);
@@ -3583,8 +3578,6 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
 
         case WINED3D_RTYPE_CUBE_TEXTURE:
         {
-            struct wined3d_surface *src_surface;
-            struct wined3d_surface *dst_surface;
             unsigned int src_levels = wined3d_texture_get_level_count(src_texture);
             unsigned int dst_levels = wined3d_texture_get_level_count(dst_texture);
 
@@ -3592,11 +3585,8 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
             {
                 for (j = 0; j < level_count; ++j)
                 {
-                    src_surface = surface_from_resource(wined3d_texture_get_sub_resource(src_texture,
-                            i * src_levels + j + src_skip_levels));
-                    dst_surface = surface_from_resource(wined3d_texture_get_sub_resource(dst_texture,
-                            i * dst_levels + j));
-                    hr = wined3d_device_update_surface(device, src_surface, NULL, dst_surface, NULL);
+                    hr = wined3d_device_update_surface(device, src_texture, i * src_levels + j + src_skip_levels, NULL,
+                            dst_texture, i * dst_levels + j, NULL);
                     if (FAILED(hr))
                     {
                         WARN("Failed to update surface, hr %#x.\n", hr);
@@ -3774,12 +3764,25 @@ float CDECL wined3d_device_get_npatch_mode(const struct wined3d_device *device)
 /* FIXME: Callers should probably use wined3d_device_update_sub_resource()
  * instead. */
 HRESULT CDECL wined3d_device_update_surface(struct wined3d_device *device,
-        struct wined3d_surface *src_surface, const RECT *src_rect,
-        struct wined3d_surface *dst_surface, const POINT *dst_point)
+        struct wined3d_texture *src_texture, unsigned int src_idx, const RECT *src_rect,
+        struct wined3d_texture *dst_texture, unsigned int dst_idx, const POINT *dst_point)
 {
-    TRACE("device %p, src_surface %p, src_rect %s, dst_surface %p, dst_point %s.\n",
-            device, src_surface, wine_dbgstr_rect(src_rect),
-            dst_surface, wine_dbgstr_point(dst_point));
+    struct wined3d_resource *dst_resource, *src_resource;
+    struct wined3d_surface *dst_surface, *src_surface;
+
+    TRACE("device %p, src_texture %p, src_idx %u, src_rect %s, dst_texture %p, dst_idx %u, dst_point %s.\n",
+            device, src_texture, src_idx, wine_dbgstr_rect(src_rect),
+            dst_texture, dst_idx, wine_dbgstr_point(dst_point));
+
+    dst_resource = wined3d_texture_get_sub_resource(dst_texture, dst_idx);
+    src_resource = wined3d_texture_get_sub_resource(src_texture, src_idx);
+
+    if (!dst_resource || dst_resource->type != WINED3D_RTYPE_SURFACE
+            || !src_resource || src_resource->type != WINED3D_RTYPE_SURFACE)
+        return WINED3DERR_INVALIDCALL;
+
+    dst_surface = surface_from_resource(dst_resource);
+    src_surface = surface_from_resource(src_resource);
 
     if (src_surface->resource.pool != WINED3D_POOL_SYSTEM_MEM || dst_surface->resource.pool != WINED3D_POOL_DEFAULT)
     {
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 5de7876..a9016ba 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -159,7 +159,7 @@
 @ cdecl wined3d_device_uninit_3d(ptr)
 @ cdecl wined3d_device_uninit_gdi(ptr)
 @ cdecl wined3d_device_update_sub_resource(ptr ptr long ptr ptr long long)
-@ cdecl wined3d_device_update_surface(ptr ptr ptr ptr ptr)
+@ cdecl wined3d_device_update_surface(ptr ptr long ptr ptr long ptr)
 @ cdecl wined3d_device_update_texture(ptr ptr ptr)
 @ cdecl wined3d_device_validate_device(ptr ptr)
 
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 28bda4c..a3fe79b 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2318,8 +2318,8 @@ HRESULT __cdecl wined3d_device_uninit_gdi(struct wined3d_device *device);
 void __cdecl wined3d_device_update_sub_resource(struct wined3d_device *device, struct wined3d_resource *resource,
         unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,
         unsigned int depth_pitch);
-HRESULT __cdecl wined3d_device_update_surface(struct wined3d_device *device, struct wined3d_surface *src_surface,
-        const RECT *src_rect, struct wined3d_surface *dst_surface, const POINT *dst_point);
+HRESULT __cdecl wined3d_device_update_surface(struct wined3d_device *device, struct wined3d_texture *src_texture, unsigned int src_idx,
+        const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_idx, const POINT *dst_point);
 HRESULT __cdecl wined3d_device_update_texture(struct wined3d_device *device,
         struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture);
 HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes);
-- 
1.9.1




More information about the wine-patches mailing list