mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
vulkan: Don't create unnecessary render passes
Pass the render pass to the pipeline creation function instead of creating an extra one just for pipeline creation.
This commit is contained in:
parent
35b09c727a
commit
746d0d8fde
@ -52,7 +52,6 @@ struct _GskVulkanRender
|
||||
|
||||
GskVulkanCommandPool *command_pool;
|
||||
VkFence fence;
|
||||
VkRenderPass render_pass;
|
||||
VkDescriptorSetLayout descriptor_set_layout;
|
||||
VkPipelineLayout pipeline_layout;
|
||||
GskVulkanUploader *uploader;
|
||||
@ -169,46 +168,6 @@ gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
NULL,
|
||||
&self->descriptor_pool);
|
||||
|
||||
GSK_VK_CHECK (vkCreateRenderPass, gdk_vulkan_context_get_device (self->vulkan),
|
||||
&(VkRenderPassCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
|
||||
.attachmentCount = 1,
|
||||
.pAttachments = (VkAttachmentDescription[]) {
|
||||
{
|
||||
.format = gdk_vulkan_context_get_image_format (self->vulkan),
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
||||
}
|
||||
},
|
||||
.subpassCount = 1,
|
||||
.pSubpasses = (VkSubpassDescription []) {
|
||||
{
|
||||
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
.inputAttachmentCount = 0,
|
||||
.colorAttachmentCount = 1,
|
||||
.pColorAttachments = (VkAttachmentReference []) {
|
||||
{
|
||||
.attachment = 0,
|
||||
.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
||||
}
|
||||
},
|
||||
.pResolveAttachments = (VkAttachmentReference []) {
|
||||
{
|
||||
.attachment = VK_ATTACHMENT_UNUSED,
|
||||
.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
||||
}
|
||||
},
|
||||
.pDepthStencilAttachment = NULL,
|
||||
}
|
||||
},
|
||||
.dependencyCount = 0
|
||||
},
|
||||
NULL,
|
||||
&self->render_pass);
|
||||
|
||||
GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
|
||||
&(VkDescriptorSetLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
@ -387,7 +346,8 @@ gsk_vulkan_render_upload (GskVulkanRender *self)
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
|
||||
GskVulkanPipelineType type)
|
||||
GskVulkanPipelineType type,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
static const struct {
|
||||
const char *name;
|
||||
@ -438,7 +398,7 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
|
||||
self->pipelines[type] = pipeline_info[type].create_func (self->vulkan,
|
||||
self->pipeline_layout,
|
||||
pipeline_info[type].name,
|
||||
self->render_pass);
|
||||
render_pass);
|
||||
|
||||
return self->pipelines[type];
|
||||
}
|
||||
@ -774,10 +734,6 @@ gsk_vulkan_render_free (GskVulkanRender *self)
|
||||
self->pipeline_layout,
|
||||
NULL);
|
||||
|
||||
vkDestroyRenderPass (device,
|
||||
self->render_pass,
|
||||
NULL);
|
||||
|
||||
vkDestroyDescriptorPool (device,
|
||||
self->descriptor_pool,
|
||||
NULL);
|
||||
|
@ -313,6 +313,16 @@ gsk_vulkan_render_pass_append_push_constants (GskVulkanRenderPass *self,
|
||||
return FALSE; \
|
||||
}G_STMT_END
|
||||
|
||||
static GskVulkanPipeline *
|
||||
gsk_vulkan_render_pass_get_pipeline (GskVulkanRenderPass *self,
|
||||
GskVulkanRender *render,
|
||||
GskVulkanPipelineType pipeline_type)
|
||||
{
|
||||
return gsk_vulkan_render_get_pipeline (render,
|
||||
pipeline_type,
|
||||
self->render_pass);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
|
||||
GskVulkanRender *render,
|
||||
@ -349,7 +359,7 @@ gsk_vulkan_render_pass_add_fallback_node (GskVulkanRenderPass *self,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, GSK_VULKAN_PIPELINE_TEXTURE);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, GSK_VULKAN_PIPELINE_TEXTURE);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -413,7 +423,7 @@ gsk_vulkan_render_pass_add_color_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -439,7 +449,7 @@ gsk_vulkan_render_pass_add_linear_gradient_node (GskVulkanRenderPass *self
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_LINEAR_GRADIENT_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -465,7 +475,7 @@ gsk_vulkan_render_pass_add_border_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_BORDER_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -491,7 +501,7 @@ gsk_vulkan_render_pass_add_texture_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -517,7 +527,7 @@ gsk_vulkan_render_pass_add_texture_scale_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -545,7 +555,7 @@ gsk_vulkan_render_pass_add_inset_shadow_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_INSET_SHADOW_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -573,7 +583,7 @@ gsk_vulkan_render_pass_add_outset_shadow_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_OUTSET_SHADOW_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -753,7 +763,7 @@ gsk_vulkan_render_pass_add_opacity_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -779,7 +789,7 @@ gsk_vulkan_render_pass_add_color_matrix_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -949,7 +959,7 @@ gsk_vulkan_render_pass_add_repeat_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -975,7 +985,7 @@ gsk_vulkan_render_pass_add_blend_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_BLEND_MODE_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -1001,7 +1011,7 @@ gsk_vulkan_render_pass_add_cross_fade_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_CROSS_FADE_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
@ -1052,7 +1062,7 @@ gsk_vulkan_render_pass_add_text_node (GskVulkanRenderPass *self,
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_TEXT_CLIP_ROUNDED;
|
||||
op.type = GSK_VULKAN_OP_TEXT;
|
||||
}
|
||||
op.text.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.text.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
|
||||
op.text.start_glyph = 0;
|
||||
op.text.texture_index = G_MAXUINT;
|
||||
@ -1116,7 +1126,7 @@ gsk_vulkan_render_pass_add_blur_node (GskVulkanRenderPass *self,
|
||||
else
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_BLUR_CLIP_ROUNDED;
|
||||
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
op.render.pipeline = gsk_vulkan_render_pass_get_pipeline (self, render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
return TRUE;
|
||||
|
@ -81,7 +81,8 @@ void gsk_vulkan_render_add_render_pass (GskVulk
|
||||
void gsk_vulkan_render_upload (GskVulkanRender *self);
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
|
||||
GskVulkanPipelineType pipeline_type);
|
||||
GskVulkanPipelineType pipeline_type,
|
||||
VkRenderPass render_pass);
|
||||
gsize gsk_vulkan_render_get_sampler_descriptor (GskVulkanRender *self,
|
||||
GskVulkanRenderSampler render_sampler);
|
||||
gsize gsk_vulkan_render_get_image_descriptor (GskVulkanRender *self,
|
||||
|
Loading…
Reference in New Issue
Block a user