From 65808926600673236b222127a106b206243bff88 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 16 Mar 2021 17:13:26 +0100 Subject: [PATCH] wined3d: Take the layer index into account in wined3d_shader_resource_view_gl_generate_mipmap(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/view.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index fec7e950a64..cd13da02078 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1197,7 +1197,7 @@ static void shader_resource_view_gl_bind_and_dirtify(struct wined3d_shader_resou void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resource_view_gl *view_gl, struct wined3d_context_gl *context_gl) { - unsigned int i, j, layer_count, level_count, base_level, max_level; + unsigned int i, j, layer_count, level_count, base_level, base_layer; const struct wined3d_gl_info *gl_info = context_gl->gl_info; struct wined3d_texture_gl *texture_gl; struct gl_texture *gl_tex; @@ -1209,14 +1209,16 @@ void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resou layer_count = view_gl->v.desc.u.texture.layer_count; level_count = view_gl->v.desc.u.texture.level_count; base_level = view_gl->v.desc.u.texture.level_idx; - max_level = base_level + level_count - 1; + base_layer = view_gl->v.desc.u.texture.layer_idx; texture_gl = wined3d_texture_gl(texture_from_resource(view_gl->v.resource)); srgb = !!(texture_gl->t.flags & WINED3D_TEXTURE_IS_SRGB); location = srgb ? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB; for (i = 0; i < layer_count; ++i) { - wined3d_texture_load_location(&texture_gl->t, i * level_count + base_level, &context_gl->c, location); + if (!wined3d_texture_load_location(&texture_gl->t, + (base_layer + i) * level_count + base_level, &context_gl->c, location)) + ERR("Failed to load source layer %u.\n", base_layer + i); } if (view_gl->gl_view.name) @@ -1227,7 +1229,7 @@ void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resou { wined3d_texture_gl_bind_and_dirtify(texture_gl, context_gl, srgb); gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_BASE_LEVEL, base_level); - gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_MAX_LEVEL, max_level); + gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_MAX_LEVEL, base_level + level_count - 1); } if (gl_info->supported[ARB_SAMPLER_OBJECTS]) @@ -1245,10 +1247,12 @@ void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resou for (i = 0; i < layer_count; ++i) { - for (j = base_level + 1; j <= max_level; ++j) + for (j = 1; j < level_count; ++j) { - wined3d_texture_validate_location(&texture_gl->t, i * level_count + j, location); - wined3d_texture_invalidate_location(&texture_gl->t, i * level_count + j, ~location); + wined3d_texture_validate_location(&texture_gl->t, + (base_layer + i) * level_count + base_level + j, location); + wined3d_texture_invalidate_location(&texture_gl->t, + (base_layer + i) * level_count + base_level + j, ~location); } }