mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
vulkan: Don't store unused matrices
We can compute it when needed, so do that.
This commit is contained in:
parent
5b93a32f90
commit
a55fda0b49
@ -115,8 +115,6 @@ struct _GskVulkanRenderPass
|
|||||||
GskVulkanImage *target;
|
GskVulkanImage *target;
|
||||||
graphene_rect_t viewport;
|
graphene_rect_t viewport;
|
||||||
cairo_region_t *clip;
|
cairo_region_t *clip;
|
||||||
graphene_matrix_t mv;
|
|
||||||
graphene_matrix_t p;
|
|
||||||
|
|
||||||
float scale_x;
|
float scale_x;
|
||||||
float scale_y;
|
float scale_y;
|
||||||
@ -154,13 +152,6 @@ gsk_vulkan_render_pass_new (GdkVulkanContext *context,
|
|||||||
self->scale_x = scale_x;
|
self->scale_x = scale_x;
|
||||||
self->scale_y = scale_y;
|
self->scale_y = scale_y;
|
||||||
|
|
||||||
graphene_matrix_init_scale (&self->mv, self->scale_x, self->scale_y, 1.0);
|
|
||||||
graphene_matrix_init_ortho (&self->p,
|
|
||||||
viewport->origin.x, viewport->origin.x + viewport->size.width,
|
|
||||||
viewport->origin.y, viewport->origin.y + viewport->size.height,
|
|
||||||
2 * ORTHO_NEAR_PLANE - ORTHO_FAR_PLANE,
|
|
||||||
ORTHO_FAR_PLANE);
|
|
||||||
|
|
||||||
if (signal_semaphore != VK_NULL_HANDLE) // this is a dependent pass
|
if (signal_semaphore != VK_NULL_HANDLE) // this is a dependent pass
|
||||||
final_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
final_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
else
|
else
|
||||||
@ -506,10 +497,8 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self,
|
|||||||
GskVulkanOp op = {
|
GskVulkanOp op = {
|
||||||
.render.node = node
|
.render.node = node
|
||||||
};
|
};
|
||||||
graphene_matrix_t old_mv;
|
|
||||||
GskRenderNode *child;
|
GskRenderNode *child;
|
||||||
GskTransform *transform;
|
GskTransform *transform;
|
||||||
graphene_matrix_t transform_matrix;
|
|
||||||
float new_scale_x = self->scale_x;
|
float new_scale_x = self->scale_x;
|
||||||
float new_scale_y = self->scale_x;
|
float new_scale_y = self->scale_x;
|
||||||
float old_scale_x;
|
float old_scale_x;
|
||||||
@ -575,16 +564,12 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
old_mv = self->mv;
|
|
||||||
old_scale_x = self->scale_x;
|
old_scale_x = self->scale_x;
|
||||||
old_scale_y = self->scale_y;
|
old_scale_y = self->scale_y;
|
||||||
|
|
||||||
self->scale_x = new_scale_x;
|
self->scale_x = new_scale_x;
|
||||||
self->scale_y = new_scale_y;
|
self->scale_y = new_scale_y;
|
||||||
|
|
||||||
gsk_transform_to_matrix (transform, &transform_matrix);
|
|
||||||
graphene_matrix_multiply (&transform_matrix, &self->mv, &self->mv);
|
|
||||||
|
|
||||||
child = gsk_transform_node_get_child (node);
|
child = gsk_transform_node_get_child (node);
|
||||||
if (!gsk_vulkan_push_constants_transform (&op.constants.constants, constants, transform, &child->bounds))
|
if (!gsk_vulkan_push_constants_transform (&op.constants.constants, constants, transform, &child->bounds))
|
||||||
FALLBACK ("Transform nodes can't deal with clip type %u", constants->clip.type);
|
FALLBACK ("Transform nodes can't deal with clip type %u", constants->clip.type);
|
||||||
@ -598,7 +583,6 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self,
|
|||||||
|
|
||||||
self->scale_x = old_scale_x;
|
self->scale_x = old_scale_x;
|
||||||
self->scale_y = old_scale_y;
|
self->scale_y = old_scale_y;
|
||||||
self->mv = old_mv;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1003,9 +987,16 @@ gsk_vulkan_render_pass_add (GskVulkanRenderPass *self,
|
|||||||
GskRenderNode *node)
|
GskRenderNode *node)
|
||||||
{
|
{
|
||||||
GskVulkanOp op = { 0, };
|
GskVulkanOp op = { 0, };
|
||||||
graphene_matrix_t mvp;
|
graphene_matrix_t projection, mvp;
|
||||||
|
|
||||||
|
graphene_matrix_init_scale (&mvp, self->scale_x, self->scale_y, 1.0);
|
||||||
|
graphene_matrix_init_ortho (&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, &mvp);
|
||||||
|
|
||||||
graphene_matrix_multiply (&self->mv, &self->p, &mvp);
|
|
||||||
op.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS;
|
op.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS;
|
||||||
gsk_vulkan_push_constants_init (&op.constants.constants, &mvp, &self->viewport);
|
gsk_vulkan_push_constants_init (&op.constants.constants, &mvp, &self->viewport);
|
||||||
g_array_append_val (self->render_ops, op);
|
g_array_append_val (self->render_ops, op);
|
||||||
|
Loading…
Reference in New Issue
Block a user