Commit Graph

3122 Commits

Author SHA1 Message Date
Benjamin Otte
7fb11dfeb0 gpu: Print filename in exceptions
I want to know which shader I screwed up.
2024-07-22 01:28:40 +02:00
Benjamin Otte
6d09eed90e gpu: Remove unused argument
It's always passing NULL.
2024-07-22 01:28:40 +02:00
Benjamin Otte
2a9056b49e ngl: Fix crash at startup
Commit 1580490670 included a reordering of
acquiring the frame before making the context current.

Sometimes (like at startup) new frames need to be created.

Setting up a new frame assumed the GL context was current.

Change it so that we delay the one GL setup we do in frames until later.
2024-07-19 21:37:48 +02:00
Benjamin Otte
300639e537 vulkan: Use right check for waiting on external image semaphore
Commit 3aa6c27c26 changed the initial layout of imported dmabuf images,
but did not adapt this check.
2024-07-17 22:59:23 +02:00
Benjamin Otte
ad218f0786 gpu: Pass the pass to frame_submit()
We will need that in the next commit.
2024-07-17 22:59:23 +02:00
Benjamin Otte
4966f8cdf8 vulkan: Add an acquire semaphore to frames
Vulkan requires us waiting on the image acquired from
vkAcquireNextImageKHR() before we start rendering to it, as that
function is allowed to return images that are still in use by the
compositor.
Because of that requirement, vkAcquireNextImageKHR() requires a
semaphore or fence to be passed that it can signal once it's done.

We now use a side channel to begin_frame() - calling
set_draw_semaphore() - to pass that semaphore so that the
vkAcquireNextImageKHR() call inside begin_frame() can use it, and then
we can wait on it later when we submit.

And yes, this is insanely convoluted, the Vulkan developers should
totally have thought about GTK's internal designs before coming up
with that idea.
2024-07-17 22:59:23 +02:00
Benjamin Otte
1580490670 gpu: add gsk_gpu_frame_begin/end()
These are just factoring out gdk_draw_context_begin/end_frame() so I can
add one tiny thing there later.

And I did both even though I only need one, because it felt wrong to
just do one.
2024-07-17 22:59:23 +02:00
Benjamin Otte
3cf5e8cf4e gpu: Move gc calls further to the edges of the function
Make the function look like that:

1. handle special case
2. maybe GC
3. draw
4. queue next gc
5. cleanup

This seems like the sanest approach to avoid gc() collecting things
necessary for drawing in the future.

And I need to refactor stuff, so having it out of the way is a good
idea.
2024-07-17 22:59:23 +02:00
Benjamin Otte
d21ac80178 gpu: Simplify a function
Now that we only ever use 2 images max per shader due to the removal of
the ubershader, we can just hardcode it in the function.
2024-07-17 22:59:23 +02:00
Benjamin Otte
11543a229a texturedownloader: Add color state
... and plumb the color state through the downloading machinery, where
no matter what path it takes it ends up in
gdk_memory_convert_color_state() or gdk_memory_convert().

The 2nd of those has been expanded to optionally do colorstate
conversion when the 2 colorstates are different.
2024-07-16 21:23:44 +02:00
Benjamin Otte
37bea9d162 gpu: Don't transition invalid cache items
When a cache item is invalid, don't move it into the hash table.
Instead, just delete it.

Something like this could happen:

1. A texture is cached
In the case of #6867 this would be a webpage in epiphany.

2. The texture cache item is garbage-collected
For example, epiphany might switch to a new tab, and the previous page's
texture will remain. After 15s or so, we collect our item for that
texture.

3. The texture is cached again, but in the target colorspace
We now decide we need the texture again, but not in any colorspace, we
need it in the target colorspace. This might be because we run an
effect on it (like a crossfade) or because we want mipmaps (like in the
overview map, where its zoomed out).

4. The old invalid item is transitioned into the hash table
We now have an invalid item in the hash table. This is extra bad,
because it had only one reference (from the texture), but we treat it
like it has 2 (from us in the hash table and from the texture).
So depending on if the texture is freed before we reuse it, we get
different results: If it was free, we get invalid memory accesses, if it
was not freed, we treat it like a valid cache item and think the image
inside is still valid.

Fixes #6867
2024-07-16 03:15:36 +02:00
Michael Catanzaro
4c40395a38 gpu: fix memory corruption in cache_gc_cb()
gsk_gpu_device_gc() may release the last ref on the GskGpuDevice,
leading to memory corruption when setting priv->cache_gc_source = 0.

Includes a bit of refactoring, so the ref/unref wraps nicely around the
actual code.

Fixes crashes seen after using the inspector and closing the window,
thereby closing all windows of a display and releasing all references to
the device.

Fixes #6861
2024-07-14 21:54:57 +02:00
Benjamin Otte
5f8e83d75d gpu: Fix memleak in texture-scale code 2024-07-14 21:54:40 +02:00
Matthias Clasen
54e5cc296f colorstate: Add rec2100-pq and rec2100-linear
These are wide-gamut, HDR colorstates that we will need for HDR support.
2024-07-13 15:11:07 -04:00
Matthias Clasen
457fd68168 gpu: Make color conversion extensible
Change the glsl convert_color function to proceed in stages:
- first unpremultiply
- then linearize
- then transform linearly
- then delinearize
- then premultiply
All the steps are only taken if needed.
2024-07-13 15:09:12 -04:00
Benjamin Otte
648c780e91 gpu: Respect colorstate for offscreens
We want to render in at least the minimum required depth of the used
colorstate.
2024-07-13 14:51:49 -04:00
Benjamin Otte
6d263f8680 gpu: Add GSK_GPU_BLEND_NONE
Allows writing without blending. This is useful when copying/converting
textures.

In particular, we use it for colorspace conversions.
2024-07-13 10:56:47 +02:00
Benjamin Otte
d9ab6495ef gpu: Fix color convert path to not crash
The occlusion culling reorganization messed up this branch.

Make it work again.
2024-07-13 10:56:47 +02:00
Benjamin Otte
d54b68b93c gpu: Convert values to float[4] from GdkRGBA
We need to make sure our clear values are in the right colorstate, not
in sRGB.

The occluision culling managed to sneak through the big transition for
that.
2024-07-13 02:07:15 +02:00
Benjamin Otte
761346ed5a gpu: Remove unused macro
This is a leftover from the pre-color-managed times
2024-07-13 02:07:15 +02:00
Benjamin Otte
1c1b78aa1c gpu: Implement tiling for texture-scale nodes
This is actually the node Loupe is using, so having tiling work with it
is important.

Because of the previous commit, different filters are supported fine.

Fixes: #6324
2024-07-12 18:09:46 +02:00
Benjamin Otte
cdb2308ddd gpu: Add filter support to tiled images
This allows mipmapping if downscaled a lot, like we do for non-tiled
images.

A side effect is that due to the simpler caching for tiles, we can only
cache the mipmapped images in one colorstate. But we need to pick a
potentially non-default one, because we want to mipmap in a linear
colorstate.

So this is somewhat suboptimal. Patches with improvements accepted.
2024-07-12 17:31:36 +02:00
Benjamin Otte
c581f722bd gpu: Split out a function
We'll need mapping scaling filters to samplers elsewhere soon.
2024-07-12 17:31:36 +02:00
Benjamin Otte
340c98c6cd gpu: Split a function
Split drawing the tiles from setting up the offscreen for drawing the
tiles.
2024-07-12 17:31:36 +02:00
Benjamin Otte
39f5c5bf49 gpu: Implement tiling for texture nodes
Use the new cache feature to split oversized textures into tiles the
size given by the new device API.

Then number those tiles from left to right and top to bottom and use
that number as the tile id.
2024-07-12 17:31:36 +02:00
Benjamin Otte
392f6855ca gpu: Add gsk_gpu_device_get_tile_size()
This allows managing tiling of images. And I'd like this value to live
somewhere prominent instead of as a hardcoded number in the
nodeprocessor.
2024-07-12 17:31:36 +02:00
Benjamin Otte
1cae48ab93 gpu: Add a tile cache
Nobody is using it yet, but it's the API.

It's very simple and just allows adding tiles by an index. What that
index means is up to the caller.
2024-07-12 17:31:36 +02:00
Benjamin Otte
d0f8ef09a0 gpu: Do a GC run after every tile of large images
When we draw large images, we absolutely do not want to keep memory that
we do not need. So do a GC run after every tile. That otentially slows
down things, but it also improves the chances of not running out of
memory.

Here's the node for the image I managed to create after I applied this
patch:

repeat {
  bounds: 0 0 50000 50000;
  child: text {
    font: "Noto Color Emoji 10000px";
    glyphs: 661 0 0 0 color;
    offset: 0 10000;
    hint-style: none;
  }
}
2024-07-12 16:57:23 +02:00
Benjamin Otte
0516dca116 vulkan: Don't try to use nonexisting formats
Handle the error that new rgba format exists.
2024-07-12 16:56:23 +02:00
Benjamin Otte
ebc6a043c9 gpu: Cleanups 2024-07-12 16:56:23 +02:00
Benjamin Otte
8e2ae79875 gpu: Change function to (transfer full)
Functions should behave as I expect, and I just spent an hour debugging
a refcount issue because I assumed our image creation functions return
refrences. Which is a very sane assumption.
2024-07-12 16:55:59 +02:00
Benjamin Otte
27ac764653 gpu: Don't multiply by 1/x, divide by x
This is less error-prone with floating point math, even though it is
somewhat slower.
2024-07-12 16:55:59 +02:00
Benjamin Otte
e40ad5faa5 gpu: Cache textures when doing copies
The texture and texture-scale node code is creating image copies
for mipmaps and to adapt to the compositing colorstate.

Those texture should be cached.
2024-07-11 14:57:20 +02:00
Benjamin Otte
dd393a4a0e gpu: Split out texture lookup function
It's unused in 3 function and has become somewhat unwieldy.
2024-07-11 14:57:20 +02:00
Benjamin Otte
881954dfca gpu: Rework texture caching
We want to cache textures in the compositing color state, not in their
original color state. However, the compositing color state may change
(think multimonitor setups).

So we additionally keep a cache per colorstate.

That means texture lookup is now a 3-step process:

1. Look up in the compositing colorstate's cache

2. Look up in the general cache

3. Upload
2024-07-11 14:57:20 +02:00
Benjamin Otte
cf12503fec gpu: Don't replace cache items
Instead, keep them. This is not useful yet, but will become so in the
next commits.
2024-07-11 14:57:20 +02:00
Benjamin Otte
ad757cccb6 Don't use GL_SRGB for premultiplied textures
GL_SRGB is doing postmultiplied alpha, so if the texture is
premultiplied, we can't use this optimization.

The optimization still works for unpremultiplied and opaque images,
because those don't do that step.
2024-07-11 14:57:20 +02:00
Benjamin Otte
b801eae00f gpu: All ops obey the ccs now
Remove the macro used for the not-yet converted ops.
2024-07-11 14:57:20 +02:00
Benjamin Otte
2fe9ff7918 gpu: Make mask op obey ccs
No colorstate conversions allowed here, though technically we could use
the alternate color state for the source most of the time, as the mask's
colorstate is only relevant for luminance.
2024-07-11 14:57:20 +02:00
Benjamin Otte
c407582096 gpu: Make blur op obey ccs
Blend ops don't do colorspace conversion, so this commit just hardcodes
that and rewrites the shader to use recent APIs.
2024-07-11 14:57:20 +02:00
Benjamin Otte
0fc3dbaa9b gpu: Make texture op obey ccs
Well, texture ops actually don't do any colorspace stuff, but let's
explicitly hardcode that.
2024-07-11 14:57:20 +02:00
Benjamin Otte
77ed264714 gpu: Introduce gsk_gpu_color_states_create_equal()
This is a function that's meant to be used whenever both color states
of the shader are equal. In that case no colorspace conversion code
needs to be created and shaders can be shared.
2024-07-11 14:57:20 +02:00
Benjamin Otte
a14efce914 gpu: Make blur op obey ccs 2024-07-11 14:57:20 +02:00
Benjamin Otte
08f90a188c gl: Force U8 textures for U8_SRGB depths
The GL renderer is using FLOAT32 instead of GL_SRGB, which is screwing
up the node-editor by making it turn on high bit depth unconditionally.

So until someone fixes the GL renderer properly, do this quickfix.
2024-07-11 14:57:20 +02:00
Benjamin Otte
df46eeafdb gpu: Make colormatrix op obey ccs
The colormatrix needs to be applied to unpremultiplied values, so we use
the alternative colorstate for that.
2024-07-11 14:57:20 +02:00
Benjamin Otte
0029286a1e gpu: Remove unused function
The colormatrix shader is no longer used for opacity.
2024-07-11 14:57:20 +02:00
Benjamin Otte
0e46d4eb98 gpu: Pass sampler to the image op
That way, we can use it in one other place where we want to use mipmaps.

I don't really like it because it adds yet another argument,
but then the one new caller was selecting suboptimal shaders, and that's
worse.
2024-07-11 14:57:20 +02:00
Benjamin Otte
f80e3fff92 gpu: Don't use the colormatrix shader for opacity
The colormatrix shade does a whole matrix multiplication, which is
absolutely not necessary.

The convert shader has builtin opacity handling and when the colorstates
match will do no conversion.
2024-07-11 14:57:20 +02:00
Benjamin Otte
504c6ba792 gpu: Don't use color matrix for opacity
We can use the regular image op which will select the fastest shader.
2024-07-11 14:57:20 +02:00
Benjamin Otte
c0aba9aee1 gpu: Make crossfade op obey ccs
I didn't have an idea what to use the alternate color state for, so I
don't use it.
2024-07-11 14:57:20 +02:00
Benjamin Otte
b97cf2b9d9 gpu: Track image colorstate
So far we only track the image colorstate and convert if necessary.

There is no caching of the converted images happening.
2024-07-11 14:57:20 +02:00
Benjamin Otte
f81e7b2112 gpu: Make conic gradient op obey ccs
Straight copy of the linear gradient changes.
2024-07-11 14:57:20 +02:00
Benjamin Otte
b59e4a929e gpu: Make radial gradient op obey ccs
Straight copy of the linear gradient changes.
2024-07-11 14:57:20 +02:00
Benjamin Otte
099d72f037 gpu: Make box shadow op obey ccs 2024-07-11 14:57:20 +02:00
Benjamin Otte
73acb41931 gpu: Make colorize op obey ccs 2024-07-11 14:57:20 +02:00
Benjamin Otte
ebb7fdb099 gpu: Make linear gradient op obey ccs
The alternative color state is used as the interpolation color state.
Colors are transformed into that space on the CPU.

For now we set the interpolation color state to SRGB, because ultimately
we want to let callers specify it, so having something that's easy to
map to that behavior is desirable.
Otherwise we might have chosen to interpolate in the compositing
colorstate.

It also means that we need to premultiply colors on the CPU now because
of the limitations of the shader colorstates APIs.
2024-07-11 14:57:20 +02:00
Benjamin Otte
ec3cb0ad9a gpu: Make border op obey ccs 2024-07-11 14:57:20 +02:00
Benjamin Otte
7ffef6792f gpu: Make rounded-color op obey ccs
This is the same as the color op.
2024-07-11 14:57:20 +02:00
Benjamin Otte
383148dc31 gpu: Make color op obey ccs
This makes use of the GskGpuColorStates by setting the ccs as output
colorstate and the color's colorstate as alternative color state.

The shader adaption is very straightforward because of that.
2024-07-11 14:57:20 +02:00
Benjamin Otte
a31601ccfc gpu: Make clear op obey ccs
This is the first op to obey the compositing color state. This means
from now on until all ops obey the ccs rendering is broken when ccs is
not set to linear.

I'll keep individual ops in seperate commits for easier review, because
they all need different adaptations.
2024-07-11 14:57:20 +02:00
Benjamin Otte
a587492cad gpu: Handle target not being composite colorstate
Render to an offscreen and add a final conversion if the target
colorstate is not a rendering colorstate.

This now allows the GPU renderer to render to any colorstate.
2024-07-11 14:57:20 +02:00
Benjamin Otte
f65d4914e4 gpu: Port convert op to GskGpuColorStates
Make it handle straight alpha, too, by checking if the alt colorspace is
premultiplied - which is the colorspace of the source.
2024-07-11 14:57:20 +02:00
Benjamin Otte
88dc49a5b6 gpu: Print the color states of shader ops
Makes the verbose output (a lot) more verbose, but it makes the
colorstates used in the shaders very visible.

And it will be relevant once people start using different colorstates
everywhere (like oklab for gradients/colors and so on).
2024-07-11 14:57:20 +02:00
Benjamin Otte
91d970e9c5 gpu: Add shaders for the new specialization constant
This adds the following functions:

output_color_from_alt()
alt_color_from_output()
  Converts between the two colors

output_color_alpha()
alt_color_alpha()
  Multiplies a color with an alpha value
2024-07-11 14:57:20 +02:00
Benjamin Otte
6c5ae48a05 gpu: Pass color states as specialization constant
This adds a GdkColorStates that encodes 2 of the default GdkColorStates
and wether their values are premultiplied or not.

Neither do the shaders do anything with this information yet, nor do the
shaders do anything with it yet, this is just the plumbing.
2024-07-11 14:57:20 +02:00
Benjamin Otte
d85ec2cbb4 gpu: create SRGB images
If desired, try creating GL_SRGB images. Pass a try_srgb boolean down to
the image creation functions and have them attempt to create images like
that.

When it is not possible to create srgb images in the given format, just
fall back to regular images. The calling code is meant to check the
GSK_GPU_IMAGE_SRGB flags to determine the actual format of the resulting
image.
2024-07-11 14:57:20 +02:00
Benjamin Otte
05b79bc378 gpu: Handle SRGB in render_texture()
When GDK_MEMORY_U8_SRGB is desired by the node, and a SRGB image is
created, pick SRGB_LINEAR as the colorspace to pass to frame_render().
2024-07-11 14:57:20 +02:00
Matthias Clasen
3ba63315d5 gpu: Pass compositing color states
Make the node processor and the pattern writer track the current
compositing color state. Color state nodes change it. We pass
the surface color state down via the frame apis.

The name of the variable is "ccs" for "compositing color space". It's an
unused variable name and it's common enough to deserve a short and sweet
name.
2024-07-11 14:57:20 +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
4fa6f791f4 cairo: Use the draw context's color state
This just passes through the sRGB set by the GDK backends instead of
hardcoding sRGB, so no functional changes.
2024-07-11 14:57:20 +02:00
Benjamin Otte
6287eaa745 cairo: Add colorstate to GskRenderNode::draw and use it
This adds the following:
- ccs argument to GskRenderNode::draw
  This is the compositing color state to use when drawing.

- make implementations use the CCS argument
  FIXME: Some implementations are missing

- gsk_render_node_draw_with_color_state()
  Draws a node with any color state, by switching to its compositing
  color state, drawing in that color state and then converting to the
  desired color state.
  This does draw the result OVER the previous contents in the passed in
  color state, so this function should be called with the target being
  empty.

- gsk_render_node_draw_ccs()
  This needs to be passed a css and then draws with that ccs.
  The main use for this is chaining up in rendernode draw()
  implementations.

- split out shared Cairo functions into gdkcairoprivate.h
  gskrendernode.c and gskrendernodeimpl.c need the same functions.
  Plus, there's various code in GDK that wants to use it, so put it in
  gdk/ not in gsk/

gsk_render_node_draw() now calls gsk_render_node_draw_with_color_state()
with GDK_COLOR_STATE_SRGB.
2024-07-11 14:57:20 +02:00
Benjamin Otte
ab7d969700 gdk: Add color state arg to gdk_texture_download_surface()
All callers set it to SRGB at the moment.
2024-07-11 14:57:20 +02:00
Matthias Clasen
5a7d7cc9f5 gsk: Show srgb information in verbose output
Show which offscreens are using an srgb format.
2024-07-11 14:57:20 +02:00
Benjamin Otte
1bbf5f7a17 gdk: Add GDK_MEMORY_NONE depth
That's basically the "undefined" value. We need that when drawing
nothing, which so far only happens with empty container nodes.

But empty container nodes can be children of other nodes, and that makes
things propagate. So instead of catching them, force the whole rest of
the code to deal with an undefined depth.

We also can't just set a random depth, because that will cause merging
to fail.
2024-07-11 14:57:20 +02:00
Matthias Clasen
db3b3c62bb ngl: Mark backbuffers as srgb
When the surface tells us that a surface is using an sRGB backbuffer,
set the corresponding flag on the backbuffer.
2024-07-11 14:57:20 +02:00
Matthias Clasen
de76045939 vulkan: Mark swapchain images as GSK_GPU_IMAGE_SRGB
Detect if an SRGB format is in use and mark the images as such.

So far this doesn't happen, but once it does, things will work.
2024-07-11 14:57:20 +02:00
Benjamin Otte
16c29a7db5 texture: Add gdk_texture_get_depth()
... and use it.
2024-07-11 14:57:20 +02:00
Benjamin Otte
b5b0002d24 rendernode: Return the right depth for colors
This makes sure we return U8_SRGB for GdkRGBA colors with linear
compositing.
2024-07-11 14:57:19 +02:00
Benjamin Otte
a7ceb8ce66 gdk: Add GDK_MEMORY_U8_SRGB depth
This is an experiment for now, but it seems that encoding srgb inside
the depth makes sense, as we not just use depth to decide on the
GL fbconfigs/Vulkan formats to pick, depth also encodes how the [0...1]
color values are quantized when stored.

Let's see where this goes.
2024-07-11 14:57:19 +02:00
Benjamin Otte
6dea23128a gpu: Add the GSK_GPU_IMAGE_SRGB flag
This commit just adds the flag, but I wanted to make it an individual
commit to explain the purpose:

The SRGB flag is meant to be used for images that have an SRGB format.
In Vulkan terms, that means VK_FORMAT_*_SRGB.
In GL, it means GL_SRGB or GL_SRGB_ALPHA.

As these formats have been madatory since GL 3.0, we can (ab)use them
uncoditionally. Images in these formats are renderable, too, so it's
not just usable for uploading.

What these images allow is treating the data as sRGB while shaders
access them as linear, thereby getting sRGB<=>linear conversions for
free.

It is also possible to switch off the linearization of these images and
treat them as sRGB, which allows all sorts of shenanigans, though one
has to be careful if that turning off applies to the relevant GL/Vulkan
code in question.
2024-07-11 14:57:19 +02:00
Benjamin Otte
2f4e19d514 gdk: Allow querying GL SRGB formats
Nobody is using this yet.
2024-07-11 14:57:19 +02:00
Benjamin Otte
1273413c7b vulkan: Import GL textures via dmabufs
If the GL texture is exportable to a dmabuf, we can just use our dmabuf
importing code to get that texture into Vulkan.
There is no need to go via host memory in that case.

And if it doesn't work, we just fall back, like before.
2024-07-11 14:14:35 +02:00
Benjamin Otte
ef3f48a2be vulkan: Refactor gsk_vulkan_image_new_for_dmabuf()
It now works with just a dmabuf and doesn't take a texture anymore.

Which means it can be used from other codepaths in the future.
2024-07-11 14:14:35 +02:00
Benjamin Otte
fff78b60e9 gpu: All nodes are implemented
Unimplemented nodes are a failure now.

We make this a soft failure with a g_warning() so that during
development when adding new nodes, the renderer doesn't instantly crash,
but instead prnts a warning.

But we do consider unimplemented nodes a bug now.

Because of that, add_fallback_node() is now renamed to add_cairo_node().
2024-07-11 13:34:37 +02:00
Benjamin Otte
9abc7fc80b gpu: Don't hand Cairo invalid nodes
When encountering an invalid node, exit asap. Don't draw it with Cairo,
Cairo won't know what to do with it either.
2024-07-11 13:34:37 +02:00
Benjamin Otte
d8059ebdd2 gpu: "Implement" GL shader nodes
Instead of falling back to Cairo, draw the pink error rectangle
directly.
2024-07-11 13:34:36 +02:00
Matthias Clasen
8c988a7b07 Take all transforms into account
When determining which way is up for the offloaded texture, we
must take all transforms into account - the ones outside the
subsurface node, and the ones inside.
2024-07-10 22:11:13 +02:00
Benjamin Otte
4f2b639a24 gpu: We can handle 90 degree rotations quite easily 2024-07-10 22:06:24 +02:00
Benjamin Otte
3e01924ca3 gpu: Handle dihedral transforms in occlusion culling 2024-07-10 22:06:24 +02:00
Matthias Clasen
4d2884bde7 offload: Support dihedral transforms
When looking for the texture transform, allow dihedral transforms,
and pass them along when attaching to the subsurface.
2024-07-10 21:34:12 +02:00
Benjamin Otte
6065165060 Add gdk_dihedral_swaps_xy
This function determines if a dihedral transform swaps x and y.
2024-07-10 21:34:12 +02:00
Benjamin Otte
9272bf96f6 gpu: Handle affine transforms without touching matrix
By moving negative affines to be treated like dihedrals, because they
also need support of the modelview, we can free up the affine branch for
doing work without it.

Not a big win I guess, but it makes scaling more efficient.
2024-07-10 21:34:12 +02:00
Benjamin Otte
ae3efb2d2f gpu: Implement transform support for dihedral transforms
This allows handling them without ever needing to offscreen for losing
the clip, because the clip can always be transformed.

Also, all the optimizations keep working, like occlusion culling,
clears, and so on.

The main benefit of this work is the ability for offloading to now
handle dihedral transforms of the video buffer.

The other big advantage is that we can now start our rendering with a
dihedral transform from the compositor.
2024-07-10 21:34:12 +02:00
Benjamin Otte
b9ecae84f5 gpu: Shuffle some transform flags around
No need to check for negative numbers now that we can just use the
category that doesn't give us any.
2024-07-10 21:34:12 +02:00
Benjamin Otte
cd3286c71a gpu: Switch to GskFineTransformCategory
This is purely replacing the enums, no functional changes.
2024-07-10 21:34:12 +02:00
Benjamin Otte
83c2766e3f rendernode: Handle rotation transforms in opacity calculations
Tests included.
2024-07-10 21:34:12 +02:00
Benjamin Otte
5f719c8ea3 transform: Implement transform_point() for dihedrals
No longer using the default path and risking rounding issues.
2024-07-10 21:34:12 +02:00
Benjamin Otte
555f7d5404 transform: Implement transform_bounds() for dihedrals
No longer using the default path and risking rounding issues.
2024-07-10 21:34:12 +02:00
Benjamin Otte
3bcfc5539c transform: Add gsk_transform_to_dihedral()
I hate everything about this.

Is is xy or yx now?
Do I need to combine(a, b) or combine(b, a)?
2024-07-10 14:38:48 +02:00