pvr: Fix rect splitting logic in pvr_unwind_rects()
authorMatt Coster <matt.coster@imgtec.com>
Fri, 19 May 2023 10:46:38 +0000 (11:46 +0100)
committerMatt Coster <matt.coster@imgtec.com>
Wed, 31 May 2023 11:23:58 +0000 (12:23 +0100)
Fixes:
  dEQP-VK.api.copy_and_blit.core.image_to_buffer.buffer_offset_relaxed
  dEQP-VK.api.image_clearing.core.clear_color_image.3d.optimal
    .single_layer.r8_unorm_200x180x16

Signed-off-by: Matt Coster <matt.coster@imgtec.com>
Reported-by: Soroush Kashani <soroush.kashani@imgtec.com>
Reported-by: Oskar Rundgren <oskar.rundgren@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23309>

src/imagination/vulkan/pvr_job_transfer.c

index 96224d7..d1b8064 100644 (file)
@@ -4848,6 +4848,7 @@ static void pvr_unwind_rects(uint32_t width,
          VkRect2D *new_rect = input ? &mappings[new_mapping].src_rect
                                     : &mappings[new_mapping].dst_rect;
          uint32_t split_point = width - texel_unwind;
+         uint32_t split_width;
 
          assert(new_mapping < ARRAY_SIZE(pass->sources[0].mappings));
 
@@ -4856,28 +4857,28 @@ static void pvr_unwind_rects(uint32_t width,
          rect->extent.width = split_point - rect->offset.x;
          new_rect->offset.x = split_point;
 
+         split_width = (rect->offset.x + new_rect->extent.width) - split_point;
+
          if (input) {
-            mappings[i].dst_rect.extent.width -=
-               new_rect->extent.width - split_point;
+            mappings[i].dst_rect.extent.width -= split_width;
             mappings[new_mapping].dst_rect.offset.x =
                mappings[i].dst_rect.offset.x +
                mappings[i].dst_rect.extent.width;
+            mappings[new_mapping].dst_rect.extent.width = split_width;
          } else {
-            mappings[i].src_rect.extent.width -=
-               new_rect->extent.width - split_point;
+            mappings[i].src_rect.extent.width -= split_width;
             mappings[new_mapping].src_rect.offset.x =
                mappings[i].src_rect.offset.x +
                mappings[i].src_rect.extent.width;
-            mappings[new_mapping].src_rect.extent.width = texel_unwind;
+            mappings[new_mapping].src_rect.extent.width = split_width;
          }
 
          rect->offset.x += texel_unwind;
          rect->extent.width = width - rect->offset.x;
 
-         new_rect->offset.x =
-            (int32_t)texel_unwind - (int32_t)width + new_rect->offset.x;
+         new_rect->offset.x += (int32_t)texel_unwind - (int32_t)width;
          new_rect->offset.y++;
-         new_rect->extent.width = texel_unwind - width + new_rect->extent.width;
+         new_rect->extent.width += (int32_t)texel_unwind - (int32_t)width;
 
          new_mappings++;
       }