Commit Graph

81046 Commits

Author SHA1 Message Date
Benjamin Otte
3bc1e0534f gpu: Clean up headers
After the device/cache split, this was forgotten.
2024-07-22 01:28:40 +02:00
Benjamin Otte
7fb11dfeb0 gpu: Print filename in exceptions
I want to know which shader I screwed up.
2024-07-22 01:28:40 +02:00
Benjamin Otte
6d09eed90e gpu: Remove unused argument
It's always passing NULL.
2024-07-22 01:28:40 +02:00
Benjamin Otte
496211727d vulkan: dmabufs require ycbcr
So make sure that GDK_VULKAN_DISABLE=ycbcr also disables dmabufs.
2024-07-22 01:28:39 +02:00
Benjamin Otte
ee5e3b5927 Merge branch 'fix-urilauncher-uaf' into 'main'
urilauncher: Fix use-after-free on GCC < 12

See merge request GNOME/gtk!7471
2024-07-21 12:57:36 +00:00
Benjamin Otte
2087595747 Merge branch 'wip/otte/for-main' into 'main'
ngl: Fix crash at startup

See merge request GNOME/gtk!7472
2024-07-19 20:17:14 +00:00
Benjamin Otte
25268c2086 gstsink: Don't use g_autoptr 2024-07-19 21:37:48 +02:00
Benjamin Otte
2a9056b49e ngl: Fix crash at startup
Commit 1580490670 included a reordering of
acquiring the frame before making the context current.

Sometimes (like at startup) new frames need to be created.

Setting up a new frame assumed the GL context was current.

Change it so that we delay the one GL setup we do in frames until later.
2024-07-19 21:37:48 +02:00
Sergey Bugaev
46363b617e urilauncher: Fix use-after-free on GCC < 12
Building GTK with GCC 8 results in the following warning:

  gtk/gtkurilauncher.c: In function ‘gtk_uri_launcher_launch’:
  gtk/gtkurilauncher.c:315:3: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation]
     else
     ^~~~
  gtk/gtkurilauncher.c:317:1: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   ^~~

In the compiled code, gtk_show_uri_full () is invoked whether the portal
branch is taken or not, leading to use-after-free of the task.

It looks like GCC in versions older than 12 treats the _Pragma(s) that
G_GNUC_BEGIN_IGNORE_DEPRECATIONS expands to as C-level statements, and
therefore the pragma takes up the 'else' statement slot.

See https://godbolt.org/z/e5zqbaqxo for a simple reproducer.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2024-07-19 20:36:45 +03:00
Yaron Shahrabani
adb3baa7d2 Update Hebrew translation 2024-07-19 12:58:41 +00:00
Carlos Garnacho
31a79fbd9f Merge branch 'main' into 'main'
Ignore grabbing tablet devices without pads or tools

See merge request GNOME/gtk!7470
2024-07-18 12:10:36 +00:00
Jie Liu
d8919311b1 Ignore grabbing tablet devices without pads or tools
Signed-off-by: Jie Liu <liujie01@kylinos.cn>
2024-07-18 18:19:26 +08:00
Benjamin Otte
0e0158a825 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Do a naive implementation of P010, P012 and P016

See merge request GNOME/gtk!7469
2024-07-18 03:13:32 +00:00
Benjamin Otte
619926ec83 dmabuf: fix mmap() calls
* We cannot map with offset, because offsets need to be page-size
  aligned. And our code doesn't expect an offset anyway.
* The error return value from mmap() is MAP_FAILED aka -1, not NULL aka
  0.
2024-07-18 04:33:14 +02:00
Benjamin Otte
1afb832ff0 dmabuf: Do a naive implementation of P010, P012 and P016
These are the common HDR formats, so we better have the baseline of
those.
2024-07-18 04:33:14 +02:00
Benjamin Otte
823b529f89 gstsink: Remove unused member variable 2024-07-18 04:33:14 +02:00
Benjamin Otte
4707784755 gstsink: Use GdkMemoryTextureBuilder 2024-07-18 04:33:14 +02:00
Benjamin Otte
1ebcd27605 Merge branch 'wip/otte/for-main' into 'main'
Various Vulkan fixes

See merge request GNOME/gtk!7468
2024-07-17 21:19:02 +00:00
Benjamin Otte
300639e537 vulkan: Use right check for waiting on external image semaphore
Commit 3aa6c27c26 changed the initial layout of imported dmabuf images,
but did not adapt this check.
2024-07-17 22:59:23 +02:00
Benjamin Otte
ad218f0786 gpu: Pass the pass to frame_submit()
We will need that in the next commit.
2024-07-17 22:59:23 +02:00
Benjamin Otte
4966f8cdf8 vulkan: Add an acquire semaphore to frames
Vulkan requires us waiting on the image acquired from
vkAcquireNextImageKHR() before we start rendering to it, as that
function is allowed to return images that are still in use by the
compositor.
Because of that requirement, vkAcquireNextImageKHR() requires a
semaphore or fence to be passed that it can signal once it's done.

We now use a side channel to begin_frame() - calling
set_draw_semaphore() - to pass that semaphore so that the
vkAcquireNextImageKHR() call inside begin_frame() can use it, and then
we can wait on it later when we submit.

And yes, this is insanely convoluted, the Vulkan developers should
totally have thought about GTK's internal designs before coming up
with that idea.
2024-07-17 22:59:23 +02:00
Benjamin Otte
1580490670 gpu: add gsk_gpu_frame_begin/end()
These are just factoring out gdk_draw_context_begin/end_frame() so I can
add one tiny thing there later.

And I did both even though I only need one, because it felt wrong to
just do one.
2024-07-17 22:59:23 +02:00
Benjamin Otte
3cf5e8cf4e gpu: Move gc calls further to the edges of the function
Make the function look like that:

1. handle special case
2. maybe GC
3. draw
4. queue next gc
5. cleanup

This seems like the sanest approach to avoid gc() collecting things
necessary for drawing in the future.

And I need to refactor stuff, so having it out of the way is a good
idea.
2024-07-17 22:59:23 +02:00
Benjamin Otte
d21ac80178 gpu: Simplify a function
Now that we only ever use 2 images max per shader due to the removal of
the ubershader, we can just hardcode it in the function.
2024-07-17 22:59:23 +02:00
Martin
effbaa7770 Update Slovenian translation 2024-07-17 07:07:05 +00:00
Quentin PAGÈS
a9a61abc81 Update Occitan translation 2024-07-17 07:02:10 +00:00
Ekaterine Papava
e5b05424c8 Update Georgian translation 2024-07-16 21:45:51 +00:00
Matthias Clasen
8f920101f3 Merge branch 'wip/otte/texture-colorstate-api' into 'main'
Add support for color states to texture constructors/downloader

See merge request GNOME/gtk!7461
2024-07-16 21:09:48 +00:00
Matthias Clasen
1c59474f45 Merge branch 'inspector-crash' into 'main'
inspector: Fix a crash

See merge request GNOME/gtk!7467
2024-07-16 20:58:37 +00:00
Benjamin Otte
9be7104b71 testsuite: Add a save=>load cycle test for PNGs with colorstates 2024-07-16 22:04:11 +02:00
Benjamin Otte
31e0ec71f2 png: Add color state support
When loading or saving png files, encode the CICP flags of the color
state into the PNG.

When loading, decode the CICP flags if available and detect the
colorstate they use.
If we do not support the cicp tags, we do not load the image.

So far, we ignore the ICC profiles.

Includes regeneration of nodeparse test *reference* output to include
the new tags we write to PNGs.
The original tests do not include those tags, so we implicitly test that
we read untagged files correctly.
2024-07-16 22:04:10 +02:00
Benjamin Otte
6c33afc13c png: Move texture data download further down
We only download the data when we actually need it for writing into the
PNG stream.

This allows modifying the download parameters (in particular color state
in the next commit) while writing out their settings, so the code for
selecting the right colorstate liives in only one place.

We have to be careful though, because the download now happens after the
setjmp(), so we need to make sure the error path handles both cases
without leaking: Where the download has happened and where it hasn't.
2024-07-16 22:03:48 +02:00
Benjamin Otte
03daf42fb5 png: Port to MemoryTextureBuilder 2024-07-16 22:03:46 +02:00
Matthias Clasen
b33b68ef75 dmabuf texture: color state support 2024-07-16 21:23:44 +02:00
Matthias Clasen
0ee8ca43d1 gl texture: color state support 2024-07-16 21:23:44 +02:00
Benjamin Otte
77da45a173 testsuite: Update colorstate test 2024-07-16 21:23:44 +02:00
Benjamin Otte
5e1c3c5d69 gdk: Add GdkMemoryTexture::color-state
This allows setting the color state of textures.
2024-07-16 21:23:44 +02:00
Benjamin Otte
05953a20cc testsuite: Allow colorstate properties to have SRGB as default value
This needs custom code because boxed paramspecs always default to NULL.
But we want to always default to SRGB.
2024-07-16 21:23:44 +02:00
Benjamin Otte
3c8a93b972 gdk: Add GdkMemoryTextureBuilder
Same thing as dmabuf and GL texture builders. Preparation for adding
color state support to texture constructors.

As a bonus, we can now do update regions with memory textures.
2024-07-16 21:23:44 +02:00
Benjamin Otte
11543a229a texturedownloader: Add color state
... and plumb the color state through the downloading machinery, where
no matter what path it takes it ends up in
gdk_memory_convert_color_state() or gdk_memory_convert().

The 2nd of those has been expanded to optionally do colorstate
conversion when the 2 colorstates are different.
2024-07-16 21:23:44 +02:00
Robert Mader
d448e12cf4 inspector: Fix a crash
gdk_wayland_color_get_color_manager() rightfully is not NULL-safe.

Fixes: 2031ec1b57 ("inspector: Show the color management protocol")
2024-07-16 10:30:56 +02:00
Benjamin Otte
fee4ad0174 Merge branch 'wip/otte/for-main' into 'main'
gpu: Don't transition invalid cache items

Closes #6867

See merge request GNOME/gtk!7466
2024-07-16 01:40:16 +00:00
Matthias Clasen
38f01cf1f2 Merge branch 'fix-subsurface-crash' into 'main'
wayland/subsurface: Handle NULL-buffers in dmabuf_buffer_release

See merge request GNOME/gtk!7465
2024-07-16 01:25:41 +00:00
Benjamin Otte
37bea9d162 gpu: Don't transition invalid cache items
When a cache item is invalid, don't move it into the hash table.
Instead, just delete it.

Something like this could happen:

1. A texture is cached
In the case of #6867 this would be a webpage in epiphany.

2. The texture cache item is garbage-collected
For example, epiphany might switch to a new tab, and the previous page's
texture will remain. After 15s or so, we collect our item for that
texture.

3. The texture is cached again, but in the target colorspace
We now decide we need the texture again, but not in any colorspace, we
need it in the target colorspace. This might be because we run an
effect on it (like a crossfade) or because we want mipmaps (like in the
overview map, where its zoomed out).

4. The old invalid item is transitioned into the hash table
We now have an invalid item in the hash table. This is extra bad,
because it had only one reference (from the texture), but we treat it
like it has 2 (from us in the hash table and from the texture).
So depending on if the texture is freed before we reuse it, we get
different results: If it was free, we get invalid memory accesses, if it
was not freed, we treat it like a valid cache item and think the image
inside is still valid.

Fixes #6867
2024-07-16 03:15:36 +02:00
Robert Mader
b241fcd418 wayland/subsurface: Handle NULL-buffers in dmabuf_buffer_release
This happens when buffer creation fails in `get_dmabuf_wl_buffer()` and
we manually call `listener->release (data, NULL)`.

Fixes: 2478dd8322 ("subsurface: Split a function")
2024-07-16 01:43:15 +02:00
Benjamin Otte
86e735cd5c Merge branch 'wip/otte/for-main' into 'main'
vulkan: Remove draw semaphore

Closes #6861

See merge request GNOME/gtk!7460
2024-07-14 21:11:06 +00:00
Michael Catanzaro
4c40395a38 gpu: fix memory corruption in cache_gc_cb()
gsk_gpu_device_gc() may release the last ref on the GskGpuDevice,
leading to memory corruption when setting priv->cache_gc_source = 0.

Includes a bit of refactoring, so the ref/unref wraps nicely around the
actual code.

Fixes crashes seen after using the inspector and closing the window,
thereby closing all windows of a display and releasing all references to
the device.

Fixes #6861
2024-07-14 21:54:57 +02:00
Benjamin Otte
d32fd76b31 docs: Fix typo 2024-07-14 21:54:40 +02:00
Benjamin Otte
5f8e83d75d gpu: Fix memleak in texture-scale code 2024-07-14 21:54:40 +02:00
Benjamin Otte
b08a17064e vulkan: Remove draw semaphore
That's unused (or wrongly used) leftover code from 2017.

The validation layers also don't like it.
2024-07-14 21:54:40 +02:00