Commit e42f89b5 authored by Jan Sikorski's avatar Jan Sikorski Committed by Alexandre Julliard

wined3d: Handle different slice pitches in compressed texture updates.

parent fc29f2a6
......@@ -2169,43 +2169,44 @@ static void wined3d_texture_gl_upload_bo(const struct wined3d_format *src_format
GL_EXTCALL(glCompressedTexSubImage1D(target, level, dst_x,
update_w, internal, dst_row_pitch, addr));
}
else if (dst_row_pitch == src_row_pitch)
else
{
if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_3D)
unsigned int row, y, slice, slice_count = 1, row_count = 1;
/* glCompressedTexSubImage2D() ignores pixel store state, so we
* can't use the unpack row length like for glTexSubImage2D. */
if (dst_row_pitch != src_row_pitch)
{
GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_x, dst_y, dst_z,
update_w, update_h, update_d, internal, dst_slice_pitch * update_d, addr));
row_count = (update_h + src_format->block_height - 1) / src_format->block_height;
update_h = src_format->block_height;
wined3d_format_calculate_pitch(src_format, 1, update_w, update_h,
&dst_row_pitch, &dst_slice_pitch);
}
else
if (dst_slice_pitch != src_slice_pitch)
{
GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_x, dst_y,
update_w, update_h, internal, dst_slice_pitch, addr));
slice_count = update_d;
update_d = 1;
}
}
else
{
unsigned int row_count = (update_h + src_format->block_height - 1) / src_format->block_height;
unsigned int row, y, z;
/* glCompressedTexSubImage2D() ignores pixel store state, so we
* can't use the unpack row length like for glTexSubImage2D. */
for (z = dst_z; z < dst_z + update_d; ++z)
for (slice = 0; slice < slice_count; ++slice)
{
for (row = 0, y = dst_y; row < row_count; ++row)
{
const BYTE *upload_addr = &addr[slice * src_slice_pitch + row * src_row_pitch];
if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_3D)
{
GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_x, y, z,
update_w, src_format->block_height, 1, internal, dst_row_pitch, addr));
GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_x, y, dst_z + slice, update_w,
update_h, update_d, internal, update_d * dst_slice_pitch, upload_addr));
}
else
{
GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_x, y,
update_w, src_format->block_height, internal, dst_row_pitch, addr));
GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_x, y, update_w,
update_h, internal, dst_slice_pitch, upload_addr));
}
y += src_format->block_height;
addr += src_row_pitch;
}
}
}
......
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