gsk/vulkan/renderpass: Don't scale scissor and render area
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Mon, 3 Apr 2023 13:06:18 +0000 (10:06 -0300)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Mon, 3 Apr 2023 13:59:45 +0000 (10:59 -0300)
The rects passed to the clip region are in buffer coordinates, and
must not be scaled. Consider the following scenario: Wayland, with
a 1024x768@2 window. That gives us a 2048x1536 raw image. To setup
the Vulkan render pass code, we'd scale 2048x1536 *again*, to an
unreasonable 4196x3072, which is (1) incorrect and (2) really
incorrect and (3) can lead to crashes at best, full GPU resets
at worst - and a GPU reset is incredibly not fun!

Now that we pass the right clip regions at the right coordinates
at all times, remove the extra scaling from the render pass.

gsk/vulkan/gskvulkanrenderpass.c

index 458d2b1fa4151238e4ed81589cffba661b7ada33..24432ddd0670d80a49e9aaac6e7cb7c0cb0f1232 100644 (file)
@@ -2258,8 +2258,8 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass     *self,
                        0,
                        1,
                        &(VkRect2D) {
-                          { rect.x * self->scale_x, rect.y * self->scale_y },
-                          { rect.width * self->scale_x, rect.height * self->scale_y }
+                          { rect.x, rect.y },
+                          { rect.width, rect.height }
                        });
 
       vkCmdBeginRenderPass (command_buffer,
@@ -2268,8 +2268,8 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass     *self,
                                 .renderPass = self->render_pass,
                                 .framebuffer = gsk_vulkan_render_get_framebuffer (render, self->target),
                                 .renderArea = { 
-                                    { rect.x * self->scale_x, rect.y * self->scale_y },
-                                    { rect.width * self->scale_x, rect.height * self->scale_y }
+                                    { rect.x, rect.y },
+                                    { rect.width, rect.height }
                                 },
                                 .clearValueCount = 1,
                                 .pClearValues = (VkClearValue [1]) {