Commit Graph

78016 Commits

Author SHA1 Message Date
Matthias Clasen
13d0e311b7 gsk: Prepare for external textures
Prepare the plumbing in the GL renderer for textures that use
target GL_TEXTURE_EXTERNAL_OES. These need to use a special sampler,
so make sure our sampler machinery does not run over it.
2023-10-22 16:42:17 -04:00
Matthias Clasen
52254f755f gsk: Support dmabuf textures
Defer handling of dmabuf textures to the driver,
and add the necessary code in load_texture.
2023-10-22 16:42:17 -04:00
Matthias Clasen
494154beb6 dmabuf: Add an EGL downloader
Add an implementation of GdkDmabufDownloader that uses
gsk_renderer_render_texture + GL texture download.

Since gsk isn't threadsafe, we do the download in the main thread,
taking care to not disturb the current GL context of whatever is
going on there at the time.

And since gsk renderers are expensive to create, we cache it
in the display.

Note that gsk does not yet have any special support for
dmabuf textures, so for now, they will always get downloaded
and then reuploaded as GL textures.
2023-10-22 16:42:17 -04:00
Matthias Clasen
adde188eca gsk: Add a helper for converting textures
This is a simple helper that feed a GdkTexture
through a renderer and returns the resulting
texture. This will be used to convert dmabuf
textures to 'native' textures.
2023-10-22 16:39:24 -04:00
Matthias Clasen
8fb0ab2b43 gl context: Add private dmabuf API
Add API to import a dmabuf into a texture,
and to export a texture to a dmabuf.

All this is implemented using the relevant
EGL and GL extensions.
2023-10-22 16:39:24 -04:00
Matthias Clasen
b8b5835fc6 gl context: Check for more GL extensions
These will be used in future commits.
2023-10-22 16:39:24 -04:00
Matthias Clasen
463307655c display: Check for more EGL extensions
We are going to rely on this in future commits.
2023-10-22 16:39:24 -04:00
Matthias Clasen
d17d8e04a6 Add a few dmabuf texture tests
Test some basic import and export of dmabufs.

For now, put the test into the 'failing' suite,
since it does not work in CI, and also fails
on AMD hw.
2023-10-22 16:39:24 -04:00
Benjamin Otte
3a9aea44df Merge branch 'wip/otte/for-main' into 'main'
build: Change where we get drm_fourcc.h from

See merge request GNOME/gtk!6514
2023-10-22 19:33:27 +00:00
Benjamin Otte
e05764806a build: Change where we get drm_fourcc.h from
The canonical source for userspace is libdrm, not kernel headers.

Fixes compilation on Arch Linux.
2023-10-22 20:40:20 +02:00
Benjamin Otte
5ca65f04fe Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Allow downloaders to fail initialization

See merge request GNOME/gtk!6513
2023-10-22 17:19:16 +00:00
Benjamin Otte
32ba1e389c build: Check for drm/drm_fourcc.h too
It's part of the kernel headers package so I did not check for libdrm.

As a side effect I checked the #define to HAVE_DMABUF.
2023-10-22 17:27:11 +02:00
Benjamin Otte
beb9e0c906 dmabuf: Add gdk_dmabuf_is_disjoint()
No users yet, but Vulkan will use this later. So have it available
already.
2023-10-22 17:03:15 +02:00
Benjamin Otte
98f02f6221 dmabuf: Reject the INVALID modifier
Trying to use it is a programming error, applications should have code
that uses real modifiers.

Also add a check to the formatsbuilder so our code doesn't include the
invalid modifier by accident.

We don't really know how to deal with it, so better force applications
to figure out what to do.
2023-10-22 17:03:15 +02:00
Benjamin Otte
13848969f4 dmabuf: Allow downloaders to fail initialization
When adding the formats of a downloader, allow them to return FALSE to
mean "This method is not supported", which is a useful way to opt out
when checking GL or Vulkan extensions and finding out that the desired
one isn't supported.
2023-10-22 17:03:13 +02:00
Matthias Clasen
0817dfe67f Merge branch 'matthiasc/for-main' into 'main'
dmabuf: Give downloaders a name

See merge request GNOME/gtk!6511
2023-10-21 23:42:10 +00:00
Matthias Clasen
9e3f537a15 dmabuf: Give downloaders a name
Add name to the downloader struct, and add it
to the debug spew for newly created dmabuf
textures.
2023-10-21 19:19:21 -04:00
Matthias Clasen
612e0e29f9 Merge branch 'matthiasc/for-main' into 'main'
testdmabuf: Add a --download-to option

See merge request GNOME/gtk!6510
2023-10-21 21:39:36 +00:00
Matthias Clasen
e1cbc96b8c testdmabuf: Add a --download-to option
The next option we add will tilt the balance
towards GOptionContext.
2023-10-21 17:26:53 -04:00
Matthias Clasen
410240fe7b Merge branch 'matthiasc/for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!6509
2023-10-21 20:34:36 +00:00
Matthias Clasen
73cf3a92f9 cosmetics 2023-10-21 16:10:09 -04:00
Matthias Clasen
dd15122ccb dmabuf: Add some debug spew 2023-10-21 14:44:28 -04:00
Benjamin Otte
5299f1384f Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Require valid fds for all planes

See merge request GNOME/gtk!6508
2023-10-21 15:15:57 +00:00
Benjamin Otte
58a0e4ffaa testdmabuf: Add --disjoint and --undecorated
The code now by default puts all planes into the same fd - like
v4l does, too.

The old behavior of one fd per plane can be enabled via --disjoint.

Also, am --undecorated option has been added so that the window
isn't decorated and all that the renderer has to do is display the
dmabuf.
This is useful when debugging just the dmabuf rendering.
2023-10-21 17:02:05 +02:00
Benjamin Otte
7ab9056c11 testdmabuf: Fix NV12
The code was computing the wrong size.
2023-10-21 16:42:16 +02:00
Benjamin Otte
2d9fbb16bc testdmabuf: Use the actual pixel
The previous code would subsample the luma channel, too. Don't do that.
2023-10-21 16:42:15 +02:00
Benjamin Otte
cbfd8542c6 dmabuf: Require valid fds for all planes
This seems to be what everyone does, so we should do it, too.

Previously it was assumed that an fd of -1 would mean reusing the
previous fd with a different offset, but that seems to be uncommon.
2023-10-21 16:42:15 +02:00
Piotr Drąg
7679504134 Update POTFILES.in 2023-10-21 14:14:02 +02:00
Sabri Ünal
446d461ad2 Update Turkish translation 2023-10-21 09:16:05 +00:00
Matthias Clasen
5b6fcfe8c9 Merge branch 'misc-dmabuf-fixes' into 'main'
Make a test app with dma heaps

See merge request GNOME/gtk!6507
2023-10-21 02:06:20 +00:00
Matthias Clasen
59ce7ab222 dmabuf: Improve the debug message
Printing the format can only help.
2023-10-20 20:03:27 -04:00
Matthias Clasen
0992837b08 dmabuf: Fix the mmap logic
We want to unmap the buffers we mapped in
the first loop, so pass the right pointers
here.
2023-10-20 20:03:11 -04:00
Matthias Clasen
aca02916ad dmabuf: Fix NV12 import
We were not seeking in the right fd,
so our sizes were wrong, and crashes
happened.
2023-10-20 19:53:33 -04:00
Matthias Clasen
98e883f9b4 Make a test app with dma heaps
This uses the dma-heap kernel api to create a dma-buf
and use it for a GdkDmabufTexture. It supports a few
formats to test how well GL conversion of YUV works.

The YUV code is adapted from weston tests.
2023-10-20 19:53:33 -04:00
Matthias Clasen
2c66aa0c15 Merge branch 'matthiasc/for-main' into 'main'
dmabuf: Fix format mapping for RGB formats

See merge request GNOME/gtk!6506
2023-10-20 23:44:52 +00:00
Matthias Clasen
8843c0d504 dmabuf: Fix format mapping for RGB formats
The channel order was reversed.
2023-10-20 19:22:00 -04:00
Matthias Clasen
8858f1c9ec Merge branch 'xrgb-formats' into 'main'
Add XRGB memory formats

Closes #6172

See merge request GNOME/gtk!6505
2023-10-20 22:34:19 +00:00
Matthias Clasen
a1c5c20e2c dmabuf: Add xrgb formats 2023-10-20 18:14:45 -04:00
Matthias Clasen
1da674423d vulkan: Add xrgb formats
For now, we just fall back to RGB.
2023-10-20 18:14:45 -04:00
Matthias Clasen
10250a0a6a Add XRGB memory formats
These are not uncommon in dmabufs,
and supporting them is easy.

Fixes: #6172
2023-10-20 17:58:06 -04:00
Matthias Clasen
c0a2f9fbc3 Merge branch 'missing-argb-format' into 'main'
Add GDK_MEMORY_A8B8G8R8_PREMULTIPLIED

See merge request GNOME/gtk!6504
2023-10-20 21:12:43 +00:00
Matthias Clasen
bd974b08b3 Add GDK_MEMORY_A8B8G8R8_PREMULTIPLIED
We did have 4 ordering variations of ARGB straight,
but only 3 premultiplied. Add the missing one.

Update all the places where we switch over memory formats.
2023-10-20 16:42:40 -04:00
Matthias Clasen
d289c0d4f1 Merge branch 'matthiasc/for-main' into 'main'
rendernodeparser: Use private memoryformat api

See merge request GNOME/gtk!6502
2023-10-20 14:00:55 +00:00
Matthias Clasen
f4722289f7 Merge branch 'more-bgra' into 'main'
gsk: Use has_bgra in more places

See merge request GNOME/gtk!6500
2023-10-20 13:43:51 +00:00
Benjamin Otte
389af3591c Merge branch 'wip/otte/for-main' into 'main'
dmabuf refactoring

See merge request GNOME/gtk!6503
2023-10-20 12:48:53 +00:00
Benjamin Otte
008d9e5327 vulkan: Actually check for GDK_DEBUG=vulkan-disable
The dmabuf code would happily init Vulkan even if it was told we don't
want it.
2023-10-20 14:26:59 +02:00
Benjamin Otte
09723d79c6 dmabuf: Support YUYV and friends
Same as the NV12 support, but necessary for the poor people stuck on
Intel laptops.
2023-10-20 14:26:59 +02:00
Benjamin Otte
4586af5876 dmabuf: Add support for NV12 and NV21
This is as-good-as-necessary and doesn't do any fancy colorspace magic
or chroma whatevering.

That's a task for the future.
2023-10-20 14:26:59 +02:00
Benjamin Otte
193d9cd31a dmabuf: Improve download
1. Split out the download function from the mmap'ing of the plane(s)

2. Make the code mmap() all the planes

3. Determine size using lseek() as documented by libdrm, instead of
   trying to guess it from the format.

4. Fix some bugs, like switcheroos of width and height
2023-10-20 14:26:59 +02:00
Benjamin Otte
f29303dea7 dmabuf: Allocate the intermediate buffer properly.
We should use the stride from the buffer's format, not from the dmabuf.
2023-10-20 14:26:59 +02:00