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"
|
2017-09-26 01:02:21 +00:00
|
|
|
#include "gskprofilerprivate.h"
|
2016-12-23 20:36:17 +00:00
|
|
|
#include "gskrendernodeprivate.h"
|
|
|
|
#include "gskrenderer.h"
|
2017-09-26 01:02:21 +00:00
|
|
|
#include "gskrendererprivate.h"
|
2016-12-23 20:36:17 +00:00
|
|
|
#include "gskroundedrectprivate.h"
|
2019-03-01 05:35:55 +00:00
|
|
|
#include "gsktransform.h"
|
2023-07-01 04:14:48 +00:00
|
|
|
#include "gskvulkanblendmodeopprivate.h"
|
2023-07-02 04:30:10 +00:00
|
|
|
#include "gskvulkanbluropprivate.h"
|
2023-07-02 22:56:31 +00:00
|
|
|
#include "gskvulkanborderopprivate.h"
|
2016-12-23 20:36:17 +00:00
|
|
|
#include "gskvulkanclipprivate.h"
|
2023-06-25 21:04:43 +00:00
|
|
|
#include "gskvulkancolormatrixopprivate.h"
|
2023-06-29 04:58:55 +00:00
|
|
|
#include "gskvulkancoloropprivate.h"
|
2023-06-29 19:44:40 +00:00
|
|
|
#include "gskvulkancrossfadeopprivate.h"
|
2023-07-03 05:53:22 +00:00
|
|
|
#include "gskvulkanglyphopprivate.h"
|
2023-07-02 03:09:24 +00:00
|
|
|
#include "gskvulkaninsetshadowopprivate.h"
|
2023-07-03 01:15:59 +00:00
|
|
|
#include "gskvulkanlineargradientopprivate.h"
|
2023-06-24 02:00:02 +00:00
|
|
|
#include "gskvulkanopprivate.h"
|
2023-06-24 22:56:13 +00:00
|
|
|
#include "gskvulkanrendererprivate.h"
|
2016-12-08 12:26:36 +00:00
|
|
|
#include "gskvulkanimageprivate.h"
|
2023-06-25 21:04:43 +00:00
|
|
|
#include "gskvulkanoffscreenopprivate.h"
|
2023-07-02 03:09:24 +00:00
|
|
|
#include "gskvulkanoutsetshadowopprivate.h"
|
2023-07-03 13:47:53 +00:00
|
|
|
#include "gskvulkanpushconstantsopprivate.h"
|
2023-06-24 02:49:39 +00:00
|
|
|
#include "gskvulkanscissoropprivate.h"
|
2023-06-24 22:56:13 +00:00
|
|
|
#include "gskvulkantextureopprivate.h"
|
2023-06-25 23:38:50 +00:00
|
|
|
#include "gskvulkanuploadcairoopprivate.h"
|
2023-06-24 22:56:13 +00:00
|
|
|
#include "gskvulkanuploadopprivate.h"
|
2017-09-01 20:58:42 +00:00
|
|
|
#include "gskprivate.h"
|
|
|
|
|
2023-06-20 14:35:55 +00:00
|
|
|
#include "gdk/gdkvulkancontextprivate.h"
|
|
|
|
|
2023-06-23 02:40:05 +00:00
|
|
|
#define GDK_ARRAY_NAME gsk_vulkan_render_ops
|
|
|
|
#define GDK_ARRAY_TYPE_NAME GskVulkanRenderOps
|
|
|
|
#define GDK_ARRAY_ELEMENT_TYPE guchar
|
|
|
|
#define GDK_ARRAY_BY_VALUE 1
|
|
|
|
#include "gdk/gdkarrayimpl.c"
|
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
#define ORTHO_NEAR_PLANE -10000
|
|
|
|
#define ORTHO_FAR_PLANE 10000
|
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
typedef struct _GskVulkanParseState GskVulkanParseState;
|
|
|
|
|
2016-12-08 12:26:36 +00:00
|
|
|
struct _GskVulkanRenderPass
|
|
|
|
{
|
|
|
|
GdkVulkanContext *vulkan;
|
|
|
|
|
2023-06-23 02:40:05 +00:00
|
|
|
GskVulkanRenderOps render_ops;
|
2017-09-25 13:25:29 +00:00
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
GskVulkanImage *target;
|
|
|
|
graphene_rect_t viewport;
|
|
|
|
cairo_region_t *clip;
|
|
|
|
|
2023-05-10 00:46:57 +00:00
|
|
|
graphene_vec2_t scale;
|
2023-03-24 01:26:14 +00:00
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
VkRenderPass render_pass;
|
2023-06-17 16:53:33 +00:00
|
|
|
VkFramebuffer framebuffer;
|
2017-09-28 00:56:01 +00:00
|
|
|
VkSemaphore signal_semaphore;
|
|
|
|
GArray *wait_semaphores;
|
|
|
|
GskVulkanBuffer *vertex_data;
|
2016-12-08 12:26:36 +00:00
|
|
|
};
|
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
struct _GskVulkanParseState
|
|
|
|
{
|
2023-05-19 01:08:43 +00:00
|
|
|
cairo_rectangle_int_t scissor;
|
|
|
|
graphene_point_t offset;
|
|
|
|
graphene_vec2_t scale;
|
|
|
|
GskTransform *modelview;
|
|
|
|
graphene_matrix_t projection;
|
|
|
|
GskVulkanClip clip;
|
2023-05-11 21:38:12 +00:00
|
|
|
};
|
|
|
|
|
2023-05-09 20:30:49 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
static GQuark fallback_pixels_quark;
|
|
|
|
static GQuark texture_pixels_quark;
|
|
|
|
#endif
|
|
|
|
|
2016-12-08 12:26:36 +00:00
|
|
|
GskVulkanRenderPass *
|
2023-05-10 00:46:57 +00:00
|
|
|
gsk_vulkan_render_pass_new (GdkVulkanContext *context,
|
|
|
|
GskVulkanImage *target,
|
|
|
|
const graphene_vec2_t *scale,
|
|
|
|
const graphene_rect_t *viewport,
|
|
|
|
cairo_region_t *clip,
|
|
|
|
VkSemaphore signal_semaphore)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
|
|
|
GskVulkanRenderPass *self;
|
2017-09-28 00:56:01 +00:00
|
|
|
VkImageLayout final_layout;
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2023-03-03 11:48:49 +00:00
|
|
|
self = g_new0 (GskVulkanRenderPass, 1);
|
2016-12-08 12:26:36 +00:00
|
|
|
self->vulkan = g_object_ref (context);
|
2023-06-23 02:40:05 +00:00
|
|
|
gsk_vulkan_render_ops_init (&self->render_ops);
|
2017-09-28 00:56:01 +00:00
|
|
|
|
|
|
|
self->target = g_object_ref (target);
|
|
|
|
self->clip = cairo_region_copy (clip);
|
2017-09-29 19:45:37 +00:00
|
|
|
self->viewport = *viewport;
|
2023-05-10 00:46:57 +00:00
|
|
|
graphene_vec2_init_from_vec2 (&self->scale, scale);
|
2017-09-28 00:56:01 +00:00
|
|
|
|
|
|
|
if (signal_semaphore != VK_NULL_HANDLE) // this is a dependent pass
|
|
|
|
final_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
|
|
|
else
|
|
|
|
final_layout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
|
|
|
GSK_VK_CHECK (vkCreateRenderPass, gdk_vulkan_context_get_device (self->vulkan),
|
|
|
|
&(VkRenderPassCreateInfo) {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
|
|
|
|
.attachmentCount = 1,
|
|
|
|
.pAttachments = (VkAttachmentDescription[]) {
|
|
|
|
{
|
2023-06-17 14:05:09 +00:00
|
|
|
.format = gsk_vulkan_image_get_vk_format (target),
|
2017-09-28 00:56:01 +00:00
|
|
|
.samples = VK_SAMPLE_COUNT_1_BIT,
|
|
|
|
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
|
|
|
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
2022-05-08 05:08:03 +00:00
|
|
|
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
2017-09-28 00:56:01 +00:00
|
|
|
.finalLayout = final_layout
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.subpassCount = 1,
|
|
|
|
.pSubpasses = (VkSubpassDescription []) {
|
|
|
|
{
|
|
|
|
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
|
|
|
|
.inputAttachmentCount = 0,
|
|
|
|
.colorAttachmentCount = 1,
|
|
|
|
.pColorAttachments = (VkAttachmentReference []) {
|
|
|
|
{
|
|
|
|
.attachment = 0,
|
|
|
|
.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.pResolveAttachments = (VkAttachmentReference []) {
|
|
|
|
{
|
|
|
|
.attachment = VK_ATTACHMENT_UNUSED,
|
|
|
|
.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.pDepthStencilAttachment = NULL,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
.dependencyCount = 0
|
|
|
|
},
|
|
|
|
NULL,
|
|
|
|
&self->render_pass);
|
|
|
|
|
2023-06-17 16:53:33 +00:00
|
|
|
GSK_VK_CHECK (vkCreateFramebuffer, gdk_vulkan_context_get_device (self->vulkan),
|
|
|
|
&(VkFramebufferCreateInfo) {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
|
|
|
|
.renderPass = self->render_pass,
|
|
|
|
.attachmentCount = 1,
|
|
|
|
.pAttachments = (VkImageView[1]) {
|
|
|
|
gsk_vulkan_image_get_image_view (target)
|
|
|
|
},
|
|
|
|
.width = gsk_vulkan_image_get_width (target),
|
|
|
|
.height = gsk_vulkan_image_get_height (target),
|
|
|
|
.layers = 1
|
|
|
|
},
|
|
|
|
NULL,
|
|
|
|
&self->framebuffer);
|
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
self->signal_semaphore = signal_semaphore;
|
|
|
|
self->wait_semaphores = g_array_new (FALSE, FALSE, sizeof (VkSemaphore));
|
|
|
|
self->vertex_data = NULL;
|
|
|
|
|
2017-09-26 01:02:21 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
2023-05-09 20:30:49 +00:00
|
|
|
if (fallback_pixels_quark == 0)
|
|
|
|
{
|
|
|
|
fallback_pixels_quark = g_quark_from_static_string ("fallback-pixels");
|
|
|
|
texture_pixels_quark = g_quark_from_static_string ("texture-pixels");
|
|
|
|
}
|
2017-09-26 01:02:21 +00:00
|
|
|
#endif
|
2016-12-08 12:26:36 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gsk_vulkan_render_pass_free (GskVulkanRenderPass *self)
|
|
|
|
{
|
2023-06-17 16:53:33 +00:00
|
|
|
VkDevice device = gdk_vulkan_context_get_device (self->vulkan);
|
2023-06-24 20:29:47 +00:00
|
|
|
GskVulkanOp *op;
|
|
|
|
gsize i;
|
2023-06-17 16:53:33 +00:00
|
|
|
|
2023-06-24 20:29:47 +00:00
|
|
|
for (i = 0; i < gsk_vulkan_render_ops_get_size (&self->render_ops); i += op->op_class->size)
|
|
|
|
{
|
|
|
|
op = (GskVulkanOp *) gsk_vulkan_render_ops_index (&self->render_ops, i);
|
|
|
|
|
|
|
|
gsk_vulkan_op_finish (op);
|
|
|
|
}
|
2023-06-23 02:40:05 +00:00
|
|
|
gsk_vulkan_render_ops_clear (&self->render_ops);
|
2023-06-24 20:29:47 +00:00
|
|
|
|
2016-12-08 12:26:36 +00:00
|
|
|
g_object_unref (self->vulkan);
|
2017-09-28 00:56:01 +00:00
|
|
|
g_object_unref (self->target);
|
|
|
|
cairo_region_destroy (self->clip);
|
2023-06-17 16:53:33 +00:00
|
|
|
vkDestroyFramebuffer (device, self->framebuffer, NULL);
|
|
|
|
vkDestroyRenderPass (device, self->render_pass, NULL);
|
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
if (self->vertex_data)
|
|
|
|
gsk_vulkan_buffer_free (self->vertex_data);
|
|
|
|
if (self->signal_semaphore != VK_NULL_HANDLE)
|
2023-06-17 16:53:33 +00:00
|
|
|
vkDestroySemaphore (device, self->signal_semaphore, NULL);
|
2017-09-28 00:56:01 +00:00
|
|
|
g_array_unref (self->wait_semaphores);
|
|
|
|
|
2023-03-03 11:48:49 +00:00
|
|
|
g_free (self);
|
2016-12-08 12:26:36 +00:00
|
|
|
}
|
|
|
|
|
2023-06-24 02:49:39 +00:00
|
|
|
static inline gsize
|
|
|
|
round_up (gsize number, gsize divisor)
|
|
|
|
{
|
|
|
|
return (number + divisor - 1) / divisor * divisor;
|
|
|
|
}
|
|
|
|
|
2023-06-28 02:30:35 +00:00
|
|
|
gpointer
|
2023-06-24 02:09:56 +00:00
|
|
|
gsk_vulkan_render_pass_alloc_op (GskVulkanRenderPass *self,
|
|
|
|
gsize size)
|
|
|
|
{
|
|
|
|
gsize pos;
|
|
|
|
|
|
|
|
pos = gsk_vulkan_render_ops_get_size (&self->render_ops);
|
|
|
|
|
|
|
|
gsk_vulkan_render_ops_splice (&self->render_ops,
|
|
|
|
pos,
|
|
|
|
0, FALSE,
|
|
|
|
NULL,
|
|
|
|
size);
|
|
|
|
|
|
|
|
return gsk_vulkan_render_ops_index (&self->render_ops, pos);
|
|
|
|
}
|
|
|
|
|
2023-05-19 01:08:43 +00:00
|
|
|
static void
|
|
|
|
gsk_vulkan_render_pass_append_scissor (GskVulkanRenderPass *self,
|
|
|
|
GskRenderNode *node,
|
|
|
|
const GskVulkanParseState *state)
|
|
|
|
{
|
2023-06-28 02:30:35 +00:00
|
|
|
gsk_vulkan_scissor_op (self, &state->scissor);
|
2023-05-19 01:08:43 +00:00
|
|
|
}
|
|
|
|
|
2023-05-11 20:09:12 +00:00
|
|
|
static void
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_append_push_constants (GskVulkanRenderPass *self,
|
|
|
|
GskRenderNode *node,
|
|
|
|
const GskVulkanParseState *state)
|
2023-05-11 20:09:12 +00:00
|
|
|
{
|
2023-07-03 13:47:53 +00:00
|
|
|
graphene_matrix_t mvp;
|
2023-05-11 20:09:12 +00:00
|
|
|
|
2023-05-12 02:18:59 +00:00
|
|
|
if (state->modelview)
|
|
|
|
{
|
2023-07-03 13:47:53 +00:00
|
|
|
gsk_transform_to_matrix (state->modelview, &mvp);
|
|
|
|
graphene_matrix_multiply (&mvp, &state->projection, &mvp);
|
2023-05-12 02:18:59 +00:00
|
|
|
}
|
|
|
|
else
|
2023-07-03 13:47:53 +00:00
|
|
|
graphene_matrix_init_from_matrix (&mvp, &state->projection);
|
2023-05-12 02:18:59 +00:00
|
|
|
|
2023-07-03 13:47:53 +00:00
|
|
|
gsk_vulkan_push_constants_op (self, &state->scale, &mvp, &state->clip.rect);
|
2023-05-11 20:09:12 +00:00
|
|
|
}
|
|
|
|
|
2016-12-23 23:52:07 +00:00
|
|
|
#define FALLBACK(...) G_STMT_START { \
|
2022-09-23 01:36:50 +00:00
|
|
|
GSK_RENDERER_DEBUG (gsk_vulkan_render_get_renderer (render), FALLBACK, __VA_ARGS__); \
|
2023-03-31 17:00:33 +00:00
|
|
|
return FALSE; \
|
2016-12-23 23:52:07 +00:00
|
|
|
}G_STMT_END
|
|
|
|
|
2023-06-25 21:04:43 +00:00
|
|
|
static GskVulkanImage *
|
|
|
|
gsk_vulkan_render_pass_get_node_as_image (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node,
|
|
|
|
graphene_rect_t *tex_bounds)
|
|
|
|
{
|
|
|
|
VkSemaphore semaphore;
|
|
|
|
GskVulkanImage *result;
|
|
|
|
|
|
|
|
switch ((guint) gsk_render_node_get_node_type (node))
|
|
|
|
{
|
|
|
|
case GSK_TEXTURE_NODE:
|
|
|
|
{
|
|
|
|
GdkTexture *texture = gsk_texture_node_get_texture (node);
|
|
|
|
GskVulkanRenderer *renderer = GSK_VULKAN_RENDERER (gsk_vulkan_render_get_renderer (render));
|
|
|
|
result = gsk_vulkan_renderer_get_texture_image (renderer, texture);
|
|
|
|
if (result == NULL)
|
|
|
|
{
|
2023-06-28 02:30:35 +00:00
|
|
|
result = gsk_vulkan_upload_op (self, self->vulkan, texture);
|
2023-06-25 21:04:43 +00:00
|
|
|
gsk_vulkan_renderer_add_texture_image (renderer, texture, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
*tex_bounds = node->bounds;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-06-25 23:38:50 +00:00
|
|
|
case GSK_CAIRO_NODE:
|
|
|
|
{
|
|
|
|
graphene_rect_t clipped;
|
|
|
|
|
|
|
|
graphene_rect_offset_r (&state->clip.rect.bounds, - state->offset.x, - state->offset.y, &clipped);
|
|
|
|
graphene_rect_intersection (&clipped, &node->bounds, &clipped);
|
|
|
|
|
|
|
|
if (clipped.size.width == 0 || clipped.size.height == 0)
|
|
|
|
return NULL;
|
|
|
|
|
2023-06-28 02:30:35 +00:00
|
|
|
result = gsk_vulkan_upload_cairo_op (self,
|
|
|
|
self->vulkan,
|
|
|
|
node,
|
|
|
|
&state->scale,
|
|
|
|
&clipped);
|
2023-06-25 23:38:50 +00:00
|
|
|
|
|
|
|
*tex_bounds = clipped;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-06-25 21:04:43 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
graphene_rect_t clipped;
|
|
|
|
|
|
|
|
graphene_rect_offset_r (&state->clip.rect.bounds, - state->offset.x, - state->offset.y, &clipped);
|
|
|
|
graphene_rect_intersection (&clipped, &node->bounds, &clipped);
|
|
|
|
|
|
|
|
if (clipped.size.width == 0 || clipped.size.height == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* assuming the unclipped bounds should go to texture coordinates 0..1,
|
|
|
|
* calculate the coordinates for the clipped texture size
|
|
|
|
*/
|
|
|
|
*tex_bounds = clipped;
|
|
|
|
|
|
|
|
vkCreateSemaphore (gdk_vulkan_context_get_device (self->vulkan),
|
|
|
|
&(VkSemaphoreCreateInfo) {
|
|
|
|
VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
|
|
|
|
NULL,
|
|
|
|
0
|
|
|
|
},
|
|
|
|
NULL,
|
|
|
|
&semaphore);
|
|
|
|
g_array_append_val (self->wait_semaphores, semaphore);
|
|
|
|
|
2023-06-28 02:30:35 +00:00
|
|
|
result = gsk_vulkan_offscreen_op (self,
|
|
|
|
self->vulkan,
|
|
|
|
render,
|
|
|
|
&state->scale,
|
|
|
|
&clipped,
|
|
|
|
semaphore,
|
|
|
|
node);
|
2023-06-25 21:04:43 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 16:27:24 +00:00
|
|
|
static void
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_fallback_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2023-06-25 23:40:45 +00:00
|
|
|
GskVulkanImage *image;
|
|
|
|
graphene_rect_t clipped;
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2023-06-25 23:40:45 +00:00
|
|
|
graphene_rect_offset_r (&state->clip.rect.bounds, - state->offset.x, - state->offset.y, &clipped);
|
|
|
|
graphene_rect_intersection (&clipped, &node->bounds, &clipped);
|
2017-09-30 02:41:00 +00:00
|
|
|
|
2023-06-25 23:40:45 +00:00
|
|
|
if (clipped.size.width == 0 || clipped.size.height == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
2023-06-28 02:30:35 +00:00
|
|
|
image = gsk_vulkan_upload_cairo_op (self,
|
|
|
|
self->vulkan,
|
|
|
|
node,
|
|
|
|
&state->scale,
|
|
|
|
&clipped);
|
2023-06-25 23:40:45 +00:00
|
|
|
|
2023-06-28 02:30:35 +00:00
|
|
|
gsk_vulkan_texture_op (self,
|
2023-06-29 04:36:17 +00:00
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
2023-06-28 02:30:35 +00:00
|
|
|
image,
|
|
|
|
GSK_VULKAN_SAMPLER_DEFAULT,
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
&clipped);
|
2017-09-23 05:59:50 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-22 18:20:57 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_implode (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return TRUE;
|
|
|
|
}
|
2017-01-18 03:07:09 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_container_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
|
|
|
for (guint i = 0; i < gsk_container_node_get_n_children (node); i++)
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (self, render, state, gsk_container_node_get_child (node, i));
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_cairo_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
|
|
|
/* We're using recording surfaces, so drawing them to an image
|
|
|
|
* surface and uploading them is the right thing.
|
|
|
|
* But that's exactly what the fallback code does.
|
|
|
|
*/
|
|
|
|
if (gsk_cairo_node_get_surface (node) != NULL)
|
2023-05-11 21:38:12 +00:00
|
|
|
return gsk_vulkan_render_pass_add_fallback_node (self, render, state, node);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_color_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-06-29 04:58:55 +00:00
|
|
|
gsk_vulkan_color_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
gsk_color_node_get_color (node));
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-06-08 10:03:48 +00:00
|
|
|
gsk_vulkan_render_pass_add_linear_gradient_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-07-03 01:15:59 +00:00
|
|
|
gsk_vulkan_linear_gradient_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
gsk_linear_gradient_node_get_start (node),
|
|
|
|
gsk_linear_gradient_node_get_end (node),
|
|
|
|
gsk_render_node_get_node_type (node) == GSK_REPEATING_LINEAR_GRADIENT_NODE,
|
|
|
|
gsk_linear_gradient_node_get_color_stops (node, NULL),
|
|
|
|
gsk_linear_gradient_node_get_n_color_stops (node));
|
2023-03-31 17:00:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_border_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-07-02 22:56:31 +00:00
|
|
|
gsk_vulkan_border_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
|
|
|
gsk_border_node_get_outline (node),
|
|
|
|
&state->offset,
|
|
|
|
gsk_border_node_get_widths (node),
|
|
|
|
gsk_border_node_get_colors (node));
|
2023-03-31 17:00:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_texture_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-06-24 22:56:13 +00:00
|
|
|
GskVulkanImage *image;
|
|
|
|
GskVulkanRenderer *renderer;
|
|
|
|
GdkTexture *texture;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-06-24 22:56:13 +00:00
|
|
|
renderer = GSK_VULKAN_RENDERER (gsk_vulkan_render_get_renderer (render));
|
|
|
|
texture = gsk_texture_node_get_texture (node);
|
|
|
|
image = gsk_vulkan_renderer_get_texture_image (renderer, texture);
|
|
|
|
if (image == NULL)
|
|
|
|
{
|
2023-06-28 02:30:35 +00:00
|
|
|
image = gsk_vulkan_upload_op (self, self->vulkan, texture);
|
2023-06-24 22:56:13 +00:00
|
|
|
gsk_vulkan_renderer_add_texture_image (renderer, texture, image);
|
|
|
|
}
|
|
|
|
|
2023-06-28 02:30:35 +00:00
|
|
|
gsk_vulkan_texture_op (self,
|
2023-06-29 04:36:17 +00:00
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
2023-06-28 02:30:35 +00:00
|
|
|
image,
|
|
|
|
GSK_VULKAN_SAMPLER_DEFAULT,
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
&node->bounds);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-05-23 03:26:08 +00:00
|
|
|
static inline gboolean
|
|
|
|
gsk_vulkan_render_pass_add_texture_scale_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
|
|
|
{
|
2023-06-25 03:25:01 +00:00
|
|
|
GskVulkanImage *image;
|
|
|
|
GskVulkanRenderer *renderer;
|
|
|
|
GskVulkanRenderSampler sampler;
|
|
|
|
GdkTexture *texture;
|
2023-05-23 03:26:08 +00:00
|
|
|
|
2023-06-25 03:25:01 +00:00
|
|
|
renderer = GSK_VULKAN_RENDERER (gsk_vulkan_render_get_renderer (render));
|
|
|
|
texture = gsk_texture_scale_node_get_texture (node);
|
|
|
|
switch (gsk_texture_scale_node_get_filter (node))
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
case GSK_SCALING_FILTER_LINEAR:
|
|
|
|
case GSK_SCALING_FILTER_TRILINEAR:
|
|
|
|
sampler = GSK_VULKAN_SAMPLER_DEFAULT;
|
|
|
|
break;
|
|
|
|
case GSK_SCALING_FILTER_NEAREST:
|
|
|
|
sampler = GSK_VULKAN_SAMPLER_NEAREST;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
image = gsk_vulkan_renderer_get_texture_image (renderer, texture);
|
|
|
|
if (image == NULL)
|
|
|
|
{
|
2023-06-28 02:30:35 +00:00
|
|
|
image = gsk_vulkan_upload_op (self, self->vulkan, texture);
|
2023-06-25 03:25:01 +00:00
|
|
|
gsk_vulkan_renderer_add_texture_image (renderer, texture, image);
|
|
|
|
}
|
|
|
|
|
2023-06-28 02:30:35 +00:00
|
|
|
gsk_vulkan_texture_op (self,
|
2023-06-29 04:36:17 +00:00
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
2023-06-28 02:30:35 +00:00
|
|
|
image,
|
|
|
|
sampler,
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
&node->bounds);
|
2023-05-23 03:26:08 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_inset_shadow_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
|
|
|
if (gsk_inset_shadow_node_get_blur_radius (node) > 0)
|
|
|
|
FALLBACK ("Blur support not implemented for inset shadows");
|
|
|
|
|
2023-07-02 03:09:24 +00:00
|
|
|
gsk_vulkan_inset_shadow_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
|
|
|
gsk_inset_shadow_node_get_outline (node),
|
|
|
|
&state->offset,
|
|
|
|
gsk_inset_shadow_node_get_color (node),
|
|
|
|
&GRAPHENE_POINT_INIT (gsk_inset_shadow_node_get_dx (node),
|
|
|
|
gsk_inset_shadow_node_get_dy (node)),
|
|
|
|
gsk_inset_shadow_node_get_spread (node),
|
|
|
|
gsk_inset_shadow_node_get_blur_radius (node));
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2023-02-08 03:52:06 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_outset_shadow_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
|
|
|
if (gsk_outset_shadow_node_get_blur_radius (node) > 0)
|
|
|
|
FALLBACK ("Blur support not implemented for outset shadows");
|
|
|
|
|
2023-07-02 03:09:24 +00:00
|
|
|
gsk_vulkan_outset_shadow_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
|
|
|
gsk_outset_shadow_node_get_outline (node),
|
|
|
|
&state->offset,
|
|
|
|
gsk_outset_shadow_node_get_color (node),
|
|
|
|
&GRAPHENE_POINT_INIT (gsk_outset_shadow_node_get_dx (node),
|
|
|
|
gsk_outset_shadow_node_get_dy (node)),
|
|
|
|
gsk_outset_shadow_node_get_spread (node),
|
|
|
|
gsk_outset_shadow_node_get_blur_radius (node));
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
|
|
|
GskRenderNode *child;
|
2023-03-24 01:30:12 +00:00
|
|
|
GskTransform *transform;
|
2023-05-11 21:38:12 +00:00
|
|
|
GskVulkanParseState new_state;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-10 14:40:22 +00:00
|
|
|
child = gsk_transform_node_get_child (node);
|
2023-03-24 01:30:12 +00:00
|
|
|
transform = gsk_transform_node_get_transform (node);
|
|
|
|
|
|
|
|
switch (gsk_transform_get_category (transform))
|
|
|
|
{
|
|
|
|
case GSK_TRANSFORM_CATEGORY_IDENTITY:
|
|
|
|
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
|
2023-05-10 14:40:22 +00:00
|
|
|
{
|
|
|
|
float dx, dy;
|
|
|
|
gsk_transform_to_translate (transform, &dx, &dy);
|
2023-05-12 00:51:50 +00:00
|
|
|
new_state = *state;
|
|
|
|
new_state.offset.x += dx;
|
|
|
|
new_state.offset.y += dy;
|
|
|
|
gsk_vulkan_render_pass_add_node (self, render, &new_state, child);
|
2023-05-10 14:40:22 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
2023-03-24 01:30:12 +00:00
|
|
|
|
|
|
|
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
|
|
|
|
{
|
2023-05-12 03:15:28 +00:00
|
|
|
float dx, dy, scale_x, scale_y;
|
2023-05-10 00:46:57 +00:00
|
|
|
gsk_transform_to_affine (transform, &scale_x, &scale_y, &dx, &dy);
|
2023-05-12 03:15:28 +00:00
|
|
|
gsk_vulkan_clip_scale (&new_state.clip, &state->clip, scale_x, scale_y);
|
|
|
|
new_state.offset.x = (state->offset.x + dx) / scale_x;
|
|
|
|
new_state.offset.y = (state->offset.y + dy) / scale_y;
|
2023-05-12 18:49:31 +00:00
|
|
|
graphene_vec2_init (&new_state.scale, fabs (scale_x), fabs (scale_y));
|
2023-05-12 03:15:28 +00:00
|
|
|
graphene_vec2_multiply (&new_state.scale, &state->scale, &new_state.scale);
|
2023-05-12 18:49:31 +00:00
|
|
|
new_state.modelview = gsk_transform_scale (gsk_transform_ref (state->modelview),
|
|
|
|
scale_x / fabs (scale_x),
|
|
|
|
scale_y / fabs (scale_y));
|
2023-03-24 01:30:12 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_TRANSFORM_CATEGORY_2D:
|
|
|
|
{
|
2023-05-12 03:15:28 +00:00
|
|
|
float skew_x, skew_y, scale_x, scale_y, angle, dx, dy;
|
|
|
|
GskTransform *clip_transform;
|
|
|
|
|
|
|
|
clip_transform = gsk_transform_transform (gsk_transform_translate (NULL, &state->offset), transform);
|
|
|
|
|
2023-05-17 23:18:38 +00:00
|
|
|
if (gsk_vulkan_clip_contains_rect (&state->clip, &state->offset, &node->bounds))
|
|
|
|
{
|
|
|
|
gsk_vulkan_clip_init_empty (&new_state.clip, &child->bounds);
|
|
|
|
}
|
|
|
|
else if (!gsk_vulkan_clip_transform (&new_state.clip, &state->clip, clip_transform, &child->bounds))
|
2023-05-12 03:15:28 +00:00
|
|
|
{
|
|
|
|
gsk_transform_unref (clip_transform);
|
|
|
|
FALLBACK ("Transform nodes can't deal with clip type %u", state->clip.type);
|
|
|
|
}
|
|
|
|
|
|
|
|
new_state.modelview = gsk_transform_ref (state->modelview);
|
|
|
|
new_state.modelview = gsk_transform_scale (state->modelview,
|
|
|
|
graphene_vec2_get_x (&state->scale),
|
|
|
|
graphene_vec2_get_y (&state->scale));
|
|
|
|
new_state.modelview = gsk_transform_transform (new_state.modelview, clip_transform);
|
|
|
|
gsk_transform_unref (clip_transform);
|
|
|
|
|
|
|
|
gsk_transform_to_2d_components (new_state.modelview,
|
|
|
|
&skew_x, &skew_y,
|
|
|
|
&scale_x, &scale_y,
|
|
|
|
&angle,
|
|
|
|
&dx, &dy);
|
|
|
|
scale_x = fabs (scale_x);
|
|
|
|
scale_y = fabs (scale_y);
|
|
|
|
new_state.modelview = gsk_transform_scale (new_state.modelview, 1 / scale_x, 1 / scale_y);
|
|
|
|
graphene_vec2_init (&new_state.scale, scale_x, scale_y);
|
|
|
|
new_state.offset = *graphene_point_zero ();
|
2023-03-24 01:30:12 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
|
|
|
|
case GSK_TRANSFORM_CATEGORY_ANY:
|
|
|
|
case GSK_TRANSFORM_CATEGORY_3D:
|
|
|
|
{
|
|
|
|
graphene_quaternion_t rotation;
|
2023-05-12 02:18:59 +00:00
|
|
|
graphene_matrix_t matrix;
|
2023-03-24 01:30:12 +00:00
|
|
|
graphene_vec4_t perspective;
|
|
|
|
graphene_vec3_t translation;
|
2023-05-10 00:46:57 +00:00
|
|
|
graphene_vec3_t matrix_scale;
|
2023-03-24 01:30:12 +00:00
|
|
|
graphene_vec3_t shear;
|
2023-05-12 03:15:28 +00:00
|
|
|
GskTransform *clip_transform;
|
2023-06-04 17:16:04 +00:00
|
|
|
float scale_x, scale_y, old_pixels, new_pixels;
|
2023-05-12 03:15:28 +00:00
|
|
|
|
|
|
|
clip_transform = gsk_transform_transform (gsk_transform_translate (NULL, &state->offset), transform);
|
|
|
|
|
2023-05-17 23:18:38 +00:00
|
|
|
if (gsk_vulkan_clip_contains_rect (&state->clip, &state->offset, &node->bounds))
|
|
|
|
{
|
|
|
|
gsk_vulkan_clip_init_empty (&new_state.clip, &child->bounds);
|
|
|
|
}
|
|
|
|
else if (!gsk_vulkan_clip_transform (&new_state.clip, &state->clip, clip_transform, &child->bounds))
|
2023-05-12 03:15:28 +00:00
|
|
|
{
|
|
|
|
gsk_transform_unref (clip_transform);
|
|
|
|
FALLBACK ("Transform nodes can't deal with clip type %u", state->clip.type);
|
|
|
|
}
|
|
|
|
|
|
|
|
new_state.modelview = gsk_transform_ref (state->modelview);
|
|
|
|
new_state.modelview = gsk_transform_scale (state->modelview,
|
|
|
|
graphene_vec2_get_x (&state->scale),
|
|
|
|
graphene_vec2_get_y (&state->scale));
|
|
|
|
new_state.modelview = gsk_transform_transform (new_state.modelview, clip_transform);
|
|
|
|
gsk_transform_unref (clip_transform);
|
2023-03-24 01:30:12 +00:00
|
|
|
|
2023-05-12 03:15:28 +00:00
|
|
|
gsk_transform_to_matrix (new_state.modelview, &matrix);
|
2023-03-24 01:30:12 +00:00
|
|
|
graphene_matrix_decompose (&matrix,
|
|
|
|
&translation,
|
2023-05-10 00:46:57 +00:00
|
|
|
&matrix_scale,
|
2023-03-24 01:30:12 +00:00
|
|
|
&rotation,
|
|
|
|
&shear,
|
|
|
|
&perspective);
|
|
|
|
|
2023-05-12 03:15:28 +00:00
|
|
|
scale_x = fabs (graphene_vec3_get_x (&matrix_scale));
|
|
|
|
scale_y = fabs (graphene_vec3_get_y (&matrix_scale));
|
2023-06-04 17:16:04 +00:00
|
|
|
old_pixels = graphene_vec2_get_x (&state->scale) * graphene_vec2_get_y (&state->scale) *
|
|
|
|
state->clip.rect.bounds.size.width * state->clip.rect.bounds.size.height;
|
|
|
|
new_pixels = scale_x * scale_y * new_state.clip.rect.bounds.size.width * new_state.clip.rect.bounds.size.height;
|
|
|
|
if (new_pixels > 2 * old_pixels)
|
|
|
|
{
|
|
|
|
float forced_downscale = 2 * old_pixels / new_pixels;
|
|
|
|
scale_x *= forced_downscale;
|
|
|
|
scale_y *= forced_downscale;
|
|
|
|
}
|
2023-05-12 03:15:28 +00:00
|
|
|
new_state.modelview = gsk_transform_scale (new_state.modelview, 1 / scale_x, 1 / scale_y);
|
|
|
|
graphene_vec2_init (&new_state.scale, scale_x, scale_y);
|
|
|
|
new_state.offset = *graphene_point_zero ();
|
2023-03-24 01:30:12 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-05-19 01:08:43 +00:00
|
|
|
new_state.scissor = state->scissor;
|
2023-05-12 02:09:13 +00:00
|
|
|
graphene_matrix_init_from_matrix (&new_state.projection, &state->projection);
|
2023-05-11 21:38:12 +00:00
|
|
|
|
|
|
|
gsk_vulkan_render_pass_append_push_constants (self, node, &new_state);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (self, render, &new_state, child);
|
2023-03-24 01:30:12 +00:00
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_append_push_constants (self, node, state);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-12 02:18:59 +00:00
|
|
|
gsk_transform_unref (new_state.modelview);
|
2023-03-24 01:30:12 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-06-29 19:44:40 +00:00
|
|
|
static gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_opacity_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-06-25 22:29:13 +00:00
|
|
|
GskVulkanImage *image;
|
|
|
|
graphene_rect_t tex_rect;
|
|
|
|
|
|
|
|
image = gsk_vulkan_render_pass_get_node_as_image (self,
|
|
|
|
render,
|
|
|
|
state,
|
|
|
|
gsk_opacity_node_get_child (node),
|
|
|
|
&tex_rect);
|
|
|
|
if (image == NULL)
|
|
|
|
return TRUE;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-06-29 19:43:26 +00:00
|
|
|
gsk_vulkan_color_matrix_op_opacity (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
|
|
|
image,
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
&tex_rect,
|
|
|
|
gsk_opacity_node_get_opacity (node));
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_color_matrix_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-06-25 21:04:43 +00:00
|
|
|
GskVulkanImage *image;
|
|
|
|
graphene_rect_t tex_rect;
|
|
|
|
|
|
|
|
image = gsk_vulkan_render_pass_get_node_as_image (self,
|
|
|
|
render,
|
|
|
|
state,
|
|
|
|
gsk_color_matrix_node_get_child (node),
|
|
|
|
&tex_rect);
|
|
|
|
if (image == NULL)
|
|
|
|
return TRUE;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-06-28 02:30:35 +00:00
|
|
|
gsk_vulkan_color_matrix_op (self,
|
2023-06-29 04:36:17 +00:00
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
2023-06-28 02:30:35 +00:00
|
|
|
image,
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
&tex_rect,
|
|
|
|
gsk_color_matrix_node_get_color_matrix (node),
|
|
|
|
gsk_color_matrix_node_get_color_offset (node));
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2023-05-19 03:35:18 +00:00
|
|
|
static gboolean
|
|
|
|
clip_can_be_scissored (const graphene_rect_t *rect,
|
|
|
|
const graphene_vec2_t *scale,
|
|
|
|
GskTransform *modelview,
|
|
|
|
cairo_rectangle_int_t *int_rect)
|
|
|
|
{
|
|
|
|
graphene_rect_t transformed_rect;
|
|
|
|
float scale_x = graphene_vec2_get_x (scale);
|
|
|
|
float scale_y = graphene_vec2_get_y (scale);
|
|
|
|
|
|
|
|
switch (gsk_transform_get_category (modelview))
|
|
|
|
{
|
|
|
|
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
|
|
|
|
case GSK_TRANSFORM_CATEGORY_ANY:
|
|
|
|
case GSK_TRANSFORM_CATEGORY_3D:
|
|
|
|
case GSK_TRANSFORM_CATEGORY_2D:
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
|
|
|
|
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
|
|
|
|
gsk_transform_transform_bounds (modelview, rect, &transformed_rect);
|
|
|
|
rect = &transformed_rect;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSK_TRANSFORM_CATEGORY_IDENTITY:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
int_rect->x = rect->origin.x * scale_x;
|
|
|
|
int_rect->y = rect->origin.y * scale_y;
|
|
|
|
int_rect->width = rect->size.width * scale_x;
|
|
|
|
int_rect->height = rect->size.height * scale_y;
|
|
|
|
|
|
|
|
return int_rect->x == rect->origin.x * scale_x
|
|
|
|
&& int_rect->y == rect->origin.y * scale_y
|
|
|
|
&& int_rect->width == rect->size.width * scale_x
|
|
|
|
&& int_rect->height == rect->size.height * scale_y;
|
|
|
|
}
|
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_clip_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-05-11 21:38:12 +00:00
|
|
|
GskVulkanParseState new_state;
|
2023-05-10 14:40:22 +00:00
|
|
|
graphene_rect_t clip;
|
2023-05-19 03:35:18 +00:00
|
|
|
gboolean do_push_constants, do_scissor;
|
2023-05-10 14:40:22 +00:00
|
|
|
|
|
|
|
graphene_rect_offset_r (gsk_clip_node_get_clip (node),
|
2023-05-12 00:51:50 +00:00
|
|
|
state->offset.x, state->offset.y,
|
2023-05-10 14:40:22 +00:00
|
|
|
&clip);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-19 03:35:18 +00:00
|
|
|
/* Check if we can use scissoring for the clip */
|
|
|
|
if (clip_can_be_scissored (&clip, &state->scale, state->modelview, &new_state.scissor))
|
|
|
|
{
|
|
|
|
if (!gdk_rectangle_intersect (&new_state.scissor, &state->scissor, &new_state.scissor))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (gsk_vulkan_clip_intersect_rect (&new_state.clip, &state->clip, &clip))
|
|
|
|
{
|
|
|
|
if (new_state.clip.type == GSK_VULKAN_CLIP_RECT)
|
|
|
|
new_state.clip.type = GSK_VULKAN_CLIP_NONE;
|
|
|
|
|
|
|
|
do_push_constants = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gsk_vulkan_clip_init_copy (&new_state.clip, &state->clip);
|
|
|
|
do_push_constants = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
do_scissor = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!gsk_vulkan_clip_intersect_rect (&new_state.clip, &state->clip, &clip))
|
|
|
|
FALLBACK ("Failed to find intersection between clip of type %u and rectangle", state->clip.type);
|
|
|
|
|
|
|
|
new_state.scissor = state->scissor;
|
|
|
|
|
|
|
|
do_push_constants = TRUE;
|
|
|
|
do_scissor = FALSE;
|
|
|
|
}
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
if (new_state.clip.type == GSK_VULKAN_CLIP_ALL_CLIPPED)
|
2023-03-31 17:00:33 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2023-05-12 00:51:50 +00:00
|
|
|
new_state.offset = state->offset;
|
2023-05-12 01:35:58 +00:00
|
|
|
graphene_vec2_init_from_vec2 (&new_state.scale, &state->scale);
|
2023-05-12 02:18:59 +00:00
|
|
|
new_state.modelview = state->modelview;
|
2023-05-12 02:09:13 +00:00
|
|
|
graphene_matrix_init_from_matrix (&new_state.projection, &state->projection);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-19 03:35:18 +00:00
|
|
|
if (do_scissor)
|
|
|
|
gsk_vulkan_render_pass_append_scissor (self, node, &new_state);
|
|
|
|
if (do_push_constants)
|
|
|
|
gsk_vulkan_render_pass_append_push_constants (self, node, &new_state);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (self, render, &new_state, gsk_clip_node_get_child (node));
|
|
|
|
|
2023-05-19 03:35:18 +00:00
|
|
|
if (do_push_constants)
|
|
|
|
gsk_vulkan_render_pass_append_push_constants (self, node, state);
|
|
|
|
if (do_scissor)
|
|
|
|
gsk_vulkan_render_pass_append_scissor (self, node, state);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_rounded_clip_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-05-11 21:38:12 +00:00
|
|
|
GskVulkanParseState new_state;
|
2023-05-10 14:40:22 +00:00
|
|
|
GskRoundedRect clip;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-10 14:40:22 +00:00
|
|
|
clip = *gsk_rounded_clip_node_get_clip (node);
|
2023-05-12 00:51:50 +00:00
|
|
|
gsk_rounded_rect_offset (&clip, state->offset.x, state->offset.y);
|
2023-05-10 14:40:22 +00:00
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
if (!gsk_vulkan_clip_intersect_rounded_rect (&new_state.clip, &state->clip, &clip))
|
|
|
|
FALLBACK ("Failed to find intersection between clip of type %u and rounded rectangle", state->clip.type);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
if (new_state.clip.type == GSK_VULKAN_CLIP_ALL_CLIPPED)
|
2023-03-31 17:00:33 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2023-05-19 01:08:43 +00:00
|
|
|
new_state.scissor = state->scissor;
|
2023-05-12 00:51:50 +00:00
|
|
|
new_state.offset = state->offset;
|
2023-05-12 01:35:58 +00:00
|
|
|
graphene_vec2_init_from_vec2 (&new_state.scale, &state->scale);
|
2023-05-12 02:18:59 +00:00
|
|
|
new_state.modelview = state->modelview;
|
2023-05-12 02:09:13 +00:00
|
|
|
graphene_matrix_init_from_matrix (&new_state.projection, &state->projection);
|
2023-05-11 21:38:12 +00:00
|
|
|
|
|
|
|
gsk_vulkan_render_pass_append_push_constants (self, node, &new_state);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (self, render, &new_state, gsk_rounded_clip_node_get_child (node));
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_append_push_constants (self, node, state);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_repeat_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-06-26 01:47:25 +00:00
|
|
|
const graphene_rect_t *child_bounds;
|
|
|
|
VkSemaphore semaphore;
|
|
|
|
GskVulkanImage *image;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-06-26 01:47:25 +00:00
|
|
|
child_bounds = gsk_repeat_node_get_child_bounds (node);
|
|
|
|
|
|
|
|
if (graphene_rect_get_area (child_bounds) == 0)
|
2023-05-09 22:08:24 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2023-06-26 01:47:25 +00:00
|
|
|
/* We need to create a texture in the right size so that we can repeat it
|
|
|
|
* properly, so even for texture nodes this step is necessary.
|
|
|
|
* We also can't use the clip because of that. */
|
|
|
|
vkCreateSemaphore (gdk_vulkan_context_get_device (self->vulkan),
|
|
|
|
&(VkSemaphoreCreateInfo) {
|
|
|
|
VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
|
|
|
|
NULL,
|
|
|
|
0
|
|
|
|
},
|
|
|
|
NULL,
|
|
|
|
&semaphore);
|
|
|
|
|
|
|
|
g_array_append_val (self->wait_semaphores, semaphore);
|
|
|
|
|
2023-06-28 02:30:35 +00:00
|
|
|
image = gsk_vulkan_offscreen_op (self,
|
|
|
|
self->vulkan,
|
|
|
|
render,
|
|
|
|
&state->scale,
|
|
|
|
child_bounds,
|
|
|
|
semaphore,
|
|
|
|
gsk_repeat_node_get_child (node));
|
2023-06-26 01:47:25 +00:00
|
|
|
|
2023-06-28 02:30:35 +00:00
|
|
|
gsk_vulkan_texture_op (self,
|
2023-06-29 04:36:17 +00:00
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
2023-06-28 02:30:35 +00:00
|
|
|
image,
|
|
|
|
GSK_VULKAN_SAMPLER_REPEAT,
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
child_bounds);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_blend_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-07-01 04:14:48 +00:00
|
|
|
GskRenderNode *top_child, *bottom_child;
|
|
|
|
GskVulkanImage *top_image, *bottom_image;
|
|
|
|
graphene_rect_t top_tex_rect, bottom_tex_rect;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-07-01 04:14:48 +00:00
|
|
|
top_child = gsk_blend_node_get_top_child (node);
|
|
|
|
top_image = gsk_vulkan_render_pass_get_node_as_image (self,
|
|
|
|
render,
|
|
|
|
state,
|
|
|
|
top_child,
|
|
|
|
&top_tex_rect);
|
|
|
|
bottom_child = gsk_blend_node_get_bottom_child (node);
|
|
|
|
bottom_image = gsk_vulkan_render_pass_get_node_as_image (self,
|
|
|
|
render,
|
|
|
|
state,
|
|
|
|
bottom_child,
|
|
|
|
&bottom_tex_rect);
|
|
|
|
if (top_image == NULL)
|
|
|
|
{
|
|
|
|
if (bottom_image == NULL)
|
|
|
|
return TRUE;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-07-01 04:14:48 +00:00
|
|
|
top_image = bottom_image;
|
|
|
|
top_tex_rect = *graphene_rect_zero ();
|
|
|
|
}
|
|
|
|
else if (bottom_image == NULL)
|
|
|
|
{
|
|
|
|
bottom_image = top_image;
|
|
|
|
bottom_tex_rect = *graphene_rect_zero ();
|
|
|
|
}
|
|
|
|
|
|
|
|
gsk_vulkan_blend_mode_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
gsk_blend_node_get_blend_mode (node),
|
|
|
|
top_image,
|
|
|
|
&top_child->bounds,
|
|
|
|
&top_tex_rect,
|
|
|
|
bottom_image,
|
|
|
|
&bottom_child->bounds,
|
|
|
|
&bottom_tex_rect);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_cross_fade_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-06-29 19:44:40 +00:00
|
|
|
GskRenderNode *start_child, *end_child;
|
|
|
|
GskVulkanImage *start_image, *end_image;
|
|
|
|
graphene_rect_t start_tex_rect, end_tex_rect;
|
|
|
|
float progress;
|
|
|
|
|
|
|
|
progress = gsk_cross_fade_node_get_progress (node);
|
|
|
|
start_child = gsk_cross_fade_node_get_start_child (node);
|
|
|
|
start_image = gsk_vulkan_render_pass_get_node_as_image (self,
|
|
|
|
render,
|
|
|
|
state,
|
|
|
|
start_child,
|
|
|
|
&start_tex_rect);
|
|
|
|
end_child = gsk_cross_fade_node_get_end_child (node);
|
|
|
|
end_image = gsk_vulkan_render_pass_get_node_as_image (self,
|
|
|
|
render,
|
|
|
|
state,
|
|
|
|
end_child,
|
|
|
|
&end_tex_rect);
|
|
|
|
if (start_image == NULL)
|
|
|
|
{
|
|
|
|
if (end_image == NULL)
|
|
|
|
return TRUE;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-06-29 19:44:40 +00:00
|
|
|
gsk_vulkan_color_matrix_op_opacity (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &end_child->bounds),
|
|
|
|
end_image,
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
&end_tex_rect,
|
|
|
|
progress);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-06-29 19:44:40 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (end_image == NULL)
|
|
|
|
{
|
|
|
|
gsk_vulkan_color_matrix_op_opacity (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &start_child->bounds),
|
|
|
|
start_image,
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
&start_tex_rect,
|
|
|
|
1.0f - progress);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gsk_vulkan_cross_fade_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
progress,
|
|
|
|
start_image,
|
|
|
|
&start_child->bounds,
|
|
|
|
&start_tex_rect,
|
|
|
|
end_image,
|
|
|
|
&end_child->bounds,
|
|
|
|
&end_tex_rect);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_text_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
|
|
|
const PangoGlyphInfo *glyphs;
|
|
|
|
GskVulkanRenderer *renderer;
|
2023-07-03 07:15:04 +00:00
|
|
|
const graphene_point_t *node_offset;
|
2023-03-31 17:00:33 +00:00
|
|
|
const PangoFont *font;
|
|
|
|
guint num_glyphs;
|
|
|
|
int x_position;
|
|
|
|
int i;
|
2023-07-03 07:15:04 +00:00
|
|
|
float scale;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
renderer = GSK_VULKAN_RENDERER (gsk_vulkan_render_get_renderer (render));
|
|
|
|
num_glyphs = gsk_text_node_get_num_glyphs (node);
|
|
|
|
glyphs = gsk_text_node_get_glyphs (node, NULL);
|
|
|
|
font = gsk_text_node_get_font (node);
|
|
|
|
|
2016-12-26 16:11:13 +00:00
|
|
|
|
2023-07-03 07:15:04 +00:00
|
|
|
scale = MAX (graphene_vec2_get_x (&state->scale), graphene_vec2_get_y (&state->scale));
|
|
|
|
node_offset = gsk_text_node_get_offset (node);
|
2016-12-30 05:46:34 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
x_position = 0;
|
2023-07-03 07:15:04 +00:00
|
|
|
for (i = 0; i < num_glyphs; i++)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-07-03 07:15:04 +00:00
|
|
|
GskVulkanCachedGlyph *glyph;
|
2023-03-31 17:00:33 +00:00
|
|
|
const PangoGlyphInfo *gi = &glyphs[i];
|
2023-07-03 07:15:04 +00:00
|
|
|
graphene_rect_t glyph_bounds, glyph_tex_rect;
|
|
|
|
|
|
|
|
glyph = gsk_vulkan_renderer_cache_glyph (renderer,
|
|
|
|
(PangoFont *)font,
|
|
|
|
gi->glyph,
|
|
|
|
x_position + gi->geometry.x_offset,
|
|
|
|
gi->geometry.y_offset,
|
|
|
|
scale);
|
|
|
|
|
|
|
|
glyph_bounds = GRAPHENE_RECT_INIT (glyph->draw_x + node_offset->x + (float) (x_position + gi->geometry.x_offset) / PANGO_SCALE,
|
|
|
|
glyph->draw_y + node_offset->y + (float) (gi->geometry.y_offset) / PANGO_SCALE,
|
|
|
|
glyph->draw_width,
|
|
|
|
glyph->draw_height);
|
|
|
|
graphene_rect_init (&glyph_tex_rect,
|
|
|
|
glyph_bounds.origin.x - glyph->draw_width * glyph->tx / glyph->tw,
|
|
|
|
glyph_bounds.origin.y - glyph->draw_height * glyph->ty / glyph->th,
|
|
|
|
glyph->draw_width / glyph->tw,
|
|
|
|
glyph->draw_height / glyph->th);
|
|
|
|
if (gsk_text_node_has_color_glyphs (node))
|
|
|
|
gsk_vulkan_texture_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &glyph_bounds),
|
|
|
|
glyph->atlas_image,
|
|
|
|
GSK_VULKAN_SAMPLER_DEFAULT,
|
|
|
|
&glyph_bounds,
|
|
|
|
&state->offset,
|
|
|
|
&glyph_tex_rect);
|
2017-09-03 13:54:47 +00:00
|
|
|
else
|
2023-07-03 07:15:04 +00:00
|
|
|
gsk_vulkan_glyph_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &glyph_bounds),
|
|
|
|
glyph->atlas_image,
|
|
|
|
&glyph_bounds,
|
|
|
|
&state->offset,
|
|
|
|
&glyph_tex_rect,
|
|
|
|
gsk_text_node_get_color (node));
|
2017-09-03 13:54:47 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
x_position += gi->geometry.width;
|
|
|
|
}
|
2023-02-11 13:59:06 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_blur_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-07-02 04:30:10 +00:00
|
|
|
GskVulkanImage *image;
|
|
|
|
graphene_rect_t tex_rect;
|
|
|
|
float radius;
|
2023-03-31 17:00:33 +00:00
|
|
|
|
2023-07-02 04:30:10 +00:00
|
|
|
radius = gsk_blur_node_get_radius (node);
|
|
|
|
if (radius == 0)
|
|
|
|
{
|
|
|
|
gsk_vulkan_render_pass_add_node (self, render, state, gsk_blur_node_get_child (node));
|
|
|
|
return TRUE;
|
|
|
|
}
|
2017-01-10 13:59:20 +00:00
|
|
|
|
2023-07-02 04:30:10 +00:00
|
|
|
image = gsk_vulkan_render_pass_get_node_as_image (self,
|
|
|
|
render,
|
|
|
|
state,
|
|
|
|
gsk_blur_node_get_child (node),
|
|
|
|
&tex_rect);
|
|
|
|
if (image == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
gsk_vulkan_blur_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
|
|
|
|
image,
|
|
|
|
&node->bounds,
|
|
|
|
&state->offset,
|
|
|
|
&tex_rect,
|
|
|
|
radius);
|
2016-12-12 18:30:41 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2016-12-23 20:36:17 +00:00
|
|
|
|
2023-07-03 05:53:22 +00:00
|
|
|
static inline gboolean
|
|
|
|
gsk_vulkan_render_pass_add_mask_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
|
|
|
{
|
|
|
|
GskVulkanImage *mask_image;
|
|
|
|
graphene_rect_t mask_tex_rect;
|
|
|
|
GskRenderNode *source, *mask;
|
|
|
|
GskMaskMode mode;
|
|
|
|
|
|
|
|
mode = gsk_mask_node_get_mask_mode (node);
|
|
|
|
source = gsk_mask_node_get_source (node);
|
|
|
|
mask = gsk_mask_node_get_mask (node);
|
|
|
|
mask_image = gsk_vulkan_render_pass_get_node_as_image (self,
|
|
|
|
render,
|
|
|
|
state,
|
|
|
|
mask,
|
|
|
|
&mask_tex_rect);
|
|
|
|
if (mask_image == NULL)
|
|
|
|
{
|
|
|
|
if (mode == GSK_MASK_MODE_INVERTED_ALPHA)
|
|
|
|
gsk_vulkan_render_pass_add_node (self, render, state, source);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use the glyph shader as an optimization */
|
|
|
|
if (mode == GSK_MASK_MODE_ALPHA &&
|
|
|
|
gsk_render_node_get_node_type (source) == GSK_COLOR_NODE)
|
|
|
|
{
|
|
|
|
graphene_rect_t bounds;
|
|
|
|
if (graphene_rect_intersection (&source->bounds, &mask->bounds, &bounds))
|
|
|
|
gsk_vulkan_glyph_op (self,
|
|
|
|
gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &bounds),
|
|
|
|
mask_image,
|
|
|
|
&bounds,
|
|
|
|
&state->offset,
|
|
|
|
&mask_tex_rect,
|
|
|
|
gsk_color_node_get_color (source));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
static inline gboolean
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_debug_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (self, render, state, gsk_debug_node_get_child (node));
|
2023-03-31 17:00:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2018-04-23 22:41:48 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
#undef FALLBACK
|
2016-12-23 20:36:17 +00:00
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
typedef gboolean (*GskVulkanRenderPassNodeFunc) (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node);
|
2023-03-31 17:00:33 +00:00
|
|
|
|
|
|
|
/* TODO: implement remaining nodes */
|
2023-06-11 01:09:09 +00:00
|
|
|
static const GskVulkanRenderPassNodeFunc nodes_vtable[] = {
|
2023-03-31 17:00:33 +00:00
|
|
|
[GSK_NOT_A_RENDER_NODE] = gsk_vulkan_render_pass_implode,
|
|
|
|
[GSK_CONTAINER_NODE] = gsk_vulkan_render_pass_add_container_node,
|
|
|
|
[GSK_CAIRO_NODE] = gsk_vulkan_render_pass_add_cairo_node,
|
|
|
|
[GSK_COLOR_NODE] = gsk_vulkan_render_pass_add_color_node,
|
2023-06-08 10:03:48 +00:00
|
|
|
[GSK_LINEAR_GRADIENT_NODE] = gsk_vulkan_render_pass_add_linear_gradient_node,
|
|
|
|
[GSK_REPEATING_LINEAR_GRADIENT_NODE] = gsk_vulkan_render_pass_add_linear_gradient_node,
|
2023-03-31 17:00:33 +00:00
|
|
|
[GSK_RADIAL_GRADIENT_NODE] = NULL,
|
|
|
|
[GSK_REPEATING_RADIAL_GRADIENT_NODE] = NULL,
|
|
|
|
[GSK_CONIC_GRADIENT_NODE] = NULL,
|
|
|
|
[GSK_BORDER_NODE] = gsk_vulkan_render_pass_add_border_node,
|
|
|
|
[GSK_TEXTURE_NODE] = gsk_vulkan_render_pass_add_texture_node,
|
|
|
|
[GSK_INSET_SHADOW_NODE] = gsk_vulkan_render_pass_add_inset_shadow_node,
|
|
|
|
[GSK_OUTSET_SHADOW_NODE] = gsk_vulkan_render_pass_add_outset_shadow_node,
|
|
|
|
[GSK_TRANSFORM_NODE] = gsk_vulkan_render_pass_add_transform_node,
|
|
|
|
[GSK_OPACITY_NODE] = gsk_vulkan_render_pass_add_opacity_node,
|
|
|
|
[GSK_COLOR_MATRIX_NODE] = gsk_vulkan_render_pass_add_color_matrix_node,
|
|
|
|
[GSK_REPEAT_NODE] = gsk_vulkan_render_pass_add_repeat_node,
|
|
|
|
[GSK_CLIP_NODE] = gsk_vulkan_render_pass_add_clip_node,
|
|
|
|
[GSK_ROUNDED_CLIP_NODE] = gsk_vulkan_render_pass_add_rounded_clip_node,
|
|
|
|
[GSK_SHADOW_NODE] = NULL,
|
|
|
|
[GSK_BLEND_NODE] = gsk_vulkan_render_pass_add_blend_node,
|
|
|
|
[GSK_CROSS_FADE_NODE] = gsk_vulkan_render_pass_add_cross_fade_node,
|
|
|
|
[GSK_TEXT_NODE] = gsk_vulkan_render_pass_add_text_node,
|
|
|
|
[GSK_BLUR_NODE] = gsk_vulkan_render_pass_add_blur_node,
|
|
|
|
[GSK_DEBUG_NODE] = gsk_vulkan_render_pass_add_debug_node,
|
|
|
|
[GSK_GL_SHADER_NODE] = NULL,
|
2023-05-23 03:26:08 +00:00
|
|
|
[GSK_TEXTURE_SCALE_NODE] = gsk_vulkan_render_pass_add_texture_scale_node,
|
2023-07-03 05:53:22 +00:00
|
|
|
[GSK_MASK_NODE] = gsk_vulkan_render_pass_add_mask_node,
|
2023-03-31 17:00:33 +00:00
|
|
|
};
|
2016-12-12 23:11:06 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
static void
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
const GskVulkanParseState *state,
|
|
|
|
GskRenderNode *node)
|
2023-03-31 17:00:33 +00:00
|
|
|
{
|
|
|
|
GskVulkanRenderPassNodeFunc node_func;
|
|
|
|
GskRenderNodeType node_type;
|
|
|
|
gboolean fallback = FALSE;
|
2016-12-23 20:36:17 +00:00
|
|
|
|
2023-06-11 01:01:04 +00:00
|
|
|
/* This catches the corner cases of empty nodes, so after this check
|
|
|
|
* there's quaranteed to be at least 1 pixel that needs to be drawn */
|
2023-07-10 23:38:02 +00:00
|
|
|
if (!gsk_vulkan_clip_may_intersect_rect (&state->clip, &state->offset, &node->bounds))
|
2023-06-11 01:01:04 +00:00
|
|
|
return;
|
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
node_type = gsk_render_node_get_node_type (node);
|
2023-06-11 01:09:09 +00:00
|
|
|
if (node_type < G_N_ELEMENTS (nodes_vtable))
|
|
|
|
node_func = nodes_vtable[node_type];
|
|
|
|
else
|
|
|
|
node_func = NULL;
|
2016-12-23 20:36:17 +00:00
|
|
|
|
2023-03-31 17:00:33 +00:00
|
|
|
if (node_func)
|
2016-12-23 20:36:17 +00:00
|
|
|
{
|
2023-05-11 21:38:12 +00:00
|
|
|
if (!node_func (self, render, state, node))
|
2023-03-31 17:00:33 +00:00
|
|
|
fallback = TRUE;
|
2016-12-09 04:59:19 +00:00
|
|
|
}
|
2023-03-31 17:00:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
GSK_RENDERER_DEBUG (gsk_vulkan_render_get_renderer (render),
|
|
|
|
FALLBACK, "Unsupported node '%s'",
|
|
|
|
g_type_name_from_instance ((GTypeInstance *) node));
|
|
|
|
fallback = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fallback)
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_fallback_node (self, render, state, node);
|
2016-12-08 12:26:36 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 23:11:06 +00:00
|
|
|
void
|
2023-05-19 01:08:43 +00:00
|
|
|
gsk_vulkan_render_pass_add (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
GskRenderNode *node)
|
2016-12-12 23:11:06 +00:00
|
|
|
{
|
2023-05-11 21:38:12 +00:00
|
|
|
GskVulkanParseState state;
|
2023-05-14 02:15:06 +00:00
|
|
|
graphene_rect_t clip;
|
2023-05-19 01:08:43 +00:00
|
|
|
float scale_x, scale_y;
|
2023-05-14 02:15:06 +00:00
|
|
|
|
2023-05-19 01:08:43 +00:00
|
|
|
scale_x = 1 / graphene_vec2_get_x (&self->scale);
|
|
|
|
scale_y = 1 / graphene_vec2_get_y (&self->scale);
|
|
|
|
cairo_region_get_extents (self->clip, &state.scissor);
|
|
|
|
clip = GRAPHENE_RECT_INIT(state.scissor.x, state.scissor.y,
|
|
|
|
state.scissor.width, state.scissor.height);
|
|
|
|
graphene_rect_scale (&clip, scale_x, scale_y, &clip);
|
|
|
|
gsk_vulkan_clip_init_empty (&state.clip, &clip);
|
2023-05-09 22:21:39 +00:00
|
|
|
|
2023-05-12 03:15:28 +00:00
|
|
|
state.modelview = NULL;
|
2023-05-12 02:09:13 +00:00
|
|
|
graphene_matrix_init_ortho (&state.projection,
|
2023-05-19 01:08:43 +00:00
|
|
|
0, self->viewport.size.width,
|
|
|
|
0, self->viewport.size.height,
|
2023-05-09 22:21:39 +00:00
|
|
|
2 * ORTHO_NEAR_PLANE - ORTHO_FAR_PLANE,
|
|
|
|
ORTHO_FAR_PLANE);
|
2023-05-12 01:35:58 +00:00
|
|
|
graphene_vec2_init_from_vec2 (&state.scale, &self->scale);
|
2023-05-19 01:08:43 +00:00
|
|
|
state.offset = GRAPHENE_POINT_INIT (-self->viewport.origin.x * scale_x,
|
|
|
|
-self->viewport.origin.y * scale_y);
|
2016-12-12 23:11:06 +00:00
|
|
|
|
2023-05-19 01:08:43 +00:00
|
|
|
gsk_vulkan_render_pass_append_scissor (self, node, &state);
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_append_push_constants (self, node, &state);
|
2016-12-12 23:11:06 +00:00
|
|
|
|
2023-05-11 21:38:12 +00:00
|
|
|
gsk_vulkan_render_pass_add_node (self, render, &state, node);
|
2016-12-12 23:11:06 +00:00
|
|
|
}
|
|
|
|
|
2016-12-08 12:26:36 +00:00
|
|
|
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;
|
|
|
|
|
2023-06-24 02:00:02 +00:00
|
|
|
for (i = 0; i < gsk_vulkan_render_ops_get_size (&self->render_ops); i += op->op_class->size)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2023-06-23 02:40:05 +00:00
|
|
|
op = (GskVulkanOp *) gsk_vulkan_render_ops_index (&self->render_ops, i);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2023-07-03 01:23:17 +00:00
|
|
|
gsk_vulkan_op_upload (op, self, render, uploader);
|
2023-06-24 02:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
static 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;
|
2023-06-24 02:00:02 +00:00
|
|
|
gsize n_bytes;
|
2016-12-18 00:45:07 +00:00
|
|
|
guint i;
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2016-12-18 00:45:07 +00:00
|
|
|
n_bytes = 0;
|
2023-06-24 02:00:02 +00:00
|
|
|
for (i = 0; i < gsk_vulkan_render_ops_get_size (&self->render_ops); i += op->op_class->size)
|
2016-12-18 00:45:07 +00:00
|
|
|
{
|
2023-06-23 02:40:05 +00:00
|
|
|
op = (GskVulkanOp *) gsk_vulkan_render_ops_index (&self->render_ops, i);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2023-06-24 02:00:02 +00:00
|
|
|
n_bytes = gsk_vulkan_op_count_vertex_data (op, n_bytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
return n_bytes;
|
|
|
|
}
|
|
|
|
|
2023-05-18 20:52:17 +00:00
|
|
|
static void
|
2016-12-18 00:45:07 +00:00
|
|
|
gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
2017-09-01 20:58:42 +00:00
|
|
|
GskVulkanRender *render,
|
2023-05-18 21:10:16 +00:00
|
|
|
guchar *data)
|
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;
|
|
|
|
|
2023-06-24 02:00:02 +00:00
|
|
|
for (i = 0; i < gsk_vulkan_render_ops_get_size (&self->render_ops); i += op->op_class->size)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2023-06-23 02:40:05 +00:00
|
|
|
op = (GskVulkanOp *) gsk_vulkan_render_ops_index (&self->render_ops, i);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2023-06-24 02:00:02 +00:00
|
|
|
gsk_vulkan_op_collect_vertex_data (op, self, render, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
static GskVulkanBuffer *
|
2017-09-28 00:55:14 +00:00
|
|
|
gsk_vulkan_render_pass_get_vertex_data (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render)
|
|
|
|
{
|
2017-09-28 00:56:01 +00:00
|
|
|
if (self->vertex_data == NULL)
|
|
|
|
{
|
|
|
|
gsize n_bytes;
|
|
|
|
guchar *data;
|
|
|
|
|
|
|
|
n_bytes = gsk_vulkan_render_pass_count_vertex_data (self);
|
2023-05-09 22:09:03 +00:00
|
|
|
if (n_bytes == 0)
|
|
|
|
return NULL;
|
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
self->vertex_data = gsk_vulkan_buffer_new (self->vulkan, n_bytes);
|
|
|
|
data = gsk_vulkan_buffer_map (self->vertex_data);
|
2023-05-18 21:10:16 +00:00
|
|
|
gsk_vulkan_render_pass_collect_vertex_data (self, render, data);
|
2017-09-28 00:56:01 +00:00
|
|
|
gsk_vulkan_buffer_unmap (self->vertex_data);
|
|
|
|
}
|
2017-09-28 00:55:14 +00:00
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
return self->vertex_data;
|
|
|
|
}
|
2017-09-28 00:55:14 +00:00
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
gsize
|
|
|
|
gsk_vulkan_render_pass_get_wait_semaphores (GskVulkanRenderPass *self,
|
|
|
|
VkSemaphore **semaphores)
|
|
|
|
{
|
|
|
|
*semaphores = (VkSemaphore *)self->wait_semaphores->data;
|
|
|
|
return self->wait_semaphores->len;
|
|
|
|
}
|
2017-09-28 00:55:14 +00:00
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
gsize
|
|
|
|
gsk_vulkan_render_pass_get_signal_semaphores (GskVulkanRenderPass *self,
|
|
|
|
VkSemaphore **semaphores)
|
|
|
|
{
|
|
|
|
*semaphores = (VkSemaphore *)&self->signal_semaphore;
|
|
|
|
return self->signal_semaphore != VK_NULL_HANDLE ? 1 : 0;
|
2017-09-28 00:55:14 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2023-06-24 02:00:02 +00:00
|
|
|
for (i = 0; i < gsk_vulkan_render_ops_get_size (&self->render_ops); i += op->op_class->size)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2023-06-23 02:40:05 +00:00
|
|
|
op = (GskVulkanOp *) gsk_vulkan_render_ops_index (&self->render_ops, i);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2023-06-24 02:00:02 +00:00
|
|
|
gsk_vulkan_op_reserve_descriptor_sets (op, render);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
static void
|
|
|
|
gsk_vulkan_render_pass_draw_rect (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
2023-05-12 18:49:31 +00:00
|
|
|
VkPipelineLayout pipeline_layout,
|
2017-09-28 00:56:01 +00:00
|
|
|
VkCommandBuffer command_buffer)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2023-06-26 21:26:19 +00:00
|
|
|
VkPipeline current_pipeline = VK_NULL_HANDLE;
|
|
|
|
VkPipeline op_pipeline;
|
2016-12-14 06:34:18 +00:00
|
|
|
GskVulkanOp *op;
|
2023-06-23 02:40:05 +00:00
|
|
|
guint i;
|
2017-09-28 00:56:01 +00:00
|
|
|
GskVulkanBuffer *vertex_buffer;
|
|
|
|
|
|
|
|
vertex_buffer = gsk_vulkan_render_pass_get_vertex_data (self, render);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2023-05-18 21:34:27 +00:00
|
|
|
if (vertex_buffer)
|
|
|
|
vkCmdBindVertexBuffers (command_buffer,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
(VkBuffer[1]) {
|
|
|
|
gsk_vulkan_buffer_get_buffer (vertex_buffer)
|
|
|
|
},
|
|
|
|
(VkDeviceSize[1]) { 0 });
|
|
|
|
|
2023-06-24 02:00:02 +00:00
|
|
|
for (i = 0; i < gsk_vulkan_render_ops_get_size (&self->render_ops); i += op->op_class->size)
|
2016-12-08 12:26:36 +00:00
|
|
|
{
|
2023-06-23 02:40:05 +00:00
|
|
|
op = (GskVulkanOp *) gsk_vulkan_render_ops_index (&self->render_ops, i);
|
2016-12-08 12:26:36 +00:00
|
|
|
|
2023-06-29 04:36:17 +00:00
|
|
|
if (op->op_class->shader_name)
|
|
|
|
{
|
|
|
|
op_pipeline = gsk_vulkan_render_create_pipeline (render,
|
|
|
|
op->op_class->shader_name,
|
|
|
|
op->clip_type,
|
|
|
|
op->op_class->vertex_input_state,
|
|
|
|
gsk_vulkan_image_get_vk_format (self->target),
|
|
|
|
self->render_pass);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
op_pipeline = gsk_vulkan_op_get_pipeline (op);
|
|
|
|
|
2023-06-24 02:00:02 +00:00
|
|
|
if (op_pipeline && op_pipeline != current_pipeline)
|
|
|
|
{
|
|
|
|
current_pipeline = op_pipeline;
|
|
|
|
vkCmdBindPipeline (command_buffer,
|
|
|
|
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
2023-06-26 21:26:19 +00:00
|
|
|
current_pipeline);
|
2023-06-24 02:00:02 +00:00
|
|
|
}
|
|
|
|
|
2023-06-25 20:16:37 +00:00
|
|
|
gsk_vulkan_op_command (op, render, pipeline_layout, command_buffer);
|
2023-06-24 02:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-28 00:56:01 +00:00
|
|
|
void
|
2023-05-12 18:49:31 +00:00
|
|
|
gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
|
|
|
GskVulkanRender *render,
|
|
|
|
VkPipelineLayout pipeline_layout,
|
|
|
|
VkCommandBuffer command_buffer)
|
2017-09-28 00:56:01 +00:00
|
|
|
{
|
2023-05-14 02:12:14 +00:00
|
|
|
cairo_rectangle_int_t rect;
|
2017-09-28 00:56:01 +00:00
|
|
|
|
|
|
|
vkCmdSetViewport (command_buffer,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
&(VkViewport) {
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.width = self->viewport.size.width,
|
|
|
|
.height = self->viewport.size.height,
|
|
|
|
.minDepth = 0,
|
|
|
|
.maxDepth = 1
|
|
|
|
});
|
|
|
|
|
2023-05-14 02:12:14 +00:00
|
|
|
cairo_region_get_extents (self->clip, &rect);
|
|
|
|
|
|
|
|
vkCmdBeginRenderPass (command_buffer,
|
|
|
|
&(VkRenderPassBeginInfo) {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
|
|
|
|
.renderPass = self->render_pass,
|
2023-06-17 16:53:33 +00:00
|
|
|
.framebuffer = self->framebuffer,
|
2023-05-14 02:12:14 +00:00
|
|
|
.renderArea = {
|
|
|
|
{ rect.x, rect.y },
|
|
|
|
{ rect.width, rect.height }
|
2017-09-28 00:56:01 +00:00
|
|
|
},
|
2023-05-14 02:12:14 +00:00
|
|
|
.clearValueCount = 1,
|
|
|
|
.pClearValues = (VkClearValue [1]) {
|
|
|
|
{ .color = { .float32 = { 0.f, 0.f, 0.f, 0.f } } }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
VK_SUBPASS_CONTENTS_INLINE);
|
2017-09-28 00:56:01 +00:00
|
|
|
|
2023-06-20 13:39:29 +00:00
|
|
|
gsk_vulkan_render_bind_descriptor_sets (render, command_buffer);
|
2023-05-20 00:56:02 +00:00
|
|
|
|
2023-05-14 02:12:14 +00:00
|
|
|
gsk_vulkan_render_pass_draw_rect (self, render, pipeline_layout, command_buffer);
|
2017-09-28 00:56:01 +00:00
|
|
|
|
2023-05-14 02:12:14 +00:00
|
|
|
vkCmdEndRenderPass (command_buffer);
|
2017-09-28 00:56:01 +00:00
|
|
|
}
|
2023-06-24 02:00:02 +00:00
|
|
|
|