Software (CPU) presentation subsystem: cl-windowing/software #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Present a CPU-drawn frame — a plain Lisp array of pixels — to a cl-windowing window on Windows and Wayland, with no GPU API (no OpenGL/Vulkan/DirectX). The case that asks for it is an application that is not graphically intensive and wants no Vulkan device: a text editor, a log viewer, a small tool. It also keeps the display layer honestly usable without Vulkan, and is a very different second presentation path, so it exercises the window abstraction the way a second backend did.
Design
A new optional system
cl-windowing/softwareholds the portable part (depends oncl-windowingcore only), exactly parallel tocl-windowing/vulkan:pixel-surfaceobject bound to a window, the canonical pixel format, the public API, and the resize handshake.backend-create-pixel-surface,backend-resize-pixel-surface,backend-present-pixels,backend-destroy-pixel-surface.cl-windowing/win32implements it with GDI (viacl-win32);cl-windowing/waylandwithwl_shm(viacl-wl).Public API
create-pixel-surface/destroy-pixel-surface/with-pixel-surface.begin-pixel-frame→(values pixels width height): reallocates to the window's pending pixel size if any (so you draw at the new size), else returns the current buffer; allocates nothing in steady state.present-pixel-surface &key damage: blits/commits;damage= optional(x y w h)rectangles for partial repaint; callsadopt-window-sizejust before the frame shows (the core's resize contract).pixel-surface-window,pixel-surface-size,pixel-surface-pixels.Pixel format
One canonical format so user code never branches on platform: a
(simple-array (unsigned-byte 32) (*))of#xAARRGGBBpixels, top row first, tightly packed. On little-endian (SBCL's targets) this is byte-identical to a top-down GDIBI_RGB32 bpp DIB and towl_shmXRGB8888(bytes B,G,R,X), so the backends hand the array's memory straight to the platform. Windows are opaque (alpha byte ignored); transparency (ARGB8888premultiplied) is a later extension.Resize and scale
Follows the existing handshake:
window-pending-pixel-size→begin-pixel-framereallocates →present-pixel-surfacecallsadopt-window-size. Buffer sized towindow-pixel-size; the ±1px fractional-scale rounding on Windows is absorbed byStretchDIBitsto the client rect (as the Vulkan swapchain absorbs it), and on Wayland by viewporter (the path the Wayland backend already uses).Backends
CreateDIBSectionDIB is the retained frame; present copies the Lisp array into it andBitBlt/StretchDIBitsto the window DC;WM_PAINTrepaints from the retained DIB (so uncovering/resizing needs no app redraw);WM_ERASEBKGNDkeeps returning 1. Needs GDI bindings → dxtr/cl-win32#1.wl_shmpool +XRGB8888buffer (double-buffered);write-shared-memory+attach/damage_buffer/commit; viewporter for fractional scale.cl-wlalready exposes all the shared-memory machinery (make-shared-memory,shared-memory-fd,write-shared-memory,wl-shm-create-pool), so no cl-wl work is needed.Capabilities & errors
window-system-capabilitiesgains:software-presentationwhere the backend offers it;create-pixel-surfacesignalsunsupported-errorwhere absent.unsupported-error.closed-errorfor dead window/surface;window-system-errorwrapping a failedCreateDIBSection/mmap/wl_shmallocation.Tests (cl-windowing/test)
begin-pixel-framesizing, resize reallocation and adopt-at-present; steady-state frames allocate nothing.GetDIBits, check pixels; resize follows;WM_PAINTrepaints the pattern; cross-thread present test to settle the thread rule.wl_shmbuffer and check pixels; resize remakes the pool; damage reported as committed.Packaging
New
cl-windowing/softwaresystem +software/dir;/win32and/waylandeach gain asoftware.lisp(dependencies unchanged — they already needcl-win32/cl-wl); the test system depends on it; README gains a "Software presentation" section with the run example.Spec & dependencies
Full design in
gdi.orgin the engine workspace. Depends on GDI bindings: dxtr/cl-win32#1. Nocl-wlchanges needed.Decided
engine-design.org, its Libraries table and its Build order, and that document does not linkgdi.org.Open decisions for Kim (see gdi.org)
:format :argb8888extension.