@aardworx/wombat.rendering 0.9.32 → 0.18.1

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.
Files changed (95) hide show
  1. package/dist/runtime/derivedModes/kernelCodegen.d.ts +90 -0
  2. package/dist/runtime/derivedModes/kernelCodegen.d.ts.map +1 -0
  3. package/dist/runtime/derivedModes/kernelCodegen.js +623 -0
  4. package/dist/runtime/derivedModes/kernelCodegen.js.map +1 -0
  5. package/dist/runtime/derivedModes/modeKeyCpu.d.ts.map +1 -1
  6. package/dist/runtime/derivedModes/modeKeyCpu.js +23 -67
  7. package/dist/runtime/derivedModes/modeKeyCpu.js.map +1 -1
  8. package/dist/runtime/derivedModes/partitionDispatcher.d.ts +79 -0
  9. package/dist/runtime/derivedModes/partitionDispatcher.d.ts.map +1 -0
  10. package/dist/runtime/derivedModes/partitionDispatcher.js +303 -0
  11. package/dist/runtime/derivedModes/partitionDispatcher.js.map +1 -0
  12. package/dist/runtime/derivedModes/partitionKernel.d.ts +12 -0
  13. package/dist/runtime/derivedModes/partitionKernel.d.ts.map +1 -0
  14. package/dist/runtime/derivedModes/partitionKernel.js +127 -0
  15. package/dist/runtime/derivedModes/partitionKernel.js.map +1 -0
  16. package/dist/runtime/derivedModes/partitionKernelLayout.d.ts +4 -0
  17. package/dist/runtime/derivedModes/partitionKernelLayout.d.ts.map +1 -0
  18. package/dist/runtime/derivedModes/partitionKernelLayout.js +24 -0
  19. package/dist/runtime/derivedModes/partitionKernelLayout.js.map +1 -0
  20. package/dist/runtime/derivedModes/rule.d.ts +38 -86
  21. package/dist/runtime/derivedModes/rule.d.ts.map +1 -1
  22. package/dist/runtime/derivedModes/rule.js +34 -74
  23. package/dist/runtime/derivedModes/rule.js.map +1 -1
  24. package/dist/runtime/derivedUniforms/dispatch.d.ts +10 -8
  25. package/dist/runtime/derivedUniforms/dispatch.d.ts.map +1 -1
  26. package/dist/runtime/derivedUniforms/dispatch.js +31 -18
  27. package/dist/runtime/derivedUniforms/dispatch.js.map +1 -1
  28. package/dist/runtime/derivedUniforms/marker.d.ts +90 -11
  29. package/dist/runtime/derivedUniforms/marker.d.ts.map +1 -1
  30. package/dist/runtime/derivedUniforms/marker.js +161 -15
  31. package/dist/runtime/derivedUniforms/marker.js.map +1 -1
  32. package/dist/runtime/derivedUniforms/sceneIntegration.d.ts +25 -6
  33. package/dist/runtime/derivedUniforms/sceneIntegration.d.ts.map +1 -1
  34. package/dist/runtime/derivedUniforms/sceneIntegration.js +61 -20
  35. package/dist/runtime/derivedUniforms/sceneIntegration.js.map +1 -1
  36. package/dist/runtime/heapEligibility.d.ts.map +1 -1
  37. package/dist/runtime/heapEligibility.js +22 -2
  38. package/dist/runtime/heapEligibility.js.map +1 -1
  39. package/dist/runtime/heapScene/chunkedArena.d.ts +76 -0
  40. package/dist/runtime/heapScene/chunkedArena.d.ts.map +1 -0
  41. package/dist/runtime/heapScene/chunkedArena.js +223 -0
  42. package/dist/runtime/heapScene/chunkedArena.js.map +1 -0
  43. package/dist/runtime/heapScene/freelist.d.ts +50 -0
  44. package/dist/runtime/heapScene/freelist.d.ts.map +1 -0
  45. package/dist/runtime/heapScene/freelist.js +160 -0
  46. package/dist/runtime/heapScene/freelist.js.map +1 -0
  47. package/dist/runtime/heapScene/growBuffer.d.ts +23 -2
  48. package/dist/runtime/heapScene/growBuffer.d.ts.map +1 -1
  49. package/dist/runtime/heapScene/growBuffer.js +35 -3
  50. package/dist/runtime/heapScene/growBuffer.js.map +1 -1
  51. package/dist/runtime/heapScene/pools.d.ts +65 -42
  52. package/dist/runtime/heapScene/pools.d.ts.map +1 -1
  53. package/dist/runtime/heapScene/pools.js +206 -134
  54. package/dist/runtime/heapScene/pools.js.map +1 -1
  55. package/dist/runtime/heapScene.d.ts +12 -0
  56. package/dist/runtime/heapScene.d.ts.map +1 -1
  57. package/dist/runtime/heapScene.js +949 -167
  58. package/dist/runtime/heapScene.js.map +1 -1
  59. package/dist/runtime/hybridScene.d.ts +7 -0
  60. package/dist/runtime/hybridScene.d.ts.map +1 -1
  61. package/dist/runtime/hybridScene.js +1 -0
  62. package/dist/runtime/hybridScene.js.map +1 -1
  63. package/dist/runtime/index.d.ts +4 -3
  64. package/dist/runtime/index.d.ts.map +1 -1
  65. package/dist/runtime/index.js +4 -3
  66. package/dist/runtime/index.js.map +1 -1
  67. package/dist/runtime/renderTask.d.ts +5 -0
  68. package/dist/runtime/renderTask.d.ts.map +1 -1
  69. package/dist/runtime/renderTask.js +1 -0
  70. package/dist/runtime/renderTask.js.map +1 -1
  71. package/dist/runtime/runtime.d.ts +6 -0
  72. package/dist/runtime/runtime.d.ts.map +1 -1
  73. package/dist/runtime/runtime.js +1 -0
  74. package/dist/runtime/runtime.js.map +1 -1
  75. package/package.json +1 -1
  76. package/src/runtime/derivedModes/kernelCodegen.ts +673 -0
  77. package/src/runtime/derivedModes/modeKeyCpu.ts +22 -60
  78. package/src/runtime/derivedModes/partitionDispatcher.ts +349 -0
  79. package/src/runtime/derivedModes/partitionKernelLayout.ts +25 -0
  80. package/src/runtime/derivedModes/rule.ts +66 -145
  81. package/src/runtime/derivedUniforms/dispatch.ts +48 -21
  82. package/src/runtime/derivedUniforms/marker.ts +210 -16
  83. package/src/runtime/derivedUniforms/sceneIntegration.ts +67 -20
  84. package/src/runtime/heapEligibility.ts +22 -1
  85. package/src/runtime/heapScene/chunkedArena.ts +238 -0
  86. package/src/runtime/heapScene/freelist.ts +161 -0
  87. package/src/runtime/heapScene/growBuffer.ts +39 -2
  88. package/src/runtime/heapScene/pools.ts +231 -143
  89. package/src/runtime/heapScene.ts +1134 -161
  90. package/src/runtime/hybridScene.ts +8 -0
  91. package/src/runtime/index.ts +12 -9
  92. package/src/runtime/renderTask.ts +6 -0
  93. package/src/runtime/runtime.ts +7 -0
  94. package/src/runtime/derivedModes/gpuDispatcher.ts +0 -226
  95. package/src/runtime/derivedModes/gpuKernel.ts +0 -98
@@ -0,0 +1,90 @@
1
+ import type { Expr, Stmt, IntrinsicEvalTable } from "@aardworx/wombat.shader/ir";
2
+ import type { ModeAxis } from "./rule.js";
3
+ /** One traced+rewritten axis-rule body, ready for codegen. */
4
+ export interface RuleCodegenSpec {
5
+ readonly axis: ModeAxis;
6
+ /** Unique within `axis` within the bucket. */
7
+ readonly axisRuleId: number;
8
+ /**
9
+ * The rule body — already rewritten so every `ReturnValue` returns
10
+ * a `Const u32` PER-AXIS index into this axis's union value table.
11
+ */
12
+ readonly body: Stmt;
13
+ readonly intrinsics: IntrinsicEvalTable;
14
+ /** Per-rule WGSL helpers (concatenated into the kernel). */
15
+ readonly helpersWGSL: string;
16
+ readonly inputUniforms: ReadonlyArray<string>;
17
+ }
18
+ /** Per-active-axis entry inside a single combo: either picks a rule
19
+ * (axis index computed at runtime by `rule_<axis>_<id>`) or a fixed
20
+ * per-axis index (a compile-time constant for axes the combo has no
21
+ * rule on — the index of baseDescriptor's value in this axis's
22
+ * union table). */
23
+ export type ComboAxisSource = {
24
+ readonly kind: "rule";
25
+ readonly axisRuleId: number;
26
+ } | {
27
+ readonly kind: "const";
28
+ readonly idx: number;
29
+ };
30
+ export interface ComboAxis {
31
+ readonly axis: ModeAxis;
32
+ /** |axisValues[axis]| — the stride for mixed-radix encoding is the
33
+ * product of cardinalities of axes after this one in `axes`. */
34
+ readonly cardinality: number;
35
+ readonly source: ComboAxisSource;
36
+ }
37
+ export interface ComboCodegenSpec {
38
+ readonly comboId: number;
39
+ /** Active axes (those with at least one rule in the bucket), in
40
+ * canonical order. Every combo in the bucket carries the same
41
+ * axis list — combos differ only in which axes have rules. */
42
+ readonly axes: ReadonlyArray<ComboAxis>;
43
+ }
44
+ export interface KernelCodegenSpec {
45
+ /** Distinct axis-rules registered on the bucket. */
46
+ readonly rules: ReadonlyArray<RuleCodegenSpec>;
47
+ /** Distinct combos appearing on ROs in this bucket. */
48
+ readonly combos: ReadonlyArray<ComboCodegenSpec>;
49
+ /** Total slot count = ∏ cardinality across active axes. */
50
+ readonly totalSlots: number;
51
+ /** Bucket-wide ordered list of uniform names that any rule body
52
+ * reads (`ReadInput("Uniform", name)`). Each one becomes a
53
+ * `refK: u32` field in the Record struct + a tail slot in master
54
+ * records; rules dereference their named reads as `r.refK`. */
55
+ readonly uniformOrder: ReadonlyArray<string>;
56
+ }
57
+ /** Emit the WGSL partition kernel for the given rules + combos.
58
+ * Per-record dispatch:
59
+ * `switch (r.comboId) { case 0u: { return combo_0(r); } … }`
60
+ * Each `combo_<id>(r)` computes per-axis indices (calling
61
+ * `rule_<axis>_<axisRuleId>(r)` for axes the combo has a rule on,
62
+ * or using a const for the others) and composes them into a
63
+ * global slot index via mixed-radix encoding over `axes`. */
64
+ export declare function emitPartitionKernel(spec: KernelCodegenSpec): string;
65
+ /**
66
+ * Replace every `ReadInput("<scope>", "<name>")` leaf in `e` with
67
+ * the supplied `replacement` Expr. Used to bake the rule's
68
+ * `declared` ReadInput as a `Const u32` of the current declared
69
+ * value before codegen — the resulting body has no `declared`
70
+ * references, so the kernel doesn't need a per-dispatch uniform.
71
+ */
72
+ export declare function substituteReadInput(e: Expr, scope: string, name: string, replacement: Expr): Expr;
73
+ export declare function substituteReadInputInStmt(s: Stmt, scope: string, name: string, replacement: Expr): Stmt;
74
+ /** Walk `s` and collect the names of every `ReadInput("Uniform", name)`
75
+ * it contains (in DFS order, deduped). heapScene uses this to size
76
+ * the bucket's `uniformOrder` + master-record uniform-ref tail. */
77
+ export declare function collectUniformReadsInStmt(s: Stmt): string[];
78
+ /**
79
+ * Rewrite the body so every `ReturnValue` returns a `Const u32` slot
80
+ * index (resolved by `exprToSlot`). `Conditional` expressions are
81
+ * recursed into — each branch is rewritten independently. Other
82
+ * non-Conditional return expressions are matched as a whole against
83
+ * `exprToSlot` (using stableStringify-content equality upstream).
84
+ *
85
+ * After this pass the kernel emits a u32 directly from
86
+ * `rule_<axis>(r)`; the partition entry switches on it as a slot
87
+ * index, no SLOT_LOOKUP table needed.
88
+ */
89
+ export declare function rewriteOutputsToSlotIndices(body: Stmt, exprToSlot: (e: Expr) => number | undefined): Stmt;
90
+ //# sourceMappingURL=kernelCodegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernelCodegen.d.ts","sourceRoot":"","sources":["../../../src/runtime/derivedModes/kernelCodegen.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAiB,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,4DAA4D;IAC5D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC/C;AAED;;;;oBAIoB;AACpB,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB;qEACiE;IACjE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;mEAE+D;IAC/D,QAAQ,CAAC,I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