UEFI graphics
The experimental x86_64 UEFI runtime provides (sigil uefi) while firmware Boot Services are active. Graphics use a software XRGB8888 canvas and copy damage to an RGBX or BGRX Graphics Output Protocol framebuffer.
Choose a mode before opening a canvas
gop-modes returns a list of #(index width height pixel-format) vectors in firmware index order. An absent GOP returns an empty list. Formats are rgbx, bgrx, bit-mask, blt-only or unknown; the last three can be inspected but cannot be presented by this runtime. Enumeration does not set a mode or change text-console ownership. A failed QueryMode returns a structured error, rather than silently omitting a mode.
gop-set-mode! accepts a firmware index. It returns #t on success or #(uefi-error gop-set-mode! status) on firmware failure, an out-of-range integer, or an unsupported framebuffer. Noninteger arguments raise a type error. Explicit choices have no resolution cap. Firmware must provide valid width, height, stride, RGBX/BGRX format, framebuffer address and storage size. The framebuffer arithmetic must fit the address space.
For example, choose a listed 2560x1440 mode before allocating its canvas:
(import (prefix (sigil uefi) uefi:))
(define modes (uefi:gop-modes))
(unless (uefi:uefi-error? modes)
(let ((native
(find (lambda (mode)
(and (= (vector-ref mode 1) 2560)
(= (vector-ref mode 2) 1440)
(memq (vector-ref mode 3) '(rgbx bgrx)))) modes)))
(when native
(let ((result (uefi:gop-set-mode! (vector-ref native 0))))
(when (eq? result #t)
(let* ((info (uefi:gop-info))
(width (vector-ref info 0))
(height (vector-ref info 1))
(pixels (make-bytevector (* width height 4) 0)))
(uefi:gop-present! pixels width 0 0 width height)))))))A successful mode change can clear the screen. Changing modes after drawing is allowed, but callers must recreate canvases at the new dimensions. If firmware changes the mode and then reports an invalid framebuffer, the setter returns an error even though the screen may have changed. Subsequent drawing still validates the live framebuffer.
Automatic behavior and the text console
The first gop-info or gop-present! applies automatic mode selection once, unless a successful explicit choice already exists. It keeps a usable firmware mode within 1920x1200. Otherwise it chooses the largest RGBX/BGRX mode within that bound among the first 256 firmware modes, as before. Failed explicit choices do not suppress this fallback. A successful explicit choice can also recover after automatic selection fails.
gop-info returns #f without usable graphics, otherwise #(width height pixels-per-scan-line pixel-format). Opening graphics through gop-info or gop-present! routes later diagnostic text to firmware SerialIo to avoid overwriting the image. Mode listing, EDID reads and explicit mode selection do not change that routing. Selection itself can necessarily alter the screen. Programs retaining a text fallback should inspect modes and EDID before deciding to open graphics.
EDID
gop-edid copies the selected display's EFI_EDID_ACTIVE_PROTOCOL bytes, falling back to EFI_EDID_DISCOVERED_PROTOCOL when Active is absent or empty. It returns #f when no bytes are available and a structured firmware error on other protocol failures. It never falls back to an unrelated display. Raw data is copied unchanged, up to EDID's 256-block size of 32768 bytes. The API currently associates EDID with the GOP handle itself; combined-output GOP handles without their own EDID return #f.
The pure edid-preferred-mode helper returns #(width height) from the first detailed timing descriptor, or #f. It checks the 128-byte base block's header, version 1.0 through 1.4 and checksum, and rejects absent, zero-sized and interlaced timings. It does not search later descriptors or extension blocks. Additional bytes and missing extensions do not affect base-block parsing. Non-bytevector input raises.
edid-screen-size validates the same base block and returns the physical width and height from bytes 21-22, in centimeters. Either zero dimension returns #f, including EDID 1.4 encodings that describe only an aspect ratio. Physical dimensions have centimeter precision, so an application matching aspect ratios should allow for rounding.
For protocol layout, see the UEFI console specification. The timing field layout is also described by the Linux DRM EDID definitions.
Performance and qualification
The original 1920x1200 policy was introduced as a conservative default, with no recorded performance measurement. Keeping it only for automatic selection preserves application behavior while allowing explicit native resolutions. One four-byte-per-pixel canvas uses 7.91 MiB at 1920x1080, 14.06 MiB at 2560x1440 and 31.64 MiB at 3840x2160, plus the firmware framebuffer and the renderer/runtime's other allocations. Full-frame writes scale with pixel count; damage-only presentation can reduce that cost.
The graphics qualification harness uses QEMU/OVMF, private variables files, independent firmware mocks, fixed EDID fixtures and rejecting controls. Its presentation probe warms the framebuffer once, then measures eight full gop-present! calls with allocation and logging outside the timed interval. It uses the runtime's calibrated monotonic clock; QEMU software-emulation timings describe that environment, not panel refresh rate or real-device throughput.