From: Matteo Bruni Subject: [PATCH 4/5] wined3d: Set GL_UNPACK_ALIGNMENT to 1 when uploading surfaces from user memory. Message-Id: <1423595692-26048-4-git-send-email-mbruni@codeweavers.com> Date: Tue, 10 Feb 2015 20:14:51 +0100 The device surface alignment does not apply to user-memory surfaces. Together with the previous patch this fixes bug 36090... except that I can't reproduce the issue anymore, probably worked around by a game update. --- dlls/wined3d/surface.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 3428535..b0963ea 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1543,6 +1543,7 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w else { const BYTE *addr = data->addr; + unsigned int surface_alignment = surface->resource.device->surface_alignment; addr += src_rect->top * src_pitch; addr += src_rect->left * format->byte_count; @@ -1552,8 +1553,12 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w update_w, update_h, format->glFormat, format->glType, addr); gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, src_pitch / format->byte_count); + if (src_pitch & (surface_alignment - 1)) + gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl_info->gl_ops.gl.p_glTexSubImage2D(surface->texture_target, surface->texture_level, dst_point->x, dst_point->y, update_w, update_h, format->glFormat, format->glType, addr); + if (src_pitch & (surface_alignment - 1)) + gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ALIGNMENT, surface_alignment); gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); checkGLcall("glTexSubImage2D"); } -- 2.0.5