Compare commits
7 Commits
frame-cloc
...
wip/matthi
Author | SHA1 | Date | |
---|---|---|---|
|
083167c3c1 | ||
|
1a7faa5e6b | ||
|
2a4070fa8a | ||
|
aede999309 | ||
|
4ccfe57dc1 | ||
|
5746309b63 | ||
|
4f4e0120ae |
@@ -76,11 +76,12 @@ gsk_vulkan_blend_pipeline_init (GskVulkanBlendPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_blend_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
gsk_vulkan_blend_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BLEND_PIPELINE, layout, shader_name, render_pass);
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BLEND_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
|
@@ -13,7 +13,8 @@ typedef struct _GskVulkanBlendPipelineLayout GskVulkanBlendPipelineLayout;
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanBlendPipeline, gsk_vulkan_blend_pipeline, GSK, VULKAN_BLEND_PIPELINE, GskVulkanPipeline)
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_blend_pipeline_new (GskVulkanPipelineLayout * layout,
|
||||
GskVulkanPipeline * gsk_vulkan_blend_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
|
@@ -83,11 +83,12 @@ gsk_vulkan_blur_pipeline_init (GskVulkanBlurPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_blur_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
gsk_vulkan_blur_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BLUR_PIPELINE, layout, shader_name, render_pass);
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BLUR_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
|
@@ -13,7 +13,8 @@ typedef struct _GskVulkanBlurPipelineLayout GskVulkanBlurPipelineLayout;
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanBlurPipeline, gsk_vulkan_blur_pipeline, GSK, VULKAN_BLUR_PIPELINE, GskVulkanPipeline)
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_blur_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
GskVulkanPipeline * gsk_vulkan_blur_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
|
@@ -115,11 +115,12 @@ gsk_vulkan_border_pipeline_init (GskVulkanBorderPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_border_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
gsk_vulkan_border_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BORDER_PIPELINE, layout, shader_name, render_pass);
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BORDER_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
|
@@ -14,7 +14,8 @@ typedef struct _GskVulkanBorderPipelineLayout GskVulkanBorderPipelineLayout;
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanBorderPipeline, gsk_vulkan_border_pipeline, GSK, VULKAN_BORDER_PIPELINE, GskVulkanPipeline)
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_border_pipeline_new (GskVulkanPipelineLayout * layout,
|
||||
GskVulkanPipeline * gsk_vulkan_border_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
|
@@ -111,11 +111,12 @@ gsk_vulkan_box_shadow_pipeline_init (GskVulkanBoxShadowPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_box_shadow_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
gsk_vulkan_box_shadow_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BOX_SHADOW_PIPELINE, layout, shader_name, render_pass);
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BOX_SHADOW_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
|
@@ -14,7 +14,8 @@ typedef struct _GskVulkanBoxShadowPipelineLayout GskVulkanBoxShadowPipelineLayou
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanBoxShadowPipeline, gsk_vulkan_box_shadow_pipeline, GSK, VULKAN_BOX_SHADOW_PIPELINE, GskVulkanPipeline)
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_box_shadow_pipeline_new (GskVulkanPipelineLayout * layout,
|
||||
GskVulkanPipeline * gsk_vulkan_box_shadow_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
|
@@ -133,7 +133,7 @@ gsk_vulkan_clip_transform (GskVulkanClip *dest,
|
||||
const graphene_matrix_t *transform,
|
||||
const graphene_rect_t *viewport)
|
||||
{
|
||||
switch (dest->type)
|
||||
switch (src->type)
|
||||
{
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
|
@@ -76,11 +76,12 @@ gsk_vulkan_color_pipeline_init (GskVulkanColorPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_color_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
gsk_vulkan_color_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_COLOR_PIPELINE, layout, shader_name, render_pass);
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_COLOR_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
|
@@ -13,7 +13,8 @@ typedef struct _GskVulkanColorPipelineLayout GskVulkanColorPipelineLayout;
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanColorPipeline, gsk_vulkan_color_pipeline, GSK, VULKAN_COLOR_PIPELINE, GskVulkanPipeline)
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_color_pipeline_new (GskVulkanPipelineLayout * layout,
|
||||
GskVulkanPipeline * gsk_vulkan_color_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
|
@@ -76,11 +76,12 @@ gsk_vulkan_color_text_pipeline_init (GskVulkanColorTextPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_color_text_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
gsk_vulkan_color_text_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new_full (GSK_TYPE_VULKAN_COLOR_TEXT_PIPELINE, layout, shader_name, render_pass,
|
||||
return gsk_vulkan_pipeline_new_full (GSK_TYPE_VULKAN_COLOR_TEXT_PIPELINE, context, layout, shader_name, render_pass,
|
||||
VK_BLEND_FACTOR_SRC_ALPHA, VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,8 @@ typedef struct _GskVulkanColorTextPipelineLayout GskVulkanColorTextPipelineLayou
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanColorTextPipeline, gsk_vulkan_color_text_pipeline, GSK, VULKAN_COLOR_TEXT_PIPELINE, GskVulkanPipeline)
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_color_text_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
GskVulkanPipeline * gsk_vulkan_color_text_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
|
130
gsk/gskvulkancrossfadepipeline.c
Normal file
130
gsk/gskvulkancrossfadepipeline.c
Normal file
@@ -0,0 +1,130 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gskvulkancrossfadepipelineprivate.h"
|
||||
|
||||
struct _GskVulkanCrossFadePipeline
|
||||
{
|
||||
GObject parent_instance;
|
||||
};
|
||||
|
||||
typedef struct _GskVulkanCrossFadeInstance GskVulkanCrossFadeInstance;
|
||||
|
||||
struct _GskVulkanCrossFadeInstance
|
||||
{
|
||||
float rect[4];
|
||||
float tex_rect[4];
|
||||
float progress;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskVulkanCrossFadePipeline, gsk_vulkan_cross_fade_pipeline, GSK_TYPE_VULKAN_PIPELINE)
|
||||
|
||||
static const VkPipelineVertexInputStateCreateInfo *
|
||||
gsk_vulkan_cross_fade_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
|
||||
{
|
||||
static const VkVertexInputBindingDescription vertexBindingDescriptions[] = {
|
||||
{
|
||||
.binding = 0,
|
||||
.stride = sizeof (GskVulkanCrossFadeInstance),
|
||||
.inputRate = VK_VERTEX_INPUT_RATE_INSTANCE
|
||||
}
|
||||
};
|
||||
static const VkVertexInputAttributeDescription vertexInputAttributeDescription[] = {
|
||||
{
|
||||
.location = 0,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = 0,
|
||||
},
|
||||
{
|
||||
.location = 1,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, tex_rect),
|
||||
},
|
||||
{
|
||||
.location = 2,
|
||||
.binding = 0,
|
||||
.format = VK_FORMAT_R32_SFLOAT,
|
||||
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, progress),
|
||||
}
|
||||
};
|
||||
static const VkPipelineVertexInputStateCreateInfo info = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||
.vertexBindingDescriptionCount = G_N_ELEMENTS (vertexBindingDescriptions),
|
||||
.pVertexBindingDescriptions = vertexBindingDescriptions,
|
||||
.vertexAttributeDescriptionCount = G_N_ELEMENTS (vertexInputAttributeDescription),
|
||||
.pVertexAttributeDescriptions = vertexInputAttributeDescription
|
||||
};
|
||||
|
||||
return &info;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_cross_fade_pipeline_finalize (GObject *gobject)
|
||||
{
|
||||
//GskVulkanCrossFadePipeline *self = GSK_VULKAN_BLUR_PIPELINE (gobject);
|
||||
|
||||
G_OBJECT_CLASS (gsk_vulkan_cross_fade_pipeline_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_cross_fade_pipeline_class_init (GskVulkanCrossFadePipelineClass *klass)
|
||||
{
|
||||
GskVulkanPipelineClass *pipeline_class = GSK_VULKAN_PIPELINE_CLASS (klass);
|
||||
|
||||
G_OBJECT_CLASS (klass)->finalize = gsk_vulkan_cross_fade_pipeline_finalize;
|
||||
|
||||
pipeline_class->get_input_state_create_info = gsk_vulkan_cross_fade_pipeline_get_input_state_create_info;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_cross_fade_pipeline_init (GskVulkanCrossFadePipeline *self)
|
||||
{
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_cross_fade_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_CROSS_FADE_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_cross_fade_pipeline_count_vertex_data (GskVulkanCrossFadePipeline *pipeline)
|
||||
{
|
||||
return sizeof (GskVulkanCrossFadeInstance);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_rect_t *rect,
|
||||
double progress)
|
||||
{
|
||||
GskVulkanCrossFadeInstance *instance = (GskVulkanCrossFadeInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->tex_rect[0] = 0.0;
|
||||
instance->tex_rect[1] = 0.0;
|
||||
instance->tex_rect[2] = 1.0;
|
||||
instance->tex_rect[3] = 1.0;
|
||||
instance->progress = progress;
|
||||
}
|
||||
|
||||
gsize
|
||||
gsk_vulkan_cross_fade_pipeline_draw (GskVulkanCrossFadePipeline *pipeline,
|
||||
VkCommandBuffer command_buffer,
|
||||
gsize offset,
|
||||
gsize n_commands)
|
||||
{
|
||||
vkCmdDraw (command_buffer,
|
||||
6, n_commands,
|
||||
0, offset);
|
||||
|
||||
return n_commands;
|
||||
}
|
33
gsk/gskvulkancrossfadepipelineprivate.h
Normal file
33
gsk/gskvulkancrossfadepipelineprivate.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef __GSK_VULKAN_CROSS_FADE_PIPELINE_PRIVATE_H__
|
||||
#define __GSK_VULKAN_CROSS_FADE_PIPELINE_PRIVATE_H__
|
||||
|
||||
#include <graphene.h>
|
||||
|
||||
#include "gskvulkanpipelineprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskVulkanCrossFadePipelineLayout GskVulkanCrossFadePipelineLayout;
|
||||
|
||||
#define GSK_TYPE_VULKAN_CROSS_FADE_PIPELINE (gsk_vulkan_cross_fade_pipeline_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanCrossFadePipeline, gsk_vulkan_cross_fade_pipeline, GSK, VULKAN_CROSS_FADE_PIPELINE, GskVulkanPipeline)
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_cross_fade_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_cross_fade_pipeline_count_vertex_data (GskVulkanCrossFadePipeline *pipeline);
|
||||
void gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_rect_t *rect,
|
||||
double progress);
|
||||
gsize gsk_vulkan_cross_fade_pipeline_draw (GskVulkanCrossFadePipeline *pipeline,
|
||||
VkCommandBuffer command_buffer,
|
||||
gsize offset,
|
||||
gsize n_commands);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_VULKAN_CROSS_FADE_PIPELINE_PRIVATE_H__ */
|
@@ -108,11 +108,12 @@ gsk_vulkan_effect_pipeline_init (GskVulkanEffectPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_effect_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
gsk_vulkan_effect_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_EFFECT_PIPELINE, layout, shader_name, render_pass);
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_EFFECT_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
|
@@ -13,7 +13,8 @@ typedef struct _GskVulkanEffectPipelineLayout GskVulkanEffectPipelineLayout;
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanEffectPipeline, gsk_vulkan_effect_pipeline, GSK, VULKAN_EFFECT_PIPELINE, GskVulkanPipeline)
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_effect_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
GskVulkanPipeline * gsk_vulkan_effect_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
|
@@ -159,11 +159,12 @@ gsk_vulkan_linear_gradient_pipeline_init (GskVulkanLinearGradientPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_linear_gradient_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
gsk_vulkan_linear_gradient_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_LINEAR_GRADIENT_PIPELINE, layout, shader_name, render_pass);
|
||||
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_LINEAR_GRADIENT_PIPELINE, context, layout, shader_name, render_pass);
|
||||
}
|
||||
|
||||
gsize
|
||||
|
@@ -16,7 +16,8 @@ typedef struct _GskVulkanLinearGradientPipelineLayout GskVulkanLinearGradientPip
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanLinearGradientPipeline, gsk_vulkan_linear_gradient_pipeline, GSK, VULKAN_LINEAR_GRADIENT_PIPELINE, GskVulkanPipeline)
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_linear_gradient_pipeline_new (GskVulkanPipelineLayout * layout,
|
||||
GskVulkanPipeline * gsk_vulkan_linear_gradient_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
|
@@ -9,22 +9,14 @@
|
||||
|
||||
typedef struct _GskVulkanPipelinePrivate GskVulkanPipelinePrivate;
|
||||
|
||||
struct _GskVulkanPipelineLayout
|
||||
{
|
||||
volatile gint ref_count;
|
||||
GdkVulkanContext *vulkan;
|
||||
|
||||
VkPipelineLayout pipeline_layout;
|
||||
VkDescriptorSetLayout descriptor_set_layout;
|
||||
};
|
||||
|
||||
struct _GskVulkanPipelinePrivate
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GskVulkanPipelineLayout *layout;
|
||||
GdkVulkanContext *context;
|
||||
|
||||
VkPipeline pipeline;
|
||||
VkPipelineLayout layout;
|
||||
|
||||
GskVulkanShader *vertex_shader;
|
||||
GskVulkanShader *fragment_shader;
|
||||
@@ -36,18 +28,17 @@ static void
|
||||
gsk_vulkan_pipeline_finalize (GObject *gobject)
|
||||
{
|
||||
GskVulkanPipelinePrivate *priv = gsk_vulkan_pipeline_get_instance_private (GSK_VULKAN_PIPELINE (gobject));
|
||||
VkDevice device;
|
||||
|
||||
VkDevice device = gdk_vulkan_context_get_device (priv->layout->vulkan);
|
||||
device = gdk_vulkan_context_get_device (priv->context);
|
||||
|
||||
vkDestroyPipeline (device,
|
||||
priv->pipeline,
|
||||
NULL);
|
||||
|
||||
|
||||
g_clear_pointer (&priv->fragment_shader, gsk_vulkan_shader_free);
|
||||
g_clear_pointer (&priv->vertex_shader, gsk_vulkan_shader_free);
|
||||
|
||||
g_clear_pointer (&priv->layout, gsk_vulkan_pipeline_layout_unref);
|
||||
|
||||
G_OBJECT_CLASS (gsk_vulkan_pipeline_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
@@ -64,18 +55,20 @@ gsk_vulkan_pipeline_init (GskVulkanPipeline *self)
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
GskVulkanPipelineLayout *layout,
|
||||
GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new_full (pipeline_type, layout, shader_name, render_pass,
|
||||
return gsk_vulkan_pipeline_new_full (pipeline_type, context, layout, shader_name, render_pass,
|
||||
VK_BLEND_FACTOR_ONE,
|
||||
VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_pipeline_new_full (GType pipeline_type,
|
||||
GskVulkanPipelineLayout *layout,
|
||||
GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass,
|
||||
VkBlendFactor srcBlendFactor,
|
||||
@@ -83,11 +76,10 @@ gsk_vulkan_pipeline_new_full (GType pipeline_type,
|
||||
{
|
||||
GskVulkanPipelinePrivate *priv;
|
||||
GskVulkanPipeline *self;
|
||||
|
||||
VkDevice device;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (pipeline_type, GSK_TYPE_VULKAN_PIPELINE), NULL);
|
||||
g_return_val_if_fail (layout != NULL, NULL);
|
||||
g_return_val_if_fail (layout != VK_NULL_HANDLE, NULL);
|
||||
g_return_val_if_fail (shader_name != NULL, NULL);
|
||||
g_return_val_if_fail (render_pass != VK_NULL_HANDLE, NULL);
|
||||
|
||||
@@ -95,12 +87,13 @@ gsk_vulkan_pipeline_new_full (GType pipeline_type,
|
||||
|
||||
priv = gsk_vulkan_pipeline_get_instance_private (self);
|
||||
|
||||
priv->layout = gsk_vulkan_pipeline_layout_ref (layout);
|
||||
device = gdk_vulkan_context_get_device (context);
|
||||
|
||||
device = gdk_vulkan_context_get_device (layout->vulkan);
|
||||
priv->context = context;
|
||||
priv->layout = layout;
|
||||
|
||||
priv->vertex_shader = gsk_vulkan_shader_new_from_resource (layout->vulkan, GSK_VULKAN_SHADER_VERTEX, shader_name, NULL);
|
||||
priv->fragment_shader = gsk_vulkan_shader_new_from_resource (layout->vulkan, GSK_VULKAN_SHADER_FRAGMENT, shader_name, NULL);
|
||||
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);
|
||||
|
||||
GSK_VK_CHECK (vkCreateGraphicsPipelines, device,
|
||||
VK_NULL_HANDLE,
|
||||
@@ -167,7 +160,7 @@ gsk_vulkan_pipeline_new_full (GType pipeline_type,
|
||||
VK_DYNAMIC_STATE_SCISSOR
|
||||
},
|
||||
},
|
||||
.layout = gsk_vulkan_pipeline_layout_get_pipeline_layout (priv->layout),
|
||||
.layout = priv->layout,
|
||||
.renderPass = render_pass,
|
||||
.subpass = 0,
|
||||
.basePipelineHandle = VK_NULL_HANDLE,
|
||||
@@ -187,91 +180,10 @@ gsk_vulkan_pipeline_get_pipeline (GskVulkanPipeline *self)
|
||||
return priv->pipeline;
|
||||
}
|
||||
|
||||
/*** GskVulkanPipelineLayout ***/
|
||||
|
||||
GskVulkanPipelineLayout *
|
||||
gsk_vulkan_pipeline_layout_new (GdkVulkanContext *context)
|
||||
{
|
||||
GskVulkanPipelineLayout *self;
|
||||
VkDevice device;
|
||||
|
||||
self = g_slice_new0 (GskVulkanPipelineLayout);
|
||||
self->ref_count = 1;
|
||||
self->vulkan = g_object_ref (context);
|
||||
|
||||
device = gdk_vulkan_context_get_device (context);
|
||||
|
||||
GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
|
||||
&(VkDescriptorSetLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
.bindingCount = 1,
|
||||
.pBindings = (VkDescriptorSetLayoutBinding[1]) {
|
||||
{
|
||||
.binding = 0,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
|
||||
}
|
||||
}
|
||||
},
|
||||
NULL,
|
||||
&self->descriptor_set_layout);
|
||||
|
||||
GSK_VK_CHECK (vkCreatePipelineLayout, device,
|
||||
&(VkPipelineLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
.setLayoutCount = 1,
|
||||
.pSetLayouts = &self->descriptor_set_layout,
|
||||
.pushConstantRangeCount = gst_vulkan_push_constants_get_range_count (),
|
||||
.pPushConstantRanges = gst_vulkan_push_constants_get_ranges ()
|
||||
},
|
||||
NULL,
|
||||
&self->pipeline_layout);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GskVulkanPipelineLayout *
|
||||
gsk_vulkan_pipeline_layout_ref (GskVulkanPipelineLayout *self)
|
||||
{
|
||||
self->ref_count++;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_pipeline_layout_unref (GskVulkanPipelineLayout *self)
|
||||
{
|
||||
VkDevice device;
|
||||
|
||||
self->ref_count--;
|
||||
|
||||
if (self->ref_count > 0)
|
||||
return;
|
||||
|
||||
device = gdk_vulkan_context_get_device (self->vulkan);
|
||||
|
||||
vkDestroyPipelineLayout (device,
|
||||
self->pipeline_layout,
|
||||
NULL);
|
||||
|
||||
vkDestroyDescriptorSetLayout (device,
|
||||
self->descriptor_set_layout,
|
||||
NULL);
|
||||
|
||||
g_slice_free (GskVulkanPipelineLayout, self);
|
||||
}
|
||||
|
||||
|
||||
VkPipelineLayout
|
||||
gsk_vulkan_pipeline_layout_get_pipeline_layout (GskVulkanPipelineLayout *self)
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self)
|
||||
{
|
||||
return self->pipeline_layout;
|
||||
}
|
||||
GskVulkanPipelinePrivate *priv = gsk_vulkan_pipeline_get_instance_private (self);
|
||||
|
||||
VkDescriptorSetLayout
|
||||
gsk_vulkan_pipeline_layout_get_descriptor_set_layout (GskVulkanPipelineLayout *self)
|
||||
{
|
||||
return self->descriptor_set_layout;
|
||||
return priv->layout;
|
||||
}
|
||||
|
||||
|
@@ -7,8 +7,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskVulkanPipelineLayout GskVulkanPipelineLayout;
|
||||
|
||||
#define GSK_TYPE_VULKAN_PIPELINE (gsk_vulkan_pipeline_get_type ())
|
||||
|
||||
G_DECLARE_DERIVABLE_TYPE (GskVulkanPipeline, gsk_vulkan_pipeline, GSK, VULKAN_PIPELINE, GObject)
|
||||
@@ -34,28 +32,21 @@ 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);
|
||||
GskVulkanPipelineLayout * gsk_vulkan_pipeline_layout_ref (GskVulkanPipelineLayout *self);
|
||||
void gsk_vulkan_pipeline_layout_unref (GskVulkanPipelineLayout *self);
|
||||
|
||||
VkPipelineLayout gsk_vulkan_pipeline_layout_get_pipeline_layout
|
||||
(GskVulkanPipelineLayout *self);
|
||||
VkDescriptorSetLayout gsk_vulkan_pipeline_layout_get_descriptor_set_layout
|
||||
(GskVulkanPipelineLayout *self);
|
||||
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_pipeline_new (GType pipeline_type,
|
||||
GskVulkanPipelineLayout *layout,
|
||||
GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
GskVulkanPipeline * gsk_vulkan_pipeline_new_full (GType pipeline_type,
|
||||
GskVulkanPipelineLayout *layout,
|
||||
GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass,
|
||||
VkBlendFactor srcBlendFactor,
|
||||
VkBlendFactor dstBlendFactor);
|
||||
|
||||
VkPipeline gsk_vulkan_pipeline_get_pipeline (GskVulkanPipeline *self);
|
||||
VkPipelineLayout gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -16,9 +16,11 @@
|
||||
#include "gskvulkanboxshadowpipelineprivate.h"
|
||||
#include "gskvulkancolorpipelineprivate.h"
|
||||
#include "gskvulkancolortextpipelineprivate.h"
|
||||
#include "gskvulkancrossfadepipelineprivate.h"
|
||||
#include "gskvulkaneffectpipelineprivate.h"
|
||||
#include "gskvulkanlineargradientpipelineprivate.h"
|
||||
#include "gskvulkantextpipelineprivate.h"
|
||||
#include "gskvulkanpushconstantsprivate.h"
|
||||
|
||||
#define ORTHO_NEAR_PLANE -10000
|
||||
#define ORTHO_FAR_PLANE 10000
|
||||
@@ -40,14 +42,15 @@ struct _GskVulkanRender
|
||||
GskVulkanCommandPool *command_pool;
|
||||
VkFence fence;
|
||||
VkRenderPass render_pass;
|
||||
GskVulkanPipelineLayout *layout;
|
||||
VkDescriptorSetLayout descriptor_set_layout;
|
||||
VkPipelineLayout pipeline_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];
|
||||
|
||||
@@ -176,7 +179,42 @@ gsk_vulkan_render_new (GskRenderer *renderer,
|
||||
NULL,
|
||||
&self->render_pass);
|
||||
|
||||
self->layout = gsk_vulkan_pipeline_layout_new (self->vulkan);
|
||||
GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
|
||||
&(VkDescriptorSetLayoutCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
.bindingCount = 1,
|
||||
.pBindings = (VkDescriptorSetLayoutBinding[1]) {
|
||||
{
|
||||
.binding = 0,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
|
||||
}
|
||||
}
|
||||
},
|
||||
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 = gst_vulkan_push_constants_get_range_count (),
|
||||
.pPushConstantRanges = gst_vulkan_push_constants_get_ranges ()
|
||||
},
|
||||
NULL,
|
||||
&self->pipeline_layout[i]);
|
||||
}
|
||||
|
||||
self->uploader = gsk_vulkan_uploader_new (self->vulkan, self->command_pool);
|
||||
|
||||
@@ -318,48 +356,51 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
|
||||
{
|
||||
static const struct {
|
||||
const char *name;
|
||||
GskVulkanPipeline * (* create_func) (GskVulkanPipelineLayout *layout, const char *name, VkRenderPass render_pass);
|
||||
guint num_textures;
|
||||
GskVulkanPipeline * (* create_func) (GdkVulkanContext *context, VkPipelineLayout 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 },
|
||||
{ "crossfade", 2, gsk_vulkan_cross_fade_pipeline_new },
|
||||
{ "crossfade-clip", 2, gsk_vulkan_cross_fade_pipeline_new },
|
||||
{ "crossfade-clip-rounded", 2, gsk_vulkan_cross_fade_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,
|
||||
pipeline_info[type].name,
|
||||
self->render_pass);
|
||||
}
|
||||
self->pipelines[type] = pipeline_info[type].create_func (self->vulkan,
|
||||
self->pipeline_layout[pipeline_info[type].num_textures],
|
||||
pipeline_info[type].name,
|
||||
self->render_pass);
|
||||
|
||||
return self->pipelines[type];
|
||||
}
|
||||
@@ -447,9 +488,7 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self,
|
||||
|
||||
VkDescriptorSetLayout *layouts = g_newa (VkDescriptorSetLayout, needed_sets);
|
||||
for (i = 0; i < needed_sets; i++)
|
||||
{
|
||||
layouts[i] = gsk_vulkan_pipeline_layout_get_descriptor_set_layout (self->layout);
|
||||
}
|
||||
layouts[i] = self->descriptor_set_layout;
|
||||
|
||||
GSK_VK_CHECK (vkAllocateDescriptorSets, device,
|
||||
&(VkDescriptorSetAllocateInfo) {
|
||||
@@ -545,7 +584,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->pipeline_layout, command_buffer);
|
||||
}
|
||||
|
||||
vkCmdEndRenderPass (command_buffer);
|
||||
@@ -638,7 +677,10 @@ 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++)
|
||||
vkDestroyPipelineLayout (device,
|
||||
self->pipeline_layout[i],
|
||||
NULL);
|
||||
|
||||
vkDestroyRenderPass (device,
|
||||
self->render_pass,
|
||||
@@ -650,6 +692,10 @@ gsk_vulkan_render_free (GskVulkanRender *self)
|
||||
g_free (self->descriptor_sets);
|
||||
g_hash_table_unref (self->descriptor_set_indexes);
|
||||
|
||||
vkDestroyDescriptorSetLayout (device,
|
||||
self->descriptor_set_layout,
|
||||
NULL);
|
||||
|
||||
vkDestroyFence (device,
|
||||
self->fence,
|
||||
NULL);
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "gskvulkanclipprivate.h"
|
||||
#include "gskvulkancolorpipelineprivate.h"
|
||||
#include "gskvulkancolortextpipelineprivate.h"
|
||||
#include "gskvulkancrossfadepipelineprivate.h"
|
||||
#include "gskvulkaneffectpipelineprivate.h"
|
||||
#include "gskvulkanlineargradientpipelineprivate.h"
|
||||
#include "gskvulkantextpipelineprivate.h"
|
||||
@@ -26,6 +27,7 @@
|
||||
typedef union _GskVulkanOp GskVulkanOp;
|
||||
typedef struct _GskVulkanOpRender GskVulkanOpRender;
|
||||
typedef struct _GskVulkanOpText GskVulkanOpText;
|
||||
typedef struct _GskVulkanOpCrossFade GskVulkanOpCrossFade;
|
||||
typedef struct _GskVulkanOpPushConstants GskVulkanOpPushConstants;
|
||||
|
||||
typedef enum {
|
||||
@@ -35,8 +37,6 @@ typedef enum {
|
||||
GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP,
|
||||
GSK_VULKAN_OP_SURFACE,
|
||||
GSK_VULKAN_OP_TEXTURE,
|
||||
GSK_VULKAN_OP_TEXT,
|
||||
GSK_VULKAN_OP_COLOR_TEXT,
|
||||
GSK_VULKAN_OP_COLOR,
|
||||
GSK_VULKAN_OP_LINEAR_GRADIENT,
|
||||
GSK_VULKAN_OP_OPACITY,
|
||||
@@ -45,8 +45,13 @@ typedef enum {
|
||||
GSK_VULKAN_OP_BORDER,
|
||||
GSK_VULKAN_OP_INSET_SHADOW,
|
||||
GSK_VULKAN_OP_OUTSET_SHADOW,
|
||||
/* GskVulkanOpText */
|
||||
GSK_VULKAN_OP_TEXT,
|
||||
GSK_VULKAN_OP_COLOR_TEXT,
|
||||
/* GskVulkanOpCrossFade */
|
||||
GSK_VULKAN_OP_CROSS_FADE,
|
||||
/* GskVulkanOpPushConstants */
|
||||
GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS
|
||||
GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS,
|
||||
} GskVulkanOpType;
|
||||
|
||||
struct _GskVulkanOpRender
|
||||
@@ -76,6 +81,20 @@ struct _GskVulkanOpText
|
||||
guint num_glyphs; /* number of *non-empty* glyphs (== instances) we render */
|
||||
};
|
||||
|
||||
struct _GskVulkanOpCrossFade
|
||||
{
|
||||
GskVulkanOpType type;
|
||||
GskRenderNode *node; /* node that's the source of this op */
|
||||
GskVulkanPipeline *pipeline; /* pipeline to use */
|
||||
GskRoundedRect clip; /* clip rect (or random memory if not relevant) */
|
||||
GskVulkanImage *start; /* source images to render */
|
||||
GskVulkanImage *end;
|
||||
gsize vertex_offset; /* offset into vertex buffer */
|
||||
gsize vertex_count; /* number of vertices */
|
||||
gsize descriptor_set_start; /* indices into descriptor sets array */
|
||||
gsize descriptor_set_end;
|
||||
};
|
||||
|
||||
struct _GskVulkanOpPushConstants
|
||||
{
|
||||
GskVulkanOpType type;
|
||||
@@ -87,8 +106,9 @@ union _GskVulkanOp
|
||||
{
|
||||
GskVulkanOpType type;
|
||||
GskVulkanOpRender render;
|
||||
GskVulkanOpPushConstants constants;
|
||||
GskVulkanOpText text;
|
||||
GskVulkanOpCrossFade crossfade;
|
||||
GskVulkanOpPushConstants constants;
|
||||
};
|
||||
|
||||
struct _GskVulkanRenderPass
|
||||
@@ -161,10 +181,23 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
|
||||
case GSK_REPEAT_NODE:
|
||||
case GSK_SHADOW_NODE:
|
||||
case GSK_BLEND_NODE:
|
||||
case GSK_CROSS_FADE_NODE:
|
||||
default:
|
||||
FALLBACK ("Unsupported node '%s'\n", node->node_class->type_name);
|
||||
|
||||
case GSK_CROSS_FADE_NODE:
|
||||
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_CROSS_FADE;
|
||||
else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_CROSS_FADE_CLIP;
|
||||
else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
|
||||
pipeline_type = GSK_VULKAN_PIPELINE_CROSS_FADE_CLIP_ROUNDED;
|
||||
else
|
||||
FALLBACK ("Cross fade nodes can't deal with clip type %u\n", constants->clip.type);
|
||||
op.type = GSK_VULKAN_OP_CROSS_FADE;
|
||||
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
||||
g_array_append_val (self->render_ops, op);
|
||||
return;
|
||||
|
||||
case GSK_INSET_SHADOW_NODE:
|
||||
if (gsk_inset_shadow_node_get_blur_radius (node) > 0)
|
||||
FALLBACK ("Blur support not implemented for inset shadows\n");
|
||||
@@ -707,6 +740,24 @@ gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self,
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_OP_CROSS_FADE:
|
||||
{
|
||||
GskRenderNode *start = gsk_cross_fade_node_get_start_child (op->render.node);
|
||||
GskRenderNode *end = gsk_cross_fade_node_get_end_child (op->render.node);
|
||||
|
||||
op->crossfade.start = gsk_vulkan_render_pass_get_node_as_texture (self,
|
||||
render,
|
||||
uploader,
|
||||
start,
|
||||
&start->bounds);
|
||||
op->crossfade.end = gsk_vulkan_render_pass_get_node_as_texture (self,
|
||||
render,
|
||||
uploader,
|
||||
end,
|
||||
&end->bounds);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
case GSK_VULKAN_OP_COLOR:
|
||||
@@ -787,6 +838,11 @@ gsk_vulkan_render_pass_count_vertex_data (GskVulkanRenderPass *self)
|
||||
n_bytes += op->render.vertex_count;
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_OP_CROSS_FADE:
|
||||
op->crossfade.vertex_count = gsk_vulkan_cross_fade_pipeline_count_vertex_data (GSK_VULKAN_CROSS_FADE_PIPELINE (op->crossfade.pipeline));
|
||||
n_bytes += op->crossfade.vertex_count;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS:
|
||||
@@ -977,6 +1033,17 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_OP_CROSS_FADE:
|
||||
{
|
||||
op->crossfade.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GSK_VULKAN_CROSS_FADE_PIPELINE (op->crossfade.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->crossfade.node->bounds,
|
||||
gsk_cross_fade_node_get_progress (op->crossfade.node));
|
||||
n_bytes += op->crossfade.vertex_count;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS:
|
||||
@@ -1017,6 +1084,12 @@ gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulkanRenderPass *self,
|
||||
case GSK_VULKAN_OP_COLOR_TEXT:
|
||||
op->text.descriptor_set_index = gsk_vulkan_render_reserve_descriptor_set (render, op->text.source);
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_OP_CROSS_FADE:
|
||||
op->crossfade.descriptor_set_start = gsk_vulkan_render_reserve_descriptor_set (render, op->crossfade.start);
|
||||
op->crossfade.descriptor_set_end = gsk_vulkan_render_reserve_descriptor_set (render, op->crossfade.end);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
case GSK_VULKAN_OP_COLOR:
|
||||
@@ -1034,7 +1107,8 @@ void
|
||||
gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
||||
GskVulkanRender *render,
|
||||
GskVulkanBuffer *vertex_buffer,
|
||||
GskVulkanPipelineLayout *layout,
|
||||
guint layout_count,
|
||||
VkPipelineLayout *pipeline_layout,
|
||||
VkCommandBuffer command_buffer)
|
||||
{
|
||||
GskVulkanPipeline *current_pipeline = NULL;
|
||||
@@ -1072,7 +1146,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 +1179,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 +1212,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 +1246,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 +1279,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 +1387,44 @@ 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,
|
||||
pipeline_layout[i]);
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_OP_CROSS_FADE:
|
||||
if (current_pipeline != op->crossfade.pipeline)
|
||||
{
|
||||
current_pipeline = op->crossfade.pipeline;
|
||||
vkCmdBindPipeline (command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
gsk_vulkan_pipeline_get_pipeline (current_pipeline));
|
||||
vkCmdBindVertexBuffers (command_buffer,
|
||||
0,
|
||||
1,
|
||||
(VkBuffer[1]) {
|
||||
gsk_vulkan_buffer_get_buffer (vertex_buffer)
|
||||
},
|
||||
(VkDeviceSize[1]) { op->crossfade.vertex_offset });
|
||||
current_draw_index = 0;
|
||||
}
|
||||
|
||||
vkCmdBindDescriptorSets (command_buffer,
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
gsk_vulkan_pipeline_get_pipeline_layout (current_pipeline),
|
||||
0,
|
||||
2,
|
||||
(VkDescriptorSet[2]) {
|
||||
gsk_vulkan_render_get_descriptor_set (render, op->crossfade.descriptor_set_start),
|
||||
gsk_vulkan_render_get_descriptor_set (render, op->crossfade.descriptor_set_end)
|
||||
},
|
||||
0,
|
||||
NULL);
|
||||
|
||||
current_draw_index += gsk_vulkan_cross_fade_pipeline_draw (GSK_VULKAN_CROSS_FADE_PIPELINE (current_pipeline),
|
||||
command_buffer,
|
||||
current_draw_index, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -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,
|
||||
VkPipelineLayout *pipeline_layout,
|
||||
VkCommandBuffer command_buffer);
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -40,6 +40,9 @@ typedef enum {
|
||||
GSK_VULKAN_PIPELINE_COLOR_TEXT,
|
||||
GSK_VULKAN_PIPELINE_COLOR_TEXT_CLIP,
|
||||
GSK_VULKAN_PIPELINE_COLOR_TEXT_CLIP_ROUNDED,
|
||||
GSK_VULKAN_PIPELINE_CROSS_FADE,
|
||||
GSK_VULKAN_PIPELINE_CROSS_FADE_CLIP,
|
||||
GSK_VULKAN_PIPELINE_CROSS_FADE_CLIP_ROUNDED,
|
||||
/* add more */
|
||||
GSK_VULKAN_N_PIPELINES
|
||||
} GskVulkanPipelineType;
|
||||
|
@@ -83,11 +83,12 @@ gsk_vulkan_text_pipeline_init (GskVulkanTextPipeline *self)
|
||||
}
|
||||
|
||||
GskVulkanPipeline *
|
||||
gsk_vulkan_text_pipeline_new (GskVulkanPipelineLayout *layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
gsk_vulkan_text_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass)
|
||||
{
|
||||
return gsk_vulkan_pipeline_new_full (GSK_TYPE_VULKAN_TEXT_PIPELINE, layout, shader_name, render_pass,
|
||||
return gsk_vulkan_pipeline_new_full (GSK_TYPE_VULKAN_TEXT_PIPELINE, context, layout, shader_name, render_pass,
|
||||
VK_BLEND_FACTOR_SRC_ALPHA, VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
|
@@ -14,9 +14,10 @@ typedef struct _GskVulkanTextPipelineLayout GskVulkanTextPipelineLayout;
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanTextPipeline, gsk_vulkan_text_pipeline, GSK, VULKAN_TEXT_PIPELINE, GskVulkanPipeline)
|
||||
|
||||
GskVulkanPipeline * gsk_vulkan_text_pipeline_new (GskVulkanPipelineLayout * layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
GskVulkanPipeline * gsk_vulkan_text_pipeline_new (GdkVulkanContext *context,
|
||||
VkPipelineLayout layout,
|
||||
const char *shader_name,
|
||||
VkRenderPass render_pass);
|
||||
|
||||
gsize gsk_vulkan_text_pipeline_count_vertex_data (GskVulkanTextPipeline *pipeline,
|
||||
int num_instances);
|
||||
|
@@ -62,6 +62,7 @@ if have_vulkan
|
||||
'gskvulkanclip.c',
|
||||
'gskvulkancolorpipeline.c',
|
||||
'gskvulkancolortextpipeline.c',
|
||||
'gskvulkancrossfadepipeline.c',
|
||||
'gskvulkancommandpool.c',
|
||||
'gskvulkaneffectpipeline.c',
|
||||
'gskvulkanglyphcache.c',
|
||||
|
BIN
gsk/resources/vulkan/crossfade-clip-rounded.frag.spv
Normal file
BIN
gsk/resources/vulkan/crossfade-clip-rounded.frag.spv
Normal file
Binary file not shown.
BIN
gsk/resources/vulkan/crossfade-clip-rounded.vert.spv
Normal file
BIN
gsk/resources/vulkan/crossfade-clip-rounded.vert.spv
Normal file
Binary file not shown.
BIN
gsk/resources/vulkan/crossfade-clip.frag.spv
Normal file
BIN
gsk/resources/vulkan/crossfade-clip.frag.spv
Normal file
Binary file not shown.
BIN
gsk/resources/vulkan/crossfade-clip.vert.spv
Normal file
BIN
gsk/resources/vulkan/crossfade-clip.vert.spv
Normal file
Binary file not shown.
20
gsk/resources/vulkan/crossfade.frag
Normal file
20
gsk/resources/vulkan/crossfade.frag
Normal file
@@ -0,0 +1,20 @@
|
||||
#version 420 core
|
||||
|
||||
#include "clip.frag.glsl"
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in vec2 inTexCoord;
|
||||
layout(location = 2) in float inProgress;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D startTexture;
|
||||
layout(set = 1, binding = 0) uniform sampler2D endTexture;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 start = texture (startTexture, inTexCoord);
|
||||
vec4 end = texture (endTexture, inTexCoord);
|
||||
|
||||
color = clip (inPos, mix (start, end, inProgress));
|
||||
}
|
BIN
gsk/resources/vulkan/crossfade.frag.spv
Normal file
BIN
gsk/resources/vulkan/crossfade.frag.spv
Normal file
Binary file not shown.
38
gsk/resources/vulkan/crossfade.vert
Normal file
38
gsk/resources/vulkan/crossfade.vert
Normal file
@@ -0,0 +1,38 @@
|
||||
#version 420 core
|
||||
|
||||
#include "clip.vert.glsl"
|
||||
|
||||
layout(location = 0) in vec4 inRect;
|
||||
layout(location = 1) in vec4 inTexRect;
|
||||
layout(location = 2) in float inProgress;
|
||||
|
||||
layout(location = 0) out vec2 outPos;
|
||||
layout(location = 1) out vec2 outTexCoord;
|
||||
layout(location = 2) out float outProgress;
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
vec2 offsets[6] = { vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(0.0, 1.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(1.0, 1.0) };
|
||||
|
||||
void main() {
|
||||
vec4 rect = clip (inRect);
|
||||
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
||||
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
||||
|
||||
outPos = pos;
|
||||
|
||||
vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
|
||||
rect.zw / inRect.zw);
|
||||
texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
|
||||
inTexRect.zw * texrect.zw);
|
||||
outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
|
||||
|
||||
outProgress = inProgress;
|
||||
}
|
BIN
gsk/resources/vulkan/crossfade.vert.spv
Normal file
BIN
gsk/resources/vulkan/crossfade.vert.spv
Normal file
Binary file not shown.
@@ -12,6 +12,7 @@ gsk_private_vulkan_fragment_shaders = [
|
||||
'border.frag',
|
||||
'color.frag',
|
||||
'color-matrix.frag',
|
||||
'crossfade.frag',
|
||||
'inset-shadow.frag',
|
||||
'linear.frag',
|
||||
'mask.frag',
|
||||
@@ -24,6 +25,7 @@ gsk_private_vulkan_vertex_shaders = [
|
||||
'border.vert',
|
||||
'color.vert',
|
||||
'color-matrix.vert',
|
||||
'crossfade.vert',
|
||||
'inset-shadow.vert',
|
||||
'linear.vert',
|
||||
'mask.vert',
|
||||
|
Reference in New Issue
Block a user