@aardworx/wombat.rendering 0.1.0 → 0.1.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.
- package/dist/commands/clear.d.ts +3 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +69 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +5 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/render.d.ts +16 -0
- package/dist/commands/render.d.ts.map +1 -0
- package/dist/commands/render.js +93 -0
- package/dist/commands/render.js.map +1 -0
- package/dist/core/acquire.d.ts +3 -0
- package/dist/core/acquire.d.ts.map +1 -0
- package/dist/core/acquire.js +22 -0
- package/dist/core/acquire.js.map +1 -0
- package/dist/core/adaptiveResource.d.ts +29 -0
- package/dist/core/adaptiveResource.d.ts.map +1 -0
- package/dist/core/adaptiveResource.js +73 -0
- package/dist/core/adaptiveResource.js.map +1 -0
- package/dist/core/buffer.d.ts +20 -0
- package/dist/core/buffer.d.ts.map +1 -0
- package/dist/core/buffer.js +30 -0
- package/dist/core/buffer.js.map +1 -0
- package/dist/core/bufferView.d.ts +15 -0
- package/dist/core/bufferView.d.ts.map +1 -0
- package/dist/core/bufferView.js +12 -0
- package/dist/core/bufferView.js.map +1 -0
- package/dist/core/clear.d.ts +9 -0
- package/dist/core/clear.d.ts.map +1 -0
- package/dist/core/clear.js +7 -0
- package/dist/core/clear.js.map +1 -0
- package/dist/core/command.d.ts +45 -0
- package/dist/core/command.d.ts.map +1 -0
- package/dist/core/command.js +12 -0
- package/dist/core/command.js.map +1 -0
- package/dist/core/drawCall.d.ts +17 -0
- package/dist/core/drawCall.d.ts.map +1 -0
- package/dist/core/drawCall.js +5 -0
- package/dist/core/drawCall.js.map +1 -0
- package/dist/core/framebuffer.d.ts +32 -0
- package/dist/core/framebuffer.d.ts.map +1 -0
- package/dist/core/framebuffer.js +6 -0
- package/dist/core/framebuffer.js.map +1 -0
- package/dist/core/framebufferSignature.d.ts +12 -0
- package/dist/core/framebufferSignature.d.ts.map +1 -0
- package/dist/core/framebufferSignature.js +7 -0
- package/dist/core/framebufferSignature.js.map +1 -0
- package/dist/core/index.d.ts +20 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/pipelineState.d.ts +56 -0
- package/dist/core/pipelineState.d.ts.map +1 -0
- package/dist/core/pipelineState.js +6 -0
- package/dist/core/pipelineState.js.map +1 -0
- package/dist/core/renderContext.d.ts +8 -0
- package/dist/core/renderContext.d.ts.map +1 -0
- package/dist/core/renderContext.js +39 -0
- package/dist/core/renderContext.js.map +1 -0
- package/dist/core/renderObject.d.ts +45 -0
- package/dist/core/renderObject.d.ts.map +1 -0
- package/dist/core/renderObject.js +11 -0
- package/dist/core/renderObject.js.map +1 -0
- package/dist/core/renderTask.d.ts +12 -0
- package/dist/core/renderTask.d.ts.map +1 -0
- package/dist/core/renderTask.js +5 -0
- package/dist/core/renderTask.js.map +1 -0
- package/dist/core/renderTree.d.ts +35 -0
- package/dist/core/renderTree.d.ts.map +1 -0
- package/dist/core/renderTree.js +17 -0
- package/dist/core/renderTree.js.map +1 -0
- package/dist/core/sampler.d.ts +12 -0
- package/dist/core/sampler.d.ts.map +1 -0
- package/dist/core/sampler.js +8 -0
- package/dist/core/sampler.js.map +1 -0
- package/dist/core/shader.d.ts +3 -0
- package/dist/core/shader.d.ts.map +1 -0
- package/dist/core/shader.js +6 -0
- package/dist/core/shader.js.map +1 -0
- package/dist/core/texture.d.ts +34 -0
- package/dist/core/texture.d.ts.map +1 -0
- package/dist/core/texture.js +29 -0
- package/dist/core/texture.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/adaptiveBuffer.d.ts +22 -0
- package/dist/resources/adaptiveBuffer.d.ts.map +1 -0
- package/dist/resources/adaptiveBuffer.js +99 -0
- package/dist/resources/adaptiveBuffer.js.map +1 -0
- package/dist/resources/adaptiveSampler.d.ts +4 -0
- package/dist/resources/adaptiveSampler.d.ts.map +1 -0
- package/dist/resources/adaptiveSampler.js +73 -0
- package/dist/resources/adaptiveSampler.js.map +1 -0
- package/dist/resources/adaptiveTexture.d.ts +14 -0
- package/dist/resources/adaptiveTexture.d.ts.map +1 -0
- package/dist/resources/adaptiveTexture.js +265 -0
- package/dist/resources/adaptiveTexture.js.map +1 -0
- package/dist/resources/framebuffer.d.ts +14 -0
- package/dist/resources/framebuffer.d.ts.map +1 -0
- package/dist/resources/framebuffer.js +144 -0
- package/dist/resources/framebuffer.js.map +1 -0
- package/dist/resources/framebufferSignature.d.ts +10 -0
- package/dist/resources/framebufferSignature.d.ts.map +1 -0
- package/dist/resources/framebufferSignature.js +22 -0
- package/dist/resources/framebufferSignature.js.map +1 -0
- package/dist/resources/index.d.ts +14 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +24 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/mipGen.d.ts +17 -0
- package/dist/resources/mipGen.d.ts.map +1 -0
- package/dist/resources/mipGen.js +125 -0
- package/dist/resources/mipGen.js.map +1 -0
- package/dist/resources/preparedComputeShader.d.ts +104 -0
- package/dist/resources/preparedComputeShader.d.ts.map +1 -0
- package/dist/resources/preparedComputeShader.js +341 -0
- package/dist/resources/preparedComputeShader.js.map +1 -0
- package/dist/resources/preparedRenderObject.d.ts +61 -0
- package/dist/resources/preparedRenderObject.d.ts.map +1 -0
- package/dist/resources/preparedRenderObject.js +430 -0
- package/dist/resources/preparedRenderObject.js.map +1 -0
- package/dist/resources/renderPipeline.d.ts +27 -0
- package/dist/resources/renderPipeline.d.ts.map +1 -0
- package/dist/resources/renderPipeline.js +102 -0
- package/dist/resources/renderPipeline.js.map +1 -0
- package/dist/resources/shaderDiagnostics.d.ts +14 -0
- package/dist/resources/shaderDiagnostics.d.ts.map +1 -0
- package/dist/resources/shaderDiagnostics.js +40 -0
- package/dist/resources/shaderDiagnostics.js.map +1 -0
- package/dist/resources/sourceMapDecoder.d.ts +23 -0
- package/dist/resources/sourceMapDecoder.d.ts.map +1 -0
- package/dist/resources/sourceMapDecoder.js +116 -0
- package/dist/resources/sourceMapDecoder.js.map +1 -0
- package/dist/resources/uniformBuffer.d.ts +23 -0
- package/dist/resources/uniformBuffer.d.ts.map +1 -0
- package/dist/resources/uniformBuffer.js +149 -0
- package/dist/resources/uniformBuffer.js.map +1 -0
- package/dist/resources/webgpuFlags.d.ts +32 -0
- package/dist/resources/webgpuFlags.d.ts.map +1 -0
- package/dist/resources/webgpuFlags.js +40 -0
- package/dist/resources/webgpuFlags.js.map +1 -0
- package/dist/runtime/copy.d.ts +3 -0
- package/dist/runtime/copy.d.ts.map +1 -0
- package/dist/runtime/copy.js +12 -0
- package/dist/runtime/copy.js.map +1 -0
- package/dist/runtime/index.d.ts +6 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/renderTask.d.ts +10 -0
- package/dist/runtime/renderTask.d.ts.map +1 -0
- package/dist/runtime/renderTask.js +119 -0
- package/dist/runtime/renderTask.js.map +1 -0
- package/dist/runtime/renderTo.d.ts +40 -0
- package/dist/runtime/renderTo.d.ts.map +1 -0
- package/dist/runtime/renderTo.js +97 -0
- package/dist/runtime/renderTo.js.map +1 -0
- package/dist/runtime/runtime.d.ts +48 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +100 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/runtime/scenePass.d.ts +25 -0
- package/dist/runtime/scenePass.d.ts.map +1 -0
- package/dist/runtime/scenePass.js +250 -0
- package/dist/runtime/scenePass.js.map +1 -0
- package/dist/window/canvas.d.ts +38 -0
- package/dist/window/canvas.d.ts.map +1 -0
- package/dist/window/canvas.js +194 -0
- package/dist/window/canvas.js.map +1 -0
- package/dist/window/index.d.ts +3 -0
- package/dist/window/index.d.ts.map +1 -0
- package/dist/window/index.js +4 -0
- package/dist/window/index.js.map +1 -0
- package/dist/window/loop.d.ts +16 -0
- package/dist/window/loop.d.ts.map +1 -0
- package/dist/window/loop.js +43 -0
- package/dist/window/loop.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderTask.js","sourceRoot":"","sources":["../../src/runtime/renderTask.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,eAAe;AACf,EAAE;AACF,kEAAkE;AAClE,0DAA0D;AAC1D,qEAAqE;AACrE,iEAAiE;AACjE,+DAA+D;AAC/D,uEAAuE;AACvE,EAAE;AACF,oEAAoE;AACpE,mEAAmE;AACnE,uDAAuD;AAEvD,OAAO,EACL,aAAa,GAQd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAyB,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,MAAM,UAAU;IAWK;IACA;IAXnB;;;;;OAKG;IACc,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IACjD,SAAS,GAAG,KAAK,CAAC;IAE1B,YACmB,GAAmB,EACnB,QAAwB;QADxB,QAAG,GAAH,GAAG,CAAgB;QACnB,aAAQ,GAAR,QAAQ,CAAgB;IACxC,CAAC;IAEJ,GAAG,CAAC,KAAoB;QACtB,IAAI,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACnD,IA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AAG,CAAC,eAAe,CAAC,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;QAC3E,KAAK,MAAM,IAAI,IAAI,MAAM;YAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACpD,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;IAEO,QAAQ,CACd,GAAyC,EACzC,MAAoB,EACpB,IAAgB;QAEhB,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACpB,CAAC,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YACnF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,CAAC,CAAC;QACT,yDAAyD;QACzD,8DAA8D;QAC9D,2DAA2D;QAC3D,4DAA4D;QAC5D,sDAAsD;IACxD,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAmB,EAAE,QAAwB;IAG7E,OAAO,IAAI,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAED,mEAAmE;AACnE,+DAA+D;AAC/D,MAAM,UAAU,GAA6C,SAAS,CAAC;AACvE,KAAK,UAAU,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AdaptiveResource, ITexture, type ClearValues, type FramebufferSignature, type IFramebuffer, type RenderTree } from "../core/index.js";
|
|
2
|
+
import { type FramebufferSize } from "../resources/index.js";
|
|
3
|
+
import { HashMap, type aval } from "@aardworx/wombat.adaptive";
|
|
4
|
+
import type { RuntimeContext } from "./renderTask.js";
|
|
5
|
+
export interface RenderToOptions {
|
|
6
|
+
readonly size: aval<FramebufferSize>;
|
|
7
|
+
readonly signature: FramebufferSignature;
|
|
8
|
+
/** What to clear the FBO with each frame. Omit to skip the clear pass. */
|
|
9
|
+
readonly clear?: ClearValues;
|
|
10
|
+
readonly label?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Extra GPU texture usage flags for every color attachment.
|
|
13
|
+
* `RENDER_ATTACHMENT | TEXTURE_BINDING` are always set; pass
|
|
14
|
+
* `COPY_SRC` here to enable readback, `STORAGE_BINDING` for
|
|
15
|
+
* compute writes, etc.
|
|
16
|
+
*/
|
|
17
|
+
readonly extraUsage?: GPUTextureUsageFlags;
|
|
18
|
+
}
|
|
19
|
+
export interface RenderToResult {
|
|
20
|
+
/** The full framebuffer resource. Acquire/release for explicit lifetime control. */
|
|
21
|
+
readonly framebuffer: AdaptiveResource<IFramebuffer>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns an `aval<ITexture>` for the named color attachment.
|
|
24
|
+
* The aval is itself an AdaptiveResource — acquiring it
|
|
25
|
+
* activates the render-to pipeline.
|
|
26
|
+
*/
|
|
27
|
+
color(name: string): AdaptiveResource<ITexture>;
|
|
28
|
+
/**
|
|
29
|
+
* Convenience for multi-target render passes: returns a
|
|
30
|
+
* `HashMap<string, aval<ITexture>>` covering every color
|
|
31
|
+
* attachment in the signature. Each entry shares the underlying
|
|
32
|
+
* lifetime — acquiring any (or the whole map's entries) activates
|
|
33
|
+
* the render-to pipeline.
|
|
34
|
+
*/
|
|
35
|
+
colors(): HashMap<string, AdaptiveResource<ITexture>>;
|
|
36
|
+
/** Returns the depth-stencil attachment as an `ITexture` (if the signature has one). */
|
|
37
|
+
depthStencil(): AdaptiveResource<ITexture>;
|
|
38
|
+
}
|
|
39
|
+
export declare function renderTo(ctx: RuntimeContext, scene: RenderTree, opts: RenderToOptions): RenderToResult;
|
|
40
|
+
//# sourceMappingURL=renderTo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderTo.d.ts","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`RenderTask.renderTo` ported.
|
|
2
|
+
//
|
|
3
|
+
// Usage:
|
|
4
|
+
// const result = renderTo(ctx, scene, { size, signature, clear });
|
|
5
|
+
// const colorAval: aval<ITexture> = result.color("color");
|
|
6
|
+
// // bind colorAval as a texture on a downstream RenderObject
|
|
7
|
+
//
|
|
8
|
+
// `result.framebuffer` is an `AdaptiveResource<IFramebuffer>` that:
|
|
9
|
+
// - Allocates the FBO on first acquire.
|
|
10
|
+
// - On `compute(token)`: reads `size`, encodes a clear pass +
|
|
11
|
+
// scene render into the active `RenderContext.encoder`, returns
|
|
12
|
+
// the FBO. Encoding only runs when an outer encoder is active;
|
|
13
|
+
// when read outside a frame the FBO is returned untouched.
|
|
14
|
+
// - On last release: disposes the inner cache and frees the FBO.
|
|
15
|
+
//
|
|
16
|
+
// Each `result.color(name)` is a derived `aval<ITexture>` whose
|
|
17
|
+
// lifetime forwards to `framebuffer`, so consuming any attachment
|
|
18
|
+
// keeps the whole pipeline alive.
|
|
19
|
+
import { AdaptiveResource, ITexture, RenderContext, } from "../core/index.js";
|
|
20
|
+
import { allocateFramebuffer, } from "../resources/index.js";
|
|
21
|
+
import { beginPassDescriptor } from "../commands/index.js";
|
|
22
|
+
import { HashMap } from "@aardworx/wombat.adaptive";
|
|
23
|
+
import { ScenePass } from "./scenePass.js";
|
|
24
|
+
class RenderToFramebuffer extends AdaptiveResource {
|
|
25
|
+
ctx;
|
|
26
|
+
fbo;
|
|
27
|
+
scene;
|
|
28
|
+
clearValues;
|
|
29
|
+
signature;
|
|
30
|
+
scenePass;
|
|
31
|
+
constructor(ctx, fbo, scene, clearValues, signature) {
|
|
32
|
+
super();
|
|
33
|
+
this.ctx = ctx;
|
|
34
|
+
this.fbo = fbo;
|
|
35
|
+
this.scene = scene;
|
|
36
|
+
this.clearValues = clearValues;
|
|
37
|
+
this.signature = signature;
|
|
38
|
+
}
|
|
39
|
+
create() {
|
|
40
|
+
this.fbo.acquire();
|
|
41
|
+
this.scenePass = new ScenePass(this.ctx.device, this.signature, this.scene, this.ctx.compileEffect);
|
|
42
|
+
}
|
|
43
|
+
destroy() {
|
|
44
|
+
this.scenePass?.dispose();
|
|
45
|
+
this.scenePass = undefined;
|
|
46
|
+
this.fbo.release();
|
|
47
|
+
}
|
|
48
|
+
compute(token) {
|
|
49
|
+
const fb = this.fbo.getValue(token);
|
|
50
|
+
const enc = RenderContext.encoder;
|
|
51
|
+
if (enc !== null && this.scenePass !== undefined) {
|
|
52
|
+
const leaves = this.scenePass.resolve(token);
|
|
53
|
+
if (leaves.length > 0 || this.clearValues !== undefined) {
|
|
54
|
+
const pass = enc.beginRenderPass(beginPassDescriptor(fb, this.clearValues));
|
|
55
|
+
for (const leaf of leaves)
|
|
56
|
+
leaf.record(pass, token);
|
|
57
|
+
pass.end();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return fb;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function renderTo(ctx, scene, opts) {
|
|
64
|
+
const fbo = allocateFramebuffer(ctx.device, opts.signature, opts.size, {
|
|
65
|
+
...(opts.label !== undefined ? { labelPrefix: opts.label } : {}),
|
|
66
|
+
...(opts.extraUsage !== undefined ? { extraUsage: opts.extraUsage } : {}),
|
|
67
|
+
});
|
|
68
|
+
const renderToFbo = new RenderToFramebuffer(ctx, fbo, scene, opts.clear, opts.signature);
|
|
69
|
+
return {
|
|
70
|
+
framebuffer: renderToFbo,
|
|
71
|
+
color(name) {
|
|
72
|
+
return renderToFbo.derive(fb => {
|
|
73
|
+
const tex = fb.colorTextures?.tryFind(name);
|
|
74
|
+
if (tex === undefined) {
|
|
75
|
+
throw new Error(`renderTo.color: framebuffer has no color attachment "${name}"`);
|
|
76
|
+
}
|
|
77
|
+
return ITexture.fromGPU(tex);
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
colors() {
|
|
81
|
+
let out = HashMap.empty();
|
|
82
|
+
for (const [name] of opts.signature.colors) {
|
|
83
|
+
out = out.add(name, this.color(name));
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
},
|
|
87
|
+
depthStencil() {
|
|
88
|
+
return renderToFbo.derive(fb => {
|
|
89
|
+
if (fb.depthStencilTexture === undefined) {
|
|
90
|
+
throw new Error("renderTo.depthStencil: framebuffer has no depth-stencil attachment");
|
|
91
|
+
}
|
|
92
|
+
return ITexture.fromGPU(fb.depthStencilTexture);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=renderTo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderTo.js","sourceRoot":"","sources":["../../src/runtime/renderTo.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,SAAS;AACT,qEAAqE;AACrE,6DAA6D;AAC7D,gEAAgE;AAChE,EAAE;AACF,oEAAoE;AACpE,0CAA0C;AAC1C,gEAAgE;AAChE,oEAAoE;AACpE,mEAAmE;AACnE,+DAA+D;AAC/D,mEAAmE;AACnE,EAAE;AACF,gEAAgE;AAChE,kEAAkE;AAClE,kCAAkC;AAElC,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,aAAa,GAKd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,GAEpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAiC,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAuC3C,MAAM,mBAAoB,SAAQ,gBAA8B;IAI3C;IACA;IACA;IACA;IACA;IAPX,SAAS,CAAwB;IAEzC,YACmB,GAAmB,EACnB,GAAmC,EACnC,KAAiB,EACjB,WAAoC,EACpC,SAA+B;QAC9C,KAAK,EAAE,CAAC;QALO,QAAG,GAAH,GAAG,CAAgB;QACnB,QAAG,GAAH,GAAG,CAAgC;QACn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IAAI,CAAC,CAAC,CAAC;YACxC,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QACD,YAAY;YACV,OAAO,WAAW,CAAC,MAAM,CAAW,EAAE,CAAC,EAAE;gBACvC,IAAI,EAAE,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;oBACzC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;gBACxF,CAAC;gBACD,OAAO,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Command, CompiledEffect, Effect, IRenderTask, RenderTree } from "../core/index.js";
|
|
2
|
+
import type { alist } from "@aardworx/wombat.adaptive";
|
|
3
|
+
import { type RenderToOptions, type RenderToResult } from "./renderTo.js";
|
|
4
|
+
export interface RuntimeOptions {
|
|
5
|
+
readonly device: GPUDevice;
|
|
6
|
+
/**
|
|
7
|
+
* Optional override for `Effect → CompiledEffect`. Defaults to
|
|
8
|
+
* `effect.compile({ target: "wgsl" })`. Override when tests want
|
|
9
|
+
* a hand-built CompiledEffect or when the caller needs custom
|
|
10
|
+
* `CompileOptions` (`skipMatrixReversal`, source-file labelling,
|
|
11
|
+
* …).
|
|
12
|
+
*/
|
|
13
|
+
readonly compileEffect?: (effect: Effect) => CompiledEffect;
|
|
14
|
+
}
|
|
15
|
+
export declare class Runtime {
|
|
16
|
+
private readonly ctx;
|
|
17
|
+
private readonly _tasks;
|
|
18
|
+
private _disposed;
|
|
19
|
+
private _deviceLost;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves to the lost-info when the device is reported lost.
|
|
22
|
+
* Stays pending while the device is alive.
|
|
23
|
+
*/
|
|
24
|
+
readonly deviceLost: Promise<GPUDeviceLostInfo>;
|
|
25
|
+
constructor(opts: RuntimeOptions);
|
|
26
|
+
get device(): GPUDevice;
|
|
27
|
+
get isDeviceLost(): boolean;
|
|
28
|
+
/** Compile an `alist<Command>` into a runnable `IRenderTask`. */
|
|
29
|
+
compile(commands: alist<Command>): IRenderTask;
|
|
30
|
+
/**
|
|
31
|
+
* Render `scene` into a freshly-allocated framebuffer, returning
|
|
32
|
+
* lazy `aval<ITexture>` handles for each color/depth attachment.
|
|
33
|
+
* The framebuffer + inner render task come live when any
|
|
34
|
+
* returned aval is acquired (transitively, e.g. by binding it
|
|
35
|
+
* to a downstream RenderObject), and shut down on last release.
|
|
36
|
+
*/
|
|
37
|
+
renderTo(scene: RenderTree, opts: RenderToOptions): RenderToResult;
|
|
38
|
+
/**
|
|
39
|
+
* Tear down every IRenderTask compiled through this Runtime.
|
|
40
|
+
* After calling this, `compile()` and `renderTo()` throw.
|
|
41
|
+
* Idempotent. Intended for page-unload + fatal error paths.
|
|
42
|
+
*
|
|
43
|
+
* Note: doesn't destroy the GPUDevice itself — the user still
|
|
44
|
+
* owns its lifecycle.
|
|
45
|
+
*/
|
|
46
|
+
disposeAll(): void;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAY,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,cAAc,CAAC;CAC7D;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAiB;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAS;IAC5B;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;gBAEpC,IAAI,EAAE,cAAc;IAoBhC,IAAI,MAAM,IAAI,SAAS,CAA4B;IACnD,IAAI,YAAY,IAAI,OAAO,CAA6B;IAqBxD,iEAAiE;IACjE,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,WAAW;IAS9C;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,GAAG,cAAc;IAKlE;;;;;;;OAOG;IACH,UAAU,IAAI,IAAI;CAQnB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Runtime — the user-facing entry point. Holds the device +
|
|
2
|
+
// effect-compilation hook, exposes `compile(commands)` and
|
|
3
|
+
// (eventually) `renderTo(...)`.
|
|
4
|
+
import { compileRenderTask } from "./renderTask.js";
|
|
5
|
+
import { renderTo } from "./renderTo.js";
|
|
6
|
+
export class Runtime {
|
|
7
|
+
ctx;
|
|
8
|
+
_tasks = new Set();
|
|
9
|
+
_disposed = false;
|
|
10
|
+
_deviceLost = false;
|
|
11
|
+
/**
|
|
12
|
+
* Resolves to the lost-info when the device is reported lost.
|
|
13
|
+
* Stays pending while the device is alive.
|
|
14
|
+
*/
|
|
15
|
+
deviceLost;
|
|
16
|
+
constructor(opts) {
|
|
17
|
+
this.ctx = {
|
|
18
|
+
device: opts.device,
|
|
19
|
+
compileEffect: opts.compileEffect ?? ((e) => e.compile({ target: "wgsl" })),
|
|
20
|
+
};
|
|
21
|
+
// `device.lost` is a real-WebGPU promise; mock devices may not
|
|
22
|
+
// expose it. Treat as "never lost" in that case.
|
|
23
|
+
const lost = opts.device.lost;
|
|
24
|
+
this.deviceLost = lost !== undefined
|
|
25
|
+
? lost.then((info) => {
|
|
26
|
+
this._deviceLost = true;
|
|
27
|
+
// Best-effort: dispose all outstanding tasks so user code
|
|
28
|
+
// that still holds them stops trying to encode against a
|
|
29
|
+
// dead device.
|
|
30
|
+
this.disposeAll();
|
|
31
|
+
return info;
|
|
32
|
+
})
|
|
33
|
+
: new Promise(() => { });
|
|
34
|
+
}
|
|
35
|
+
get device() { return this.ctx.device; }
|
|
36
|
+
get isDeviceLost() { return this._deviceLost; }
|
|
37
|
+
// Recovery story (after `device.lost`):
|
|
38
|
+
//
|
|
39
|
+
// 1. The `lost`-handler above fires `disposeAll()`, releasing all
|
|
40
|
+
// `IRenderTask`s and the `PreparedRenderObject`s they hold.
|
|
41
|
+
// User-level avals (`cval`, `clist`, `cset`) survive — they're
|
|
42
|
+
// device-agnostic.
|
|
43
|
+
// 2. Caller re-requests an adapter + device, constructs a new
|
|
44
|
+
// `Runtime` from it, and re-`compile()`s their original
|
|
45
|
+
// `alist<Command>`. The new Runtime builds fresh
|
|
46
|
+
// PreparedRenderObjects + a fresh ScenePass tree from the same
|
|
47
|
+
// user data; the per-device caches inside compile-pipeline /
|
|
48
|
+
// sampler / mip-gen are keyed on `WeakMap<GPUDevice, ...>` so
|
|
49
|
+
// they re-populate naturally for the new device.
|
|
50
|
+
//
|
|
51
|
+
// We don't expose a single-call `replaceDevice()` because every
|
|
52
|
+
// prepared object's GPU handles are baked in at construction; the
|
|
53
|
+
// cleanest path is to discard the old Runtime and construct a new
|
|
54
|
+
// one from the same source `alist<Command>`.
|
|
55
|
+
/** Compile an `alist<Command>` into a runnable `IRenderTask`. */
|
|
56
|
+
compile(commands) {
|
|
57
|
+
if (this._disposed)
|
|
58
|
+
throw new Error("Runtime: compile after disposeAll");
|
|
59
|
+
const task = compileRenderTask(this.ctx, commands);
|
|
60
|
+
this._tasks.add(task);
|
|
61
|
+
const origDispose = task.dispose.bind(task);
|
|
62
|
+
task.dispose = () => { origDispose(); this._tasks.delete(task); };
|
|
63
|
+
return task;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Render `scene` into a freshly-allocated framebuffer, returning
|
|
67
|
+
* lazy `aval<ITexture>` handles for each color/depth attachment.
|
|
68
|
+
* The framebuffer + inner render task come live when any
|
|
69
|
+
* returned aval is acquired (transitively, e.g. by binding it
|
|
70
|
+
* to a downstream RenderObject), and shut down on last release.
|
|
71
|
+
*/
|
|
72
|
+
renderTo(scene, opts) {
|
|
73
|
+
if (this._disposed)
|
|
74
|
+
throw new Error("Runtime: renderTo after disposeAll");
|
|
75
|
+
return renderTo(this.ctx, scene, opts);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Tear down every IRenderTask compiled through this Runtime.
|
|
79
|
+
* After calling this, `compile()` and `renderTo()` throw.
|
|
80
|
+
* Idempotent. Intended for page-unload + fatal error paths.
|
|
81
|
+
*
|
|
82
|
+
* Note: doesn't destroy the GPUDevice itself — the user still
|
|
83
|
+
* owns its lifecycle.
|
|
84
|
+
*/
|
|
85
|
+
disposeAll() {
|
|
86
|
+
if (this._disposed)
|
|
87
|
+
return;
|
|
88
|
+
this._disposed = true;
|
|
89
|
+
for (const t of [...this._tasks]) {
|
|
90
|
+
try {
|
|
91
|
+
t.dispose();
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
console.error("Runtime.disposeAll: task.dispose threw", e);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
this._tasks.clear();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,2DAA2D;AAC3D,gCAAgC;AAIhC,OAAO,EAAE,iBAAiB,EAAuB,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,QAAQ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AC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type AdaptiveToken } from "@aardworx/wombat.adaptive";
|
|
2
|
+
import { type CompiledEffect, type Effect, type FramebufferSignature, type RenderTree } from "../core/index.js";
|
|
3
|
+
import { type PreparedRenderObject } from "../resources/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Counters surfaced for tests. `prepareCount` only goes up when
|
|
6
|
+
* `prepareRenderObject` is called for a fresh RenderObject; it
|
|
7
|
+
* does not increment per frame on an unchanged scene.
|
|
8
|
+
*/
|
|
9
|
+
export interface WalkerStats {
|
|
10
|
+
prepareCount: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class ScenePass {
|
|
13
|
+
private readonly root;
|
|
14
|
+
/** Bumped on `prepareRenderObject`. Tests use this to confirm O(deltas) prep cost. */
|
|
15
|
+
readonly stats: WalkerStats;
|
|
16
|
+
constructor(device: GPUDevice, signature: FramebufferSignature, tree: RenderTree, compileEffect: (e: Effect) => CompiledEffect);
|
|
17
|
+
/**
|
|
18
|
+
* Pull deltas from every dynamic subtree, splice the affected
|
|
19
|
+
* walkers, and produce the current ordered list of leaves.
|
|
20
|
+
* Idempotent on a clean adaptive graph (no readers fire).
|
|
21
|
+
*/
|
|
22
|
+
resolve(token: AdaptiveToken): PreparedRenderObject[];
|
|
23
|
+
dispose(): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=scenePass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenePass.d.ts","sourceRoot":"","sources":["../../src/runtime/scenePass.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,KAAK,aAAa,EAQnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,oBAAoB,EAEzB,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAC;AAS/B;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;CACtB;AA6LD,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,sFAAsF;IACtF,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAuB;gBAGhD,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,oBAAoB,EAC/B,IAAI,EAAE,UAAU,EAChB,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,cAAc;IAM9C;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,oBAAoB,EAAE;IAOrD,OAAO,IAAI,IAAI;CAGhB"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// ScenePass — delta-driven walker for one `Render` command's
|
|
2
|
+
// `RenderTree`. Built once at task-compile time; subscribes to the
|
|
3
|
+
// dynamic subtrees (`Adaptive` / `OrderedFromList` /
|
|
4
|
+
// `UnorderedFromSet`); incrementally maintains its set of
|
|
5
|
+
// PreparedRenderObjects.
|
|
6
|
+
//
|
|
7
|
+
// Per-frame cost = O(deltas) + O(leaves) for emission. The static
|
|
8
|
+
// recursion through Empty / Leaf / Ordered / Unordered nodes that
|
|
9
|
+
// the previous walker did each frame is gone — those are folded
|
|
10
|
+
// into a stable NodeWalker tree at construction.
|
|
11
|
+
//
|
|
12
|
+
// Lifted from Aardvark.Rendering's CommandTask delta handling.
|
|
13
|
+
// We keep the *adaptive bookkeeping* pattern (per-RO AdaptiveObject,
|
|
14
|
+
// reader-driven splice) and drop the native command-stream linked-
|
|
15
|
+
// list — that was a .NET↔native amortisation in the F# build with
|
|
16
|
+
// no analogue in WebGPU/JS.
|
|
17
|
+
import { MapExt, } from "@aardworx/wombat.adaptive";
|
|
18
|
+
import {} from "../core/index.js";
|
|
19
|
+
import { prepareRenderObject, } from "../resources/index.js";
|
|
20
|
+
class NodeWalker {
|
|
21
|
+
}
|
|
22
|
+
class EmptyWalker extends NodeWalker {
|
|
23
|
+
update() { }
|
|
24
|
+
emit() { }
|
|
25
|
+
dispose() { }
|
|
26
|
+
}
|
|
27
|
+
class LeafWalker extends NodeWalker {
|
|
28
|
+
prepared;
|
|
29
|
+
constructor(ctx, obj) {
|
|
30
|
+
super();
|
|
31
|
+
const eff = ctx.compileEffect(obj.effect);
|
|
32
|
+
this.prepared = prepareRenderObject(ctx.device, obj, eff, ctx.signature, {
|
|
33
|
+
effectId: obj.effect.id,
|
|
34
|
+
});
|
|
35
|
+
this.prepared.acquire();
|
|
36
|
+
ctx.stats.prepareCount++;
|
|
37
|
+
}
|
|
38
|
+
update() { }
|
|
39
|
+
emit(out) { out.push(this.prepared); }
|
|
40
|
+
dispose() { this.prepared.release(); }
|
|
41
|
+
}
|
|
42
|
+
class OrderedWalker extends NodeWalker {
|
|
43
|
+
children;
|
|
44
|
+
constructor(children) {
|
|
45
|
+
super();
|
|
46
|
+
this.children = children;
|
|
47
|
+
}
|
|
48
|
+
update(token) { for (const c of this.children)
|
|
49
|
+
c.update(token); }
|
|
50
|
+
emit(out) { for (const c of this.children)
|
|
51
|
+
c.emit(out); }
|
|
52
|
+
dispose() { for (const c of this.children)
|
|
53
|
+
c.dispose(); }
|
|
54
|
+
}
|
|
55
|
+
// Same identity-rank counter used by the previous walker. Sorting
|
|
56
|
+
// Unordered subtrees by pipeline-then-group0-layout to minimise
|
|
57
|
+
// state changes inside the render pass.
|
|
58
|
+
const sortRanks = new WeakMap();
|
|
59
|
+
let nextSortRank = 1;
|
|
60
|
+
function rankOf(o) {
|
|
61
|
+
let r = sortRanks.get(o);
|
|
62
|
+
if (r === undefined) {
|
|
63
|
+
r = nextSortRank++;
|
|
64
|
+
sortRanks.set(o, r);
|
|
65
|
+
}
|
|
66
|
+
return r;
|
|
67
|
+
}
|
|
68
|
+
function compareLeaves(a, b) {
|
|
69
|
+
const pa = rankOf(a.pipeline);
|
|
70
|
+
const pb = rankOf(b.pipeline);
|
|
71
|
+
if (pa !== pb)
|
|
72
|
+
return pa - pb;
|
|
73
|
+
const la = a.groups[0]?.layout;
|
|
74
|
+
const lb = b.groups[0]?.layout;
|
|
75
|
+
if (la !== undefined && lb !== undefined && la !== lb)
|
|
76
|
+
return rankOf(la) - rankOf(lb);
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
class UnorderedWalker extends NodeWalker {
|
|
80
|
+
children;
|
|
81
|
+
constructor(children) {
|
|
82
|
+
super();
|
|
83
|
+
this.children = children;
|
|
84
|
+
}
|
|
85
|
+
update(token) { for (const c of this.children)
|
|
86
|
+
c.update(token); }
|
|
87
|
+
emit(out) {
|
|
88
|
+
const start = out.length;
|
|
89
|
+
for (const c of this.children)
|
|
90
|
+
c.emit(out);
|
|
91
|
+
// Sort just our slice in-place.
|
|
92
|
+
const slice = out.splice(start);
|
|
93
|
+
slice.sort(compareLeaves);
|
|
94
|
+
for (const p of slice)
|
|
95
|
+
out.push(p);
|
|
96
|
+
}
|
|
97
|
+
dispose() { for (const c of this.children)
|
|
98
|
+
c.dispose(); }
|
|
99
|
+
}
|
|
100
|
+
class AdaptiveWalker extends NodeWalker {
|
|
101
|
+
source;
|
|
102
|
+
ctx;
|
|
103
|
+
current;
|
|
104
|
+
currentTree;
|
|
105
|
+
constructor(source, ctx) {
|
|
106
|
+
super();
|
|
107
|
+
this.source = source;
|
|
108
|
+
this.ctx = ctx;
|
|
109
|
+
}
|
|
110
|
+
update(token) {
|
|
111
|
+
const t = this.source.getValue(token);
|
|
112
|
+
if (t !== this.currentTree) {
|
|
113
|
+
this.current?.dispose();
|
|
114
|
+
this.current = build(t, this.ctx);
|
|
115
|
+
this.currentTree = t;
|
|
116
|
+
}
|
|
117
|
+
this.current.update(token);
|
|
118
|
+
}
|
|
119
|
+
emit(out) { this.current?.emit(out); }
|
|
120
|
+
dispose() { this.current?.dispose(); this.current = undefined; }
|
|
121
|
+
}
|
|
122
|
+
class OrderedFromListWalker extends NodeWalker {
|
|
123
|
+
ctx;
|
|
124
|
+
reader;
|
|
125
|
+
// Sorted-by-Index map. Reassigned (immutable persistent) on every delta.
|
|
126
|
+
map = MapExt.empty(indexCompare);
|
|
127
|
+
constructor(source, ctx) {
|
|
128
|
+
super();
|
|
129
|
+
this.ctx = ctx;
|
|
130
|
+
this.reader = source.getReader();
|
|
131
|
+
}
|
|
132
|
+
update(token) {
|
|
133
|
+
const deltas = this.reader.getChanges(token);
|
|
134
|
+
for (const [idx, op] of deltas) {
|
|
135
|
+
if (op.tag === "Set") {
|
|
136
|
+
const old = this.map.tryFind(idx);
|
|
137
|
+
if (old !== undefined)
|
|
138
|
+
old.dispose();
|
|
139
|
+
const w = build(op.value, this.ctx);
|
|
140
|
+
// Update the new child immediately so its initial state
|
|
141
|
+
// is consistent before the next emit.
|
|
142
|
+
w.update(token);
|
|
143
|
+
this.map = this.map.add(idx, w);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const old = this.map.tryFind(idx);
|
|
147
|
+
if (old !== undefined) {
|
|
148
|
+
old.dispose();
|
|
149
|
+
this.map = this.map.remove(idx);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Existing children may have dirty sub-readers — update them too.
|
|
154
|
+
for (const [, w] of this.map)
|
|
155
|
+
w.update(token);
|
|
156
|
+
}
|
|
157
|
+
emit(out) {
|
|
158
|
+
for (const [, w] of this.map)
|
|
159
|
+
w.emit(out);
|
|
160
|
+
}
|
|
161
|
+
dispose() {
|
|
162
|
+
for (const [, w] of this.map)
|
|
163
|
+
w.dispose();
|
|
164
|
+
this.map = MapExt.empty(indexCompare);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
class UnorderedFromSetWalker extends NodeWalker {
|
|
168
|
+
ctx;
|
|
169
|
+
reader;
|
|
170
|
+
map = new Map();
|
|
171
|
+
constructor(source, ctx) {
|
|
172
|
+
super();
|
|
173
|
+
this.ctx = ctx;
|
|
174
|
+
this.reader = source.getReader();
|
|
175
|
+
}
|
|
176
|
+
update(token) {
|
|
177
|
+
const deltas = this.reader.getChanges(token);
|
|
178
|
+
for (const op of deltas) {
|
|
179
|
+
if (op.count > 0) {
|
|
180
|
+
if (!this.map.has(op.value)) {
|
|
181
|
+
const w = build(op.value, this.ctx);
|
|
182
|
+
w.update(token);
|
|
183
|
+
this.map.set(op.value, w);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else if (op.count < 0) {
|
|
187
|
+
const old = this.map.get(op.value);
|
|
188
|
+
if (old !== undefined) {
|
|
189
|
+
old.dispose();
|
|
190
|
+
this.map.delete(op.value);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
for (const w of this.map.values())
|
|
195
|
+
w.update(token);
|
|
196
|
+
}
|
|
197
|
+
emit(out) {
|
|
198
|
+
const start = out.length;
|
|
199
|
+
for (const w of this.map.values())
|
|
200
|
+
w.emit(out);
|
|
201
|
+
const slice = out.splice(start);
|
|
202
|
+
slice.sort(compareLeaves);
|
|
203
|
+
for (const p of slice)
|
|
204
|
+
out.push(p);
|
|
205
|
+
}
|
|
206
|
+
dispose() {
|
|
207
|
+
for (const w of this.map.values())
|
|
208
|
+
w.dispose();
|
|
209
|
+
this.map.clear();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function indexCompare(a, b) { return a.compareTo(b); }
|
|
213
|
+
function build(tree, ctx) {
|
|
214
|
+
switch (tree.kind) {
|
|
215
|
+
case "Empty": return new EmptyWalker();
|
|
216
|
+
case "Leaf": return new LeafWalker(ctx, tree.object);
|
|
217
|
+
case "Ordered": return new OrderedWalker(tree.children.map(c => build(c, ctx)));
|
|
218
|
+
case "Unordered": return new UnorderedWalker(tree.children.map(c => build(c, ctx)));
|
|
219
|
+
case "Adaptive": return new AdaptiveWalker(tree.tree, ctx);
|
|
220
|
+
case "OrderedFromList": return new OrderedFromListWalker(tree.children, ctx);
|
|
221
|
+
case "UnorderedFromSet": return new UnorderedFromSetWalker(tree.children, ctx);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// ---------------------------------------------------------------------------
|
|
225
|
+
// ScenePass — public entry
|
|
226
|
+
// ---------------------------------------------------------------------------
|
|
227
|
+
export class ScenePass {
|
|
228
|
+
root;
|
|
229
|
+
/** Bumped on `prepareRenderObject`. Tests use this to confirm O(deltas) prep cost. */
|
|
230
|
+
stats = { prepareCount: 0 };
|
|
231
|
+
constructor(device, signature, tree, compileEffect) {
|
|
232
|
+
const ctx = { device, signature, compileEffect, stats: this.stats };
|
|
233
|
+
this.root = build(tree, ctx);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Pull deltas from every dynamic subtree, splice the affected
|
|
237
|
+
* walkers, and produce the current ordered list of leaves.
|
|
238
|
+
* Idempotent on a clean adaptive graph (no readers fire).
|
|
239
|
+
*/
|
|
240
|
+
resolve(token) {
|
|
241
|
+
this.root.update(token);
|
|
242
|
+
const out = [];
|
|
243
|
+
this.root.emit(out);
|
|
244
|
+
return out;
|
|
245
|
+
}
|
|
246
|
+
dispose() {
|
|
247
|
+
this.root.dispose();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=scenePass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenePass.js","sourceRoot":"","sources":["../../src/runtime/scenePass.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,mEAAmE;AACnE,qDAAqD;AACrD,0DAA0D;AAC1D,yBAAyB;AACzB,EAAE;AACF,kEAAkE;AAClE,kEAAkE;AAClE,gEAAgE;AAChE,iDAAiD;AACjD,EAAE;AACF,+DAA+D;AAC/D,qEAAqE;AACrE,mEAAmE;AACnE,kEAAkE;AAClE,4BAA4B;AAE5B,OAAO,EAIL,MAAM,GAKP,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAMN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,GAEpB,MAAM,uBA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AC3B,8EAA8E;AAE9E,MAAM,OAAO,SAAS;IACH,IAAI,CAAa;IAClC,sFAAsF;IAC7E,KAAK,GAAgB,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;IAElD,YACE,MAAiB,EACjB,SAA+B,EAC/B,IAAgB,EAChB,aAA4C;QAE5C,MAAM,GAAG,GAAiB,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAClF,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,KAAoB;QAC1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,GAAG,GAA2B,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type IFramebuffer, type FramebufferSignature } from "../core/index.js";
|
|
2
|
+
import { type aval } from "@aardworx/wombat.adaptive";
|
|
3
|
+
export interface AttachCanvasOptions {
|
|
4
|
+
/** Texture format for the swap-chain. Default: device's preferred format. */
|
|
5
|
+
readonly format?: GPUTextureFormat;
|
|
6
|
+
/** Optional depth/stencil format. When set, an off-screen depth texture is co-allocated. */
|
|
7
|
+
readonly depthFormat?: GPUTextureFormat;
|
|
8
|
+
/** Pre-multiplied / opaque alpha mode. Default `"premultiplied"`. */
|
|
9
|
+
readonly alphaMode?: GPUCanvasAlphaMode;
|
|
10
|
+
/** Logical → physical pixel scaling. Default: `window.devicePixelRatio`. */
|
|
11
|
+
readonly devicePixelRatio?: number;
|
|
12
|
+
/** Color attachment name in the resulting `FramebufferSignature`. Default `"color"`. */
|
|
13
|
+
readonly colorAttachmentName?: string;
|
|
14
|
+
/**
|
|
15
|
+
* MSAA sample count. Default 1. With `> 1`, a hidden multisample
|
|
16
|
+
* color texture (and depth, if `depthFormat` is set) is allocated
|
|
17
|
+
* sized to the canvas; the swap-chain texture becomes the resolve
|
|
18
|
+
* target. Common values: 1 (off), 4 (fast MSAA).
|
|
19
|
+
*/
|
|
20
|
+
readonly sampleCount?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface CanvasAttachment {
|
|
23
|
+
/** Reactive framebuffer; bump per frame via `markFrame()`. */
|
|
24
|
+
readonly framebuffer: aval<IFramebuffer>;
|
|
25
|
+
/** Reactive `{ width, height }` driven by ResizeObserver. */
|
|
26
|
+
readonly size: aval<{
|
|
27
|
+
readonly width: number;
|
|
28
|
+
readonly height: number;
|
|
29
|
+
}>;
|
|
30
|
+
/** The signature derived from the chosen formats. */
|
|
31
|
+
readonly signature: FramebufferSignature;
|
|
32
|
+
/** Mark a new frame: invalidates the framebuffer aval so its next read produces a fresh swap-chain texture. */
|
|
33
|
+
markFrame(): void;
|
|
34
|
+
/** Disconnect the resize observer + clear the canvas context. Idempotent. */
|
|
35
|
+
dispose(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare function attachCanvas(device: GPUDevice, canvas: HTMLCanvasElement | OffscreenCanvas, opts?: AttachCanvasOptions): CanvasAttachment;
|
|
38
|
+
//# sourceMappingURL=canvas.d.ts.map
|