@aardworx/wombat.rendering 0.9.33 → 0.19.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.
Files changed (107) hide show
  1. package/dist/core/renderObject.d.ts +16 -0
  2. package/dist/core/renderObject.d.ts.map +1 -1
  3. package/dist/runtime/derivedModes/kernelCodegen.d.ts +90 -0
  4. package/dist/runtime/derivedModes/kernelCodegen.d.ts.map +1 -0
  5. package/dist/runtime/derivedModes/kernelCodegen.js +623 -0
  6. package/dist/runtime/derivedModes/kernelCodegen.js.map +1 -0
  7. package/dist/runtime/derivedModes/modeKeyCpu.d.ts.map +1 -1
  8. package/dist/runtime/derivedModes/modeKeyCpu.js +23 -67
  9. package/dist/runtime/derivedModes/modeKeyCpu.js.map +1 -1
  10. package/dist/runtime/derivedModes/partitionDispatcher.d.ts +79 -0
  11. package/dist/runtime/derivedModes/partitionDispatcher.d.ts.map +1 -0
  12. package/dist/runtime/derivedModes/partitionDispatcher.js +303 -0
  13. package/dist/runtime/derivedModes/partitionDispatcher.js.map +1 -0
  14. package/dist/runtime/derivedModes/partitionKernel.d.ts +12 -0
  15. package/dist/runtime/derivedModes/partitionKernel.d.ts.map +1 -0
  16. package/dist/runtime/derivedModes/partitionKernel.js +127 -0
  17. package/dist/runtime/derivedModes/partitionKernel.js.map +1 -0
  18. package/dist/runtime/derivedModes/partitionKernelLayout.d.ts +4 -0
  19. package/dist/runtime/derivedModes/partitionKernelLayout.d.ts.map +1 -0
  20. package/dist/runtime/derivedModes/partitionKernelLayout.js +24 -0
  21. package/dist/runtime/derivedModes/partitionKernelLayout.js.map +1 -0
  22. package/dist/runtime/derivedModes/rule.d.ts +38 -86
  23. package/dist/runtime/derivedModes/rule.d.ts.map +1 -1
  24. package/dist/runtime/derivedModes/rule.js +34 -74
  25. package/dist/runtime/derivedModes/rule.js.map +1 -1
  26. package/dist/runtime/derivedUniforms/dispatch.d.ts +10 -8
  27. package/dist/runtime/derivedUniforms/dispatch.d.ts.map +1 -1
  28. package/dist/runtime/derivedUniforms/dispatch.js +31 -18
  29. package/dist/runtime/derivedUniforms/dispatch.js.map +1 -1
  30. package/dist/runtime/derivedUniforms/marker.d.ts +90 -11
  31. package/dist/runtime/derivedUniforms/marker.d.ts.map +1 -1
  32. package/dist/runtime/derivedUniforms/marker.js +161 -15
  33. package/dist/runtime/derivedUniforms/marker.js.map +1 -1
  34. package/dist/runtime/derivedUniforms/sceneIntegration.d.ts +25 -6
  35. package/dist/runtime/derivedUniforms/sceneIntegration.d.ts.map +1 -1
  36. package/dist/runtime/derivedUniforms/sceneIntegration.js +61 -20
  37. package/dist/runtime/derivedUniforms/sceneIntegration.js.map +1 -1
  38. package/dist/runtime/heapAdapter.d.ts.map +1 -1
  39. package/dist/runtime/heapAdapter.js +17 -0
  40. package/dist/runtime/heapAdapter.js.map +1 -1
  41. package/dist/runtime/heapEligibility.d.ts.map +1 -1
  42. package/dist/runtime/heapEligibility.js +22 -2
  43. package/dist/runtime/heapEligibility.js.map +1 -1
  44. package/dist/runtime/heapScene/chunkedArena.d.ts +76 -0
  45. package/dist/runtime/heapScene/chunkedArena.d.ts.map +1 -0
  46. package/dist/runtime/heapScene/chunkedArena.js +223 -0
  47. package/dist/runtime/heapScene/chunkedArena.js.map +1 -0
  48. package/dist/runtime/heapScene/freelist.d.ts +55 -0
  49. package/dist/runtime/heapScene/freelist.d.ts.map +1 -0
  50. package/dist/runtime/heapScene/freelist.js +188 -0
  51. package/dist/runtime/heapScene/freelist.js.map +1 -0
  52. package/dist/runtime/heapScene/growBuffer.d.ts +23 -2
  53. package/dist/runtime/heapScene/growBuffer.d.ts.map +1 -1
  54. package/dist/runtime/heapScene/growBuffer.js +35 -3
  55. package/dist/runtime/heapScene/growBuffer.js.map +1 -1
  56. package/dist/runtime/heapScene/pools.d.ts +84 -42
  57. package/dist/runtime/heapScene/pools.d.ts.map +1 -1
  58. package/dist/runtime/heapScene/pools.js +309 -134
  59. package/dist/runtime/heapScene/pools.js.map +1 -1
  60. package/dist/runtime/heapScene.d.ts +24 -0
  61. package/dist/runtime/heapScene.d.ts.map +1 -1
  62. package/dist/runtime/heapScene.js +1158 -92
  63. package/dist/runtime/heapScene.js.map +1 -1
  64. package/dist/runtime/hybridScene.d.ts +15 -0
  65. package/dist/runtime/hybridScene.d.ts.map +1 -1
  66. package/dist/runtime/hybridScene.js +16 -0
  67. package/dist/runtime/hybridScene.js.map +1 -1
  68. package/dist/runtime/index.d.ts +4 -3
  69. package/dist/runtime/index.d.ts.map +1 -1
  70. package/dist/runtime/index.js +4 -3
  71. package/dist/runtime/index.js.map +1 -1
  72. package/dist/runtime/renderTask.d.ts +5 -0
  73. package/dist/runtime/renderTask.d.ts.map +1 -1
  74. package/dist/runtime/renderTask.js +1 -0
  75. package/dist/runtime/renderTask.js.map +1 -1
  76. package/dist/runtime/runtime.d.ts +6 -0
  77. package/dist/runtime/runtime.d.ts.map +1 -1
  78. package/dist/runtime/runtime.js +1 -0
  79. package/dist/runtime/runtime.js.map +1 -1
  80. package/dist/runtime/textureAtlas/atlasPool.d.ts +12 -0
  81. package/dist/runtime/textureAtlas/atlasPool.d.ts.map +1 -1
  82. package/dist/runtime/textureAtlas/atlasPool.js +20 -0
  83. package/dist/runtime/textureAtlas/atlasPool.js.map +1 -1
  84. package/package.json +1 -1
  85. package/src/core/renderObject.ts +16 -0
  86. package/src/runtime/derivedModes/kernelCodegen.ts +673 -0
  87. package/src/runtime/derivedModes/modeKeyCpu.ts +22 -60
  88. package/src/runtime/derivedModes/partitionDispatcher.ts +349 -0
  89. package/src/runtime/derivedModes/partitionKernelLayout.ts +25 -0
  90. package/src/runtime/derivedModes/rule.ts +66 -145
  91. package/src/runtime/derivedUniforms/dispatch.ts +48 -21
  92. package/src/runtime/derivedUniforms/marker.ts +210 -16
  93. package/src/runtime/derivedUniforms/sceneIntegration.ts +67 -20
  94. package/src/runtime/heapAdapter.ts +17 -0
  95. package/src/runtime/heapEligibility.ts +22 -1
  96. package/src/runtime/heapScene/chunkedArena.ts +238 -0
  97. package/src/runtime/heapScene/freelist.ts +196 -0
  98. package/src/runtime/heapScene/growBuffer.ts +39 -2
  99. package/src/runtime/heapScene/pools.ts +350 -143
  100. package/src/runtime/heapScene.ts +1350 -88
  101. package/src/runtime/hybridScene.ts +31 -0
  102. package/src/runtime/index.ts +12 -9
  103. package/src/runtime/renderTask.ts +6 -0
  104. package/src/runtime/runtime.ts +7 -0
  105. package/src/runtime/textureAtlas/atlasPool.ts +19 -0
  106. package/src/runtime/derivedModes/gpuDispatcher.ts +0 -226
  107. package/src/runtime/derivedModes/gpuKernel.ts +0 -98
@@ -26,18 +26,38 @@ export const ALIGN16 = (n: number) => (n + 15) & ~15;
26
26
  * it allocates, and `ensureCapacity` grows when required. This
27
27
  * separates allocation policy from grow policy.
28
28
  */
29
+ /**
30
+ * Default chunk capacity cap when none is provided. We pick 256 MB as
31
+ * a safety ceiling that's well within typical adapter
32
+ * `maxStorageBufferBindingSize` (WebGPU spec minimum is 128 MB; most
33
+ * desktop GPUs expose 2 GiB+, mobile/integrated ≥ 256 MB). Callers
34
+ * that know the adapter limit should pass it explicitly so chunks
35
+ * can grow to whatever the hardware supports — see §3 in
36
+ * `docs/heap-future-work.md` and `runtime/heapScene.ts`'s scene
37
+ * factory where the device limit is threaded in.
38
+ */
39
+ export const DEFAULT_MAX_BUFFER_BYTES = 256 * 1024 * 1024;
40
+
29
41
  export class GrowBuffer {
30
42
  private buf: GPUBuffer;
31
43
  private cap: number;
32
44
  private used = 0;
33
45
  private readonly listeners = new Set<() => void>();
46
+ private readonly maxBytes: number;
34
47
  constructor(
35
48
  private readonly device: GPUDevice,
36
49
  private readonly label: string,
37
50
  private readonly usage: GPUBufferUsageFlags,
38
51
  initialBytes: number,
52
+ maxBytes: number = DEFAULT_MAX_BUFFER_BYTES,
39
53
  ) {
40
54
  this.cap = Math.max(MIN_BUFFER_BYTES, POW2(initialBytes));
55
+ this.maxBytes = Math.max(this.cap, maxBytes);
56
+ if (this.cap > this.maxBytes) {
57
+ throw new Error(
58
+ `GrowBuffer '${label}': initial capacity ${this.cap} exceeds maxBytes ${this.maxBytes}`,
59
+ );
60
+ }
41
61
  this.buf = device.createBuffer({
42
62
  size: this.cap,
43
63
  usage: usage | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC,
@@ -46,16 +66,33 @@ export class GrowBuffer {
46
66
  }
47
67
  get buffer(): GPUBuffer { return this.buf; }
48
68
  get capacity(): number { return this.cap; }
69
+ get maxCapacity(): number { return this.maxBytes; }
49
70
  get usedBytes(): number { return this.used; }
50
71
  setUsed(n: number): void { this.used = n; }
51
72
  onResize(cb: () => void): IDisposable {
52
73
  this.listeners.add(cb);
53
74
  return { dispose: () => { this.listeners.delete(cb); } };
54
75
  }
55
- /** Ensure the buffer is at least `bytes` capacity. Grows by pow2 + copies live tail. */
76
+ /**
77
+ * Ensure the buffer is at least `bytes` capacity. Grows by pow2 +
78
+ * copies live tail. Throws if `bytes` exceeds the configured
79
+ * `maxBytes` cap — caller is expected to either open a new chunk
80
+ * (full §3 multi-draw-call path, deferred) or reject the
81
+ * allocation upstream (see `isHeapEligible`'s §2 large-object
82
+ * eject, which keeps multi-MB single ROs out of the heap arena
83
+ * entirely).
84
+ */
56
85
  ensureCapacity(bytes: number): void {
57
86
  if (bytes <= this.cap) return;
58
- const newCap = POW2(bytes);
87
+ if (bytes > this.maxBytes) {
88
+ throw new Error(
89
+ `GrowBuffer '${this.label}': requested ${bytes} bytes exceeds maxBytes ${this.maxBytes}. ` +
90
+ `This is the adapter's per-binding storage limit — landing larger workloads needs the ` +
91
+ `multi-chunk path (§3 in docs/heap-future-work.md) or upstream eviction via §2.`,
92
+ );
93
+ }
94
+ let newCap = POW2(bytes);
95
+ if (newCap > this.maxBytes) newCap = this.maxBytes;
59
96
  const newBuf = this.device.createBuffer({
60
97
  size: newCap,
61
98
  usage: this.usage | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC,