From 979c38f3099fa1d537710254c6f2961e6de7d6d9 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 21 Feb 2016 23:34:31 +0100
Subject: Revert "wined3d: Use wined3d_format_calculate_pitch() in
 surface_download_data()."

This reverts commit a95524b8f3abfaa28fc21055d95d4a087a9b6d69.
---
 dlls/wined3d/surface.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 93bf718..59c6e5c 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1325,17 +1325,18 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
     else
     {
         unsigned int dst_row_pitch, dst_slice_pitch;
-        unsigned int src_row_pitch, src_slice_pitch;
+        unsigned int src_pitch;
         GLenum gl_format = format->glFormat;
         GLenum gl_type = format->glType;
         void *mem;
 
         if (surface->container->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
         {
+            unsigned char alignment = surface->resource.device->surface_alignment;
+            src_pitch = format->byte_count * surface->pow2Width;
             wined3d_texture_get_pitch(surface->container, surface->texture_level, &dst_row_pitch, &dst_slice_pitch);
-            wined3d_format_calculate_pitch(format, surface->resource.device->surface_alignment,
-                    surface->pow2Width, surface->pow2Height, &src_row_pitch, &src_slice_pitch);
-            mem = HeapAlloc(GetProcessHeap(), 0, src_slice_pitch);
+            src_pitch = (src_pitch + alignment - 1) & ~(alignment - 1);
+            mem = HeapAlloc(GetProcessHeap(), 0, src_pitch * surface->pow2Height);
         }
         else
         {
@@ -1420,11 +1421,11 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
              * won't be released, and doesn't have to be re-read. */
             src_data = mem;
             dst_data = data.addr;
-            TRACE("Repacking the surface data from pitch %u to pitch %u.\n", src_row_pitch, dst_row_pitch);
+            TRACE("(%p) : Repacking the surface data from pitch %d to pitch %d\n", surface, src_pitch, dst_row_pitch);
             for (y = 0; y < surface->resource.height; ++y)
             {
                 memcpy(dst_data, src_data, dst_row_pitch);
-                src_data += src_row_pitch;
+                src_data += src_pitch;
                 dst_data += dst_row_pitch;
             }
 
-- 
2.7.1

