wined3d: Explicitly calculate the sub-resource level in wined3d_texture_allocate_gl_mutable_storage().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-03-02 12:10:48 +03:30 committed by Alexandre Julliard
parent 365948bf70
commit 6639ce4b09
1 changed files with 29 additions and 29 deletions

View File

@ -492,19 +492,19 @@ static void wined3d_texture_allocate_gl_mutable_storage(struct wined3d_texture *
GLenum gl_internal_format, const struct wined3d_format *format, GLenum gl_internal_format, const struct wined3d_format *format,
const struct wined3d_gl_info *gl_info) const struct wined3d_gl_info *gl_info)
{ {
unsigned int i, level, sub_call_count; unsigned int level, level_count, layer, layer_count;
sub_call_count = texture->level_count;
if (texture->target != GL_TEXTURE_2D_ARRAY)
sub_call_count *= texture->layer_count;
for (i = 0; i < sub_call_count; ++i)
{
struct wined3d_surface *surface = texture->sub_resources[i].u.surface;
GLsizei width, height; GLsizei width, height;
GLenum target; GLenum target;
level = surface->texture_level; level_count = texture->level_count;
layer_count = texture->target == GL_TEXTURE_2D_ARRAY ? 1 : texture->layer_count;
for (layer = 0; layer < layer_count; ++layer)
{
target = wined3d_texture_get_sub_resource_target(texture, layer * level_count);
for (level = 0; level < level_count; ++level)
{
width = wined3d_texture_get_level_pow2_width(texture, level); width = wined3d_texture_get_level_pow2_width(texture, level);
height = wined3d_texture_get_level_pow2_height(texture, level); height = wined3d_texture_get_level_pow2_height(texture, level);
if (texture->resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE) if (texture->resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
@ -512,10 +512,9 @@ static void wined3d_texture_allocate_gl_mutable_storage(struct wined3d_texture *
height *= format->height_scale.numerator; height *= format->height_scale.numerator;
height /= format->height_scale.denominator; height /= format->height_scale.denominator;
} }
target = wined3d_texture_get_sub_resource_target(texture, i);
TRACE("surface %p, target %#x, level %u, width %u, height %u.\n", TRACE("texture %p, layer %u, level %u, target %#x, width %u, height %u.\n",
surface, target, level, width, height); texture, layer, level, target, width, height);
if (texture->target == GL_TEXTURE_2D_ARRAY) if (texture->target == GL_TEXTURE_2D_ARRAY)
{ {
@ -531,6 +530,7 @@ static void wined3d_texture_allocate_gl_mutable_storage(struct wined3d_texture *
} }
} }
} }
}
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
/* The caller is responsible for binding the correct texture. */ /* The caller is responsible for binding the correct texture. */