Commit Graph

78772 Commits

Author SHA1 Message Date
Benjamin Otte
3ac50b81f2 vulkan: Make gdk_display_create_vulkan_context() take a surface
This is so we can deprecate gdk_surface_create_vulkan_context() which is
public API in the next commit.
2024-01-07 14:47:22 +01:00
Benjamin Otte
6bac377fa5 gdk: Don't include vulkan.h in public API anymore 2024-01-07 14:47:22 +01:00
Benjamin Otte
3bb1c2298f gsk: Emit deprecation warning for #include <gsk/gl/gskglrenderer.h>
This is a bit hacky, but it seems to work.

Note: It doesn't work inside GTK because GTK_COMPILATION during the
whole build.
2024-01-07 14:47:22 +01:00
Benjamin Otte
637f6cc81b gtk: Don't #include <gsk/gl/gskglrenderer.h> 2024-01-07 14:47:22 +01:00
Benjamin Otte
0ba8903fa5 testsuite: Don't #include <gsk/gl/gskglrenderer.h> 2024-01-07 14:47:22 +01:00
Benjamin Otte
ee14b96c28 node-editor: Don't #include <gsk/gl/gskglrenderer.h> 2024-01-07 14:47:22 +01:00
Benjamin Otte
cf86a01b65 gsk: Include GL renderer in gsk.h
Same as the Vulkan renderer
2024-01-07 14:47:22 +01:00
Benjamin Otte
f57e211ba9 node-editor: Use gsk_renderer_realize_for_display()
... in all the places where we used realize (NULL) before.
2024-01-07 14:47:22 +01:00
Benjamin Otte
e2c8b7fa6c testsuite: Use gsk_renderer_realize_for_display()
... in all the places where we used realize (NULL) before.
2024-01-07 14:47:22 +01:00
Benjamin Otte
b486588883 dmabuf: Use gsk_renderer_realize_for_display()
We want to use the correct display when realizing our dmabuf
downloaders.

It's a good thing that the inspector doesn't use dmabufs, isn't it?
2024-01-07 14:47:22 +01:00
Benjamin Otte
d0bf33339e API: Add gsk_renderer_realize_for_display()
This makes realizing a renderer without a surface explicit.

And more importantly, it allows passing a different display than the
default one.
2024-01-07 14:47:22 +01:00
Benjamin Otte
df09975753 renderer: Pass the display as part of the vfunc
We allow realizing renderers without surfaces. But they still need a
display, so pass it explicitly.
2024-01-07 14:47:22 +01:00
Benjamin Otte
d21467e2e8 gdk: Remove all VulkanContext API
All API for GdkVulkanContext gets removed here. It was experimental and
it's not a good API. So get rid of it.
2024-01-07 14:47:22 +01:00
Benjamin Otte
c8529df309 inspector: Use Vulkan without a context
This means we don't need to include gdkvulkancontext.h and it means we
don't initialize Vulkan if it isn't initialized yet.

Should we?
Should we add a button maybe?

No idea.
2024-01-07 14:47:22 +01: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
1dbd74e181 Merge branch 'wip/otte/gpu' into 'main'
Add new unified renderer

See merge request GNOME/gtk!6588
2024-01-07 07:44:16 +00:00
Matthias Clasen
c8ae2d9002 testsuite: Add NGL and Vulkan renderer to compare tests
Add a testsuite called gsk-compare-vulkan to run
the gsk renderer tests with the Vulkan renderer and
gsk-compare-ngl to run them with the NGL renderer.

To run the tests locally, you can do:

meson test -C_build --suite gsk-compare-vulkan
2024-01-07 08:18:36 +01:00
Benjamin Otte
03cd652063 gpu: Disable the ubershader when shaders aren't nonuniform
If shaders don't support nonuniform indexing, we emulate it via if/else
ladders (or switch ladders) which get inlined by the GLSL compiles and
massively blow up the code.

And that makes compilation of the shaders take minutes and results in
shader code that isn't necessarily faster.

So we disable it on GL entirely and on Vulkan if the required features
aren't available.

As it's only an optimization and does not fall back to Cairo anymore,
this should be fine.
2024-01-07 08:18:36 +01:00
Matthias Clasen
c0d49f296e Update docs
Update the docs for environment variables that we parse to include
GDK_VULKAN_SKIP and GSK_GPU_SKIP.
2024-01-07 07:22:53 +01:00
Benjamin Otte
1723ab34e1 gpu: Setup attribute locations
Make the generator generate calls for the correct glBindAttribLocation()
calls.

Usually this was done correctly, but we can't rely on it. So do it
explicitly.
2024-01-07 07:22:53 +01:00
Benjamin Otte
55dbf0accb gpu: Add GSK_GPU_SKIP=blit
This allows bypassing all blit operations using gsk_gpu_blit_op()
in favor of shaders.
2024-01-07 07:22:53 +01:00
Benjamin Otte
b3d044a0b1 gpu: Add more assertions to blitop
The blitop is nasty, so we should make sure we have supported images
when using it.
2024-01-07 07:22:53 +01:00
Benjamin Otte
2fef71da5c gpu: Generate mipmap by default when downscaling too much
When downscaling more than 2x in either dimension, force mipmap use for
the texture in a texture node.
It improves the quality of textures but takes extra work.

The GL renderer does this, too (for textures that aren't in the icon cache).

This can be disabled via GSK_GPU_SKIP=mipmap.

Fixes the big-checkerboard-scaled-down2 test.
2024-01-07 07:22:53 +01:00
Benjamin Otte
48c1f5fd27 gpu: Add supersampling for gradients
Unless GSK_GPU_SKIP=gradients is given, we sample every point 4x instead
of 1x. That makes the shader run slower (by roughly a factor of 2.5x)
but it improves quality quite a bit.
2024-01-07 07:22:53 +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
d11886e7ac gpu: Use variations in the blur shader
Have one variation for colorizing to a shadow color and another
variation that just blurs.
2024-01-07 07:22:53 +01:00
Benjamin Otte
177b19a2da gpu: Use variations in the straight-alpha shader
This way we can toggle opacity handling on/off.

THe shader slowly turns into a fancy texture op - but I don't want to
rename it to "fancytexture" just yet.
2024-01-07 07:22:53 +01:00
Benjamin Otte
f943469fc9 gpu: Use variations for radial gradients 2024-01-07 07:22:53 +01:00
Benjamin Otte
59d062cb3d gpu: Use variations for the mask mode 2024-01-07 07:22:53 +01:00
Benjamin Otte
8032e30a76 gpu: Make linear gradients use variations 2024-01-07 07:22:53 +01:00
Benjamin Otte
2e81e4d452 gpu: Make box shadow shader use variations
Use it do differentiate between inset and outset shadows.
2024-01-07 07:22:53 +01:00
Benjamin Otte
d900407a18 gpu: Introduce the concept of "variation"
A variation is a #define/specialization constant that every shader can
use to specialize itself as it sees fit.

This commit adds the infrastrcture, future commits will add
implementations.
2024-01-07 07:22:53 +01:00
Benjamin Otte
64e5c76323 png: Don't set a size limit when saving
gdk_texture_save_to_png_bytes() cannot fail, so ensure that it doesn't.

Testsuite has been updated to check for this case.

Note that we do not load the PNG file that we generate here.
Loading is a lot more scary than saving after all.
If people want to load oversized PNG files, they should use a real PNG
loader.
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
2a5f6fdde5 gpu: Handle a clipping cornercase properly
If we enter the situation where we need to redirect the clipping to an
offscreen, make sure that:

* the ubershader gets only used when beneficial

* we size the offscreen properly and don't let it grow infinitely.

Fixes the clip-intersection-fail-opacity test
2024-01-07 07:22:53 +01:00
Benjamin Otte
6dbbd65ef8 gpu: Handle opacity in the Cairo path
Fixes random calls to add_fallback_node() from code that wants to handle
opacity.

Also makes Cairo nodes work with opacity, of course.
2024-01-07 07:22:53 +01:00
Benjamin Otte
9947760d87 gpu: Handle alpha in image_op() wrapper
There are various places where the alpha is implicitly assumed to be
handled, so just handle it.

As a bonus, this simplifies a bunch of code and makes the texture node
rendering work with alpha.
2024-01-07 07:22:53 +01:00
Benjamin Otte
493b83ff24 gpu: Optimize box-shadow shader
Like in the border shader, don't draw the (potentially large for the
window's shadow) inside part that is transparent.
2024-01-07 07:22:53 +01:00
Benjamin Otte
b65f6eef59 gpu: Replace a fallback with offscreens
Use an offscreen and mask it if the clips get too complicated.

Technically, the code could be improved to set the rounded clip on the
offscreen instead of rendering it as a mask, but that would require more
sophisticated tracking of clip regions by respecting the scissor, and
the current clip handling can't do that yet.

This removes one of the last places where the GPU renderer was still
using Cairo fallbacks.
2024-01-07 07:22:53 +01:00
Benjamin Otte
f6ff0ee18c gpu: Add gsk_gpu_node_processor_add_images()
This is for generating descriptors for more than 1 image. The arguments
for this function are very awkward, but I couldn't come up with better
ones and the function isn't that important.

And the calling places still look a lot nicer now.
2024-01-07 07:22:53 +01:00
Benjamin Otte
b388c066dc gpu: Add gsk_gpu_node_processor_init_draw/finish_draw()
These initialize/finish an offscreen and start drawing to it.

It simplifies the process of using offscreens quite a bit that way.
2024-01-07 07:22:53 +01:00
Benjamin Otte
9fe011b98f gpu: Add stroke support
Same as for fill nodes, we render the stroke to a mask and then run a
mask shader.

The color node child optimization is included already.
2024-01-07 07:22:53 +01:00
Benjamin Otte
89ab3a8146 gpu: Optimize solid color fills 2024-01-07 07:22:53 +01:00
Benjamin Otte
5dcaca9b3c gpu: Add fill node support
For now this uses Cairo to generate a mask and then runs a mask op.

This is different from just using fallback in that the child is rendered
with the GPU and not via fallback.
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
0c32a94d8e gpu: Split linear gradient shader into 2 parts
A generic part that can be shared by all gradient shaders that does the
color stop handling and a gradient-specific part that needs to be
implemented individually by each gradient implementation.
2024-01-07 07:22:53 +01:00
Benjamin Otte
6d20f4bc60 gpu: Change the cairo upload op prototype
Make it take a draw function instead of a node.

This way, we can draw more fancy stuff with Cairo.
2024-01-07 07:22:53 +01:00
Benjamin Otte
8361949ba1 gpu: Handle >7 color stops
If there are more than 7 color stops, we can split the gradient into
multiple gradients with color stops like so:
  0, 1, 2, 3, 4, 5, transparent
  transparent, 6, 7, 8, 9, 10, transparent
  ...
  transparent, n-2, n-1, n
and use the new BLEND_ADD to draw them on top of each other.

Adapt the testcae that tests this to use colors that work with the fancy
algorithm we use now, so that BLEND_ADD and transitions to transparent
do not cause issues.
2024-01-07 07:22:52 +01:00
Benjamin Otte
8372bc00bd gpu: Make the ubershader use the correct coordinates
Instead of scaled coordinates, use the unscaled ones.

This ensure that gradients get computed correctly as they are not safe
against nonorthogonal transforms - like scales with different scale
factors.
2024-01-07 07:22:52 +01:00