2016-12-08 12:26:36 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gskvulkanrenderpassprivate.h"
|
|
|
|
|
2016-12-23 23:52:07 +00:00
|
|
|
#include "gskdebugprivate.h"
|
2016-12-23 20:36:17 +00:00
|
|
|
#include "gskrendernodeprivate.h"
|
|
|
|
#include "gskrenderer.h"
|
|
|
|
#include "gskroundedrectprivate.h"
|
2016-12-18 00:45:07 +00:00
|
|
|
#include "gskvulkanblendpipelineprivate.h"
|
2017-01-10 13:59:20 +00:00
|
|
|
#include "gskvulkanborderpipelineprivate.h"
|
2017-01-18 03:07:09 +00:00
|
|
|
#include "gskvulkanboxshadowpipelineprivate.h"
|
2016-12-23 20:36:17 +00:00
|
|
|
#include "gskvulkanclipprivate.h"
|
2016-12-18 01:18:01 +00:00
|
|
|
#include "gskvulkancolorpipelineprivate.h"
|
2016-12-30 05:46:34 +00:00
|
|
|
#include "gskvulkaneffectpipelineprivate.h"
|
2016-12-26 16:11:13 +00:00
|
|
|
#include "gskvulkanlineargradientpipelineprivate.h"
|
2016-12-08 12:26:36 +00:00
|
|
|
#include "gskvulkanimageprivate.h"
|
2016-12-14 06:21:21 +00:00
|
|
|
#include "gskvulkanpushconstantsprivate.h"
|
2016-12-09 06:23:04 +00:00
|
|
|
#include "gskvulkanrendererprivate.h"
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-14 06:34:18 +00:00
|
|
|
typedef union _GskVulkanOp GskVulkanOp;
|
|
|
|
typedef struct _GskVulkanOpRender GskVulkanOpRender;
|
|
|
|
typedef struct _GskVulkanOpPushConstants GskVulkanOpPushConstants;
|
2016-12-08 12:26:36 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2016-12-14 06:34:18 +00:00
|
|
|
/* GskVulkanOpRender */
|
2016-12-09 04:59:19 +00:00
|
|
|
GSK_VULKAN_OP_FALLBACK,
|
2016-12-23 20:36:17 +00:00
|
|
|
GSK_VULKAN_OP_FALLBACK_CLIP,
|
|
|
|
GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP,
|
2016-12-09 04:59:19 +00:00
|
|
|
GSK_VULKAN_OP_SURFACE,
|
2016-12-12 23:11:06 +00:00
|
|
|
GSK_VULKAN_OP_TEXTURE,
|
2016-12-14 08:40:15 +00:00
|
|
|
GSK_VULKAN_OP_COLOR,
|
2016-12-26 16:11:13 +00:00
|
|
|
GSK_VULKAN_OP_LINEAR_GRADIENT,
|
2016-12-30 05:46:34 +00:00
|
|
|
GSK_VULKAN_OP_OPACITY,
|
2016-12-31 13:14:26 +00:00
|
|
|
GSK_VULKAN_OP_COLOR_MATRIX,
|
2017-01-10 13:59:20 +00:00
|
|
|
GSK_VULKAN_OP_BORDER,
|
2017-01-18 03:07:09 +00:00
|
|
|
GSK_VULKAN_OP_INSET_SHADOW,
|
|
|
|
GSK_VULKAN_OP_OUTSET_SHADOW,
|
2016-12-14 06:34:18 +00:00
|
|
|
/* GskVulkanOpPushConstants */
|
2016-12-18 06:07:02 +00:00
|
|
|
GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS
|
2016-12-08 12:26:36 +00:00
|
|
|
} GskVulkanOpType;
|
|
|
|
|
2016-12-14 06:34:18 +00:00
|
|
|
struct _GskVulkanOpRender
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
|
|
|
GskVulkanOpType type;
|
|
|
|
GskRenderNode *node; /* node that's the source of this op */
|
2016-12-14 08:40:15 +00:00
|
|
|
GskVulkanPipeline *pipeline; /* pipeline to use */
|
2016-12-23 20:36:17 +00:00
|
|
|
GskRoundedRect clip; /* clip rect (or random memory if not relevant) */
|
2016-12-08 12:26:36 +00:00
|
|
|
GskVulkanImage *source; /* source image to render */
|
|
|
|
gsize vertex_offset; /* offset into vertex buffer */
|
|
|
|
gsize vertex_count; /* number of vertices */
|
2016-12-09 01:55:47 +00:00
|
|
|
gsize descriptor_set_index; /* index into descriptor sets array for the right descriptor set to bind */
|
2016-12-08 12:26:36 +00:00
|
|
|
};
|
|
|
|
|
2016-12-14 06:34:18 +00:00
|
|
|
struct _GskVulkanOpPushConstants
|
|
|
|
{
|
|
|
|
GskVulkanOpType type;
|
|
|
|
GskRenderNode *node; /* node that's the source of this op */
|
|
|
|
GskVulkanPushConstants constants; /* new constants to push */
|
|
|
|
};
|
|
|
|
|
|
|
|
union _GskVulkanOp
|
|
|
|
{
|
|
|
|
GskVulkanOpType type;
|
|
|
|
GskVulkanOpRender render;
|
|
|
|
GskVulkanOpPushConstants constants;
|
|
|
|
};
|
|
|
|
|
2016-12-08 12:26:36 +00:00
|
|
|
struct _GskVulkanRenderPass
|
|
|
|
{
|
|
|
|
GdkVulkanContext *vulkan;
|
|
|
|
|
|
|
|
GArray *render_ops;
|
|
|
|
};
|
|
|
|
|
|
|
|
GskVulkanRenderPass *
|
|
|
|
gsk_vulkan_render_pass_new (GdkVulkanContext *context)
|
|
|
|
{
|
|
|
|
GskVulkanRenderPass *self;
|
|
|
|
|
|
|
|
self = g_slice_new0 (GskVulkanRenderPass);
|
|
|
|
self->vulkan = g_object_ref (context);
|
2016-12-14 06:34:18 +00:00
|
|
|
self->render_ops = g_array_new (FALSE, FALSE, sizeof (GskVulkanOp));
|
2016-12-08 12:26:36 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gsk_vulkan_render_pass_free (GskVulkanRenderPass *self)
|
|
|
|
{
|
|
|
|
g_array_unref (self->render_ops);
|
|
|
|
g_object_unref (self->vulkan);
|
|
|
|
|
|
|
|
g_slice_free (GskVulkanRenderPass, self);
|
|
|
|
}
|
|
|
|
|
2016-12-23 23:52:07 +00:00
|
|
|
#define FALLBACK(...) G_STMT_START { \
|
|
|
|
GSK_NOTE (FALLBACK, g_print (__VA_ARGS__)); \
|
|
|
|
goto fallback; \
|
|
|
|
}G_STMT_END
|
|
|
|
|
2016-12-08 12:26:36 +00:00
|
|
|
void
|
2016-12-14 06:21:21 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanPushConstants *constants,
|
|
|
|
GskRenderNode *node)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
GskVulkanOp op = {
|
2016-12-08 12:26:36 +00:00
|
|
|
.type = GSK_VULKAN_OP_FALLBACK,
|
2016-12-14 06:34:18 +00:00
|
|
|
.render.node = node
|
2016-12-08 12:26:36 +00:00
|
|
|
};
|
2016-12-24 05:16:54 +00:00
|
|
|
GskVulkanPipelineType pipeline_type;
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-11 01:33:58 +00:00
|
|
|
switch (gsk_render_node_get_node_type (node))
|
2016-12-09 04:59:19 +00:00
|
|
|
{
|
2016-12-11 01:33:58 +00:00
|
|
|
case GSK_NOT_A_RENDER_NODE:
|
|
|
|
g_assert_not_reached ();
|
2016-12-23 20:36:17 +00:00
|
|
|
return;
|
2017-01-10 13:59:20 +00:00
|
|
|
case GSK_REPEAT_NODE:
|
2016-12-30 05:46:34 +00:00
|
|
|
case GSK_SHADOW_NODE:
|
|
|
|
case GSK_BLEND_NODE:
|
|
|
|
case GSK_CROSS_FADE_NODE:
|
2016-12-13 03:20:04 +00:00
|
|
|
default:
|
2016-12-23 23:52:07 +00:00
|
|
|
FALLBACK ("Unsupported node '%s'\n", node->node_class->type_name);
|
2016-12-13 03:20:04 +00:00
|
|
|
|
2017-01-18 03:07:09 +00:00
|
|
|
case GSK_INSET_SHADOW_NODE:
|
|
|
|
if (gsk_inset_shadow_node_get_blur_radius (node) > 0)
|
|
|
|
FALLBACK ("Blur support not implemented for inset shadows\n");
|
|
|
|
else if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_INSET_SHADOW;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_INSET_SHADOW_CLIP;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_INSET_SHADOW_CLIP_ROUNDED;
|
|
|
|
else
|
|
|
|
FALLBACK ("Inset shadow nodes can't deal with clip type %u\n", constants->clip.type);
|
|
|
|
op.type = GSK_VULKAN_OP_INSET_SHADOW;
|
|
|
|
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case GSK_OUTSET_SHADOW_NODE:
|
|
|
|
if (gsk_outset_shadow_node_get_blur_radius (node) > 0)
|
|
|
|
FALLBACK ("Blur support not implemented for outset shadows\n");
|
|
|
|
else if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_OUTSET_SHADOW;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_OUTSET_SHADOW_CLIP;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_OUTSET_SHADOW_CLIP_ROUNDED;
|
|
|
|
else
|
|
|
|
FALLBACK ("Outset shadow nodes can't deal with clip type %u\n", constants->clip.type);
|
|
|
|
op.type = GSK_VULKAN_OP_OUTSET_SHADOW;
|
|
|
|
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
return;
|
|
|
|
|
2016-12-11 01:33:58 +00:00
|
|
|
case GSK_CAIRO_NODE:
|
2016-12-23 20:36:17 +00:00
|
|
|
if (gsk_cairo_node_get_surface (node) == NULL)
|
|
|
|
return;
|
2017-01-01 22:47:53 +00:00
|
|
|
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_BLEND;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_BLEND_CLIP;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_BLEND_CLIP_ROUNDED;
|
|
|
|
else
|
2016-12-24 03:58:51 +00:00
|
|
|
FALLBACK ("Cairo nodes can't deal with clip type %u\n", constants->clip.type);
|
2016-12-23 20:36:17 +00:00
|
|
|
op.type = GSK_VULKAN_OP_SURFACE;
|
2017-01-01 22:47:53 +00:00
|
|
|
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
2016-12-23 20:36:17 +00:00
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
return;
|
2016-12-11 01:33:58 +00:00
|
|
|
|
|
|
|
case GSK_TEXTURE_NODE:
|
2017-01-01 22:47:53 +00:00
|
|
|
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_BLEND;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_BLEND_CLIP;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_BLEND_CLIP_ROUNDED;
|
|
|
|
else
|
2016-12-24 03:58:51 +00:00
|
|
|
FALLBACK ("Texture nodes can't deal with clip type %u\n", constants->clip.type);
|
2016-12-09 04:59:19 +00:00
|
|
|
op.type = GSK_VULKAN_OP_TEXTURE;
|
2017-01-01 22:47:53 +00:00
|
|
|
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
2016-12-14 08:40:15 +00:00
|
|
|
g_array_append_val (self->render_ops, op);
|
2016-12-23 20:36:17 +00:00
|
|
|
return;
|
2016-12-14 08:40:15 +00:00
|
|
|
|
|
|
|
case GSK_COLOR_NODE:
|
2016-12-24 05:16:54 +00:00
|
|
|
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_COLOR;
|
2016-12-25 05:01:54 +00:00
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_CLIP;
|
2016-12-24 05:16:54 +00:00
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_CLIP_ROUNDED;
|
|
|
|
else
|
2016-12-24 03:58:51 +00:00
|
|
|
FALLBACK ("Color nodes can't deal with clip type %u\n", constants->clip.type);
|
2016-12-14 08:40:15 +00:00
|
|
|
op.type = GSK_VULKAN_OP_COLOR;
|
2016-12-24 05:16:54 +00:00
|
|
|
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
2016-12-09 04:59:19 +00:00
|
|
|
g_array_append_val (self->render_ops, op);
|
2016-12-23 20:36:17 +00:00
|
|
|
return;
|
2016-12-11 01:33:58 +00:00
|
|
|
|
2016-12-26 16:11:13 +00:00
|
|
|
case GSK_LINEAR_GRADIENT_NODE:
|
|
|
|
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
|
|
|
if (gsk_linear_gradient_node_get_n_color_stops (node) > GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS)
|
|
|
|
FALLBACK ("Linear gradient with %zu color stops, hardcoded limit is %u\n",
|
|
|
|
gsk_linear_gradient_node_get_n_color_stops (node),
|
|
|
|
GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS);
|
|
|
|
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_LINEAR_GRADIENT;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_LINEAR_GRADIENT_CLIP;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_LINEAR_GRADIENT_CLIP_ROUNDED;
|
|
|
|
else
|
|
|
|
FALLBACK ("Linear gradient nodes can't deal with clip type %u\n", constants->clip.type);
|
|
|
|
op.type = GSK_VULKAN_OP_LINEAR_GRADIENT;
|
|
|
|
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
return;
|
|
|
|
|
2016-12-30 05:46:34 +00:00
|
|
|
case GSK_OPACITY_NODE:
|
|
|
|
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
2016-12-31 12:24:21 +00:00
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX;
|
2016-12-30 05:46:34 +00:00
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
|
2016-12-31 12:24:21 +00:00
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX_CLIP;
|
2016-12-30 05:46:34 +00:00
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
|
2016-12-31 12:24:21 +00:00
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX_CLIP_ROUNDED;
|
2016-12-30 05:46:34 +00:00
|
|
|
else
|
|
|
|
FALLBACK ("Opacity nodes can't deal with clip type %u\n", constants->clip.type);
|
|
|
|
op.type = GSK_VULKAN_OP_OPACITY;
|
|
|
|
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
return;
|
|
|
|
|
2016-12-31 13:14:26 +00:00
|
|
|
case GSK_COLOR_MATRIX_NODE:
|
|
|
|
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX_CLIP;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_COLOR_MATRIX_CLIP_ROUNDED;
|
|
|
|
else
|
|
|
|
FALLBACK ("Color matrix nodes can't deal with clip type %u\n", constants->clip.type);
|
|
|
|
op.type = GSK_VULKAN_OP_COLOR_MATRIX;
|
|
|
|
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
return;
|
|
|
|
|
2017-01-10 13:59:20 +00:00
|
|
|
case GSK_BORDER_NODE:
|
|
|
|
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_BORDER;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_RECT)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_BORDER_CLIP;
|
|
|
|
else if (constants->clip.type == GSK_VULKAN_CLIP_ROUNDED_CIRCULAR)
|
|
|
|
pipeline_type = GSK_VULKAN_PIPELINE_BORDER_CLIP_ROUNDED;
|
|
|
|
else
|
|
|
|
FALLBACK ("Border nodes can't deal with clip type %u\n", constants->clip.type);
|
|
|
|
op.type = GSK_VULKAN_OP_BORDER;
|
|
|
|
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, pipeline_type);
|
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
return;
|
|
|
|
|
2016-12-11 01:33:58 +00:00
|
|
|
case GSK_CONTAINER_NODE:
|
2016-12-12 18:30:41 +00:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < gsk_container_node_get_n_children (node); i++)
|
|
|
|
{
|
2016-12-24 03:58:51 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (self, render, constants, gsk_container_node_get_child (node, i));
|
2016-12-12 18:30:41 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-23 20:36:17 +00:00
|
|
|
return;
|
|
|
|
|
2016-12-12 23:11:06 +00:00
|
|
|
case GSK_TRANSFORM_NODE:
|
|
|
|
{
|
|
|
|
graphene_matrix_t transform;
|
2016-12-24 03:58:51 +00:00
|
|
|
GskRenderNode *child;
|
2016-12-23 20:36:17 +00:00
|
|
|
|
2016-12-24 03:58:51 +00:00
|
|
|
#if 0
|
2016-12-23 20:36:17 +00:00
|
|
|
if (!gsk_vulkan_clip_contains_rect (clip, &node->bounds))
|
2016-12-23 23:52:07 +00:00
|
|
|
FALLBACK ("Transform nodes can't deal with clip type %u\n", clip->type);
|
2016-12-24 03:58:51 +00:00
|
|
|
#endif
|
2016-12-12 23:11:06 +00:00
|
|
|
|
|
|
|
gsk_transform_node_get_transform (node, &transform);
|
2016-12-24 03:58:51 +00:00
|
|
|
child = gsk_transform_node_get_child (node);
|
|
|
|
if (!gsk_vulkan_push_constants_transform (&op.constants.constants, constants, &transform, &child->bounds))
|
|
|
|
FALLBACK ("Transform nodes can't deal with clip type %u\n", constants->clip.type);
|
2016-12-14 06:21:21 +00:00
|
|
|
op.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS;
|
2016-12-12 23:11:06 +00:00
|
|
|
g_array_append_val (self->render_ops, op);
|
2016-12-14 08:40:15 +00:00
|
|
|
|
2016-12-24 03:58:51 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (self, render, &op.constants.constants, child);
|
2016-12-14 06:34:18 +00:00
|
|
|
gsk_vulkan_push_constants_init_copy (&op.constants.constants, constants);
|
2016-12-12 23:11:06 +00:00
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
}
|
2016-12-23 20:36:17 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case GSK_CLIP_NODE:
|
|
|
|
{
|
2016-12-24 03:58:51 +00:00
|
|
|
if (!gsk_vulkan_push_constants_intersect_rect (&op.constants.constants, constants, gsk_clip_node_peek_clip (node)))
|
|
|
|
FALLBACK ("Failed to find intersection between clip of type %u and rectangle\n", constants->clip.type);
|
2016-12-28 14:37:01 +00:00
|
|
|
if (op.constants.constants.clip.type == GSK_VULKAN_CLIP_ALL_CLIPPED)
|
2016-12-23 20:36:17 +00:00
|
|
|
return;
|
|
|
|
|
2016-12-24 03:58:51 +00:00
|
|
|
op.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS;
|
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
|
|
|
|
gsk_vulkan_render_pass_add_node (self, render, &op.constants.constants, gsk_clip_node_get_child (node));
|
|
|
|
|
|
|
|
gsk_vulkan_push_constants_init_copy (&op.constants.constants, constants);
|
|
|
|
g_array_append_val (self->render_ops, op);
|
2016-12-23 20:36:17 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
case GSK_ROUNDED_CLIP_NODE:
|
|
|
|
{
|
2016-12-24 03:58:51 +00:00
|
|
|
if (!gsk_vulkan_push_constants_intersect_rounded (&op.constants.constants,
|
|
|
|
constants,
|
|
|
|
gsk_rounded_clip_node_peek_clip (node)))
|
|
|
|
FALLBACK ("Failed to find intersection between clip of type %u and rounded rectangle\n", constants->clip.type);
|
2016-12-28 14:37:01 +00:00
|
|
|
if (op.constants.constants.clip.type == GSK_VULKAN_CLIP_ALL_CLIPPED)
|
2016-12-23 20:36:17 +00:00
|
|
|
return;
|
|
|
|
|
2016-12-24 03:58:51 +00:00
|
|
|
op.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS;
|
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
|
|
|
|
gsk_vulkan_render_pass_add_node (self, render, &op.constants.constants, gsk_rounded_clip_node_get_child (node));
|
|
|
|
|
|
|
|
gsk_vulkan_push_constants_init_copy (&op.constants.constants, constants);
|
|
|
|
g_array_append_val (self->render_ops, op);
|
2016-12-23 20:36:17 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return;
|
|
|
|
|
|
|
|
fallback:
|
2016-12-24 03:58:51 +00:00
|
|
|
switch (constants->clip.type)
|
2016-12-23 20:36:17 +00:00
|
|
|
{
|
|
|
|
case GSK_VULKAN_CLIP_NONE:
|
|
|
|
op.type = GSK_VULKAN_OP_FALLBACK;
|
|
|
|
break;
|
|
|
|
case GSK_VULKAN_CLIP_RECT:
|
|
|
|
op.type = GSK_VULKAN_OP_FALLBACK_CLIP;
|
2016-12-24 03:58:51 +00:00
|
|
|
gsk_rounded_rect_init_copy (&op.render.clip, &constants->clip.rect);
|
2016-12-23 20:36:17 +00:00
|
|
|
break;
|
|
|
|
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
|
|
|
|
case GSK_VULKAN_CLIP_ROUNDED:
|
|
|
|
op.type = GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP;
|
2016-12-24 03:58:51 +00:00
|
|
|
gsk_rounded_rect_init_copy (&op.render.clip, &constants->clip.rect);
|
2016-12-23 20:36:17 +00:00
|
|
|
break;
|
|
|
|
case GSK_VULKAN_CLIP_ALL_CLIPPED:
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return;
|
2016-12-09 04:59:19 +00:00
|
|
|
}
|
2017-01-01 22:47:53 +00:00
|
|
|
op.render.pipeline = gsk_vulkan_render_get_pipeline (render, GSK_VULKAN_PIPELINE_BLEND);
|
2016-12-23 20:36:17 +00:00
|
|
|
g_array_append_val (self->render_ops, op);
|
2016-12-08 12:26:36 +00:00
|
|
|
}
|
2016-12-23 23:52:07 +00:00
|
|
|
#undef FALLBACK
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-12 23:11:06 +00:00
|
|
|
void
|
|
|
|
gsk_vulkan_render_pass_add (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const graphene_matrix_t *mvp,
|
2016-12-23 20:36:17 +00:00
|
|
|
const graphene_rect_t *viewport,
|
2016-12-12 23:11:06 +00:00
|
|
|
GskRenderNode *node)
|
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
GskVulkanOp op = { 0, };
|
2016-12-12 23:11:06 +00:00
|
|
|
|
2016-12-14 06:21:21 +00:00
|
|
|
op.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS;
|
2016-12-24 03:58:51 +00:00
|
|
|
gsk_vulkan_push_constants_init (&op.constants.constants, mvp, viewport);
|
2016-12-12 23:11:06 +00:00
|
|
|
g_array_append_val (self->render_ops, op);
|
|
|
|
|
2016-12-24 03:58:51 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (self, render, &op.constants.constants, node);
|
2016-12-12 23:11:06 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 05:46:34 +00:00
|
|
|
static GskVulkanImage *
|
|
|
|
gsk_vulkan_render_pass_get_node_as_texture (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
GskVulkanUploader *uploader,
|
|
|
|
GskRenderNode *node,
|
|
|
|
const graphene_rect_t *bounds)
|
|
|
|
{
|
|
|
|
GskVulkanImage *result;
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
cairo_t *cr;
|
|
|
|
|
2016-12-31 21:58:15 +00:00
|
|
|
if (graphene_rect_equal (bounds, &node->bounds))
|
|
|
|
{
|
|
|
|
switch (gsk_render_node_get_node_type (node))
|
|
|
|
{
|
|
|
|
case GSK_TEXTURE_NODE:
|
|
|
|
return gsk_vulkan_renderer_ref_texture_image (GSK_VULKAN_RENDERER (gsk_vulkan_render_get_renderer (render)),
|
|
|
|
gsk_texture_node_get_texture (node),
|
|
|
|
uploader);
|
|
|
|
case GSK_CAIRO_NODE:
|
|
|
|
surface = cairo_surface_reference (gsk_cairo_node_get_surface (node));
|
|
|
|
goto got_surface;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-17 05:38:36 +00:00
|
|
|
GSK_NOTE (FALLBACK, g_print ("Node as texture not implemented. Using %gx%g fallback surface\n",
|
|
|
|
ceil (bounds->size.width),
|
|
|
|
ceil (bounds->size.height)));
|
|
|
|
|
2016-12-30 05:46:34 +00:00
|
|
|
/* XXX: We could intersect bounds with clip bounds here */
|
|
|
|
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
|
|
|
ceil (bounds->size.width),
|
|
|
|
ceil (bounds->size.height));
|
|
|
|
cr = cairo_create (surface);
|
|
|
|
cairo_translate (cr, -bounds->origin.x, -bounds->origin.y);
|
|
|
|
|
|
|
|
gsk_render_node_draw (node, cr);
|
|
|
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
2016-12-31 21:58:15 +00:00
|
|
|
got_surface:
|
2016-12-30 05:46:34 +00:00
|
|
|
result = gsk_vulkan_image_new_from_data (uploader,
|
|
|
|
cairo_image_surface_get_data (surface),
|
|
|
|
cairo_image_surface_get_width (surface),
|
|
|
|
cairo_image_surface_get_height (surface),
|
|
|
|
cairo_image_surface_get_stride (surface));
|
|
|
|
|
|
|
|
cairo_surface_destroy (surface);
|
|
|
|
|
|
|
|
gsk_vulkan_render_add_cleanup_image (render, result);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-12-08 12:26:36 +00:00
|
|
|
static void
|
2016-12-16 05:10:24 +00:00
|
|
|
gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanOpRender *op,
|
|
|
|
GskVulkanRender *render,
|
2016-12-17 03:22:44 +00:00
|
|
|
GskVulkanUploader *uploader)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2016-12-21 10:21:38 +00:00
|
|
|
GskRenderNode *node;
|
2016-12-08 12:26:36 +00:00
|
|
|
cairo_surface_t *surface;
|
|
|
|
cairo_t *cr;
|
|
|
|
|
2016-12-21 10:21:38 +00:00
|
|
|
node = op->node;
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-23 20:36:17 +00:00
|
|
|
/* XXX: We could intersect bounds with clip bounds here */
|
2016-12-08 12:26:36 +00:00
|
|
|
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
2016-12-21 10:21:38 +00:00
|
|
|
ceil (node->bounds.size.width),
|
|
|
|
ceil (node->bounds.size.height));
|
2016-12-08 12:26:36 +00:00
|
|
|
cr = cairo_create (surface);
|
2016-12-21 10:21:38 +00:00
|
|
|
cairo_translate (cr, -node->bounds.origin.x, -node->bounds.origin.y);
|
|
|
|
|
2016-12-23 20:36:17 +00:00
|
|
|
if (op->type == GSK_VULKAN_OP_FALLBACK_CLIP)
|
|
|
|
{
|
|
|
|
cairo_rectangle (cr,
|
|
|
|
op->clip.bounds.origin.x, op->clip.bounds.origin.y,
|
|
|
|
op->clip.bounds.size.width, op->clip.bounds.size.height);
|
|
|
|
cairo_clip (cr);
|
|
|
|
}
|
|
|
|
else if (op->type == GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP)
|
|
|
|
{
|
|
|
|
gsk_rounded_rect_path (&op->clip, cr);
|
|
|
|
cairo_clip (cr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_assert (op->type == GSK_VULKAN_OP_FALLBACK);
|
|
|
|
}
|
|
|
|
|
2016-12-21 10:21:38 +00:00
|
|
|
gsk_render_node_draw (node, cr);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
2016-12-17 03:22:44 +00:00
|
|
|
op->source = gsk_vulkan_image_new_from_data (uploader,
|
2016-12-08 12:26:36 +00:00
|
|
|
cairo_image_surface_get_data (surface),
|
|
|
|
cairo_image_surface_get_width (surface),
|
|
|
|
cairo_image_surface_get_height (surface),
|
|
|
|
cairo_image_surface_get_stride (surface));
|
|
|
|
|
|
|
|
cairo_surface_destroy (surface);
|
|
|
|
|
|
|
|
gsk_vulkan_render_add_cleanup_image (render, op->source);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-12-16 05:10:24 +00:00
|
|
|
gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
2016-12-17 03:22:44 +00:00
|
|
|
GskVulkanUploader *uploader)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
GskVulkanOp *op;
|
2016-12-08 12:26:36 +00:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < self->render_ops->len; i++)
|
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
op = &g_array_index (self->render_ops, GskVulkanOp, i);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
|
|
|
switch (op->type)
|
|
|
|
{
|
|
|
|
case GSK_VULKAN_OP_FALLBACK:
|
2016-12-23 20:36:17 +00:00
|
|
|
case GSK_VULKAN_OP_FALLBACK_CLIP:
|
|
|
|
case GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP:
|
2016-12-17 03:22:44 +00:00
|
|
|
gsk_vulkan_render_pass_upload_fallback (self, &op->render, render, uploader);
|
2016-12-08 12:26:36 +00:00
|
|
|
break;
|
|
|
|
|
2016-12-09 04:59:19 +00:00
|
|
|
case GSK_VULKAN_OP_SURFACE:
|
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
cairo_surface_t *surface = gsk_cairo_node_get_surface (op->render.node);
|
2016-12-17 03:22:44 +00:00
|
|
|
op->render.source = gsk_vulkan_image_new_from_data (uploader,
|
2016-12-14 06:34:18 +00:00
|
|
|
cairo_image_surface_get_data (surface),
|
|
|
|
cairo_image_surface_get_width (surface),
|
|
|
|
cairo_image_surface_get_height (surface),
|
|
|
|
cairo_image_surface_get_stride (surface));
|
|
|
|
gsk_vulkan_render_add_cleanup_image (render, op->render.source);
|
2016-12-09 04:59:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_VULKAN_OP_TEXTURE:
|
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
op->render.source = gsk_vulkan_renderer_ref_texture_image (GSK_VULKAN_RENDERER (gsk_vulkan_render_get_renderer (render)),
|
|
|
|
gsk_texture_node_get_texture (op->render.node),
|
2016-12-17 03:22:44 +00:00
|
|
|
uploader);
|
2016-12-14 06:34:18 +00:00
|
|
|
gsk_vulkan_render_add_cleanup_image (render, op->render.source);
|
2016-12-09 04:59:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-12-30 05:46:34 +00:00
|
|
|
case GSK_VULKAN_OP_OPACITY:
|
|
|
|
{
|
|
|
|
GskRenderNode *child = gsk_opacity_node_get_child (op->render.node);
|
|
|
|
|
|
|
|
op->render.source = gsk_vulkan_render_pass_get_node_as_texture (self,
|
|
|
|
render,
|
|
|
|
uploader,
|
|
|
|
child,
|
|
|
|
&child->bounds);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-12-31 13:14:26 +00:00
|
|
|
case GSK_VULKAN_OP_COLOR_MATRIX:
|
|
|
|
{
|
|
|
|
GskRenderNode *child = gsk_color_matrix_node_get_child (op->render.node);
|
|
|
|
|
|
|
|
op->render.source = gsk_vulkan_render_pass_get_node_as_texture (self,
|
|
|
|
render,
|
|
|
|
uploader,
|
|
|
|
child,
|
|
|
|
&child->bounds);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-12-08 12:26:36 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
2016-12-14 08:40:15 +00:00
|
|
|
case GSK_VULKAN_OP_COLOR:
|
2016-12-26 16:11:13 +00:00
|
|
|
case GSK_VULKAN_OP_LINEAR_GRADIENT:
|
2016-12-14 06:21:21 +00:00
|
|
|
case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS:
|
2017-01-10 13:59:20 +00:00
|
|
|
case GSK_VULKAN_OP_BORDER:
|
2017-01-18 03:07:09 +00:00
|
|
|
case GSK_VULKAN_OP_INSET_SHADOW:
|
|
|
|
case GSK_VULKAN_OP_OUTSET_SHADOW:
|
2016-12-08 12:26:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gsize
|
2016-12-18 00:45:07 +00:00
|
|
|
gsk_vulkan_render_pass_count_vertex_data (GskVulkanRenderPass *self)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2016-12-18 00:45:07 +00:00
|
|
|
GskVulkanOp *op;
|
|
|
|
gsize n_bytes;
|
|
|
|
guint i;
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-18 00:45:07 +00:00
|
|
|
n_bytes = 0;
|
|
|
|
for (i = 0; i < self->render_ops->len; i++)
|
|
|
|
{
|
|
|
|
op = &g_array_index (self->render_ops, GskVulkanOp, i);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-18 00:45:07 +00:00
|
|
|
switch (op->type)
|
|
|
|
{
|
|
|
|
case GSK_VULKAN_OP_FALLBACK:
|
2016-12-23 20:36:17 +00:00
|
|
|
case GSK_VULKAN_OP_FALLBACK_CLIP:
|
|
|
|
case GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP:
|
2016-12-18 00:45:07 +00:00
|
|
|
case GSK_VULKAN_OP_SURFACE:
|
|
|
|
case GSK_VULKAN_OP_TEXTURE:
|
|
|
|
op->render.vertex_count = gsk_vulkan_blend_pipeline_count_vertex_data (GSK_VULKAN_BLEND_PIPELINE (op->render.pipeline));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
break;
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-18 01:18:01 +00:00
|
|
|
case GSK_VULKAN_OP_COLOR:
|
|
|
|
op->render.vertex_count = gsk_vulkan_color_pipeline_count_vertex_data (GSK_VULKAN_COLOR_PIPELINE (op->render.pipeline));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
break;
|
|
|
|
|
2016-12-26 16:11:13 +00:00
|
|
|
case GSK_VULKAN_OP_LINEAR_GRADIENT:
|
|
|
|
op->render.vertex_count = gsk_vulkan_linear_gradient_pipeline_count_vertex_data (GSK_VULKAN_LINEAR_GRADIENT_PIPELINE (op->render.pipeline));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
break;
|
|
|
|
|
2016-12-30 05:46:34 +00:00
|
|
|
case GSK_VULKAN_OP_OPACITY:
|
2016-12-31 13:14:26 +00:00
|
|
|
case GSK_VULKAN_OP_COLOR_MATRIX:
|
2016-12-30 05:46:34 +00:00
|
|
|
op->render.vertex_count = gsk_vulkan_effect_pipeline_count_vertex_data (GSK_VULKAN_EFFECT_PIPELINE (op->render.pipeline));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
break;
|
|
|
|
|
2017-01-10 13:59:20 +00:00
|
|
|
case GSK_VULKAN_OP_BORDER:
|
|
|
|
op->render.vertex_count = gsk_vulkan_border_pipeline_count_vertex_data (GSK_VULKAN_BORDER_PIPELINE (op->render.pipeline));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
break;
|
|
|
|
|
2017-01-18 03:07:09 +00:00
|
|
|
case GSK_VULKAN_OP_INSET_SHADOW:
|
|
|
|
case GSK_VULKAN_OP_OUTSET_SHADOW:
|
|
|
|
op->render.vertex_count = gsk_vulkan_box_shadow_pipeline_count_vertex_data (GSK_VULKAN_BOX_SHADOW_PIPELINE (op->render.pipeline));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
break;
|
|
|
|
|
2016-12-18 00:45:07 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-18 00:45:07 +00:00
|
|
|
return n_bytes;
|
2016-12-08 12:26:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gsize
|
2016-12-18 00:45:07 +00:00
|
|
|
gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
|
|
|
guchar *data,
|
|
|
|
gsize offset,
|
|
|
|
gsize total)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
GskVulkanOp *op;
|
2016-12-18 00:45:07 +00:00
|
|
|
gsize n_bytes;
|
2016-12-08 12:26:36 +00:00
|
|
|
guint i;
|
|
|
|
|
2016-12-18 00:45:07 +00:00
|
|
|
n_bytes = 0;
|
2016-12-08 12:26:36 +00:00
|
|
|
for (i = 0; i < self->render_ops->len; i++)
|
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
op = &g_array_index (self->render_ops, GskVulkanOp, i);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
|
|
|
switch (op->type)
|
|
|
|
{
|
|
|
|
case GSK_VULKAN_OP_FALLBACK:
|
2016-12-23 20:36:17 +00:00
|
|
|
case GSK_VULKAN_OP_FALLBACK_CLIP:
|
|
|
|
case GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP:
|
2016-12-09 04:59:19 +00:00
|
|
|
case GSK_VULKAN_OP_SURFACE:
|
|
|
|
case GSK_VULKAN_OP_TEXTURE:
|
2016-12-18 00:45:07 +00:00
|
|
|
{
|
|
|
|
op->render.vertex_offset = offset + n_bytes;
|
|
|
|
gsk_vulkan_blend_pipeline_collect_vertex_data (GSK_VULKAN_BLEND_PIPELINE (op->render.pipeline),
|
|
|
|
data + n_bytes + offset,
|
2016-12-21 17:15:50 +00:00
|
|
|
&op->render.node->bounds);
|
2016-12-18 00:45:07 +00:00
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
}
|
2016-12-08 12:26:36 +00:00
|
|
|
break;
|
|
|
|
|
2016-12-18 01:18:01 +00:00
|
|
|
case GSK_VULKAN_OP_COLOR:
|
|
|
|
{
|
|
|
|
op->render.vertex_offset = offset + n_bytes;
|
|
|
|
gsk_vulkan_color_pipeline_collect_vertex_data (GSK_VULKAN_COLOR_PIPELINE (op->render.pipeline),
|
|
|
|
data + n_bytes + offset,
|
2016-12-21 17:15:50 +00:00
|
|
|
&op->render.node->bounds,
|
2016-12-18 05:54:48 +00:00
|
|
|
gsk_color_node_peek_color (op->render.node));
|
2016-12-18 01:18:01 +00:00
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-12-26 16:11:13 +00:00
|
|
|
case GSK_VULKAN_OP_LINEAR_GRADIENT:
|
|
|
|
{
|
|
|
|
op->render.vertex_offset = offset + n_bytes;
|
|
|
|
gsk_vulkan_linear_gradient_pipeline_collect_vertex_data (GSK_VULKAN_LINEAR_GRADIENT_PIPELINE (op->render.pipeline),
|
|
|
|
data + n_bytes + offset,
|
|
|
|
&op->render.node->bounds,
|
|
|
|
gsk_linear_gradient_node_peek_start (op->render.node),
|
|
|
|
gsk_linear_gradient_node_peek_end (op->render.node),
|
|
|
|
gsk_render_node_get_node_type (op->render.node) == GSK_REPEATING_LINEAR_GRADIENT_NODE,
|
|
|
|
gsk_linear_gradient_node_get_n_color_stops (op->render.node),
|
|
|
|
gsk_linear_gradient_node_peek_color_stops (op->render.node));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-12-30 05:46:34 +00:00
|
|
|
case GSK_VULKAN_OP_OPACITY:
|
|
|
|
{
|
2016-12-31 12:24:21 +00:00
|
|
|
graphene_matrix_t color_matrix;
|
|
|
|
graphene_vec4_t color_offset;
|
|
|
|
graphene_matrix_init_from_float (&color_matrix,
|
|
|
|
(float[16]) {
|
|
|
|
1.0, 0.0, 0.0, 0.0,
|
|
|
|
0.0, 1.0, 0.0, 0.0,
|
|
|
|
0.0, 0.0, 1.0, 0.0,
|
|
|
|
0.0, 0.0, 0.0, gsk_opacity_node_get_opacity (op->render.node)
|
|
|
|
});
|
|
|
|
graphene_vec4_init (&color_offset, 0.0, 0.0, 0.0, 0.0);
|
2016-12-30 05:46:34 +00:00
|
|
|
op->render.vertex_offset = offset + n_bytes;
|
|
|
|
gsk_vulkan_effect_pipeline_collect_vertex_data (GSK_VULKAN_EFFECT_PIPELINE (op->render.pipeline),
|
|
|
|
data + n_bytes + offset,
|
|
|
|
&op->render.node->bounds,
|
2016-12-31 12:24:21 +00:00
|
|
|
&color_matrix,
|
|
|
|
&color_offset);
|
2016-12-30 05:46:34 +00:00
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-12-31 13:14:26 +00:00
|
|
|
case GSK_VULKAN_OP_COLOR_MATRIX:
|
|
|
|
{
|
|
|
|
op->render.vertex_offset = offset + n_bytes;
|
|
|
|
gsk_vulkan_effect_pipeline_collect_vertex_data (GSK_VULKAN_EFFECT_PIPELINE (op->render.pipeline),
|
|
|
|
data + n_bytes + offset,
|
|
|
|
&op->render.node->bounds,
|
|
|
|
gsk_color_matrix_node_peek_color_matrix (op->render.node),
|
|
|
|
gsk_color_matrix_node_peek_color_offset (op->render.node));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
}
|
|
|
|
break;
|
2016-12-30 05:46:34 +00:00
|
|
|
|
2017-01-10 13:59:20 +00:00
|
|
|
case GSK_VULKAN_OP_BORDER:
|
|
|
|
{
|
|
|
|
op->render.vertex_offset = offset + n_bytes;
|
|
|
|
gsk_vulkan_border_pipeline_collect_vertex_data (GSK_VULKAN_BORDER_PIPELINE (op->render.pipeline),
|
|
|
|
data + n_bytes + offset,
|
|
|
|
gsk_border_node_peek_outline (op->render.node),
|
|
|
|
gsk_border_node_peek_widths (op->render.node),
|
|
|
|
gsk_border_node_peek_colors (op->render.node));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-01-18 03:07:09 +00:00
|
|
|
case GSK_VULKAN_OP_INSET_SHADOW:
|
|
|
|
{
|
|
|
|
op->render.vertex_offset = offset + n_bytes;
|
|
|
|
gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GSK_VULKAN_BOX_SHADOW_PIPELINE (op->render.pipeline),
|
|
|
|
data + n_bytes + offset,
|
|
|
|
gsk_inset_shadow_node_peek_outline (op->render.node),
|
|
|
|
gsk_inset_shadow_node_peek_color (op->render.node),
|
|
|
|
gsk_inset_shadow_node_get_dx (op->render.node),
|
|
|
|
gsk_inset_shadow_node_get_dy (op->render.node),
|
|
|
|
gsk_inset_shadow_node_get_spread (op->render.node),
|
|
|
|
gsk_inset_shadow_node_get_blur_radius (op->render.node));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_VULKAN_OP_OUTSET_SHADOW:
|
|
|
|
{
|
|
|
|
op->render.vertex_offset = offset + n_bytes;
|
|
|
|
gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GSK_VULKAN_BOX_SHADOW_PIPELINE (op->render.pipeline),
|
|
|
|
data + n_bytes + offset,
|
|
|
|
gsk_outset_shadow_node_peek_outline (op->render.node),
|
|
|
|
gsk_outset_shadow_node_peek_color (op->render.node),
|
|
|
|
gsk_outset_shadow_node_get_dx (op->render.node),
|
|
|
|
gsk_outset_shadow_node_get_dy (op->render.node),
|
|
|
|
gsk_outset_shadow_node_get_spread (op->render.node),
|
|
|
|
gsk_outset_shadow_node_get_blur_radius (op->render.node));
|
|
|
|
n_bytes += op->render.vertex_count;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-12-08 12:26:36 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
2016-12-14 06:21:21 +00:00
|
|
|
case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS:
|
2016-12-14 06:34:18 +00:00
|
|
|
continue;
|
2016-12-08 12:26:36 +00:00
|
|
|
}
|
|
|
|
|
2016-12-18 00:45:07 +00:00
|
|
|
g_assert (n_bytes + offset <= total);
|
2016-12-08 12:26:36 +00:00
|
|
|
}
|
|
|
|
|
2016-12-18 00:45:07 +00:00
|
|
|
return n_bytes;
|
2016-12-08 12:26:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-12-09 01:55:47 +00:00
|
|
|
gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
GskVulkanOp *op;
|
2016-12-08 12:26:36 +00:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < self->render_ops->len; i++)
|
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
op = &g_array_index (self->render_ops, GskVulkanOp, i);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-09 01:55:47 +00:00
|
|
|
switch (op->type)
|
|
|
|
{
|
|
|
|
case GSK_VULKAN_OP_FALLBACK:
|
2016-12-23 20:36:17 +00:00
|
|
|
case GSK_VULKAN_OP_FALLBACK_CLIP:
|
|
|
|
case GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP:
|
2016-12-09 04:59:19 +00:00
|
|
|
case GSK_VULKAN_OP_SURFACE:
|
|
|
|
case GSK_VULKAN_OP_TEXTURE:
|
2016-12-30 05:46:34 +00:00
|
|
|
case GSK_VULKAN_OP_OPACITY:
|
2016-12-31 13:14:26 +00:00
|
|
|
case GSK_VULKAN_OP_COLOR_MATRIX:
|
2016-12-14 06:34:18 +00:00
|
|
|
op->render.descriptor_set_index = gsk_vulkan_render_reserve_descriptor_set (render, op->render.source);
|
2016-12-09 01:55:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
2016-12-14 08:40:15 +00:00
|
|
|
case GSK_VULKAN_OP_COLOR:
|
2016-12-26 16:11:13 +00:00
|
|
|
case GSK_VULKAN_OP_LINEAR_GRADIENT:
|
2016-12-14 06:21:21 +00:00
|
|
|
case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS:
|
2017-01-10 13:59:20 +00:00
|
|
|
case GSK_VULKAN_OP_BORDER:
|
2017-01-18 03:07:09 +00:00
|
|
|
case GSK_VULKAN_OP_INSET_SHADOW:
|
|
|
|
case GSK_VULKAN_OP_OUTSET_SHADOW:
|
2016-12-09 01:55:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-12-08 12:26:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-12-09 04:53:04 +00:00
|
|
|
gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
2016-12-18 00:45:07 +00:00
|
|
|
GskVulkanBuffer *vertex_buffer,
|
2016-12-14 07:00:58 +00:00
|
|
|
GskVulkanPipelineLayout *layout,
|
2016-12-09 04:53:04 +00:00
|
|
|
VkCommandBuffer command_buffer)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2016-12-14 08:40:15 +00:00
|
|
|
GskVulkanPipeline *current_pipeline = NULL;
|
2016-12-18 00:45:07 +00:00
|
|
|
gsize current_draw_index = 0;
|
2016-12-14 06:34:18 +00:00
|
|
|
GskVulkanOp *op;
|
2016-12-23 21:19:56 +00:00
|
|
|
guint i, step;
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-23 21:19:56 +00:00
|
|
|
for (i = 0; i < self->render_ops->len; i += step)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2016-12-14 06:34:18 +00:00
|
|
|
op = &g_array_index (self->render_ops, GskVulkanOp, i);
|
2016-12-23 21:19:56 +00:00
|
|
|
step = 1;
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-12 23:11:06 +00:00
|
|
|
switch (op->type)
|
|
|
|
{
|
|
|
|
case GSK_VULKAN_OP_FALLBACK:
|
2016-12-23 20:36:17 +00:00
|
|
|
case GSK_VULKAN_OP_FALLBACK_CLIP:
|
|
|
|
case GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP:
|
2016-12-12 23:11:06 +00:00
|
|
|
case GSK_VULKAN_OP_SURFACE:
|
|
|
|
case GSK_VULKAN_OP_TEXTURE:
|
2016-12-18 01:18:01 +00:00
|
|
|
if (current_pipeline != op->render.pipeline)
|
|
|
|
{
|
|
|
|
current_pipeline = op->render.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->render.vertex_offset });
|
|
|
|
current_draw_index = 0;
|
|
|
|
}
|
|
|
|
|
2016-12-12 23:11:06 +00:00
|
|
|
vkCmdBindDescriptorSets (command_buffer,
|
|
|
|
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
2016-12-14 07:00:58 +00:00
|
|
|
gsk_vulkan_pipeline_layout_get_pipeline_layout (layout),
|
2016-12-12 23:11:06 +00:00
|
|
|
0,
|
|
|
|
1,
|
|
|
|
(VkDescriptorSet[1]) {
|
2016-12-14 06:34:18 +00:00
|
|
|
gsk_vulkan_render_get_descriptor_set (render, op->render.descriptor_set_index)
|
2016-12-12 23:11:06 +00:00
|
|
|
},
|
|
|
|
0,
|
|
|
|
NULL);
|
2016-12-18 01:18:01 +00:00
|
|
|
|
|
|
|
current_draw_index += gsk_vulkan_blend_pipeline_draw (GSK_VULKAN_BLEND_PIPELINE (current_pipeline),
|
|
|
|
command_buffer,
|
|
|
|
current_draw_index, 1);
|
2016-12-30 05:46:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_VULKAN_OP_OPACITY:
|
2016-12-31 13:14:26 +00:00
|
|
|
case GSK_VULKAN_OP_COLOR_MATRIX:
|
2016-12-30 05:46:34 +00:00
|
|
|
if (current_pipeline != op->render.pipeline)
|
|
|
|
{
|
|
|
|
current_pipeline = op->render.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->render.vertex_offset });
|
|
|
|
current_draw_index = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
vkCmdBindDescriptorSets (command_buffer,
|
|
|
|
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
|
|
|
gsk_vulkan_pipeline_layout_get_pipeline_layout (layout),
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
(VkDescriptorSet[1]) {
|
|
|
|
gsk_vulkan_render_get_descriptor_set (render, op->render.descriptor_set_index)
|
|
|
|
},
|
|
|
|
0,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
current_draw_index += gsk_vulkan_effect_pipeline_draw (GSK_VULKAN_EFFECT_PIPELINE (current_pipeline),
|
|
|
|
command_buffer,
|
|
|
|
current_draw_index, 1);
|
2016-12-18 01:18:01 +00:00
|
|
|
break;
|
|
|
|
|
2016-12-14 08:40:15 +00:00
|
|
|
case GSK_VULKAN_OP_COLOR:
|
|
|
|
if (current_pipeline != op->render.pipeline)
|
|
|
|
{
|
|
|
|
current_pipeline = op->render.pipeline;
|
|
|
|
vkCmdBindPipeline (command_buffer,
|
|
|
|
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
|
|
|
gsk_vulkan_pipeline_get_pipeline (current_pipeline));
|
2016-12-18 00:45:07 +00:00
|
|
|
vkCmdBindVertexBuffers (command_buffer,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
(VkBuffer[1]) {
|
|
|
|
gsk_vulkan_buffer_get_buffer (vertex_buffer)
|
|
|
|
},
|
|
|
|
(VkDeviceSize[1]) { op->render.vertex_offset });
|
|
|
|
current_draw_index = 0;
|
2016-12-14 08:40:15 +00:00
|
|
|
}
|
2016-12-12 23:11:06 +00:00
|
|
|
|
2016-12-23 21:19:56 +00:00
|
|
|
for (step = 1; step + i < self->render_ops->len; step++)
|
|
|
|
{
|
2016-12-25 05:01:54 +00:00
|
|
|
GskVulkanOp *cmp = &g_array_index (self->render_ops, GskVulkanOp, i + step);
|
|
|
|
if (cmp->type != GSK_VULKAN_OP_COLOR ||
|
|
|
|
cmp->render.pipeline != current_pipeline)
|
2016-12-23 21:19:56 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-12-18 01:18:01 +00:00
|
|
|
current_draw_index += gsk_vulkan_color_pipeline_draw (GSK_VULKAN_COLOR_PIPELINE (current_pipeline),
|
2016-12-18 00:45:07 +00:00
|
|
|
command_buffer,
|
2016-12-23 21:19:56 +00:00
|
|
|
current_draw_index, step);
|
2016-12-12 23:11:06 +00:00
|
|
|
break;
|
|
|
|
|
2016-12-26 16:11:13 +00:00
|
|
|
case GSK_VULKAN_OP_LINEAR_GRADIENT:
|
|
|
|
if (current_pipeline != op->render.pipeline)
|
|
|
|
{
|
|
|
|
current_pipeline = op->render.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->render.vertex_offset });
|
|
|
|
current_draw_index = 0;
|
|
|
|
}
|
|
|
|
current_draw_index += gsk_vulkan_linear_gradient_pipeline_draw (GSK_VULKAN_LINEAR_GRADIENT_PIPELINE (current_pipeline),
|
|
|
|
command_buffer,
|
|
|
|
current_draw_index, 1);
|
|
|
|
break;
|
|
|
|
|
2017-01-10 13:59:20 +00:00
|
|
|
case GSK_VULKAN_OP_BORDER:
|
|
|
|
if (current_pipeline != op->render.pipeline)
|
|
|
|
{
|
|
|
|
current_pipeline = op->render.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->render.vertex_offset });
|
|
|
|
current_draw_index = 0;
|
|
|
|
}
|
|
|
|
current_draw_index += gsk_vulkan_border_pipeline_draw (GSK_VULKAN_BORDER_PIPELINE (current_pipeline),
|
|
|
|
command_buffer,
|
|
|
|
current_draw_index, 1);
|
|
|
|
break;
|
|
|
|
|
2017-01-18 03:07:09 +00:00
|
|
|
case GSK_VULKAN_OP_INSET_SHADOW:
|
|
|
|
case GSK_VULKAN_OP_OUTSET_SHADOW:
|
|
|
|
if (current_pipeline != op->render.pipeline)
|
|
|
|
{
|
|
|
|
current_pipeline = op->render.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->render.vertex_offset });
|
|
|
|
current_draw_index = 0;
|
|
|
|
}
|
|
|
|
current_draw_index += gsk_vulkan_box_shadow_pipeline_draw (GSK_VULKAN_BOX_SHADOW_PIPELINE (current_pipeline),
|
|
|
|
command_buffer,
|
|
|
|
current_draw_index, 1);
|
|
|
|
break;
|
|
|
|
|
2016-12-14 06:21:21 +00:00
|
|
|
case GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS:
|
2017-01-17 04:20:07 +00:00
|
|
|
gsk_vulkan_push_constants_push (&op->constants.constants,
|
|
|
|
command_buffer,
|
|
|
|
gsk_vulkan_pipeline_layout_get_pipeline_layout (layout));
|
2016-12-14 06:21:21 +00:00
|
|
|
break;
|
2016-12-12 23:11:06 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
2016-12-08 12:26:36 +00:00
|
|
|
}
|
|
|
|
}
|