From 20a201f51a62d2735e738987db065a15d8404333 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 7 Feb 2016 18:56:22 +0100
Subject: [PATCH] Added patches to revert "move mip-level dimensions fixup"
 (causes regressions in multiple games).

---
 ...-wined3d_texture_get_sub_resource-in.patch |  90 ++++++++
 ...e-the-mip-level-dimensions-fix-up-fr.patch |  64 ++++++
 patches/ddraw-Revert_Surface_Init/definition  |   1 +
 patches/patchinstall.sh                       |  21 ++
 .../wined3d-CSMT_Main/9999-IfDefined.patch    | 196 +++++++++---------
 5 files changed, 274 insertions(+), 98 deletions(-)
 create mode 100644 patches/ddraw-Revert_Surface_Init/0001-Revert-ddraw-Use-wined3d_texture_get_sub_resource-in.patch
 create mode 100644 patches/ddraw-Revert_Surface_Init/0002-Revert-ddraw-Move-the-mip-level-dimensions-fix-up-fr.patch
 create mode 100644 patches/ddraw-Revert_Surface_Init/definition

diff --git a/patches/ddraw-Revert_Surface_Init/0001-Revert-ddraw-Use-wined3d_texture_get_sub_resource-in.patch b/patches/ddraw-Revert_Surface_Init/0001-Revert-ddraw-Use-wined3d_texture_get_sub_resource-in.patch
new file mode 100644
index 00000000..fffafb5e
--- /dev/null
+++ b/patches/ddraw-Revert_Surface_Init/0001-Revert-ddraw-Use-wined3d_texture_get_sub_resource-in.patch
@@ -0,0 +1,90 @@
+From 4227226984e3726aba1b0570db87679776842c5a Mon Sep 17 00:00:00 2001
+From: Sebastian Lackner <sebastian@fds-team.de>
+Date: Sun, 7 Feb 2016 18:52:16 +0100
+Subject: Revert "ddraw: Use wined3d_texture_get_sub_resource() in
+ ddraw_surface7_Flip()."
+
+This reverts commit b1709522307a160a7c151f5293095a3c26ab998f.
+---
+ dlls/ddraw/surface.c      | 6 +++---
+ dlls/wined3d/surface.c    | 7 +++++++
+ dlls/wined3d/wined3d.spec | 1 +
+ include/wine/wined3d.h    | 1 +
+ 4 files changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
+index f1ba858..a6fbceb 100644
+--- a/dlls/ddraw/surface.c
++++ b/dlls/ddraw/surface.c
+@@ -1268,7 +1268,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7
+             wined3d_device_set_rendertarget_view(dst_impl->ddraw->wined3d_device, 0, src_rtv, FALSE);
+         wined3d_rendertarget_view_set_parent(src_rtv, dst_impl);
+         dst_impl->wined3d_rtv = src_rtv;
+-        wined3d_resource_set_parent(wined3d_texture_get_sub_resource(src_impl->wined3d_texture, 0), dst_impl);
++        wined3d_resource_set_parent(wined3d_surface_get_resource(src_impl->wined3d_surface), dst_impl);
+         dst_impl->wined3d_surface = src_impl->wined3d_surface;
+         prev_ddraw_texture = wined3d_texture_get_parent(src_impl->wined3d_texture);
+         wined3d_resource_set_parent(wined3d_texture_get_resource(src_impl->wined3d_texture), ddraw_texture);
+@@ -1300,7 +1300,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7
+                 wined3d_device_set_rendertarget_view(dst_impl->ddraw->wined3d_device, 0, src_rtv, FALSE);
+             wined3d_rendertarget_view_set_parent(src_rtv, dst_impl);
+             dst_impl->wined3d_rtv = src_rtv;
+-            wined3d_resource_set_parent(wined3d_texture_get_sub_resource(src_impl->wined3d_texture, 0), dst_impl);
++            wined3d_resource_set_parent(wined3d_surface_get_resource(src_impl->wined3d_surface), dst_impl);
+             dst_impl->wined3d_surface = src_impl->wined3d_surface;
+             prev_ddraw_texture = wined3d_texture_get_parent(src_impl->wined3d_texture);
+             wined3d_resource_set_parent(wined3d_texture_get_resource(src_impl->wined3d_texture), ddraw_texture);
+@@ -1318,7 +1318,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7
+         wined3d_device_set_rendertarget_view(dst_impl->ddraw->wined3d_device, 0, tmp_rtv, FALSE);
+     wined3d_rendertarget_view_set_parent(tmp_rtv, src_impl);
+     src_impl->wined3d_rtv = tmp_rtv;
+-    wined3d_resource_set_parent(wined3d_texture_get_sub_resource(texture, 0), src_impl);
++    wined3d_resource_set_parent(wined3d_surface_get_resource(tmp), src_impl);
+     src_impl->wined3d_surface = tmp;
+     wined3d_resource_set_parent(wined3d_texture_get_resource(texture), ddraw_texture);
+     src_impl->wined3d_texture = texture;
+diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
+index 2a36619..e6c6258 100644
+--- a/dlls/wined3d/surface.c
++++ b/dlls/wined3d/surface.c
+@@ -1890,6 +1890,13 @@ void * CDECL wined3d_surface_get_parent(const struct wined3d_surface *surface)
+     return surface->resource.parent;
+ }
+ 
++struct wined3d_resource * CDECL wined3d_surface_get_resource(struct wined3d_surface *surface)
++{
++    TRACE("surface %p.\n", surface);
++
++    return &surface->resource;
++}
++
+ DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
+ {
+     unsigned int alignment;
+diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
+index 86d03f0..c07e0ca 100644
+--- a/dlls/wined3d/wined3d.spec
++++ b/dlls/wined3d/wined3d.spec
+@@ -225,6 +225,7 @@
+ @ cdecl wined3d_surface_get_overlay_position(ptr ptr ptr)
+ @ cdecl wined3d_surface_get_parent(ptr)
+ @ cdecl wined3d_surface_get_pitch(ptr)
++@ cdecl wined3d_surface_get_resource(ptr)
+ @ cdecl wined3d_surface_set_overlay_position(ptr long long)
+ @ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr)
+ @ cdecl wined3d_surface_update_overlay_z_order(ptr long ptr)
+diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
+index 8f9d80a..1b13a20 100644
+--- a/include/wine/wined3d.h
++++ b/include/wine/wined3d.h
+@@ -2477,6 +2477,7 @@ ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
+ HRESULT __cdecl wined3d_surface_get_overlay_position(const struct wined3d_surface *surface, LONG *x, LONG *y);
+ void * __cdecl wined3d_surface_get_parent(const struct wined3d_surface *surface);
+ DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface);
++struct wined3d_resource * __cdecl wined3d_surface_get_resource(struct wined3d_surface *surface);
+ HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y);
+ 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);
+-- 
+2.7.0
+
diff --git a/patches/ddraw-Revert_Surface_Init/0002-Revert-ddraw-Move-the-mip-level-dimensions-fix-up-fr.patch b/patches/ddraw-Revert_Surface_Init/0002-Revert-ddraw-Move-the-mip-level-dimensions-fix-up-fr.patch
new file mode 100644
index 00000000..e310ab5a
--- /dev/null
+++ b/patches/ddraw-Revert_Surface_Init/0002-Revert-ddraw-Move-the-mip-level-dimensions-fix-up-fr.patch
@@ -0,0 +1,64 @@
+From e70e6047539d266d0b7101e92ba789eed5cf9928 Mon Sep 17 00:00:00 2001
+From: Sebastian Lackner <sebastian@fds-team.de>
+Date: Sun, 7 Feb 2016 18:52:49 +0100
+Subject: Revert "ddraw: Move the mip-level dimensions fix-up from
+ ddraw_surface_init() to ddraw_surface_create()."
+
+This reverts commit 7d45318aeac41e2efabb9ddfbf95ecbea103e67d.
+---
+ dlls/ddraw/surface.c | 14 +++++---------
+ 1 file changed, 5 insertions(+), 9 deletions(-)
+
+diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
+index a6fbceb..923a935 100644
+--- a/dlls/ddraw/surface.c
++++ b/dlls/ddraw/surface.c
+@@ -5643,8 +5643,8 @@ static HRESULT CDECL ddraw_reset_enum_callback(struct wined3d_resource *resource
+ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc,
+         struct ddraw_surface **surface, IUnknown *outer_unknown, unsigned int version)
+ {
+-    struct wined3d_resource_desc wined3d_desc, wined3d_mip_desc;
+     struct ddraw_surface *root, *mip, **attach;
++    struct wined3d_resource_desc wined3d_desc;
+     struct wined3d_texture *wined3d_texture;
+     struct wined3d_resource *resource;
+     struct wined3d_display_mode mode;
+@@ -6103,17 +6103,9 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
+             mip_desc = &mip->surface_desc;
+ 
+             if (j)
+-            {
+-                wined3d_resource_get_desc(resource, &wined3d_mip_desc);
+-                mip_desc->dwWidth = wined3d_mip_desc.width;
+-                mip_desc->dwHeight = wined3d_mip_desc.height;
+-
+                 mip_desc->ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
+-            }
+             else
+-            {
+                 mip_desc->ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
+-            }
+ 
+             if (mip_desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
+             {
+@@ -6241,6 +6233,7 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
+ {
+     struct ddraw_texture *texture = wined3d_texture_get_parent(wined3d_texture);
+     DDSURFACEDESC2 *desc = &surface->surface_desc;
++    struct wined3d_resource_desc wined3d_desc;
+     unsigned int version = texture->version;
+ 
+     surface->IDirectDrawSurface7_iface.lpVtbl = &ddraw_surface7_vtbl;
+@@ -6272,6 +6265,9 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
+     }
+ 
+     *desc = texture->surface_desc;
++    wined3d_resource_get_desc(wined3d_surface_get_resource(wined3d_surface), &wined3d_desc);
++    desc->dwWidth = wined3d_desc.width;
++    desc->dwHeight = wined3d_desc.height;
+     surface->first_attached = surface;
+ 
+     if (format_is_compressed(&desc->u4.ddpfPixelFormat))
+-- 
+2.7.0
+
diff --git a/patches/ddraw-Revert_Surface_Init/definition b/patches/ddraw-Revert_Surface_Init/definition
new file mode 100644
index 00000000..1fdcd4bc
--- /dev/null
+++ b/patches/ddraw-Revert_Surface_Init/definition
@@ -0,0 +1 @@
+Fixes: [40094] Revert patches to move mip-level dimensions fixup (causes regressions in multiple games)
diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh
index d1186004..5e904d82 100755
--- a/patches/patchinstall.sh
+++ b/patches/patchinstall.sh
@@ -126,6 +126,7 @@ patch_enable_all ()
 	enable_ddraw_EnumSurfaces="$1"
 	enable_ddraw_IDirect3DTexture2_Load="$1"
 	enable_ddraw_Rendering_Targets="$1"
+	enable_ddraw_Revert_Surface_Init="$1"
 	enable_ddraw_Write_Vtable="$1"
 	enable_ddraw_ZBufferBitDepths="$1"
 	enable_ddraw_d3d_execute_buffer="$1"
@@ -525,6 +526,9 @@ patch_enable ()
 		ddraw-Rendering_Targets)
 			enable_ddraw_Rendering_Targets="$2"
 			;;
+		ddraw-Revert_Surface_Init)
+			enable_ddraw_Revert_Surface_Init="$2"
+			;;
 		ddraw-Write_Vtable)
 			enable_ddraw_Write_Vtable="$2"
 			;;
@@ -3304,6 +3308,23 @@ if test "$enable_ddraw_Rendering_Targets" -eq 1; then
 	) >> "$patchlist"
 fi
 
+# Patchset ddraw-Revert_Surface_Init
+# |
+# | This patchset fixes the following Wine bugs:
+# |   *	[#40094] Revert patches to move mip-level dimensions fixup (causes regressions in multiple games)
+# |
+# | Modified files:
+# |   *	dlls/ddraw/surface.c, dlls/wined3d/surface.c, dlls/wined3d/wined3d.spec, include/wine/wined3d.h
+# |
+if test "$enable_ddraw_Revert_Surface_Init" -eq 1; then
+	patch_apply ddraw-Revert_Surface_Init/0001-Revert-ddraw-Use-wined3d_texture_get_sub_resource-in.patch
+	patch_apply ddraw-Revert_Surface_Init/0002-Revert-ddraw-Move-the-mip-level-dimensions-fix-up-fr.patch
+	(
+		echo '+    { "Sebastian Lackner", "Revert \"ddraw: Use wined3d_texture_get_sub_resource() in ddraw_surface7_Flip().\".", 1 },';
+		echo '+    { "Sebastian Lackner", "Revert \"ddraw: Move the mip-level dimensions fix-up from ddraw_surface_init() to ddraw_surface_create().\".", 1 },';
+	) >> "$patchlist"
+fi
+
 # Patchset ddraw-Write_Vtable
 # |
 # | This patchset fixes the following Wine bugs:
diff --git a/patches/wined3d-CSMT_Main/9999-IfDefined.patch b/patches/wined3d-CSMT_Main/9999-IfDefined.patch
index 63cf9e96..5894fb72 100644
--- a/patches/wined3d-CSMT_Main/9999-IfDefined.patch
+++ b/patches/wined3d-CSMT_Main/9999-IfDefined.patch
@@ -5722,7 +5722,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      surface_evict_sysmem(surface);
  }
  
-@@ -1716,10 +2144,28 @@
+@@ -1723,10 +2151,28 @@
  
  DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
  {
@@ -5751,7 +5751,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  }
  
  HRESULT CDECL wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y)
-@@ -1844,6 +2290,7 @@
+@@ -1851,6 +2297,7 @@
      {
          DeleteDC(surface->hDC);
          DeleteObject(surface->dib.DIBsection);
@@ -5759,7 +5759,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          surface->resource.bitmap_data = NULL;
          surface->flags &= ~SFLAG_DIBSECTION;
          create_dib = TRUE;
-@@ -1852,6 +2299,15 @@
+@@ -1859,6 +2306,15 @@
      surface->resource.locations = 0;
      wined3d_resource_free_sysmem(&surface->resource);
      surface->resource.map_heap_memory = NULL;
@@ -5775,7 +5775,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      width = texture_resource->width;
      height = texture_resource->height;
-@@ -1877,6 +2333,7 @@
+@@ -1884,6 +2340,7 @@
      else
          surface->flags &= ~SFLAG_NONPOW2;
  
@@ -5783,7 +5783,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      if ((surface->resource.user_memory = mem))
      {
          surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
-@@ -1897,6 +2354,27 @@
+@@ -1904,6 +2361,27 @@
          surface->resource.size = wined3d_format_calculate_size(texture_resource->format,
                  1, width, height, 1);
          surface->resource.custom_row_pitch = wined3d_format_calculate_pitch(texture_resource->format, width);
@@ -5811,7 +5811,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      }
  
      /* The format might be changed to a format that needs conversion.
-@@ -1919,11 +2397,19 @@
+@@ -1926,11 +2404,19 @@
  
      if (!valid_location)
      {
@@ -5831,7 +5831,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      return WINED3D_OK;
  }
-@@ -2282,6 +2768,7 @@
+@@ -2289,6 +2775,7 @@
  
  static struct wined3d_texture *surface_convert_format(struct wined3d_surface *source, enum wined3d_format_id to_fmt)
  {
@@ -5839,7 +5839,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      void *dst_data = NULL, *src_data = NULL;
      UINT src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch;
      const struct d3dfmt_converter_desc *conv;
-@@ -2290,6 +2777,13 @@
+@@ -2297,6 +2784,13 @@
      struct wined3d_surface *dst;
      struct wined3d_context *context = NULL;
      struct wined3d_device *device = source->resource.device;
@@ -5853,7 +5853,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      conv = find_converter(source->resource.format->id, to_fmt);
      if (!conv)
-@@ -2314,6 +2808,7 @@
+@@ -2321,6 +2815,7 @@
      }
      dst = surface_from_resource(wined3d_texture_get_sub_resource(ret, 0));
  
@@ -5861,7 +5861,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      wined3d_resource_get_pitch(&source->resource, &src_row_pitch, &src_slice_pitch);
      wined3d_resource_get_pitch(&ret->resource, &dst_row_pitch, &dst_slice_pitch);
  
-@@ -2354,6 +2849,32 @@
+@@ -2361,6 +2856,32 @@
      if (context)
          context_release(context);
      return NULL;
@@ -5894,7 +5894,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  }
  
  static HRESULT _Blt_ColorFill(BYTE *buf, unsigned int width, unsigned int height,
-@@ -2416,6 +2937,7 @@
+@@ -2423,6 +2944,7 @@
  
  HRESULT wined3d_surface_unmap(struct wined3d_surface *surface)
  {
@@ -5902,7 +5902,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      HRESULT hr;
      TRACE("surface %p.\n", surface);
  
-@@ -2426,6 +2948,20 @@
+@@ -2433,6 +2955,20 @@
      memset(&surface->lockedRect, 0, sizeof(surface->lockedRect));
  
      return hr;
@@ -5923,7 +5923,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  }
  
  HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_desc *map_desc,
-@@ -2433,6 +2969,21 @@
+@@ -2440,6 +2976,21 @@
  {
      const struct wined3d_format *format = surface->resource.format;
      unsigned int fmt_flags = surface->container->resource.format_flags;
@@ -5945,7 +5945,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      if ((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && box
              && !surface_check_block_align(surface, box))
-@@ -2444,6 +2995,13 @@
+@@ -2451,6 +3002,13 @@
              return WINED3DERR_INVALIDCALL;
      }
  
@@ -5959,7 +5959,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      /* Performance optimization: Count how often a surface is mapped, if it is
       * mapped regularly do not throw away the system memory copy. This avoids
       * the need to download the surface from OpenGL all the time. The surface
-@@ -2459,6 +3017,7 @@
+@@ -2466,6 +3024,7 @@
          }
      }
  
@@ -5967,7 +5967,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      if (box)
      {
          surface->lockedRect.left = box->left;
-@@ -2548,6 +3107,119 @@
+@@ -2555,6 +3114,119 @@
      DWORD slice_pitch, pitch;
  
      wined3d_resource_get_memory(&surface->resource, dst_location, &data);
@@ -6087,7 +6087,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      if (surface != old_ctx->current_rt)
      {
-@@ -2587,8 +3259,13 @@
+@@ -2594,8 +3266,13 @@
      }
  
      /* Setup pixel store pack state -- to glReadPixels into the correct place */
@@ -6101,7 +6101,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      checkGLcall("glPixelStorei");
  
      gl_info->gl_ops.gl.p_glReadPixels(0, 0,
-@@ -2605,6 +3282,10 @@
+@@ -2612,6 +3289,10 @@
      {
          /* glReadPixels returns the image upside down, and there is no way to prevent this.
           * Flip the lines in software. */
@@ -6112,7 +6112,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          if (!(row = HeapAlloc(GetProcessHeap(), 0, pitch)))
              goto error;
  
-@@ -2849,8 +3530,13 @@
+@@ -2856,8 +3537,13 @@
  
      /* The texture is now most up to date - If the surface is a render target
       * and has a drawable, this path is never entered. */
@@ -6126,7 +6126,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  }
  
  /* Uses the hardware to stretch and flip the image */
-@@ -2918,7 +3604,11 @@
+@@ -2925,7 +3611,11 @@
          checkGLcall("glEnable(texture_target)");
  
          /* For now invalidate the texture copy of the back buffer. Drawable and sysmem copy are untouched */
@@ -6138,7 +6138,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      }
  
      /* Make sure that the top pixel is always above the bottom pixel, and keep a separate upside down flag
-@@ -3115,6 +3805,7 @@
+@@ -3122,6 +3812,7 @@
          checkGLcall("glDeleteTextures(1, &backup)");
      }
  
@@ -6146,7 +6146,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      if (wined3d_settings.cs_multithreaded)
          gl_info->gl_ops.gl.p_glFinish();
      else if (wined3d_settings.strict_draw_ordering)
-@@ -3126,6 +3817,17 @@
+@@ -3133,6 +3824,17 @@
       * and has a drawable, this path is never entered. */
      wined3d_resource_validate_location(&dst_surface->resource, WINED3D_LOCATION_TEXTURE_RGB);
      wined3d_resource_invalidate_location(&dst_surface->resource, ~WINED3D_LOCATION_TEXTURE_RGB);
@@ -6164,7 +6164,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  }
  
  /* Front buffer coordinates are always full screen coordinates, but our GL
-@@ -3180,9 +3882,15 @@
+@@ -3187,9 +3889,15 @@
  
      gl_info = context->gl_info;
  
@@ -6180,7 +6180,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      wined3d_texture_load(src_surface->container, context, FALSE);
  
      /* Activate the destination context, set it up for blitting */
-@@ -3225,9 +3933,13 @@
+@@ -3232,9 +3940,13 @@
      /* Leave the opengl state valid for blitting */
      device->blitter->unset_shader(context->gl_info);
  
@@ -6194,7 +6194,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              || (dst_surface->container->swapchain
              && dst_surface->container->swapchain->front_buffer == dst_surface->container))
          gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
-@@ -3240,8 +3952,13 @@
+@@ -3247,8 +3959,13 @@
  {
      struct wined3d_resource *resource = &s->container->resource;
      struct wined3d_device *device = resource->device;
@@ -6208,7 +6208,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      const struct blit_shader *blitter;
      HRESULT hr;
  
-@@ -3252,6 +3969,7 @@
+@@ -3259,6 +3976,7 @@
          return WINED3DERR_INVALIDCALL;
      }
  
@@ -6216,7 +6216,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      /* Can't incref / decref the resource here. This is executed inside the worker
       * thread. Playing with the refcount here makes the worker thread visible to
       * the client lib. Problems occur when the worker thread happens to hold the
-@@ -3268,6 +3986,21 @@
+@@ -3275,6 +3993,21 @@
      view.sub_resource_idx = s->texture_layer * texture->level_count + s->texture_level;
  
      hr = blitter->color_fill(device, &view, rect, color);
@@ -6238,7 +6238,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      return hr;
  }
-@@ -3277,8 +4010,13 @@
+@@ -3284,8 +4017,13 @@
          enum wined3d_texture_filter_type filter)
  {
      struct wined3d_device *device = dst_surface->resource.device;
@@ -6252,7 +6252,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, blt_fx %p, filter %s.\n",
              dst_surface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect),
-@@ -3469,6 +4207,7 @@
+@@ -3476,6 +4214,7 @@
  {
      TRACE("surface %p, new location %#x, w %u, h %u.\n", surface, location, w, h);
  
@@ -6260,7 +6260,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      if (((surface->resource.locations & WINED3D_LOCATION_TEXTURE_RGB) && !(location & WINED3D_LOCATION_TEXTURE_RGB))
              || (!(surface->resource.locations & WINED3D_LOCATION_TEXTURE_RGB)
              && (location & WINED3D_LOCATION_TEXTURE_RGB)))
-@@ -3477,6 +4216,15 @@
+@@ -3484,6 +4223,15 @@
      surface->ds_current_size.cx = w;
      surface->ds_current_size.cy = h;
      surface->resource.locations = location;
@@ -6276,7 +6276,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  }
  
  /* Context activation is done by the caller. */
-@@ -3491,7 +4239,11 @@
+@@ -3498,7 +4246,11 @@
      /* TODO: Make this work for modes other than FBO */
      if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return;
  
@@ -6288,7 +6288,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      {
          w = surface->ds_current_size.cx;
          h = surface->ds_current_size.cy;
-@@ -3518,6 +4270,7 @@
+@@ -3525,6 +4277,7 @@
      }
  
      wined3d_surface_prepare(surface, context, location);
@@ -6296,7 +6296,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      if (surface->resource.locations & WINED3D_LOCATION_DISCARDED)
      {
          TRACE("Surface was discarded, no need copy data.\n");
-@@ -3532,6 +4285,22 @@
+@@ -3539,6 +4292,22 @@
      {
          FIXME("No up to date depth stencil location.\n");
          surface->resource.locations |= location;
@@ -6319,7 +6319,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          surface->ds_current_size.cx = surface->resource.width;
          surface->ds_current_size.cy = surface->resource.height;
          return;
-@@ -3595,9 +4364,13 @@
+@@ -3602,9 +4371,13 @@
  
          context_invalidate_state(context, STATE_FRAMEBUFFER);
  
@@ -6333,7 +6333,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
      }
      else if (location == WINED3D_LOCATION_DRAWABLE)
-@@ -3613,9 +4386,13 @@
+@@ -3620,9 +4393,13 @@
  
          context_invalidate_state(context, STATE_FRAMEBUFFER);
  
@@ -6347,7 +6347,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
      }
      else
-@@ -3623,6 +4400,7 @@
+@@ -3630,6 +4407,7 @@
          ERR("Invalid location (%#x) specified.\n", location);
      }
  
@@ -6355,7 +6355,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      surface->resource.locations |= location;
      surface->ds_current_size.cx = surface->resource.width;
      surface->ds_current_size.cy = surface->resource.height;
-@@ -3655,6 +4433,124 @@
+@@ -3662,6 +4440,124 @@
  
      FIXME("Can't load surface %p with location flags %s into sysmem.\n",
              surface, wined3d_debug_location(surface->resource.locations));
@@ -6480,7 +6480,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  }
  
  /* Context activation is done by the caller. */
-@@ -3663,12 +4559,14 @@
+@@ -3670,12 +4566,14 @@
  {
      RECT r;
  
@@ -6495,7 +6495,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
              && wined3d_resource_is_offscreen(&surface->container->resource))
      {
-@@ -3677,7 +4575,11 @@
+@@ -3684,7 +4582,11 @@
      }
  
      surface_get_rect(surface, NULL, &r);
@@ -6507,7 +6507,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      surface_blt_to_drawable(surface->resource.device, context,
              WINED3D_TEXF_POINT, FALSE, surface, &r, surface, &r);
  
-@@ -3692,6 +4594,7 @@
+@@ -3699,6 +4601,7 @@
      struct wined3d_device *device = surface->resource.device;
      const struct wined3d_color_key_conversion *conversion;
      struct wined3d_texture *texture = surface->container;
@@ -6515,7 +6515,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      UINT width, src_row_pitch, src_slice_pitch, dst_pitch;
      struct wined3d_bo_address data;
      struct wined3d_format format;
-@@ -3718,6 +4621,24 @@
+@@ -3725,6 +4628,24 @@
      }
  
      if (surface->resource.locations & (WINED3D_LOCATION_TEXTURE_SRGB | WINED3D_LOCATION_TEXTURE_RGB)
@@ -6540,7 +6540,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              && (surface->container->resource.format_flags & WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB)
              && fbo_blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
                  NULL, surface->resource.usage, surface->resource.pool, surface->resource.format,
-@@ -3733,6 +4654,7 @@
+@@ -3740,6 +4661,7 @@
          return WINED3D_OK;
      }
  
@@ -6548,7 +6548,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      if (surface->resource.locations & (WINED3D_LOCATION_RB_MULTISAMPLE | WINED3D_LOCATION_RB_RESOLVED)
              && (!srgb || (surface->container->resource.format_flags & WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB))
              && fbo_blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
-@@ -3740,6 +4662,15 @@
+@@ -3747,6 +4669,15 @@
                  NULL, surface->resource.usage, surface->resource.pool, surface->resource.format))
      {
          DWORD src_location = surface->resource.locations & WINED3D_LOCATION_RB_RESOLVED ?
@@ -6564,7 +6564,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                  WINED3D_LOCATION_RB_RESOLVED : WINED3D_LOCATION_RB_MULTISAMPLE;
          DWORD dst_location = srgb ? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB;
          RECT rect = {0, 0, surface->resource.width, surface->resource.height};
-@@ -3754,6 +4685,7 @@
+@@ -3761,6 +4692,7 @@
  
      if (srgb)
      {
@@ -6572,7 +6572,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          if ((surface->resource.locations & (WINED3D_LOCATION_TEXTURE_RGB | surface->resource.map_binding))
                  == WINED3D_LOCATION_TEXTURE_RGB)
          {
-@@ -3788,6 +4720,42 @@
+@@ -3795,6 +4727,42 @@
  
      width = surface->resource.width;
      wined3d_resource_get_pitch(&surface->resource, &src_row_pitch, &src_slice_pitch);
@@ -6615,7 +6615,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      format = *texture->resource.format;
      if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE)))
-@@ -3796,7 +4764,11 @@
+@@ -3803,7 +4771,11 @@
      /* Don't use PBOs for converted surfaces. During PBO conversion we look at
       * WINED3D_TEXTURE_CONVERTED but it isn't set (yet) in all cases it is
       * getting called. */
@@ -6627,7 +6627,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      {
          TRACE("Removing the pbo attached to surface %p.\n", surface);
  
-@@ -3805,6 +4777,7 @@
+@@ -3812,6 +4784,7 @@
          else
              surface->resource.map_binding = WINED3D_LOCATION_SYSMEM;
  
@@ -6635,7 +6635,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          wined3d_resource_prepare_map_memory(&surface->resource, context);
          wined3d_resource_load_location(&surface->resource, context, surface->resource.map_binding);
          wined3d_resource_free_bo(&surface->resource);
-@@ -3812,6 +4785,14 @@
+@@ -3819,6 +4792,14 @@
      }
  
      wined3d_resource_get_memory(&surface->resource, surface->resource.locations, &data);
@@ -6650,7 +6650,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      if (format.convert)
      {
          /* This code is entered for texture formats which need a fixup. */
-@@ -3826,9 +4807,15 @@
+@@ -3833,9 +4814,15 @@
              context_release(context);
              return E_OUTOFMEMORY;
          }
@@ -6666,7 +6666,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          data.addr = mem;
      }
      else if (conversion)
-@@ -3848,6 +4835,7 @@
+@@ -3855,6 +4842,7 @@
          }
          if (texture->swapchain && texture->swapchain->palette)
              palette = texture->swapchain->palette;
@@ -6674,7 +6674,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          conversion->convert(data.addr, src_row_pitch, mem, dst_pitch,
                  width, height, palette, &texture->async.gl_color_key);
          src_row_pitch = dst_pitch;
-@@ -3856,6 +4844,16 @@
+@@ -3863,6 +4851,16 @@
  
      wined3d_surface_upload_data(surface, gl_info, &format, &src_rect,
              src_row_pitch, &dst_point, srgb, wined3d_const_bo_address(&data));
@@ -6691,7 +6691,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      HeapFree(GetProcessHeap(), 0, mem);
  
-@@ -3869,11 +4867,19 @@
+@@ -3876,11 +4874,19 @@
      const RECT rect = {0, 0, surface->resource.width, surface->resource.height};
      DWORD src_location;
  
@@ -6711,7 +6711,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          src_location = WINED3D_LOCATION_TEXTURE_SRGB;
      else /* surface_blt_fbo will load the source location if necessary. */
          src_location = WINED3D_LOCATION_TEXTURE_RGB;
-@@ -3882,11 +4888,17 @@
+@@ -3889,11 +4895,17 @@
              surface, src_location, &rect, surface, dst_location, &rect);
  }
  
@@ -6729,7 +6729,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      HRESULT hr;
  
      TRACE("surface %p, location %s.\n", surface, wined3d_debug_location(location));
-@@ -3894,6 +4906,7 @@
+@@ -3901,6 +4913,7 @@
      if (surface->resource.usage & WINED3DUSAGE_DEPTHSTENCIL)
      {
          if (location == WINED3D_LOCATION_TEXTURE_RGB
@@ -6737,7 +6737,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                  && surface->resource.locations & (WINED3D_LOCATION_DRAWABLE | WINED3D_LOCATION_DISCARDED))
          {
              surface_load_ds_location(surface, context, location);
-@@ -3917,6 +4930,45 @@
+@@ -3924,6 +4937,45 @@
      {
          ERR("Surface %p does not have any up to date location.\n", surface);
          return;
@@ -6783,7 +6783,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      }
  
      switch (location)
-@@ -3930,7 +4982,11 @@
+@@ -3937,7 +4989,11 @@
  
          case WINED3D_LOCATION_DRAWABLE:
              if (FAILED(hr = surface_load_drawable(surface, context)))
@@ -6795,7 +6795,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              break;
  
          case WINED3D_LOCATION_RB_RESOLVED:
-@@ -3942,7 +4998,11 @@
+@@ -3949,7 +5005,11 @@
          case WINED3D_LOCATION_TEXTURE_SRGB:
              if (FAILED(hr = surface_load_texture(surface, context,
                      location == WINED3D_LOCATION_TEXTURE_SRGB)))
@@ -6807,7 +6807,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              break;
  
          default:
-@@ -3950,12 +5010,21 @@
+@@ -3957,12 +5017,21 @@
              break;
      }
  
@@ -6829,7 +6829,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  }
  
  static HRESULT ffp_blit_alloc(struct wined3d_device *device) { return WINED3D_OK; }
-@@ -4064,7 +5133,11 @@
+@@ -4071,7 +5140,11 @@
          const RECT *rect, const struct wined3d_color *color)
  {
      const RECT draw_rect = {0, 0, view->width, view->height};
@@ -6841,7 +6841,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      device_clear_render_targets(device, 1, &fb, 1, rect, &draw_rect, WINED3DCLEAR_TARGET, color, 0.0f, 0);
  
-@@ -4114,8 +5187,13 @@
+@@ -4121,8 +5194,13 @@
      wined3d_texture_set_color_key(src_surface->container, WINED3D_CKEY_SRC_BLT,
              (old_color_key_flags & WINED3D_CKEY_SRC_BLT) ? &old_blt_key : NULL);
  
@@ -6855,7 +6855,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  }
  
  const struct blit_shader ffp_blit =  {
-@@ -4271,6 +5349,7 @@
+@@ -4278,6 +5356,7 @@
          struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
          const WINEDDBLTFX *fx, enum wined3d_texture_filter_type filter)
  {
@@ -6863,7 +6863,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      int bpp, srcheight, srcwidth, dstheight, dstwidth, width;
      const struct wined3d_format *src_format, *dst_format;
      unsigned int src_fmt_flags, dst_fmt_flags;
-@@ -4305,6 +5384,28 @@
+@@ -4312,6 +5391,28 @@
          wined3d_resource_get_pitch(&dst_surface->resource, &dst_row_pitch, &dst_slice_pitch);
          src_data = dst_data;
          src_row_pitch = dst_row_pitch;
@@ -6892,7 +6892,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          src_format = dst_surface->resource.format;
          dst_format = src_format;
          dst_fmt_flags = dst_surface->container->resource.format_flags;
-@@ -4316,12 +5417,14 @@
+@@ -4323,12 +5424,14 @@
          dst_fmt_flags = dst_surface->container->resource.format_flags;
          if (src_surface)
          {
@@ -6907,7 +6907,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              if (dst_surface->resource.format->id != src_surface->resource.format->id)
              {
                  if (!(src_texture = surface_convert_format(src_surface, dst_format->id)))
-@@ -4332,9 +5435,13 @@
+@@ -4339,9 +5442,13 @@
                  }
                  src_surface = surface_from_resource(wined3d_texture_get_sub_resource(src_texture, 0));
              }
@@ -6921,7 +6921,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              src_format = src_surface->resource.format;
              src_fmt_flags = src_surface->container->resource.format_flags;
          }
-@@ -4344,8 +5451,12 @@
+@@ -4351,8 +5458,12 @@
              src_fmt_flags = dst_fmt_flags;
          }
  
@@ -6934,7 +6934,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      }
  
      bpp = dst_surface->resource.format->byte_count;
-@@ -4356,12 +5467,24 @@
+@@ -4363,12 +5474,24 @@
      width = (dst_rect->right - dst_rect->left) * bpp;
  
      if (src_surface)
@@ -6959,7 +6959,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      if (src_fmt_flags & dst_fmt_flags & WINED3DFMT_FLAG_BLOCKS)
      {
-@@ -4396,7 +5519,11 @@
+@@ -4403,7 +5526,11 @@
          }
  
          hr = surface_cpu_blt_compressed(sbase, dbuf,
@@ -6971,7 +6971,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                  src_format, flags, fx);
          goto release;
      }
-@@ -4404,7 +5531,11 @@
+@@ -4411,7 +5538,11 @@
      /* First, all the 'source-less' blits */
      if (flags & WINEDDBLT_COLORFILL)
      {
@@ -6983,7 +6983,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          flags &= ~WINEDDBLT_COLORFILL;
      }
  
-@@ -4454,6 +5585,7 @@
+@@ -4461,6 +5592,7 @@
                          for (y = 0; y < dstheight; ++y)
                          {
                              memcpy(dbuf, sbuf, width);
@@ -6991,7 +6991,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                              sbuf += src_row_pitch;
                              dbuf += dst_row_pitch;
                          }
-@@ -4467,6 +5599,21 @@
+@@ -4474,6 +5606,21 @@
                          {
                              sbuf -= src_row_pitch;
                              dbuf -= dst_row_pitch;
@@ -7013,7 +7013,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                              memcpy(dbuf, sbuf, width);
                          }
                      }
-@@ -4476,8 +5623,13 @@
+@@ -4483,8 +5630,13 @@
                          for (y = 0; y < dstheight; ++y)
                          {
                              memmove(dbuf, sbuf, width);
@@ -7027,7 +7027,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                          }
                      }
                  }
-@@ -4486,9 +5638,15 @@
+@@ -4493,9 +5645,15 @@
                      /* Stretching in y direction only. */
                      for (y = sy = 0; y < dstheight; ++y, sy += yinc)
                      {
@@ -7043,7 +7043,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                      }
                  }
              }
-@@ -4498,6 +5656,7 @@
+@@ -4505,6 +5663,7 @@
                  int last_sy = -1;
                  for (y = sy = 0; y < dstheight; ++y, sy += yinc)
                  {
@@ -7051,7 +7051,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                      sbuf = sbase + (sy >> 16) * src_row_pitch;
  
                      if ((sy >> 16) == (last_sy >> 16))
-@@ -4505,6 +5664,15 @@
+@@ -4512,6 +5671,15 @@
                          /* This source row is the same as last source row -
                           * Copy the already stretched row. */
                          memcpy(dbuf, dbuf - dst_row_pitch, width);
@@ -7067,7 +7067,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                      }
                      else
                      {
-@@ -4551,6 +5719,7 @@
+@@ -4558,6 +5726,7 @@
                          }
  #undef STRETCH_ROW
                      }
@@ -7075,7 +7075,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                      dbuf += dst_row_pitch;
                      last_sy = sy;
                  }
-@@ -4559,6 +5728,16 @@
+@@ -4566,6 +5735,16 @@
          else
          {
              LONG dstyinc = dst_row_pitch, dstxinc = bpp;
@@ -7092,7 +7092,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              DWORD keylow = 0xffffffff, keyhigh = 0, keymask = 0xffffffff;
              DWORD destkeylow = 0x0, destkeyhigh = 0xffffffff, destkeymask = 0xffffffff;
              if (flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYDEST | WINEDDBLT_KEYSRCOVERRIDE | WINEDDBLT_KEYDESTOVERRIDE))
-@@ -4608,7 +5787,11 @@
+@@ -4615,7 +5794,11 @@
                  LONG tmpxy;
                  dTopLeft     = dbuf;
                  dTopRight    = dbuf + ((dstwidth - 1) * bpp);
@@ -7104,7 +7104,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                  dBottomRight = dBottomLeft + ((dstwidth - 1) * bpp);
  
                  if (fx->dwDDFX & WINEDDBLTFX_ARITHSTRETCHY)
-@@ -4685,6 +5868,7 @@
+@@ -4692,6 +5875,7 @@
                  flags &= ~(WINEDDBLT_DDFX);
              }
  
@@ -7112,7 +7112,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  #define COPY_COLORKEY_FX(type) \
  do { \
      const type *s; \
-@@ -4706,6 +5890,29 @@
+@@ -4713,6 +5897,29 @@
          d = (type *)(((BYTE *)d) + dstyinc); \
      } \
  } while(0)
@@ -7142,7 +7142,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
              switch (bpp)
              {
-@@ -4724,7 +5931,11 @@
+@@ -4731,7 +5938,11 @@
                      BYTE *d = dbuf, *dx;
                      for (y = sy = 0; y < dstheight; ++y, sy += yinc)
                      {
@@ -7154,7 +7154,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                          dx = d;
                          for (x = sx = 0; x < dstwidth; ++x, sx+= xinc)
                          {
-@@ -4755,10 +5966,12 @@
+@@ -4762,10 +5973,12 @@
          }
      }
  
@@ -7167,7 +7167,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  error:
      if (flags && FIXME_ON(d3d_surface))
      {
-@@ -4766,6 +5979,7 @@
+@@ -4773,6 +5986,7 @@
      }
  
  release:
@@ -7175,7 +7175,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      if (dst_data)
      {
          wined3d_resource_release_map_ptr(&dst_surface->resource, context);
-@@ -4784,6 +5998,14 @@
+@@ -4791,6 +6005,14 @@
          wined3d_texture_decref(src_texture);
      if (context)
          context_release(context);
@@ -7190,7 +7190,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
      return hr;
  }
-@@ -4829,7 +6051,11 @@
+@@ -4836,7 +6058,11 @@
      cpu_blit_blit_surface,
  };
  
@@ -7202,7 +7202,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
          const WINEDDBLTFX *fx, enum wined3d_texture_filter_type filter)
  {
-@@ -4847,6 +6073,98 @@
+@@ -4854,6 +6080,98 @@
              | WINEDDBLT_DONOTWAIT
              | WINEDDBLT_ALPHATEST;
  
@@ -7301,7 +7301,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      if (!device->d3d_initialized)
      {
          WARN("D3D not initialized, using fallback.\n");
-@@ -4910,6 +6228,7 @@
+@@ -4917,6 +6235,7 @@
              TRACE("Depth fill.\n");
  
              if (!surface_convert_depth_to_float(dst_surface, fx->u5.dwFillDepth, &depth))
@@ -7309,7 +7309,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                  return;
  
              if (SUCCEEDED(wined3d_surface_depth_fill(dst_surface, dst_rect, depth)))
-@@ -4920,6 +6239,24 @@
+@@ -4927,6 +6246,24 @@
              if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_surface->container->resource.draw_binding,
                      src_rect, dst_surface, dst_surface->container->resource.draw_binding, dst_rect)))
                  return;
@@ -7334,7 +7334,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          }
      }
      else
-@@ -4928,8 +6265,13 @@
+@@ -4935,8 +6272,13 @@
  
          /* In principle this would apply to depth blits as well, but we don't
           * implement those in the CPU blitter at the moment. */
@@ -7348,7 +7348,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          {
              if (scale)
                  TRACE("Not doing sysmem blit because of scaling.\n");
-@@ -4951,7 +6293,11 @@
+@@ -4958,7 +6300,11 @@
                  goto fallback;
  
              if (SUCCEEDED(surface_color_fill(dst_surface, dst_rect, &color)))
@@ -7360,7 +7360,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
          }
          else
          {
-@@ -4973,8 +6319,13 @@
+@@ -4980,8 +6326,13 @@
              {
                  blit_op = WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST;
              }
@@ -7374,7 +7374,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              {
                  /* Upload */
                  if (scale)
-@@ -4990,11 +6341,18 @@
+@@ -4997,11 +6348,18 @@
                          if (!wined3d_resource_is_offscreen(&dst_surface->container->resource))
                          {
                              struct wined3d_context *context = context_acquire(device, dst_surface);
@@ -7393,7 +7393,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                      }
                  }
              }
-@@ -5018,7 +6376,11 @@
+@@ -5025,7 +6383,11 @@
                  wined3d_swapchain_present(dst_swapchain, NULL, NULL, dst_swapchain->win_handle, NULL, 0);
                  dst_swapchain->desc.swap_effect = swap_effect;
  
@@ -7405,7 +7405,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              }
  
              if (fbo_blit_supported(&device->adapter->gl_info, blit_op,
-@@ -5034,10 +6396,17 @@
+@@ -5041,10 +6403,17 @@
                          dst_surface, dst_surface->container->resource.draw_binding, dst_rect);
                  context_release(context);
  
@@ -7423,7 +7423,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
              }
  
              blitter = wined3d_select_blitter(&device->adapter->gl_info, &device->adapter->d3d_info, blit_op,
-@@ -5047,6 +6416,7 @@
+@@ -5054,6 +6423,7 @@
              {
                  blitter->blit_surface(device, blit_op, filter, src_surface,
                          src_rect, dst_surface, dst_rect, color_key);
@@ -7431,7 +7431,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
                  return;
              }
          }
-@@ -5212,6 +6582,21 @@
+@@ -5219,6 +6589,21 @@
      wined3d_surface_location_invalidated,
      wined3d_surface_load_location,
  };
@@ -7453,7 +7453,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
  
  static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_texture *container,
          const struct wined3d_resource_desc *desc, GLenum target, unsigned int level, unsigned int layer, DWORD flags)
-@@ -5273,7 +6658,11 @@
+@@ -5280,7 +6665,11 @@
      }
  
      surface->container = container;
@@ -7465,7 +7465,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      list_init(&surface->renderbuffers);
      list_init(&surface->overlays);
  
-@@ -5305,9 +6694,14 @@
+@@ -5312,9 +6701,14 @@
      if (surface->resource.map_binding == WINED3D_LOCATION_DIB)
      {
          wined3d_resource_free_sysmem(&surface->resource);
@@ -7480,7 +7480,7 @@ diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
      }
  
      return hr;
-@@ -5334,7 +6728,11 @@
+@@ -5341,7 +6735,11 @@
      if (FAILED(hr = surface_init(object, container, desc, target, level, layer, flags)))
      {
          WARN("Failed to initialize surface, returning %#x.\n", hr);