gpu: Introduce GskGpuShaderImage

It's a struct collecting all relevant info for a texture passed to a
shader.

The ultimate goal is to get rid of the descriptors and let ops
manage them on thir own.
This commit is contained in:
Benjamin Otte 2024-07-18 22:42:15 +02:00
parent a118cbb3ff
commit b1e441d18a
5 changed files with 44 additions and 24 deletions

View File

@ -49,15 +49,13 @@ static const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = {
};
void
gsk_gpu_colorize_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GskGpuColorStates color_states,
GskGpuDescriptors *descriptors,
guint32 descriptor,
const graphene_rect_t *rect,
const graphene_point_t *offset,
const graphene_rect_t *tex_rect,
const float color[4])
gsk_gpu_colorize_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GskGpuColorStates color_states,
GskGpuDescriptors *descriptors,
const graphene_point_t *offset,
const GskGpuShaderImage *image,
const float color[4])
{
GskGpuColorizeInstance *instance;
@ -69,8 +67,8 @@ gsk_gpu_colorize_op (GskGpuFrame *frame,
descriptors,
&instance);
gsk_gpu_rect_to_float (rect, offset, instance->rect);
gsk_gpu_rect_to_float (tex_rect, offset, instance->tex_rect);
instance->tex_id = descriptor;
gsk_gpu_rect_to_float (image->coverage ? image->coverage : image->bounds, offset, instance->rect);
gsk_gpu_rect_to_float (image->bounds, offset, instance->tex_rect);
instance->tex_id = image->descriptor;
gsk_gpu_color_to_float (color, instance->color);
}

View File

@ -10,10 +10,8 @@ void gsk_gpu_colorize_op (GskGpuF
GskGpuShaderClip clip,
GskGpuColorStates color_states,
GskGpuDescriptors *desc,
guint32 descriptor,
const graphene_rect_t *rect,
const graphene_point_t *offset,
const graphene_rect_t *tex_rect,
const GskGpuShaderImage *image,
const float color[4]);

View File

@ -2502,10 +2502,14 @@ gsk_gpu_node_processor_add_shadow_node (GskGpuNodeProcessor *self,
gsk_gpu_clip_get_shader_clip (&self->clip, &shadow_offset, &child->bounds),
gsk_gpu_node_processor_color_states_for_rgba (self),
desc,
descriptor,
&child->bounds,
&shadow_offset,
&tex_rect,
&(GskGpuShaderImage) {
image,
GSK_GPU_SAMPLER_TRANSPARENT,
descriptor,
&child->bounds,
&tex_rect,
},
GSK_RGBA_TO_VEC4 (&shadow->color));
}
else
@ -2736,10 +2740,14 @@ gsk_gpu_node_processor_add_mask_node (GskGpuNodeProcessor *self,
gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, &node->bounds),
gsk_gpu_node_processor_color_states_for_rgba (self),
self->desc,
descriptor,
&node->bounds,
&self->offset,
&mask_rect,
&(GskGpuShaderImage) {
mask_image,
GSK_GPU_SAMPLER_DEFAULT,
descriptor,
&node->bounds,
&mask_rect,
},
GSK_RGBA_TO_VEC4_ALPHA (rgba, self->opacity));
}
else
@ -2892,10 +2900,14 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
gsk_gpu_clip_get_shader_clip (&self->clip, &glyph_offset, &glyph_bounds),
gsk_gpu_node_processor_color_states_for_rgba (self),
self->desc,
descriptor,
&glyph_bounds,
&glyph_origin,
&glyph_tex_rect,
&(GskGpuShaderImage) {
image,
GSK_GPU_SAMPLER_DEFAULT,
descriptor,
&glyph_bounds,
&glyph_tex_rect
},
GSK_RGBA_TO_VEC4 (&color));
offset.x += glyphs[i].geometry.width * inv_pango_scale;

View File

@ -5,8 +5,19 @@
#include "gskgputypesprivate.h"
#include "gskgpucolorstatesprivate.h"
#include <graphene.h>
G_BEGIN_DECLS
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 */
};
struct _GskGpuShaderOp
{
GskGpuOp parent_op;

View File

@ -15,6 +15,7 @@ typedef struct _GskGpuFrame GskGpuFrame;
typedef struct _GskGpuImage GskGpuImage;
typedef struct _GskGpuOp GskGpuOp;
typedef struct _GskGpuOpClass GskGpuOpClass;
typedef struct _GskGpuShaderImage GskGpuShaderImage;
typedef struct _GskGpuShaderOp GskGpuShaderOp;
typedef struct _GskGpuShaderOpClass GskGpuShaderOpClass;
typedef struct _GskVulkanDescriptors GskVulkanDescriptors;