animader-cli 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -402,6 +402,7 @@
402
402
  (member :name pngine-inputs :description "16 B: time, canvasWidth, canvasHeight, aspect (all f32). Runtime-provided; there is no authored document declaration to navigate to.")
403
403
  (member :name scene-time-inputs :description "12 B: time, canvasWidth, canvasHeight (all f32) — the first 12 bytes of pngine-inputs. True scene timing is not modelled yet. Runtime-provided; there is no authored document declaration to navigate to.")
404
404
  (member :name pngine-frame-inputs :description "20 B: the 16 B of pngine-inputs, then frameIndex (u32) — the executor's frame counter, which is also the ping-pong pool phase. For a jitter sequence (TAA) or any per-frame rotation. Runtime-provided; there is no authored document declaration to navigate to.")
405
+ (member :name control-inputs :description "4 B per declared `(control …)`, in declaration order; the frame's own `write-buffer` carries them, so a guard and a shader read one value.")
405
406
  (member :name pointer-inputs :description "48 B: x, y, clickX, clickY, dx, dy, buttons, pressure, modifiers, scrollX, scrollY, _pad (all f32). Runtime-provided; there is no authored document declaration to navigate to.")))
406
407
  ; The two ref arms are ONE cross-ref target group, never a union of two ref
407
408
  ; kinds: a union resolves first-match while the emitter looks the name up in
@@ -417,6 +418,28 @@
417
418
  :underlying union
418
419
  :union (union-shape :alternatives [builtin-data-source data-or-wasm-ref]))
419
420
 
421
+ ; ---- the guard subject: a builtin control or a declared one ----
422
+ ; A `(step-group :when …)` names ONE thing, and the two things it can name
423
+ ; live in different tables. The union of a member set and a reference kind is
424
+ ; `write-buffer-source`'s shape, not a second mechanism: the arms overlap on
425
+ ; the symbol shape, so a name neither accepts reports
426
+ ; `union_no_branch_matched` naming both explanations, and a name only the
427
+ ; reference arm could mean reports that arm's own `not_cross_ref`. Splitting
428
+ ; it into two keys would let an author write both spellings at once.
429
+ (value-kind :name builtin-control
430
+ :description "A control the engine provides every frame. Runtime-provided; there is no authored document declaration to navigate to."
431
+ :underlying symbol
432
+ :members (member-set
433
+ (member :name time :description "The built-in control the engine sets every frame: seconds since the frame program started. Needs no (control …) declaration; the compiler reserves the name, so a declared control cannot shadow it.")))
434
+ (value-kind :name control-ref
435
+ :description "Reference to a declared (control :name …)."
436
+ :underlying symbol
437
+ :cross-ref (cross-ref :target [pngine/control]))
438
+ (value-kind :name control-source
439
+ :description "The subject of a guard: the builtin control time, or a name declared by (control …)."
440
+ :underlying union
441
+ :union (union-shape :alternatives [builtin-control control-ref]))
442
+
420
443
  ; `byte-size` was `[byte-count data-ref]` — a union whose ref arm meant "size
421
444
  ; this buffer from that data without filling it". Every corpus use of it also
422
445
  ; carried `:mapped-at-creation <the same data>`, naming one thing twice, and
@@ -648,7 +671,8 @@
648
671
  (member :name rg16float :description "2×16-bit float; renderable, filterable.")
649
672
  (member :name r32float :description "1×32-bit float; renderable; filterable only with the float32-filterable feature.")
650
673
  (member :name r32uint :description "1×32-bit unsigned int; not filterable.")
651
- ; ---- base (no-feature) color / srgb / packed; compressed (BC/ETC2/EAC/ASTC) are deferred (need an upload path) ----
674
+ ; ---- base (no-feature) color / srgb / packed; all three compressed
675
+ ; families (BC, ETC2/EAC and ASTC) are exposed by plan 07 ----
652
676
  (member :name rgba8unorm-srgb :description "4×8-bit unorm, sRGB-encoded; renderable, filterable, blendable.")
653
677
  (member :name rgba8uint :description "4×8-bit unsigned int; renderable, not filterable.")
654
678
  (member :name rgba8sint :description "4×8-bit signed int; renderable, not filterable.")
@@ -683,6 +707,69 @@
683
707
  (member :name rgba16unorm :description "4×16-bit unorm; needs texture-formats-tier1. Renderable + blendable when enabled.")
684
708
  (member :name rgba16snorm :description "4×16-bit signed norm; needs texture-formats-tier1. Renderable + blendable when enabled.")
685
709
  (member :name depth32float-stencil8 :description "32-bit float depth plus 8-bit stencil; needs the depth32float-stencil8 device feature.")
710
+ ; ---- BC compressed (plan 07): 4×4 texel blocks, 8 or 16 bytes per
711
+ ; block, copy-only. Creation needs texture-compression-bc; 3D additionally
712
+ ; needs texture-compression-bc-sliced-3d. Descriptor width/height and copy
713
+ ; origin/extent are whole blocks. ----
714
+ (member :name bc1-rgba-unorm :description "BC1 4×4 RGB(A) unorm; 8 bytes per block. Needs texture-compression-bc.")
715
+ (member :name bc1-rgba-unorm-srgb :description "BC1 4×4 RGB(A), sRGB-encoded; 8 bytes per block. Needs texture-compression-bc.")
716
+ (member :name bc2-rgba-unorm :description "BC2 4×4 RGB(A) with explicit alpha; 16 bytes per block. Needs texture-compression-bc.")
717
+ (member :name bc2-rgba-unorm-srgb :description "BC2 4×4 RGB(A) with explicit alpha, sRGB-encoded; 16 bytes per block. Needs texture-compression-bc.")
718
+ (member :name bc3-rgba-unorm :description "BC3 4×4 interpolated alpha; 16 bytes per block. Needs texture-compression-bc.")
719
+ (member :name bc3-rgba-unorm-srgb :description "BC3 4×4 interpolated alpha, sRGB-encoded; 16 bytes per block. Needs texture-compression-bc.")
720
+ (member :name bc4-r-unorm :description "BC4 single-channel 4×4 unorm; 8 bytes per block. Needs texture-compression-bc.")
721
+ (member :name bc4-r-snorm :description "BC4 single-channel 4×4 snorm; 8 bytes per block. Needs texture-compression-bc.")
722
+ (member :name bc5-rg-unorm :description "BC5 two-channel 4×4 unorm; 16 bytes per block. Needs texture-compression-bc.")
723
+ (member :name bc5-rg-snorm :description "BC5 two-channel 4×4 snorm; 16 bytes per block. Needs texture-compression-bc.")
724
+ (member :name bc6h-rgb-ufloat :description "BC6H unsigned HDR RGB 4×4; 16 bytes per block. Needs texture-compression-bc.")
725
+ (member :name bc6h-rgb-float :description "BC6H signed HDR RGB 4×4; 16 bytes per block. Needs texture-compression-bc.")
726
+ (member :name bc7-rgba-unorm :description "BC7 high-quality RGBA 4×4 unorm; 16 bytes per block. Needs texture-compression-bc.")
727
+ (member :name bc7-rgba-unorm-srgb :description "BC7 high-quality RGBA 4×4, sRGB-encoded; 16 bytes per block. Needs texture-compression-bc.")
728
+ ; ---- ETC2/EAC compressed (plan 07 tranche B): 4×4 texel blocks, 8 or
729
+ ; 16 bytes per block, copy-only. Creation needs texture-compression-etc2;
730
+ ; the CRD has no ETC2/EAC sliced-3d feature, so 3D is refused. ----
731
+ (member :name etc2-rgb8unorm :description "ETC2 RGB 4×4 unorm; 8 bytes per block. Needs texture-compression-etc2.")
732
+ (member :name etc2-rgb8unorm-srgb :description "ETC2 RGB 4×4, sRGB-encoded; 8 bytes per block. Needs texture-compression-etc2.")
733
+ (member :name etc2-rgb8a1unorm :description "ETC2 RGB with 1-bit alpha, 4×4 unorm; 8 bytes per block. Needs texture-compression-etc2.")
734
+ (member :name etc2-rgb8a1unorm-srgb :description "ETC2 RGB with 1-bit alpha, 4×4, sRGB-encoded; 8 bytes per block. Needs texture-compression-etc2.")
735
+ (member :name etc2-rgba8unorm :description "ETC2 RGBA 4×4 unorm; 16 bytes per block. Needs texture-compression-etc2.")
736
+ (member :name etc2-rgba8unorm-srgb :description "ETC2 RGBA 4×4, sRGB-encoded; 16 bytes per block. Needs texture-compression-etc2.")
737
+ (member :name eac-r11unorm :description "EAC single-channel 4×4 unorm; 8 bytes per block. Needs texture-compression-etc2.")
738
+ (member :name eac-r11snorm :description "EAC single-channel 4×4 snorm; 8 bytes per block. Needs texture-compression-etc2.")
739
+ (member :name eac-rg11unorm :description "EAC two-channel 4×4 unorm; 16 bytes per block. Needs texture-compression-etc2.")
740
+ (member :name eac-rg11snorm :description "EAC two-channel 4×4 snorm; 16 bytes per block. Needs texture-compression-etc2.")
741
+ ; ---- ASTC compressed (plan 07 tranche C): the block dimensions are the
742
+ ; ones in the name (4×4 through 12×12), the block is always 16 bytes,
743
+ ; copy-only. Creation needs texture-compression-astc; 3D additionally
744
+ ; needs texture-compression-astc-sliced-3d. ----
745
+ (member :name astc-4x4-unorm :description "ASTC 4×4 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
746
+ (member :name astc-4x4-unorm-srgb :description "ASTC 4×4 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
747
+ (member :name astc-5x4-unorm :description "ASTC 5×4 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
748
+ (member :name astc-5x4-unorm-srgb :description "ASTC 5×4 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
749
+ (member :name astc-5x5-unorm :description "ASTC 5×5 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
750
+ (member :name astc-5x5-unorm-srgb :description "ASTC 5×5 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
751
+ (member :name astc-6x5-unorm :description "ASTC 6×5 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
752
+ (member :name astc-6x5-unorm-srgb :description "ASTC 6×5 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
753
+ (member :name astc-6x6-unorm :description "ASTC 6×6 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
754
+ (member :name astc-6x6-unorm-srgb :description "ASTC 6×6 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
755
+ (member :name astc-8x5-unorm :description "ASTC 8×5 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
756
+ (member :name astc-8x5-unorm-srgb :description "ASTC 8×5 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
757
+ (member :name astc-8x6-unorm :description "ASTC 8×6 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
758
+ (member :name astc-8x6-unorm-srgb :description "ASTC 8×6 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
759
+ (member :name astc-8x8-unorm :description "ASTC 8×8 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
760
+ (member :name astc-8x8-unorm-srgb :description "ASTC 8×8 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
761
+ (member :name astc-10x5-unorm :description "ASTC 10×5 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
762
+ (member :name astc-10x5-unorm-srgb :description "ASTC 10×5 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
763
+ (member :name astc-10x6-unorm :description "ASTC 10×6 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
764
+ (member :name astc-10x6-unorm-srgb :description "ASTC 10×6 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
765
+ (member :name astc-10x8-unorm :description "ASTC 10×8 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
766
+ (member :name astc-10x8-unorm-srgb :description "ASTC 10×8 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
767
+ (member :name astc-10x10-unorm :description "ASTC 10×10 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
768
+ (member :name astc-10x10-unorm-srgb :description "ASTC 10×10 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
769
+ (member :name astc-12x10-unorm :description "ASTC 12×10 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
770
+ (member :name astc-12x10-unorm-srgb :description "ASTC 12×10 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
771
+ (member :name astc-12x12-unorm :description "ASTC 12×12 RGBA unorm; 16 bytes per block. Needs texture-compression-astc.")
772
+ (member :name astc-12x12-unorm-srgb :description "ASTC 12×12 RGBA, sRGB-encoded; 16 bytes per block. Needs texture-compression-astc.")
686
773
  (member :name preferred-canvas-format :description "Resolved at runtime to the platform's canvas format. Runtime-provided; there is no authored document declaration to navigate to.")))
687
774
  (value-kind :name texture-usage
688
775
  :description "GPUTextureUsage flag — what the texture may be used for."
@@ -720,6 +807,19 @@
720
807
  :description "Texture size as [width], [width height], or [width height depth-or-array-layers]; the missing dimensions default to 1."
721
808
  :underlying vector
722
809
  :vector (vector-shape :element extent :min-len 1 :max-len 3))
810
+ ; GPUExtent3D as a COPY extent (writeTexture's `size` argument): [w], [w h]
811
+ ; or [w h d]. Same element type and length as extent3, deliberately its own
812
+ ; kind: an allocation dimension is `extent` (>= 1), while a copy dimension
813
+ ; can also be a bounded expression / define-ref through `u32`; and a copy
814
+ ; size is judged against the mip's physical extent by plan 01, not by a
815
+ ; texture's allocation rule. Its absent dimensions mean height/depth = 1
816
+ ; ONLY when the key is present. An absent KEY is a different thing: the
817
+ ; remaining physical extent at the origin, a recorded PNGine deviation from
818
+ ; the IDL's required `size` argument (see the write-texture form).
819
+ (value-kind :name copy-extent
820
+ :description "Copy size [width], [width height], or [width height depth-or-array-layers] (1–3 non-negative u32s). Absent dimensions default to 1 only when the key is present; an omitted :size means the remaining physical extent at the destination origin."
821
+ :underlying vector
822
+ :vector (vector-shape :element u32 :min-len 1 :max-len 3))
723
823
  ; GPUTextureDescriptor.size is ONE required member, so it is one required key
724
824
  ; over the three things a pngine texture may be sized by. Three
725
825
  ; different underlyings — vector, symbol member, cross-ref — so the union
@@ -828,11 +928,29 @@
828
928
  (head :name stencil-back :max 1)))
829
929
 
830
930
  ; ---- Phase 2d: MRT / MSAA / advanced render state ----
831
- ; A render-pass attachment view: the canvas (context-current-texture) or a
832
- ; declared (texture …) — e.g. an MSAA color target, or a resolve target.
931
+ ; A render-pass attachment view: the canvas (context-current-texture), a
932
+ ; declared (texture …), or a declared (texture-view …) selecting one mip and
933
+ ; one array layer. The union is the authoring surface of plan 09: a bare
934
+ ; texture still means the texture's default view (legacy bytes unchanged),
935
+ ; an explicit view names exactly the subresource the pass renders into.
936
+ ;
937
+ ; Two cross-ref arms first-match is safe here for the reason the one-namespace
938
+ ; rule exists: `checkNameNamespace` refuses a name declared by two forms, so
939
+ ; a symbol cannot be both a texture and a texture-view in one document. The
940
+ ; emitter resolves through its separate id tables and the union only has to
941
+ ; admit the spellings; should a collision ever survive schema validation, it
942
+ ; is refused before any phase, never silently resolved one way here and the
943
+ ; other downstream.
833
944
  (value-kind :name attachment-view
834
945
  :underlying union
835
- :union (union-shape :alternatives [view-source texture-ref]))
946
+ :union (union-shape :alternatives [view-source texture-ref texture-view-ref]))
947
+ ; The DEPTH authoring form's own union: texture or texture-view, never the
948
+ ; canvas. A depth attachment has no canvas spelling (the runtime's depth view
949
+ ; is the document's to declare), and the plan refuses it deliberately; the
950
+ ; colour/resolve `attachment-view` union keeps its view-source arm.
951
+ (value-kind :name depth-attachment-view
952
+ :underlying union
953
+ :union (union-shape :alternatives [texture-ref texture-view-ref]))
836
954
  (value-kind :name blend-factor
837
955
  :description "GPUBlendFactor — multiplier applied to source / destination color in the blend equation."
838
956
  :underlying symbol
@@ -989,9 +1107,16 @@
989
1107
 
990
1108
  ; ---- strings ----
991
1109
  (value-kind :name file-path
992
- :description "File path relative to the source document (non-empty, no newlines)."
1110
+ :description "File path relative to the compile root (non-empty, no newlines)."
993
1111
  :underlying string
994
1112
  :string-bounds (string-bounds :format path))
1113
+ ; A package SPECIFIER, not a path: `<name>` or `@<scope>/<name>`, optionally
1114
+ ; followed by `/subpath`. The grammar is enforced by the resolver before any
1115
+ ; candidate path is constructed; this kind exists so the spelling is a named
1116
+ ; authoring concept rather than an unconstrained string.
1117
+ (value-kind :name package-specifier
1118
+ :description "A plain-WGSL package specifier: `name` or `@scope/name`, optionally `/subpath`. No URL, version suffix or `..`."
1119
+ :underlying string)
995
1120
  ; The one string kind that carries CONTENT rather than a name or a path.
996
1121
  ; SJON's `:format` set is email|uri|path|uuid|semver, so there is no schema
997
1122
  ; check for base64 — the emitter decodes and reports `data_base64_invalid`
@@ -1071,16 +1196,33 @@
1071
1196
  ; `duplicate_cross_ref_target` at the declaration, so a step can never be
1072
1197
  ; ambiguous. A named graph is in the list because the frame names it in the
1073
1198
  ; AUTHORED aggregate, where it is a `(pass-graph …)` / `(draw-graph …)` and
1074
- ; not yet the `(step-group …)` its hook emits.
1199
+ ; not yet the `(step-group …)` its hook emits; a `(select …)` and a
1200
+ ; `(mip-chain …)` join for the same reason (2089e59's fix, applied to the
1201
+ ; fourth and fifth members).
1075
1202
  ; (It used to be a union tried in order, while the emitter kept
1076
1203
  ; one table for both pass kinds — a collision silently dropped the render pass.)
1077
1204
  (value-kind :name frame-step
1078
- :description "One frame step: a render-pass, compute-pass or queue name, a named pass-graph/draw-graph (a step group), or a step-group name (one namespace across the forms)."
1205
+ :description "One frame step: a render-pass, compute-pass or queue name, a named pass-graph/draw-graph/mip-chain (a step group), a step-group name, or a select name (one namespace across the forms)."
1079
1206
  :underlying symbol
1080
- :cross-ref (cross-ref :target [render-pass compute-pass queue step-group pass-graph draw-graph]))
1207
+ :cross-ref (cross-ref :target [render-pass compute-pass queue step-group pass-graph draw-graph select mip-chain]))
1081
1208
  (value-kind :name frame-step-list
1082
1209
  :description "Passes and queues run every frame, in order."
1083
1210
  :underlying vector :vector (vector-shape :element frame-step :max-len 2048))
1211
+ ; One frame step, run ONCE per loaded payload (VGPU-09). Same namespace and
1212
+ ; same targets as `frame-step`, and the same spelling — a one-time step is
1213
+ ; written by naming the ordinary form, not by a second declaration of it.
1214
+ ; What is refused on this slot is lifecycle, not syntax: the canvas (a
1215
+ ; per-frame view), a guarded group/select (zero or many runs), a step also
1216
+ ; reached by :before/:perform, a group cycle, a queue whose generated
1217
+ ; one-shot pass name is taken, and an upload whose asset does not resolve.
1218
+ ; See `docs/sjon-reference.md`, "What `:init` means, exactly".
1219
+ (value-kind :name init-step
1220
+ :description "One one-time step: a render-pass, compute-pass or queue name, a named pass-graph/draw-graph/mip-chain (a step group), a step-group name, or a select name (one namespace across the forms)."
1221
+ :underlying symbol
1222
+ :cross-ref (cross-ref :target [render-pass compute-pass queue step-group pass-graph draw-graph select mip-chain]))
1223
+ (value-kind :name init-step-list
1224
+ :description "One-time steps: run once per loaded payload, in order, before the recurring work. A queue write is lowered to a generated one-shot compute pass; a render/compute pass runs through exec_pass_once."
1225
+ :underlying vector :vector (vector-shape :element init-step :max-len 2048))
1084
1226
  ; `:min-len 1` because count 0 is not "no color targets" on the wire — it is
1085
1227
  ; the frozen legacy sentinel meaning "substitute the preferred canvas format"
1086
1228
  ; (docs/abi.md §6.5), which is exactly the fabrication 3.0.0 removes.
@@ -1274,11 +1416,12 @@
1274
1416
  (value-kind :name in-stage-section :underlying form :heads (head-set
1275
1417
  (head :name constant)))
1276
1418
  (value-kind :name bind-entry-item :underlying form :heads (head-set :names [entry]))
1277
- (value-kind :name queue-action :underlying form :heads (head-set :names [write-buffer copy-texture-to-texture copy-external-image-to-texture resolve-query-set copy-buffer-to-buffer]))
1278
- ; Both texture copies take exactly one endpoint of each kind. The heads
1279
- ; are shared but the FORMS are not — each copy declares its own slot-local
1419
+ (value-kind :name queue-action :underlying form :heads (head-set :names [write-buffer write-texture copy-buffer-to-texture copy-texture-to-buffer copy-texture-to-texture copy-external-image-to-texture resolve-query-set copy-buffer-to-buffer]))
1420
+ ; Every copy takes exactly one endpoint of each kind. The heads are shared
1421
+ ; but the FORMS are not — each copy declares its own slot-local
1280
1422
  ; `source`/`destination`, resolved local-first, so `(source :image …)` under
1281
- ; one is not `(source :texture …)` under the other.
1423
+ ; one is not `(source :texture …)` under the other, and a buffer endpoint's
1424
+ ; members are not a texture endpoint's.
1282
1425
  (value-kind :name copy-endpoints-section :underlying form :heads (head-set
1283
1426
  (head :name source :min 1 :max 1)
1284
1427
  (head :name destination :min 1 :max 1)))
@@ -1458,20 +1601,23 @@
1458
1601
  ; reported against the fragment rather than as an unresolved identifier
1459
1602
  ; somewhere in an assembled module the author never wrote.
1460
1603
  (form :name wgsl
1461
- :description "A named WGSL fragment, from inline :code or a :file, assembled into the modules that :imports it. Not a GPU object: never validated, minified or shipped alone."
1604
+ :description "A named WGSL fragment, from inline :code, a :file, or an installed package's export, assembled into the modules that :imports it. Not a GPU object: never validated, minified or shipped alone."
1462
1605
  (key :name name :type symbol
1463
1606
  :description "Fragment name referenced by another fragment's, a (shader-module …)'s or a (pass …)'s :imports.")
1464
1607
  (key :name code :type string :optional true
1465
- :description "WGSL source text, kept verbatim. Exactly one of :code or :file.")
1608
+ :description "WGSL source text, kept verbatim. Exactly one of :code, :file or :package.")
1466
1609
  (key :name file :type file-path :optional true
1467
- :description "Path to a .wgsl file, relative to the source document. Exactly one of :code or :file.")
1610
+ :description "Path to a .wgsl file, relative to the compile root. Exactly one of :code, :file or :package.")
1611
+ (key :name package :type package-specifier :optional true
1612
+ :description "An installed plain-WGSL package export, e.g. \"@example/noise\" or \"@example/noise/math\". Exactly one of :code, :file or :package; a package entry owns its own imports and holes, so :imports and :requires cannot be combined with it.")
1468
1613
  (key :name imports :type wgsl-ref-list :optional true
1469
1614
  :description "Fragments this one is assembled behind, in dependency order. The graph must be acyclic and each fragment appears once per assembled module.")
1470
1615
  (key :name requires :type wgsl-name-list :optional true
1471
1616
  :description "WGSL identifiers this fragment uses but does not declare. Every one must be declared by the module that imports it (or by a sibling fragment) — reached or not, since validation runs before dead-code elimination. `validate` checks the list against the fragment's own text and warns both ways: a listed name never used as a hole, a hole never listed.")
1472
1617
  (exclusive-group :cardinality exactly-one
1473
1618
  (alt :keys [code])
1474
- (alt :keys [file])))
1619
+ (alt :keys [file])
1620
+ (alt :keys [package])))
1475
1621
 
1476
1622
  (form :name shader-module
1477
1623
  :description "A named WGSL module. The source is opaque text to SJON. With :imports it is the ROOT of an assembled module: its fragments' text in dependency order, then its own."
@@ -1480,7 +1626,7 @@
1480
1626
  (key :name code :type string :optional true
1481
1627
  :description "WGSL source text, kept verbatim (a triple-quoted string's indentation is part of the shader). Exactly one of :code or :file.")
1482
1628
  (key :name file :type file-path :optional true
1483
- :description "Path to a .wgsl file, relative to the source document. Exactly one of :code or :file.")
1629
+ :description "Path to a .wgsl file, relative to the compile root. Exactly one of :code or :file.")
1484
1630
  (key :name imports :type wgsl-ref-list :optional true
1485
1631
  :description "Fragments assembled ahead of this module's own text. Minification and dead-code elimination run once over the whole assembled module, so names stay consistent across fragment boundaries and unreached fragment code is dropped.")
1486
1632
  (exclusive-group :cardinality exactly-one
@@ -1557,7 +1703,7 @@
1557
1703
  (form :name bytes
1558
1704
  :description "Verbatim bytes as a (data …) source: a sidecar file read at compile time, or inline base64. Stored with no MIME prefix and sized like an inline array, so a buffer's :data can size and fill from it — which (data … :file …) deliberately cannot."
1559
1705
  (key :name file :type file-path :optional true
1560
- :description "Binary file path relative to the source document, embedded byte-for-byte. Exactly one of :file or :base64.")
1706
+ :description "Binary file path relative to the compile root, embedded byte-for-byte. Exactly one of :file or :base64.")
1561
1707
  (key :name base64 :type base64-text :optional true
1562
1708
  :description "The bytes inline, base64-encoded, for a document that carries its own data. Exactly one of :file or :base64.")
1563
1709
  (exclusive-group :cardinality exactly-one
@@ -1655,9 +1801,10 @@
1655
1801
  :description "Number of queries in the set, 1 to 4096 (the createQuerySet bound)."))
1656
1802
 
1657
1803
  (form :name queue
1658
- :description "Queue actions (write-buffer, copy-buffer-to-buffer, copy-texture-to-texture,
1659
- copy-external-image-to-texture, resolve-query-set) run in order by the
1660
- frames that reference it."
1804
+ :description "Queue actions (write-buffer, write-texture, copy-buffer-to-texture,
1805
+ copy-texture-to-buffer, copy-buffer-to-buffer, copy-texture-to-texture,
1806
+ copy-external-image-to-texture, resolve-query-set)
1807
+ run in order by the frames that reference it."
1661
1808
  :positional queue-action
1662
1809
  (key :name name :type symbol))
1663
1810
 
@@ -1672,33 +1819,152 @@
1672
1819
  ; document said twice what the widened union now says once, and the
1673
1820
  ; exclusive-group existed to stop an author saying both.
1674
1821
  (key :name data :type write-buffer-source
1675
- :description "Source: a (data …) ref, a (wasm-call …) whose result is written each frame, or a runtime builtin — pngine-inputs (16B time/width/height/aspect), scene-time-inputs (12B), pngine-frame-inputs (20B, + frameIndex), pointer-inputs (48B)."))
1822
+ :description "Source: a (data …) ref, a (wasm-call …) whose result is written each frame, or a runtime builtin — pngine-inputs (16B time/width/height/aspect), scene-time-inputs (12B), pngine-frame-inputs (20B, + frameIndex), pointer-inputs (48B), control-inputs (4B per declared (control …) in declaration order)."))
1823
+
1824
+ ; The flat form of GPUQueue.writeTexture. Nine keys mirror the two texel-copy
1825
+ ; dictionaries plus the method's own `data` and `size` arguments:
1826
+ ; GPUTexelCopyTextureInfo (texture, mipLevel, origin, aspect) and
1827
+ ; GPUTexelCopyBufferLayout (offset, bytesPerRow, rowsPerImage). PNGine spells
1828
+ ; every one as a :key, so the mapping table's only sentinels are `data` and
1829
+ ; `size`, the two arguments that are NOT members of either dictionary.
1830
+ ;
1831
+ ; Presence is the wire's: `:bytes-per-row` and `:rows-per-image` are optional
1832
+ ; because the IDL gives those members NO default, and their absence survives
1833
+ ; into the PNGB presence flags (explicit zero is not omission). `:origin`
1834
+ ; carries no `:default` token because origin3 is a vector; each component
1835
+ ; defaults to 0, which is what the IDL's `{}` means.
1836
+ ;
1837
+ ; `:size` is the ONE recorded deviation: the IDL REQUIRES the size argument,
1838
+ ; but an omitted `:size` here means the remaining physical extent at the
1839
+ ; origin (plan 01's calculateWrite), so an author can update a subregion
1840
+ ; without restating the texture size. An explicit `:size` keeps its absent
1841
+ ; dimensions at height/depth 1 only because the key is present.
1842
+ (form :name write-texture
1843
+ :description "Queue op: upload raw texels into a texture (GPUQueue.writeTexture). :texture and :data are required; :offset, :origin, :mip-level and :aspect carry WebGPU's defaults. An omitted :size means the remaining physical extent at :origin — a recorded PNGine deviation from the IDL's required size argument. Omitted :bytes-per-row / :rows-per-image stay absent on the wire; explicit zero is not omission."
1844
+ (key :name texture :type texture-ref
1845
+ :description "Destination texture (needs copy-dst usage, one sample, and a non-pooled id).")
1846
+ (key :name data :type data-ref
1847
+ :description "Raw source bytes: a (data …) entry with a byte length. Image-MIME-wrapped data is refused; the bytes are never base64 on the wire.")
1848
+ (key :name offset :type byte-count :default 0
1849
+ :description "Byte offset into :data (GPUTexelCopyBufferLayout.offset, default 0). Unaligned values are legal: writeTexture has no 256-byte rule.")
1850
+ (key :name bytes-per-row :type byte-count :optional true
1851
+ :description "GPUTexelCopyBufferLayout.bytesPerRow — bytes per texel-block row. Optional because the IDL gives it no default; absent stays absent (explicit 0 is not omission).")
1852
+ (key :name rows-per-image :type byte-count :optional true
1853
+ :description "GPUTexelCopyBufferLayout.rowsPerImage — rows per texel image (array layer / depth slice). Optional because the IDL gives it no default; absent stays absent (explicit 0 is not omission).")
1854
+ (key :name origin :type origin3 :optional true
1855
+ :description "Destination origin [x y z] in texels (GPUTexelCopyTextureInfo.origin, IDL default {} = all zero); components default to 0. z selects the array layer or depth slice.")
1856
+ (key :name mip-level :type subresource-index :default 0
1857
+ :description "Destination mip level (GPUTexelCopyTextureInfo.mipLevel, default 0); a u32 varint, no u8 ceiling.")
1858
+ (key :name aspect :type texture-aspect :default all
1859
+ :description "Destination aspect (GPUTexelCopyTextureInfo.aspect, default all). Depth/stencil formats require a single aspect and a full-subresource write.")
1860
+ (key :name size :type copy-extent :optional true
1861
+ :description "GPUExtent3D size to write (1–3 u32s). Optional only through the recorded deviation: absent means the remaining physical extent at :origin, whereas the IDL requires the size argument. Present, absent dimensions default to 1."))
1862
+
1863
+ ; Buffer↔texture copies reuse plan 01's descriptor/layout model with an
1864
+ ; explicit aligned-buffer policy (plan 05, D16). Both endpoints are separate
1865
+ ; IDL dictionaries, so both are slot-local child forms: the buffer side is
1866
+ ; GPUTexelCopyBufferInfo (its `buffer` plus the inherited
1867
+ ; GPUTexelCopyBufferLayout members) and the texture side is
1868
+ ; GPUTexelCopyTextureInfo. `:size` is each method's own `copySize` argument,
1869
+ ; not a member of either dictionary.
1870
+ ;
1871
+ ; Compared with writeTexture, the buffer copy adds exactly two rules, both
1872
+ ; only when the texture endpoint is present: a supplied `:bytes-per-row` is a
1873
+ ; multiple of 256, and `:offset` is a multiple of the texel block copy
1874
+ ; footprint — except a depth-stencil texture endpoint (source or
1875
+ ; destination) uses 4. `writeTexture` has neither rule.
1876
+ (form :name copy-buffer-to-texture
1877
+ :description "Queue op: copy from a buffer into a texture subresource (GPUCommandEncoder.copyBufferToTexture). The source is a GPUTexelCopyBufferInfo and the destination a GPUTexelCopyTextureInfo; :size is the method's copySize. A supplied source :bytes-per-row must be a multiple of 256, and :offset a multiple of the texel block copy footprint (4 for a depth-stencil destination)."
1878
+ :positional copy-endpoints-section
1879
+ (key :name size :type copy-extent :optional true
1880
+ :description "GPUCommandEncoder.copyBufferToTexture's copySize (1–3 u32s). Optional only through the recorded deviation: absent means the remaining physical extent at the destination origin.")
1881
+ (form :name source
1882
+ :description "Buffer source (GPUTexelCopyBufferInfo with its GPUTexelCopyBufferLayout)."
1883
+ (key :name buffer :type buffer-ref
1884
+ :description "Source buffer name; needs copy-src usage.")
1885
+ (key :name offset :type byte-count :default 0
1886
+ :description "Byte offset into the source buffer (GPUTexelCopyBufferLayout.offset, default 0). Must be a multiple of the texel block copy footprint, or 4 for a depth-stencil endpoint.")
1887
+ (key :name bytes-per-row :type byte-count :optional true
1888
+ :description "GPUTexelCopyBufferLayout.bytesPerRow — bytes between texel-block rows. Optional in the IDL (no default); a supplied value must be a multiple of 256, and WebGPU requires it when the copy spans more than one block row or image.")
1889
+ (key :name rows-per-image :type byte-count :optional true
1890
+ :description "GPUTexelCopyBufferLayout.rowsPerImage — rows per texel image. Optional in the IDL (no default); WebGPU requires it when the copy spans more than one image."))
1891
+ (form :name destination
1892
+ :description "Texture destination (GPUTexelCopyTextureInfo)."
1893
+ (key :name texture :type texture-ref
1894
+ :description "Destination texture name; needs copy-dst usage, one sample, and a non-pooled id.")
1895
+ (key :name mip-level :type subresource-index :default 0
1896
+ :description "Destination mip level (GPUTexelCopyTextureInfo.mipLevel, default 0).")
1897
+ (key :name origin :type origin3 :optional true
1898
+ :description "Destination origin [x y z] in texels (GPUTexelCopyTextureInfo.origin, IDL default {} = all zero); z selects the array layer or depth slice.")
1899
+ (key :name aspect :type texture-aspect :default all
1900
+ :description "Destination aspect (GPUTexelCopyTextureInfo.aspect, default all). Depth/stencil formats require a single aspect and a full-subresource copy.")))
1901
+
1902
+ (form :name copy-texture-to-buffer
1903
+ :description "Queue op: copy a texture subresource into a buffer (GPUCommandEncoder.copyTextureToBuffer), the byte-preserving readback path. The source is a GPUTexelCopyTextureInfo and the destination a GPUTexelCopyBufferInfo; :size is the method's copySize. A supplied destination :bytes-per-row must be a multiple of 256, and :offset a multiple of the texel block copy footprint (4 for a depth-stencil source)."
1904
+ :positional copy-endpoints-section
1905
+ (key :name size :type copy-extent :optional true
1906
+ :description "GPUCommandEncoder.copyTextureToBuffer's copySize (1–3 u32s). Optional only through the recorded deviation: absent means the remaining physical extent at the source origin.")
1907
+ (form :name source
1908
+ :description "Texture source (GPUTexelCopyTextureInfo)."
1909
+ (key :name texture :type texture-ref
1910
+ :description "Source texture name; needs copy-src usage.")
1911
+ (key :name mip-level :type subresource-index :default 0
1912
+ :description "Source mip level (GPUTexelCopyTextureInfo.mipLevel, default 0).")
1913
+ (key :name origin :type origin3 :optional true
1914
+ :description "Source origin [x y z] in texels (GPUTexelCopyTextureInfo.origin, IDL default {} = all zero); z selects the array layer or depth slice.")
1915
+ (key :name aspect :type texture-aspect :default all
1916
+ :description "Source aspect (GPUTexelCopyTextureInfo.aspect, default all). Depth/stencil formats require a single aspect and a full-subresource copy."))
1917
+ (form :name destination
1918
+ :description "Buffer destination (GPUTexelCopyBufferInfo with its GPUTexelCopyBufferLayout)."
1919
+ (key :name buffer :type buffer-ref
1920
+ :description "Destination buffer name; needs copy-dst usage, and map-read when the bytes are read back to the host.")
1921
+ (key :name offset :type byte-count :default 0
1922
+ :description "Byte offset into the destination buffer (GPUTexelCopyBufferLayout.offset, default 0). Must be a multiple of the texel block copy footprint, or 4 for a depth-stencil endpoint.")
1923
+ (key :name bytes-per-row :type byte-count :optional true
1924
+ :description "GPUTexelCopyBufferLayout.bytesPerRow — bytes between texel-block rows. Optional in the IDL (no default); a supplied value must be a multiple of 256, and WebGPU requires it when the copy spans more than one block row or image.")
1925
+ (key :name rows-per-image :type byte-count :optional true
1926
+ :description "GPUTexelCopyBufferLayout.rowsPerImage — rows per texel image. Optional in the IDL (no default); WebGPU requires it when the copy spans more than one image.")))
1676
1927
 
1677
1928
  ; Both ends of a copy are dictionaries in the IDL
1678
1929
  ; (GPUTexelCopyTextureInfo / GPUCopyExternalImageSourceInfo), so they are
1679
1930
  ; child forms, and their members are that form's keys: `:mip-level` and
1680
- ; `:origin` describe the DESTINATION subresource, not the copy. The flat
1931
+ ; `:origin` describe the endpoint's subresource, not the copy. The flat
1681
1932
  ; `:source X :texture Y` spelling is retired rather than kept as a second one.
1682
1933
  ; Their heads are SLOT-LOCAL: `source` carries a texture under one copy
1683
1934
  ; and an image under the other, and neither is a global form.
1684
1935
  ;
1685
- ; There is no `:size`: pngine copies the whole source, which is what both
1686
- ; runtimes do today. A key the bytecode cannot carry would validate and be
1687
- ; dropped in silence — the texture→texture opcode encodes the two texture
1688
- ; ids and nothing else (`wire_schema` L_2V); the external-image opcode encodes
1689
- ; the bitmap id, the texture id and the destination mip level + origin
1690
- ; (L_COPY_EXT_IMG). Neither carries a size. It arrives when the opcode does.
1936
+ ; COMPATIBILITY RULE (plan 06): a `(copy-texture-to-texture …)` that authors
1937
+ ; none of `:mip-level`, `:origin`, `:aspect` on either endpoint and no `:size`
1938
+ ; stays on the legacy whole-texture operation forever — PNGB 0x23 and command
1939
+ ; 0x23, byte-identical, including the canvas-size fallback. Any one of those
1940
+ ; keys (even with its default value) selects the subresource operation and the
1941
+ ; normalized SubresourceCopy model. The legacy opcode carries two ids and
1942
+ ; nothing else (`wire_schema` L_2V); the new operation is PNGB 0x80.
1691
1943
  (form :name copy-texture-to-texture
1692
- :description "Queue op: GPU texture→texture copy. context-current-texture names the canvas; otherwise a (texture …) name."
1944
+ :description "Queue op: GPU texture→texture copy. With no :mip-level, :origin or :aspect on either endpoint and no :size, this is the legacy whole-texture copy (PNGB 0x23) byte-identically; any such key selects the subresource operation. context-current-texture names the canvas; otherwise a (texture …) name."
1693
1945
  :positional copy-endpoints-section
1946
+ (key :name size :type copy-extent :optional true
1947
+ :description "GPUCommandEncoder.copyTextureToTexture's copySize (1–3 u32s). Optional only through the recorded deviation: absent means the remaining physical SOURCE extent at the source :origin and :mip-level; the destination must contain the same extent at its origin. Presence selects the subresource operation.")
1694
1948
  (form :name source
1695
- :description "Copy source (GPUTexelCopyTextureInfo)."
1949
+ :description "Copy source (GPUTexelCopyTextureInfo). With no subresource key and no outer :size it is the legacy whole-texture source."
1696
1950
  (key :name texture :type attachment-view
1697
- :description "Source texture: context-current-texture or a (texture …) name."))
1951
+ :description "Source texture: context-current-texture or a (texture …) name; needs copy-src usage.")
1952
+ (key :name mip-level :type subresource-index :default 0
1953
+ :description "Source mip level (GPUTexelCopyTextureInfo.mipLevel, default 0). Authoring the key selects the subresource operation; omitting it leaves the legacy route available.")
1954
+ (key :name origin :type origin3 :optional true
1955
+ :description "Source origin [x y z] in texels (GPUTexelCopyTextureInfo.origin, IDL default {} = all zero); z selects the array layer or depth slice. Its presence selects the subresource operation.")
1956
+ (key :name aspect :type texture-aspect :default all
1957
+ :description "Source aspect (GPUTexelCopyTextureInfo.aspect, default all). A depth-stencil texture→texture copy requires all on BOTH endpoints — the opposite of the write path's single-aspect rule. Its presence selects the subresource operation."))
1698
1958
  (form :name destination
1699
- :description "Copy destination (GPUTexelCopyTextureInfo)."
1959
+ :description "Copy destination (GPUTexelCopyTextureInfo). With no subresource key and no outer :size it is the legacy whole-texture destination."
1700
1960
  (key :name texture :type attachment-view
1701
- :description "Destination texture: context-current-texture or a (texture …) name.")))
1961
+ :description "Destination texture: context-current-texture or a (texture …) name; needs copy-dst usage and a non-pooled id on the subresource path.")
1962
+ (key :name mip-level :type subresource-index :default 0
1963
+ :description "Destination mip level (GPUTexelCopyTextureInfo.mipLevel, default 0). Its presence selects the subresource operation.")
1964
+ (key :name origin :type origin3 :optional true
1965
+ :description "Destination origin [x y z] in texels (GPUTexelCopyTextureInfo.origin, IDL default {} = all zero); z selects the array layer or depth slice. Its presence selects the subresource operation.")
1966
+ (key :name aspect :type texture-aspect :default all
1967
+ :description "Destination aspect (GPUTexelCopyTextureInfo.aspect, default all). A depth-stencil texture→texture copy requires all on BOTH endpoints. Its presence selects the subresource operation.")))
1702
1968
 
1703
1969
  (form :name copy-external-image-to-texture
1704
1970
  :description "Queue op: upload a decoded image (image-bitmap) into a texture. mip-level / origin default to 0 per the WebGPU spec."
@@ -1794,6 +2060,21 @@
1794
2060
  ; the layout, so there is nothing to derive a reachable set from.
1795
2061
  (key :name prune-unused :type boolean :default false
1796
2062
  :description "Drop each (entry …) whose (group, binding) no entry point of the :layout pipeline reaches. Prevents the bind-group/auto-layout desync that aborts at set_bind_group. Ignored when :layout names an explicit (bind-group-layout …); refused as redundant on a group with no :layout, which is pruned per pipeline already.")
2063
+ ; VGPU-08 Slice B — the narrow, all-or-nothing compile-time resource
2064
+ ; inference. For each reflected fixed-size uniform binding at this group's
2065
+ ; :group that an entry point of a binding pipeline reaches and no explicit
2066
+ ; (entry …) claims, the emitter synthesizes the ordinary buffer and entry:
2067
+ ; a buffer named `auto_uniforms__g<group>_b<binding>` with the reflected
2068
+ ; struct's exact layout size and [uniform copy-dst] usage, and the
2069
+ ; (entry :binding N :buffer …) that binds it. Explicit entries win; an
2070
+ ; unclaimed storage/texture/sampler binding, incompatible layout variants
2071
+ ; across pipelines, a generated-name collision or a slot past the
2072
+ ; compiler's 8-way destination join refuse with a named code rather than
2073
+ ; guess. Textures, samplers, storage buffers and vertex buffers are never
2074
+ ; synthesized. This is pure emitter inference, not a lowering hook: there
2075
+ ; is no `:lowering` and no sugar-ledger row.
2076
+ (key :name auto-uniforms :type boolean :default false
2077
+ :description "Synthesize an ordinary buffer + entry for every reflected fixed-size uniform binding at this group's :group that a binding pipeline reaches and no explicit (entry …) claims. Explicit entries win; unclaimed non-uniform bindings, incompatible layout variants, name collisions and slots past the compiler's 8-way destination join refuse. Pure emitter inference: no lowering hook.")
1797
2078
  ; Slot-local entry form: `(entry :binding N :buffer|:sampler|:texture|:texture-view R)`.
1798
2079
  ; Resolved LOCAL-FIRST under bind-group, so this `entry` is distinct from the
1799
2080
  ; bind-group-layout's entry. (A global `entry` stand-in used to sit above
@@ -2143,9 +2424,9 @@
2143
2424
  (form :name color-attachment
2144
2425
  :description "One color target of a render pass."
2145
2426
  (key :name view :type attachment-view
2146
- :description "Texture written by this pass: the canvas (context-current-texture) or a (texture …).")
2427
+ :description "Attachment written by this pass: the canvas (context-current-texture), a (texture …) (its default view), or a (texture-view …) selecting one mip level and one array layer.")
2147
2428
  (key :name resolve-target :type attachment-view :optional true
2148
- :description "Receives the resolved single-sample output when :view is multisampled.")
2429
+ :description "Receives the resolved single-sample output when :view is multisampled — the canvas, a (texture …), or a (texture-view …) selecting one mip level and one array layer.")
2149
2430
  (key :name clear-value :type clear-color :optional true
2150
2431
  :description "RGBA the attachment is cleared to when load-op is clear (WebGPU default: transparent black). Stating one beside `:load-op load` is an error — WebGPU would ignore it.")
2151
2432
  ; REQUIRED, matching GPURenderPassColorAttachment.loadOp/storeOp. WebGPU has
@@ -2180,8 +2461,8 @@
2180
2461
  ; document. The emitter says it instead, with a span on the attachment.
2181
2462
  (form :name depth-stencil-attachment
2182
2463
  :description "Depth/stencil target of a render pass."
2183
- (key :name view :type texture-ref
2184
- :description "The depth/stencil (texture …) this pass tests/writes against.")
2464
+ (key :name view :type depth-attachment-view
2465
+ :description "The depth/stencil (texture …) or (texture-view …) this pass tests/writes against. The canvas is not a depth attachment.")
2185
2466
  (key :name depth-clear-value :type unorm :optional true
2186
2467
  :description "Depth cleared to when depth-load-op is clear, in [0,1]. Required when it clears — WebGPU has no default for it — and rejected beside `:depth-load-op load`.")
2187
2468
  (key :name depth-load-op :type load-op :optional true
@@ -2313,6 +2594,20 @@
2313
2594
  (key :name index-buffer :type buffer-ref :optional true
2314
2595
  :description "Index buffer when the bundle draws indexed."))
2315
2596
 
2597
+ ; A host-settable f32. It is one value with two readers: a guard compares it
2598
+ ; before a group runs, and a shader samples the same slot through
2599
+ ; `control-inputs`, so the branch and the draw cannot disagree. The schema
2600
+ ; carries what it can (a unique name, a real default); the rest are compiler
2601
+ ; checks and the description says so rather than implying enforcement here:
2602
+ ; `time` is reserved, the name must be a WGSL identifier because it becomes a
2603
+ ; struct member, and it must not collide with a reflected uniform field
2604
+ ; because the host addresses both by bare name.
2605
+ (form :name control
2606
+ :description "A named f32 the host sets, readable by guards and by shaders through control-inputs. `time` is reserved by the compiler. The name must be a WGSL identifier and must not collide with a reflected uniform field — both are compiler checks, not schema rules."
2607
+ (key :name name :type symbol
2608
+ :description "Control name, unique among controls. It names a WGSL struct member in control-inputs, so it must be a WGSL identifier, and the host addresses it and reflected uniforms by bare name, so it must not collide with one (both compiler checks).")
2609
+ (key :name default :type real :default 0
2610
+ :description "Initial value: a literal, a bounded expression, or a bare (define …) name. Omitted, it is 0. The compiler rejects a value that is not finite after f32 rounding."))
2316
2611
  ; A named sequence of frame steps, expanded WHERE IT IS NAMED. This is what a
2317
2612
  ; `(draw-graph …)` or `(pass-graph …)` with a `:name` emits instead of a
2318
2613
  ; frame: a graph is several passes, so without a name for the set there is no
@@ -2320,21 +2615,132 @@
2320
2615
  ; document's only frame and refuse the other. Nothing reaches the wire — the
2321
2616
  ; emitter inlines a group's steps into the frame that names it, so a frame
2322
2617
  ; over groups emits exactly the ops the same frame written out by hand does.
2618
+ ;
2619
+ ; The guard keys are shaped so the schema can carry the rules (plan 4.6):
2620
+ ; `:when` is one union slot, each comparison is the existing `real` kind,
2621
+ ; and `:requires [when]` turns a comparison or `:else` written without a
2622
+ ; subject into a located reject instead of inert input. Which key means what
2623
+ ; is in each description; holding TWO comparisons is a window, which is why
2624
+ ; that sentence sits on the comparison keys rather than in one shared place.
2323
2625
  (form :name step-group
2324
- :description "A named sequence of frame steps, inlined wherever a (frame …) or another group names it. Emitted by a named (draw-graph …) / (pass-graph …); writable by hand to name a sequence once and run it in several frames."
2626
+ :description "A named sequence of frame steps, inlined wherever a (frame …) or another group names it. Emitted by a named (draw-graph …) / (pass-graph …); writable by hand to name a sequence once and run it in several frames. With :when the group runs only when every comparison key holds (no comparison key = nonzero), and :else names the steps that run otherwise; without :when the group behaves exactly as today."
2325
2627
  (key :name name :type symbol)
2326
2628
  (key :name perform :type frame-step-list
2327
- :description "The steps this group stands for, in order."))
2629
+ :description "The steps this group stands for, in order.")
2630
+ (key :name when :type control-source :optional true
2631
+ :description "The guard's subject: the builtin control time, or a (control …) name. The group runs only when every comparison key holds; with no comparison key it runs when the control is nonzero.")
2632
+ (key :name is :type real :optional true :requires [when]
2633
+ :description "Holds when the control equals this value (an exact f32 comparison). Written beside another comparison key, both must hold — two keys make a window.")
2634
+ (key :name is-not :type real :optional true :requires [when]
2635
+ :description "Holds when the control does not equal this value. Written beside another comparison key, both must hold — two keys make a window.")
2636
+ (key :name below :type real :optional true :requires [when]
2637
+ :description "Holds when the control is less than this value. Written beside another comparison key, both must hold — two keys make a window, as in :at-least 10 :below 10.5.")
2638
+ (key :name above :type real :optional true :requires [when]
2639
+ :description "Holds when the control is greater than this value. Written beside another comparison key, both must hold — two keys make a window.")
2640
+ (key :name at-least :type real :optional true :requires [when]
2641
+ :description "Holds when the control is greater than or equal to this value. Written beside another comparison key, both must hold — two keys make a window.")
2642
+ (key :name at-most :type real :optional true :requires [when]
2643
+ :description "Holds when the control is less than or equal to this value. Written beside another comparison key, both must hold — two keys make a window.")
2644
+ (key :name else :type frame-step-list :optional true :requires [when]
2645
+ :description "The steps that run when the guard does not hold. Needs :when; a group without a guard has nothing to be the alternative to."))
2328
2646
  (form :name frame
2329
2647
  :description "Frame program: what runs each frame, in order."
2330
2648
  (key :name name :type symbol)
2331
- (key :name init :type compute-pass-ref-list :optional true
2332
- :description "One-shot (init …) steps run on the first frame only (each lowers to a compute-pass of the same name).")
2649
+ (key :name init :type init-step-list :optional true
2650
+ :description "One-time steps, run once per loaded payload in this order and before any recurring work: a (queue …) (its actions are lowered to a generated one-shot compute pass), an offscreen (render-pass …), a (compute-pass …) or an (init …) (which lowers to one), or a named group of those forms. Refused: a canvas target or canvas-sized storage binding (including through a replayed render bundle), a guarded group or (select …), a step also reached from :before/:perform, a group cycle, a generated-name collision, a runtime-provided write source (pngine-inputs, scene-time-inputs, pngine-frame-inputs, pointer-inputs), an upload whose asset does not resolve, and a legal group fan-out that exceeds the emitter's walk budget.")
2333
2651
  (key :name before :type queue-ref-list :optional true
2334
2652
  :description "(queue …) ops run before each frame's passes.")
2335
2653
  (key :name perform :type frame-step-list
2336
2654
  :description "Passes and queues run every frame, in order."))
2337
2655
 
2656
+ ; =====================================================================
2657
+ ; `(select …)` sugar — lowered to a chain of guarded step-groups by
2658
+ ; pngine/select-v1 (plan frame-program §4.3)
2659
+ ; =====================================================================
2660
+ ; `select` picks the first case whose comparison holds, and the whole thing
2661
+ ; is sugar: the hook lowers it to the chain of guarded `(step-group …)`
2662
+ ; forms a hand-written document would spell out. The schema carries what it
2663
+ ; can (the case count, the `:on` union, the comparison keys as `real`); the
2664
+ ; one rule no key-set can express — "a case carries at least one comparison
2665
+ ; key", because a key-set has no min-children — is the hook's, refused on
2666
+ ; the case's own span. The default belongs in `:else`.
2667
+ ;
2668
+ ; The count bound is head-set bounds on the slot-local `case` form: below
2669
+ ; the floor `positional_missing` (on the select's head), above the ceiling
2670
+ ; `positional_too_many` (on the 65th child) — the same per-head cardinality
2671
+ ; mechanism the pipeline sections use.
2672
+ (value-kind :name select-section :underlying form :heads (head-set
2673
+ (head :name case :min 1 :max 64)))
2674
+ ; One case. The comparison keys are the six a `(step-group …)` guard takes,
2675
+ ; with the same meanings (every key written must hold, so two keys make a
2676
+ ; window); the subject is the select's `:on`, written once, which is why
2677
+ ; these carry no `:requires`. No `:name` — a case is a positional arm, not a
2678
+ ; target, and the group the hook builds for it is named after the SELECT.
2679
+ (form :name case
2680
+ :description "One case of a (select …): at least one comparison key (the default belongs in the select's :else), and the steps to perform when it is the first case that holds."
2681
+ (key :name is :type real :optional true
2682
+ :description "Holds when the control equals this value (an exact f32 comparison). Written beside another comparison key, both must hold — two keys make a window.")
2683
+ (key :name is-not :type real :optional true
2684
+ :description "Holds when the control does not equal this value. Written beside another comparison key, both must hold — two keys make a window.")
2685
+ (key :name below :type real :optional true
2686
+ :description "Holds when the control is less than this value. Written beside another comparison key, both must hold — two keys make a window.")
2687
+ (key :name above :type real :optional true
2688
+ :description "Holds when the control is greater than this value. Written beside another comparison key, both must hold — two keys make a window.")
2689
+ (key :name at-least :type real :optional true
2690
+ :description "Holds when the control is greater than or equal to this value. Written beside another comparison key, both must hold — two keys make a window.")
2691
+ (key :name at-most :type real :optional true
2692
+ :description "Holds when the control is less than or equal to this value. Written beside another comparison key, both must hold — two keys make a window.")
2693
+ (key :name perform :type frame-step-list
2694
+ :description "The steps this case performs when it is the first case that holds."))
2695
+ ; The chain's shape, for the reader: `(select :name backdrop :on scene (case
2696
+ ; :is 0 :perform [linePass]) (case :is 1 :perform [gatesPass]) :else
2697
+ ; [ringPass])` lowers to
2698
+ ; (step-group :name backdrop :when scene :is 0 :perform [linePass] :else [backdrop__case1])
2699
+ ; (step-group :name backdrop__case1 :when scene :is 1 :perform [gatesPass] :else [ringPass])
2700
+ ; — the first group keeps the select's name (so a frame names `backdrop`
2701
+ ; either way), continuations follow the hooks' double-underscore convention,
2702
+ ; and the last case's `:else` is the select's `:else`.
2703
+ (form :name select
2704
+ :description "Pick the first case whose comparison holds. Sugar: pngine/select-v1 lowers it to a chain of guarded (step-group …) forms, so a frame names the select exactly as it names a group. Cases are tried in source order and the first match wins (overlap is legal — that is what makes a :below cascade work); no match and no :else, the select does nothing."
2705
+ :lowering (lowering :hook pngine/select-v1
2706
+ :produces [step-group])
2707
+ :positional select-section
2708
+ (key :name name :type symbol
2709
+ :description "Select name — the first group of the lowered chain keeps it, so a (frame …) names the select itself, and the continuation groups are <name>__caseN.")
2710
+ (key :name on :type control-source
2711
+ :description "The control every case compares — the builtin time, or a name declared by (control …). Becomes :when on every group the lowering emits.")
2712
+ (key :name else :type frame-step-list :optional true
2713
+ :description "The steps that run when no case holds. Becomes the last group's :else, so it is the chain's fallback arm."))
2714
+
2715
+ ; =====================================================================
2716
+ ; `(mip-chain …)` sugar — lowered to a render-pass chain by
2717
+ ; pngine/mips-v1 (plan 08)
2718
+ ; =====================================================================
2719
+ ; A mip chain is ordinary resources and ordinary scheduling: the hook emits
2720
+ ; a sampled/attachment (texture-view …) pair per generated level, one linear
2721
+ ; sampler, one fullscreen module/pipeline for the texture's format, a bind
2722
+ ; group and render pass per level, and one named `(step-group …)` holding
2723
+ ; those passes in ascending order. The author schedules that group in a
2724
+ ; frame like any other step and queues the level-0 write before it; nothing
2725
+ ; runs at load time and no once-only side channel is created.
2726
+ ;
2727
+ ; The descriptor checks are the hook's, not the schema's (they relate keys
2728
+ ; to a sibling `(texture …)`): 2d, one sample, one layer, not pooled, at
2729
+ ; least two mip levels, sampled AND attachable, and a format that is both
2730
+ ; filterable and color-renderable without an optional feature. A one-level
2731
+ ; texture is `nothing-to-generate` rather than an empty group.
2732
+ (form :name mip-chain
2733
+ :description "Generate a (texture …)'s mip levels from level 0 with a named step-group of ordinary render passes. Sugar: pngine/mips-v1."
2734
+ :lowering (lowering :hook pngine/mips-v1
2735
+ :produces [texture-view sampler shader-module render-pipeline vertex
2736
+ fragment color-target bind-group entry render-pass
2737
+ color-attachment draw step-group])
2738
+ (key :name name :type symbol
2739
+ :description "The generated step-group's name. A (frame …) performs it like any other step, after the step that writes level 0.")
2740
+ (key :name texture :type texture-ref
2741
+ :description "The (texture …) whose levels 1..mip-level-count-1 the chain generates. Level 0 is an input and is never overwritten; the texture must be 2d, one-sample, one-layer, non-pooled, sampled and renderable, with a filterable color format."))
2742
+
2743
+
2338
2744
  ; ---- init sugar: lowered to compute-pipeline + bind-group + compute-pass ----
2339
2745
  (form :name init
2340
2746
  :description "One-shot compute init of a storage buffer (first frame only)."
@@ -2416,7 +2822,7 @@
2416
2822
  :positional pass-section
2417
2823
  (key :name name :type symbol)
2418
2824
  (key :name code :type string
2419
- :description "WGSL fragment (or compute) source; the hook injects the binding prelude (pngine uniforms, pointer, sampler, dep/feedback textures, D0… data buffers). Required — the hook always refused its absence.")
2825
+ :description "WGSL fragment (or compute) source; the hook injects the binding prelude (pngine uniforms, pointer, sampler, dep/feedback textures, D0… data buffers, and — when the document declares (control …) forms and the code names `controls` — the ControlInputs struct, one f32 member per control in declaration order, on the next binding, with a graph-shared buffer and one control-inputs write per frame). Required — the hook always refused its absence.")
2420
2826
  (key :name feedback :type boolean :optional true
2421
2827
  :description "Ping-pong texture pair for feedback; the previous frame is readable as prev_<name>.")
2422
2828
  ; The intermediate's texel format, which is ONE value in WebGPU terms: the