luvcraft/portal.lisp
One texture and view per ring slot.
The slot the scene draws, and the slot it drew before that.
A child game's frames on a rectangle in this game's world.
One bind group per ring slot for frame, made on first use.
Draw portal's panel into the open scene pass. Overlays that own a portal
(the terminal wall) call this from their own drawing so their glass goes on
top; a free portal is an overlay itself and calls it from encode-luvcraft-overlay.
Publish which slot this frame samples, so the pump steers clear of it and of the one the previous frame may still be reading.
A ring slot no parent frame is showing, was showing a frame ago, or is about to show (the child's last completed slot); NIL when the ring is full, which means the parent has not yet caught up and the pump should wait.
The pump itself may be the one releasing us, through ON-STOP.
This process's texture over mirror's surface slot, for sampling.
The two vec4s of *PORTAL-UNIFORM-MEMBERS*: picture u0 v0 u1 v1, then the
moment the link opened and the picture's texel size.
The value the frame environment carries as elapsed time, for shaders.
Show a child game on a world panel. With no mirror, spawn a child of
width x height points; otherwise mirror is a negotiated, ready one (say, from
the portal server).
rectangle, when given, is called with the picture's aspect and returns the
panel's world origin, right edge, and up edge, and optionally a fourth value:
the picture's rectangle inside the panel as (u0 v0 u1 v1), the whole panel by
default. Without rectangle the picture is its own panel, screen-height cells
tall before the camera.
on-stop, when given, is called with the portal if its pump stops on its own,
which is to say the child went away. With attach-p the portal is added to
session's overlays and draws itself; an overlay that owns the portal passes
NIL and draws it through encode-luvcraft-portal-picture. Returns the portal.
Ask the child for frames at the portal's rate until the portal is released.
Stop portal and release it, whether or not it was one of session's overlays.
A child game's frames on a rectangle in this game's world.
How the children of a list are arranged.
(portal frame)An explicitly owned AVFrame.
Logical disjunction of tests and raw truth values.
(device descriptor)Asks the DEVICE for a handle to newly created instance of some object fulfilling the DESCRIPTOR.
(overlay session pass surface-texture)Encode OVERLAY into SESSION's open scene PASS for SURFACE-TEXTURE.
(portal session pass surface-texture)Draw PORTAL's panel into the open scene PASS. Overlays that own a portal (the terminal wall) call this from their own drawing so their glass goes on top; a free portal is an overlay itself and calls it from ENCODE-LUVCRAFT-OVERLAY.
Test whether two compatible scalars are equal.
(pass-encoder pipeline)(pass-encoder slot buffer &key (offset 0))(pass-encoder index bind-group)(pass-encoder vertex-count
&optional (instance-count 1) (first-vertex 0) (first-instance 0))(portal)A ring slot no parent frame is showing, was showing a frame ago, or is about to show (the child's last completed slot); NIL when the ring is full, which means the parent has not yet caught up and the pump should wait.
(mirror)The non-negative remainder of integer division.
(overlay)The live shader pipelines OVERLAY owns, so the session can count them among its own; none by default.
(overlay)Release resources owned by an object attached to luvcraft.
Logical conjunction of tests and raw truth values.
Logical negation of one test or raw truth value.
(mirror)(&body body)(name &body body)(handle)Logically invalidate HANDLE immediately. Native teardown may be deferred until submitted work which captured HANDLE has completed.
(artifact)(device mirror slot format)(mirror &optional slot)(device surface pixel-format usage &key label)(format descriptor)(device native-object owner descriptor)Wrap a platform texture and its retained OWNER in the HAL.
(picture-rect opened texel-u texel-v)The two vec4s of *PORTAL-UNIFORM-MEMBERS*: picture u0 v0 u1 v1, then the moment the link opened and the picture's texel size.
(session &key mirror
(width 640) (height 400)
(distance 6.0) (lift 1.5)
(screen-height 3.0)
rectangle on-stop
(attach-p t)
(frames-per-second 30))Show a child game on a world panel. With no MIRROR, spawn a child of WIDTH x HEIGHT points; otherwise MIRROR is a negotiated, ready one (say, from the portal server). RECTANGLE, when given, is called with the picture's aspect and returns the panel's world origin, right edge, and up edge, and optionally a fourth…
(&key (width 640) (height 400) (slots 3) executable)Spawn a child game in a hidden WIDTH x HEIGHT window (in points) over pipes, give it a ring of SLOTS surfaces the size of its pixel frame, and return the mirror once it is drawing. Its stderr lands in build/luvcraft-mirror.log.
Division of two represented quantities.
Multiplication and scalar scaling.
(camera distance lift width height)Return the lower-left corner and edge vectors of a screen facing CAMERA. The screen hangs DISTANCE ahead of the camera and LIFT above its eye, sized WIDTH by HEIGHT in cells, square to the camera's own basis.
(origin right-edge up-edge)(&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.
The linear HDR attachment format shared by every scene-stage pipeline.
(portal)(session overlay)Attach OVERLAY at SESSION's next native frame boundary and return it. ADD consumes a newly offered OVERLAY on both success and terminal rejection. Once SESSION begins stopping, the rejected overlay is released exactly once before APPLICATION-ATTACHMENT-CLOSED is signalled.
(mirror &optional slot)Ask the child for one frame into SLOT (default: the slot after the last completed one) and return the slot once its pixels are in the surface.
Subtraction or unary negation.
Convert one scalar float or unsigned value to a 32-bit float.
Test whether one compatible scalar is less than another.
(session portal)(session overlay &key (release-p t))Detach OVERLAY at a frame boundary and optionally release it there. The no-release path is intentionally preserved for FUSE-LUVCRAFT-OVERLAY: that path may run inside a frame whose command stream still borrows OVERLAY.
A portal: another luvcraft, running in another process, on a world screen.
The child draws into an IOSurface (see mirror.lisp); this side wraps the same surfaces as textures and draws one on a world panel through the video screen's quad vertex stage and a fragment stage of its own, the :PORTAL-SCREEN role in shaders.lisp, which sets the picture on a matte inside the panel and marks it as a transmission. A small thread keeps asking the child for frames, one ring slot at a time. The scene shows the slot the child finished last; the pump never asks the child to draw into that slot or the one shown before it, which a parent frame in flight may still be sampling. So the ring has three slots and nobody tears.