Commit Graph

78705 Commits

Author SHA1 Message Date
Benjamin Otte
a9b27a7de0 gpu: Implement a GdkDmabufDownloader 2024-01-07 07:22:52 +01:00
Benjamin Otte
41d80ac277 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-07 07:22:52 +01:00
Benjamin Otte
cf9b8231bd 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-07 07:22:52 +01:00
Benjamin Otte
3b6035a46d testsuite: Add new renderers to the scaling test 2024-01-07 07:22:52 +01:00
Benjamin Otte
c7a69882d3 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-07 07:22:52 +01:00
Benjamin Otte
e5cd813a24 gpu: Add debug messages
Add FALLBACK debug messages when a texture upload format is not
supported.
2024-01-07 07:22:52 +01:00
Benjamin Otte
62d917eb08 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-07 07:22:52 +01:00
Benjamin Otte
d4c4e4bbc5 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-07 07:22:52 +01:00
Benjamin Otte
cfcc9658b2 gpu: Make VulkanRealDescriptor keep the frame
There's too much interaction between the two to warrant not having it
around.
2024-01-07 07:22:52 +01:00
Benjamin Otte
d8a0cd24d7 gpu: Add support for blend modes 2024-01-07 07:22:52 +01:00
Benjamin Otte
496ecd68f2 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-07 07:22:52 +01:00
Benjamin Otte
683878c733 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-07 07:22:52 +01:00
Benjamin Otte
38c0e2bdf6 gpu: Update the pipeline cache
When a new shader was compiled, queue a save of the pipeline cache.
2024-01-07 07:22:52 +01:00
Benjamin Otte
f0fc2709d6 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-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
Georges Basile Stavracas Neto
c2ec97e922 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-07 07:22:52 +01:00
Benjamin Otte
90a278ce46 gpu: Rename some descriptors APIs
We want tosupport buffers here, too, so make the names unambiguous.
2024-01-07 07:22:52 +01:00
Benjamin Otte
2a5fe8cd0c 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-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
9f65cdf3aa gpu: Add support for subsurfaces 2024-01-07 07:22:52 +01:00
Benjamin Otte
35bc08da5e 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-07 07:22:52 +01:00
Benjamin Otte
723c2493b2 gpu: Handle opacity in a bunch of nodes 2024-01-07 07:22:52 +01:00
Benjamin Otte
245e51099f 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-07 07:22:52 +01:00
Benjamin Otte
a06cd6a821 gpu: Make the uber shader handle affine transforms
Fixes the last (non-blur) Nautilus offscreens in Nautilus.
2024-01-07 07:22:52 +01:00
Benjamin Otte
1c509be875 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-07 07:22:52 +01:00
Benjamin Otte
9894417a09 gpu: Split out a function
We want to use it elsewhere.
2024-01-07 07:22:52 +01:00
Benjamin Otte
51f218c877 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-07 07:22:52 +01:00
Benjamin Otte
a8bb0a0ee1 gpu: Split out a function
I want to use it in more places.
2024-01-07 07:22:52 +01:00
Benjamin Otte
b7414dfbdd 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-07 07:22:52 +01:00
Benjamin Otte
057479c284 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-07 07:22:52 +01:00
Benjamin Otte
c5a01cd14b 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-07 07:22:52 +01:00
Benjamin Otte
719ff9eca9 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-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
ae2020aca2 gpu: Make descriptor-indexing optional
Do extra work if it's not available.
2024-01-07 07:22:51 +01:00
Benjamin Otte
450524f6cf gpu: Remove UPDATE_AFTER_BIND flag
We don't update after binding.
2024-01-07 07:22:51 +01:00
Benjamin Otte
be09cebb09 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-07 07:22:51 +01:00
Benjamin Otte
6230ff0fc4 gpu: Cache GL state
That way we don't need to setup the textures and program for every
command.
2024-01-07 07:22:51 +01:00
Benjamin Otte
1733671295 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-07 07:22:51 +01:00
Benjamin Otte
78a7127b96 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-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
96e579501f 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-07 07:22:51 +01:00
Benjamin Otte
98c88780bc 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-07 07:22:51 +01:00
Benjamin Otte
7dcb7d7d0f gpu: Add Vulkan feature flags for more advanced features
Code continues if those features aren't available, buit is probably
broken.
2024-01-07 07:22:51 +01:00
Benjamin Otte
95e36af46b gpu: Update shader code for different buffer/sampler sizes
Use specialization constants for that.
2024-01-07 07:22:51 +01:00
Benjamin Otte
47a13e601f 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-07 07:22:51 +01:00
Benjamin Otte
a301f18ebf 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-07 07:22:51 +01:00
Benjamin Otte
6cbf4667a4 gpu: Add support for dmabuf import to GL 2024-01-07 07:22:51 +01:00
Benjamin Otte
ef20b706e2 gpu: Prepare GL rendering for samplerExternalEOS
Carry an n_external_textures variable around when selecting programs and
compile different programs for different amounts of external textures.

For now, this code is unused, but dmabufs will need it.
2024-01-07 07:22:51 +01:00
Benjamin Otte
979e4207f3 gpu: Add importing of GL textures to the GL renderer
syncing with the GLsync is kind of a hack (because we just do it on
import), but it works.
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