@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.
- 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 +21 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +14 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/pipelineState.d.ts +126 -0
- package/dist/core/pipelineState.d.ts.map +1 -0
- package/dist/core/pipelineState.js +88 -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 +93 -0
- package/dist/resources/preparedRenderObject.d.ts.map +1 -0
- package/dist/resources/preparedRenderObject.js +541 -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 +255 -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
- package/src/core/index.ts +10 -1
- package/src/core/pipelineState.ts +178 -24
- package/src/resources/preparedRenderObject.ts +271 -85
- package/src/runtime/scenePass.ts +6 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface RawTextureSource {
|
|
2
|
+
readonly kind: "raw";
|
|
3
|
+
readonly data: ArrayBuffer | ArrayBufferView;
|
|
4
|
+
readonly width: number;
|
|
5
|
+
readonly height: number;
|
|
6
|
+
readonly depthOrArrayLayers?: number;
|
|
7
|
+
readonly format: GPUTextureFormat;
|
|
8
|
+
readonly mipLevelCount?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ExternalTextureSource {
|
|
11
|
+
readonly kind: "external";
|
|
12
|
+
readonly source: ImageBitmap | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | ImageData;
|
|
13
|
+
/** Override the format the runtime should allocate (default: "rgba8unorm"). */
|
|
14
|
+
readonly format?: GPUTextureFormat;
|
|
15
|
+
/** Generate a mip chain on upload. Default `false`. */
|
|
16
|
+
readonly generateMips?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export type HostTextureSource = RawTextureSource | ExternalTextureSource;
|
|
19
|
+
export type ITexture = {
|
|
20
|
+
readonly kind: "gpu";
|
|
21
|
+
readonly texture: GPUTexture;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "host";
|
|
24
|
+
readonly source: HostTextureSource;
|
|
25
|
+
};
|
|
26
|
+
export declare const ITexture: {
|
|
27
|
+
readonly fromGPU: (texture: GPUTexture) => ITexture;
|
|
28
|
+
readonly fromExternal: (source: ExternalTextureSource["source"], opts?: {
|
|
29
|
+
format?: GPUTextureFormat;
|
|
30
|
+
generateMips?: boolean;
|
|
31
|
+
}) => ITexture;
|
|
32
|
+
readonly fromRaw: (raw: Omit<RawTextureSource, "kind">) => ITexture;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=texture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texture.d.ts","sourceRoot":"","sources":["../../src/core/texture.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,MAAM,EACX,WAAW,GACX,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,eAAe,GACf,SAAS,CAAC;IACd,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IACnC,uDAAuD;IACvD,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG,qBAAqB,CAAC;AAEzE,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAElE,eAAO,MAAM,QAAQ;gCACF,UAAU,KAAG,QAAQ;oCAI5B,qBAAqB,CAAC,QAAQ,CAAC,SACjC;QAAE,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,KAC1D,QAAQ;4BASE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,KAAG,QAAQ;CAG9C,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// ITexture — texture source that can be either a real GPU texture
|
|
2
|
+
// or a host-side image. Mirrors the IBuffer pattern.
|
|
3
|
+
//
|
|
4
|
+
// Host sources cover everything WebGPU's `copyExternalImageToTexture`
|
|
5
|
+
// or `writeTexture` can accept:
|
|
6
|
+
// - `ImageBitmap`, `HTMLImageElement`, `HTMLVideoElement`,
|
|
7
|
+
// `HTMLCanvasElement`, `OffscreenCanvas`, `ImageData` —
|
|
8
|
+
// uploaded via `copyExternalImageToTexture`.
|
|
9
|
+
// - Raw `{ data, width, height, format }` — uploaded via
|
|
10
|
+
// `queue.writeTexture` (one mip; runtime can synthesise the
|
|
11
|
+
// rest if requested).
|
|
12
|
+
export const ITexture = {
|
|
13
|
+
fromGPU(texture) {
|
|
14
|
+
return { kind: "gpu", texture };
|
|
15
|
+
},
|
|
16
|
+
fromExternal(source, opts = {}) {
|
|
17
|
+
const ext = {
|
|
18
|
+
kind: "external",
|
|
19
|
+
source,
|
|
20
|
+
...(opts.format !== undefined ? { format: opts.format } : {}),
|
|
21
|
+
...(opts.generateMips !== undefined ? { generateMips: opts.generateMips } : {}),
|
|
22
|
+
};
|
|
23
|
+
return { kind: "host", source: ext };
|
|
24
|
+
},
|
|
25
|
+
fromRaw(raw) {
|
|
26
|
+
return { kind: "host", source: { kind: "raw", ...raw } };
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=texture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texture.js","sourceRoot":"","sources":["../../src/core/texture.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,qDAAqD;AACrD,EAAE;AACF,sEAAsE;AACtE,gCAAgC;AAChC,6DAA6D;AAC7D,4DAA4D;AAC5D,iDAAiD;AACjD,2DAA2D;AAC3D,gEAAgE;AAChE,0BAA0B;AAiC1B,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,CAAC,OAAmB;QACzB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAClC,CAAC;IACD,YAAY,CACV,MAAuC,EACvC,OAA8D,EAAE;QAEhE,MAAM,GAAG,GAA0B;YACjC,IAAI,EAAE,UAAU;YAChB,MAAM;YACN,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7D,GAAG,CAAC,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChF,CAAC;QACF,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IACvC,CAAC;IACD,OAAO,CAAC,GAAmC;QACzC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,GAAG,EAAE,EAAE,CAAC;IAC3D,CAAC;CACO,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Public API of `@aardworx/wombat.rendering`.
|
|
2
|
+
//
|
|
3
|
+
// Default entry re-exports everything: types, resource preparers,
|
|
4
|
+
// command-stream functions, runtime, and the window/canvas glue.
|
|
5
|
+
// Subpath exports give granular access for advanced consumers.
|
|
6
|
+
//
|
|
7
|
+
// import { ... } from "@aardworx/wombat.rendering"; // everything
|
|
8
|
+
// import { ... } from "@aardworx/wombat.rendering/core"; // types only
|
|
9
|
+
// import { ... } from "@aardworx/wombat.rendering/resources";
|
|
10
|
+
// import { ... } from "@aardworx/wombat.rendering/commands";
|
|
11
|
+
// import { ... } from "@aardworx/wombat.rendering/runtime";
|
|
12
|
+
// import { ... } from "@aardworx/wombat.rendering/window";
|
|
13
|
+
export * from "./core/index.js";
|
|
14
|
+
export * from "./resources/index.js";
|
|
15
|
+
export * from "./commands/index.js";
|
|
16
|
+
export * from "./runtime/index.js";
|
|
17
|
+
export * from "./window/index.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,+DAA+D;AAC/D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,gEAAgE;AAChE,+DAA+D;AAC/D,8DAA8D;AAC9D,6DAA6D;AAE7D,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AdaptiveResource, type IBuffer } from "../core/index.js";
|
|
2
|
+
import { type aval } from "@aardworx/wombat.adaptive";
|
|
3
|
+
export interface PrepareAdaptiveBufferOptions {
|
|
4
|
+
/** Bitwise OR of GPUBufferUsage flags. `COPY_DST` is added automatically when needed. */
|
|
5
|
+
readonly usage: GPUBufferUsageFlags;
|
|
6
|
+
/** Optional debug label forwarded to created GPUBuffers. */
|
|
7
|
+
readonly label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Reuse the existing GPUBuffer when the new host data fits in
|
|
10
|
+
* the current allocation. Default `true`. Set `false` to force
|
|
11
|
+
* a fresh buffer on every host-side change (rarely useful).
|
|
12
|
+
*/
|
|
13
|
+
readonly reuseOnFit?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Wrap an `aval<IBuffer>` as a ref-counted, adaptively-uploaded
|
|
17
|
+
* `AdaptiveResource<GPUBuffer>`. The resource is itself an
|
|
18
|
+
* `aval<GPUBuffer>` — downstream consumers can `getValue(token)`
|
|
19
|
+
* inside their own adaptive evaluation.
|
|
20
|
+
*/
|
|
21
|
+
export declare function prepareAdaptiveBuffer(device: GPUDevice, source: aval<IBuffer>, opts: PrepareAdaptiveBufferOptions): AdaptiveResource<GPUBuffer>;
|
|
22
|
+
//# sourceMappingURL=adaptiveBuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptiveBuffer.d.ts","sourceRoot":"","sources":["../../src/resources/adaptiveBuffer.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,gBAAgB,EAGhB,KAAK,OAAO,EACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,IAAI,EACV,MAAM,2BAA2B,CAAC;AAGnC,MAAM,WAAW,4BAA4B;IAC3C,yFAAyF;IACzF,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AA6ED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,EACrB,IAAI,EAAE,4BAA4B,GACjC,gBAAgB,CAAC,SAAS,CAAC,CAE7B"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// prepareAdaptiveBuffer — lift `aval<IBuffer>` to
|
|
2
|
+
// `AdaptiveResource<GPUBuffer>`.
|
|
3
|
+
//
|
|
4
|
+
// Behaviour:
|
|
5
|
+
// - On `acquire` (refCount 0→1): subscribes, allocates nothing yet.
|
|
6
|
+
// - On `compute(token)`:
|
|
7
|
+
// - reads the source `aval<IBuffer>`;
|
|
8
|
+
// - if it's `gpu`: returns the user's handle directly. We
|
|
9
|
+
// don't own it; `destroy()` will not free it.
|
|
10
|
+
// - if it's `host`: ensures we own a `GPUBuffer` of sufficient
|
|
11
|
+
// size + correct usage flags, encodes a `writeBuffer` (via
|
|
12
|
+
// device.queue) to upload the bytes, returns the owned
|
|
13
|
+
// buffer. Reuses the existing buffer when capacity allows;
|
|
14
|
+
// reallocates on growth.
|
|
15
|
+
// - On `destroy`: frees the owned buffer (if any).
|
|
16
|
+
//
|
|
17
|
+
// `writeBuffer` does not require a GPUCommandEncoder — it goes via
|
|
18
|
+
// `GPUQueue.writeBuffer`, scheduled at the next submit. That keeps
|
|
19
|
+
// the upload path simple and avoids needing `RenderContext.encoder`
|
|
20
|
+
// for plain CPU→GPU buffer flow. (Compute-produced buffers will
|
|
21
|
+
// need the encoder; that's a different code path.)
|
|
22
|
+
import { AdaptiveResource, tryAcquire, tryRelease, } from "../core/index.js";
|
|
23
|
+
import {} from "@aardworx/wombat.adaptive";
|
|
24
|
+
import { BufferUsage } from "./webgpuFlags.js";
|
|
25
|
+
class AdaptiveBuffer extends AdaptiveResource {
|
|
26
|
+
device;
|
|
27
|
+
source;
|
|
28
|
+
opts;
|
|
29
|
+
_owned = undefined;
|
|
30
|
+
_ownedCapacity = 0;
|
|
31
|
+
constructor(device, source, opts) {
|
|
32
|
+
super();
|
|
33
|
+
this.device = device;
|
|
34
|
+
this.source = source;
|
|
35
|
+
this.opts = opts;
|
|
36
|
+
}
|
|
37
|
+
create() {
|
|
38
|
+
tryAcquire(this.source);
|
|
39
|
+
}
|
|
40
|
+
destroy() {
|
|
41
|
+
if (this._owned !== undefined) {
|
|
42
|
+
this._owned.destroy();
|
|
43
|
+
this._owned = undefined;
|
|
44
|
+
this._ownedCapacity = 0;
|
|
45
|
+
}
|
|
46
|
+
tryRelease(this.source);
|
|
47
|
+
}
|
|
48
|
+
compute(token) {
|
|
49
|
+
const src = this.source.getValue(token);
|
|
50
|
+
if (src.kind === "gpu") {
|
|
51
|
+
// Caller-owned buffer; drop any owned allocation we still hold.
|
|
52
|
+
if (this._owned !== undefined) {
|
|
53
|
+
this._owned.destroy();
|
|
54
|
+
this._owned = undefined;
|
|
55
|
+
this._ownedCapacity = 0;
|
|
56
|
+
}
|
|
57
|
+
return src.buffer;
|
|
58
|
+
}
|
|
59
|
+
// host — upload via queue.writeBuffer.
|
|
60
|
+
const usage = this.opts.usage | BufferUsage.COPY_DST;
|
|
61
|
+
const reuseOnFit = this.opts.reuseOnFit ?? true;
|
|
62
|
+
const requiredSize = roundUp4(src.sizeBytes);
|
|
63
|
+
if (this._owned === undefined
|
|
64
|
+
|| !reuseOnFit
|
|
65
|
+
|| requiredSize > this._ownedCapacity) {
|
|
66
|
+
if (this._owned !== undefined)
|
|
67
|
+
this._owned.destroy();
|
|
68
|
+
const desc = {
|
|
69
|
+
size: requiredSize,
|
|
70
|
+
usage,
|
|
71
|
+
...(this.opts.label !== undefined ? { label: this.opts.label } : {}),
|
|
72
|
+
};
|
|
73
|
+
this._owned = this.device.createBuffer(desc);
|
|
74
|
+
this._ownedCapacity = requiredSize;
|
|
75
|
+
}
|
|
76
|
+
// writeBuffer accepts ArrayBuffer or any ArrayBufferView.
|
|
77
|
+
const data = src.data;
|
|
78
|
+
if (data instanceof ArrayBuffer) {
|
|
79
|
+
this.device.queue.writeBuffer(this._owned, 0, data, 0, src.sizeBytes);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.device.queue.writeBuffer(this._owned, 0, data.buffer, data.byteOffset, src.sizeBytes);
|
|
83
|
+
}
|
|
84
|
+
return this._owned;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function roundUp4(n) {
|
|
88
|
+
return (n + 3) & ~3;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Wrap an `aval<IBuffer>` as a ref-counted, adaptively-uploaded
|
|
92
|
+
* `AdaptiveResource<GPUBuffer>`. The resource is itself an
|
|
93
|
+
* `aval<GPUBuffer>` — downstream consumers can `getValue(token)`
|
|
94
|
+
* inside their own adaptive evaluation.
|
|
95
|
+
*/
|
|
96
|
+
export function prepareAdaptiveBuffer(device, source, opts) {
|
|
97
|
+
return new AdaptiveBuffer(device, source, opts);
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=adaptiveBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptiveBuffer.js","sourceRoot":"","sources":["../../src/resources/adaptiveBuffer.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,iCAAiC;AACjC,EAAE;AACF,aAAa;AACb,sEAAsE;AACtE,2BAA2B;AAC3B,0CAA0C;AAC1C,8DAA8D;AAC9D,oDAAoD;AACpD,mEAAmE;AACnE,iEAAiE;AACjE,6DAA6D;AAC7D,iEAAiE;AACjE,+BAA+B;AAC/B,qDAAqD;AACrD,EAAE;AACF,mEAAmE;AACnE,mEAAmE;AACnE,oEAAoE;AACpE,gEAAgE;AAChE,mDAAmD;AAEnD,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,UAAU,GAEX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGN,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAe/C,MAAM,cAAe,SA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;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAAiB,EACjB,MAAqB,EACrB,IAAkC;IAElC,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AdaptiveResource, type ISampler } from "../core/index.js";
|
|
2
|
+
import { type aval } from "@aardworx/wombat.adaptive";
|
|
3
|
+
export declare function prepareAdaptiveSampler(device: GPUDevice, source: aval<ISampler>): AdaptiveResource<GPUSampler>;
|
|
4
|
+
//# sourceMappingURL=adaptiveSampler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptiveSampler.d.ts","sourceRoot":"","sources":["../../src/resources/adaptiveSampler.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAGhB,KAAK,QAAQ,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,IAAI,EACV,MAAM,2BAA2B,CAAC;AA2DnC,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,GACrB,gBAAgB,CAAC,UAAU,CAAC,CAE9B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// prepareAdaptiveSampler — lift `aval<ISampler>` to
|
|
2
|
+
// `AdaptiveResource<GPUSampler>`.
|
|
3
|
+
//
|
|
4
|
+
// Samplers are cheap and structurally-identifiable — the device
|
|
5
|
+
// dedupes them via a descriptor cache. Per AdaptiveResource we
|
|
6
|
+
// just track the most recent handle; on descriptor change we
|
|
7
|
+
// fetch a fresh one from the cache.
|
|
8
|
+
import { AdaptiveResource, tryAcquire, tryRelease, } from "../core/index.js";
|
|
9
|
+
import {} from "@aardworx/wombat.adaptive";
|
|
10
|
+
class SamplerCache {
|
|
11
|
+
device;
|
|
12
|
+
map = new Map();
|
|
13
|
+
constructor(device) {
|
|
14
|
+
this.device = device;
|
|
15
|
+
}
|
|
16
|
+
get(desc) {
|
|
17
|
+
const k = key(desc);
|
|
18
|
+
let s = this.map.get(k);
|
|
19
|
+
if (s === undefined) {
|
|
20
|
+
s = this.device.createSampler(desc);
|
|
21
|
+
this.map.set(k, s);
|
|
22
|
+
}
|
|
23
|
+
return s;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function key(d) {
|
|
27
|
+
return [
|
|
28
|
+
d.addressModeU ?? "clamp-to-edge",
|
|
29
|
+
d.addressModeV ?? "clamp-to-edge",
|
|
30
|
+
d.addressModeW ?? "clamp-to-edge",
|
|
31
|
+
d.magFilter ?? "nearest",
|
|
32
|
+
d.minFilter ?? "nearest",
|
|
33
|
+
d.mipmapFilter ?? "nearest",
|
|
34
|
+
d.lodMinClamp ?? 0,
|
|
35
|
+
d.lodMaxClamp ?? 32,
|
|
36
|
+
d.compare ?? "",
|
|
37
|
+
d.maxAnisotropy ?? 1,
|
|
38
|
+
].join("|");
|
|
39
|
+
}
|
|
40
|
+
const caches = new WeakMap();
|
|
41
|
+
function cacheFor(device) {
|
|
42
|
+
let c = caches.get(device);
|
|
43
|
+
if (c === undefined) {
|
|
44
|
+
c = new SamplerCache(device);
|
|
45
|
+
caches.set(device, c);
|
|
46
|
+
}
|
|
47
|
+
return c;
|
|
48
|
+
}
|
|
49
|
+
class AdaptiveSampler extends AdaptiveResource {
|
|
50
|
+
device;
|
|
51
|
+
source;
|
|
52
|
+
constructor(device, source) {
|
|
53
|
+
super();
|
|
54
|
+
this.device = device;
|
|
55
|
+
this.source = source;
|
|
56
|
+
}
|
|
57
|
+
create() { tryAcquire(this.source); }
|
|
58
|
+
destroy() {
|
|
59
|
+
// We never own the GPUSampler — the cache does. Just propagate
|
|
60
|
+
// release to the source aval (in case it's an AdaptiveResource).
|
|
61
|
+
tryRelease(this.source);
|
|
62
|
+
}
|
|
63
|
+
compute(token) {
|
|
64
|
+
const s = this.source.getValue(token);
|
|
65
|
+
if (s.kind === "gpu")
|
|
66
|
+
return s.sampler;
|
|
67
|
+
return cacheFor(this.device).get(s.descriptor);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function prepareAdaptiveSampler(device, source) {
|
|
71
|
+
return new AdaptiveSampler(device, source);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=adaptiveSampler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptiveSampler.js","sourceRoot":"","sources":["../../src/resources/adaptiveSampler.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,kCAAkC;AAClC,EAAE;AACF,gEAAgE;AAChE,+DAA+D;AAC/D,6DAA6D;AAC7D,oCAAoC;AAEpC,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,UAAU,GAEX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGN,MAAM,2BAA2B,CAAC;AAEnC,MAAM,YAAY;IAEa;IADZ,GAAG,GAAG,IAAI,GAAG,EAAsB,CAAC;IACrD,YAA6B,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAClD,GAAG,CAAC,IAA0B;QAC5B,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACpB,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YACpC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACrB,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAED,SAAS,GAAG,CAAC,CAAuB;IAClC,OAAO;QACL,CAAC,CAAC,YAAY,IAAI,eAAe;QACjC,CAAC,CAAC,YAAY,IAAI,eAAe;QACjC,CAAC,CAAC,YAAY,IAAI,eAAe;QACjC,CA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,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;CACF;AAED,MAAM,UAAU,sBAAsB,CACpC,MAAiB,EACjB,MAAsB;IAEtB,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AdaptiveResource, type ITexture } from "../core/index.js";
|
|
2
|
+
import { type aval } from "@aardworx/wombat.adaptive";
|
|
3
|
+
export interface PrepareAdaptiveTextureOptions {
|
|
4
|
+
/** Extra usage flags. `COPY_DST` and `TEXTURE_BINDING` are added automatically. */
|
|
5
|
+
readonly usage?: GPUTextureUsageFlags;
|
|
6
|
+
/** Optional debug label. */
|
|
7
|
+
readonly label?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Wrap an `aval<ITexture>` as a ref-counted, adaptively-uploaded
|
|
11
|
+
* `AdaptiveResource<GPUTexture>`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function prepareAdaptiveTexture(device: GPUDevice, source: aval<ITexture>, opts?: PrepareAdaptiveTextureOptions): AdaptiveResource<GPUTexture>;
|
|
14
|
+
//# sourceMappingURL=adaptiveTexture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptiveTexture.d.ts","sourceRoot":"","sources":["../../src/resources/adaptiveTexture.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,gBAAgB,EAGhB,KAAK,QAAQ,EAGd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,IAAI,EACV,MAAM,2BAA2B,CAAC;AAGnC,MAAM,WAAW,6BAA6B;IAC5C,mFAAmF;IACnF,QAAQ,CAAC,KAAK,CAAC,EAAE,oBAAoB,CAAC;IACtC,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AA8ND;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EACtB,IAAI,GAAE,6BAAkC,GACvC,gBAAgB,CAAC,UAAU,CAAC,CAE9B"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// prepareAdaptiveTexture — lift `aval<ITexture>` to
|
|
2
|
+
// `AdaptiveResource<GPUTexture>`.
|
|
3
|
+
//
|
|
4
|
+
// Behaviour matches `prepareAdaptiveBuffer`: on `compute`, if the
|
|
5
|
+
// source is `gpu` return the user's handle; if `host`, ensure we
|
|
6
|
+
// own a GPUTexture of the right size/format and upload via the
|
|
7
|
+
// queue (writeTexture for raw, copyExternalImageToTexture for
|
|
8
|
+
// external sources).
|
|
9
|
+
//
|
|
10
|
+
// Reuse: a host source with the same dimensions + format reuses
|
|
11
|
+
// the existing texture; mismatch triggers a fresh allocation.
|
|
12
|
+
//
|
|
13
|
+
// Mip-map generation is not implemented in this first cut —
|
|
14
|
+
// `generateMips: true` on an external source allocates the mip
|
|
15
|
+
// levels but only mip 0 is uploaded. (Mip generation requires a
|
|
16
|
+
// compute pass; that lands in a follow-up.)
|
|
17
|
+
import { AdaptiveResource, tryAcquire, tryRelease, } from "../core/index.js";
|
|
18
|
+
import {} from "@aardworx/wombat.adaptive";
|
|
19
|
+
import { TextureUsage } from "./webgpuFlags.js";
|
|
20
|
+
function descsEqual(a, b) {
|
|
21
|
+
return (a.width === b.width
|
|
22
|
+
&& a.height === b.height
|
|
23
|
+
&& a.depthOrArrayLayers === b.depthOrArrayLayers
|
|
24
|
+
&& a.format === b.format
|
|
25
|
+
&& a.mipLevelCount === b.mipLevelCount);
|
|
26
|
+
}
|
|
27
|
+
function descFor(src) {
|
|
28
|
+
if (src.kind === "raw") {
|
|
29
|
+
return {
|
|
30
|
+
width: src.width,
|
|
31
|
+
height: src.height,
|
|
32
|
+
depthOrArrayLayers: src.depthOrArrayLayers ?? 1,
|
|
33
|
+
format: src.format,
|
|
34
|
+
mipLevelCount: src.mipLevelCount ?? 1,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// external
|
|
38
|
+
const s = src.source;
|
|
39
|
+
let width = 0;
|
|
40
|
+
let height = 0;
|
|
41
|
+
if (s instanceof ImageData) {
|
|
42
|
+
width = s.width;
|
|
43
|
+
height = s.height;
|
|
44
|
+
}
|
|
45
|
+
else if ("naturalWidth" in s && typeof s.naturalWidth === "number") {
|
|
46
|
+
// HTMLImageElement
|
|
47
|
+
width = s.naturalWidth || s.width;
|
|
48
|
+
height = s.naturalHeight || s.height;
|
|
49
|
+
}
|
|
50
|
+
else if ("videoWidth" in s && typeof s.videoWidth === "number") {
|
|
51
|
+
// HTMLVideoElement
|
|
52
|
+
width = s.videoWidth;
|
|
53
|
+
height = s.videoHeight;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// ImageBitmap, HTMLCanvasElement, OffscreenCanvas — all have width/height
|
|
57
|
+
width = s.width;
|
|
58
|
+
height = s.height;
|
|
59
|
+
}
|
|
60
|
+
const generateMips = src.generateMips === true;
|
|
61
|
+
return {
|
|
62
|
+
width, height, depthOrArrayLayers: 1,
|
|
63
|
+
format: src.format ?? "rgba8unorm",
|
|
64
|
+
mipLevelCount: generateMips ? mipCount(width, height) : 1,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function mipCount(w, h) {
|
|
68
|
+
return Math.floor(Math.log2(Math.max(w, h))) + 1;
|
|
69
|
+
}
|
|
70
|
+
class AdaptiveTexture extends AdaptiveResource {
|
|
71
|
+
device;
|
|
72
|
+
source;
|
|
73
|
+
opts;
|
|
74
|
+
_owned = undefined;
|
|
75
|
+
_ownedDesc = undefined;
|
|
76
|
+
constructor(device, source, opts) {
|
|
77
|
+
super();
|
|
78
|
+
this.device = device;
|
|
79
|
+
this.source = source;
|
|
80
|
+
this.opts = opts;
|
|
81
|
+
}
|
|
82
|
+
create() { tryAcquire(this.source); }
|
|
83
|
+
destroy() {
|
|
84
|
+
if (this._owned !== undefined) {
|
|
85
|
+
this._owned.destroy();
|
|
86
|
+
this._owned = undefined;
|
|
87
|
+
this._ownedDesc = undefined;
|
|
88
|
+
}
|
|
89
|
+
tryRelease(this.source);
|
|
90
|
+
}
|
|
91
|
+
compute(token) {
|
|
92
|
+
const src = this.source.getValue(token);
|
|
93
|
+
if (src.kind === "gpu") {
|
|
94
|
+
if (this._owned !== undefined) {
|
|
95
|
+
this._owned.destroy();
|
|
96
|
+
this._owned = undefined;
|
|
97
|
+
this._ownedDesc = undefined;
|
|
98
|
+
}
|
|
99
|
+
return src.texture;
|
|
100
|
+
}
|
|
101
|
+
const desc = descFor(src.source);
|
|
102
|
+
const usage = (this.opts.usage ?? 0)
|
|
103
|
+
| TextureUsage.COPY_DST
|
|
104
|
+
| TextureUsage.TEXTURE_BINDING
|
|
105
|
+
| (src.source.kind === "external" ? TextureUsage.RENDER_ATTACHMENT : 0);
|
|
106
|
+
if (this._owned === undefined || this._ownedDesc === undefined || !descsEqual(this._ownedDesc, desc)) {
|
|
107
|
+
if (this._owned !== undefined)
|
|
108
|
+
this._owned.destroy();
|
|
109
|
+
const tdesc = {
|
|
110
|
+
size: { width: desc.width, height: desc.height, depthOrArrayLayers: desc.depthOrArrayLayers },
|
|
111
|
+
format: desc.format,
|
|
112
|
+
mipLevelCount: desc.mipLevelCount,
|
|
113
|
+
usage,
|
|
114
|
+
...(this.opts.label !== undefined ? { label: this.opts.label } : {}),
|
|
115
|
+
};
|
|
116
|
+
this._owned = this.device.createTexture(tdesc);
|
|
117
|
+
this._ownedDesc = desc;
|
|
118
|
+
}
|
|
119
|
+
if (src.source.kind === "raw") {
|
|
120
|
+
uploadRaw(this.device, this._owned, src.source);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
uploadExternal(this.device, this._owned, src.source);
|
|
124
|
+
}
|
|
125
|
+
return this._owned;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function uploadRaw(device, tex, src) {
|
|
129
|
+
const bytes = src.data instanceof ArrayBuffer ? new Uint8Array(src.data) : new Uint8Array(src.data.buffer, src.data.byteOffset, src.data.byteLength);
|
|
130
|
+
const block = blockInfoFor(src.format);
|
|
131
|
+
const blocksPerRow = Math.ceil(src.width / block.width);
|
|
132
|
+
const rowsOfBlocks = Math.ceil(src.height / block.height);
|
|
133
|
+
device.queue.writeTexture({ texture: tex }, bytes, { bytesPerRow: blocksPerRow * block.bytesPerBlock, rowsPerImage: rowsOfBlocks }, { width: src.width, height: src.height, depthOrArrayLayers: src.depthOrArrayLayers ?? 1 });
|
|
134
|
+
}
|
|
135
|
+
function uploadExternal(device, tex, src) {
|
|
136
|
+
device.queue.copyExternalImageToTexture({ source: src.source }, { texture: tex }, { width: src.source.width, height: src.source.height, depthOrArrayLayers: 1 });
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Block dimensions + size for a WebGPU texture format. Linear
|
|
140
|
+
* (uncompressed) formats report 1×1 blocks. Block-compressed
|
|
141
|
+
* formats (BC*, ETC*, ASTC*, EAC) use their native block size so
|
|
142
|
+
* `writeTexture`'s bytesPerRow / rowsPerImage land on the right
|
|
143
|
+
* block grid.
|
|
144
|
+
*/
|
|
145
|
+
function blockInfoFor(format) {
|
|
146
|
+
switch (format) {
|
|
147
|
+
// 8-bit
|
|
148
|
+
case "r8unorm":
|
|
149
|
+
case "r8snorm":
|
|
150
|
+
case "r8uint":
|
|
151
|
+
case "r8sint":
|
|
152
|
+
return { width: 1, height: 1, bytesPerBlock: 1 };
|
|
153
|
+
// 16-bit
|
|
154
|
+
case "rg8unorm":
|
|
155
|
+
case "rg8snorm":
|
|
156
|
+
case "rg8uint":
|
|
157
|
+
case "rg8sint":
|
|
158
|
+
case "r16uint":
|
|
159
|
+
case "r16sint":
|
|
160
|
+
case "r16float":
|
|
161
|
+
return { width: 1, height: 1, bytesPerBlock: 2 };
|
|
162
|
+
// 32-bit
|
|
163
|
+
case "rgba8unorm":
|
|
164
|
+
case "rgba8unorm-srgb":
|
|
165
|
+
case "rgba8snorm":
|
|
166
|
+
case "rgba8uint":
|
|
167
|
+
case "rgba8sint":
|
|
168
|
+
case "bgra8unorm":
|
|
169
|
+
case "bgra8unorm-srgb":
|
|
170
|
+
case "rgb10a2unorm":
|
|
171
|
+
case "rgb10a2uint":
|
|
172
|
+
case "rg11b10ufloat":
|
|
173
|
+
case "rgb9e5ufloat":
|
|
174
|
+
case "rg16uint":
|
|
175
|
+
case "rg16sint":
|
|
176
|
+
case "rg16float":
|
|
177
|
+
case "r32uint":
|
|
178
|
+
case "r32sint":
|
|
179
|
+
case "r32float":
|
|
180
|
+
return { width: 1, height: 1, bytesPerBlock: 4 };
|
|
181
|
+
// 64-bit
|
|
182
|
+
case "rgba16uint":
|
|
183
|
+
case "rgba16sint":
|
|
184
|
+
case "rgba16float":
|
|
185
|
+
case "rg32uint":
|
|
186
|
+
case "rg32sint":
|
|
187
|
+
case "rg32float":
|
|
188
|
+
return { width: 1, height: 1, bytesPerBlock: 8 };
|
|
189
|
+
// 128-bit
|
|
190
|
+
case "rgba32uint":
|
|
191
|
+
case "rgba32sint":
|
|
192
|
+
case "rgba32float":
|
|
193
|
+
return { width: 1, height: 1, bytesPerBlock: 16 };
|
|
194
|
+
// ---- Block-compressed formats ----
|
|
195
|
+
// BC1/2/3/4/5 (DXT/RGTC) — 4×4 blocks
|
|
196
|
+
case "bc1-rgba-unorm":
|
|
197
|
+
case "bc1-rgba-unorm-srgb":
|
|
198
|
+
case "bc4-r-unorm":
|
|
199
|
+
case "bc4-r-snorm":
|
|
200
|
+
return { width: 4, height: 4, bytesPerBlock: 8 };
|
|
201
|
+
case "bc2-rgba-unorm":
|
|
202
|
+
case "bc2-rgba-unorm-srgb":
|
|
203
|
+
case "bc3-rgba-unorm":
|
|
204
|
+
case "bc3-rgba-unorm-srgb":
|
|
205
|
+
case "bc5-rg-unorm":
|
|
206
|
+
case "bc5-rg-snorm":
|
|
207
|
+
case "bc6h-rgb-ufloat":
|
|
208
|
+
case "bc6h-rgb-float":
|
|
209
|
+
case "bc7-rgba-unorm":
|
|
210
|
+
case "bc7-rgba-unorm-srgb":
|
|
211
|
+
return { width: 4, height: 4, bytesPerBlock: 16 };
|
|
212
|
+
// ETC2 — 4×4 blocks
|
|
213
|
+
case "etc2-rgb8unorm":
|
|
214
|
+
case "etc2-rgb8unorm-srgb":
|
|
215
|
+
case "etc2-rgb8a1unorm":
|
|
216
|
+
case "etc2-rgb8a1unorm-srgb":
|
|
217
|
+
case "eac-r11unorm":
|
|
218
|
+
case "eac-r11snorm":
|
|
219
|
+
return { width: 4, height: 4, bytesPerBlock: 8 };
|
|
220
|
+
case "etc2-rgba8unorm":
|
|
221
|
+
case "etc2-rgba8unorm-srgb":
|
|
222
|
+
case "eac-rg11unorm":
|
|
223
|
+
case "eac-rg11snorm":
|
|
224
|
+
return { width: 4, height: 4, bytesPerBlock: 16 };
|
|
225
|
+
// ASTC — variable block size, all 16 bytes/block.
|
|
226
|
+
case "astc-4x4-unorm":
|
|
227
|
+
case "astc-4x4-unorm-srgb": return { width: 4, height: 4, bytesPerBlock: 16 };
|
|
228
|
+
case "astc-5x4-unorm":
|
|
229
|
+
case "astc-5x4-unorm-srgb": return { width: 5, height: 4, bytesPerBlock: 16 };
|
|
230
|
+
case "astc-5x5-unorm":
|
|
231
|
+
case "astc-5x5-unorm-srgb": return { width: 5, height: 5, bytesPerBlock: 16 };
|
|
232
|
+
case "astc-6x5-unorm":
|
|
233
|
+
case "astc-6x5-unorm-srgb": return { width: 6, height: 5, bytesPerBlock: 16 };
|
|
234
|
+
case "astc-6x6-unorm":
|
|
235
|
+
case "astc-6x6-unorm-srgb": return { width: 6, height: 6, bytesPerBlock: 16 };
|
|
236
|
+
case "astc-8x5-unorm":
|
|
237
|
+
case "astc-8x5-unorm-srgb": return { width: 8, height: 5, bytesPerBlock: 16 };
|
|
238
|
+
case "astc-8x6-unorm":
|
|
239
|
+
case "astc-8x6-unorm-srgb": return { width: 8, height: 6, bytesPerBlock: 16 };
|
|
240
|
+
case "astc-8x8-unorm":
|
|
241
|
+
case "astc-8x8-unorm-srgb": return { width: 8, height: 8, bytesPerBlock: 16 };
|
|
242
|
+
case "astc-10x5-unorm":
|
|
243
|
+
case "astc-10x5-unorm-srgb": return { width: 10, height: 5, bytesPerBlock: 16 };
|
|
244
|
+
case "astc-10x6-unorm":
|
|
245
|
+
case "astc-10x6-unorm-srgb": return { width: 10, height: 6, bytesPerBlock: 16 };
|
|
246
|
+
case "astc-10x8-unorm":
|
|
247
|
+
case "astc-10x8-unorm-srgb": return { width: 10, height: 8, bytesPerBlock: 16 };
|
|
248
|
+
case "astc-10x10-unorm":
|
|
249
|
+
case "astc-10x10-unorm-srgb": return { width: 10, height: 10, bytesPerBlock: 16 };
|
|
250
|
+
case "astc-12x10-unorm":
|
|
251
|
+
case "astc-12x10-unorm-srgb": return { width: 12, height: 10, bytesPerBlock: 16 };
|
|
252
|
+
case "astc-12x12-unorm":
|
|
253
|
+
case "astc-12x12-unorm-srgb": return { width: 12, height: 12, bytesPerBlock: 16 };
|
|
254
|
+
default:
|
|
255
|
+
throw new Error(`blockInfoFor: unsupported format ${format}`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Wrap an `aval<ITexture>` as a ref-counted, adaptively-uploaded
|
|
260
|
+
* `AdaptiveResource<GPUTexture>`.
|
|
261
|
+
*/
|
|
262
|
+
export function prepareAdaptiveTexture(device, source, opts = {}) {
|
|
263
|
+
return new AdaptiveTexture(device, source, opts);
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=adaptiveTexture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptiveTexture.js","sourceRoot":"","sources":["../../src/resources/adaptiveTexture.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,kCAAkC;AAClC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,+DAA+D;AAC/D,8DAA8D;AAC9D,qBAAqB;AACrB,EAAE;A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AE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAG,aAAa,EAAE,EAAE,EAAE,CAAC;QAC3G,KAAK,iBAAiB,CAAC;QAAE,KAAK,sBAAsB,CAAC,CAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAG,aAAa,EAAE,EAAE,EAAE,CAAC;QAC3G,KAAK,iBAAiB,CAAC;QAAE,KAAK,sBAAsB,CAAC,CAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAG,aAAa,EAAE,EAAE,EAAE,CAAC;QAC3G,KAAK,kBAAkB,CAAC;QAAC,KAAK,uBAAuB,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;QAC3G,KAAK,kBAAkB,CAAC;QAAC,KAAK,uBAAuB,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;QAC3G,KAAK,kBAAkB,CAAC;QAAC,KAAK,uBAAuB,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;QAE3G;YACE,MAAM,IAAI,KAAK,CAAC,oCAAoC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAiB,EACjB,MAAsB,EACtB,OAAsC,EAAE;IAExC,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AdaptiveResource, type IFramebuffer } from "../core/index.js";
|
|
2
|
+
import { type aval } from "@aardworx/wombat.adaptive";
|
|
3
|
+
export interface FramebufferSize {
|
|
4
|
+
readonly width: number;
|
|
5
|
+
readonly height: number;
|
|
6
|
+
}
|
|
7
|
+
export interface AllocateFramebufferOptions {
|
|
8
|
+
/** Extra usage flags ORed into every attachment. `RENDER_ATTACHMENT` is added automatically. */
|
|
9
|
+
readonly extraUsage?: GPUTextureUsageFlags;
|
|
10
|
+
/** Optional debug-label prefix; attachment name is appended. */
|
|
11
|
+
readonly labelPrefix?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function allocateFramebuffer(device: GPUDevice, signature: import("../core/index.js").FramebufferSignature, size: aval<FramebufferSize>, opts?: AllocateFramebufferOptions): AdaptiveResource<IFramebuffer>;
|
|
14
|
+
//# sourceMappingURL=framebuffer.d.ts.map
|