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

wined3d: Take the layer index into account in wined3d_shader_resource_view_gl_generate_mipmap().

parent 8c473180
......@@ -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);
}
}
......
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