Commit cf470f31 authored by Benjamin Otte's avatar Benjamin Otte

vulkan: Push the correct matrix when drawing

Instead of pushing the root matrix, push the world matrix for the
current node. That way, the bounds we emit as vertices are actually
properly transformed.
parent 93448b8c
......@@ -437,16 +437,9 @@ gsk_vulkan_render_draw (GskVulkanRender *self,
},
(VkDeviceSize[1]) { 0 });
vkCmdPushConstants (self->command_buffer,
gsk_vulkan_pipeline_get_pipeline_layout (self->pipeline),
VK_SHADER_STAGE_VERTEX_BIT,
0,
sizeof (graphene_matrix_t),
&self->mvp);
for (l = self->render_passes; l; l = l->next)
{
gsk_vulkan_render_pass_draw (l->data, self, self->pipeline, self->command_buffer);
gsk_vulkan_render_pass_draw (l->data, self, &self->mvp, self->pipeline, self->command_buffer);
}
vkCmdEndRenderPass (self->command_buffer);
......
......@@ -211,12 +211,15 @@ gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulkanRenderPass *self,
}
void
gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
GskVulkanRender *render,
GskVulkanPipeline *pipeline,
VkCommandBuffer command_buffer)
gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
GskVulkanRender *render,
const graphene_matrix_t *root_mvp,
GskVulkanPipeline *pipeline,
VkCommandBuffer command_buffer)
{
GskVulkanRenderOp *op;
graphene_matrix_t world, mvp;
float float_matrix[16];
guint i;
for (i = 0; i < self->render_ops->len; i++)
......@@ -234,6 +237,17 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
0,
NULL);
gsk_render_node_get_world_matrix (op->node, &world);
graphene_matrix_multiply (&world, root_mvp, &mvp);
graphene_matrix_to_float (&mvp, float_matrix);
vkCmdPushConstants (command_buffer,
gsk_vulkan_pipeline_get_pipeline_layout (pipeline),
VK_SHADER_STAGE_VERTEX_BIT,
0,
sizeof (float_matrix),
&float_matrix);
vkCmdDraw (command_buffer,
op->vertex_count, 1,
op->vertex_offset, 0);
......
......@@ -31,6 +31,7 @@ void gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulk
GskVulkanRender *render);
void gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
GskVulkanRender *render,
const graphene_matrix_t*root_mvp,
GskVulkanPipeline *pipeline,
VkCommandBuffer command_buffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment