diff options
author | Benjamin Otte <otte@redhat.com> | 2023-05-12 04:09:13 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2023-05-17 02:25:32 +0200 |
commit | 6de27b7effc99e383b34b49d80aff0e4506c5912 (patch) | |
tree | fced4f593b8bf3d81b5d3ebe76479f4c3ce9bd58 | |
parent | 8d337c67009c4ea1be028cc47d8549b790087fa2 (diff) | |
download | gtk+-6de27b7effc99e383b34b49d80aff0e4506c5912.tar.gz |
vulkan: Split modelview and projection
This is adding extra work, but the benefits should become visible
in future commits.
-rw-r--r-- | gsk/vulkan/gskvulkanrenderpass.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c index a71febe1d5..296559826a 100644 --- a/gsk/vulkan/gskvulkanrenderpass.c +++ b/gsk/vulkan/gskvulkanrenderpass.c @@ -134,7 +134,8 @@ struct _GskVulkanParseState { graphene_point_t offset; graphene_vec2_t scale; - graphene_matrix_t mvp; + graphene_matrix_t modelview; + graphene_matrix_t projection; GskVulkanClip clip; }; @@ -252,10 +253,10 @@ gsk_vulkan_render_pass_append_push_constants (GskVulkanRenderPass *self, .constants.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS, .constants.node = node, .constants.scale= state->scale, - .constants.mvp = state->mvp, .constants.clip = state->clip.rect, }; + graphene_matrix_multiply (&state->modelview, &state->projection, &op.constants.mvp); g_array_append_val (self->render_ops, op); } @@ -611,7 +612,8 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self, FALLBACK ("Transform nodes can't deal with clip type %u", state->clip.type); gsk_transform_to_matrix (transform, &matrix); - graphene_matrix_multiply (&matrix, &state->mvp, &new_state.mvp); + graphene_matrix_multiply (&matrix, &state->modelview, &new_state.modelview); + graphene_matrix_init_from_matrix (&new_state.projection, &state->projection); gsk_vulkan_render_pass_append_push_constants (self, node, &new_state); @@ -705,7 +707,8 @@ gsk_vulkan_render_pass_add_clip_node (GskVulkanRenderPass *self, new_state.offset = state->offset; graphene_vec2_init_from_vec2 (&new_state.scale, &state->scale); - graphene_matrix_init_from_matrix (&new_state.mvp, &state->mvp); + graphene_matrix_init_from_matrix (&new_state.modelview, &state->modelview); + graphene_matrix_init_from_matrix (&new_state.projection, &state->projection); gsk_vulkan_render_pass_append_push_constants (self, node, &new_state); @@ -736,7 +739,8 @@ gsk_vulkan_render_pass_add_rounded_clip_node (GskVulkanRenderPass *self, new_state.offset = state->offset; graphene_vec2_init_from_vec2 (&new_state.scale, &state->scale); - graphene_matrix_init_from_matrix (&new_state.mvp, &state->mvp); + graphene_matrix_init_from_matrix (&new_state.modelview, &state->modelview); + graphene_matrix_init_from_matrix (&new_state.projection, &state->projection); gsk_vulkan_render_pass_append_push_constants (self, node, &new_state); @@ -1042,18 +1046,16 @@ gsk_vulkan_render_pass_add (GskVulkanRenderPass *self, GskRenderNode *node) { GskVulkanParseState state; - graphene_matrix_t projection, mvp; - graphene_matrix_init_scale (&mvp, + graphene_matrix_init_scale (&state.modelview, graphene_vec2_get_x (&self->scale), graphene_vec2_get_y (&self->scale), 1.0); - graphene_matrix_init_ortho (&projection, + graphene_matrix_init_ortho (&state.projection, self->viewport.origin.x, self->viewport.origin.x + self->viewport.size.width, self->viewport.origin.y, self->viewport.origin.y + self->viewport.size.height, 2 * ORTHO_NEAR_PLANE - ORTHO_FAR_PLANE, ORTHO_FAR_PLANE); - graphene_matrix_multiply (&mvp, &projection, &state.mvp); gsk_vulkan_clip_init_empty (&state.clip, &self->viewport); graphene_vec2_init_from_vec2 (&state.scale, &self->scale); state.offset = *graphene_point_zero (); |