@luma.gl/core 9.1.0-alpha.14 → 9.1.0-alpha.16
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 +11 -19
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/canvas-context.js +12 -40
- package/dist/adapter/device.d.ts +48 -27
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +36 -35
- package/dist/adapter/luma.d.ts +14 -5
- package/dist/adapter/luma.d.ts.map +1 -1
- package/dist/adapter/luma.js +29 -1
- package/dist/adapter/resources/buffer.d.ts +8 -1
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +11 -2
- package/dist/adapter/resources/command-encoder.d.ts +8 -8
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.d.ts +9 -0
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +19 -4
- package/dist/adapter/resources/render-pass.d.ts +1 -1
- package/dist/adapter/resources/render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/render-pass.js +3 -3
- package/dist/adapter/resources/shader.d.ts +4 -3
- package/dist/adapter/resources/shader.d.ts.map +1 -1
- package/dist/adapter/resources/shader.js +5 -3
- package/dist/adapter/resources/texture.d.ts +2 -3
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +2 -3
- package/dist/adapter-utils/format-compiler-log.js +2 -1
- package/dist/dist.dev.js +160 -134
- package/dist/dist.min.js +7 -7
- package/dist/gpu-type-utils/decode-texture-format.js +2 -2
- package/dist/index.cjs +132 -105
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/portable/uniform-block.js +1 -1
- package/dist/portable/uniform-store.js +2 -2
- package/package.json +2 -2
- package/src/adapter/canvas-context.ts +23 -55
- package/src/adapter/device.ts +87 -80
- package/src/adapter/luma.ts +41 -5
- package/src/adapter/resources/buffer.ts +16 -2
- package/src/adapter/resources/command-encoder.ts +8 -8
- package/src/adapter/resources/framebuffer.ts +26 -4
- package/src/adapter/resources/render-pass.ts +4 -4
- package/src/adapter/resources/shader.ts +9 -5
- package/src/adapter/resources/texture.ts +2 -3
- package/src/adapter-utils/format-compiler-log.ts +2 -1
- package/src/gpu-type-utils/decode-texture-format.ts +2 -2
- package/src/index.ts +1 -0
- package/src/portable/uniform-block.ts +1 -1
- package/src/portable/uniform-store.ts +2 -2
|
@@ -3,24 +3,24 @@ import type { Framebuffer } from "./resources/framebuffer.js";
|
|
|
3
3
|
import type { TextureFormat } from "../gpu-type-utils/texture-formats.js";
|
|
4
4
|
/** Properties for a CanvasContext */
|
|
5
5
|
export type CanvasContextProps = {
|
|
6
|
-
/** If canvas not supplied, will be created and added to the DOM. If string, will be looked up in the DOM */
|
|
6
|
+
/** If a canvas not supplied, one will be created and added to the DOM. If a string, a canvas with that id will be looked up in the DOM */
|
|
7
7
|
canvas?: HTMLCanvasElement | OffscreenCanvas | string | null;
|
|
8
|
-
/** If new canvas is created, it will be created in the specified container, otherwise appended
|
|
8
|
+
/** If new canvas is created, it will be created in the specified container, otherwise is appended as a child of document.body */
|
|
9
9
|
container?: HTMLElement | string | null;
|
|
10
|
-
/** Width in pixels of the canvas */
|
|
10
|
+
/** Width in pixels of the canvas - used when creating a new canvas */
|
|
11
11
|
width?: number;
|
|
12
|
-
/** Height in pixels of the canvas */
|
|
12
|
+
/** Height in pixels of the canvas - used when creating a new canvas */
|
|
13
13
|
height?: number;
|
|
14
|
+
/** Visibility (only used if new canvas is created). */
|
|
15
|
+
visible?: boolean;
|
|
14
16
|
/** Whether to apply a device pixels scale factor (`true` uses browser DPI) */
|
|
15
17
|
useDevicePixels?: boolean | number;
|
|
16
|
-
/** Whether to track resizes
|
|
18
|
+
/** Whether to track window resizes */
|
|
17
19
|
autoResize?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
visible?: boolean;
|
|
20
|
-
/** WebGPU only https://www.w3.org/TR/webgpu/#canvas-configuration */
|
|
21
|
-
colorSpace?: 'srgb';
|
|
22
|
-
/** WebGPU only https://www.w3.org/TR/webgpu/#canvas-configuration */
|
|
20
|
+
/** https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure#alphamode */
|
|
23
21
|
alphaMode?: 'opaque' | 'premultiplied';
|
|
22
|
+
/** https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure#colorspace */
|
|
23
|
+
colorSpace?: 'srgb';
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* Manages a canvas. Supports both HTML or offscreen canvas
|
|
@@ -30,6 +30,7 @@ export type CanvasContextProps = {
|
|
|
30
30
|
* @todo transferControlToOffscreen: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen
|
|
31
31
|
*/
|
|
32
32
|
export declare abstract class CanvasContext {
|
|
33
|
+
static defaultProps: Required<CanvasContextProps>;
|
|
33
34
|
abstract readonly device: Device;
|
|
34
35
|
readonly id: string;
|
|
35
36
|
readonly props: Required<CanvasContextProps>;
|
|
@@ -50,15 +51,6 @@ export declare abstract class CanvasContext {
|
|
|
50
51
|
clientHeight: number;
|
|
51
52
|
devicePixelRatio: number;
|
|
52
53
|
};
|
|
53
|
-
/** Check if the DOM is loaded */
|
|
54
|
-
static get isPageLoaded(): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Get a 'lazy' promise that resolves when the DOM is loaded.
|
|
57
|
-
* @note Since there may be limitations on number of `load` event listeners,
|
|
58
|
-
* it is recommended avoid calling this function until actually needed.
|
|
59
|
-
* I.e. don't call it until you know that you will be looking up a string in the DOM.
|
|
60
|
-
*/
|
|
61
|
-
static pageLoaded: Promise<void>;
|
|
62
54
|
constructor(props?: CanvasContextProps);
|
|
63
55
|
/** Returns a framebuffer with properly resized current 'swap chain' textures */
|
|
64
56
|
abstract getCurrentFramebuffer(): Framebuffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/canvas-context.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,MAAM,EAAC,oBAAiB;AACrC,OAAO,KAAK,EAAC,WAAW,EAAC,mCAAgC;AAEzD,OAAO,KAAK,EAAC,aAAa,EAAC,6CAA0C;
|
|
1
|
+
{"version":3,"file":"canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/canvas-context.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,MAAM,EAAC,oBAAiB;AACrC,OAAO,KAAK,EAAC,WAAW,EAAC,mCAAgC;AAEzD,OAAO,KAAK,EAAC,aAAa,EAAC,6CAA0C;AAErE,qCAAqC;AACrC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,0IAA0I;IAC1I,MAAM,CAAC,EAAE,iBAAiB,GAAG,eAAe,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7D,iIAAiI;IACjI,SAAS,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IACxC,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IAC9E,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACnC,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4FAA4F;IAC5F,SAAS,CAAC,EAAE,QAAQ,GAAG,eAAe,CAAC;IACvC,6FAA6F;IAC7F,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;GAMG;AACH,8BAAsB,aAAa;IACjC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAU/C;IAEF,QAA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;IACH,mBAAmB,CACjB,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAM,GAC9C,IAAI;IA4DP,0GAA0G;IAC1G,oBAAoB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAUxC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KACpC,GAAG,IAAI;IAER,0DAA0D;IAC1D,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI;IAEjC;;;OAGG;IACH,SAAS,CAAC,uBAAuB,CAAC,EAAE,EAAE,MAAM;CAK7C"}
|
|
@@ -3,19 +3,6 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { isBrowser } from '@probe.gl/env';
|
|
5
5
|
import { log } from "../utils/log.js";
|
|
6
|
-
const isPage = isBrowser() && typeof document !== 'undefined';
|
|
7
|
-
const isPageLoaded = () => isPage && document.readyState === 'complete';
|
|
8
|
-
const DEFAULT_CANVAS_CONTEXT_PROPS = {
|
|
9
|
-
canvas: null,
|
|
10
|
-
width: 800, // width are height are only used by headless gl
|
|
11
|
-
height: 600,
|
|
12
|
-
useDevicePixels: true,
|
|
13
|
-
autoResize: true,
|
|
14
|
-
container: null,
|
|
15
|
-
visible: true,
|
|
16
|
-
colorSpace: 'srgb',
|
|
17
|
-
alphaMode: 'opaque'
|
|
18
|
-
};
|
|
19
6
|
/**
|
|
20
7
|
* Manages a canvas. Supports both HTML or offscreen canvas
|
|
21
8
|
* - Creates a new canvas or looks up a canvas from the DOM
|
|
@@ -24,6 +11,17 @@ const DEFAULT_CANVAS_CONTEXT_PROPS = {
|
|
|
24
11
|
* @todo transferControlToOffscreen: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen
|
|
25
12
|
*/
|
|
26
13
|
export class CanvasContext {
|
|
14
|
+
static defaultProps = {
|
|
15
|
+
canvas: null,
|
|
16
|
+
width: 800, // width are height are only used by headless gl
|
|
17
|
+
height: 600,
|
|
18
|
+
useDevicePixels: true,
|
|
19
|
+
autoResize: true,
|
|
20
|
+
container: null,
|
|
21
|
+
visible: true,
|
|
22
|
+
alphaMode: 'opaque',
|
|
23
|
+
colorSpace: 'srgb'
|
|
24
|
+
};
|
|
27
25
|
id;
|
|
28
26
|
props;
|
|
29
27
|
canvas;
|
|
@@ -35,19 +33,8 @@ export class CanvasContext {
|
|
|
35
33
|
resizeObserver;
|
|
36
34
|
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
37
35
|
_canvasSizeInfo = { clientWidth: 0, clientHeight: 0, devicePixelRatio: 1 };
|
|
38
|
-
/** Check if the DOM is loaded */
|
|
39
|
-
static get isPageLoaded() {
|
|
40
|
-
return isPageLoaded();
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get a 'lazy' promise that resolves when the DOM is loaded.
|
|
44
|
-
* @note Since there may be limitations on number of `load` event listeners,
|
|
45
|
-
* it is recommended avoid calling this function until actually needed.
|
|
46
|
-
* I.e. don't call it until you know that you will be looking up a string in the DOM.
|
|
47
|
-
*/
|
|
48
|
-
static pageLoaded = getPageLoadPromise();
|
|
49
36
|
constructor(props) {
|
|
50
|
-
this.props = { ...
|
|
37
|
+
this.props = { ...CanvasContext.defaultProps, ...props };
|
|
51
38
|
props = this.props;
|
|
52
39
|
if (!isBrowser()) {
|
|
53
40
|
this.id = 'node-canvas-context';
|
|
@@ -233,21 +220,9 @@ export class CanvasContext {
|
|
|
233
220
|
}
|
|
234
221
|
}
|
|
235
222
|
// HELPER FUNCTIONS
|
|
236
|
-
/** Returns a promise that resolves when the page is loaded */
|
|
237
|
-
function getPageLoadPromise() {
|
|
238
|
-
if (isPageLoaded() || typeof window === 'undefined') {
|
|
239
|
-
return Promise.resolve();
|
|
240
|
-
}
|
|
241
|
-
return new Promise(resolve => {
|
|
242
|
-
window.addEventListener('load', () => resolve());
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
223
|
function getContainer(container) {
|
|
246
224
|
if (typeof container === 'string') {
|
|
247
225
|
const element = document.getElementById(container);
|
|
248
|
-
if (!element && !isPageLoaded()) {
|
|
249
|
-
throw new Error(`Accessing '${container}' before page was loaded`);
|
|
250
|
-
}
|
|
251
226
|
if (!element) {
|
|
252
227
|
throw new Error(`${container} is not an HTML element`);
|
|
253
228
|
}
|
|
@@ -261,9 +236,6 @@ function getContainer(container) {
|
|
|
261
236
|
/** Get a Canvas element from DOM id */
|
|
262
237
|
function getCanvasFromDOM(canvasId) {
|
|
263
238
|
const canvas = document.getElementById(canvasId);
|
|
264
|
-
if (!canvas && !isPageLoaded()) {
|
|
265
|
-
throw new Error(`Accessing '${canvasId}' before page was loaded`);
|
|
266
|
-
}
|
|
267
239
|
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
268
240
|
throw new Error('Object is not a canvas element');
|
|
269
241
|
}
|
package/dist/adapter/device.d.ts
CHANGED
|
@@ -116,32 +116,49 @@ export type WebGLDeviceFeature = 'timer-query-webgl' | 'compilation-status-async
|
|
|
116
116
|
type WebGLCompressedTextureFeatures = 'texture-compression-bc5-webgl' | 'texture-compression-bc7-webgl' | 'texture-compression-etc1-webgl' | 'texture-compression-pvrtc-webgl' | 'texture-compression-atc-webgl';
|
|
117
117
|
/** Device properties */
|
|
118
118
|
export type DeviceProps = {
|
|
119
|
+
/** string id for debugging. Stored on the object, used in logging and set on underlying GPU objects when feasible. */
|
|
119
120
|
id?: string;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
|
|
121
|
+
/** Properties for creating a default canvas context */
|
|
122
|
+
createCanvasContext?: CanvasContextProps | true;
|
|
123
|
+
/** Control which type of GPU is preferred on systems with both integrated and discrete GPU. Defaults to "high-performance" / discrete GPU. */
|
|
124
|
+
powerPreference?: 'default' | 'high-performance' | 'low-power';
|
|
125
|
+
/** Hints that device creation should fail if no hardware GPU is available (if the system performance is "low"). */
|
|
126
|
+
failIfMajorPerformanceCaveat?: boolean;
|
|
126
127
|
/** Error handling */
|
|
127
128
|
onError?: (error: Error) => unknown;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
129
|
+
/** WebGL specific: Properties passed through to WebGL2RenderingContext creation: `canvas.getContext('webgl2', props.webgl)` */
|
|
130
|
+
webgl?: WebGLContextProps;
|
|
131
|
+
/** Show shader source in browser? The default is`'error'`, meaning that logs are shown when shader compilation has errors */
|
|
132
|
+
debugShaders?: 'never' | 'errors' | 'warnings' | 'always';
|
|
133
|
+
/** Renders a small version of updated Framebuffers into the primary canvas context. Can be set in console luma.log.set('debug-framebuffers', true) */
|
|
134
|
+
debugFramebuffers?: boolean;
|
|
135
|
+
/** WebGL specific - Trace WebGL calls (instruments WebGL2RenderingContext at the expense of performance). Can be set in console luma.log.set('debug-webgl', true) */
|
|
136
|
+
debugWebGL?: boolean;
|
|
137
|
+
/** WebGL specific - Initialize the SpectorJS WebGL debugger. Can be set in console luma.log.set('debug-spectorjs', true) */
|
|
138
|
+
debugSpectorJS?: boolean;
|
|
139
|
+
/** WebGL specific - SpectorJS URL. Override if CDN is down or different SpectorJS version is desired. */
|
|
140
|
+
debugSpectorJSUrl?: string;
|
|
141
|
+
/** WebGPU specific - Request a Device with the highest limits supported by platform. On WebGPU devices can be created with minimal limits. */
|
|
142
|
+
_requestMaxLimits?: boolean;
|
|
141
143
|
/** Disable specific features */
|
|
142
|
-
|
|
144
|
+
_disabledFeatures?: Partial<Record<DeviceFeature, boolean>>;
|
|
145
|
+
/** WebGL specific - Initialize all features on startup */
|
|
146
|
+
_initializeFeatures?: boolean;
|
|
143
147
|
/** Never destroy cached shaders and pipelines */
|
|
144
148
|
_factoryDestroyPolicy?: 'unused' | 'never';
|
|
149
|
+
/** @deprecated Internal, Do not use directly! Use `luma.attachDevice()` to attach to pre-created contexts/devices. */
|
|
150
|
+
_handle?: unknown;
|
|
151
|
+
};
|
|
152
|
+
/** WebGL independent copy of WebGLContextAttributes */
|
|
153
|
+
type WebGLContextProps = {
|
|
154
|
+
alpha?: boolean;
|
|
155
|
+
desynchronized?: boolean;
|
|
156
|
+
antialias?: boolean;
|
|
157
|
+
depth?: boolean;
|
|
158
|
+
failIfMajorPerformanceCaveat?: boolean;
|
|
159
|
+
powerPreference?: 'default' | 'high-performance' | 'low-power';
|
|
160
|
+
premultipliedAlpha?: boolean;
|
|
161
|
+
preserveDrawingBuffer?: boolean;
|
|
145
162
|
};
|
|
146
163
|
/**
|
|
147
164
|
* Create and attach devices for a specific backend. Currently static methods on each device
|
|
@@ -171,6 +188,8 @@ export declare abstract class Device {
|
|
|
171
188
|
};
|
|
172
189
|
/** stats */
|
|
173
190
|
readonly statsManager: StatsManager;
|
|
191
|
+
/** An abstract timestamp used for change tracking */
|
|
192
|
+
timestamp: number;
|
|
174
193
|
/** Used by other luma.gl modules to store data on the device */
|
|
175
194
|
_lumaData: {
|
|
176
195
|
[key: string]: unknown;
|
|
@@ -208,7 +227,7 @@ export declare abstract class Device {
|
|
|
208
227
|
/** Default / primary canvas context. Can be null as WebGPU devices can be created without a CanvasContext */
|
|
209
228
|
abstract canvasContext: CanvasContext | null;
|
|
210
229
|
/** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */
|
|
211
|
-
|
|
230
|
+
getDefaultCanvasContext(): CanvasContext;
|
|
212
231
|
/** Creates a new CanvasContext (WebGPU only) */
|
|
213
232
|
abstract createCanvasContext(props?: CanvasContextProps): CanvasContext;
|
|
214
233
|
/** Call after rendering a frame (necessary e.g. on WebGL OffscreenCanvas) */
|
|
@@ -239,6 +258,12 @@ export declare abstract class Device {
|
|
|
239
258
|
abstract createTransformFeedback(props: TransformFeedbackProps): TransformFeedback;
|
|
240
259
|
abstract createQuerySet(props: QuerySetProps): QuerySet;
|
|
241
260
|
createCommandEncoder(props?: CommandEncoderProps): CommandEncoder;
|
|
261
|
+
/** A monotonic counter for tracking buffer and texture updates */
|
|
262
|
+
incrementTimestamp(): number;
|
|
263
|
+
/** Report unhandled device errors */
|
|
264
|
+
onError(error: Error): void;
|
|
265
|
+
/** @deprecated Use getDefaultCanvasContext() */
|
|
266
|
+
getCanvasContext(): CanvasContext;
|
|
242
267
|
/** @deprecated - will be removed - should use command encoder */
|
|
243
268
|
readPixelsToArrayWebGL(source: Framebuffer | Texture, options?: {
|
|
244
269
|
sourceX?: number;
|
|
@@ -276,12 +301,8 @@ export declare abstract class Device {
|
|
|
276
301
|
}): void;
|
|
277
302
|
/** @deprecated - will be removed - should use for debugging only */
|
|
278
303
|
resetWebGL(): void;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
incrementTimestamp(): number;
|
|
282
|
-
/** Report unhandled device errors */
|
|
283
|
-
onError(error: Error): void;
|
|
284
|
-
protected _getBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps;
|
|
304
|
+
/** Subclasses use this to support .createBuffer() overloads */
|
|
305
|
+
protected _normalizeBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps;
|
|
285
306
|
}
|
|
286
307
|
export {};
|
|
287
308
|
//# sourceMappingURL=device.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/adapter/device.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAY,kCAA+B;AAG/D,OAAO,KAAK,EAAC,aAAa,EAAC,8CAA2C;AACtE,OAAO,KAAK,EAAC,aAAa,EAAE,kBAAkB,EAAC,4BAAyB;AACxE,OAAO,KAAK,EAAC,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EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG;IAIpD,+EAA+E;IAC/E,UAAU,CAAC,OAAO,CAAC,EAAE;QAAC,WAAW,CAAC,EAAE,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAC,GAAG,IAAI;IAIhG,oEAAoE;IACpE,UAAU,IAAI,IAAI;IAMlB,+DAA+D;IAC/D,SAAS,CAAC,qBAAqB,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,GAAG,eAAe,GAAG,WAAW;CAqBjG"}
|
package/dist/adapter/device.js
CHANGED
|
@@ -30,33 +30,27 @@ export class DeviceFeatures {
|
|
|
30
30
|
export class Device {
|
|
31
31
|
static defaultProps = {
|
|
32
32
|
id: null,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
width: 800, // width are height are only used by headless gl
|
|
37
|
-
height: 600,
|
|
38
|
-
requestMaxLimits: true,
|
|
33
|
+
powerPreference: 'high-performance',
|
|
34
|
+
failIfMajorPerformanceCaveat: false,
|
|
35
|
+
createCanvasContext: undefined,
|
|
39
36
|
// Callbacks
|
|
40
37
|
onError: (error) => log.error(error.message),
|
|
41
|
-
|
|
42
|
-
// alpha: undefined,
|
|
43
|
-
// depth: undefined,
|
|
44
|
-
// stencil: undefined,
|
|
45
|
-
// antialias: undefined,
|
|
46
|
-
// premultipliedAlpha: undefined,
|
|
47
|
-
// preserveDrawingBuffer: undefined,
|
|
48
|
-
// failIfMajorPerformanceCaveat: undefined
|
|
49
|
-
debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance)
|
|
50
|
-
break: log.get('break') || [],
|
|
51
|
-
// WebGL specific debugging
|
|
52
|
-
debugWithSpectorJS: undefined,
|
|
53
|
-
spectorUrl: undefined,
|
|
38
|
+
_factoryDestroyPolicy: 'unused',
|
|
54
39
|
// TODO - Change these after confirming things work as expected
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
_initializeFeatures: true,
|
|
41
|
+
_disabledFeatures: {
|
|
57
42
|
'compilation-status-async-webgl': true
|
|
58
43
|
},
|
|
59
|
-
|
|
44
|
+
_requestMaxLimits: true,
|
|
45
|
+
// WebGL specific
|
|
46
|
+
webgl: {},
|
|
47
|
+
debugShaders: log.get('debug-shaders') || undefined,
|
|
48
|
+
debugFramebuffers: Boolean(log.get('debug-framebuffers')),
|
|
49
|
+
debugWebGL: Boolean(log.get('debug-webgl')),
|
|
50
|
+
debugSpectorJS: undefined, // Note: log setting is queried by the spector.js code
|
|
51
|
+
debugSpectorJSUrl: undefined,
|
|
52
|
+
// INTERNAL
|
|
53
|
+
_handle: undefined
|
|
60
54
|
};
|
|
61
55
|
get [Symbol.toStringTag]() {
|
|
62
56
|
return 'Device';
|
|
@@ -73,6 +67,8 @@ export class Device {
|
|
|
73
67
|
userData = {};
|
|
74
68
|
/** stats */
|
|
75
69
|
statsManager = lumaStats;
|
|
70
|
+
/** An abstract timestamp used for change tracking */
|
|
71
|
+
timestamp = 0;
|
|
76
72
|
/** Used by other luma.gl modules to store data on the device */
|
|
77
73
|
_lumaData = {};
|
|
78
74
|
/** Check if a specific texture format is GPU compressed */
|
|
@@ -92,15 +88,29 @@ export class Device {
|
|
|
92
88
|
this.props.onError(error);
|
|
93
89
|
}
|
|
94
90
|
/** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */
|
|
95
|
-
|
|
91
|
+
getDefaultCanvasContext() {
|
|
96
92
|
if (!this.canvasContext) {
|
|
97
|
-
throw new Error('Device has no CanvasContext');
|
|
93
|
+
throw new Error('Device has no default CanvasContext. See props.createCanvasContext');
|
|
98
94
|
}
|
|
99
95
|
return this.canvasContext;
|
|
100
96
|
}
|
|
101
97
|
createCommandEncoder(props = {}) {
|
|
102
98
|
throw new Error('not implemented');
|
|
103
99
|
}
|
|
100
|
+
/** A monotonic counter for tracking buffer and texture updates */
|
|
101
|
+
incrementTimestamp() {
|
|
102
|
+
return this.timestamp++;
|
|
103
|
+
}
|
|
104
|
+
// Error Handling
|
|
105
|
+
/** Report unhandled device errors */
|
|
106
|
+
onError(error) {
|
|
107
|
+
this.props.onError(error);
|
|
108
|
+
}
|
|
109
|
+
// DEPRECATED METHODS
|
|
110
|
+
/** @deprecated Use getDefaultCanvasContext() */
|
|
111
|
+
getCanvasContext() {
|
|
112
|
+
return this.getDefaultCanvasContext();
|
|
113
|
+
}
|
|
104
114
|
// WebGL specific HACKS - enables app to remove webgl import
|
|
105
115
|
// Use until we have a better way to handle these
|
|
106
116
|
/** @deprecated - will be removed - should use command encoder */
|
|
@@ -131,18 +141,9 @@ export class Device {
|
|
|
131
141
|
resetWebGL() {
|
|
132
142
|
throw new Error('not implemented');
|
|
133
143
|
}
|
|
134
|
-
timestamp = 0;
|
|
135
|
-
/** A monotonic counter for tracking buffer and texture updates */
|
|
136
|
-
incrementTimestamp() {
|
|
137
|
-
return this.timestamp++;
|
|
138
|
-
}
|
|
139
|
-
// Error Handling
|
|
140
|
-
/** Report unhandled device errors */
|
|
141
|
-
onError(error) {
|
|
142
|
-
this.props.onError(error);
|
|
143
|
-
}
|
|
144
144
|
// IMPLEMENTATION
|
|
145
|
-
|
|
145
|
+
/** Subclasses use this to support .createBuffer() overloads */
|
|
146
|
+
_normalizeBufferProps(props) {
|
|
146
147
|
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
|
|
147
148
|
props = { data: props };
|
|
148
149
|
}
|
package/dist/adapter/luma.d.ts
CHANGED
|
@@ -7,18 +7,20 @@ declare global {
|
|
|
7
7
|
var luma: Luma;
|
|
8
8
|
}
|
|
9
9
|
/** Properties for creating a new device */
|
|
10
|
-
export type CreateDeviceProps =
|
|
10
|
+
export type CreateDeviceProps = {
|
|
11
11
|
/** Selects the type of device. `best-available` uses webgpu if available, then webgl. */
|
|
12
12
|
type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available';
|
|
13
|
+
/** List of adapters. Will also search any pre-registered adapters */
|
|
13
14
|
adapters?: Adapter[];
|
|
14
|
-
};
|
|
15
|
+
} & DeviceProps;
|
|
15
16
|
/** Properties for attaching an existing WebGL context or WebGPU device to a new luma Device */
|
|
16
|
-
export type AttachDeviceProps =
|
|
17
|
+
export type AttachDeviceProps = {
|
|
18
|
+
type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available';
|
|
17
19
|
/** Externally created WebGL context or WebGPU device */
|
|
18
20
|
handle: unknown;
|
|
19
|
-
/** List of adapters. Will also search any pre-registered
|
|
21
|
+
/** List of adapters. Will also search any pre-registered adapters */
|
|
20
22
|
adapters?: Adapter[];
|
|
21
|
-
};
|
|
23
|
+
} & DeviceProps;
|
|
22
24
|
/**
|
|
23
25
|
* Entry point to the luma.gl GPU abstraction
|
|
24
26
|
* Register WebGPU and/or WebGL adapters (controls application bundle size)
|
|
@@ -26,6 +28,13 @@ export type AttachDeviceProps = DeviceProps & {
|
|
|
26
28
|
*/
|
|
27
29
|
export declare class Luma {
|
|
28
30
|
static defaultProps: Required<CreateDeviceProps>;
|
|
31
|
+
/**
|
|
32
|
+
* Get a 'lazy' promise that resolves when the DOM is loaded.
|
|
33
|
+
* @note Since there may be limitations on number of `load` event listeners,
|
|
34
|
+
* it is recommended avoid calling this function until actually needed.
|
|
35
|
+
* I.e. don't call it until you know that you will be looking up a string in the DOM.
|
|
36
|
+
*/
|
|
37
|
+
static pageLoaded: Promise<void>;
|
|
29
38
|
/** Global stats for all devices */
|
|
30
39
|
readonly stats: StatsManager;
|
|
31
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"luma.d.ts","sourceRoot":"","sources":["../../src/adapter/luma.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"luma.d.ts","sourceRoot":"","sources":["../../src/adapter/luma.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA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6CAA6C;IAC7C,oBAAoB,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,MAAM,EAAE;IAQxD,iDAAiD;IACjD,uBAAuB,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI;IAW5E,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAIrD,wCAAwC;IAClC,YAAY,CAAC,KAAK,GAAE,iBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IA8BlE,kFAAkF;IAC5E,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAmC7D;;;OAGG;IACH,aAAa,CAAC,OAAO,GAAE,OAAc,EAAE,QAAQ,GAAE,OAAO,EAAO,GAAG,IAAI;IAStE,0CAA0C;IAC1C,SAAS,CAAC,aAAa,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAUvE,uCAAuC;IACvC,eAAe,CAAC,aAAa,EAAE,GAAG,EAAE,GAAG,IAAI;CAS5C;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,MAAa,CAAC"}
|
package/dist/adapter/luma.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { isBrowser } from '@probe.gl/env';
|
|
4
5
|
import { Device } from "./device.js";
|
|
5
6
|
import { lumaStats } from "../utils/stats-manager.js";
|
|
6
7
|
import { log } from "../utils/log.js";
|
|
8
|
+
const isPage = isBrowser() && typeof document !== 'undefined';
|
|
9
|
+
const isPageLoaded = () => isPage && document.readyState === 'complete';
|
|
7
10
|
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering';
|
|
8
11
|
const ERROR_MESSAGE = 'No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.';
|
|
9
12
|
/**
|
|
@@ -17,6 +20,15 @@ export class Luma {
|
|
|
17
20
|
type: 'best-available',
|
|
18
21
|
adapters: undefined
|
|
19
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Get a 'lazy' promise that resolves when the DOM is loaded.
|
|
25
|
+
* @note Since there may be limitations on number of `load` event listeners,
|
|
26
|
+
* it is recommended avoid calling this function until actually needed.
|
|
27
|
+
* I.e. don't call it until you know that you will be looking up a string in the DOM.
|
|
28
|
+
*/
|
|
29
|
+
static pageLoaded = getPageLoadPromise().then(() => {
|
|
30
|
+
log.probe(2, 'DOM is loaded')();
|
|
31
|
+
});
|
|
20
32
|
/** Global stats for all devices */
|
|
21
33
|
stats = lumaStats;
|
|
22
34
|
/**
|
|
@@ -31,7 +43,7 @@ export class Luma {
|
|
|
31
43
|
VERSION =
|
|
32
44
|
// Version detection using build plugin
|
|
33
45
|
// @ts-expect-error no-undef
|
|
34
|
-
typeof "9.1.0-alpha.
|
|
46
|
+
typeof "9.1.0-alpha.16" !== 'undefined' ? "9.1.0-alpha.16" : 'running from source';
|
|
35
47
|
spector;
|
|
36
48
|
preregisteredAdapters = new Map();
|
|
37
49
|
constructor() {
|
|
@@ -80,6 +92,9 @@ export class Luma {
|
|
|
80
92
|
// if (props.gl) {
|
|
81
93
|
// props.type = 'webgl';
|
|
82
94
|
// }
|
|
95
|
+
if (props.createCanvasContext) {
|
|
96
|
+
await Luma.pageLoaded;
|
|
97
|
+
}
|
|
83
98
|
const adapterMap = this.getAdapterMap(props.adapters);
|
|
84
99
|
let type = props.type || '';
|
|
85
100
|
if (type === 'best-available') {
|
|
@@ -101,6 +116,9 @@ export class Luma {
|
|
|
101
116
|
if (props.handle instanceof WebGL2RenderingContext) {
|
|
102
117
|
type = 'webgl';
|
|
103
118
|
}
|
|
119
|
+
if (props.createCanvasContext) {
|
|
120
|
+
await Luma.pageLoaded;
|
|
121
|
+
}
|
|
104
122
|
// TODO - WebGPU does not yet have a stable API
|
|
105
123
|
// if (props.handle instanceof GPUDevice) {
|
|
106
124
|
// const WebGPUDevice = adapters.get('webgpu') as any;
|
|
@@ -157,3 +175,13 @@ export class Luma {
|
|
|
157
175
|
* Run-time selection of the first available Device
|
|
158
176
|
*/
|
|
159
177
|
export const luma = new Luma();
|
|
178
|
+
// HELPER FUNCTIONS
|
|
179
|
+
/** Returns a promise that resolves when the page is loaded */
|
|
180
|
+
function getPageLoadPromise() {
|
|
181
|
+
if (isPageLoaded() || typeof window === 'undefined') {
|
|
182
|
+
return Promise.resolve();
|
|
183
|
+
}
|
|
184
|
+
return new Promise(resolve => {
|
|
185
|
+
window.addEventListener('load', () => resolve());
|
|
186
|
+
});
|
|
187
|
+
}
|
|
@@ -39,9 +39,16 @@ export declare abstract class Buffer extends Resource<BufferProps> {
|
|
|
39
39
|
readonly indexType?: 'uint16' | 'uint32';
|
|
40
40
|
/** Length of buffer in bytes */
|
|
41
41
|
abstract byteLength: number;
|
|
42
|
-
/** "Time" of last update */
|
|
42
|
+
/** "Time" of last update, can be used to check if redraw is needed */
|
|
43
43
|
updateTimestamp: number;
|
|
44
44
|
constructor(device: Device, props: BufferProps);
|
|
45
|
+
/**
|
|
46
|
+
* Create a copy of this Buffer with new byteLength, with same props but of the specified size.
|
|
47
|
+
* @note Does not copy contents of the cloned Buffer.
|
|
48
|
+
*/
|
|
49
|
+
clone(props: {
|
|
50
|
+
byteLength: number;
|
|
51
|
+
}): Buffer;
|
|
45
52
|
/** Write data to buffer */
|
|
46
53
|
abstract write(data: ArrayBufferView, byteOffset?: number): void;
|
|
47
54
|
/** Read data asynchronously */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/buffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,sBAAmB;AAEnD,MAAM,MAAM,WAAW,GAAG,aAAa,G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,QAAQ,CAAC;IACzC,gCAAgC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,sEAAsE;IACtE,eAAe,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAwB9C;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM;IAI1C,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAEhE,+BAA+B;IAC/B,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAEjF,iDAAiD;IACjD,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU;IAMnE,iDAAiD;IACjD,MAAM,CAAC,qBAAqB,SAAM;IAElC,iFAAiF;IACjF,SAAS,EAAE,WAAW,CAAsB;IAE5C,oEAAoE;IACpE,SAAS,CAAC,aAAa,CACrB,IAAI,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI,EAC1C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,IAAI;CAcR"}
|
|
@@ -35,7 +35,7 @@ export class Buffer extends Resource {
|
|
|
35
35
|
usage;
|
|
36
36
|
/** For index buffers, whether indices are 16 or 32 bit */
|
|
37
37
|
indexType;
|
|
38
|
-
/** "Time" of last update */
|
|
38
|
+
/** "Time" of last update, can be used to check if redraw is needed */
|
|
39
39
|
updateTimestamp;
|
|
40
40
|
constructor(device, props) {
|
|
41
41
|
const deducedProps = { ...props };
|
|
@@ -48,12 +48,21 @@ export class Buffer extends Resource {
|
|
|
48
48
|
deducedProps.indexType = 'uint16';
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
// Remove data from props before storing, we don't want to hold on to a big chunk of memory
|
|
52
|
+
delete deducedProps.data;
|
|
51
53
|
super(device, deducedProps, Buffer.defaultProps);
|
|
52
|
-
this.usage =
|
|
54
|
+
this.usage = deducedProps.usage || 0;
|
|
53
55
|
this.indexType = deducedProps.indexType;
|
|
54
56
|
// TODO - perhaps this should be set on async write completion?
|
|
55
57
|
this.updateTimestamp = device.incrementTimestamp();
|
|
56
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a copy of this Buffer with new byteLength, with same props but of the specified size.
|
|
61
|
+
* @note Does not copy contents of the cloned Buffer.
|
|
62
|
+
*/
|
|
63
|
+
clone(props) {
|
|
64
|
+
return this.device.createBuffer({ ...this.props, ...props });
|
|
65
|
+
}
|
|
57
66
|
/** Read data synchronously. @note WebGL2 only */
|
|
58
67
|
readSyncWebGL(byteOffset, byteLength) {
|
|
59
68
|
throw new Error('not implemented');
|