Jan Sikorski : wined3d: Handle different slice pitches in compressed texture updates.

Alexandre Julliard julliard at winehq.org
Fri Mar 26 16:03:32 CDT 2021


Module: wine
Branch: master
Commit: e42f89b5430899496852cb13eaaadea6f32ed998
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e42f89b5430899496852cb13eaaadea6f32ed998

Author: Jan Sikorski <jsikorski at codeweavers.com>
Date:   Fri Mar 26 14:21:47 2021 +0100

wined3d: Handle different slice pitches in compressed texture updates.

Signed-off-by: Jan Sikorski <jsikorski at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/texture.c | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 22bd8cc34b7..4db62b198eb 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -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;
                 }
             }
         }




More information about the wine-cvs mailing list