Commit Graph

78689 Commits

Author SHA1 Message Date
Benjamin Otte
db93fd6b7b renderer: Add Vulkan renderer to the list of renderers
It's better than the Cairo renderer, so use it instead.

It's still only picked once GL fails, so it will probably only ever be
picked when people use GDK_DEBUG=gl-disable, but at least it will be
picked.
2024-01-04 14:54:24 +01:00
Benjamin Otte
fb6ee45064 renderer: Split function
per-backend renderers and GL renderers are a different thing, so treat
them as such.

Also, try the GL renderer unconditionally. The renderer initialization
code will take care of GL not being available.
2024-01-04 14:54:24 +01:00
Benjamin Otte
f6f43cd374 vulkan: Add a Vulkan downloader
This is using the Vulkan renderer.

It also allows claiming support for all the formats that only Vulkan
supports, but that neither GL nor native mmap can handle.
2024-01-04 14:54:24 +01:00
Benjamin Otte
0473a429ac gpu: Implement a GdkDmabufDownloader 2024-01-04 14:54:24 +01:00
Benjamin Otte
d225f40acd gpu: Add a boolean flag allow_dmabuf to the downloadop
It can be set to force the downloadop to not create dmabuf textures.
2024-01-04 14:54:24 +01:00
Benjamin Otte
2bcee1e69e gpu: Update to memoryformat Vulkan code
The existing code for setting up formats was copied from the old Vulkan
renderer and never updated.
2024-01-04 14:54:24 +01:00
Benjamin Otte
9a81ed9ab1 testsuite: Add new renderers to the scaling test 2024-01-04 14:54:24 +01:00
Benjamin Otte
fb9c4c15be gpu: Reorganize format handling
Add GSK_GPU_IMAGE_RENDERABLE and GSK_GPU_IMAGE_FILTERABLE and make sure
to check formats for this feature.

This requires reorganizing code to actually do this work instead of just
pretending formats are supported.

This fixes GLES upload tests with NGL.
2024-01-04 14:54:24 +01:00
Benjamin Otte
f2ac427035 gpu: Add debug messages
Add FALLBACK debug messages when a texture upload format is not
supported.
2024-01-04 14:54:24 +01:00
Benjamin Otte
95d7c7de3a vulkan: Use vulkan feature flags for incremental present
I did it because it unifies the code.

But it also gains the benefit of being debuggable because it can
now be turned off via GDK_VULKAN_SKIP=incremental-present
2024-01-04 14:54:24 +01:00
Benjamin Otte
80a2cbb447 gpu: sync dmabufs via semaphores
This ensures both that we signal a semaphore for a dmabuf when we export
an image and that we import semaphores for dmabufs and wait on them.

Fixes Vulkan node-editor displaying the Vulkan renderer in the sidebar.
2024-01-04 14:54:23 +01:00
Benjamin Otte
14a1c53358 gpu: Make VulkanRealDescriptor keep the frame
There's too much interaction between the two to warrant not having it
around.
2024-01-04 14:54:23 +01:00
Benjamin Otte
fcb8e920c8 gpu: Add support for blend modes 2024-01-04 14:54:23 +01:00
Benjamin Otte
8003d875ee gpu: Make Vulkan renderer provide dmabuf textures
Make gsk_renderer_render_texture() create a dmabuf texture if that is
possible.

If it isn't (ie if we're not on Linux or if dmabufs are otherwise not
working) fall back to the previous code of creating a memory texture.
2024-01-04 14:54:23 +01:00
Benjamin Otte
ce08750906 gpu: Add gsk_gpu_device_create_download_image()
This way, we can differentiate between regular offscreens and images
that are meant to be used for gsk_renderer_render_texture() or similar.
2024-01-04 14:54:23 +01:00
Benjamin Otte
15c72b32bd gpu: Update the pipeline cache
When a new shader was compiled, queue a save of the pipeline cache.
2024-01-04 14:54:23 +01:00
Benjamin Otte
21841872f4 gpu: Implement support for multiple storage buffers
When using the uber shader a lot, we may overflow the (only 16kB large)
storage buffer.

Stop crashing when that happens and instead just allocate a new one.
2024-01-04 14:54:23 +01:00
Benjamin Otte
9ef440a577 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-04 14:54:23 +01:00
Georges Basile Stavracas Neto
83b922f2ee gpu/renderer: Improve scale detection
The GL branch should eventually call into gdk_gl_context_get_scale(),
which is what checks for GDK_DEBUG=gl-fractional; whereas the Vulkan
branch needs no change.
2024-01-04 14:54:23 +01:00
Benjamin Otte
a6bcc2208a gpu: Rename some descriptors APIs
We want tosupport buffers here, too, so make the names unambiguous.
2024-01-04 14:54:22 +01:00
Benjamin Otte
f7f61fadb3 gpu: Only run uber shaders if beneficial
If we have the choice between running the ubershader or a normal shader
with offscreens, make the choice depend on if the ubershader would
offscreen anyway.
If so, just run the normal shader.

This really gets rid of all ubershader invocations in Adwaita
widget-factory.
2024-01-04 14:54:22 +01:00
Benjamin Otte
8bb3cca512 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-04 14:54:22 +01:00
Benjamin Otte
6dc9736b37 gpu: Add support for subsurfaces 2024-01-04 14:54:22 +01:00
Benjamin Otte
cd054a6e6d gpu: Rework caching layer
Instead of using an enum, use a usual custom class struct like we use
for GskGpuOp.

As a side effect of that refactoring, the display gained a hash table
for textures where we can't use the render data because the texture is
used in multiple renderers.
The goal here is that a texture is always cached and we can ensure that
there is a 1:1 relation between textures and their GskGpuImage. This is
important in particular for external textures - like dmabufs - where we
absolutely don't want 2 images with 2 device memories, and where we use
toggle references to keep them alive.
2024-01-04 14:54:22 +01:00
Benjamin Otte
2e11cf754c gpu: Handle opacity in a bunch of nodes 2024-01-04 14:54:22 +01:00
Benjamin Otte
880aaab037 gpu: Add optimization for opacity nodes
Track the global opacity and allow nodes to handle it themselves.

If the nodes don't, fall back to what we did previously: Use the
ubershader.
2024-01-04 14:54:22 +01:00
Benjamin Otte
a295d59db8 gpu: Make the uber shader handle affine transforms
Fixes the last (non-blur) Nautilus offscreens in Nautilus.
2024-01-04 14:54:22 +01:00
Benjamin Otte
13e6ecb330 gpu: Replace clip node fallback with uber or offscreen
We don't need to use a fallback here anymore, we have enough code by now
to do this smarter.
2024-01-04 14:54:22 +01:00
Benjamin Otte
88c25199ce gpu: Split out a function
We want to use it elsewhere.
2024-01-04 14:54:22 +01:00
Benjamin Otte
743dfc276a gpu: Replace fallback with offscreen
We don't need to fallback with transform nodes when the clip is
too complex. We can redirect to an offscreen instead, which doesn't have
a clip.
2024-01-04 14:54:21 +01:00
Benjamin Otte
134d809a7d gpu: Split out a function
I want to use it in more places.
2024-01-04 14:54:21 +01:00
Benjamin Otte
3936e7ee7d gpu: Be stricter about texture units
Reserve 3 texture units per immutable sampler (because that's the
maximum per YUV sampler).
Ensure that the max-sampler calculations always include the immutable
samplers, too.
2024-01-04 14:54:21 +01:00
Benjamin Otte
a5c7339920 gpu: Improve memory handling on Vulkan
We now handle the case where memory is not HOST_CACHED.

We also track the memory type now so we can avoid mapping image memory
that is not HOST_CACHED and use buffer transfers instead.
2024-01-04 14:54:21 +01:00
Benjamin Otte
e8fb0e71c9 gpu: Make the texture ladder handle 32 textures
So now we can put more textures in one descriptor set even if dynamic
indexing isn't supported.
2024-01-04 14:54:21 +01:00
Benjamin Otte
9d0b15273d gpu: Require Vulkan 1.2 shaders for dynamic indexing
Shader compilers struggle with compiling code that indexes texture
arrays by indexes, so keep the fallback shaders simple and don't do that
there.

There's not much of a performance difference anyway between those two
methods.
2024-01-04 14:54:21 +01:00
Benjamin Otte
168be35bed gpu: Add back single descriptors set usage with descriptor indexing 2024-01-04 14:54:21 +01:00
Benjamin Otte
9777188ae4 gpu: Make descriptor-indexing optional
Do extra work if it's not available.
2024-01-04 14:54:21 +01:00
Benjamin Otte
21f52cacf9 gpu: Remove UPDATE_AFTER_BIND flag
We don't update after binding.
2024-01-04 14:54:21 +01:00
Benjamin Otte
5ed293e3df gpu: Handle multiple image descriptors
In the case where descriptor indexing is not enabled and the number of
max images is small (or we use extensive amounts of immutable samplers),
we need to be able to switch descriptors.

This patch makes that possible.
2024-01-04 14:54:21 +01:00
Benjamin Otte
c51c3b2660 gpu: Cache GL state
That way we don't need to setup the textures and program for every
command.
2024-01-04 14:54:20 +01:00
Benjamin Otte
5dc455f011 gpu: Add a CommandState struct to the command vfuncs
This way, we can make it writable and track things like the active
textures and the current program.

We don't do that yet, but we can.
2024-01-04 14:54:20 +01:00
Benjamin Otte
fbd972498f gpu: Handle missing support nor nonuniform texture accesses
We compile custom shaders for Vulkan 1.0 that don't require the
extension.

We  also ensure that our accesses are uniform by only executing one
shader at a time.
2024-01-04 14:54:20 +01:00
Benjamin Otte
b87d82de7e 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-04 14:54:20 +01:00
Benjamin Otte
c165b9d47c gpu: Add GDK_VULKAN_SKIP env var
The variable forces skipping of optional Vulkan features. This is useful
for testing.

Also debug-print the features in use.
2024-01-04 14:54:20 +01:00
Benjamin Otte
37d4e29c44 gpu: Set max samplers/buffers based on features
If we run older code, we don't have enough samplers and buffers
available. So make sure to reflect that.
2024-01-04 14:54:20 +01:00
Benjamin Otte
1923cad9f7 gpu: Add Vulkan feature flags for more advanced features
Code continues if those features aren't available, buit is probably
broken.
2024-01-04 14:54:20 +01:00
Benjamin Otte
9349ba8330 gpu: Update shader code for different buffer/sampler sizes
Use specialization constants for that.
2024-01-04 14:54:20 +01:00
Benjamin Otte
0c72233a9d gpu: Make PipelineLayout objects do more things
Let the objects track the number of samplers or buffers needed.

This is a required step for making Vulkan work with less featureful
(read: mobile) implementations.
2024-01-04 14:54:20 +01:00
Benjamin Otte
9733b8d4e1 gpu: Track position fwidth explicitly
This is relevant went encountering repeat nodes, where the repeat cutoff
will make the fwidth of the position go wild otherwise.

Gradients require more work now, because we need to compute offsets
twice - once for the pixel, once for the offst.
2024-01-04 14:54:20 +01:00
Benjamin Otte
4d9ff5e46a gpu: Add support for dmabuf import to GL 2024-01-04 14:54:19 +01:00