Commit Graph

39 Commits

Author SHA1 Message Date
Benjamin Otte
5152c13081 vulkan: Change rounded_rect_shrink()
Same fix as with the GL renderer
2023-09-15 16:34:00 +02:00
Benjamin Otte
d665d2fb89 vulkan: Add nonuniformEXT() where needed
The magical term to know about (because the GLSL compiler or the
validation layers sure as hell don't) is:

  "dynamically uniform expression"

because if you don't have that when indexing a texture or buffer array,
you need to add nonuniformEXT() around the index variable.

Fixes the close icon on AMD having glitches of the previous icon visible
in some pixels.
2023-08-21 05:19:44 +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
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
92038d6b7f build: Move the glslc check into the top meson file
Put it with the other Vulkan checks, so it's easy to find.
2023-07-19 21:30:35 +02:00
Benjamin Otte
6e27579d1f vulkan: Remove the pre-compiled shaders
Instead, build-depnd on glslc to build them.

glslc is available in all important distros for a while:
  Fedora >= 28
  Ubuntu >= 23.04
  Debian >= 12
  Arch
  Opensuse >= 15.2
  msys2
are the ones I checked.

So we can depend on it and avoid having to deal with keeping spirv files
up-to-date in all commits.

It's also 700kB of data, and not updating it helps.
2023-07-19 21:30:35 +02:00
Benjamin Otte
90e933a6aa vulkan: Rebuild the shaders
Just to be sure I didn't forget rebuilding some shader at some point.
2023-07-16 13:52:15 +02:00
Benjamin Otte
73f1dfc762 vulkan: Repurpose mask shader
Use if for mask nodes to do the generic source image + mask image
operation with the 4 available mask modes.
2023-07-16 12:13:00 +02:00
Benjamin Otte
2d6ebbb4d5 vulkan: Add a glyph shader
This shader is an updated version of the mask shader, but I want to use
the mask name for the mask node and that's a different functionality.

Also, add an operation for it and partially implement the mask node
using it, so we can test that this shader works.

Replacing the shader used for text rendering is the next step.
2023-07-16 12:12:59 +02:00
Benjamin Otte
8207c548cc vulkan: Combine textures and samplers again
This reverts most of commit f420c143e0
again because it turns out GPUs like combined images and samplers.

But: The one thing we don't revert is allowing the C code to select any
combination of sampler and image:
gsk_vulkan_render_get_image_descriptor() now takes a 2nd argument
specifying the sampler.

This allows the same flexibility as before, we just combine things
early.

This change was inspired by
https://developer.nvidia.com/blog/vulkan-dos-donts/
2023-07-16 12:12:36 +02:00
Matthias Clasen
40707a6af0 Merge branch 'ebassi/issue-5934' into 'main'
Lower the Python requirement

Closes #5934

See merge request GNOME/gtk!6167
2023-07-05 10:57:45 +00:00
Emmanuele Bassi
9b71c9dfc6 Do not use bleeding edge Python
The match operator was added in Python 3.10, which is a bit too new for
some downstreams.

While at it, let's fix the flake8 errors and warnings.

Fixes: #5934
2023-07-05 10:19:18 +01:00
Benjamin Otte
84737a5159 build: Include the right things
If we build our own targets, we need to include those.

This is only relevant when adding new shaders because meson will
complain that the (unused) sources don't exist as it tries to include
those.
And that will make the build.ninja file not be generated which would
have build those shaders and would have allowed to copy them into the
sources.

Note that this makes builds with glslc not care about all the shader
files being included with the sources, but we have CI to check that.
2023-07-03 22:02:44 +02:00
Benjamin Otte
6c85ed1ba1 vulkan: Generate vertex array headers from shaders
The script is pretty dumb but it does its job.
2023-06-27 07:11:48 +02:00
Benjamin Otte
2e58274f23 vulkan: Rename crossfade => cross-fade
Preparation for the future.
2023-06-27 06:46:57 +02:00
Benjamin Otte
4ade0afe03 vulkan: Rename blendmode to blend-mode
Preparation for future changes, nothing to see here.
2023-06-27 06:46:57 +02:00
Benjamin Otte
169355f771 vulkan: Rebuild the precompiled shaders
We forgot that with all the changes.
2023-06-20 20:17:06 +02:00
Benjamin Otte
17698bfd2e vulkan: Use 3 descriptor sets, not 3 bindings
It turns out variable length is only supported for the last binding in
a set, not for every binding.
So we need to create one set for each of our arrays.

[ VUID-VkDescriptorSetLayoutBindingFlagsCreateInfo-pBindingFlags-03004 ] Object 0: handle = 0x33a9f10, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xd3f353a | vkCreateDescriptorSetLayout(): pBindings[0] has VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT but 0 is the largest value of all the bindings. The Vulkan spec states: If an element of pBindingFlags includes VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT, then all other elements of VkDescriptorSetLayoutCreateInfo::pBindings must have a smaller value of binding (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkDescriptorSetLayoutBindingFlagsCreateInfo-pBindingFlags-03004)
2023-06-20 20:15:12 +02:00
Benjamin Otte
0a5e5023a8 vulkan: Remove unused declaration from shader 2023-06-20 20:15:12 +02:00
Benjamin Otte
2883f4b7a2 vulkan: Antialiasing for linear gradients
Shaders are complicated now...
2023-06-08 22:16:18 +02:00
Benjamin Otte
e3cc3f7841 vulkan: Make gradient shader use buffers
This allows putting any number of color stops into the buffer, so
fallbacks with too many stops are no longer necessary.
2023-06-08 21:53:06 +02:00
Benjamin Otte
d1135f9e3c vulkan: Add support for storage buffers
And add a default storage buffer that is used for per-frame temporary
data.

So far nothing is using this code, this is just infrastructure.
2023-06-08 21:53:06 +02:00
Benjamin Otte
2d89dfea29 vulkan: Switch GLSL version to 450
We need more modern features soon.
2023-06-08 21:53:06 +02:00
Benjamin Otte
f420c143e0 vulkan: Split textures and samplers
The idea here is that we can do more complex combinations and use that
to support texture-scale nodes or use fancy texture formats (suc as
YUV).

I'm not sure this is actually necessary, but for now it gives more
flexibility.
2023-06-04 19:42:01 +02:00
Benjamin Otte
330a8b1cdb vulkan: Convert blend shader
Same work as crossfade shader pretty much.
2023-06-04 19:42:01 +02:00
Benjamin Otte
8d19db6732 vulkan: Update the cross-fade shader
This also fixes it rendering weird things when the bounds of start and
end node don't match.
2023-06-04 19:42:01 +02:00
Benjamin Otte
0f1b039306 vulkan: Implement bindless texture rendering
Instead of having a descriptor set per operation, we just have one
descriptor set and bind all our images into it.

Then the shaders get to use an index into the large texture array
instead.

Getting this to work - because it's a Vulkan extension that needs to be
manually enabled, even though it's officially part of Vulkan 1.2 - is
insane.
2023-06-04 19:42:01 +02:00
Benjamin Otte
a73530f952 vulkan: Update texture shader to do AA 2023-06-04 19:42:01 +02:00
Benjamin Otte
3e620a8fe5 vulkan: Split generic code off
No need to duplicate code in shaders when it can be shared.
2023-06-04 19:42:01 +02:00
Benjamin Otte
87c9503293 vulkan: Rewrite AA shaders to respect scale
The border and color shaders - the ones that do AA - now multiply their
coordinates by the scale factor, which gives them better rounding
capabilities.

This in particular improves the case where they are used in fractional
scaling situations, where the scale is defined at the root element.
2023-06-04 19:42:01 +02:00
Benjamin Otte
a09580b9ef vulkan: Split scale from matrix
Now, the scale is no longer part of the matrix. This allows shaders to
transform points by the scale which increases accuracy for antialiasing.
2023-06-04 19:42:01 +02:00
Benjamin Otte
57222cc64c vulkan: Add scale to push constants
This way, it can be pushed to the shaders
2023-06-04 19:42:01 +02:00
Benjamin Otte
af901a10e3 vulkan: Make border shader handle fractional widths
We were rounding widths properly, make sure we always round up.
2023-06-04 19:42:00 +02:00
Benjamin Otte
3d1a607367 vulkan: Don't round corners when growing rounded rect
If the corner is set to 0, keep it there.
2023-06-04 19:42:00 +02:00
Benjamin Otte
1be21a33d9 vulkan: Rewrite rounded rectangle to use SDF distance
We can use this to properly compute distance in scaled situations.
We also now compute coverage with (imperfect) antialiasing.
2023-06-04 19:42:00 +02:00
Benjamin Otte
64bcdb713c vulkan: Start rework on shaders to allow antialiased drawing
This introduces the rect object and adds a rect_distance() and
rect_coverage() function.

_distance() returns the signed distance tp the rectangle.
_coverage() returns the coverage of a pixel centered at that position.

Note that the pixel size is computed using dFdx/dFdy.
2023-06-04 19:42:00 +02:00
Benjamin Otte
d51c92f54d build: Make shaders depend on their includes
This does not do any proper dependency tracking, it just makes every
shader depend on every include shader.

But that's good enough for now.
2023-05-16 18:53:27 +02:00
Benjamin Otte
9b558b50b8 vulkan: Rebuild SPIR-V files
It's been a while since somebody last compiled them, glslc should be
somewhat newer by now.
2023-05-02 08:47:10 +02:00
Matthias Clasen
900a4e4d31 gsk: Move shader resources
Move the resources of each renderer to its subdirectory.
We've previously done that for the ngl renderer, but it
is better to be consistent and do it for all the renderers.
2021-04-03 08:24:58 -04:00