main f2d166b

#22 fix(drm): hardware cursor plane refused on nvidia-drm

state
closed
opened
bnema ·
updated

Problem

On the NVIDIA proprietary driver (nvidia-drm), KMS refuses the hardware cursor plane:

{"level":"warn","component":"drm","error":"invalid argument","connector":"DP-1","message":"cursor plane refused; hardware cursor off"}

NeferWL then falls back to a software cursor drawn into the frame. It works, but:

  • every pointer motion forces a new frame (more GPU work, more latency);
  • the cursor only appears after the first motion.

AMD (amdgpu) does not hit this: the cursor plane is accepted.

Likely cause

The cursor buffers are linear images allocated by Vulkan and exported (internal/adapters/vulkan/cursor.go, CursorBuffers), the same allocate-in-Vulkan, scan-out-in-KMS path that corrupted the primary plane on NVIDIA. nvidia-drm has its own cursor buffer requirements (Aquamarine notes NVIDIA cursor buffers may be non-renderable or linear-only).

What other compositors do

  • wlroots: allocates cursor buffers with GBM using GBM_BO_USE_CURSOR.
  • Hyprland: cursor:use_cpu_buffer (default on NVIDIA) writes the cursor into a CPU (dumb) buffer.

Proposed fix

  1. Allocate the two cursor buffers with GBM (GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE, linear ARGB8888) using the existing internal/adapters/drm/gbm package. Write the pixels with gbm_bo_write or a map.
  2. Otherwise, use KMS dumb buffers (DRM_IOCTL_MODE_CREATE_DUMB and mmap) and write the cursor pixels from the CPU (64×64, negligible cost).
  3. Keep the current Vulkan cursor images, then the software cursor, as fallbacks.
  4. Log which cursor allocator is used.

Verification

  • Unit tests with generated mocks for the allocator choice and fallbacks.
  • Allocation test on a real NVIDIA GPU (render node only; no display available for the scanout itself).
  • End-to-end check on an NVIDIA machine with a display: no cursor plane refused warning, and the cursor shows at startup.

Comments1

bnema

Confirmed on nvidia-drm with main (6d4359db, neferwl!26): DP-1 3440x1440 logs `"message":"hardware cursor"` with `"alloc":"dumb"` (size 256), no `cursor plane refused`; cursor moves go through cursor commits (`cursor_commits:2`) with no missed vblanks; output images stay on `"alloc":"gbm"`.

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 25

Tags 10

↑↓ moveenter openesc close