From 27845d2fbdcf54adc6362880e0e8fe316da34ac8 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 7 Jun 2021 16:55:11 +0200 Subject: [PATCH] wined3d: Use the texture level count to calculate sub-resource indices for OpenGL mip-map generation. Instead of the view's level count, which may be different. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/view.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index cda16b690f8..f9ba8430d08 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, base_layer; + unsigned int i, j, layer_count, level_count, base_level, base_layer, sub_resource_idx; const struct wined3d_gl_info *gl_info = context_gl->gl_info; struct wined3d_texture_gl *texture_gl; struct gl_texture *gl_tex; @@ -1216,8 +1216,8 @@ void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resou location = srgb ? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB; for (i = 0; i < layer_count; ++i) { - if (!wined3d_texture_load_location(&texture_gl->t, - (base_layer + i) * level_count + base_level, &context_gl->c, location)) + sub_resource_idx = (base_layer + i) * texture_gl->t.level_count + base_level; + if (!wined3d_texture_load_location(&texture_gl->t, sub_resource_idx, &context_gl->c, location)) ERR("Failed to load source layer %u.\n", base_layer + i); } @@ -1249,10 +1249,9 @@ void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resou { for (j = 1; j < level_count; ++j) { - 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); + sub_resource_idx = (base_layer + i) * texture_gl->t.level_count + base_level + j; + wined3d_texture_validate_location(&texture_gl->t, sub_resource_idx, location); + wined3d_texture_invalidate_location(&texture_gl->t, sub_resource_idx, ~location); } }