2023-08-21 00:18:37 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gskgpuglobalsopprivate.h"
|
|
|
|
|
|
|
|
#include "gskgpuframeprivate.h"
|
|
|
|
#include "gskgpuprintprivate.h"
|
|
|
|
#include "gskroundedrectprivate.h"
|
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
|
|
#include "gskvulkandeviceprivate.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct _GskGpuGlobalsOp GskGpuGlobalsOp;
|
|
|
|
|
|
|
|
struct _GskGpuGlobalsOp
|
|
|
|
{
|
|
|
|
GskGpuOp op;
|
|
|
|
|
|
|
|
GskGpuGlobalsInstance instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
gsk_gpu_globals_op_finish (GskGpuOp *op)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gsk_gpu_globals_op_print (GskGpuOp *op,
|
|
|
|
GskGpuFrame *frame,
|
|
|
|
GString *string,
|
|
|
|
guint indent)
|
|
|
|
{
|
|
|
|
gsk_gpu_print_op (string, indent, "globals");
|
|
|
|
gsk_gpu_print_newline (string);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
|
|
static GskGpuOp *
|
|
|
|
gsk_gpu_globals_op_vk_command (GskGpuOp *op,
|
|
|
|
GskGpuFrame *frame,
|
|
|
|
VkRenderPass render_pass,
|
|
|
|
VkFormat format,
|
|
|
|
VkCommandBuffer command_buffer)
|
|
|
|
{
|
|
|
|
GskGpuGlobalsOp *self = (GskGpuGlobalsOp *) op;
|
|
|
|
|
|
|
|
vkCmdPushConstants (command_buffer,
|
|
|
|
gsk_vulkan_device_get_vk_pipeline_layout (GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (frame))),
|
|
|
|
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
|
|
0,
|
|
|
|
sizeof (self->instance),
|
|
|
|
&self->instance);
|
|
|
|
|
|
|
|
return op->next;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static GskGpuOp *
|
|
|
|
gsk_gpu_globals_op_gl_command (GskGpuOp *op,
|
2023-08-29 06:34:55 +00:00
|
|
|
GskGpuFrame *frame,
|
|
|
|
gsize flip_y)
|
2023-08-21 00:18:37 +00:00
|
|
|
{
|
|
|
|
GskGpuGlobalsOp *self = (GskGpuGlobalsOp *) op;
|
|
|
|
|
|
|
|
/* the GskGLFrame makes sure the uniform buffer points to the globals */
|
|
|
|
/* FIXME: Does it matter if we glBufferData() or glSubBufferData() here? */
|
|
|
|
glBufferSubData (GL_UNIFORM_BUFFER,
|
|
|
|
0,
|
|
|
|
sizeof (self->instance),
|
|
|
|
&self->instance);
|
|
|
|
|
|
|
|
return op->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GskGpuOpClass GSK_GPU_GLOBALS_OP_CLASS = {
|
|
|
|
GSK_GPU_OP_SIZE (GskGpuGlobalsOp),
|
|
|
|
GSK_GPU_STAGE_COMMAND,
|
|
|
|
gsk_gpu_globals_op_finish,
|
|
|
|
gsk_gpu_globals_op_print,
|
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
|
|
gsk_gpu_globals_op_vk_command,
|
|
|
|
#endif
|
|
|
|
gsk_gpu_globals_op_gl_command
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
gsk_gpu_globals_op (GskGpuFrame *frame,
|
|
|
|
const graphene_vec2_t *scale,
|
|
|
|
const graphene_matrix_t *mvp,
|
|
|
|
const GskRoundedRect *clip)
|
|
|
|
{
|
|
|
|
GskGpuGlobalsOp *self;
|
|
|
|
|
|
|
|
self = (GskGpuGlobalsOp *) gsk_gpu_op_alloc (frame, &GSK_GPU_GLOBALS_OP_CLASS);
|
|
|
|
|
|
|
|
graphene_matrix_to_float (mvp, self->instance.mvp);
|
|
|
|
gsk_rounded_rect_to_float (clip, graphene_point_zero (), self->instance.clip);
|
|
|
|
graphene_vec2_to_float (scale, self->instance.scale);
|
|
|
|
}
|