hal/metal/canvas.lisp
Make the layer follow SDL's physical-pixel extent, including Retina scale.
A render-only drawable can remain framebuffer-only. Copies need the broader CAMetalLayer texture contract used by captures and luvcraft.
CAMetalLayer cycles a bounded native drawable pool, but each NEXTDRAWABLE call is represented by a fresh borrowed Lisp texture wrapper. Metal 4's resource identity survives those wrappers and becomes reusable only when the layer makes that drawable available again.
All selectors and resource relationships below have already crossed the Lisp validation boundary. Keep the inspectable exception bridge for setup and diagnosis, but do established per-frame traffic as direct objc_msgSend calls on the native thread that actually encodes.
Require the Metal 4 drawable operations in their semantic order.
Objective-C sends happen on the Cocoa thread. Establish the dynamic tracing runtime there rather than on this caller thread.
Present one Metal 4 clear and return bounded SDL/layer/submission evidence.
(provider)Return the SDL presentation policy required by GPU PROVIDER.
A provider for the system's preferred Metal device.
A GPU presentation relationship configured for a canvas.
A native destination with a lifetime and frame clock.
(context)Return CONTEXT's configured drawable extent as (WIDTH HEIGHT), or NIL.
(context)Return the GPU device used by CONTEXT, or NIL before first configuration.
A MuPDF context: its allocator, its store, and its error stack.
(context operation expected-state)(format)(format)(layer width height)(layer)Logical conjunction of tests and raw truth values.
Test whether two compatible scalars are equal.
(context configuration)The small portable portion of a canvas presentation configuration.
(object operation)(&optional (stream *standard-output*))(context configuration)Configure or reconfigure CONTEXT for presentation.
(canvas function)(context)Logical negation of one test or raw truth value.
(canvas)(canvas gpu-provider &optional configuration)Create a GPU presentation relationship between CANVAS and GPU-PROVIDER. When CONFIGURATION is omitted, return the context unconfigured.
(pointer &key (ownership :borrowed) protocol-name)(context)Return the borrowed GPU texture current during a canvas frame.
Logical disjunction of tests and raw truth values.
(context surface-texture)Return the stable presentation slot key for SURFACE-TEXTURE in CONTEXT. Applications use this to retain per-frame resources without assuming that a backend returns the same Lisp wrapper every time it revisits a native drawable.
(name-and-options lambda-list &body body)Define a function whose complete dynamic extent is an ambient trace zone. The inferred name is PACKAGE/FUNCTION. Use (NAME :ZONE ZONE-NAME) to provide a more semantic name and :VALUE FORM to attach a Tracy work count.
(() &body body)(() &body body)((name &key (tracy-value nil tracy-value-supplied-p)) &body body)Measure BODY as nested zone NAME for whichever measurement is watching. TRACY-VALUE, when supplied, is attached to the Tracy zone at exit. It does not affect the bounded CPU trace, whose zones retain time and runtime costs. Two independent things may be: a Tracy viewer attached to this image, and an opt-in…
(device descriptor)Asks the DEVICE for a handle to newly created instance of some object fulfilling the DESCRIPTOR.
(size descriptor &optional (operation :create))(canvas)Predict when a frame acquired now will become visible on CANVAS.
(canvas timestamp function)(queue command-buffers &key after-commit)Commit finished Metal work and retain its dependencies to QUEUE's frontier. AFTER-COMMIT performs the drawable signal and presentation handshake before the completion event is enqueued. Presentation is the only caller of that backend-local extension; ordinary callers use SUBMIT. #T9K4RC
(handle)Logically invalidate HANDLE immediately. Native teardown may be deferred until submitted work which captured HANDLE has completed.
(context function)Acquire a frame texture, call FUNCTION with texture, encoder, and predicted presentation time, then complete presentation. FUNCTION runs on the canvas's native frame thread, with CANVAS-TIME overridden to that same prediction.
(selectors)(canvas device context color)(canvas function)Run FUNCTION with a timestamp on CANVAS's native frame/event thread. The initial native implementation is synchronous: the caller waits for the function's values. The protocol leaves room for a real frame scheduler.
((trace) &body body)(context red green blue &optional (alpha 1.0))(object)(&key (width 320) (height 200) (visible-p nil)
(color #(0.80d0 0.10d0 0.70d0 1.0d0)))(&key (title "luv canvas") (width 800) (height 600)
x y (visible-p t) (fullscreen-p nil)
(high-pixel-density-p nil)
(clock (make-demand-clock))
(time (make-lazy-clock))
(presentation-api :vulkan))Construct an unrealized SDL canvas. WIDTH or HEIGHT may be NIL, which asks the display for a size when the window is finally created.
(provider &optional descriptor)
Metal 4 presentation as a relationship between an SDL canvas and device.