vulkan: Make projection matrix match GL
authorBenjamin Otte <otte@redhat.com>
Tue, 16 May 2023 15:18:19 +0000 (17:18 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 16 May 2023 16:53:27 +0000 (18:53 +0200)
Vulkan has a different initial coordinate system to GL.

GL:
(-1, 1, -1) +------+.
            |`.    | `.
            |  `·--|---·
            |   :  |   :
            +------+.  :
             `. :    `.:
               `·------· (1, -1, 1)

Vulkan:
(-1, -1, 0) +------+.
            |`.    | `.
            |  `·--|---·
            |   :  |   :
            +------+.  :
             `. :    `.:
               `·------· (1, 1, 1)

so adjust the near and far plane we pass to
graphene_matrix_init_ortho() to make it end up with the same
projection as the GL renderer.

gsk/vulkan/gskvulkanrenderpass.c

index c23aa0ba7b3a5e600955f8c7b11060d678c7cfd8..f364b7f4c1a91be7dcdaf896687c526316711131 100644 (file)
@@ -157,7 +157,7 @@ gsk_vulkan_render_pass_new (GdkVulkanContext  *context,
   graphene_matrix_init_ortho (&self->p,
                               viewport->origin.x, viewport->origin.x + viewport->size.width,
                               viewport->origin.y, viewport->origin.y + viewport->size.height,
-                              ORTHO_NEAR_PLANE,
+                              2 * ORTHO_NEAR_PLANE - ORTHO_FAR_PLANE,
                               ORTHO_FAR_PLANE);
 
   if (signal_semaphore != VK_NULL_HANDLE) // this is a dependent pass