@luma.gl/core 9.2.6 → 9.3.0-alpha.10
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/adapter/canvas-context.d.ts +6 -162
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/canvas-context.js +5 -419
- package/dist/adapter/canvas-context.js.map +1 -1
- package/dist/adapter/canvas-observer.d.ts +32 -0
- package/dist/adapter/canvas-observer.d.ts.map +1 -0
- package/dist/adapter/canvas-observer.js +90 -0
- package/dist/adapter/canvas-observer.js.map +1 -0
- package/dist/adapter/canvas-surface.d.ts +150 -0
- package/dist/adapter/canvas-surface.d.ts.map +1 -0
- package/dist/adapter/canvas-surface.js +392 -0
- package/dist/adapter/canvas-surface.js.map +1 -0
- package/dist/adapter/device.d.ts +81 -16
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +191 -10
- package/dist/adapter/device.js.map +1 -1
- package/dist/adapter/luma.js +1 -1
- package/dist/adapter/luma.js.map +1 -1
- package/dist/adapter/presentation-context.d.ts +11 -0
- package/dist/adapter/presentation-context.d.ts.map +1 -0
- package/dist/adapter/presentation-context.js +12 -0
- package/dist/adapter/presentation-context.js.map +1 -0
- package/dist/adapter/resources/buffer.d.ts +1 -1
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +14 -6
- package/dist/adapter/resources/buffer.js.map +1 -1
- package/dist/adapter/resources/command-buffer.d.ts +3 -1
- package/dist/adapter/resources/command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/command-buffer.js +3 -1
- package/dist/adapter/resources/command-buffer.js.map +1 -1
- package/dist/adapter/resources/command-encoder.d.ts +30 -7
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/command-encoder.js +68 -2
- package/dist/adapter/resources/command-encoder.js.map +1 -1
- package/dist/adapter/resources/compute-pipeline.d.ts +2 -2
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/fence.d.ts +16 -0
- package/dist/adapter/resources/fence.d.ts.map +1 -0
- package/dist/adapter/resources/fence.js +17 -0
- package/dist/adapter/resources/fence.js.map +1 -0
- package/dist/adapter/resources/framebuffer.d.ts +1 -1
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +15 -12
- package/dist/adapter/resources/framebuffer.js.map +1 -1
- package/dist/adapter/resources/query-set.d.ts +17 -1
- package/dist/adapter/resources/query-set.d.ts.map +1 -1
- package/dist/adapter/resources/query-set.js.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +28 -10
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +21 -2
- package/dist/adapter/resources/render-pipeline.js.map +1 -1
- package/dist/adapter/resources/resource.d.ts +13 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js +243 -14
- package/dist/adapter/resources/resource.js.map +1 -1
- package/dist/adapter/resources/shader.js +27 -25
- package/dist/adapter/resources/shader.js.map +1 -1
- package/dist/adapter/resources/shared-render-pipeline.d.ts +22 -0
- package/dist/adapter/resources/shared-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/shared-render-pipeline.js +25 -0
- package/dist/adapter/resources/shared-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/texture-view.d.ts +1 -1
- package/dist/adapter/resources/texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/texture.d.ts +168 -28
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +284 -25
- package/dist/adapter/resources/texture.js.map +1 -1
- package/dist/adapter/types/attachments.d.ts +1 -1
- package/dist/adapter/types/attachments.d.ts.map +1 -1
- package/dist/adapter/types/buffer-layout.d.ts +1 -1
- package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
- package/dist/adapter/types/parameters.d.ts +3 -1
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- package/dist/adapter/types/parameters.js +1 -0
- package/dist/adapter/types/parameters.js.map +1 -1
- package/dist/adapter/types/shader-layout.d.ts +10 -6
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter/types/uniforms.d.ts +6 -0
- package/dist/adapter/types/uniforms.d.ts.map +1 -1
- package/dist/adapter-utils/bind-groups.d.ts +9 -0
- package/dist/adapter-utils/bind-groups.d.ts.map +1 -0
- package/dist/adapter-utils/bind-groups.js +41 -0
- package/dist/adapter-utils/bind-groups.js.map +1 -0
- package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -1
- package/dist/adapter-utils/format-compiler-log.js +23 -15
- package/dist/adapter-utils/format-compiler-log.js.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts +2 -2
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.js +6 -6
- package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
- package/dist/dist.dev.js +2686 -644
- package/dist/dist.min.js +10 -9
- package/dist/factories/bind-group-factory.d.ts +20 -0
- package/dist/factories/bind-group-factory.d.ts.map +1 -0
- package/dist/factories/bind-group-factory.js +79 -0
- package/dist/factories/bind-group-factory.js.map +1 -0
- package/dist/factories/core-module-state.d.ts +7 -0
- package/dist/factories/core-module-state.d.ts.map +1 -0
- package/dist/{shadertypes/data-types/shader-types.js → factories/core-module-state.js} +1 -1
- package/dist/factories/core-module-state.js.map +1 -0
- package/dist/factories/pipeline-factory.d.ts +54 -0
- package/dist/factories/pipeline-factory.d.ts.map +1 -0
- package/dist/factories/pipeline-factory.js +270 -0
- package/dist/factories/pipeline-factory.js.map +1 -0
- package/dist/factories/shader-factory.d.ts +20 -0
- package/dist/factories/shader-factory.d.ts.map +1 -0
- package/dist/factories/shader-factory.js +84 -0
- package/dist/factories/shader-factory.js.map +1 -0
- package/dist/index.cjs +2422 -554
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +30 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/portable/shader-block-writer.d.ts +51 -0
- package/dist/portable/shader-block-writer.d.ts.map +1 -0
- package/dist/portable/shader-block-writer.js +185 -0
- package/dist/portable/shader-block-writer.js.map +1 -0
- package/dist/portable/uniform-block.d.ts +1 -1
- package/dist/portable/uniform-block.d.ts.map +1 -1
- package/dist/portable/uniform-store.d.ts +55 -24
- package/dist/portable/uniform-store.d.ts.map +1 -1
- package/dist/portable/uniform-store.js +73 -25
- package/dist/portable/uniform-store.js.map +1 -1
- package/dist/shadertypes/data-types/data-type-decoder.d.ts +20 -0
- package/dist/shadertypes/data-types/data-type-decoder.d.ts.map +1 -0
- package/dist/shadertypes/data-types/data-type-decoder.js +79 -0
- package/dist/shadertypes/data-types/data-type-decoder.js.map +1 -0
- package/dist/shadertypes/data-types/data-types.d.ts +31 -12
- package/dist/shadertypes/data-types/data-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-data-types.js +2 -1
- package/dist/shadertypes/data-types/decode-data-types.js.map +1 -1
- package/dist/{image-utils → shadertypes/image-types}/image-types.d.ts +0 -6
- package/dist/shadertypes/image-types/image-types.d.ts.map +1 -0
- package/dist/shadertypes/image-types/image-types.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-block-layout.d.ts +72 -0
- package/dist/shadertypes/shader-types/shader-block-layout.d.ts.map +1 -0
- package/dist/shadertypes/shader-types/shader-block-layout.js +209 -0
- package/dist/shadertypes/shader-types/shader-block-layout.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-type-decoder.d.ts +41 -0
- package/dist/shadertypes/shader-types/shader-type-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{data-types/decode-shader-types.js → shader-types/shader-type-decoder.js} +43 -4
- package/dist/shadertypes/shader-types/shader-type-decoder.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-types.d.ts +101 -0
- package/dist/shadertypes/shader-types/shader-types.d.ts.map +1 -0
- package/dist/shadertypes/shader-types/shader-types.js +30 -0
- package/dist/shadertypes/shader-types/shader-types.js.map +1 -0
- package/dist/shadertypes/texture-types/pixel-utils.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/pixel-utils.js +4 -4
- package/dist/shadertypes/texture-types/pixel-utils.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-decoder.d.ts +36 -0
- package/dist/shadertypes/texture-types/texture-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-format-decoder.js +109 -37
- package/dist/shadertypes/texture-types/texture-format-decoder.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-generics.d.ts +34 -0
- package/dist/shadertypes/texture-types/texture-format-generics.d.ts.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-generics.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-table.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-format-table.js +10 -9
- package/dist/shadertypes/texture-types/texture-format-table.js.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-formats.d.ts +51 -17
- package/dist/shadertypes/texture-types/texture-formats.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-formats.js +1 -0
- package/dist/shadertypes/texture-types/texture-formats.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-layout.d.ts +5 -0
- package/dist/shadertypes/texture-types/texture-layout.d.ts.map +1 -0
- package/dist/shadertypes/texture-types/texture-layout.js +41 -0
- package/dist/shadertypes/texture-types/texture-layout.js.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts +24 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.js +106 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.js.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-formats.d.ts +50 -0
- package/dist/shadertypes/vertex-types/vertex-formats.d.ts.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-formats.js.map +1 -0
- package/dist/utils/array-equal.d.ts +1 -1
- package/dist/utils/array-equal.d.ts.map +1 -1
- package/dist/utils/array-equal.js +15 -9
- package/dist/utils/array-equal.js.map +1 -1
- package/dist/utils/assert.d.ts +5 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/assert.js +17 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/stats-manager.d.ts.map +1 -1
- package/dist/utils/stats-manager.js +61 -1
- package/dist/utils/stats-manager.js.map +1 -1
- package/package.json +6 -6
- package/src/adapter/canvas-context.ts +7 -556
- package/src/adapter/canvas-observer.ts +130 -0
- package/src/adapter/canvas-surface.ts +521 -0
- package/src/adapter/device.ts +308 -24
- package/src/adapter/presentation-context.ts +16 -0
- package/src/adapter/resources/buffer.ts +13 -5
- package/src/adapter/resources/command-buffer.ts +4 -2
- package/src/adapter/resources/command-encoder.ts +101 -10
- package/src/adapter/resources/compute-pipeline.ts +2 -2
- package/src/adapter/resources/fence.ts +32 -0
- package/src/adapter/resources/framebuffer.ts +16 -13
- package/src/adapter/resources/query-set.ts +17 -1
- package/src/adapter/resources/render-pipeline.ts +52 -16
- package/src/adapter/resources/resource.ts +289 -14
- package/src/adapter/resources/shader.ts +28 -28
- package/src/adapter/resources/shared-render-pipeline.ts +40 -0
- package/src/adapter/resources/texture-view.ts +1 -1
- package/src/adapter/resources/texture.ts +427 -49
- package/src/adapter/types/attachments.ts +1 -1
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +4 -1
- package/src/adapter/types/shader-layout.ts +15 -9
- package/src/adapter/types/uniforms.ts +12 -0
- package/src/adapter-utils/bind-groups.ts +71 -0
- package/src/adapter-utils/format-compiler-log.ts +23 -15
- package/src/adapter-utils/get-attribute-from-layouts.ts +8 -11
- package/src/factories/bind-group-factory.ts +139 -0
- package/src/factories/core-module-state.ts +11 -0
- package/src/factories/pipeline-factory.ts +328 -0
- package/src/factories/shader-factory.ts +103 -0
- package/src/index.ts +70 -26
- package/src/portable/shader-block-writer.ts +254 -0
- package/src/portable/uniform-block.ts +1 -1
- package/src/portable/uniform-store.ts +98 -40
- package/src/shadertypes/data-types/data-type-decoder.ts +105 -0
- package/src/shadertypes/data-types/data-types.ts +100 -48
- package/src/shadertypes/data-types/decode-data-types.ts +2 -1
- package/src/{image-utils → shadertypes/image-types}/image-types.ts +0 -7
- package/src/shadertypes/shader-types/shader-block-layout.ts +340 -0
- package/src/shadertypes/{data-types/decode-shader-types.ts → shader-types/shader-type-decoder.ts} +88 -14
- package/src/shadertypes/shader-types/shader-types.ts +207 -0
- package/src/shadertypes/{textures → texture-types}/pixel-utils.ts +4 -4
- package/src/shadertypes/{textures → texture-types}/texture-format-decoder.ts +166 -45
- package/src/shadertypes/{textures → texture-types}/texture-format-generics.ts +42 -48
- package/src/shadertypes/{textures → texture-types}/texture-format-table.ts +10 -9
- package/src/shadertypes/{textures → texture-types}/texture-formats.ts +73 -17
- package/src/shadertypes/texture-types/texture-layout.ts +60 -0
- package/src/shadertypes/vertex-types/vertex-format-decoder.ts +131 -0
- package/src/shadertypes/vertex-types/vertex-formats.ts +183 -0
- package/src/utils/array-equal.ts +21 -9
- package/src/utils/assert.ts +18 -0
- package/src/utils/stats-manager.ts +76 -2
- package/dist/image-utils/image-types.d.ts.map +0 -1
- package/dist/image-utils/image-types.js.map +0 -1
- package/dist/portable/uniform-buffer-layout.d.ts +0 -28
- package/dist/portable/uniform-buffer-layout.d.ts.map +0 -1
- package/dist/portable/uniform-buffer-layout.js +0 -96
- package/dist/portable/uniform-buffer-layout.js.map +0 -1
- package/dist/shadertypes/data-types/decode-shader-types.d.ts +0 -17
- package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types/decode-shader-types.js.map +0 -1
- package/dist/shadertypes/data-types/shader-types.d.ts +0 -45
- package/dist/shadertypes/data-types/shader-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types/shader-types.js.map +0 -1
- package/dist/shadertypes/textures/pixel-utils.d.ts.map +0 -1
- package/dist/shadertypes/textures/pixel-utils.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-decoder.d.ts +0 -18
- package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-decoder.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-generics.d.ts +0 -33
- package/dist/shadertypes/textures/texture-format-generics.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-generics.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-table.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-table.js.map +0 -1
- package/dist/shadertypes/textures/texture-formats.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-formats.js.map +0 -1
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts +0 -18
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +0 -1
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js +0 -100
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +0 -1
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts +0 -27
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +0 -1
- package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +0 -1
- package/src/portable/uniform-buffer-layout.ts +0 -118
- package/src/shadertypes/data-types/shader-types.ts +0 -87
- package/src/shadertypes/vertex-arrays/decode-vertex-format.ts +0 -124
- package/src/shadertypes/vertex-arrays/vertex-formats.ts +0 -91
- /package/dist/{image-utils → shadertypes/image-types}/image-types.js +0 -0
- /package/dist/shadertypes/{textures → texture-types}/pixel-utils.d.ts +0 -0
- /package/dist/shadertypes/{textures → texture-types}/texture-format-generics.js +0 -0
- /package/dist/shadertypes/{textures → texture-types}/texture-format-table.d.ts +0 -0
- /package/dist/shadertypes/{vertex-arrays → vertex-types}/vertex-formats.js +0 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { isBrowser } from '@probe.gl/env';
|
|
5
|
+
import { CanvasObserver } from "./canvas-observer.js";
|
|
6
|
+
import { uid } from "../utils/uid.js";
|
|
7
|
+
import { withResolvers } from "../utils/promise-utils.js";
|
|
8
|
+
import { assertDefined } from "../utils/assert.js";
|
|
9
|
+
/**
|
|
10
|
+
* Shared tracked-canvas lifecycle used by both renderable and presentation contexts.
|
|
11
|
+
* - Creates a new canvas or looks up a canvas from the DOM
|
|
12
|
+
* - Provides check for DOM loaded
|
|
13
|
+
* @todo commit() @see https://github.com/w3ctag/design-reviews/issues/288
|
|
14
|
+
* @todo transferControlToOffscreen: @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen
|
|
15
|
+
*/
|
|
16
|
+
export class CanvasSurface {
|
|
17
|
+
static isHTMLCanvas(canvas) {
|
|
18
|
+
return typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement;
|
|
19
|
+
}
|
|
20
|
+
static isOffscreenCanvas(canvas) {
|
|
21
|
+
return typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas;
|
|
22
|
+
}
|
|
23
|
+
static defaultProps = {
|
|
24
|
+
id: undefined,
|
|
25
|
+
canvas: null,
|
|
26
|
+
width: 800,
|
|
27
|
+
height: 600,
|
|
28
|
+
useDevicePixels: true,
|
|
29
|
+
autoResize: true,
|
|
30
|
+
container: null,
|
|
31
|
+
visible: true,
|
|
32
|
+
alphaMode: 'opaque',
|
|
33
|
+
colorSpace: 'srgb',
|
|
34
|
+
trackPosition: false
|
|
35
|
+
};
|
|
36
|
+
id;
|
|
37
|
+
props;
|
|
38
|
+
canvas;
|
|
39
|
+
/** Handle to HTML canvas */
|
|
40
|
+
htmlCanvas;
|
|
41
|
+
/** Handle to wrapped OffScreenCanvas */
|
|
42
|
+
offscreenCanvas;
|
|
43
|
+
type;
|
|
44
|
+
/** Promise that resolved once the resize observer has updated the pixel size */
|
|
45
|
+
initialized;
|
|
46
|
+
isInitialized = false;
|
|
47
|
+
/** Visibility is automatically updated (via an IntersectionObserver) */
|
|
48
|
+
isVisible = true;
|
|
49
|
+
/** Width of canvas in CSS units (tracked by a ResizeObserver) */
|
|
50
|
+
cssWidth;
|
|
51
|
+
/** Height of canvas in CSS units (tracked by a ResizeObserver) */
|
|
52
|
+
cssHeight;
|
|
53
|
+
/** Device pixel ratio. Automatically updated via media queries */
|
|
54
|
+
devicePixelRatio;
|
|
55
|
+
/** Exact width of canvas in physical pixels (tracked by a ResizeObserver) */
|
|
56
|
+
devicePixelWidth;
|
|
57
|
+
/** Exact height of canvas in physical pixels (tracked by a ResizeObserver) */
|
|
58
|
+
devicePixelHeight;
|
|
59
|
+
/** Width of drawing buffer: automatically tracks this.pixelWidth if props.autoResize is true */
|
|
60
|
+
drawingBufferWidth;
|
|
61
|
+
/** Height of drawing buffer: automatically tracks this.pixelHeight if props.autoResize is true */
|
|
62
|
+
drawingBufferHeight;
|
|
63
|
+
/** Resolves when the canvas is initialized, i.e. when the ResizeObserver has updated the pixel size */
|
|
64
|
+
_initializedResolvers = withResolvers();
|
|
65
|
+
_canvasObserver;
|
|
66
|
+
/** Position of the canvas in the document, updated by a timer */
|
|
67
|
+
_position = [0, 0];
|
|
68
|
+
/** Whether this canvas context has been destroyed */
|
|
69
|
+
destroyed = false;
|
|
70
|
+
/** Whether the drawing buffer size needs to be resized (deferred resizing to avoid flicker) */
|
|
71
|
+
_needsDrawingBufferResize = true;
|
|
72
|
+
toString() {
|
|
73
|
+
return `${this[Symbol.toStringTag]}(${this.id})`;
|
|
74
|
+
}
|
|
75
|
+
constructor(props) {
|
|
76
|
+
this.props = { ...CanvasSurface.defaultProps, ...props };
|
|
77
|
+
props = this.props;
|
|
78
|
+
this.initialized = this._initializedResolvers.promise;
|
|
79
|
+
if (!isBrowser()) {
|
|
80
|
+
this.canvas = { width: props.width || 1, height: props.height || 1 };
|
|
81
|
+
}
|
|
82
|
+
else if (!props.canvas) {
|
|
83
|
+
this.canvas = createCanvasElement(props);
|
|
84
|
+
}
|
|
85
|
+
else if (typeof props.canvas === 'string') {
|
|
86
|
+
this.canvas = getCanvasFromDOM(props.canvas);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this.canvas = props.canvas;
|
|
90
|
+
}
|
|
91
|
+
if (CanvasSurface.isHTMLCanvas(this.canvas)) {
|
|
92
|
+
this.id = props.id || this.canvas.id;
|
|
93
|
+
this.type = 'html-canvas';
|
|
94
|
+
this.htmlCanvas = this.canvas;
|
|
95
|
+
}
|
|
96
|
+
else if (CanvasSurface.isOffscreenCanvas(this.canvas)) {
|
|
97
|
+
this.id = props.id || 'offscreen-canvas';
|
|
98
|
+
this.type = 'offscreen-canvas';
|
|
99
|
+
this.offscreenCanvas = this.canvas;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.id = props.id || 'node-canvas-context';
|
|
103
|
+
this.type = 'node';
|
|
104
|
+
}
|
|
105
|
+
this.cssWidth = this.htmlCanvas?.clientWidth || this.canvas.width;
|
|
106
|
+
this.cssHeight = this.htmlCanvas?.clientHeight || this.canvas.height;
|
|
107
|
+
this.devicePixelWidth = this.canvas.width;
|
|
108
|
+
this.devicePixelHeight = this.canvas.height;
|
|
109
|
+
this.drawingBufferWidth = this.canvas.width;
|
|
110
|
+
this.drawingBufferHeight = this.canvas.height;
|
|
111
|
+
this.devicePixelRatio = globalThis.devicePixelRatio || 1;
|
|
112
|
+
this._position = [0, 0];
|
|
113
|
+
this._canvasObserver = new CanvasObserver({
|
|
114
|
+
canvas: this.htmlCanvas,
|
|
115
|
+
trackPosition: this.props.trackPosition,
|
|
116
|
+
onResize: entries => this._handleResize(entries),
|
|
117
|
+
onIntersection: entries => this._handleIntersection(entries),
|
|
118
|
+
onDevicePixelRatioChange: () => this._observeDevicePixelRatio(),
|
|
119
|
+
onPositionChange: () => this.updatePosition()
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
destroy() {
|
|
123
|
+
if (!this.destroyed) {
|
|
124
|
+
this.destroyed = true;
|
|
125
|
+
this._stopObservers();
|
|
126
|
+
// @ts-expect-error Clear the device to make sure we don't access it after destruction.
|
|
127
|
+
this.device = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
setProps(props) {
|
|
131
|
+
if ('useDevicePixels' in props) {
|
|
132
|
+
this.props.useDevicePixels = props.useDevicePixels || false;
|
|
133
|
+
this._updateDrawingBufferSize();
|
|
134
|
+
}
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
/** Returns a framebuffer with properly resized current 'swap chain' textures */
|
|
138
|
+
getCurrentFramebuffer(options) {
|
|
139
|
+
this._resizeDrawingBufferIfNeeded();
|
|
140
|
+
return this._getCurrentFramebuffer(options);
|
|
141
|
+
}
|
|
142
|
+
getCSSSize() {
|
|
143
|
+
return [this.cssWidth, this.cssHeight];
|
|
144
|
+
}
|
|
145
|
+
getPosition() {
|
|
146
|
+
return this._position;
|
|
147
|
+
}
|
|
148
|
+
getDevicePixelSize() {
|
|
149
|
+
return [this.devicePixelWidth, this.devicePixelHeight];
|
|
150
|
+
}
|
|
151
|
+
getDrawingBufferSize() {
|
|
152
|
+
return [this.drawingBufferWidth, this.drawingBufferHeight];
|
|
153
|
+
}
|
|
154
|
+
getMaxDrawingBufferSize() {
|
|
155
|
+
const maxTextureDimension = this.device.limits.maxTextureDimension2D;
|
|
156
|
+
return [maxTextureDimension, maxTextureDimension];
|
|
157
|
+
}
|
|
158
|
+
setDrawingBufferSize(width, height) {
|
|
159
|
+
width = Math.floor(width);
|
|
160
|
+
height = Math.floor(height);
|
|
161
|
+
if (this.drawingBufferWidth === width && this.drawingBufferHeight === height) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this.drawingBufferWidth = width;
|
|
165
|
+
this.drawingBufferHeight = height;
|
|
166
|
+
this._needsDrawingBufferResize = true;
|
|
167
|
+
}
|
|
168
|
+
getDevicePixelRatio() {
|
|
169
|
+
const devicePixelRatio = typeof window !== 'undefined' && window.devicePixelRatio;
|
|
170
|
+
return devicePixelRatio || 1;
|
|
171
|
+
}
|
|
172
|
+
cssToDevicePixels(cssPixel, yInvert = true) {
|
|
173
|
+
const ratio = this.cssToDeviceRatio();
|
|
174
|
+
const [width, height] = this.getDrawingBufferSize();
|
|
175
|
+
return scalePixels(cssPixel, ratio, width, height, yInvert);
|
|
176
|
+
}
|
|
177
|
+
/** @deprecated - use .getDevicePixelSize() */
|
|
178
|
+
getPixelSize() {
|
|
179
|
+
return this.getDevicePixelSize();
|
|
180
|
+
}
|
|
181
|
+
/** @deprecated Use the current drawing buffer size for projection setup. */
|
|
182
|
+
getAspect() {
|
|
183
|
+
const [width, height] = this.getDrawingBufferSize();
|
|
184
|
+
return width > 0 && height > 0 ? width / height : 1;
|
|
185
|
+
}
|
|
186
|
+
/** @deprecated Returns multiplier need to convert CSS size to Device size */
|
|
187
|
+
cssToDeviceRatio() {
|
|
188
|
+
try {
|
|
189
|
+
const [drawingBufferWidth] = this.getDrawingBufferSize();
|
|
190
|
+
const [cssWidth] = this.getCSSSize();
|
|
191
|
+
return cssWidth ? drawingBufferWidth / cssWidth : 1;
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
return 1;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/** @deprecated Use canvasContext.setDrawingBufferSize() */
|
|
198
|
+
resize(size) {
|
|
199
|
+
this.setDrawingBufferSize(size.width, size.height);
|
|
200
|
+
}
|
|
201
|
+
_setAutoCreatedCanvasId(id) {
|
|
202
|
+
if (this.htmlCanvas?.id === 'lumagl-auto-created-canvas') {
|
|
203
|
+
this.htmlCanvas.id = id;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Starts DOM observation after the derived context and its device are fully initialized.
|
|
208
|
+
*
|
|
209
|
+
* `CanvasSurface` construction runs before subclasses can assign `this.device`, and the
|
|
210
|
+
* default WebGL canvas context is created before `WebGLDevice` has initialized `limits`,
|
|
211
|
+
* `features`, and the rest of its runtime state. Deferring observer startup avoids early
|
|
212
|
+
* `ResizeObserver` and DPR callbacks running against a partially initialized device.
|
|
213
|
+
*/
|
|
214
|
+
_startObservers() {
|
|
215
|
+
if (this.destroyed) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this._canvasObserver.start();
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Stops all DOM observation and timers associated with a canvas surface.
|
|
222
|
+
*
|
|
223
|
+
* This pairs with `_startObservers()` so teardown uses the same lifecycle whether a context is
|
|
224
|
+
* explicitly destroyed, abandoned during device reuse, or temporarily has not started observing
|
|
225
|
+
* yet. Centralizing shutdown here keeps resize/DPR/position watchers from surviving past the
|
|
226
|
+
* lifetime of the owning device.
|
|
227
|
+
*/
|
|
228
|
+
_stopObservers() {
|
|
229
|
+
this._canvasObserver.stop();
|
|
230
|
+
}
|
|
231
|
+
_handleIntersection(entries) {
|
|
232
|
+
if (this.destroyed) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const entry = entries.find(entry_ => entry_.target === this.canvas);
|
|
236
|
+
if (!entry) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const isVisible = entry.isIntersecting;
|
|
240
|
+
if (this.isVisible !== isVisible) {
|
|
241
|
+
this.isVisible = isVisible;
|
|
242
|
+
this.device.props.onVisibilityChange(this);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
_handleResize(entries) {
|
|
246
|
+
if (this.destroyed) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const entry = entries.find(entry_ => entry_.target === this.canvas);
|
|
250
|
+
if (!entry) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const contentBoxSize = assertDefined(entry.contentBoxSize?.[0]);
|
|
254
|
+
this.cssWidth = contentBoxSize.inlineSize;
|
|
255
|
+
this.cssHeight = contentBoxSize.blockSize;
|
|
256
|
+
const oldPixelSize = this.getDevicePixelSize();
|
|
257
|
+
const devicePixelWidth = entry.devicePixelContentBoxSize?.[0]?.inlineSize ||
|
|
258
|
+
contentBoxSize.inlineSize * devicePixelRatio;
|
|
259
|
+
const devicePixelHeight = entry.devicePixelContentBoxSize?.[0]?.blockSize ||
|
|
260
|
+
contentBoxSize.blockSize * devicePixelRatio;
|
|
261
|
+
const [maxDevicePixelWidth, maxDevicePixelHeight] = this.getMaxDrawingBufferSize();
|
|
262
|
+
this.devicePixelWidth = Math.max(1, Math.min(devicePixelWidth, maxDevicePixelWidth));
|
|
263
|
+
this.devicePixelHeight = Math.max(1, Math.min(devicePixelHeight, maxDevicePixelHeight));
|
|
264
|
+
this._updateDrawingBufferSize();
|
|
265
|
+
this.device.props.onResize(this, { oldPixelSize });
|
|
266
|
+
}
|
|
267
|
+
_updateDrawingBufferSize() {
|
|
268
|
+
if (this.props.autoResize) {
|
|
269
|
+
if (typeof this.props.useDevicePixels === 'number') {
|
|
270
|
+
const devicePixelRatio = this.props.useDevicePixels;
|
|
271
|
+
this.setDrawingBufferSize(this.cssWidth * devicePixelRatio, this.cssHeight * devicePixelRatio);
|
|
272
|
+
}
|
|
273
|
+
else if (this.props.useDevicePixels) {
|
|
274
|
+
this.setDrawingBufferSize(this.devicePixelWidth, this.devicePixelHeight);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
this.setDrawingBufferSize(this.cssWidth, this.cssHeight);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
this._initializedResolvers.resolve();
|
|
281
|
+
this.isInitialized = true;
|
|
282
|
+
this.updatePosition();
|
|
283
|
+
}
|
|
284
|
+
_resizeDrawingBufferIfNeeded() {
|
|
285
|
+
if (this._needsDrawingBufferResize) {
|
|
286
|
+
this._needsDrawingBufferResize = false;
|
|
287
|
+
const sizeChanged = this.drawingBufferWidth !== this.canvas.width ||
|
|
288
|
+
this.drawingBufferHeight !== this.canvas.height;
|
|
289
|
+
if (sizeChanged) {
|
|
290
|
+
this.canvas.width = this.drawingBufferWidth;
|
|
291
|
+
this.canvas.height = this.drawingBufferHeight;
|
|
292
|
+
this._configureDevice();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
_observeDevicePixelRatio() {
|
|
297
|
+
if (this.destroyed || !this._canvasObserver.started) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const oldRatio = this.devicePixelRatio;
|
|
301
|
+
this.devicePixelRatio = window.devicePixelRatio;
|
|
302
|
+
this.updatePosition();
|
|
303
|
+
this.device.props.onDevicePixelRatioChange?.(this, {
|
|
304
|
+
oldRatio
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
updatePosition() {
|
|
308
|
+
if (this.destroyed) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const newRect = this.htmlCanvas?.getBoundingClientRect();
|
|
312
|
+
if (newRect) {
|
|
313
|
+
const position = [newRect.left, newRect.top];
|
|
314
|
+
this._position ??= position;
|
|
315
|
+
const positionChanged = position[0] !== this._position[0] || position[1] !== this._position[1];
|
|
316
|
+
if (positionChanged) {
|
|
317
|
+
const oldPosition = this._position;
|
|
318
|
+
this._position = position;
|
|
319
|
+
this.device.props.onPositionChange?.(this, {
|
|
320
|
+
oldPosition
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function getContainer(container) {
|
|
327
|
+
if (typeof container === 'string') {
|
|
328
|
+
const element = document.getElementById(container);
|
|
329
|
+
if (!element) {
|
|
330
|
+
throw new Error(`${container} is not an HTML element`);
|
|
331
|
+
}
|
|
332
|
+
return element;
|
|
333
|
+
}
|
|
334
|
+
if (container) {
|
|
335
|
+
return container;
|
|
336
|
+
}
|
|
337
|
+
return document.body;
|
|
338
|
+
}
|
|
339
|
+
function getCanvasFromDOM(canvasId) {
|
|
340
|
+
const canvas = document.getElementById(canvasId);
|
|
341
|
+
if (!CanvasSurface.isHTMLCanvas(canvas)) {
|
|
342
|
+
throw new Error('Object is not a canvas element');
|
|
343
|
+
}
|
|
344
|
+
return canvas;
|
|
345
|
+
}
|
|
346
|
+
function createCanvasElement(props) {
|
|
347
|
+
const { width, height } = props;
|
|
348
|
+
const newCanvas = document.createElement('canvas');
|
|
349
|
+
newCanvas.id = uid('lumagl-auto-created-canvas');
|
|
350
|
+
newCanvas.width = width || 1;
|
|
351
|
+
newCanvas.height = height || 1;
|
|
352
|
+
newCanvas.style.width = Number.isFinite(width) ? `${width}px` : '100%';
|
|
353
|
+
newCanvas.style.height = Number.isFinite(height) ? `${height}px` : '100%';
|
|
354
|
+
if (!props?.visible) {
|
|
355
|
+
newCanvas.style.visibility = 'hidden';
|
|
356
|
+
}
|
|
357
|
+
const container = getContainer(props?.container || null);
|
|
358
|
+
container.insertBefore(newCanvas, container.firstChild);
|
|
359
|
+
return newCanvas;
|
|
360
|
+
}
|
|
361
|
+
function scalePixels(pixel, ratio, width, height, yInvert) {
|
|
362
|
+
const point = pixel;
|
|
363
|
+
const x = scaleX(point[0], ratio, width);
|
|
364
|
+
let y = scaleY(point[1], ratio, height, yInvert);
|
|
365
|
+
let temporary = scaleX(point[0] + 1, ratio, width);
|
|
366
|
+
const xHigh = temporary === width - 1 ? temporary : temporary - 1;
|
|
367
|
+
temporary = scaleY(point[1] + 1, ratio, height, yInvert);
|
|
368
|
+
let yHigh;
|
|
369
|
+
if (yInvert) {
|
|
370
|
+
temporary = temporary === 0 ? temporary : temporary + 1;
|
|
371
|
+
yHigh = y;
|
|
372
|
+
y = temporary;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
yHigh = temporary === height - 1 ? temporary : temporary - 1;
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
x,
|
|
379
|
+
y,
|
|
380
|
+
width: Math.max(xHigh - x + 1, 1),
|
|
381
|
+
height: Math.max(yHigh - y + 1, 1)
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
function scaleX(x, ratio, width) {
|
|
385
|
+
return Math.min(Math.round(x * ratio), width - 1);
|
|
386
|
+
}
|
|
387
|
+
function scaleY(y, ratio, height, yInvert) {
|
|
388
|
+
return yInvert
|
|
389
|
+
? Math.max(0, height - 1 - Math.round(y * ratio))
|
|
390
|
+
: Math.min(Math.round(y * ratio), height - 1);
|
|
391
|
+
}
|
|
392
|
+
//# sourceMappingURL=canvas-surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas-surface.js","sourceRoot":"","sources":["../../src/adapter/canvas-surface.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAC,cAAc,EAAC,6BAA0B;AAIjD,OAAO,EAAC,GAAG,EAAC,wBAAqB;AACjC,OAAO,EAAC,aAAa,EAAC,kCAA+B;AACrD,OAAO,EAAC,aAAa,EAAC,2BAAwB;AAiC9C;;;;;;GAMG;AACH,MAAM,OAAgB,aAAa;IACjC,MAAM,CAAC,YAAY,CAAC,MAAe;QACjC,OAAO,OAAO,iBAAiB,KAAK,WAAW,IAAI,MAAM,YAAY,iBAAiB,CAAC;IACzF,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,MAAe;QACtC,OAAO,OAAO,eAAe,KAAK,WAAW,IAAI,MAAM,YAAY,eAAe,CAAC;IACrF,CAAC;IAED,MAAM,CAAC,YAAY,GAAiC;QAClD,EAAE,EAAE,SAAU;QACd,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,eAAe,EAAE,IAAI;QACrB,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,IAAI;QACf,OAAO,EAA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C,KAAK,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;KACnC,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,CAAS,EAAE,KAAa,EAAE,KAAa;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS,EAAE,KAAa,EAAE,MAAc,EAAE,OAAgB;IACxE,OAAO,OAAO;QACZ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QACjD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/adapter/device.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { StatsManager } from "../utils/stats-manager.js";
|
|
2
|
-
import type { VertexFormat, VertexFormatInfo } from "../shadertypes/vertex-
|
|
3
|
-
import type { TextureFormat, TextureFormatInfo } from "../shadertypes/
|
|
2
|
+
import type { VertexFormat, VertexFormatInfo } from "../shadertypes/vertex-types/vertex-formats.js";
|
|
3
|
+
import type { TextureFormat, TextureFormatInfo, CompressedTextureFormat } from "../shadertypes/texture-types/texture-formats.js";
|
|
4
4
|
import type { CanvasContext, CanvasContextProps } from "./canvas-context.js";
|
|
5
|
+
import type { PresentationContext, PresentationContextProps } from "./presentation-context.js";
|
|
5
6
|
import type { BufferProps } from "./resources/buffer.js";
|
|
6
7
|
import { Buffer } from "./resources/buffer.js";
|
|
7
8
|
import type { RenderPipeline, RenderPipelineProps } from "./resources/render-pipeline.js";
|
|
9
|
+
import type { SharedRenderPipeline } from "./resources/shared-render-pipeline.js";
|
|
8
10
|
import type { ComputePipeline, ComputePipelineProps } from "./resources/compute-pipeline.js";
|
|
9
11
|
import type { Sampler, SamplerProps } from "./resources/sampler.js";
|
|
10
12
|
import type { Shader, ShaderProps } from "./resources/shader.js";
|
|
@@ -18,7 +20,9 @@ import type { CommandBuffer } from "./resources/command-buffer.js";
|
|
|
18
20
|
import type { VertexArray, VertexArrayProps } from "./resources/vertex-array.js";
|
|
19
21
|
import type { TransformFeedback, TransformFeedbackProps } from "./resources/transform-feedback.js";
|
|
20
22
|
import type { QuerySet, QuerySetProps } from "./resources/query-set.js";
|
|
21
|
-
import type {
|
|
23
|
+
import type { Fence } from "./resources/fence.js";
|
|
24
|
+
import type { Bindings, ComputeShaderLayout, ShaderLayout } from "./types/shader-layout.js";
|
|
25
|
+
import type { ExternalImage } from "../shadertypes/image-types/image-types.js";
|
|
22
26
|
/**
|
|
23
27
|
* Identifies the GPU vendor and driver.
|
|
24
28
|
* @note Chrome WebGPU does not provide much information, though more can be enabled with
|
|
@@ -116,7 +120,7 @@ export declare class DeviceFeatures {
|
|
|
116
120
|
export type DeviceFeature = WebGPUDeviceFeature | WebGLDeviceFeature | WebGLCompressedTextureFeatures;
|
|
117
121
|
/** Chrome-specific extensions. Expected to eventually become standard features. */
|
|
118
122
|
export type WebGPUDeviceFeature = 'depth-clip-control' | 'depth32float-stencil8' | 'texture-compression-bc' | 'texture-compression-bc-sliced-3d' | 'texture-compression-etc2' | 'texture-compression-astc' | 'texture-compression-astc-sliced-3d' | 'timestamp-query' | 'indirect-first-instance' | 'shader-f16' | 'rg11b10ufloat-renderable' | 'bgra8unorm-storage' | 'float32-filterable' | 'float32-blendable' | 'clip-distances' | 'dual-source-blending' | 'subgroups';
|
|
119
|
-
export type WebGLDeviceFeature = '
|
|
123
|
+
export type WebGLDeviceFeature = 'compilation-status-async-webgl' | 'provoking-vertex-webgl' | 'polygon-mode-webgl' | 'shader-noperspective-interpolation-webgl' | 'shader-conservative-depth-webgl' | 'shader-clip-cull-distance-webgl' | 'float32-renderable-webgl' | 'float16-renderable-webgl' | 'rgb9e5ufloat-renderable-webgl' | 'snorm8-renderable-webgl' | 'norm16-webgl' | 'norm16-renderable-webgl' | 'snorm16-renderable-webgl' | 'float16-filterable-webgl' | 'texture-filterable-anisotropic-webgl' | 'bgra8unorm-storage' | 'texture-blend-float-webgl';
|
|
120
124
|
type WebGLCompressedTextureFeatures = 'texture-compression-bc5-webgl' | 'texture-compression-bc7-webgl' | 'texture-compression-etc1-webgl' | 'texture-compression-pvrtc-webgl' | 'texture-compression-atc-webgl';
|
|
121
125
|
/** Texture format capabilities that have been checked against a specific device */
|
|
122
126
|
export type DeviceTextureFormatCapabilities = {
|
|
@@ -147,21 +151,23 @@ export type DeviceProps = {
|
|
|
147
151
|
/** Error handler. If it returns a probe logger style function, it will be called at the site of the error to optimize console error links. */
|
|
148
152
|
onError?: (error: Error, context?: unknown) => unknown;
|
|
149
153
|
/** Called when the size of a CanvasContext's canvas changes */
|
|
150
|
-
onResize?: (ctx: CanvasContext, info: {
|
|
154
|
+
onResize?: (ctx: CanvasContext | PresentationContext, info: {
|
|
151
155
|
oldPixelSize: [number, number];
|
|
152
156
|
}) => unknown;
|
|
153
157
|
/** Called when the absolute position of a CanvasContext's canvas changes. Must set `CanvasContextProps.trackPosition: true` */
|
|
154
|
-
onPositionChange?: (ctx: CanvasContext, info: {
|
|
158
|
+
onPositionChange?: (ctx: CanvasContext | PresentationContext, info: {
|
|
155
159
|
oldPosition: [number, number];
|
|
156
160
|
}) => unknown;
|
|
157
161
|
/** Called when the visibility of a CanvasContext's canvas changes */
|
|
158
|
-
onVisibilityChange?: (ctx: CanvasContext) => unknown;
|
|
162
|
+
onVisibilityChange?: (ctx: CanvasContext | PresentationContext) => unknown;
|
|
159
163
|
/** Called when the device pixel ratio of a CanvasContext's canvas changes */
|
|
160
|
-
onDevicePixelRatioChange?: (ctx: CanvasContext, info: {
|
|
164
|
+
onDevicePixelRatioChange?: (ctx: CanvasContext | PresentationContext, info: {
|
|
161
165
|
oldRatio: number;
|
|
162
166
|
}) => unknown;
|
|
163
167
|
/** Turn on implementation defined checks that slow down execution but help break where errors occur */
|
|
164
168
|
debug?: boolean;
|
|
169
|
+
/** Enable GPU timestamp collection without enabling all debug validation paths. */
|
|
170
|
+
debugGPUTime?: boolean;
|
|
165
171
|
/** Show shader source in browser? The default is `'error'`, meaning that logs are shown when shader compilation has errors */
|
|
166
172
|
debugShaders?: 'never' | 'errors' | 'warnings' | 'always';
|
|
167
173
|
/** Renders a small version of updated Framebuffers into the primary canvas context. Can be set in console luma.log.set('debug-framebuffers', true) */
|
|
@@ -184,13 +190,28 @@ export type DeviceProps = {
|
|
|
184
190
|
_initializeFeatures?: boolean;
|
|
185
191
|
/** Enable shader caching (via ShaderFactory) */
|
|
186
192
|
_cacheShaders?: boolean;
|
|
187
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* Destroy cached shaders when they become unused.
|
|
195
|
+
* Defaults to `false` so repeated create/destroy cycles can still reuse cached shaders.
|
|
196
|
+
* Enable this if the application creates very large numbers of distinct shaders and needs cache eviction.
|
|
197
|
+
*/
|
|
198
|
+
_destroyShaders?: boolean;
|
|
199
|
+
/** Enable pipeline caching (via PipelineFactory) */
|
|
188
200
|
_cachePipelines?: boolean;
|
|
189
|
-
/**
|
|
190
|
-
|
|
201
|
+
/** Enable sharing of backend render-pipeline implementations when caching is enabled. Currently used by WebGL. */
|
|
202
|
+
_sharePipelines?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Destroy cached pipelines when they become unused.
|
|
205
|
+
* Defaults to `false` so repeated create/destroy cycles can still reuse cached pipelines.
|
|
206
|
+
* Enable this if the application creates very large numbers of distinct pipelines and needs cache eviction.
|
|
207
|
+
*/
|
|
208
|
+
_destroyPipelines?: boolean;
|
|
191
209
|
/** @deprecated Internal, Do not use directly! Use `luma.attachDevice()` to attach to pre-created contexts/devices. */
|
|
192
210
|
_handle?: unknown;
|
|
193
211
|
};
|
|
212
|
+
type DeviceFactories = {
|
|
213
|
+
bindGroupFactory?: unknown;
|
|
214
|
+
};
|
|
194
215
|
/** WebGL independent copy of WebGLContextAttributes */
|
|
195
216
|
type WebGLContextProps = {
|
|
196
217
|
/** indicates if the canvas contains an alpha buffer. */
|
|
@@ -242,14 +263,14 @@ export declare abstract class Device {
|
|
|
242
263
|
};
|
|
243
264
|
/** stats */
|
|
244
265
|
readonly statsManager: StatsManager;
|
|
266
|
+
/** Internal per-device factory storage */
|
|
267
|
+
_factories: DeviceFactories;
|
|
245
268
|
/** An abstract timestamp used for change tracking */
|
|
246
269
|
timestamp: number;
|
|
247
270
|
/** True if this device has been reused during device creation (app has multiple references) */
|
|
248
271
|
_reused: boolean;
|
|
249
272
|
/** Used by other luma.gl modules to store data on the device */
|
|
250
|
-
|
|
251
|
-
[key: string]: unknown;
|
|
252
|
-
};
|
|
273
|
+
private _moduleData;
|
|
253
274
|
/** Information about the device (vendor, versions etc) */
|
|
254
275
|
abstract info: DeviceInfo;
|
|
255
276
|
/** Optional capability discovery */
|
|
@@ -261,6 +282,8 @@ export declare abstract class Device {
|
|
|
261
282
|
/** Default depth format used on this system */
|
|
262
283
|
abstract preferredDepthFormat: 'depth16' | 'depth24plus' | 'depth32float';
|
|
263
284
|
protected _textureCaps: Partial<Record<TextureFormat, DeviceTextureFormatCapabilities>>;
|
|
285
|
+
/** Internal timestamp query set used when GPU timing collection is enabled for this device. */
|
|
286
|
+
protected _debugGPUTimeQuery: QuerySet | null;
|
|
264
287
|
constructor(props: DeviceProps);
|
|
265
288
|
abstract destroy(): void;
|
|
266
289
|
getVertexFormatInfo(format: VertexFormat): VertexFormatInfo;
|
|
@@ -269,8 +292,6 @@ export declare abstract class Device {
|
|
|
269
292
|
getTextureFormatInfo(format: TextureFormat): TextureFormatInfo;
|
|
270
293
|
/** Determines what operations are supported on a texture format on this particular device (checks against supported device features) */
|
|
271
294
|
getTextureFormatCapabilities(format: TextureFormat): DeviceTextureFormatCapabilities;
|
|
272
|
-
/** Return the implementation specific alignment for a texture format. 1 on WebGL, 256 on WebGPU */
|
|
273
|
-
abstract getTextureByteAlignment(): number;
|
|
274
295
|
/** Calculates the number of mip levels for a texture of width, height and in case of 3d textures only, depth */
|
|
275
296
|
getMipLevelCount(width: number, height: number, depth3d?: number): number;
|
|
276
297
|
/** Check if data is an external image */
|
|
@@ -288,6 +309,8 @@ export declare abstract class Device {
|
|
|
288
309
|
isTextureFormatRenderable(format: TextureFormat): boolean;
|
|
289
310
|
/** Check if a specific texture format is GPU compressed */
|
|
290
311
|
isTextureFormatCompressed(format: TextureFormat): boolean;
|
|
312
|
+
/** Returns the compressed texture formats that can be created and sampled on this device */
|
|
313
|
+
getSupportedCompressedTextureFormats(): CompressedTextureFormat[];
|
|
291
314
|
pushDebugGroup(groupLabel: string): void;
|
|
292
315
|
popDebugGroup(): void;
|
|
293
316
|
insertDebugMarker(markerLabel: string): void;
|
|
@@ -332,6 +355,8 @@ export declare abstract class Device {
|
|
|
332
355
|
getDefaultCanvasContext(): CanvasContext;
|
|
333
356
|
/** Creates a new CanvasContext (WebGPU only) */
|
|
334
357
|
abstract createCanvasContext(props?: CanvasContextProps): CanvasContext;
|
|
358
|
+
/** Creates a presentation context for a destination canvas. WebGL requires the default canvas context to use an OffscreenCanvas. */
|
|
359
|
+
abstract createPresentationContext(props?: PresentationContextProps): PresentationContext;
|
|
335
360
|
/** Call after rendering a frame (necessary e.g. on WebGL OffscreenCanvas) */
|
|
336
361
|
abstract submit(commandBuffer?: CommandBuffer): void;
|
|
337
362
|
/** Create a buffer */
|
|
@@ -356,10 +381,44 @@ export declare abstract class Device {
|
|
|
356
381
|
/** Create a transform feedback (immutable set of output buffer bindings). WebGL only. */
|
|
357
382
|
abstract createTransformFeedback(props: TransformFeedbackProps): TransformFeedback;
|
|
358
383
|
abstract createQuerySet(props: QuerySetProps): QuerySet;
|
|
384
|
+
/** Create a fence sync object */
|
|
385
|
+
createFence(): Fence;
|
|
359
386
|
/** Create a RenderPass using the default CommandEncoder */
|
|
360
387
|
beginRenderPass(props?: RenderPassProps): RenderPass;
|
|
361
388
|
/** Create a ComputePass using the default CommandEncoder*/
|
|
362
389
|
beginComputePass(props?: ComputePassProps): ComputePass;
|
|
390
|
+
/**
|
|
391
|
+
* Generate mipmaps for a WebGPU texture.
|
|
392
|
+
* WebGPU textures must be created up front with the required mip count, usage flags, and a format that supports the chosen generation path.
|
|
393
|
+
* WebGL uses `Texture.generateMipmapsWebGL()` directly because the backend manages mip generation on the texture object itself.
|
|
394
|
+
*/
|
|
395
|
+
generateMipmapsWebGPU(_texture: Texture): void;
|
|
396
|
+
/** Internal helper for creating a shareable WebGL render-pipeline implementation. */
|
|
397
|
+
_createSharedRenderPipelineWebGL(_props: RenderPipelineProps): SharedRenderPipeline;
|
|
398
|
+
/** Internal WebGPU-only helper for retrieving the native bind-group layout for a pipeline group. */
|
|
399
|
+
_createBindGroupLayoutWebGPU(_pipeline: RenderPipeline | ComputePipeline, _group: number): unknown;
|
|
400
|
+
/** Internal WebGPU-only helper for creating a native bind group. */
|
|
401
|
+
_createBindGroupWebGPU(_bindGroupLayout: unknown, _shaderLayout: ShaderLayout | ComputeShaderLayout, _bindings: Bindings, _group: number): unknown;
|
|
402
|
+
/**
|
|
403
|
+
* Internal helper that returns `true` when timestamp-query GPU timing should be
|
|
404
|
+
* collected for this device.
|
|
405
|
+
*/
|
|
406
|
+
_supportsDebugGPUTime(): boolean;
|
|
407
|
+
/**
|
|
408
|
+
* Internal helper that enables device-managed GPU timing collection on the
|
|
409
|
+
* default command encoder. Reuses the existing query set if timing is already enabled.
|
|
410
|
+
*
|
|
411
|
+
* @param queryCount - Number of timestamp slots reserved for profiled passes.
|
|
412
|
+
* @returns The device-managed timestamp QuerySet, or `null` when timing is not supported or could not be enabled.
|
|
413
|
+
*/
|
|
414
|
+
_enableDebugGPUTime(queryCount?: number): QuerySet | null;
|
|
415
|
+
/**
|
|
416
|
+
* Internal helper that disables device-managed GPU timing collection and restores
|
|
417
|
+
* the default command encoder to an unprofiled state.
|
|
418
|
+
*/
|
|
419
|
+
_disableDebugGPUTime(): void;
|
|
420
|
+
/** Internal helper that returns `true` when device-managed GPU timing is currently active. */
|
|
421
|
+
_isDebugGPUTimeEnabled(): boolean;
|
|
363
422
|
/**
|
|
364
423
|
* Determines what operations are supported on a texture format, checking against supported device features
|
|
365
424
|
* Subclasses override to apply additional checks
|
|
@@ -404,11 +463,17 @@ export declare abstract class Device {
|
|
|
404
463
|
}): void;
|
|
405
464
|
/** @deprecated - will be removed - should use for debugging only */
|
|
406
465
|
resetWebGL(): void;
|
|
466
|
+
getModuleData<ModuleDataT extends Record<string, unknown>>(moduleName: string): ModuleDataT;
|
|
407
467
|
/** Helper to get the canvas context props */
|
|
408
468
|
static _getCanvasContextProps(props: DeviceProps): CanvasContextProps | undefined;
|
|
409
469
|
protected _getDeviceTextureFormatCapabilities(format: TextureFormat): DeviceTextureFormatCapabilities;
|
|
410
470
|
/** Subclasses use this to support .createBuffer() overloads */
|
|
411
471
|
protected _normalizeBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps;
|
|
412
472
|
}
|
|
473
|
+
/**
|
|
474
|
+
* Internal helper for resolving the default `debug` prop.
|
|
475
|
+
* Precedence is: explicit log debug value first, then `NODE_ENV`, then `false`.
|
|
476
|
+
*/
|
|
477
|
+
export declare function _getDefaultDebugValue(logDebugValue: unknown, nodeEnv?: string): boolean;
|
|
413
478
|
export {};
|
|
414
479
|
//# sourceMappingURL=device.d.ts.map
|