-
Notifications
You must be signed in to change notification settings - Fork 133
fix(capture): zero-copy dmabuf→VAAPI capture — fix whole-screen recording freeze on GNOME/AMD (#507) #508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Beetix
wants to merge
9
commits into
getopenscreen:main
Choose a base branch
from
operametrix:fix/gnome-fullscreen-dmabuf-capture
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix(capture): zero-copy dmabuf→VAAPI capture — fix whole-screen recording freeze on GNOME/AMD (#507) #508
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4c6df69
feat(capture): negotiate tiled dmabuf and plumb the GPU descriptor (#…
Beetix 138b490
feat(capture): add the dmabuf -> VAAPI importer module (#507)
Beetix 61007ef
feat(capture): wire the dmabuf importer through to the encoder (#507)
Beetix f8fe003
fix(capture): make the dmabuf VAAPI import work on radeonsi (#507)
Beetix 5bbe242
feat(capture): auto-enable dmabuf import with shm fallback (#507)
Beetix 0b6d7b5
feat(capture): crop window captures on the GPU in the VPP (#507)
Beetix 8d91be7
fix(capture): address CodeRabbit review on #508
Beetix 2fd7528
fix(capture): invalidate held dmabuf buffers on remove (CodeRabbit #508)
Beetix fef27cf
fix(capture): generation-tag held dmabuf buffers against slot reuse (…
Beetix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #include "dmabuf_modifiers.h" | ||
|
|
||
| #include <dlfcn.h> | ||
| #include <stddef.h> | ||
|
|
||
| /* | ||
| * Minimal EGL surface, spelled out rather than pulled from <EGL/egl.h> so the | ||
| * build needs no EGL dev package (same reasoning as the DRM modifier constants | ||
| * in pw_shim.c). libEGL itself is dlopen'd at runtime; if it is absent the | ||
| * caller degrades to the LINEAR/INVALID offer. | ||
| */ | ||
| typedef void *EGLDisplay; | ||
| typedef unsigned int EGLBoolean; | ||
| typedef int EGLint; | ||
| typedef intptr_t EGLAttrib; | ||
| typedef uint64_t EGLuint64KHR; | ||
|
|
||
| #define OSC_EGL_TRUE 1 | ||
| #define OSC_EGL_NO_DISPLAY ((EGLDisplay)0) | ||
| #define OSC_EGL_DEFAULT_DISPLAY ((void *)0) | ||
| /* EGL_MESA_platform_surfaceless — a display with no window system, exactly what | ||
| * a one-shot capability query wants. */ | ||
| #define OSC_EGL_PLATFORM_SURFACELESS_MESA 0x31DD | ||
|
|
||
| typedef void *(*osc_eglGetProcAddress)(const char *); | ||
| typedef EGLDisplay (*osc_eglGetPlatformDisplay)(EGLint platform, void *native, | ||
| const EGLAttrib *attrib_list); | ||
| typedef EGLBoolean (*osc_eglInitialize)(EGLDisplay, EGLint *major, EGLint *minor); | ||
| typedef EGLBoolean (*osc_eglTerminate)(EGLDisplay); | ||
| typedef EGLBoolean (*osc_eglQueryDmaBufModifiersEXT)(EGLDisplay, EGLint format, | ||
| EGLint max_modifiers, | ||
| EGLuint64KHR *modifiers, | ||
| EGLBoolean *external_only, | ||
| EGLint *num_modifiers); | ||
|
|
||
| int osc_query_dmabuf_modifiers(uint32_t fourcc, uint64_t *out, int max_out) | ||
| { | ||
| if (out == NULL || max_out <= 0) { | ||
| return 0; | ||
| } | ||
|
|
||
| /* RTLD_NODELETE: EGL keeps process-global state, so never let dlclose run | ||
| * its destructors — we deliberately do not dlclose at all. */ | ||
| void *egl = dlopen("libEGL.so.1", RTLD_NOW | RTLD_LOCAL | RTLD_NODELETE); | ||
| if (egl == NULL) { | ||
| return 0; | ||
| } | ||
|
|
||
| osc_eglGetProcAddress get_proc = | ||
| (osc_eglGetProcAddress)dlsym(egl, "eglGetProcAddress"); | ||
| osc_eglInitialize egl_init = (osc_eglInitialize)dlsym(egl, "eglInitialize"); | ||
| osc_eglTerminate egl_terminate = (osc_eglTerminate)dlsym(egl, "eglTerminate"); | ||
| if (get_proc == NULL || egl_init == NULL || egl_terminate == NULL) { | ||
| return 0; | ||
| } | ||
|
|
||
| osc_eglGetPlatformDisplay get_display = | ||
| (osc_eglGetPlatformDisplay)get_proc("eglGetPlatformDisplayEXT"); | ||
| osc_eglQueryDmaBufModifiersEXT query_mods = | ||
| (osc_eglQueryDmaBufModifiersEXT)get_proc("eglQueryDmaBufModifiersEXT"); | ||
| if (get_display == NULL || query_mods == NULL) { | ||
| return 0; | ||
| } | ||
|
|
||
| EGLDisplay dpy = get_display(OSC_EGL_PLATFORM_SURFACELESS_MESA, | ||
| OSC_EGL_DEFAULT_DISPLAY, NULL); | ||
| if (dpy == OSC_EGL_NO_DISPLAY) { | ||
| return 0; | ||
| } | ||
| if (egl_init(dpy, NULL, NULL) != OSC_EGL_TRUE) { | ||
| return 0; | ||
| } | ||
|
|
||
| int written = 0; | ||
| EGLint count = 0; | ||
| if (query_mods(dpy, (EGLint)fourcc, 0, NULL, NULL, &count) == OSC_EGL_TRUE && | ||
| count > 0) { | ||
| EGLuint64KHR mods[128]; | ||
| EGLBoolean external[128]; | ||
| EGLint cap = (EGLint)(sizeof(mods) / sizeof(mods[0])); | ||
| if (count > cap) { | ||
| count = cap; | ||
| } | ||
| if (query_mods(dpy, (EGLint)fourcc, count, mods, external, &count) == | ||
| OSC_EGL_TRUE) { | ||
| for (EGLint i = 0; i < count && written < max_out; i++) { | ||
| out[written++] = (uint64_t)mods[i]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| egl_terminate(dpy); | ||
| return written; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #ifndef OSC_DMABUF_MODIFIERS_H | ||
| #define OSC_DMABUF_MODIFIERS_H | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| /* | ||
| * Query the DRM format modifiers the local GPU's EGL stack can import for a | ||
| * given DRM fourcc (e.g. XRGB8888). These are the modifiers we can legitimately | ||
| * advertise to the compositor in the dmabuf EnumFormat: a compositor buffer | ||
| * whose modifier is in this set is one we can hand to VAAPI. Fills `out` with up | ||
| * to `max_out` modifiers and returns the count, or 0 when enumeration is | ||
| * unavailable (no libEGL, no surfaceless platform, driver refuses) — in which | ||
| * case the caller falls back to LINEAR/INVALID only. | ||
| * | ||
| * libEGL is loaded with dlopen, matching how this crate treats libpipewire: the | ||
| * helper stays buildable and runnable on a box without EGL dev packages. | ||
| */ | ||
| int osc_query_dmabuf_modifiers(uint32_t fourcc, uint64_t *out, int max_out); | ||
|
|
||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dlopen has no packaging support.
nix/pipewire-helper.nixalready patches an rpath entry so the libpipewire dlopen resolves on hosts with no ld.so.cache, but libglvnd wasn't added alongside it.On NixOS the dlopen fails, only LINEAR/INVALID get advertised, mutter falls back to shm — so #507's freeze persists there, with nothing in the log unless
OPENSCREEN_PIPEWIRE_DEBUGis set, while the probe still reportsdmabuf-import available: true.Fixed in the cherry-pick above (unverified — no nix on my machine).