[gtk+/wip/otte/vulkan: 13/28] vulkan: Move command pool and fence into render object
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/vulkan: 13/28] vulkan: Move command pool and fence into render object
- Date: Fri, 9 Dec 2016 06:28:08 +0000 (UTC)
commit b419772bfce61de565e2308b8557713960c784b7
Author: Benjamin Otte <otte redhat com>
Date: Thu Dec 8 18:03:05 2016 +0100
vulkan: Move command pool and fence into render object
gsk/gskvulkanrender.c | 48 +++++++++++++++++++++++++++++++++--------
gsk/gskvulkanrenderer.c | 32 +--------------------------
gsk/gskvulkanrenderprivate.h | 6 +---
3 files changed, 42 insertions(+), 44 deletions(-)
---
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c
index 571ed29..a876a2a 100644
--- a/gsk/gskvulkanrender.c
+++ b/gsk/gskvulkanrender.c
@@ -21,6 +21,8 @@ struct _GskVulkanRender
VkRect2D scissor;
VkCommandPool command_pool;
+ VkFence fence;
+
VkCommandBuffer command_buffer;
GSList *render_passes;
@@ -56,20 +58,38 @@ gsk_vulkan_render_compute_mvp (GskVulkanRender *self)
GskVulkanRender *
gsk_vulkan_render_new (GskRenderer *renderer,
- GdkVulkanContext *context,
- VkCommandPool command_pool)
+ GdkVulkanContext *context)
{
GskVulkanRender *self;
+ VkDevice device;
self = g_slice_new0 (GskVulkanRender);
self->vulkan = context;
self->renderer = renderer;
- self->command_pool = command_pool;
gsk_vulkan_render_compute_mvp (self);
- GSK_VK_CHECK (vkAllocateCommandBuffers, gdk_vulkan_context_get_device (self->vulkan),
+ device = gdk_vulkan_context_get_device (self->vulkan);
+
+ GSK_VK_CHECK (vkCreateCommandPool, device,
+ &(const VkCommandPoolCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
+ .queueFamilyIndex = gdk_vulkan_context_get_queue_family_index
(self->vulkan),
+ .flags = 0
+ },
+ NULL,
+ &self->command_pool);
+
+ GSK_VK_CHECK (vkCreateFence, device,
+ &(VkFenceCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
+ .flags = 0
+ },
+ NULL,
+ &self->fence);
+
+ GSK_VK_CHECK (vkAllocateCommandBuffers, device,
&(VkCommandBufferAllocateInfo) {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
.commandPool = self->command_pool,
@@ -245,8 +265,7 @@ gsk_vulkan_render_draw (GskVulkanRender *self,
}
void
-gsk_vulkan_render_submit (GskVulkanRender *self,
- VkFence fence)
+gsk_vulkan_render_submit (GskVulkanRender *self)
{
GSK_VK_CHECK (vkEndCommandBuffer, self->command_buffer);
@@ -268,28 +287,37 @@ gsk_vulkan_render_submit (GskVulkanRender *self,
gdk_vulkan_context_get_draw_semaphore (self->vulkan)
}
},
- fence);
+ self->fence);
GSK_VK_CHECK (vkWaitForFences, gdk_vulkan_context_get_device (self->vulkan),
1,
- &fence,
+ &self->fence,
VK_TRUE,
INT64_MAX);
GSK_VK_CHECK (vkResetFences, gdk_vulkan_context_get_device (self->vulkan),
1,
- &fence);
+ &self->fence);
}
void
gsk_vulkan_render_free (GskVulkanRender *self)
{
- GSK_VK_CHECK (vkResetCommandPool, gdk_vulkan_context_get_device (self->vulkan),
+ VkDevice device = gdk_vulkan_context_get_device (self->vulkan);
+
+ GSK_VK_CHECK (vkResetCommandPool, device,
self->command_pool,
0);
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);
+ vkDestroyFence (device,
+ self->fence,
+ NULL);
+ vkDestroyCommandPool (device,
+ self->command_pool,
+ NULL);
+
g_slice_free (GskVulkanRender, self);
}
diff --git a/gsk/gskvulkanrenderer.c b/gsk/gskvulkanrenderer.c
index 1655e23..2332ccf 100644
--- a/gsk/gskvulkanrenderer.c
+++ b/gsk/gskvulkanrenderer.c
@@ -34,8 +34,6 @@ struct _GskVulkanRenderer
GskVulkanTarget **targets;
VkRenderPass render_pass;
- VkCommandPool command_pool;
- VkFence command_pool_fence;
VkDescriptorPool descriptor_pool;
VkDescriptorSet descriptor_set;
@@ -220,22 +218,6 @@ gsk_vulkan_renderer_realize (GskRenderer *renderer,
},
NULL,
&self->render_pass);
- GSK_VK_CHECK (vkCreateCommandPool, device,
- &(const VkCommandPoolCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
- .queueFamilyIndex = gdk_vulkan_context_get_queue_family_index
(self->vulkan),
- .flags = 0
- },
- NULL,
- &self->command_pool);
-
- GSK_VK_CHECK (vkCreateFence, device,
- &(VkFenceCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
- .flags = 0
- },
- NULL,
- &self->command_pool_fence);
self->pipeline = gsk_vulkan_pipeline_new (self->vulkan, self->render_pass);
@@ -314,16 +296,6 @@ gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
g_clear_object (&self->pipeline);
- vkDestroyFence (device,
- self->command_pool_fence,
- NULL);
- self->command_pool_fence = VK_NULL_HANDLE;
-
- vkDestroyCommandPool (device,
- self->command_pool,
- NULL);
- self->command_pool = VK_NULL_HANDLE;
-
vkDestroyRenderPass (device,
self->render_pass,
NULL);
@@ -348,7 +320,7 @@ gsk_vulkan_renderer_render (GskRenderer *renderer,
gsk_profiler_timer_begin (profiler, self->profile_timers.cpu_time);
#endif
- render = gsk_vulkan_render_new (renderer, self->vulkan, self->command_pool);
+ render = gsk_vulkan_render_new (renderer, self->vulkan);
gsk_vulkan_render_add_node (render, root);
@@ -359,7 +331,7 @@ gsk_vulkan_renderer_render (GskRenderer *renderer,
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);
gsk_vulkan_render_free (render);
diff --git a/gsk/gskvulkanrenderprivate.h b/gsk/gskvulkanrenderprivate.h
index 55c454e..b4f5edd 100644
--- a/gsk/gskvulkanrenderprivate.h
+++ b/gsk/gskvulkanrenderprivate.h
@@ -21,8 +21,7 @@ struct _GskVulkanVertex
};
GskVulkanRender * gsk_vulkan_render_new (GskRenderer *renderer,
- GdkVulkanContext *context,
- VkCommandPool
command_pool);
+ GdkVulkanContext *context);
void gsk_vulkan_render_free (GskVulkanRender *self);
GskRenderer * gsk_vulkan_render_get_renderer (GskVulkanRender *self);
@@ -42,8 +41,7 @@ void gsk_vulkan_render_draw (GskVulk
VkDescriptorSet
descriptor_set,
VkSampler sampler);
-void gsk_vulkan_render_submit (GskVulkanRender *self,
- VkFence fence);
+void gsk_vulkan_render_submit (GskVulkanRender *self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]