There's no need to use 3 different ones when they are compatible.
GdkVulkanContext *context;
VkPipeline pipeline;
- VkPipelineLayout layout;
GskVulkanShader *vertex_shader;
GskVulkanShader *fragment_shader;
}
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;
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);
VK_DYNAMIC_STATE_SCISSOR
},
},
- .layout = priv->layout,
+ .layout = layout,
.renderPass = render_pass,
.subpass = 0,
.basePipelineHandle = VK_NULL_HANDLE,
return priv->pipeline;
}
-VkPipelineLayout
-gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self)
-{
- GskVulkanPipelinePrivate *priv = gsk_vulkan_pipeline_get_instance_private (self);
-
- return priv->layout;
-}
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
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;
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) {
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);
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,
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,
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;
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;
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
+ pipeline_layout,
0,
1,
(VkDescriptorSet[1]) {
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
+ pipeline_layout,
0,
1,
(VkDescriptorSet[1]) {
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
+ pipeline_layout,
0,
1,
(VkDescriptorSet[1]) {
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
+ pipeline_layout,
0,
1,
(VkDescriptorSet[1]) {
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
+ pipeline_layout,
0,
1,
(VkDescriptorSet[1]) {
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:
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
+ pipeline_layout,
0,
2,
(VkDescriptorSet[2]) {
vkCmdBindDescriptorSets (command_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
- gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
+ pipeline_layout,
0,
2,
(VkDescriptorSet[2]) {
}
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;
},
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);
}
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);