mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
vulkan: Only use a single pipeline layout
There's no need to use 3 different ones when they are compatible.
This commit is contained in:
parent
ea9f0a3372
commit
52eefdb7d9
@ -16,7 +16,6 @@ struct _GskVulkanPipelinePrivate
|
||||
GdkVulkanContext *context;
|
||||
|
||||
VkPipeline pipeline;
|
||||
VkPipelineLayout layout;
|
||||
|
||||
GskVulkanShader *vertex_shader;
|
||||
GskVulkanShader *fragment_shader;
|
||||
@ -54,11 +53,11 @@ gsk_vulkan_pipeline_init (GskVulkanPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
GskVulkanPipelinePrivate *priv;
|
||||
GskVulkanPipeline *self;
|
||||
@ -76,7 +75,6 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
device = gdk_vulkan_context_get_device (context);
|
||||
|
||||
priv->context = context;
|
||||
priv->layout = layout;
|
||||
|
||||
priv->vertex_shader = gsk_vulkan_shader_new_from_resource (context, GSK_VULKAN_SHADER_VERTEX, shader_name, NULL);
|
||||
priv->fragment_shader = gsk_vulkan_shader_new_from_resource (context, GSK_VULKAN_SHADER_FRAGMENT, shader_name, NULL);
|
||||
@ -146,7 +144,7 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
VK_DYNAMIC_STATE_SCISSOR
|
||||
},
|
||||
},
|
||||
.layout = priv->layout,
|
||||
.layout = layout,
|
||||
.renderPass = render_pass,
|
||||
.subpass = 0,
|
||||
.basePipelineHandle = VK_NULL_HANDLE,
|
||||
@ -166,10 +164,3 @@ gsk_vulkan_pipeline_get_pipeline (GskVulkanPipeline *self)
|
||||
return priv->pipeline;
|
||||
}
|
||||
|
||||
VkPipelineLayout
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self)
|
||||
{
|
||||
GskVulkanPipelinePrivate *priv = gsk_vulkan_pipeline_get_instance_private (self);
|
||||
|
||||
return priv->layout;
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ GskVulkanPipeline * gsk_vulkan_pipeline_new (GType
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
VkPipeline gsk_vulkan_pipeline_get_pipeline (GskVulkanPipeline *self);
|
||||
VkPipelineLayout gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -40,7 +40,7 @@ struct _GskVulkanRender
|
||||
VkFence fence;
|
||||
VkRenderPass render_pass;
|
||||
VkDescriptorSetLayout descriptor_set_layout;
|
||||
VkPipelineLayout pipeline_layout[3]; /* indexed by number of textures */
|
||||
VkPipelineLayout pipeline_layout;
|
||||
GskVulkanUploader *uploader;
|
||||
|
||||
GHashTable *descriptor_set_indexes;
|
||||
@ -203,25 +203,19 @@ gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
NULL,
|
||||
&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
|
||||
};
|
||||
|
||||
GSK_VK_CHECK (vkCreatePipelineLayout, device,
|
||||
&(VkPipelineLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
.setLayoutCount = i,
|
||||
.pSetLayouts = layouts,
|
||||
.pushConstantRangeCount = gsk_vulkan_push_constants_get_range_count (),
|
||||
.pPushConstantRanges = gsk_vulkan_push_constants_get_ranges ()
|
||||
GSK_VK_CHECK (vkCreatePipelineLayout, device,
|
||||
&(VkPipelineLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
.setLayoutCount = 2,
|
||||
.pSetLayouts = (VkDescriptorSetLayout[2]) {
|
||||
self->descriptor_set_layout,
|
||||
self->descriptor_set_layout
|
||||
},
|
||||
NULL,
|
||||
&self->pipeline_layout[i]);
|
||||
}
|
||||
.pushConstantRangeCount = gsk_vulkan_push_constants_get_range_count (),
|
||||
.pPushConstantRanges = gsk_vulkan_push_constants_get_ranges ()
|
||||
},
|
||||
NULL,
|
||||
&self->pipeline_layout);
|
||||
|
||||
GSK_VK_CHECK (vkCreateSampler, device,
|
||||
&(VkSamplerCreateInfo) {
|
||||
@ -423,7 +417,7 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
|
||||
|
||||
if (self->pipelines[type] == NULL)
|
||||
self->pipelines[type] = pipeline_info[type].create_func (self->vulkan,
|
||||
self->pipeline_layout[pipeline_info[type].num_textures],
|
||||
self->pipeline_layout,
|
||||
pipeline_info[type].name,
|
||||
self->render_pass);
|
||||
|
||||
@ -612,7 +606,7 @@ gsk_vulkan_render_draw (GskVulkanRender *self)
|
||||
|
||||
command_buffer = gsk_vulkan_command_pool_get_buffer (self->command_pool);
|
||||
|
||||
gsk_vulkan_render_pass_draw (pass, self, 3, self->pipeline_layout, command_buffer);
|
||||
gsk_vulkan_render_pass_draw (pass, self, self->pipeline_layout, command_buffer);
|
||||
|
||||
gsk_vulkan_command_pool_submit_buffer (self->command_pool,
|
||||
command_buffer,
|
||||
@ -718,10 +712,9 @@ gsk_vulkan_render_free (GskVulkanRender *self)
|
||||
|
||||
g_clear_pointer (&self->uploader, gsk_vulkan_uploader_free);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
vkDestroyPipelineLayout (device,
|
||||
self->pipeline_layout[i],
|
||||
NULL);
|
||||
vkDestroyPipelineLayout (device,
|
||||
self->pipeline_layout,
|
||||
NULL);
|
||||
|
||||
vkDestroyRenderPass (device,
|
||||
self->render_pass,
|
||||
|
@ -569,9 +569,11 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self,
|
||||
gsk_vulkan_clip_scale (&new_state.clip, &state->clip, scale_x, scale_y);
|
||||
new_state.offset.x = (state->offset.x + dx) / scale_x;
|
||||
new_state.offset.y = (state->offset.y + dy) / scale_y;
|
||||
graphene_vec2_init (&new_state.scale, scale_x, scale_y);
|
||||
graphene_vec2_init (&new_state.scale, fabs (scale_x), fabs (scale_y));
|
||||
graphene_vec2_multiply (&new_state.scale, &state->scale, &new_state.scale);
|
||||
new_state.modelview = gsk_transform_ref (state->modelview);
|
||||
new_state.modelview = gsk_transform_scale (gsk_transform_ref (state->modelview),
|
||||
scale_x / fabs (scale_x),
|
||||
scale_y / fabs (scale_y));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2028,8 +2030,7 @@ gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulkanRenderPass *self,
|
||||
static void
|
||||
gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
||||
GskVulkanRender *render,
|
||||
guint layout_count,
|
||||
VkPipelineLayout *pipeline_layout,
|
||||
VkPipelineLayout pipeline_layout,
|
||||
VkCommandBuffer command_buffer)
|
||||
{
|
||||
GskVulkanPipeline *current_pipeline = NULL;
|
||||
@ -2072,7 +2073,7 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
||||
|
||||
vkCmdBindDescriptorSets (command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
|
||||
pipeline_layout,
|
||||
0,
|
||||
1,
|
||||
(VkDescriptorSet[1]) {
|
||||
@ -2105,7 +2106,7 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
||||
|
||||
vkCmdBindDescriptorSets (command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
|
||||
pipeline_layout,
|
||||
0,
|
||||
1,
|
||||
(VkDescriptorSet[1]) {
|
||||
@ -2138,7 +2139,7 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
||||
|
||||
vkCmdBindDescriptorSets (command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
|
||||
pipeline_layout,
|
||||
0,
|
||||
1,
|
||||
(VkDescriptorSet[1]) {
|
||||
@ -2174,7 +2175,7 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
||||
|
||||
vkCmdBindDescriptorSets (command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
|
||||
pipeline_layout,
|
||||
0,
|
||||
1,
|
||||
(VkDescriptorSet[1]) {
|
||||
@ -2209,7 +2210,7 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
||||
|
||||
vkCmdBindDescriptorSets (command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
|
||||
pipeline_layout,
|
||||
0,
|
||||
1,
|
||||
(VkDescriptorSet[1]) {
|
||||
@ -2317,13 +2318,11 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS:
|
||||
for (int j = 0; j < layout_count; j++)
|
||||
gsk_vulkan_push_constants_push (command_buffer,
|
||||
pipeline_layout[j],
|
||||
&op->constants.scale,
|
||||
&op->constants.mvp,
|
||||
&op->constants.clip);
|
||||
|
||||
gsk_vulkan_push_constants_push (command_buffer,
|
||||
pipeline_layout,
|
||||
&op->constants.scale,
|
||||
&op->constants.mvp,
|
||||
&op->constants.clip);
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_OP_CROSS_FADE:
|
||||
@ -2347,7 +2346,7 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
||||
|
||||
vkCmdBindDescriptorSets (command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
|
||||
pipeline_layout,
|
||||
0,
|
||||
2,
|
||||
(VkDescriptorSet[2]) {
|
||||
@ -2383,7 +2382,7 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
||||
|
||||
vkCmdBindDescriptorSets (command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
|
||||
pipeline_layout,
|
||||
0,
|
||||
2,
|
||||
(VkDescriptorSet[2]) {
|
||||
@ -2406,11 +2405,10 @@ gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
||||
GskVulkanRender *render,
|
||||
guint layout_count,
|
||||
VkPipelineLayout *pipeline_layout,
|
||||
VkCommandBuffer command_buffer)
|
||||
gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
||||
GskVulkanRender *render,
|
||||
VkPipelineLayout pipeline_layout,
|
||||
VkCommandBuffer command_buffer)
|
||||
{
|
||||
guint i;
|
||||
|
||||
@ -2456,7 +2454,7 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
||||
},
|
||||
VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
||||
gsk_vulkan_render_pass_draw_rect (self, render, layout_count, pipeline_layout, command_buffer);
|
||||
gsk_vulkan_render_pass_draw_rect (self, render, pipeline_layout, command_buffer);
|
||||
|
||||
vkCmdEndRenderPass (command_buffer);
|
||||
}
|
||||
|
@ -30,8 +30,7 @@ void gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulk
|
||||
GskVulkanRender *render);
|
||||
void gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
||||
GskVulkanRender *render,
|
||||
guint layout_count,
|
||||
VkPipelineLayout *pipeline_layout,
|
||||
VkPipelineLayout pipeline_layout,
|
||||
VkCommandBuffer command_buffer);
|
||||
gsize gsk_vulkan_render_pass_get_wait_semaphores (GskVulkanRenderPass *self,
|
||||
VkSemaphore **semaphores);
|
||||
|
Loading…
Reference in New Issue
Block a user