Commit Graph

2055 Commits

Author SHA1 Message Date
Benjamin Otte
7763e883d6 vulkan: Use VkPipeline instead of GskVulkanPipeline
This is in preparation for getting rid of GskVulkanPipelines.
2023-07-16 12:12:36 +02:00
Benjamin Otte
8bacfad171 vulkan: Use new ops for repeat nodes
The new code always uses an offscreen, even for children that are
exactly fitting texture nodes.
I would have had to write more code and didn't consider it worth it,
especially because it would have required complicating the
get_as_image() function.

This was the last node using the texture pipeline.
2023-07-16 12:12:36 +02:00
Benjamin Otte
53e7277584 vulkan: Implement fallback using new nodes
With Cairo upload and texture nodes being available, we can do that now.
2023-07-16 12:12:36 +02:00
Benjamin Otte
e43b7902be vulkan: Pass bounds to texture op
This way the node can do the normalization (and maybe stop doing it
in the future).
2023-07-16 12:12:36 +02:00
Benjamin Otte
f1d81bb7df vulkan: Add a Cairo upload node
... and use it for cairo nodes.
2023-07-16 12:12:36 +02:00
Benjamin Otte
84cf6de36d vulkan: Port opacity to new ops 2023-07-16 12:12:36 +02:00
Benjamin Otte
aaa219497b vulkan: Add offscreen and color-matrix op
.. and use them for color-matrix operations.
2023-07-16 12:12:36 +02:00
Benjamin Otte
8515224921 vulkan: Split out a function
We'll need it elsewhere soon.
2023-07-16 12:12:36 +02:00
Benjamin Otte
f53da409e5 vulkan: Add an argument to vfunc
We need this in the future.
2023-07-16 12:12:36 +02:00
Benjamin Otte
b45a2025d9 vulkan: Remove nonexisting function from header 2023-07-16 12:12:36 +02:00
Benjamin Otte
0946b0b333 vulkan: Split out a function
Making that function externally usable allows having render passes
managed externally.

Also remove a nonexisting function from the header.
2023-07-16 12:12:36 +02:00
Benjamin Otte
1d9ad55c54 vulkan: Use new ops for TextureScale nodes 2023-07-16 12:12:36 +02:00
Benjamin Otte
94a64329c2 vulkan: Add new renderops for texture rendering
Adds 2 ops:

- Upload
  Creates a new Vulkan image and uploads data into it

- Texture
  Draws a given image

These 2 ops are then used for GskTextureNodes.
2023-07-16 12:12:36 +02:00
Benjamin Otte
ba502a5009 vulkan: Split texture caching code
Instead of having one function that gets the image for the texture and
uploads it if it doesn't exist yet, make it 2 functions:

One to get the texture if it exists.
One to assign an uploaded image to the texture.

This way, we can potentially do the upload ourselves.
2023-07-16 12:12:36 +02:00
Benjamin Otte
e1d2477485 vulkan: Actually run the op_finish()
It's a no-op for all current ops, so it isn't really necessary. But
that's about to change.
2023-07-16 12:12:36 +02:00
Benjamin Otte
2fef53b154 vulkan: Pass context, not uploader
We don't need the uploader when creating the image, only when uploading.
2023-07-16 12:12:36 +02:00
Benjamin Otte
742ef96748 vulkan: Create the first real VulkanOp
Split out the scissor op into its own implementation as a proof of
concept of how ops are meant to look when they are actually working.
2023-07-16 12:12:36 +02:00
Benjamin Otte
8d928ad340 vulkan: Allocate render ops differently
Allocate the memory up front instead of passing the Op into it.

This way, we can split ops into their own source file and use
init/finish style to use them.
2023-07-16 12:12:36 +02:00
Benjamin Otte
32e123fa67 vulkan: Invent a new abstraction
GskVulkanOp is meant to be a proper abstraction of operations
the Vulkan renderer will be doing.

For now it's an atrocious clunky piece of junk wedged into the
renderpass codebase.

It's so temporary that I didn't even adjust indentation of the code.
2023-07-16 12:12:36 +02:00
Benjamin Otte
df0dd296e9 vulkan: Use the actual RenderOp type
... instead of the generic one.

This is again preparation for future changes.
2023-07-16 12:12:36 +02:00
Benjamin Otte
34e13556b4 vulkan: Use a byte array for render ops
This allows allocating only as much memory as is needed for each op.

We don't do that yet, this is still preparation.
2023-07-16 12:12:36 +02:00
Benjamin Otte
bdbb1398db vulkan: Split out a function
This is preparation for future changes.
2023-07-16 12:12:36 +02:00
Benjamin Otte
3523d56122 vulkan: Change the clip intersection check
Intersection with a roudned clip takes too long.

Instead, rename the function to may_intersect() to be clear about what
it does and then just intersect with the regular rectangle.
2023-07-11 01:39:25 +02:00
Benjamin Otte
5c601b673e vulkan: intersect rects also for CLIP_NONE
If we don't clip anything, we stil have bounds - either the framebuffer
size or (more likely) the scissor rect. And we don't want to draw
anything that is outside these bounds.

So clip in those cases, too.

Stops gtk4-demo --run=listbox from trying to render the whole listbox
instead of only the visible parts.
2023-07-10 06:32:01 +02:00
Benjamin Otte
465a34e6b0 rendernode: Implement proper GSK_IS_RENDERNODE()
Use G_TYPE_CHECK_INSTANCE_TYPE() instead of just checking for != NULL.
After all, this is a GTypeInstance.

Also fixes some gcc complaints when checking
  node == NULL || GSK_IS_RENDERNODE (node)
which gcc was convinced would be always true.
2023-07-10 06:32:01 +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
c6eb7fd483 gsk: Fix luminance in Cairo and GL renderer
In particular, fix the combination of luminance and alpha. We want to do
  mask = luminance * alpha
and for inverted
  mask = (1.0 - luminance) * alpha
so add a test that makes sure we do that and then fix the code and
existing tests to conform to it.
2023-07-03 22:02:44 +02:00
Benjamin Otte
7c58370673 rendernode: Work around a Cairo bug
When color-matrix modifying a clear surface, the surface would remain
clear according to Cairo.

That's very unfortunate when we prepare a mask for inverted-alpha
masking.
2023-07-03 22:02:44 +02: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
48804c81f3 rendernode: Mask nodes with different modes are different
So treat them as such.

Fixes the node editor not updating when I edit the mask mode.
2023-07-03 22:02:44 +02:00
Benjamin Otte
c79ec355af gsk: Catch values < 0 before bad things happen
In particular, catch radius values being < 0 by return_if_fail()ing in
the rendernode creation code, and by erroring out in the rendernode
parser.

I try too much dumb stuff in the node editor.
2023-07-03 22:02:44 +02:00
Matthias Clasen
0ae541671d gsk: Plug a memory leak in mask node fallback
We were forgetting to free the mask pattern.
Found by asan.
2023-06-27 21:54:15 -04:00
Matthias Clasen
ef0d6c7290 gsk: Plug a memory leak in the gl renderer
Found by asan.
2023-06-27 21:52:08 -04:00
Matthias Clasen
16e46a73f3 Plug a memory leak in gsk_render_node_serialize
This was introduced in 0d6a6a5997 with named
textures.
2023-06-27 21:43:17 -04:00
Matthias Clasen
51e440fa03 Merge branch 'fix-asan-ifunc' into 'main'
Fix fp16 with asan

See merge request GNOME/gtk!6153
2023-06-27 19:55:28 +00:00
Matthias Clasen
d82fb6f20a Fix fp16 with asan
The IFUNC resolvers that we are using here get
run early, before asan had a chance to set up its
plumbing, and therefore things go badly if they
are compiled with asan. Turning it off makes things
work again.

The gcc bug tracking this problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110442

Thanks to Jakub Jelinek and Florian Weimer for
analyzing this and recommending the workaround.
2023-06-27 15:17:56 -04:00
Matthias Clasen
44de6a6cbe Merge branch 'wip/sadiq/fix-use-after-free' into 'main'
gldriver: Fix a possible use-after-free

See merge request GNOME/gtk!6151
2023-06-27 18:46:28 +00:00
Mohammed Sadiq
64e27cd87d gldriver: Fix a possible use-after-free
g_hash_table_insert() frees the given key if it already exists
in the hashtable.  But since we use the same pointer in the
following line, it will result in use-after-free.

So instead, insert the key only if it doesn't exist.
2023-06-27 22:45:07 +05:30
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
684a015c98 vulkan: Add a pipeline cache
Make the display handle the cache, because we only need one.

We store the cache in
  $CACHE_DIR/gtk-4.0/vulkan-pipeline-cache/$UUID.$VERSION
so we regenerate caches for each different device (different UUID) and
each different driver version.

We also keep track of the etag of the cache file, so if 2 different
applications update the cache, we can detect that.
Vulkan allows merging caches, so the 2nd app reloads the new cache file
and merges it into its cache before saving.
2023-06-26 20:28:11 +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
299c6a3d6f vulkan: Take offscreen fromat from context
We want to create offscreens in compatible formats, and in particular we
want to ideally use the same format as rendering would use.
2023-06-20 20:15:12 +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
377592cb62 vulkan: Use the right flags
Somebody (me) had flipped the 2 flags in commit ba28971a18:

[ VUID-vkCmdCopyBufferToImage-srcBuffer-00174 ] Object 0: handle = 0x3cfaac0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x430000000043, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0xe1b276a1 | Invalid usage flag for VkBuffer 0x430000000043[] used by vkCmdCopyBufferToImage. In this case, VkBuffer should have VK_BUFFER_USAGE_TRANSFER_SRC_BIT set during creation. The Vulkan spec states: srcBuffer must have been created with VK_BUFFER_USAGE_TRANSFER_SRC_BIT usage flag (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdCopyBufferToImage-srcBuffer-00174)
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
aa6c670f15 vulkan: Add support for high bit depth 2023-06-19 15:08:00 +02:00
Benjamin Otte
746d0d8fde vulkan: Don't create unnecessary render passes
Pass the render pass to the pipeline creation function instead of
creating an extra one just for pipeline creation.
2023-06-19 15:08:00 +02:00