Commit Graph

170 Commits

Author SHA1 Message Date
Matthias Clasen
226652edb0 gsk: Add a cicp convert shader
This shader receives cicp parameters via uniforms, and converts
the texture data from or to the output colorstate. It computes
the matrix in the vertex shader, and then picks the eotf/oetf
according to the cicp parameters in the fragment shader.
2024-07-24 08:16:08 -06:00
Benjamin Otte
67b9fb43d0 gpu: Completely revamp YCbCr handling
There is now a GskGpuYcbcr struct that maintains all the Vulkan
machinery related to YCbCrConversions.
It's a GskGpuCached, so it will make itself go away when it is no longer
used, ie a video stopped playing.
2024-07-22 19:40:24 +02:00
Benjamin Otte
1b2156493b gpu: Remove descriptors
They are no longer a thing with the new way we manage textures.
2024-07-22 19:40:24 +02:00
Benjamin Otte
eccdb594eb gpu: Remove straightalpha shader
As the new convert shader can do everything this shader could, use it
instead.
2024-07-11 14:57:20 +02:00
Matthias Clasen
a78796f22c gpu: Add a color convert shader
This shader converts between two color states, by using the
same functions that we use on the cpu. The conversion to perform
is passed as part of the variation.

As premultiplication is part of color states on the shader, we also
encode the premultiplication in the shader.
And because opacity is a useful optimization, we also allow setting
opacity.

For now, the only possible color states are srgb and srgb-linear.
2024-07-11 14:57:20 +02:00
Benjamin Otte
012c4b9425 gpu: Remove the ubershader
It didn't bring any noticable benefits and it isn't compatible with the
way we intend to do colorstate support.

And nobody seems to want to spend time on it, so let's get rid of it.

We can bring it back later if someone wants to work on it.
2024-07-07 05:19:32 +02:00
Benjamin Otte
71161b6352 gpu: Split cache and device
This is for 3 reasons:

1. Separation of concerns
   The device is meant to manage the Vulkan/GL device and check stuff
   like image sizes.
   Caching is not part of that.

2. Refcounting
   Images etc want to reference the device, but the cache wants to
   reference images. If the cache is the device, that's a refcycle.

3. Flexibility
   It's now easier to implement >1 cache, say one per depth or one per
   color state.
2024-07-03 19:55:15 +02:00
Maximiliano Sandoval
c73ff197e0
gsk: meson: Document renderers
These contain docstrings.
2024-06-29 15:14:32 +02:00
Benjamin Otte
5f03053569 gsk: include Vulkan renderer in public header
The Vulkan renderer can just be public API, because it doesn't expose
any Vulkan-specific APIs.
And it can just exist when compiled without Vulkan, because it can fail
to realize.

Also move get rid of the gsk/vulkan/gskvulkanrenderer.h header. It was
experimental and isn't necessary now that the renderer is included via
gsk.h.
2024-01-07 14:47:22 +01:00
Benjamin Otte
6e4a526ddf gpu: Add a blend mode shader
I'm a bit unsure about using the zero rect in the fallback situtation
where one image doesn't exist, but it seems to work.

This removes the last pattern-only rendernode and with that the last
fallback usage with disabled ubershader.
2024-01-07 07:22:53 +01:00
Benjamin Otte
b9651606d3 gpu: Add a cross-fade shader 2024-01-07 07:22:53 +01:00
Benjamin Otte
69c8278558 gpu: Add a radial gradient shader
This is mainly copy/paste, so now this almost identical gradient code
exists 3 times.
That's kinda suboptimal.
2024-01-07 07:22:53 +01:00
Benjamin Otte
0e9b967bf9 gpu: Add a conic gradient shader 2024-01-07 07:22:53 +01:00
Benjamin Otte
5cf3c70db0 gpu: Make blend modes configurable
For now, we only have OVER and ADD blend modes. This commit doesn't use
ADD, it just sets up all the machinery and refactors things.
2024-01-07 07:22:52 +01:00
Benjamin Otte
a031011e5e gpu: Add a linear-gradient shader
The shader can only deal with up to 7 color stops - but that's good
enough for the real world.

Plus, we have the uber shader.

And if that fails, we can still fall back to Cairo.

The code also doesn't handle repeating linear gradients yet.
2024-01-07 07:22:52 +01:00
Benjamin Otte
bd901896ee gpu: Add a mask shader
This shader can take over from the ubershader. And it can be used
instead of launching the ubershader when no offscreens are necessary.

Also includes an optimization that uses the colorize shader when
appropriate.
2024-01-07 07:22:52 +01:00
Benjamin Otte
1b38cbd410 gpu: Handle storage buffers via descriptors
This makes the (currently single) storage buffer handled by
GskGpuDescriptors.
A side effect is that we now have support for multiple buffers in place.
We just have to use it.

Mixed into this commit is a complete rework of the pattern writer.
Instead of writing straight into the buffer (complete with repeatedly
backtracking when we have to do offscreens), write into a temporary
buffer and copy into the storage buffer on committing.
2024-01-07 07:22:52 +01:00
Benjamin Otte
42d89a0ff1 gpu: Add a color matrix shader
This allows avoiding the uber shader in 2 important cases:

1. opacity - and Adwaita uses that a lot
2. color-matrix - it's used for symbolic icons
2024-01-07 07:22:52 +01:00
Benjamin Otte
d50e235753 gpu: Add back single descriptors set usage with descriptor indexing 2024-01-07 07:22:51 +01:00
Benjamin Otte
94063cbe92 gpu: Change the meson code for how SPIR-V is built
This does the same thing, but in a way that's a bit more flexible.
And it prepares the next commit...
2024-01-07 07:22:51 +01:00
Benjamin Otte
c29237c75d gpu: Add support for texture-scale nodes
This adds GSK_GPU_IMAGE_CAN_MIPMAP and GSK_GPU_IMAGE_MIPMAP flags and
support to ensure_image() and image creation functions for creating a
mipmapped image.

Mipmaps are created using the new mipmap op that uses
glGenerateMipmap() on GL and equivalent blit ops on Vulkan.

This is then used to ensure the image is mipmapped when rendering it
with a texture-scale node.
2024-01-07 07:22:51 +01:00
Benjamin Otte
b4a1ed2a70 gpu: Add straight alpha support
Add a GSK_GPU_IMAGE_STRAIGHT_ALPHA and use it for images that have
straight alpha.
Make sure those images get passed through a premultiplying pass with
the new straight alpha shader.

Also remove the old Postprocess flags from the Vulkan image that were a
leftover from copying that code from the old Vulkan renderer.
2024-01-07 07:22:51 +01:00
Benjamin Otte
d8db673fb7 gpu: Add a box shadow shader
Code was inspired mainly by
  https://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
and
  https://pcwalton.github.io/_posts/2015-12-21-drawing-css-box-shadows-in-webrender.html

So far the results aren't cached, that's the task of future commits.
2024-01-07 07:22:51 +01:00
Benjamin Otte
268ad54c6a gpu: Add a rounded color shader
There's multiple uses I want it for:

1. Generating the box-shadow area for blurring
2. Generating masks for rounded-rect masking
3. Optimizing the common use case of rounded-clip + color

Only the last one is implemented in this commit.
2024-01-07 07:22:50 +01:00
Benjamin Otte
53821da4d6 gpu: Refactor image handling
Introduce a new GskGpuImageDescriptors object that tracks descriptors
for a set of images that can be managed by the GPU.
Then have each GskGpuShaderOp just reference the descriptors object they are
using, so that the coe can set things up properly.

To reference an image, the ops now just reference their descriptor -
which is the uint32 we've been sending to the shaders since forever.
2024-01-07 07:22:50 +01:00
Benjamin Otte
e3bac4063c gpu: Copy the clear trick from the Vulkan shader
When drawing opaque color regions that are large enough, use
vkCmdClearAttachments()/glClear() instead of a shader. This speeds up
background rendering on particular on older GPUs.

See the commit messages of
  bb2cd7225e
  ce042f7ba1
  0edd7547c1
for a further discussion of performance impacts.
2024-01-07 07:22:50 +01:00
Benjamin Otte
48012a1ce4 gpu: Add a color shader
We don't want to use the pattern shader for simple colors, slow GPUs do
not like this at all.
2024-01-07 07:22:50 +01:00
Benjamin Otte
23c1ec07e7 gpu: Implement shadow nodes 2024-01-07 07:22:50 +01:00
Benjamin Otte
5ab8fde0bc gpu: Add colorize shader
... and use it for glyphs.

The name is a slight variation of the "coloring" name from the GL
renderer.
The functionality is exactly what the "glyph" shader from the Vulkan
renderer does.
2024-01-07 07:22:50 +01:00
Benjamin Otte
3efe1bef93 gpu: Add a border shader
Pretty much a copy of the Vulkan border shader.

A notable change is that the input arguments are changed, because GL
gets confused if you put a mat4 at the end.
2024-01-07 07:22:50 +01:00
Benjamin Otte
720ac700b3 gpu: Move the pattern code into the nodeprocessor
We need the nodeprocessor infrastructure to create patterns, so keeping
it in a different source file would just cause header headaches.
2024-01-07 07:22:50 +01:00
Benjamin Otte
ee3367697d gpu: Move pattern code into its own file
Now we can extend the pattern creation easily - and we can add new
patterns quickly later.

Plus, we need to keep this file in sync with pattern.glsl and it's neat
when those 2 files reference only each other.
2024-01-07 07:22:50 +01:00
Benjamin Otte
c6e19f0384 gpu: Add float array to shaders and add an ubershader
... and use it for a naive color node implementation using both
so I can test it actually works.
2024-01-07 07:22:50 +01:00
Benjamin Otte
e2b5e0d17d gpu: Add scissor operation
Nothing is using it yet (we don't do clipping) apart from initializing
the scissor rect at startup.
2024-01-07 07:22:49 +01:00
Benjamin Otte
1a85d569e3 gpu: Add ability to run shaders
This heaves over an inital chunk of code from the Vulkan renderer to
execute shaders.

The only shader that exists for now is a shader that draws a single
texture.
We use that to replace the blit op we were doing before.
2024-01-07 07:22:49 +01:00
Benjamin Otte
9ddae8aebc gpu: Add outline of new GPU renderer
For now, it just renders using cairo, uploads the result to the GPU,
blits it onto the framebuffer and then is happy.

But it can do that using Vulkan and using GL (no idea which version).

The most important thing still missing is shaders.

It also has a bunch of copy/paste from the Vulkan renderer that isn't
used yet.
But I didn't want to rip it out and then try to copy it back later
2024-01-07 07:22:49 +01:00
Benjamin Otte
1e54e838e0 vulkan: Remove GskVulkanRenderer
We want to introduce a new one next.

Technically, this breaks API, because gsk_vulkan_renderer_new() is going
away, but practically, we're gonna bring it back once we introduce that
renderer in a few commits.
2024-01-07 07:22:49 +01:00
Matthias Clasen
79009d4158 gsk: Handle straight-alpha dmabufs
This omission was noticed by Benjamin Otte. Add a premultiply
uniform to the external shader, and add a separate premultiply
shader for the non-external case.
2023-12-15 07:40:27 -05:00
Matthias Clasen
34c16b0df2 gsk: Add code to offload to subsurfaces
This code walks the node tree, finds subsurface nodes, determines
if we can offload to the subsurface, and if yes, does so. This
isn't used yet.
2023-11-13 22:17:35 +01:00
Matthias Clasen
976143fbe9 gsk: Add a shader for external textures
This shader uses samplerExternalOES to sample an external texture
and blit it into a 'normal' texture. It only works in GLES, but
we won't use it outside of GLES.
2023-10-22 16:42:17 -04:00
Matthias Clasen
8f1d8d7cb5 path: Split off gskpathparse.c
This is a standalone piece of code,
and nicely fits into its own source file.
2023-09-17 12:29:46 -04:00
Matthias Clasen
6defdb4e8a Drop unused code
we are not using any gsk_spline functions currently.
2023-08-26 11:29:09 -04:00
Matthias Clasen
007cfeac94 Add GskPathMeasure
GskPathMeasure is the public API for path lengths.
2023-08-25 20:16:49 -04:00
Benjamin Otte
8862666b5a build: GSK doesn't depend on gdk-pixbuf 2023-08-21 05:19:37 +02:00
Benjamin Otte
3adf02445f build: Don't use configure_file() when custom_target() works
These two files don't need to be built when configuring, they are only
needed during build.
2023-08-21 05:19:37 +02:00
Matthias Clasen
db71c07f8f Add GskStroke
A GskStroke struct collects the parameters that are
needed for stroking a path.
2023-08-07 13:02:57 -04:00
Matthias Clasen
1b5dfcba7e gsk: Add GskPath
This commit adds the basic infrastructure for paths.
The public APIs consists of GskPath, GskPathPoint and
GskPathBuilder.

GskPath is a data structure for paths that consists
of contours, which in turn might contain Bézier curves.
The Bezier data structure is inspired by Skia, with separate
arrays for points and operations. One advantage of this
arrangement is that start and end points are shared
between adjacent curves.

A GskPathPoint represents a point on a path, which can
be queried for various properties.

GskPathBuilder is an auxiliary builder object for paths.
2023-08-06 20:48:09 -04:00
Benjamin Otte
4d9e7d30b0 vulkan: Add premultiply step to texture upload
When a GdkMemoryFormat is not supported natively and there's
postprocessing required, add a way to mark a VulkanImage as such via the
new postprocess flags.

Also allow texting such iamges only with new_for_upload() and detect
when that is the case and then run a postprocessing step that converts
that image to a suitable format.
This is done with a new "convert" shader/op.

This now supports all formats natively, no conversions happen on the CPU
anymore (unless the GPU is old).
2023-07-19 21:30:35 +02:00
Benjamin Otte
f366ccc0b2 vulkan: Introduce GskVulkanShaderOp
It's the new base class for shaders now.

We're doing deep inheritance now, woohoo!

Also, port all the shader ops to it.
2023-07-16 13:16:43 +02:00
Benjamin Otte
db2029d931 vulkan: Add GskVulkanDownloadOp
This op queues a download of an image. The image will only be available
once the commands finished executing, so it requires waiting for the
render to finish, which makes the API a bit awkward.

Included is also a download_png_op() useful for debugging.
2023-07-16 13:16:43 +02:00