2023-08-21 00:18:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "gskgpuopprivate.h"
|
|
|
|
|
|
|
|
#include "gskgputypesprivate.h"
|
2024-07-03 05:41:26 +00:00
|
|
|
#include "gskgpucolorstatesprivate.h"
|
2023-08-21 00:18:37 +00:00
|
|
|
|
2024-07-18 20:42:15 +00:00
|
|
|
#include <graphene.h>
|
|
|
|
|
2023-08-21 00:18:37 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2024-07-18 20:42:15 +00:00
|
|
|
struct _GskGpuShaderImage
|
|
|
|
{
|
|
|
|
GskGpuImage *image; /* image to draw */
|
|
|
|
GskGpuSampler sampler; /* sampler to use for image */
|
|
|
|
guint32 descriptor; /* FIXME: preallocated descriptor for image + sampler */
|
|
|
|
const graphene_rect_t *coverage; /* the clip area for the image or NULL for unclipped */
|
|
|
|
const graphene_rect_t *bounds; /* bounds for the image */
|
|
|
|
};
|
|
|
|
|
2023-08-21 00:18:37 +00:00
|
|
|
struct _GskGpuShaderOp
|
|
|
|
{
|
|
|
|
GskGpuOp parent_op;
|
|
|
|
|
2023-10-03 19:04:21 +00:00
|
|
|
GskGpuDescriptors *desc;
|
2024-07-03 05:41:26 +00:00
|
|
|
GskGpuColorStates color_states;
|
2023-12-31 04:38:56 +00:00
|
|
|
guint32 variation;
|
2023-08-21 00:18:37 +00:00
|
|
|
GskGpuShaderClip clip;
|
|
|
|
gsize vertex_offset;
|
2024-03-15 17:55:48 +00:00
|
|
|
gsize n_ops;
|
2023-08-21 00:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GskGpuShaderOpClass
|
|
|
|
{
|
|
|
|
GskGpuOpClass parent_class;
|
|
|
|
|
|
|
|
const char * shader_name;
|
|
|
|
gsize vertex_size;
|
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
|
|
const VkPipelineVertexInputStateCreateInfo *vertex_input_state;
|
|
|
|
#endif
|
2024-03-15 12:37:31 +00:00
|
|
|
void (* print_instance) (GskGpuShaderOp *shader,
|
|
|
|
gpointer instance,
|
|
|
|
GString *string);
|
2024-01-04 13:52:03 +00:00
|
|
|
void (* setup_attrib_locations) (GLuint program);
|
2023-08-21 00:18:37 +00:00
|
|
|
void (* setup_vao) (gsize offset);
|
|
|
|
};
|
|
|
|
|
2024-03-15 12:42:40 +00:00
|
|
|
void gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
|
2023-08-21 00:18:37 +00:00
|
|
|
const GskGpuShaderOpClass *op_class,
|
2024-07-03 05:41:26 +00:00
|
|
|
GskGpuColorStates color_states,
|
2023-12-31 04:38:56 +00:00
|
|
|
guint32 variation,
|
2023-08-21 00:18:37 +00:00
|
|
|
GskGpuShaderClip clip,
|
2023-10-03 19:04:21 +00:00
|
|
|
GskGpuDescriptors *desc,
|
2023-08-21 00:18:37 +00:00
|
|
|
gpointer out_vertex_data);
|
|
|
|
|
2023-10-03 19:04:21 +00:00
|
|
|
void gsk_gpu_shader_op_finish (GskGpuOp *op);
|
|
|
|
|
2024-03-15 12:37:31 +00:00
|
|
|
void gsk_gpu_shader_op_print (GskGpuOp *op,
|
|
|
|
GskGpuFrame *frame,
|
|
|
|
GString *string,
|
|
|
|
guint indent);
|
2023-08-21 00:18:37 +00:00
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
|
|
GskGpuOp * gsk_gpu_shader_op_vk_command_n (GskGpuOp *op,
|
|
|
|
GskGpuFrame *frame,
|
2023-11-04 02:57:38 +00:00
|
|
|
GskVulkanCommandState *state,
|
2023-08-21 00:18:37 +00:00
|
|
|
gsize instance_scale);
|
|
|
|
GskGpuOp * gsk_gpu_shader_op_vk_command (GskGpuOp *op,
|
|
|
|
GskGpuFrame *frame,
|
2023-11-04 02:57:38 +00:00
|
|
|
GskVulkanCommandState *state);
|
2023-08-21 00:18:37 +00:00
|
|
|
#endif
|
|
|
|
GskGpuOp * gsk_gpu_shader_op_gl_command_n (GskGpuOp *op,
|
|
|
|
GskGpuFrame *frame,
|
2023-11-04 02:57:38 +00:00
|
|
|
GskGLCommandState *state,
|
2023-08-21 00:18:37 +00:00
|
|
|
gsize instance_scale);
|
|
|
|
GskGpuOp * gsk_gpu_shader_op_gl_command (GskGpuOp *op,
|
2023-08-29 06:34:55 +00:00
|
|
|
GskGpuFrame *frame,
|
2023-11-04 02:57:38 +00:00
|
|
|
GskGLCommandState *state);
|
2023-08-21 00:18:37 +00:00
|
|
|
|
2024-07-03 17:51:16 +00:00
|
|
|
#define GSK_RGBA_TO_VEC4(_color) (float[4]) { (_color)->red, (_color)->green, (_color)->blue, (_color)->alpha }
|
|
|
|
#define GSK_RGBA_TO_VEC4_ALPHA(_color, _alpha) (float[4]) { (_color)->red, (_color)->green, (_color)->blue, (_color)->alpha * (_alpha) }
|
2024-07-13 00:05:41 +00:00
|
|
|
#define GSK_VEC4_TRANSPARENT (float[4]) { 0.0f, 0.0f, 0.0f, 0.0f }
|
2024-07-03 17:51:16 +00:00
|
|
|
|
|
|
|
static inline void
|
|
|
|
gsk_gpu_color_to_float (const float color[4],
|
|
|
|
float values[4])
|
|
|
|
{
|
|
|
|
values[0] = color[0];
|
|
|
|
values[1] = color[1];
|
|
|
|
values[2] = color[2];
|
|
|
|
values[3] = color[3];
|
|
|
|
}
|
2023-12-25 04:02:51 +00:00
|
|
|
#include <graphene.h>
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
gsk_gpu_point_to_float (const graphene_point_t *point,
|
|
|
|
const graphene_point_t *offset,
|
|
|
|
float values[2])
|
|
|
|
{
|
|
|
|
values[0] = point->x + offset->x;
|
|
|
|
values[1] = point->y + offset->y;
|
|
|
|
}
|
|
|
|
|
2023-08-21 00:18:37 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|