hal/metal/tests.lisp
This is the SDL event macOS emits for Command-Q, distinct from clicking one window's close button.
Logical invalidation is immediate. Native retirement follows the
shared-event completion frontier without blocking destroy.
The deterministic service pass retries only the published signal, never recommitting the native command buffers.
Sixty-four-bit words round-trip through the shared buffer.
A one-word offset is legal for a 64-bit array; a half word is not.
Storage buffers bind beside uniform buffers, by usage.
The parent creates a surface and hands out its integer ID; a "child" (here, the same process) looks the ID up, wraps it as a Metal texture, and clears it. The parent's original reference sees the pixels.
Test whether two compatible scalars are equal.
(format descriptor)(provider &optional descriptor)A provider for the system's preferred Metal device.
(device descriptor)Asks the DEVICE for a handle to newly created instance of some object fulfilling the DESCRIPTOR.
(queue destination data data-layout size)(handle)Logically invalidate HANDLE immediately. Native teardown may be deferred until submitted work which captured HANDLE has completed.
(device width height pixel-format usage &key (storage-mode +storage-mode-private+)
label)(object)(device native-object owner descriptor)Wrap a platform texture and its retained OWNER in the HAL.
Logical negation of one test or raw truth value.
(object)(encoder texture usage)Prepare TEXTURE for semantic USAGE in ENCODER's following commands. The backend owns any layout transition, hazard barrier, or validation needed to realize the usage. Application code does not dispatch on the backend. #T5MQO0
Multiplication and scalar scaling.
(pass-encoder)(encoder descriptor)(queue work)Schedule some command buffers on the QUEUE. Submission is asynchronous: returning does not mean the GPU has finished the work, only that the implementation retains everything the work depends on until it completes. Use SUBMITTED-WORK-DONE to wait.
(buffer &key offset size)Wait for BUFFER's device queue and copy mapped bytes back to the host.
Logical conjunction of tests and raw truth values.
Addition over compatible quantities.
(device)(device glyph-cache camera target-format string font-pathname
&key (distance 8.0) (lift 3.0) (world-units-per-em 0.55))Shape STRING once and create a depth-tested world text run on DEVICE. The run owns dense placement/model data and its live pipeline; GLYPH-CACHE owns font-and-glyph device resources reusable across runs. See #QW7P96.
Test whether one compatible scalar is less than another.
(name (selector result-type &key ownership class consumes-receiver)
&body arguments)(generic-function name specialized-lambda-list options &body body)Define a shader-producing method with ordinary DEFMETHOD identity. Calling the method reparses its small source form so changes to source-level abstractions participate in live rebuilding. Method replacement remains the role/stage identity watched by the MOP; abstraction revisions are tracked separately by live…
(role stage)Return the current durable shader specification for ROLE and STAGE.
(red &key invalid-p)(pass-encoder vertex-count
&optional (instance-count 1) (first-vertex 0) (first-instance 0))(pass-encoder index-buffer index-format index-count
&optional (instance-count 1) (first-index 0)
(base-vertex 0) (first-instance 0))Draw indexed instances from INDEX-BUFFER. INDEX-FORMAT is :UINT16 or :UINT32. The buffer is carried by the command so recorded work owns the complete indexed-draw dependency at one boundary.
(() &body body)((variable form) &body body)(() &body body)(layer width height)(layer)(presentation-api)Return the immutable SDL window flags required by PRESENTATION-API.
(provider)Return the SDL presentation policy required by GPU PROVIDER.
A native destination with a lifetime and frame clock.
(&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.
(canvas gpu-provider &optional configuration)Create a GPU presentation relationship between CANVAS and GPU-PROVIDER. When CONFIGURATION is omitted, return the context unconfigured.
Protocol class for objects receiving canvas events.
(canvas timestamp)Offer a native close to CANVAS and apply the default immediate policy. An application returning :DEFER-CANVAS-CLOSE has begun orderly teardown on another thread; its eventual CLOSE-CANVAS call ends the loop. This lets it release resources layered above the presentation context before SDL destroys that context. …
A device-compiled MSL library retaining its source document.
A linked Metal 4 render pipeline and its draw-time depth state.
A linked Metal 4 object/mesh pipeline with its dispatch geometry.
(pass-encoder pipeline)(pass-encoder x &optional (y 1) (z 1))(specification &optional (target *metal-4-target*))(&key role (stage :fragment) vertex-role label device layout vertex-module
vertex-buffers target-format target-blend primitive depth-stencil)Create and install a live mathematical render pipeline. VERTEX-MODULE is borrowed when VERTEX-ROLE is NIL and STAGE is not :VERTEX. Every module compiled from ROLE or VERTEX-ROLE is owned by the returned artifact and retired on replacement or explicit release.
(artifact)(artifact)(pass-encoder slot buffer &key (offset 0))(queue)Block until all work submitted to QUEUE so far has completed on the GPU.
A simple Org table without formulas.
(device max-buffer-count
&key (max-texture-count 0) (max-sampler-count 0) label
(attribute-strides-p nil))A general Metal 4 command encoder which owns recording memory until FINISH.
One finished, one-shot Metal 4 command buffer and its recorded dependencies.
(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
Whether retaining a queue custodian starts eventual background service.
(queue command-buffers)()Service one registry snapshot without holding the registry lock. Returns true when any backend reports progress. Errors are diagnosed once per consecutive failure and never prevent later custodians from being serviced.
(command-buffer)(encoder device command-buffer allocator)(function)Call FUNCTION where synchronous SDL canvas work can use the native main thread. On Darwin, a batch Lisp normally evaluates its toplevel form on the process main thread. Opening a canvas from that continuation would let Cocoa replace the continuation with its durable event loop. This boundary moves FUNCTION to a…
(&key
(title "luv little block world — click, look, walk")
;; NIL means "as much of this display as
;; comfortably fits"; a capture asks for the
;; exact frame it intends to write out. A
;; KMSDRM console can only present at a real
;; display mode, so the environment may pin
;; the canvas to the panel's native size.
(width (let ((value (uiop:getenv "LUVCRAFT_WIDTH")))
(and value (parse-integer value))))
(height (let ((value (uiop:getenv "LUVCRAFT_HEIGHT")))
(and value (parse-integer value))))
(frames-per-second 60)
(visible-p t)
(fullscreen-p nil)
(high-pixel-density-p t)
(world (make-empty-little-block-world))
(mesher (make-instance
'exposed-face-mesher))
(camera (make-instance 'fly-camera))
player
(selected-block *stone-block*)
(inventory (make-block-inventory))
quit-function
;; A hidden capture wanting animals in frame
;; hands in a population it has already
;; placed; the ordinary game grows its own
;; around the player as it plays.
(critters
(make-instance 'critter-population))
checkpoint-writer
(provider *gpu-provider*)
(sky-clock (make-instance 'sky-clock))
(sky-profile (make-default-sky-profile))
(shadow-diagnostic-p nil)
;; The world-text banner is a proof of the
;; Slug path, not scenery: a caller that
;; wants one asks for it, and the ordinary
;; game sky stays empty.
(world-text-string nil)
(world-text-font-pathname
(cl-dejavu:font-pathname "DejaVuSans.ttf"))
(world-text-distance 8.0)
(world-text-lift 3.0)
(world-text-units-per-em 0.55)
(video-pathname nil)
(video-distance 13.0)
(video-lift 4.5)
(video-height 5.0)
(residency-radius 6)
(publication-limit 2)
(load-schedule-limit 4)
(mesh-capture-limit 1))Open a little CPU-meshed block world. Click to capture the pointer, look with the mouse, walk with WASD, and jump with Space. Once captured, left click removes the block at the centre of view and right click places the selected block. Number keys select materials, middle click picks the targeted material, Shift…
(session &key minimum (timeout 10.0))Wait outside frame encoding for a useful initial set of chunk meshes. MINIMUM defaults to nine or the whole desired set when it is smaller. The visible startup path asks only for the nearest product before its first presentation; deterministic captures wait for the broader default set.
Subtraction or unary negation.
(session timestamp &optional sample)Division of two represented quantities.
Test whether one compatible scalar is at most another.
(session)Stop SESSION exactly once and publish its result to every caller. The sole owner attempts every named release step and closes the canvas and device last. Concurrent and later callers observe the same values or RELEASE-ERROR without releasing a native handle twice.
How the children of a list are arranged.
Base condition for errors exposed by the luv GPU API.
(width height &key (bytes-per-element 4)
(pixel-format +iosurface-pixel-format-bgra+)
(global-p t))Create a WIDTH x HEIGHT IOSurface and return its raw IOSurfaceRef. The caller owns one CF reference; release it with RELEASE-IOSURFACE. GLOBAL-P (deprecated by Apple, still honoured) is what lets another process find the surface by its integer ID with LOOKUP-IOSURFACE.
(device surface pixel-format usage &key label)(surface x y)(surface)
The external-owner retain was consumed, but this original native retain remains independently owned by the test.