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

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-02-27 09:55:13 +03:30 committed by Alexandre Julliard
parent ec4be4ba40
commit 78366806a0
1 changed files with 10 additions and 9 deletions

View File

@ -785,7 +785,7 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
struct wined3d_texture *texture = surface->container;
UINT update_w = src_rect->right - src_rect->left;
UINT update_h = src_rect->bottom - src_rect->top;
unsigned int layer;
unsigned int level, layer;
GLenum target;
TRACE("surface %p, gl_info %p, format %s, src_rect %s, src_pitch %u, dst_point %s, srgb %#x, data {%#x:%p}.\n",
@ -811,6 +811,7 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
}
target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx);
level = sub_resource_idx % texture->level_count;
layer = sub_resource_idx / texture->level_count;
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
@ -834,19 +835,19 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
TRACE("Uploading compressed data, target %#x, level %u, layer %u, x %d, y %d, w %u, h %u, "
"format %#x, image_size %#x, addr %p.\n",
target, surface->texture_level, layer, dst_point->x, dst_point->y,
target, level, layer, dst_point->x, dst_point->y,
update_w, update_h, internal, dst_slice_pitch, addr);
if (dst_row_pitch == src_pitch)
{
if (target == GL_TEXTURE_2D_ARRAY)
{
GL_EXTCALL(glCompressedTexSubImage3D(target, surface->texture_level, dst_point->x, dst_point->y,
GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_point->x, dst_point->y,
layer, update_w, update_h, 1, internal, dst_slice_pitch, addr));
}
else
{
GL_EXTCALL(glCompressedTexSubImage2D(target, surface->texture_level, dst_point->x, dst_point->y,
GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_point->x, dst_point->y,
update_w, update_h, internal, dst_slice_pitch, addr));
}
}
@ -861,12 +862,12 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
{
if (target == GL_TEXTURE_2D_ARRAY)
{
GL_EXTCALL(glCompressedTexSubImage3D(target, surface->texture_level, dst_point->x, y,
GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_point->x, y,
layer, update_w, format->block_height, 1, internal, dst_row_pitch, addr));
}
else
{
GL_EXTCALL(glCompressedTexSubImage2D(target, surface->texture_level, dst_point->x, y,
GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_point->x, y,
update_w, format->block_height, internal, dst_row_pitch, addr));
}
@ -885,18 +886,18 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
TRACE("Uploading data, target %#x, level %u, layer %u, x %d, y %d, w %u, h %u, "
"format %#x, type %#x, addr %p.\n",
target, surface->texture_level, layer, dst_point->x, dst_point->y,
target, level, layer, dst_point->x, dst_point->y,
update_w, update_h, format->glFormat, format->glType, addr);
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, src_pitch / format->byte_count);
if (target == GL_TEXTURE_2D_ARRAY)
{
GL_EXTCALL(glTexSubImage3D(target, surface->texture_level, dst_point->x, dst_point->y,
GL_EXTCALL(glTexSubImage3D(target, level, dst_point->x, dst_point->y,
layer, update_w, update_h, 1, format->glFormat, format->glType, addr));
}
else
{
gl_info->gl_ops.gl.p_glTexSubImage2D(target, surface->texture_level, dst_point->x, dst_point->y,
gl_info->gl_ops.gl.p_glTexSubImage2D(target, level, dst_point->x, dst_point->y,
update_w, update_h, format->glFormat, format->glType, addr);
}
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);