Skip to content

linux_util: negotiate explicit DRM modifiers in dmabuf probe + guard NVIDIA OSR - #633

Draft
mysticalsoap wants to merge 2 commits into
andrewrabert:mainfrom
mysticalsoap:fix/nvidia-dmabuf-modifier
Draft

linux_util: negotiate explicit DRM modifiers in dmabuf probe + guard NVIDIA OSR#633
mysticalsoap wants to merge 2 commits into
andrewrabert:mainfrom
mysticalsoap:fix/nvidia-dmabuf-modifier

Conversation

@mysticalsoap

Copy link
Copy Markdown
Contributor

Problem

On NVIDIA/Wayland the dmabuf capability probe (src/linux_util/src/dmabuf_probe.rs) allocates its test buffer with an implicit modifier and imports it via EGL without negotiating an explicit one. NVIDIA rejects implicit-modifier import, so glEGLImageTargetTexture2DOES fails with GL_INVALID_OPERATION (0x502) and shared textures latch off (same signature as #157). The Vulkan import path in gpu_paint/dmabuf_import.rs already negotiates explicit modifiers; the EGL probe didn't.

Fixing that alone regresses NVIDIA, though: once the probe passes, CEF's OSR compositor can't wrap the buffer as a writable render target ("Unable to initialize SkSurface" in Chromium's shared_image_representation.cc), blanking the window. That's an upstream Chromium bug CEF and Electron both inherit — Electron closed the identical failure not-planned (electron/electron#49247). Full write-up and two-layer diagnosis in #632.

Fix

Two commits:

  1. Probe negotiates an explicit modifier: query eglQueryDmaBufModifiersEXT for ARGB8888 (non-external-only), allocate via gbm_bo_create_with_modifiers, pass it via EGL_DMA_BUF_PLANE0_MODIFIER_{LO,HI}_EXT. Missing symbols or no advertised modifier fall through to the existing implicit path, so Mesa is unchanged.
  2. Query EGL_VENDOR and block shared textures on NVIDIA regardless of the probe result, so the corrected probe can't hand CEF the OSR path that blanks the window.

Net-neutral by design: NVIDIA already fell back to software before this (via the 0x502 failure) and still does; Mesa already worked and is untouched. The value is a correct, Vulkan-path-consistent probe plus a guard that's ready for whenever the upstream OSR bug is fixed. Happy to drop the code and keep just the issue if you'd prefer.

Verification

just fmt/just lint/just build pass. On an RTX 4090 + KWin (Plasma 6.7.3, driver 610.43.03): commit 1 alone makes the probe negotiate 0x300000000606013 and pass, then blanks with repeated SkSurface errors; commit 2 keeps the probe passing but blocks shared textures (one warn log), zero SkSurface errors, UI renders on the software path as before.

Status

Draft — this doesn't improve NVIDIA performance (blocked upstream), it replaces an unexplained transport failure with a diagnosed one and lands groundwork. Flagging the EGL_VENDOR string check as the main thing to sanity-check before this is ready.

Assisted-by: claude-sonnet-5

NVIDIA's EGL/GBM stack doesn't support implicit-modifier dmabuf import
the way Mesa does, so glEGLImageTargetTexture2DOES failed with
GL_INVALID_OPERATION (0x502) and the whole session fell back to
software CEF rendering — even though the runtime shared-texture import
path (gpu_paint's Vulkan-based dmabuf_import.rs) already negotiates
explicit modifiers correctly and is unaffected.

Query eglQueryDmaBufModifiersEXT for ARGB8888, filtered to non-
external-only entries, and allocate the test GBM buffer via
gbm_bo_create_with_modifiers when both the extension and symbol are
available, passing the chosen modifier explicitly via
EGL_DMA_BUF_PLANE0_MODIFIER_{LO,HI}_EXT. Missing symbols or an empty
modifier list fall through to the existing implicit gbm_bo_create path
unchanged, so Mesa drivers are unaffected.

Verified against RTX 4090 + KWin: the probe now negotiates an explicit
modifier (0x300000000606013) and reports GBM -> EGL -> GL import OK.

Note: enabling the shared-texture path this way surfaces a separate,
still-unresolved failure in CEF's own GPU process (repeated "Unable to
initialize SkSurface" in shared_image_representation.cc, blank
window) that was previously masked by the software-rendering fallback.
See PR description for details — not yet safe to merge on its own.

Assisted-by: claude-sonnet-5
The modifier fix in the previous commit is real and correct — NVIDIA can
genuinely import a dmabuf via the transport probe. But enabling shared
textures on that basis surfaces a separate, independent failure: CEF's
OSR compositor can't wrap the imported buffer as a writable render
target (SkSurfaces::WrapBackendTexture fails, "Unable to initialize
SkSurface" in Chromium's shared_image_representation.cc), producing a
blank window every frame instead of a UI.

This is not jellium-desktop's bug to fix. Electron hits the identical
failure — same file, same message, same trigger (OSR + shared texture),
same NVIDIA+Wayland scope, AMD/Mesa and non-OSR unaffected — and closed
their own tracking issue as not planned with no root cause or workaround
(electron/electron#49247). Both CEF and
Electron only wrap Chromium's own GPU-compositing code; neither project
controls this code path.

Query EGL_VENDOR once the display is available and block shared
textures on NVIDIA regardless of what the transport probe reports,
trading a working (if slow) software-rendered UI for a correctly
understood limitation instead of an unexplained blank window. Verified
live on RTX 4090 + KWin: transport still negotiates the modifier and
passes, the vendor guard overrides it, zero SkSurface errors, UI
renders as before (software path, same as pre-fix baseline).

Assisted-by: claude-sonnet-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant