diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-09-22 10:35:19 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-09-22 22:16:09 -0400 |
commit | 9b0ee4ac9952faf90b4d0fec81ef997b55838a9e (patch) | |
tree | 96791a92298d7adf969b3bb19055d6180d5bd212 /gsk | |
parent | 5ff6481310c2fe5249b2d1675e8022a1d3cd297f (diff) | |
download | gtk+-9b0ee4ac9952faf90b4d0fec81ef997b55838a9e.tar.gz |
Allow different pipeline layouts
These are differentiated by the number of textures; currently
we have shaders with 0 and 1 textures.
Diffstat (limited to 'gsk')
-rw-r--r-- | gsk/gskvulkanpipeline.c | 3 | ||||
-rw-r--r-- | gsk/gskvulkanpipelineprivate.h | 1 | ||||
-rw-r--r-- | gsk/gskvulkanrender.c | 82 | ||||
-rw-r--r-- | gsk/gskvulkanrenderpass.c | 20 | ||||
-rw-r--r-- | gsk/gskvulkanrenderpassprivate.h | 3 |
5 files changed, 62 insertions, 47 deletions
diff --git a/gsk/gskvulkanpipeline.c b/gsk/gskvulkanpipeline.c index ce41190f67..6a834c5d9e 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 825fa15ecd..648f04ddf1 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 500eff6db1..5a811cf142 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 f3b3dea25d..245c753cae 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 48a2461246..d38189966c 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 |