Commit Graph

12030 Commits

Author SHA1 Message Date
Matthias Clasen
7acc1c0125 Make dmabuf initialization lazier
Only initialize the Vulkan or EGL parts where possible.

When dmabufs or dmabuf formats are actually used, we still
initialize fully by creating both a Vulkan and EGL downloader.

This shortens the time to first commit from 149ms to 108ms.
2024-09-17 09:46:01 +02:00
Matthias Clasen
6059eaf355 gdk: Reorganize dmabuf initialization
Change the xxx_get_downloader() functions to init_dmabuf_xxx(),
and make them initialize both xxx_dmabuf_formats and xxx_downloader.
2024-09-17 09:46:01 +02:00
Matthias Clasen
24dc9dc653 Drop the dmabuf_downloaders array
Just use two individual fields, so we can track if we've already
created each one. This also matches the individual fields we have
for the dmabuf formats.

And change preference order of downloaders

Previously, our order was mmap > vulkan > egl.

But depending on the hw (discrete vs integrated gpu), mmap
can be catastrophically slower (on the order of 20ms vs 1.5s).

So, change the order to egl > vulkan > mmap.

Note that this currently has less effect than we'd like to,
since we don't let the downloaders claim linear formats.
2024-09-16 09:55:31 +02:00
Benjamin Otte
f2e75529cb Merge branch 'wip/otte/for-main' into 'main'
vulkan: Actually return the preferred memory format

See merge request GNOME/gtk!7713
2024-09-15 08:19:53 +00:00
Benjamin Otte
376dbe9def memoryformat: Move fast path into the threaded path
We don't want to get slower in the fast path.
2024-09-15 02:31:02 +02:00
Benjamin Otte
bba7979670 memoryformat: Add a fastpath for RGBA8 <=> BGRA8
Cairo is using BGRA8 but we want to use RGBA8 because it's the canonical
GL format.

So getting this fast sounds useful.
2024-09-15 02:31:02 +02:00
Benjamin Otte
01aafc6e65 memoryformat: Don't always convert to rec2100-linear and back
It turns out we lost the check to see if color states are equal when we
multithreaded things in !7657

Whoops.
2024-09-15 02:31:01 +02:00
Arjan Molenaar
250322deb0 Merge branch 'amolenaar/dnd-icon-on-top' into 'main'
macos: Keep DnD windows always on top

Closes #6809 and #6818

See merge request GNOME/gtk!7706
2024-09-12 09:25:05 +00:00
Matthias Clasen
bdee95c32c Merge branch 'wip/otte/for-main' into 'main'
gpu: Don't crash when there's no ops

Closes #6992

See merge request GNOME/gtk!7710
2024-09-12 00:27:29 +00:00
Arjan Molenaar
e92bd4d9ce macOS: drag surfaces should ignore all events
This fixes the Dnd demo.
2024-09-11 14:59:03 +02:00
Arjan Molenaar
a84fe6bde6 macos: Put DnD windows on status level
This will make sure the dragged window will stay visible.
2024-09-11 08:19:39 +02:00
Benjamin Otte
1ff9d1545d Revert "vulkan: Set VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT"
This reverts commit ffae0010c4.

The commit doesn't work with the nvidia driver and it's not necessary to
use it, so drop it for now.

Fixes #6992
2024-09-11 08:17:43 +02:00
Emmanuel Gil Peyrot
6dd55e381d vulkan: Fix error string
This one got added in 66ba1f76ba but didn’t end
the sentence with a dot, and didn’t have its enum name between parentheses so
that people can debug more easily which error code got generated.
2024-09-10 22:46:29 +00:00
Emmanuel Gil Peyrot
abd8d40bf9 vulkan: Add another two error codes
Those two come from the VK_KHR_pipeline_binary extension and have been added in
Vulkan 1.3.294.
2024-09-10 22:45:41 +00:00
Simon McVittie
0fa2ae48d4 gdkgltexture: Avoid use-after-free when switching GdkGLContext
`thread_current_context` might be holding the last reference to
`previous`, in which case `gdk_gl_context_make_current` on the new
context will free `previous`, leaving it a dangling pointer.
Avoid this by making sure to hold a reference.

Fixes: 41cd0c6f "gl: Fix initial EGL context creation on X11"
Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6995
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-10 00:11:18 +01:00
Benjamin Otte
9ba41ed6e8 Merge branch 'wip/otte/blur-and-blit' into 'main'
Fix blur for opaque textures

Closes #6980

See merge request GNOME/gtk!7697
2024-09-09 04:46:43 +00:00
Matthias Clasen
75fa51ef6d Cosmetics
Fix a typo
2024-09-08 19:35:53 -04:00
Benjamin Otte
5e4f692e63 tiff: Store RGBx images as 4 channels
Set the alpha channel to "undefined" in this case.

Gimp doesn't seem to like this when opening the image and insists to
doing something with it, that's a bit of a bummer.

But it allows GTK to load RGBx textures.
2024-09-09 01:25:03 +02:00
Benjamin Otte
ffae0010c4 vulkan: Set VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT
It seems Mesa doesn't support that yet, but having it doesn't hurt.

And it allows drivers to allocate less memory for the swapchains,
because we don't need all the 4 images we request in minImageCount.
But drivers tend to take that minimum image count as gospel, so we need
to use a higher number to not cause lag in corner cases.
2024-09-08 16:22:49 +02:00
Benjamin Otte
6c72a223f5 vulkan: Enable VK_EXT_swapchain_maintenance1 if available
This just adds the plumbing, usage will happen later.

For testing, GDK_VULKAN_DISABLE=swapchain-maintenance will turn it off.
2024-09-08 16:22:49 +02:00
Benjamin Otte
5a027594c3 vulkan: Add gdk_vulkan_context_has_feature()
A siimplification that will come in handy in the future.
2024-09-08 16:22:49 +02:00
Arjan Molenaar
ae0cf9ff54 Merge branch 'amolenaar/focus-im-popups' into 'main'
macos: Fix popup window and keyboard input

Closes #6950 and #5049

See merge request GNOME/gtk!7653
2024-09-08 12:54:24 +00:00
Maximiliano Sandoval
ba32140671
docs: Remove all org.gtk.Method annotations
Removed via regex and grep.
2024-09-07 09:51:32 +02:00
Maximiliano Sandoval
91d36dd410
docs: Remove all org.gtk.Property annotations
Removed via regex and grep.

The following were intentionally not removed:

- GtkImage:file: (attributes org.gtk.Property.set=gtk_image_set_from_file)
- GtkImage:resource: (attributes org.gtk.Property.set=gtk_image_set_from_resource)

As they have no getter and (setter PROP) without a (getter PROP) crash
gobject-introspection. This is fixed by
ad3118eb51.
2024-09-07 09:51:32 +02:00
Maximiliano Sandoval
4fd1e32752
docs: Use correct property gir annotations
The annotations should only be set when the name of the setter or getter
for a property "GtkClassName:prop-name" is not gtk_class_name_g(s)et_property_name.
2024-09-07 09:51:26 +02:00
Matthias Clasen
03b19d8861 docs: Recommend glycin for image loading
Best to send people elsewhere to avoid misunderstandings of our api.
2024-09-06 16:52:47 -04:00
Matthias Clasen
d3db28b3f4 memory format: Add profiler marks
Add profiler marks to our long-running threaded operations.
To avoid spamming profiles too much, only report runs that take
at least 0.5 ms.
2024-09-06 16:14:24 -04:00
Benjamin Otte
896ea5b753 memoryformat: Add linear/nearest choice for mipmaping
linear will average all the pixels for the lod, nearest will just pick
one (using the same method as OpenGL/Vulkan, picking bottom right
center).

This doesn't really make linear/nearest filtering work as it should
(because it's still a form of mipmaps), but it has 2 advantages:

1. it gets closer to the desired effect

2. it is a lot faster

Because only 1 pixel is chosen from the original image, instead of
averaging all pixels, a lot less memory needs to be accessed, and
because memory access is the bottleneck for large images, the speedup is
almost linear with the number of pixels not accessed.
And that means that even for lot level 3, aka 1/8th scale, only 1/64 of
the pixels need to be accessed, and everything is 50x faster.

Switching gtk4-demo --run=image_scaling to linear/nearest makes all the
lag go away for me, even with a 64k x 64k image.
2024-09-06 15:47:35 -04:00
Benjamin Otte
5498b077fd memoryformat: Parallelize gdk_memory_mipmap() 2024-09-06 15:47:34 -04:00
Benjamin Otte
534a9b6ba0 memoryformat: Add fast path for mipmap
We have fast conversion functions, use those directly instead of calling
into gdk_memory_convert().

This is useful because as mentioned before, the main optimization here
is RGB8 => RGBA8 and we have a fastpath for that.
2024-09-06 15:47:34 -04:00
Benjamin Otte
cea961f4f4 memoryformat: Take src_format and dest_format
Why do we need this? Because RGB images are provided in RGB format but
GPUs can't handle RGB, only RGBA, so we need to convert.

And we need to do that without allocating too much memory, because
allocating memory is slow. Which means in aprticular we need to do the
conversion after mipmapping, not before (like we were doing).
2024-09-06 15:47:34 -04:00
Benjamin Otte
848c6815d3 gpu: Allow uploading of mipmap levels when tiling
This allows uploading less memory but requires computing lod levels on
the CPU which is slow because it reads through all of the memory and so
far entirely not optimized.

However, it uses significantly less VRAM.

This is done by adding a gdk_memory_mipmap() function that does this
task.
The texture upload op now accepts a lod level and if that is >0 it uses
gdk_memory_mipmap() on the source texture.
2024-09-06 15:47:34 -04:00
Benjamin Otte
46559039f3 memoryformat: Parallelize gdk_memory_convert_color_state() 2024-09-06 15:47:34 -04:00
Benjamin Otte
eb7a42bc13 memoryformat: Parallelize generic path of gdk_memory_convert() 2024-09-06 15:47:34 -04:00
Benjamin Otte
ffe56fe6b3 memoryformat: Parallelize
Refactor code so that it uses g_parallel_task_run().
2024-09-06 15:47:34 -04:00
Benjamin Otte
d4ba57fcc3 gdk: Add gdk_parallel_task_run()
This is just the API. Users will come later.

I considered putting it into gdkmemoryformat.c because it's likely gonna
be the only user and this one function is so little code, but it didn't
fit at all.
So now it's a new file.
2024-09-06 15:47:34 -04:00
Benjamin Otte
a95c9ebc51 memoryformat: Split out a function
Allow querying the fast conversion functions outside of
gdk_memory_convert().
2024-09-06 15:47:34 -04:00
Benjamin Otte
9195c39756 build: Alphabetic order is hard 2024-09-06 15:47:34 -04:00
Luca Bacci
7559a87e8a WGL: Detect MESA D3D12 driver and request GDI compatibility
This way we get a non-opaque framebuffer / render target

Fixes #6975

References:
  [1] https://gitlab.gnome.org/GNOME/gtk/-/issues/6975
  [2] https://gitlab.freedesktop.org/mesa/mesa/-/issues/11828
2024-09-04 20:02:44 +02:00
Luca Bacci
3a9f26113f WGL: Fix attribs_remove_last() 2024-09-04 17:07:01 +02:00
Luca Bacci
6a240c36ac WGL: Swap core / compat in debug output 2024-09-04 17:04:58 +02:00
Luca Bacci
aaf4261969 WGL: Include renderer string in debug output 2024-09-04 17:03:54 +02:00
Arjan Molenaar
aca11d6879 macos: Only allow keyboard focus on toplevel windows
This avoids the focus to move to a popup or popover window.
The red/yellow/green buttons remain colored.
2024-09-04 17:03:14 +02:00
Luca Bacci
5dceb7f7d2 WGL: Make context current to get debug info
Otherwise we get NULL from glGetString()
2024-09-04 17:02:20 +02:00
Benjamin Otte
0277e26152 Merge branch 'wip/otte/for-main' into 'main'
gpu: Use right GL context when exporting texture

See merge request GNOME/gtk!7679
2024-09-01 23:08:49 +00:00
Benjamin Otte
b0e4be7fda rendernode: Colors should not influence depth decisions
Depth of a rendernode should be determined by the textures used and the
compositing colorstate requirements.
Colors influence the colorstate choice, so they indirectly influence the
depth, but they should not influence the depth directly.

Otherwise a single color in a border being rec2100-pq would make us
switch to 16bit float.

Also remove gdk_color_get_depth(), because it was only used here and
because again: Colors should not influence depth decisions.
2024-09-02 00:22:37 +02:00
Arjan Molenaar
8054099d0e Merge branch 'amolenaar/macos-maximize-and-transparency' into 'main'
macos: Fix maximizing windows

See merge request GNOME/gtk!7650
2024-09-01 19:22:38 +00:00
Maxim Zakharov
9a8e5b07ae gdk: Add missed compute_size and request_layout vfunc to GdkBroadwaySurface 2024-09-01 13:48:22 +00:00
Matthias Clasen
5b6b42b5a9 x11: Fix initialization mess
When prepare_gl fails in the right way (or the wrong way?), we
end up creating the leader window twice, and as a side effect,
creating two instances of the "Virtual core pointer" device, which
is bad news for grabs.

Fixes: #6840
2024-08-31 11:28:52 -04:00
Matthias Clasen
ae8a06cdca x11: Cosmetics
Don't return FALSE from a function returning a pointer.
2024-08-31 11:28:52 -04:00