@aardworx/wombat.rendering 0.1.0 → 0.2.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 (185) hide show
  1. package/dist/commands/clear.d.ts +3 -0
  2. package/dist/commands/clear.d.ts.map +1 -0
  3. package/dist/commands/clear.js +69 -0
  4. package/dist/commands/clear.js.map +1 -0
  5. package/dist/commands/index.d.ts +3 -0
  6. package/dist/commands/index.d.ts.map +1 -0
  7. package/dist/commands/index.js +5 -0
  8. package/dist/commands/index.js.map +1 -0
  9. package/dist/commands/render.d.ts +16 -0
  10. package/dist/commands/render.d.ts.map +1 -0
  11. package/dist/commands/render.js +93 -0
  12. package/dist/commands/render.js.map +1 -0
  13. package/dist/core/acquire.d.ts +3 -0
  14. package/dist/core/acquire.d.ts.map +1 -0
  15. package/dist/core/acquire.js +22 -0
  16. package/dist/core/acquire.js.map +1 -0
  17. package/dist/core/adaptiveResource.d.ts +29 -0
  18. package/dist/core/adaptiveResource.d.ts.map +1 -0
  19. package/dist/core/adaptiveResource.js +73 -0
  20. package/dist/core/adaptiveResource.js.map +1 -0
  21. package/dist/core/buffer.d.ts +20 -0
  22. package/dist/core/buffer.d.ts.map +1 -0
  23. package/dist/core/buffer.js +30 -0
  24. package/dist/core/buffer.js.map +1 -0
  25. package/dist/core/bufferView.d.ts +15 -0
  26. package/dist/core/bufferView.d.ts.map +1 -0
  27. package/dist/core/bufferView.js +12 -0
  28. package/dist/core/bufferView.js.map +1 -0
  29. package/dist/core/clear.d.ts +9 -0
  30. package/dist/core/clear.d.ts.map +1 -0
  31. package/dist/core/clear.js +7 -0
  32. package/dist/core/clear.js.map +1 -0
  33. package/dist/core/command.d.ts +45 -0
  34. package/dist/core/command.d.ts.map +1 -0
  35. package/dist/core/command.js +12 -0
  36. package/dist/core/command.js.map +1 -0
  37. package/dist/core/drawCall.d.ts +17 -0
  38. package/dist/core/drawCall.d.ts.map +1 -0
  39. package/dist/core/drawCall.js +5 -0
  40. package/dist/core/drawCall.js.map +1 -0
  41. package/dist/core/framebuffer.d.ts +32 -0
  42. package/dist/core/framebuffer.d.ts.map +1 -0
  43. package/dist/core/framebuffer.js +6 -0
  44. package/dist/core/framebuffer.js.map +1 -0
  45. package/dist/core/framebufferSignature.d.ts +12 -0
  46. package/dist/core/framebufferSignature.d.ts.map +1 -0
  47. package/dist/core/framebufferSignature.js +7 -0
  48. package/dist/core/framebufferSignature.js.map +1 -0
  49. package/dist/core/index.d.ts +21 -0
  50. package/dist/core/index.d.ts.map +1 -0
  51. package/dist/core/index.js +14 -0
  52. package/dist/core/index.js.map +1 -0
  53. package/dist/core/pipelineState.d.ts +126 -0
  54. package/dist/core/pipelineState.d.ts.map +1 -0
  55. package/dist/core/pipelineState.js +88 -0
  56. package/dist/core/pipelineState.js.map +1 -0
  57. package/dist/core/renderContext.d.ts +8 -0
  58. package/dist/core/renderContext.d.ts.map +1 -0
  59. package/dist/core/renderContext.js +39 -0
  60. package/dist/core/renderContext.js.map +1 -0
  61. package/dist/core/renderObject.d.ts +45 -0
  62. package/dist/core/renderObject.d.ts.map +1 -0
  63. package/dist/core/renderObject.js +11 -0
  64. package/dist/core/renderObject.js.map +1 -0
  65. package/dist/core/renderTask.d.ts +12 -0
  66. package/dist/core/renderTask.d.ts.map +1 -0
  67. package/dist/core/renderTask.js +5 -0
  68. package/dist/core/renderTask.js.map +1 -0
  69. package/dist/core/renderTree.d.ts +35 -0
  70. package/dist/core/renderTree.d.ts.map +1 -0
  71. package/dist/core/renderTree.js +17 -0
  72. package/dist/core/renderTree.js.map +1 -0
  73. package/dist/core/sampler.d.ts +12 -0
  74. package/dist/core/sampler.d.ts.map +1 -0
  75. package/dist/core/sampler.js +8 -0
  76. package/dist/core/sampler.js.map +1 -0
  77. package/dist/core/shader.d.ts +3 -0
  78. package/dist/core/shader.d.ts.map +1 -0
  79. package/dist/core/shader.js +6 -0
  80. package/dist/core/shader.js.map +1 -0
  81. package/dist/core/texture.d.ts +34 -0
  82. package/dist/core/texture.d.ts.map +1 -0
  83. package/dist/core/texture.js +29 -0
  84. package/dist/core/texture.js.map +1 -0
  85. package/dist/index.d.ts +6 -0
  86. package/dist/index.d.ts.map +1 -0
  87. package/dist/index.js +18 -0
  88. package/dist/index.js.map +1 -0
  89. package/dist/resources/adaptiveBuffer.d.ts +22 -0
  90. package/dist/resources/adaptiveBuffer.d.ts.map +1 -0
  91. package/dist/resources/adaptiveBuffer.js +99 -0
  92. package/dist/resources/adaptiveBuffer.js.map +1 -0
  93. package/dist/resources/adaptiveSampler.d.ts +4 -0
  94. package/dist/resources/adaptiveSampler.d.ts.map +1 -0
  95. package/dist/resources/adaptiveSampler.js +73 -0
  96. package/dist/resources/adaptiveSampler.js.map +1 -0
  97. package/dist/resources/adaptiveTexture.d.ts +14 -0
  98. package/dist/resources/adaptiveTexture.d.ts.map +1 -0
  99. package/dist/resources/adaptiveTexture.js +265 -0
  100. package/dist/resources/adaptiveTexture.js.map +1 -0
  101. package/dist/resources/framebuffer.d.ts +14 -0
  102. package/dist/resources/framebuffer.d.ts.map +1 -0
  103. package/dist/resources/framebuffer.js +144 -0
  104. package/dist/resources/framebuffer.js.map +1 -0
  105. package/dist/resources/framebufferSignature.d.ts +10 -0
  106. package/dist/resources/framebufferSignature.d.ts.map +1 -0
  107. package/dist/resources/framebufferSignature.js +22 -0
  108. package/dist/resources/framebufferSignature.js.map +1 -0
  109. package/dist/resources/index.d.ts +14 -0
  110. package/dist/resources/index.d.ts.map +1 -0
  111. package/dist/resources/index.js +24 -0
  112. package/dist/resources/index.js.map +1 -0
  113. package/dist/resources/mipGen.d.ts +17 -0
  114. package/dist/resources/mipGen.d.ts.map +1 -0
  115. package/dist/resources/mipGen.js +125 -0
  116. package/dist/resources/mipGen.js.map +1 -0
  117. package/dist/resources/preparedComputeShader.d.ts +104 -0
  118. package/dist/resources/preparedComputeShader.d.ts.map +1 -0
  119. package/dist/resources/preparedComputeShader.js +341 -0
  120. package/dist/resources/preparedComputeShader.js.map +1 -0
  121. package/dist/resources/preparedRenderObject.d.ts +93 -0
  122. package/dist/resources/preparedRenderObject.d.ts.map +1 -0
  123. package/dist/resources/preparedRenderObject.js +541 -0
  124. package/dist/resources/preparedRenderObject.js.map +1 -0
  125. package/dist/resources/renderPipeline.d.ts +27 -0
  126. package/dist/resources/renderPipeline.d.ts.map +1 -0
  127. package/dist/resources/renderPipeline.js +102 -0
  128. package/dist/resources/renderPipeline.js.map +1 -0
  129. package/dist/resources/shaderDiagnostics.d.ts +14 -0
  130. package/dist/resources/shaderDiagnostics.d.ts.map +1 -0
  131. package/dist/resources/shaderDiagnostics.js +40 -0
  132. package/dist/resources/shaderDiagnostics.js.map +1 -0
  133. package/dist/resources/sourceMapDecoder.d.ts +23 -0
  134. package/dist/resources/sourceMapDecoder.d.ts.map +1 -0
  135. package/dist/resources/sourceMapDecoder.js +116 -0
  136. package/dist/resources/sourceMapDecoder.js.map +1 -0
  137. package/dist/resources/uniformBuffer.d.ts +23 -0
  138. package/dist/resources/uniformBuffer.d.ts.map +1 -0
  139. package/dist/resources/uniformBuffer.js +149 -0
  140. package/dist/resources/uniformBuffer.js.map +1 -0
  141. package/dist/resources/webgpuFlags.d.ts +32 -0
  142. package/dist/resources/webgpuFlags.d.ts.map +1 -0
  143. package/dist/resources/webgpuFlags.js +40 -0
  144. package/dist/resources/webgpuFlags.js.map +1 -0
  145. package/dist/runtime/copy.d.ts +3 -0
  146. package/dist/runtime/copy.d.ts.map +1 -0
  147. package/dist/runtime/copy.js +12 -0
  148. package/dist/runtime/copy.js.map +1 -0
  149. package/dist/runtime/index.d.ts +6 -0
  150. package/dist/runtime/index.d.ts.map +1 -0
  151. package/dist/runtime/index.js +7 -0
  152. package/dist/runtime/index.js.map +1 -0
  153. package/dist/runtime/renderTask.d.ts +10 -0
  154. package/dist/runtime/renderTask.d.ts.map +1 -0
  155. package/dist/runtime/renderTask.js +119 -0
  156. package/dist/runtime/renderTask.js.map +1 -0
  157. package/dist/runtime/renderTo.d.ts +40 -0
  158. package/dist/runtime/renderTo.d.ts.map +1 -0
  159. package/dist/runtime/renderTo.js +97 -0
  160. package/dist/runtime/renderTo.js.map +1 -0
  161. package/dist/runtime/runtime.d.ts +48 -0
  162. package/dist/runtime/runtime.d.ts.map +1 -0
  163. package/dist/runtime/runtime.js +100 -0
  164. package/dist/runtime/runtime.js.map +1 -0
  165. package/dist/runtime/scenePass.d.ts +25 -0
  166. package/dist/runtime/scenePass.d.ts.map +1 -0
  167. package/dist/runtime/scenePass.js +255 -0
  168. package/dist/runtime/scenePass.js.map +1 -0
  169. package/dist/window/canvas.d.ts +38 -0
  170. package/dist/window/canvas.d.ts.map +1 -0
  171. package/dist/window/canvas.js +194 -0
  172. package/dist/window/canvas.js.map +1 -0
  173. package/dist/window/index.d.ts +3 -0
  174. package/dist/window/index.d.ts.map +1 -0
  175. package/dist/window/index.js +4 -0
  176. package/dist/window/index.js.map +1 -0
  177. package/dist/window/loop.d.ts +16 -0
  178. package/dist/window/loop.d.ts.map +1 -0
  179. package/dist/window/loop.js +43 -0
  180. package/dist/window/loop.js.map +1 -0
  181. package/package.json +1 -1
  182. package/src/core/index.ts +10 -1
  183. package/src/core/pipelineState.ts +178 -24
  184. package/src/resources/preparedRenderObject.ts +271 -85
  185. package/src/runtime/scenePass.ts +6 -1
@@ -0,0 +1,3 @@
1
+ import type { ClearValues, IFramebuffer } from "../core/index.js";
2
+ export declare function clear(cmd: GPUCommandEncoder, output: IFramebuffer, values: ClearValues): void;
3
+ //# sourceMappingURL=clear.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,wBAAgB,KAAK,CACnB,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,WAAW,GAClB,IAAI,CAiDN"}
@@ -0,0 +1,69 @@
1
+ // clear(cmd, output, values) — open a render pass on `output`
2
+ // with `loadOp: "clear"` for the named attachments listed in
3
+ // `values`, and `loadOp: "load"` for the rest. End the pass
4
+ // immediately. This is the encoding for a `Clear` Command.
5
+ //
6
+ // Note that color clears are typed as `V4f | V4i | V4ui`; we
7
+ // translate to WebGPU's `GPUColorDict` (always `r/g/b/a` numbers)
8
+ // directly. WebGPU figures out the integer-vs-float interpretation
9
+ // from the texture's format.
10
+ export function clear(cmd, output, values) {
11
+ const colorAttachments = [];
12
+ for (const [name] of output.signature.colors) {
13
+ const view = output.colors.tryFind(name);
14
+ if (view === undefined) {
15
+ throw new Error(`clear: framebuffer is missing color attachment "${name}"`);
16
+ }
17
+ const cv = values.colors?.tryFind(name);
18
+ if (cv !== undefined) {
19
+ const d = cv;
20
+ colorAttachments.push({
21
+ view,
22
+ loadOp: "clear",
23
+ storeOp: "store",
24
+ clearValue: { r: d._data[0], g: d._data[1], b: d._data[2], a: d._data[3] },
25
+ });
26
+ }
27
+ else {
28
+ colorAttachments.push({ view, loadOp: "load", storeOp: "store" });
29
+ }
30
+ }
31
+ let depthStencilAttachment;
32
+ if (output.signature.depthStencil !== undefined) {
33
+ if (output.depthStencil === undefined) {
34
+ throw new Error("clear: signature has depthStencil but framebuffer.depthStencil is undefined");
35
+ }
36
+ const sig = output.signature.depthStencil;
37
+ const att = { view: output.depthStencil };
38
+ if (sig.hasDepth) {
39
+ if (values.depth !== undefined) {
40
+ att.depthLoadOp = "clear";
41
+ att.depthStoreOp = "store";
42
+ att.depthClearValue = values.depth;
43
+ }
44
+ else {
45
+ att.depthLoadOp = "load";
46
+ att.depthStoreOp = "store";
47
+ }
48
+ }
49
+ if (sig.hasStencil) {
50
+ if (values.stencil !== undefined) {
51
+ att.stencilLoadOp = "clear";
52
+ att.stencilStoreOp = "store";
53
+ att.stencilClearValue = values.stencil;
54
+ }
55
+ else {
56
+ att.stencilLoadOp = "load";
57
+ att.stencilStoreOp = "store";
58
+ }
59
+ }
60
+ depthStencilAttachment = att;
61
+ }
62
+ const desc = {
63
+ colorAttachments,
64
+ ...(depthStencilAttachment !== undefined ? { depthStencilAttachment } : {}),
65
+ };
66
+ const pass = cmd.beginRenderPass(desc);
67
+ pass.end();
68
+ }
69
+ //# sourceMappingURL=clear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear.js","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,6DAA6D;AAC7D,4DAA4D;AAC5D,2DAA2D;AAC3D,EAAE;AACF,6DAA6D;AAC7D,kEAAkE;AAClE,mEAAmE;AACnE,6BAA6B;AAI7B,MAAM,UAAU,KAAK,CACnB,GAAsB,EACtB,MAAoB,EACpB,MAAmB;IAEnB,MAAM,gBAAgB,GAAmC,EAAE,CAAC;IAC5D,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,mDAAmD,IAAI,GAAG,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,EAA6C,CAAC;YACxD,gBAAgB,CAAC,IAAI,CAAC;gBACpB,IAAI;gBACJ,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,OAAO;gBAChB,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CA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G,CAAC,aAAa,GAAG,MAAM,CAAC;gBAAC,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC;YAC3D,CAAC;QACH,CAAC;QACD,sBAAsB,GAAG,GAAG,CAAC;IAC/B,CAAC;IACD,MAAM,IAAI,GAA4B;QACpC,gBAAgB;QAChB,GAAG,CAAC,sBAAsB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,sBAAsB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5E,CAAC;IACF,MAAM,IAAI,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,GAAG,EAAE,CAAC;AACb,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { clear } from "./clear.js";
2
+ export { render, renderMany, beginPassDescriptor, type Recordable, } from "./render.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EACL,MAAM,EACN,UAAU,EACV,mBAAmB,EACnB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ // Public API of @aardworx/wombat.rendering-commands.
2
+ // Layer 3 — command-stream functions on `GPUCommandEncoder`.
3
+ export { clear } from "./clear.js";
4
+ export { render, renderMany, beginPassDescriptor, } from "./render.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,6DAA6D;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EACL,MAAM,EACN,UAAU,EACV,mBAAmB,GAEpB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { ClearValues, IFramebuffer } from "../core/index.js";
2
+ import type { AdaptiveToken } from "@aardworx/wombat.adaptive";
3
+ export interface Recordable {
4
+ record(pass: GPURenderPassEncoder, token: AdaptiveToken): void;
5
+ }
6
+ /**
7
+ * Build a render-pass descriptor for `output`. If `clear` is set,
8
+ * named attachments use `loadOp: "clear"` with the requested
9
+ * values; the rest fall back to `loadOp: "load"`. Used by
10
+ * `render` / `renderMany` and by the runtime walker's Clear+Render
11
+ * coalescing path.
12
+ */
13
+ export declare function beginPassDescriptor(output: IFramebuffer, clear?: ClearValues): GPURenderPassDescriptor;
14
+ export declare function render(cmd: GPUCommandEncoder, prepared: Recordable, output: IFramebuffer, token: AdaptiveToken, clear?: ClearValues): void;
15
+ export declare function renderMany(cmd: GPUCommandEncoder, prepared: readonly Recordable[], output: IFramebuffer, token: AdaptiveToken, clear?: ClearValues): void;
16
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/commands/render.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAK/D,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;CAChE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,uBAAuB,CAsDtG;AAED,wBAAgB,MAAM,CACpB,GAAG,EAAE,iBAAiB,EACtB,QAAQ,EAAE,UAAU,EACpB,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,aAAa,EACpB,KAAK,CAAC,EAAE,WAAW,GAClB,IAAI,CAIN;AAED,wBAAgB,UAAU,CACxB,GAAG,EAAE,iBAAiB,EACtB,QAAQ,EAAE,SAAS,UAAU,EAAE,EAC/B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,aAAa,EACpB,KAAK,CAAC,EAAE,WAAW,GAClB,IAAI,CAKN"}
@@ -0,0 +1,93 @@
1
+ // render(cmd, prepared, output, token) — open a render pass on
2
+ // `output` (loadOp = "load"; clears go through the `Clear` command),
3
+ // record the prepared object, end the pass.
4
+ //
5
+ // Multiple prepared objects can be batched into one pass via
6
+ // `renderMany(...)` — same pass, multiple `record` calls — which
7
+ // is the path the RenderTask walker uses for an `Ordered` /
8
+ // `Unordered` subtree of leaves all targeting the same FBO.
9
+ /**
10
+ * Build a render-pass descriptor for `output`. If `clear` is set,
11
+ * named attachments use `loadOp: "clear"` with the requested
12
+ * values; the rest fall back to `loadOp: "load"`. Used by
13
+ * `render` / `renderMany` and by the runtime walker's Clear+Render
14
+ * coalescing path.
15
+ */
16
+ export function beginPassDescriptor(output, clear) {
17
+ const colorAttachments = [];
18
+ const msaa = output.signature.sampleCount > 1;
19
+ for (const [name] of output.signature.colors) {
20
+ const view = output.colors.tryFind(name);
21
+ if (view === undefined) {
22
+ throw new Error(`render: framebuffer is missing color attachment "${name}"`);
23
+ }
24
+ const resolveTarget = msaa ? output.resolveColors?.tryFind(name) : undefined;
25
+ if (msaa && resolveTarget === undefined) {
26
+ throw new Error(`render: MSAA framebuffer is missing resolve target for "${name}"`);
27
+ }
28
+ const cv = clear?.colors?.tryFind(name);
29
+ if (cv !== undefined) {
30
+ const d = cv;
31
+ colorAttachments.push({
32
+ view, loadOp: "clear", storeOp: "store",
33
+ ...(resolveTarget !== undefined ? { resolveTarget } : {}),
34
+ clearValue: { r: d._data[0], g: d._data[1], b: d._data[2], a: d._data[3] },
35
+ });
36
+ }
37
+ else {
38
+ colorAttachments.push({
39
+ view, loadOp: "load", storeOp: "store",
40
+ ...(resolveTarget !== undefined ? { resolveTarget } : {}),
41
+ });
42
+ }
43
+ }
44
+ let depthStencilAttachment;
45
+ if (output.signature.depthStencil !== undefined) {
46
+ if (output.depthStencil === undefined) {
47
+ throw new Error("render: signature has depthStencil but framebuffer.depthStencil is undefined");
48
+ }
49
+ const sig = output.signature.depthStencil;
50
+ const att = { view: output.depthStencil };
51
+ if (sig.hasDepth) {
52
+ if (clear?.depth !== undefined) {
53
+ att.depthLoadOp = "clear";
54
+ att.depthStoreOp = "store";
55
+ att.depthClearValue = clear.depth;
56
+ }
57
+ else {
58
+ att.depthLoadOp = "load";
59
+ att.depthStoreOp = "store";
60
+ }
61
+ }
62
+ if (sig.hasStencil) {
63
+ if (clear?.stencil !== undefined) {
64
+ att.stencilLoadOp = "clear";
65
+ att.stencilStoreOp = "store";
66
+ att.stencilClearValue = clear.stencil;
67
+ }
68
+ else {
69
+ att.stencilLoadOp = "load";
70
+ att.stencilStoreOp = "store";
71
+ }
72
+ }
73
+ depthStencilAttachment = att;
74
+ }
75
+ return {
76
+ colorAttachments,
77
+ ...(depthStencilAttachment !== undefined ? { depthStencilAttachment } : {}),
78
+ };
79
+ }
80
+ export function render(cmd, prepared, output, token, clear) {
81
+ const pass = cmd.beginRenderPass(beginPassDescriptor(output, clear));
82
+ prepared.record(pass, token);
83
+ pass.end();
84
+ }
85
+ export function renderMany(cmd, prepared, output, token, clear) {
86
+ if (prepared.length === 0)
87
+ return;
88
+ const pass = cmd.beginRenderPass(beginPassDescriptor(output, clear));
89
+ for (const p of prepared)
90
+ p.record(pass, token);
91
+ pass.end();
92
+ }
93
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/commands/render.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,qEAAqE;AACrE,4CAA4C;AAC5C,EAAE;AACF,6DAA6D;AAC7D,iEAAiE;AACjE,4DAA4D;AAC5D,4DAA4D;AAY5D;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAoB,EAAE,KAAmB;IAC3E,MAAM,gBAAgB,GAAmC,EAAE,CAAC;IAC5D,MAAM,IAAI,GAAG,MAAM,CA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G,MAAM,CAAC;gBAAC,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC;YAC3D,CAAC;QACH,CAAC;QACD,sBAAsB,GAAG,GAAG,CAAC;IAC/B,CAAC;IACD,OAAO;QACL,gBAAgB;QAChB,GAAG,CAAC,sBAAsB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,sBAAsB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,MAAM,CACpB,GAAsB,EACtB,QAAoB,EACpB,MAAoB,EACpB,KAAoB,EACpB,KAAmB;IAEnB,MAAM,IAAI,GAAG,GAAG,CAAC,eAAe,CAAC,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IACrE,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,EAAE,CAAC;AACb,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,GAAsB,EACtB,QAA+B,EAC/B,MAAoB,EACpB,KAAoB,EACpB,KAAmB;IAEnB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAClC,MAAM,IAAI,GAAG,GAAG,CAAC,eAAe,CAAC,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IACrE,KAAK,MAAM,CAAC,IAAI,QAAQ;QAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChD,IAAI,CAAC,GAAG,EAAE,CAAC;AACb,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function tryAcquire(av: unknown): void;
2
+ export declare function tryRelease(av: unknown): void;
3
+ //# sourceMappingURL=acquire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acquire.d.ts","sourceRoot":"","sources":["../../src/core/acquire.ts"],"names":[],"mappings":"AAeA,wBAAgB,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAE5C;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAE5C"}
@@ -0,0 +1,22 @@
1
+ // tryAcquire / tryRelease — propagate acquire/release through
2
+ // the dependency graph. If a value is an `AdaptiveResource`, drive
3
+ // its lifetime; otherwise no-op. Used by wrapper resources
4
+ // (`prepareAdaptiveBuffer`, `prepareAdaptiveTexture`, …) so that
5
+ // when a downstream consumer acquires them, any upstream
6
+ // AdaptiveResources they read also get acquired.
7
+ //
8
+ // This is what makes `renderTo` work: the returned `aval<ITexture>`
9
+ // is an AdaptiveResource holding an FBO + inner RenderTask. When
10
+ // a downstream RenderObject's prepareAdaptiveTexture acquires its
11
+ // source, that source is the renderTo result, and the FBO + task
12
+ // come live automatically.
13
+ import { AdaptiveResource } from "./adaptiveResource.js";
14
+ export function tryAcquire(av) {
15
+ if (av instanceof AdaptiveResource)
16
+ av.acquire();
17
+ }
18
+ export function tryRelease(av) {
19
+ if (av instanceof AdaptiveResource)
20
+ av.release();
21
+ }
22
+ //# sourceMappingURL=acquire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acquire.js","sourceRoot":"","sources":["../../src/core/acquire.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,mEAAmE;AACnE,2DAA2D;AAC3D,iEAAiE;AACjE,yDAAyD;AACzD,iDAAiD;AACjD,EAAE;AACF,oEAAoE;AACpE,iEAAiE;AACjE,kEAAkE;AAClE,iEAAiE;AACjE,2BAA2B;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,UAAU,UAAU,CAAC,EAAW;IACpC,IAAI,EAAE,YAAY,gBAAgB;QAAE,EAAE,CAAC,OAAO,EAAE,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAW;IACpC,IAAI,EAAE,YAAY,gBAAgB;QAAE,EAAE,CAAC,OAAO,EAAE,CAAC;AACnD,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { AbstractVal, type AdaptiveToken } from "@aardworx/wombat.adaptive";
2
+ export declare abstract class AdaptiveResource<T> extends AbstractVal<T> {
3
+ private _refCount;
4
+ /** Allocate one-time GPU resources. Called on the 0→1 acquire. */
5
+ protected abstract create(): void;
6
+ /** Free GPU resources. Called on the 1→0 release. */
7
+ protected abstract destroy(): void;
8
+ /**
9
+ * The standard aval contract: produce the current handle for
10
+ * this resource. May read other adaptive inputs via `token` and
11
+ * may encode work onto `RenderContext.encoder` if one is active
12
+ * (uploads, compute dispatches, render-to-texture, ...).
13
+ */
14
+ abstract compute(token: AdaptiveToken): T;
15
+ acquire(): void;
16
+ release(): void;
17
+ /** True iff at least one consumer holds an acquire. */
18
+ get isActive(): boolean;
19
+ get refCount(): number;
20
+ /**
21
+ * Derive a new `AdaptiveResource<R>` whose lifetime forwards to
22
+ * `this`. Consumers of the derived resource transitively
23
+ * acquire/release `this`. Use this to expose structured outputs
24
+ * of a complex resource (e.g. the colour textures of a `renderTo`
25
+ * framebuffer) as individual `aval<ITexture>`s.
26
+ */
27
+ derive<R>(project: (t: T) => R): AdaptiveResource<R>;
28
+ }
29
+ //# sourceMappingURL=adaptiveResource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adaptiveResource.d.ts","sourceRoot":"","sources":["../../src/core/adaptiveResource.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAEnC,8BAAsB,gBAAgB,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IAC9D,OAAO,CAAC,SAAS,CAAK;IAEtB,kEAAkE;IAClE,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI;IACjC,qDAAqD;IACrD,SAAS,CAAC,QAAQ,CAAC,OAAO,IAAI,IAAI;IAClC;;;;;OAKG;aACe,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,CAAC;IAElD,OAAO,IAAI,IAAI;IAKf,OAAO,IAAI,IAAI;IAQf,uDAAuD;IACvD,IAAI,QAAQ,IAAI,OAAO,CAA+B;IACtD,IAAI,QAAQ,IAAI,MAAM,CAA2B;IAEjD;;;;;;OAMG;IACH,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC;CAGrD"}
@@ -0,0 +1,73 @@
1
+ // AdaptiveResource<T> — a ref-counted, adaptively-updated GPU
2
+ // handle that **is itself an `aval<T>`**. Lifted directly from
3
+ // Aardvark.Base's `AdaptiveResource<'a>`.
4
+ //
5
+ // The shape lets `runtime.renderTo(scene, size) → aval<ITexture>`
6
+ // work the way Aardvark.Rendering's `RenderTask.renderTo` works:
7
+ // a downstream consumer treats it like any other `aval<ITexture>`,
8
+ // the FBO is allocated lazily on first `acquire`, and torn down
9
+ // when the last consumer releases.
10
+ //
11
+ // Lifecycle:
12
+ // acquire() — refCount++. On 0→1 transition, calls `create()`,
13
+ // which is where one-time setup happens (allocate
14
+ // an FBO, register input subscriptions, etc.).
15
+ // getValue(token) — the standard aval contract. Calls
16
+ // `compute(token)`, which is where adaptive work
17
+ // lives (re-render scene if size or scene changed,
18
+ // return the texture handle). May encode commands
19
+ // on the currently-active `RenderContext.encoder`.
20
+ // release() — refCount--. On 1→0 transition, calls `destroy()`,
21
+ // which frees the GPU resources.
22
+ //
23
+ // Subscribing to value changes (`addCallback`) does **not** acquire
24
+ // — acquisition is an explicit lifetime concern and a subscription
25
+ // alone does not justify keeping GPU memory live. The runtime's
26
+ // RenderTask compilation walks its referenced AdaptiveResources
27
+ // and acquires them at task-construction time, releases them on
28
+ // task disposal.
29
+ import { AbstractVal, } from "@aardworx/wombat.adaptive";
30
+ export class AdaptiveResource extends AbstractVal {
31
+ _refCount = 0;
32
+ acquire() {
33
+ this._refCount++;
34
+ if (this._refCount === 1)
35
+ this.create();
36
+ }
37
+ release() {
38
+ if (this._refCount <= 0) {
39
+ throw new Error("AdaptiveResource: release without matching acquire");
40
+ }
41
+ this._refCount--;
42
+ if (this._refCount === 0)
43
+ this.destroy();
44
+ }
45
+ /** True iff at least one consumer holds an acquire. */
46
+ get isActive() { return this._refCount > 0; }
47
+ get refCount() { return this._refCount; }
48
+ /**
49
+ * Derive a new `AdaptiveResource<R>` whose lifetime forwards to
50
+ * `this`. Consumers of the derived resource transitively
51
+ * acquire/release `this`. Use this to expose structured outputs
52
+ * of a complex resource (e.g. the colour textures of a `renderTo`
53
+ * framebuffer) as individual `aval<ITexture>`s.
54
+ */
55
+ derive(project) {
56
+ return new DerivedAdaptiveResource(this, project);
57
+ }
58
+ }
59
+ class DerivedAdaptiveResource extends AdaptiveResource {
60
+ parent;
61
+ project;
62
+ constructor(parent, project) {
63
+ super();
64
+ this.parent = parent;
65
+ this.project = project;
66
+ }
67
+ create() { this.parent.acquire(); }
68
+ destroy() { this.parent.release(); }
69
+ compute(token) {
70
+ return this.project(this.parent.getValue(token));
71
+ }
72
+ }
73
+ //# sourceMappingURL=adaptiveResource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adaptiveResource.js","sourceRoot":"","sources":["../../src/core/adaptiveResource.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,+DAA+D;AAC/D,0CAA0C;AAC1C,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,mEAAmE;AACnE,gEAAgE;AAChE,mCAAmC;AACnC,EAAE;AACF,aAAa;AACb,kEAAkE;AAClE,iEAAiE;AACjE,8DAA8D;AAC9D,wDAAwD;AACxD,gEAAgE;AAChE,kEAAkE;AAClE,iEAAiE;AACjE,kEAAkE;AAClE,mEAAmE;AACnE,gDAAgD;AAChD,EAAE;AACF,oEAAoE;AACpE,mEAAmE;AACnE,gEAAgE;AAChE,gEAAgE;AAChE,gEAAgE;AAChE,iBAAiB;AAEjB,OAAO,EACL,WAAW,GAEZ,MAAM,2BAA2B,CAAC;AAEnC,MAAM,OAAgB,gBAAoB,SAAQ,WAAc;I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;
2
+ export type IBuffer = {
3
+ readonly kind: "gpu";
4
+ readonly buffer: GPUBuffer;
5
+ readonly sizeBytes: number;
6
+ } | {
7
+ readonly kind: "host";
8
+ readonly data: HostBufferSource;
9
+ readonly sizeBytes: number;
10
+ };
11
+ export declare const IBuffer: {
12
+ readonly fromGPU: (buffer: GPUBuffer, sizeBytes?: number) => IBuffer;
13
+ /**
14
+ * Wrap a host-side `ArrayBuffer` / `ArrayBufferView`. Pass any
15
+ * wombat.base packed array's `.buffer` directly, or a `Float32Array`,
16
+ * etc.
17
+ */
18
+ readonly fromHost: (data: HostBufferSource) => IBuffer;
19
+ };
20
+ //# sourceMappingURL=buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/core/buffer.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,eAAe,CAAC;AAE7D,MAAM,MAAM,OAAO,GACf;IACE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEN,eAAO,MAAM,OAAO;+BACF,SAAS,cAAc,MAAM,KAAG,OAAO;IAGvD;;;;OAIG;8BACY,gBAAgB,KAAG,OAAO;CAOjC,CAAC"}
@@ -0,0 +1,30 @@
1
+ // IBuffer — a buffer source that can be either a real GPU buffer
2
+ // or host-side memory (an ArrayBuffer, a TypedArray, or a packed
3
+ // view from wombat.base such as `V2fArray._data` or `arr.buffer`).
4
+ //
5
+ // The user is free to mix and match: an `aval<IBuffer>` can flip
6
+ // between `gpu` and `host` over its lifetime, and the rendering
7
+ // layer transparently handles the upload when a `host` value is
8
+ // observed.
9
+ //
10
+ // `host.data` is typed as `BufferSource` (DOM standard) which
11
+ // admits `ArrayBuffer`, `SharedArrayBuffer`, and any
12
+ // `ArrayBufferView` — covering wombat.base's packed array views
13
+ // that expose a `.buffer` (ArrayBuffer) or a typed array directly.
14
+ export const IBuffer = {
15
+ fromGPU(buffer, sizeBytes) {
16
+ return { kind: "gpu", buffer, sizeBytes: sizeBytes ?? buffer.size };
17
+ },
18
+ /**
19
+ * Wrap a host-side `ArrayBuffer` / `ArrayBufferView`. Pass any
20
+ * wombat.base packed array's `.buffer` directly, or a `Float32Array`,
21
+ * etc.
22
+ */
23
+ fromHost(data) {
24
+ const sizeBytes = data instanceof ArrayBuffer
25
+ ? data.byteLength
26
+ : data.byteLength;
27
+ return { kind: "host", data, sizeBytes };
28
+ },
29
+ };
30
+ //# sourceMappingURL=buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../src/core/buffer.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,iEAAiE;AACjE,mEAAmE;AACnE,EAAE;AACF,iEAAiE;AACjE,gEAAgE;AAChE,gEAAgE;AAChE,YAAY;AACZ,EAAE;AACF,8DAA8D;AAC9D,qDAAqD;AACrD,gEAAgE;AAChE,mEAAmE;AAgBnE,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO,CAAC,MAAiB,EAAE,SAAkB;QAC3C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;IACtE,CAAC;IACD;;;;OAIG;IACH,QAAQ,CAAC,IAAsB;QAC7B,MAAM,SAAS,GACb,IAAI,YAAY,WAAW;YACzB,CAAC,CAAC,IAAI,CAAC,UAAU;YACjB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC3C,CAAC;CACO,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { IBuffer } from "./buffer.js";
2
+ export interface BufferView {
3
+ readonly buffer: IBuffer;
4
+ /** Byte offset into `buffer` where the view starts. */
5
+ readonly offset: number;
6
+ /** Number of elements (not bytes) in the view. */
7
+ readonly count: number;
8
+ /** Stride between consecutive elements, in bytes. */
9
+ readonly stride: number;
10
+ /** Vertex format — used when bound as a vertex / instance attribute. */
11
+ readonly format: GPUVertexFormat | GPUIndexFormat;
12
+ /** Index format — used when bound as an index buffer. Overrides `format`. */
13
+ readonly indexFormat?: GPUIndexFormat;
14
+ }
15
+ //# sourceMappingURL=bufferView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferView.d.ts","sourceRoot":"","sources":["../../src/core/bufferView.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CAAC;IAClD,6EAA6E;IAC7E,QAAQ,CAAC,WAAW,CAAC,EAAE,cAAc,CAAC;CACvC"}
@@ -0,0 +1,12 @@
1
+ // BufferView — a typed slice of an `IBuffer` used as a vertex
2
+ // attribute, instance attribute, or index source. The buffer
3
+ // itself can be a real GPU buffer or host-side memory; the
4
+ // runtime handles upload transparently.
5
+ //
6
+ // `format` carries the WebGPU vertex format when this view is
7
+ // bound as a vertex / instance attribute. `indexFormat` is set
8
+ // when the view is bound as an index buffer; in that case
9
+ // `format` is ignored. Both are optional so callers don't have
10
+ // to fill in the irrelevant one.
11
+ export {};
12
+ //# sourceMappingURL=bufferView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferView.js","sourceRoot":"","sources":["../../src/core/bufferView.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,6DAA6D;AAC7D,2DAA2D;AAC3D,wCAAwC;AACxC,EAAE;AACF,8DAA8D;AAC9D,+DAA+D;AAC/D,0DAA0D;AAC1D,+DAA+D;AAC/D,iCAAiC"}
@@ -0,0 +1,9 @@
1
+ import type { HashMap } from "@aardworx/wombat.adaptive";
2
+ import type { V4f, V4i, V4ui } from "@aardworx/wombat.base";
3
+ export type ClearColor = V4f | V4i | V4ui;
4
+ export interface ClearValues {
5
+ readonly colors?: HashMap<string, ClearColor>;
6
+ readonly depth?: number;
7
+ readonly stencil?: number;
8
+ }
9
+ //# sourceMappingURL=clear.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/core/clear.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;AAE1C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC9C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B"}
@@ -0,0 +1,7 @@
1
+ // ClearValues — per-attachment, name-keyed clear specification.
2
+ // Color clears are typed as V4f / V4i / V4ui to match the
3
+ // attachment's format; depth and stencil are plain numbers since
4
+ // WebGPU's GPURenderPassDepthStencilAttachment takes scalars.
5
+ // Attachments not named in `colors` keep their previous contents.
6
+ export {};
7
+ //# sourceMappingURL=clear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear.js","sourceRoot":"","sources":["../../src/core/clear.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,0DAA0D;AAC1D,iEAAiE;AACjE,8DAA8D;AAC9D,kEAAkE"}
@@ -0,0 +1,45 @@
1
+ import type { aval } from "@aardworx/wombat.adaptive";
2
+ import type { ClearValues } from "./clear.js";
3
+ import type { IFramebuffer } from "./framebuffer.js";
4
+ import type { RenderTree } from "./renderTree.js";
5
+ export interface BufferCopyRange {
6
+ readonly srcOffset: number;
7
+ readonly dstOffset: number;
8
+ readonly size: number;
9
+ }
10
+ export interface BufferCopy {
11
+ readonly kind: "buffer";
12
+ readonly src: GPUBuffer;
13
+ readonly dst: GPUBuffer;
14
+ readonly range?: BufferCopyRange;
15
+ }
16
+ export interface TextureCopy {
17
+ readonly kind: "texture";
18
+ readonly src: GPUImageCopyTexture;
19
+ readonly dst: GPUImageCopyTexture;
20
+ readonly size: GPUExtent3DStrict;
21
+ }
22
+ export type CopySpec = BufferCopy | TextureCopy;
23
+ /**
24
+ * `Render` and `Clear` take an `aval<IFramebuffer>` for their output
25
+ * so that swap-chain framebuffers (which produce a fresh
26
+ * `GPUTextureView` every animation frame) flow through cleanly.
27
+ * For static FBOs, wrap with `cval(...)` from `@aardworx/wombat.adaptive`
28
+ * — the runtime evaluates the aval per frame.
29
+ */
30
+ export type Command = {
31
+ readonly kind: "Render";
32
+ readonly output: aval<IFramebuffer>;
33
+ readonly tree: RenderTree;
34
+ } | {
35
+ readonly kind: "Clear";
36
+ readonly output: aval<IFramebuffer>;
37
+ readonly values: ClearValues;
38
+ } | {
39
+ readonly kind: "Copy";
40
+ readonly copy: CopySpec;
41
+ } | {
42
+ readonly kind: "Custom";
43
+ readonly encode: (cmd: GPUCommandEncoder) => void;
44
+ };
45
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version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AAC;IAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GAC7F;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,IAAI,CAAA;CAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ // Command — the per-frame primitive consumed by `runtime.compile`.
2
+ // Four kinds:
3
+ // Render: encode a RenderTree into an FBO.
4
+ // Clear: clear individual named attachments of an FBO.
5
+ // Copy: buffer↔buffer / texture↔texture transfers.
6
+ // Custom: escape hatch — receives the raw GPUCommandEncoder.
7
+ //
8
+ // Compute and Upload are NOT commands; they live inside
9
+ // AdaptiveResource update logic and run implicitly when a Render
10
+ // command needs a dirty resource.
11
+ export {};
12
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/core/command.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,cAAc;AACd,6CAA6C;AAC7C,0DAA0D;AAC1D,uDAAuD;AACvD,+DAA+D;AAC/D,EAAE;AACF,wDAAwD;AACxD,iEAAiE;AACjE,kCAAkC"}
@@ -0,0 +1,17 @@
1
+ export interface IndexedDrawCall {
2
+ readonly kind: "indexed";
3
+ readonly indexCount: number;
4
+ readonly instanceCount: number;
5
+ readonly firstIndex: number;
6
+ readonly baseVertex: number;
7
+ readonly firstInstance: number;
8
+ }
9
+ export interface NonIndexedDrawCall {
10
+ readonly kind: "non-indexed";
11
+ readonly vertexCount: number;
12
+ readonly instanceCount: number;
13
+ readonly firstVertex: number;
14
+ readonly firstInstance: number;
15
+ }
16
+ export type DrawCall = IndexedDrawCall | NonIndexedDrawCall;
17
+ //# sourceMappingURL=drawCall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawCall.d.ts","sourceRoot":"","sources":["../../src/core/drawCall.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,MAAM,QAAQ,GAAG,eAAe,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,5 @@
1
+ // DrawCall — what to actually draw, once the pipeline + bindings
2
+ // are bound. Indexed and non-indexed variants; both can be
3
+ // instanced.
4
+ export {};
5
+ //# sourceMappingURL=drawCall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawCall.js","sourceRoot":"","sources":["../../src/core/drawCall.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,2DAA2D;AAC3D,aAAa"}