From 64ba3ee4a065a9032b797312ad9e8a0081830578 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 28 Feb 2018 09:56:56 +0330 Subject: [PATCH] wined3d: Explicitly calculate the sub-resource level in read_from_framebuffer(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/surface.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 22156b60a4e..751424d4b63 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1433,8 +1433,8 @@ static void read_from_framebuffer(struct wined3d_surface *surface, struct wined3d_surface *restore_rt = NULL; const struct wined3d_gl_info *gl_info; unsigned int row_pitch, slice_pitch; + unsigned int width, height, level; struct wined3d_bo_address data; - unsigned int width, height; BYTE *row, *top, *bottom; BOOL src_is_upside_down; unsigned int i; @@ -1488,14 +1488,15 @@ static void read_from_framebuffer(struct wined3d_surface *surface, checkGLcall("glBindBuffer"); } - wined3d_texture_get_pitch(texture, surface->texture_level, &row_pitch, &slice_pitch); + level = sub_resource_idx % texture->level_count; + wined3d_texture_get_pitch(texture, level, &row_pitch, &slice_pitch); /* Setup pixel store pack state -- to glReadPixels into the correct place */ gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH, row_pitch / texture->resource.format->byte_count); checkGLcall("glPixelStorei"); - width = wined3d_texture_get_level_width(texture, surface->texture_level); - height = wined3d_texture_get_level_height(texture, surface->texture_level); + width = wined3d_texture_get_level_width(texture, level); + height = wined3d_texture_get_level_height(texture, level); gl_info->gl_ops.gl.p_glReadPixels(0, 0, width, height, texture->resource.format->glFormat, texture->resource.format->glType, data.addr); -- 2.11.4.GIT