hal/vulkan/canvas.lisp
The window's pixel size when this swapchain was built.
Compared against the window rather than against EXTENT, which comes from the surface's own idea of its current extent: a platform where the two disagree would otherwise ask for a rebuild on every single frame.
One swapchain's bounded, presentation-ID-indexed display observations.
Return fallback-time and the next native display beat when available.
The selected Vulkan time domain may be opaque and unrelated to Lisp's monotonic clock. Keep animation prediction in the host domain and advance native targets only from observed or already-scheduled native timestamps.
Feedback seeds the native clock. After that, requested targets own cadence: a late result is evidence of a missed beat, not a new phase from which to delay the following frame.
Return a coherent copy of context's bounded presentation observations.
Print display cadence and prediction drift observed for context.
Write context's raw presentation observations to pathname.
Wait for slot's frame to pass the queue frontier, then release it.
Describe and, when possible, enable timing observation for context.
Attach unconfigured context to device and create its native SDL surface.
A swapchain is only ever right for one window size. Resizing the window leaves the images, their views, and the surface's own extent describing a window that no longer exists, and Vulkan says so by refusing to hand out another image. Rebuilding is the whole answer, and it is cheap enough to do from inside the frame that discovered the problem.
Replace context's swapchain with one built for the window's present size.
The configuration is the one the application already asked for: only the extent, the images, and the per-image synchronization are made again. Returns NIL when the window has no pixels to present to at all, which is an ordinary state for a minimized window and not an error.
Make the swapchain agree with the window before a frame asks for an image.
Returns NIL when this frame cannot be presented, which the caller skips.
Acquire the next presentable image, rebuilding a stale swapchain once.
Returns the frame slot, its index, and the image index, or NIL when the surface still cannot supply an image and this frame should be skipped.
The semaphore is left unsignalled by a refused acquisition, so the rebuilt swapchain's own slots start clean.
Choose the display beat represented by context's next frame.
Present one image and opportunistically collect its display timestamp.
The image was presented to a surface that has already moved on. Forgetting the size this swapchain was built for is what makes the next frame rebuild it, even when the window itself reports the same pixels as before.
Run one frame, then account for whatever the validation layer said.
The end of the frame is the safe point: every Vulkan call it made has
returned, so a complaint can become a condition without unwinding through a
driver mid-call. guarding-sdl-canvas catches it, retains it with the
backtrace the callback took while the offending frames were still on the
stack, and parks the canvas -- the same treatment as any other frame that
failed, and visible from ./sly as a reported failure rather than a line
somebody has to go looking for.
(provider)Return the SDL presentation policy required by GPU PROVIDER.
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.
One swapchain's bounded, presentation-ID-indexed display observations.
(present-id)The non-negative remainder of integer division.
(timeline present-id predicted-seconds submitted-seconds
&optional (target-nanoseconds 0))Convert one scalar float or unsigned value to a 32-bit float.
The minimum of compatible quantities.
(timeline present-id actual-nanoseconds time-domain time-domain-id)Test whether two compatible scalars are equal.
Logical conjunction of tests and raw truth values.
Test whether one compatible scalar is greater than another.
(timeline fallback-time)Return FALLBACK-TIME and the next native display beat when available. The selected Vulkan time domain may be opaque and unrelated to Lisp's monotonic clock. Keep animation prediction in the host domain and advance native targets only from observed or already-scheduled native timestamps.
Logical disjunction of tests and raw truth values.
Addition over compatible quantities.
Subtraction or unary negation.
A MuPDF context: its allocator, its store, and its error stack.
(canvas function)(observations)Division of two represented quantities.
(observations)Multiplication and scalar scaling.
Test whether one compatible scalar is less than another.
Raise a dimensionless value to a dimensionless power.
The componentwise square root of a raw value.
(context &optional (stream *standard-output*))(context pathname)(context)Return the GPU device used by CONTEXT, or NIL before first configuration.
(native-device)(device)(native-device count)(device semaphore)(native-device count)(native-device slot)(handle)Logically invalidate HANDLE immediately. Native teardown may be deferred until submitted work which captured HANDLE has completed.
(queue slot)(queue index)(provider)Return Vulkan instance extensions and flags for PROVIDER.
VK_KHR_get_surface_capabilities2
VK_KHR_swapchain
(canvas provider instance)(canvas provider instance surface)Logical negation of one test or raw truth value.
VK_EXT_present_timing
VK_KHR_present_id2
(physical-device &key present-timing-p present-id-2-p)Return the optional presentation feature bits exposed by PHYSICAL-DEVICE. The values are PRESENT-TIMING, PRESENT-AT-ABSOLUTE-TIME, PRESENT-AT-RELATIVE-TIME, and PRESENT-ID-2. A feature whose extension was not advertised is never placed in the query chain and is returned as NIL.
(physical-device surface)(timeline native-device swapchain)(device swapchain)(device swapchain)(timeline native-device swapchain)(device swapchain function)(context device)(object operation)(physical-device queue-family-index surface)(context requested-format)(value minimum maximum)The maximum of compatible quantities.
(context capabilities)(capabilities)(context operation expected-state)(context configuration)The small portable portion of a canvas presentation configuration.
(&optional (stream *standard-output*))(&body body)(physical-device surface)(device surface format color-space extent
&key min-image-count (usage '(:transfer-dst))
(pre-transform :identity) (composite-alpha :opaque)
(present-mode :fifo-khr) old-swapchain present-timing-p)(device image size format vk-format &key (usage '(:copy-dst)) owner aspect
(layout :undefined) semaphore
(semaphore-value 0) submitted)(device swapchain size)(device swapchain)(context configuration)Configure or reconfigure CONTEXT for presentation.
(device)(canvas gpu-provider &optional configuration)Create a GPU presentation relationship between CANVAS and GPU-PROVIDER. When CONFIGURATION is omitted, return the context unconfigured.
(context)Return the borrowed GPU texture current during a canvas frame.
(context)Replace CONTEXT's swapchain with one built for the window's present size. The configuration is the one the application already asked for: only the extent, the images, and the per-image synchronization are made again. Returns NIL when the window has no pixels to present to at all, which is an ordinary state for a…
(category control &rest arguments)Write one timestamped line about CATEGORY, formatted from CONTROL. CATEGORY is a keyword naming the subsystem -- :canvas, :watchdog, :vulkan -- so a reader can tell at a glance which machine is talking.
(context)Make the swapchain agree with the window before a frame asks for an image. Returns NIL when this frame cannot be presented, which the caller skips.
(context)Acquire the next presentable image, rebuilding a stale swapchain once. Returns the frame slot, its index, and the image index, or NIL when the surface still cannot supply an image and this frame should be skipped.
((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 swapchain semaphore &key (timeout #xffffffffffffffff))(canvas)Predict when a frame acquired now will become visible on CANVAS.
(context queue image-index render-done predicted-presentation-time
target-nanoseconds)(queue swapchain image-index
&key (wait-semaphores #()) present-id present-stage time-domain-id
target-time target-time-domain-present-stage)(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.
(device descriptor)Asks the DEVICE for a handle to newly created instance of some object fulfilling the DESCRIPTOR.
(canvas timestamp function)(encoder texture new-layout)(queue command-buffers &key (wait-semaphores #())
(signal-semaphores #())
wait-for-completion)Submit one WebGPU-style batch and track it on the queue's frontier. WAIT-SEMAPHORES and SIGNAL-SEMAPHORES are LVK semaphore submit entries of the form (SEMAPHORE STAGES &optional VALUE). Every submission additionally signals the queue's timeline semaphore with a fresh submission index, which is returned. The…
(context function)Run one frame, then account for whatever the validation layer said. The end of the frame is the safe point: every Vulkan call it made has returned, so a complaint can become a condition without unwinding through a driver mid-call. GUARDING-SDL-CANVAS catches it, retains it with the backtrace the callback took while…
((canvas phase) &body body)Run BODY on CANVAS's loop in PHASE; an error is retained, not raised. Returns BODY's values, or NIL and the failure as a second value.
((&optional operation) &body body)Run BODY, then signal what the validation layer said while it ran. BODY leaving by its own error is left alone: that error is the news, and the layer's account of it is already in the log.
(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.
Vulkan presentation contexts and their SDL bridge.