Skip to content

feat(gfxfb): added IMPORT_BUFFER to scan out GPU buffers - #607

Merged
FlareCoding merged 1 commit into
masterfrom
pr/comp-gfxfb-import
Nov 7, 2026
Merged

FlareCoding merged 1 commit into
masterfrom
pr/comp-gfxfb-import

Conversation

@FlareCoding

Copy link
Copy Markdown
Owner

Summary

A picture the GPU renders into a buffer of /dev/gpuN (the GPU core's device file) reaches the screen only through a CPU
copy into a buffer of /dev/gfxfb (the display device), and GFXFB_IMPORT_BUFFER lets a display whose hardware can read
the GPU buffer show it directly instead.

Changes

  • Let kernel code hold a GPU buffer: gpu::lookup_buffer looks up a buffer handle in the calling process, refuses
    one lacking the rights asked for, takes a reference on the buffer and describes its memory (gpu::memory_view).
    gpu::release_buffer drops that reference from any context without waiting.
  • Show a GPU buffer without a copy: GFXFB_IMPORT_BUFFER (gfxfb_import_args) checks that the picture's rows lie
    inside a GPU buffer the caller may read and hands its memory to the display's import_buffer. A successful import
    takes a handle and, as a creation does, control of the buffers for its open file, and its buffer works as a created
    one except that mmap refuses it.
  • Keep the memory while the display reads it: the imported buffer holds the lookup's reference until the display's
    release_buffer drops it, and gfxfb drops it on any failure before the display takes it.
  • Refuse imports on displays without support: the boot display, virtio-gpu and NVIDIA's display engine refuse every
    import, which userland sees as ENOTTY.
  • Tell released memories apart in the GPU tests: the fake backend records each release by device id rather than by
    address, which the heap can hand to the next memory, so drain_reaper sees memory freed early.
  • Tests: buffer.test.cpp checks that a lookup describes the memory, holds the buffer until its release and refuses a
    handle naming no buffer or lacking read rights. Seven gfxfb.test.cpp tests, on a fake display that imports one fake
    GPU backend's scanout memory, check the reply, mmap's refusal, the release after a destroy, a present or an
    unwritable reply, gfxfb's own refusals in order, the display's refusals as file errors, control and the handle
    limit, and the boot display's refusal.

A picture rendered into a /dev/gpuN buffer reached the screen only through a CPU copy into a gfxfb buffer. Importing the
GPU buffer lets the display scan out that memory directly, a reference keeping it allocated while the display reaches
it. Each display decides which memory it can scan out, and one that takes none refuses imports.
@FlareCoding
FlareCoding merged commit 822f728 into master Nov 7, 2026
10 checks passed
@FlareCoding
FlareCoding deleted the pr/comp-gfxfb-import branch November 7, 2026 18:29
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