From d48b6b9ad502dcd59638d7e95ccd8ddbadce4168 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 18 May 2023 01:18:38 +0200 Subject: [PATCH] vulkan: Add optimization for transforms When attempting a complex transform, check if the clip can be ignored and do that if possible. That way we don't cause fallbacks when transforming the clip is too complex. --- gsk/vulkan/gskvulkanrenderpass.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c index 5f589e5e98..8bbdc9ed2c 100644 --- a/gsk/vulkan/gskvulkanrenderpass.c +++ b/gsk/vulkan/gskvulkanrenderpass.c @@ -540,11 +540,6 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self, GskTransform *transform; GskVulkanParseState new_state; -#if 0 - if (!gsk_vulkan_clip_contains_rect (clip, &node->bounds)) - FALLBACK ("Transform nodes can't deal with clip type %u\n", clip->type); -#endif - child = gsk_transform_node_get_child (node); transform = gsk_transform_node_get_transform (node); @@ -584,7 +579,11 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self, clip_transform = gsk_transform_transform (gsk_transform_translate (NULL, &state->offset), transform); - if (!gsk_vulkan_clip_transform (&new_state.clip, &state->clip, clip_transform, &child->bounds)) + if (gsk_vulkan_clip_contains_rect (&state->clip, &state->offset, &node->bounds)) + { + gsk_vulkan_clip_init_empty (&new_state.clip, &child->bounds); + } + else if (!gsk_vulkan_clip_transform (&new_state.clip, &state->clip, clip_transform, &child->bounds)) { gsk_transform_unref (clip_transform); FALLBACK ("Transform nodes can't deal with clip type %u", state->clip.type); @@ -625,7 +624,11 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self, clip_transform = gsk_transform_transform (gsk_transform_translate (NULL, &state->offset), transform); - if (!gsk_vulkan_clip_transform (&new_state.clip, &state->clip, clip_transform, &child->bounds)) + if (gsk_vulkan_clip_contains_rect (&state->clip, &state->offset, &node->bounds)) + { + gsk_vulkan_clip_init_empty (&new_state.clip, &child->bounds); + } + else if (!gsk_vulkan_clip_transform (&new_state.clip, &state->clip, clip_transform, &child->bounds)) { gsk_transform_unref (clip_transform); FALLBACK ("Transform nodes can't deal with clip type %u", state->clip.type); -- 2.30.2