[gtk+/wip/otte/vulkan: 45/62] vulkan: Make the VulkanRender object allocated
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/vulkan: 45/62] vulkan: Make the VulkanRender object allocated
- Date: Fri, 9 Dec 2016 17:38:43 +0000 (UTC)
commit eb94153a2cdd4a0f9708c6e1beb8bfe414ffed45
Author: Benjamin Otte <otte redhat com>
Date: Thu Dec 8 17:46:08 2016 +0100
vulkan: Make the VulkanRender object allocated
That way, we can have multiple of those and keep them around for reuse.
gsk/gskvulkanrender.c | 22 +++++++++++++---------
gsk/gskvulkanrenderer.c | 14 +++++++-------
gsk/gskvulkanrenderprivate.h | 5 ++---
3 files changed, 22 insertions(+), 19 deletions(-)
---
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c
index 8fd9160..2cf99ac 100644
--- a/gsk/gskvulkanrender.c
+++ b/gsk/gskvulkanrender.c
@@ -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);
}
diff --git a/gsk/gskvulkanrenderer.c b/gsk/gskvulkanrenderer.c
index 8bf422e..1655e23 100644
--- a/gsk/gskvulkanrenderer.c
+++ b/gsk/gskvulkanrenderer.c
@@ -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);
diff --git a/gsk/gskvulkanrenderprivate.h b/gsk/gskvulkanrenderprivate.h
index 53f67de..de4dc80 100644
--- a/gsk/gskvulkanrenderprivate.h
+++ b/gsk/gskvulkanrenderprivate.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]