[gtk+] Allow different pipeline layouts
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Allow different pipeline layouts
- Date: Sat, 23 Sep 2017 02:18:13 +0000 (UTC)
commit 9b0ee4ac9952faf90b4d0fec81ef997b55838a9e
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 22 10:35:19 2017 -0400
Allow different pipeline layouts
These are differentiated by the number of textures; currently
we have shaders with 0 and 1 textures.
gsk/gskvulkanpipeline.c | 3 +-
gsk/gskvulkanpipelineprivate.h | 1 +
gsk/gskvulkanrender.c | 82 +++++++++++++++++++++----------------
gsk/gskvulkanrenderpass.c | 20 +++++----
gsk/gskvulkanrenderpassprivate.h | 3 +-
5 files changed, 62 insertions(+), 47 deletions(-)
---
diff --git a/gsk/gskvulkanpipeline.c b/gsk/gskvulkanpipeline.c
index ce41190..6a834c5 100644
--- a/gsk/gskvulkanpipeline.c
+++ b/gsk/gskvulkanpipeline.c
@@ -198,6 +198,7 @@ gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self)
GskVulkanPipelineLayout *
gsk_vulkan_pipeline_layout_new (GdkVulkanContext *context,
+ guint layout_count,
VkDescriptorSetLayout *descriptor_set_layout)
{
GskVulkanPipelineLayout *self;
@@ -212,7 +213,7 @@ gsk_vulkan_pipeline_layout_new (GdkVulkanContext *context,
GSK_VK_CHECK (vkCreatePipelineLayout, device,
&(VkPipelineLayoutCreateInfo) {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
- .setLayoutCount = 1,
+ .setLayoutCount = layout_count,
.pSetLayouts = descriptor_set_layout,
.pushConstantRangeCount =
gst_vulkan_push_constants_get_range_count (),
.pPushConstantRanges = gst_vulkan_push_constants_get_ranges ()
diff --git a/gsk/gskvulkanpipelineprivate.h b/gsk/gskvulkanpipelineprivate.h
index 825fa15..648f04d 100644
--- a/gsk/gskvulkanpipelineprivate.h
+++ b/gsk/gskvulkanpipelineprivate.h
@@ -35,6 +35,7 @@ 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,
+ guint
layout_count,
VkDescriptorSetLayout
*descriptor_set_layout);
GskVulkanPipelineLayout * gsk_vulkan_pipeline_layout_ref (GskVulkanPipelineLayout
*self);
void gsk_vulkan_pipeline_layout_unref (GskVulkanPipelineLayout
*self);
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c
index 500eff6..5a811cf 100644
--- a/gsk/gskvulkanrender.c
+++ b/gsk/gskvulkanrender.c
@@ -41,14 +41,14 @@ struct _GskVulkanRender
VkFence fence;
VkRenderPass render_pass;
VkDescriptorSetLayout descriptor_set_layout;
- GskVulkanPipelineLayout *layout;
+ GskVulkanPipelineLayout *layout[3]; /* indexed by number of textures */
GskVulkanUploader *uploader;
GskVulkanBuffer *vertex_buffer;
GHashTable *descriptor_set_indexes;
VkDescriptorPool descriptor_pool;
uint32_t descriptor_pool_maxsets;
- VkDescriptorSet *descriptor_sets;
+ VkDescriptorSet *descriptor_sets;
gsize n_descriptor_sets;
GskVulkanPipeline *pipelines[GSK_VULKAN_N_PIPELINES];
@@ -194,7 +194,15 @@ gsk_vulkan_render_new (GskRenderer *renderer,
&self->descriptor_set_layout);
- self->layout = gsk_vulkan_pipeline_layout_new (self->vulkan, &self->descriptor_set_layout);
+ for (guint i = 0; i < 3; i++)
+ {
+ VkDescriptorSetLayout layouts[3] = {
+ self->descriptor_set_layout,
+ self->descriptor_set_layout,
+ self->descriptor_set_layout
+ };
+ self->layout[i] = gsk_vulkan_pipeline_layout_new (self->vulkan, i, layouts);
+ }
self->uploader = gsk_vulkan_uploader_new (self->vulkan, self->command_pool);
@@ -336,45 +344,46 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
{
static const struct {
const char *name;
+ guint num_textures;
GskVulkanPipeline * (* create_func) (GskVulkanPipelineLayout *layout, const char *name, VkRenderPass
render_pass);
} pipeline_info[GSK_VULKAN_N_PIPELINES] = {
- { "blend", gsk_vulkan_blend_pipeline_new },
- { "blend-clip", gsk_vulkan_blend_pipeline_new },
- { "blend-clip-rounded", gsk_vulkan_blend_pipeline_new },
- { "color", gsk_vulkan_color_pipeline_new },
- { "color-clip", gsk_vulkan_color_pipeline_new },
- { "color-clip-rounded", gsk_vulkan_color_pipeline_new },
- { "linear", gsk_vulkan_linear_gradient_pipeline_new },
- { "linear-clip", gsk_vulkan_linear_gradient_pipeline_new },
- { "linear-clip-rounded", gsk_vulkan_linear_gradient_pipeline_new },
- { "color-matrix", gsk_vulkan_effect_pipeline_new },
- { "color-matrix-clip", gsk_vulkan_effect_pipeline_new },
- { "color-matrix-clip-rounded", gsk_vulkan_effect_pipeline_new },
- { "border", gsk_vulkan_border_pipeline_new },
- { "border-clip", gsk_vulkan_border_pipeline_new },
- { "border-clip-rounded", gsk_vulkan_border_pipeline_new },
- { "inset-shadow", gsk_vulkan_box_shadow_pipeline_new },
- { "inset-shadow-clip", gsk_vulkan_box_shadow_pipeline_new },
- { "inset-shadow-clip-rounded", gsk_vulkan_box_shadow_pipeline_new },
- { "outset-shadow", gsk_vulkan_box_shadow_pipeline_new },
- { "outset-shadow-clip", gsk_vulkan_box_shadow_pipeline_new },
- { "outset-shadow-clip-rounded", gsk_vulkan_box_shadow_pipeline_new },
- { "blur", gsk_vulkan_blur_pipeline_new },
- { "blur-clip", gsk_vulkan_blur_pipeline_new },
- { "blur-clip-rounded", gsk_vulkan_blur_pipeline_new },
- { "mask", gsk_vulkan_text_pipeline_new },
- { "mask-clip", gsk_vulkan_text_pipeline_new },
- { "mask-clip-rounded", gsk_vulkan_text_pipeline_new },
- { "blend", gsk_vulkan_color_text_pipeline_new },
- { "blend-clip", gsk_vulkan_color_text_pipeline_new },
- { "blend-clip-rounded", gsk_vulkan_color_text_pipeline_new },
+ { "blend", 1, gsk_vulkan_blend_pipeline_new },
+ { "blend-clip", 1, gsk_vulkan_blend_pipeline_new },
+ { "blend-clip-rounded", 1, gsk_vulkan_blend_pipeline_new },
+ { "color", 0, gsk_vulkan_color_pipeline_new },
+ { "color-clip", 0, gsk_vulkan_color_pipeline_new },
+ { "color-clip-rounded", 0, gsk_vulkan_color_pipeline_new },
+ { "linear", 0, gsk_vulkan_linear_gradient_pipeline_new },
+ { "linear-clip", 0, gsk_vulkan_linear_gradient_pipeline_new },
+ { "linear-clip-rounded", 0, gsk_vulkan_linear_gradient_pipeline_new },
+ { "color-matrix", 1, gsk_vulkan_effect_pipeline_new },
+ { "color-matrix-clip", 1, gsk_vulkan_effect_pipeline_new },
+ { "color-matrix-clip-rounded", 1, gsk_vulkan_effect_pipeline_new },
+ { "border", 0, gsk_vulkan_border_pipeline_new },
+ { "border-clip", 0, gsk_vulkan_border_pipeline_new },
+ { "border-clip-rounded", 0, gsk_vulkan_border_pipeline_new },
+ { "inset-shadow", 0, gsk_vulkan_box_shadow_pipeline_new },
+ { "inset-shadow-clip", 0, gsk_vulkan_box_shadow_pipeline_new },
+ { "inset-shadow-clip-rounded", 0, gsk_vulkan_box_shadow_pipeline_new },
+ { "outset-shadow", 0, gsk_vulkan_box_shadow_pipeline_new },
+ { "outset-shadow-clip", 0, gsk_vulkan_box_shadow_pipeline_new },
+ { "outset-shadow-clip-rounded", 0, gsk_vulkan_box_shadow_pipeline_new },
+ { "blur", 1, gsk_vulkan_blur_pipeline_new },
+ { "blur-clip", 1, gsk_vulkan_blur_pipeline_new },
+ { "blur-clip-rounded", 1, gsk_vulkan_blur_pipeline_new },
+ { "mask", 1, gsk_vulkan_text_pipeline_new },
+ { "mask-clip", 1, gsk_vulkan_text_pipeline_new },
+ { "mask-clip-rounded", 1, gsk_vulkan_text_pipeline_new },
+ { "blend", 1, gsk_vulkan_color_text_pipeline_new },
+ { "blend-clip", 1, gsk_vulkan_color_text_pipeline_new },
+ { "blend-clip-rounded", 1, gsk_vulkan_color_text_pipeline_new },
};
g_return_val_if_fail (type < GSK_VULKAN_N_PIPELINES, NULL);
if (self->pipelines[type] == NULL)
{
- self->pipelines[type] = pipeline_info[type].create_func (self->layout,
+ self->pipelines[type] = pipeline_info[type].create_func
(self->layout[pipeline_info[type].num_textures],
pipeline_info[type].name,
self->render_pass);
}
@@ -561,7 +570,7 @@ gsk_vulkan_render_draw (GskVulkanRender *self,
for (l = self->render_passes; l; l = l->next)
{
- gsk_vulkan_render_pass_draw (l->data, self, self->vertex_buffer, self->layout, command_buffer);
+ gsk_vulkan_render_pass_draw (l->data, self, self->vertex_buffer, 3, self->layout, command_buffer);
}
vkCmdEndRenderPass (command_buffer);
@@ -654,7 +663,8 @@ gsk_vulkan_render_free (GskVulkanRender *self)
g_clear_pointer (&self->uploader, gsk_vulkan_uploader_free);
- g_clear_pointer (&self->layout, gsk_vulkan_pipeline_layout_unref);
+ for (i = 0; i < 3; i++)
+ g_clear_pointer (&self->layout[i], gsk_vulkan_pipeline_layout_unref);
vkDestroyRenderPass (device,
self->render_pass,
diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c
index f3b3dea..245c753 100644
--- a/gsk/gskvulkanrenderpass.c
+++ b/gsk/gskvulkanrenderpass.c
@@ -1034,7 +1034,8 @@ void
gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
GskVulkanRender *render,
GskVulkanBuffer *vertex_buffer,
- GskVulkanPipelineLayout *layout,
+ guint layout_count,
+ GskVulkanPipelineLayout **layout,
VkCommandBuffer command_buffer)
{
GskVulkanPipeline *current_pipeline = NULL;
@@ -1072,7 +1073,7 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_layout_get_pipeline_layout (layout),
+ gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
0,
1,
(VkDescriptorSet[1]) {
@@ -1105,7 +1106,7 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_layout_get_pipeline_layout (layout),
+ gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
0,
1,
(VkDescriptorSet[1]) {
@@ -1138,7 +1139,7 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_layout_get_pipeline_layout (layout),
+ gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
0,
1,
(VkDescriptorSet[1]) {
@@ -1172,7 +1173,7 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_layout_get_pipeline_layout (layout),
+ gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
0,
1,
(VkDescriptorSet[1]) {
@@ -1205,7 +1206,7 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_layout_get_pipeline_layout (layout),
+ gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
0,
1,
(VkDescriptorSet[1]) {
@@ -1313,9 +1314,10 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
break;
case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS:
- gsk_vulkan_push_constants_push (&op->constants.constants,
- command_buffer,
- gsk_vulkan_pipeline_layout_get_pipeline_layout (layout));
+ for (int i = 0; i < layout_count; i++)
+ gsk_vulkan_push_constants_push (&op->constants.constants,
+ command_buffer,
+ gsk_vulkan_pipeline_layout_get_pipeline_layout (layout[i]));
break;
default:
diff --git a/gsk/gskvulkanrenderpassprivate.h b/gsk/gskvulkanrenderpassprivate.h
index 48a2461..d381899 100644
--- a/gsk/gskvulkanrenderpassprivate.h
+++ b/gsk/gskvulkanrenderpassprivate.h
@@ -36,7 +36,8 @@ void gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulk
void gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
GskVulkanRender *render,
GskVulkanBuffer
*vertex_buffer,
- GskVulkanPipelineLayout *layout,
+ guint
layout_count,
+ GskVulkanPipelineLayout **layout,
VkCommandBuffer
command_buffer);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]