Commit eb94153a authored by Benjamin Otte's avatar Benjamin Otte

vulkan: Make the VulkanRender object allocated

That way, we can have multiple of those and keep them around for reuse.
parent 747df7aa
......@@ -37,19 +37,19 @@ gsk_vulkan_render_compute_mvp (GskVulkanRender *self)
graphene_matrix_multiply (&modelview, &projection, &self->mvp);
}
void
gsk_vulkan_render_init (GskVulkanRender *self,
GskRenderer *renderer,
GdkVulkanContext *context,
VkCommandPool command_pool)
GskVulkanRender *
gsk_vulkan_render_new (GskRenderer *renderer,
GdkVulkanContext *context,
VkCommandPool command_pool)
{
GskVulkanRender *self;
self = g_slice_new0 (GskVulkanRender);
self->vulkan = context;
self->renderer = renderer;
self->command_pool = command_pool;
self->render_passes = NULL;
self->cleanup_images = NULL;
gsk_vulkan_render_compute_mvp (self);
GSK_VK_CHECK (vkAllocateCommandBuffers, gdk_vulkan_context_get_device (self->vulkan),
......@@ -66,6 +66,8 @@ gsk_vulkan_render_init (GskVulkanRender *self,
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
.flags = 0
});
return self;
}
void
......@@ -262,7 +264,7 @@ gsk_vulkan_render_submit (GskVulkanRender *self,
}
void
gsk_vulkan_render_finish (GskVulkanRender *self)
gsk_vulkan_render_free (GskVulkanRender *self)
{
GSK_VK_CHECK (vkResetCommandPool, gdk_vulkan_context_get_device (self->vulkan),
self->command_pool,
......@@ -270,4 +272,6 @@ gsk_vulkan_render_finish (GskVulkanRender *self)
g_slist_free_full (self->render_passes, (GDestroyNotify) gsk_vulkan_render_pass_free);
g_slist_free_full (self->cleanup_images, (GDestroyNotify) gsk_vulkan_image_free);
g_slice_free (GskVulkanRender, self);
}
......@@ -337,7 +337,7 @@ gsk_vulkan_renderer_render (GskRenderer *renderer,
GskRenderNode *root)
{
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
GskVulkanRender render;
GskVulkanRender *render;
#ifdef G_ENABLE_DEBUG
GskProfiler *profiler;
gint64 cpu_time;
......@@ -348,20 +348,20 @@ gsk_vulkan_renderer_render (GskRenderer *renderer,
gsk_profiler_timer_begin (profiler, self->profile_timers.cpu_time);
#endif
gsk_vulkan_render_init (&render, renderer, self->vulkan, self->command_pool);
render = gsk_vulkan_render_new (renderer, self->vulkan, self->command_pool);
gsk_vulkan_render_add_node (&render, root);
gsk_vulkan_render_add_node (render, root);
gsk_vulkan_render_upload (&render);
gsk_vulkan_render_upload (render);
gsk_vulkan_render_draw (&render, self->pipeline,
gsk_vulkan_render_draw (render, self->pipeline,
self->render_pass,
self->targets[gdk_vulkan_context_get_draw_index (self->vulkan)]->framebuffer,
self->descriptor_set, self->sampler);
gsk_vulkan_render_submit (&render, self->command_pool_fence);
gsk_vulkan_render_submit (render, self->command_pool_fence);
gsk_vulkan_render_finish (&render);
gsk_vulkan_render_free (render);
#ifdef G_ENABLE_DEBUG
cpu_time = gsk_profiler_timer_end (profiler, self->profile_timers.cpu_time);
......
......@@ -38,11 +38,10 @@ struct _GskVulkanVertex
float tex_y;
};
void gsk_vulkan_render_init (GskVulkanRender *self,
GskRenderer *renderer,
GskVulkanRender * gsk_vulkan_render_new (GskRenderer *renderer,
GdkVulkanContext *context,
VkCommandPool command_pool);
void gsk_vulkan_render_finish (GskVulkanRender *self);
void gsk_vulkan_render_free (GskVulkanRender *self);
void gsk_vulkan_render_add_cleanup_image (GskVulkanRender *self,
GskVulkanImage *image);
......
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