[gtk+] vulkan: Move descriptor set layout to the render object
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] vulkan: Move descriptor set layout to the render object
- Date: Sat, 23 Sep 2017 02:18:03 +0000 (UTC)
commit 4c7a51f88ad8ca2d6a0f5e9aa82d7306e1f03c72
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 22 10:02:27 2017 -0400
vulkan: Move descriptor set layout to the render object
We want to maintain a single descriptor set layout while introducing
multiple pipeline layouts, so split this off.
gsk/gskvulkanpipeline.c | 33 +++------------------------------
gsk/gskvulkanpipelineprivate.h | 6 ++----
gsk/gskvulkanrender.c | 28 ++++++++++++++++++++++++----
3 files changed, 29 insertions(+), 38 deletions(-)
---
diff --git a/gsk/gskvulkanpipeline.c b/gsk/gskvulkanpipeline.c
index 71ea27e..5863d20 100644
--- a/gsk/gskvulkanpipeline.c
+++ b/gsk/gskvulkanpipeline.c
@@ -15,7 +15,6 @@ struct _GskVulkanPipelineLayout
GdkVulkanContext *vulkan;
VkPipelineLayout pipeline_layout;
- VkDescriptorSetLayout descriptor_set_layout;
};
struct _GskVulkanPipelinePrivate
@@ -190,7 +189,8 @@ gsk_vulkan_pipeline_get_pipeline (GskVulkanPipeline *self)
/*** GskVulkanPipelineLayout ***/
GskVulkanPipelineLayout *
-gsk_vulkan_pipeline_layout_new (GdkVulkanContext *context)
+gsk_vulkan_pipeline_layout_new (GdkVulkanContext *context,
+ VkDescriptorSetLayout *descriptor_set_layout)
{
GskVulkanPipelineLayout *self;
VkDevice device;
@@ -201,27 +201,11 @@ gsk_vulkan_pipeline_layout_new (GdkVulkanContext *context)
device = gdk_vulkan_context_get_device (context);
- GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
- &(VkDescriptorSetLayoutCreateInfo) {
- .sType =
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
- .bindingCount = 1,
- .pBindings = (VkDescriptorSetLayoutBinding[1]) {
- {
- .binding = 0,
- .descriptorType =
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
- .descriptorCount = 1,
- .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
- }
- }
- },
- NULL,
- &self->descriptor_set_layout);
-
GSK_VK_CHECK (vkCreatePipelineLayout, device,
&(VkPipelineLayoutCreateInfo) {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.setLayoutCount = 1,
- .pSetLayouts = &self->descriptor_set_layout,
+ .pSetLayouts = descriptor_set_layout,
.pushConstantRangeCount =
gst_vulkan_push_constants_get_range_count (),
.pPushConstantRanges = gst_vulkan_push_constants_get_ranges ()
},
@@ -255,10 +239,6 @@ gsk_vulkan_pipeline_layout_unref (GskVulkanPipelineLayout *self)
self->pipeline_layout,
NULL);
- vkDestroyDescriptorSetLayout (device,
- self->descriptor_set_layout,
- NULL);
-
g_slice_free (GskVulkanPipelineLayout, self);
}
@@ -268,10 +248,3 @@ gsk_vulkan_pipeline_layout_get_pipeline_layout (GskVulkanPipelineLayout *self)
{
return self->pipeline_layout;
}
-
-VkDescriptorSetLayout
-gsk_vulkan_pipeline_layout_get_descriptor_set_layout (GskVulkanPipelineLayout *self)
-{
- return self->descriptor_set_layout;
-}
-
diff --git a/gsk/gskvulkanpipelineprivate.h b/gsk/gskvulkanpipelineprivate.h
index 504306a..62550b2 100644
--- a/gsk/gskvulkanpipelineprivate.h
+++ b/gsk/gskvulkanpipelineprivate.h
@@ -34,15 +34,13 @@ gsk_vulkan_handle_result (VkResult res,
#define GSK_VK_CHECK(func, ...) gsk_vulkan_handle_result (func (__VA_ARGS__), G_STRINGIFY (func))
-GskVulkanPipelineLayout * gsk_vulkan_pipeline_layout_new (GdkVulkanContext
*context);
+GskVulkanPipelineLayout * gsk_vulkan_pipeline_layout_new (GdkVulkanContext
*context,
+ VkDescriptorSetLayout
*descriptor_set_layout);
GskVulkanPipelineLayout * gsk_vulkan_pipeline_layout_ref (GskVulkanPipelineLayout
*self);
void gsk_vulkan_pipeline_layout_unref (GskVulkanPipelineLayout
*self);
VkPipelineLayout gsk_vulkan_pipeline_layout_get_pipeline_layout
(GskVulkanPipelineLayout
*self);
-VkDescriptorSetLayout gsk_vulkan_pipeline_layout_get_descriptor_set_layout
- (GskVulkanPipelineLayout
*self);
-
GskVulkanPipeline * gsk_vulkan_pipeline_new (GType
pipeline_type,
GskVulkanPipelineLayout
*layout,
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c
index 0c96310..500eff6 100644
--- a/gsk/gskvulkanrender.c
+++ b/gsk/gskvulkanrender.c
@@ -40,6 +40,7 @@ struct _GskVulkanRender
GskVulkanCommandPool *command_pool;
VkFence fence;
VkRenderPass render_pass;
+ VkDescriptorSetLayout descriptor_set_layout;
GskVulkanPipelineLayout *layout;
GskVulkanUploader *uploader;
GskVulkanBuffer *vertex_buffer;
@@ -176,7 +177,24 @@ gsk_vulkan_render_new (GskRenderer *renderer,
NULL,
&self->render_pass);
- self->layout = gsk_vulkan_pipeline_layout_new (self->vulkan);
+ GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
+ &(VkDescriptorSetLayoutCreateInfo) {
+ .sType =
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
+ .bindingCount = 1,
+ .pBindings = (VkDescriptorSetLayoutBinding[1]) {
+ {
+ .binding = 0,
+ .descriptorType =
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+ .descriptorCount = 1,
+ .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
+ }
+ }
+ },
+ NULL,
+ &self->descriptor_set_layout);
+
+
+ self->layout = gsk_vulkan_pipeline_layout_new (self->vulkan, &self->descriptor_set_layout);
self->uploader = gsk_vulkan_uploader_new (self->vulkan, self->command_pool);
@@ -447,9 +465,7 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self,
VkDescriptorSetLayout *layouts = g_newa (VkDescriptorSetLayout, needed_sets);
for (i = 0; i < needed_sets; i++)
- {
- layouts[i] = gsk_vulkan_pipeline_layout_get_descriptor_set_layout (self->layout);
- }
+ layouts[i] = self->descriptor_set_layout;
GSK_VK_CHECK (vkAllocateDescriptorSets, device,
&(VkDescriptorSetAllocateInfo) {
@@ -650,6 +666,10 @@ gsk_vulkan_render_free (GskVulkanRender *self)
g_free (self->descriptor_sets);
g_hash_table_unref (self->descriptor_set_indexes);
+ vkDestroyDescriptorSetLayout (device,
+ self->descriptor_set_layout,
+ NULL);
+
vkDestroyFence (device,
self->fence,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]