Commit a95524b8 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Use wined3d_format_calculate_pitch() in surface_download_data().

parent a0beaa40
...@@ -1329,19 +1329,17 @@ static void surface_download_data(struct wined3d_surface *surface, const struct ...@@ -1329,19 +1329,17 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
} }
else else
{ {
void *mem; unsigned int src_row_pitch, src_slice_pitch, dst_pitch = 0;
GLenum gl_format = format->glFormat; GLenum gl_format = format->glFormat;
GLenum gl_type = format->glType; GLenum gl_type = format->glType;
int src_pitch = 0; void *mem;
int dst_pitch = 0;
if (surface->flags & SFLAG_NONPOW2) if (surface->flags & SFLAG_NONPOW2)
{ {
unsigned char alignment = surface->resource.device->surface_alignment;
src_pitch = format->byte_count * surface->pow2Width;
dst_pitch = wined3d_surface_get_pitch(surface); dst_pitch = wined3d_surface_get_pitch(surface);
src_pitch = (src_pitch + alignment - 1) & ~(alignment - 1); wined3d_format_calculate_pitch(format, surface->resource.device->surface_alignment,
mem = HeapAlloc(GetProcessHeap(), 0, src_pitch * surface->pow2Height); surface->pow2Width, surface->pow2Height, &src_row_pitch, &src_slice_pitch);
mem = HeapAlloc(GetProcessHeap(), 0, src_slice_pitch);
} }
else else
{ {
...@@ -1426,11 +1424,11 @@ static void surface_download_data(struct wined3d_surface *surface, const struct ...@@ -1426,11 +1424,11 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
* won't be released, and doesn't have to be re-read. */ * won't be released, and doesn't have to be re-read. */
src_data = mem; src_data = mem;
dst_data = data.addr; dst_data = data.addr;
TRACE("(%p) : Repacking the surface data from pitch %d to pitch %d\n", surface, src_pitch, dst_pitch); TRACE("Repacking the surface data from pitch %u to pitch %u.\n", src_row_pitch, dst_pitch);
for (y = 0; y < surface->resource.height; ++y) for (y = 0; y < surface->resource.height; ++y)
{ {
memcpy(dst_data, src_data, dst_pitch); memcpy(dst_data, src_data, dst_pitch);
src_data += src_pitch; src_data += src_row_pitch;
dst_data += dst_pitch; dst_data += dst_pitch;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment