@luma.gl/webgl 9.1.0-alpha.1 → 9.1.0-alpha.9
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/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +18 -11
- package/dist/adapter/converters/texture-formats.d.ts +1 -1
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +9 -16
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +0 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +4 -4
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +11 -9
- package/dist/adapter/resources/webgl-framebuffer.js +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +17 -4
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +1 -1
- package/dist/adapter/resources/webgl-shader.js +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +2 -2
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +12 -27
- package/dist/adapter/resources/webgl-transform-feedback.js +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +3 -0
- package/dist/adapter/webgl-adapter.d.ts +21 -0
- package/dist/adapter/webgl-adapter.d.ts.map +1 -0
- package/dist/adapter/webgl-adapter.js +91 -0
- package/dist/adapter/webgl-device.d.ts +15 -27
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +32 -112
- package/dist/classic/copy-and-blit.d.ts +1 -0
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +11 -10
- package/dist/context/debug/spector-types.d.ts +1108 -0
- package/dist/context/debug/spector-types.d.ts.map +1 -0
- package/dist/context/debug/spector-types.js +697 -0
- package/dist/context/debug/spector.d.ts +12 -8
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +23 -17
- package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts +9 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts.map +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js +181 -0
- package/dist/context/state-tracker/webgl-state-tracker.d.ts +43 -0
- package/dist/context/state-tracker/webgl-state-tracker.d.ts.map +1 -0
- package/dist/context/state-tracker/{track-context-state.js → webgl-state-tracker.js} +44 -74
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +5 -4
- package/dist/dist.dev.js +341 -234
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +344 -236
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/utils/uid.d.ts +7 -0
- package/dist/utils/uid.d.ts.map +1 -0
- package/dist/utils/uid.js +14 -0
- package/package.json +3 -3
- package/src/adapter/converters/device-parameters.ts +18 -12
- package/src/adapter/converters/texture-formats.ts +12 -20
- package/src/adapter/device-helpers/webgl-device-features.ts +0 -1
- package/src/adapter/helpers/webgl-texture-utils.ts +12 -9
- package/src/adapter/resources/webgl-framebuffer.ts +1 -1
- package/src/adapter/resources/webgl-render-pass.ts +17 -4
- package/src/adapter/resources/webgl-render-pipeline.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +1 -1
- package/src/adapter/resources/webgl-texture.ts +17 -27
- package/src/adapter/resources/webgl-transform-feedback.ts +1 -1
- package/src/adapter/resources/webgl-vertex-array.ts +3 -0
- package/src/adapter/webgl-adapter.ts +113 -0
- package/src/adapter/webgl-device.ts +32 -135
- package/src/classic/copy-and-blit.ts +14 -9
- package/src/context/debug/spector-types.ts +1154 -0
- package/src/context/debug/spector.ts +38 -29
- package/src/context/polyfills/polyfill-webgl1-extensions.ts +202 -0
- package/src/context/state-tracker/{track-context-state.ts → webgl-state-tracker.ts} +55 -94
- package/src/context/state-tracker/with-parameters.ts +5 -4
- package/src/index.ts +5 -7
- package/src/utils/uid.ts +16 -0
- package/dist/context/state-tracker/track-context-state.d.ts +0 -22
- package/dist/context/state-tracker/track-context-state.d.ts.map +0 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Adapter, Device, CanvasContext, log } from '@luma.gl/core';
|
|
5
|
+
import { WebGLDevice } from "./webgl-device.js";
|
|
6
|
+
import { enforceWebGL2 } from "../context/polyfills/polyfill-webgl1-extensions.js";
|
|
7
|
+
import { loadSpectorJS, DEFAULT_SPECTOR_PROPS } from "../context/debug/spector.js";
|
|
8
|
+
import { loadWebGLDeveloperTools } from "../context/debug/webgl-developer-tools.js";
|
|
9
|
+
const LOG_LEVEL = 1;
|
|
10
|
+
export class WebGLAdapter extends Adapter {
|
|
11
|
+
/** type of device's created by this adapter */
|
|
12
|
+
type = 'webgl';
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
// Add spector default props to device default props, so that runtime settings are observed
|
|
16
|
+
Device.defaultProps = { ...Device.defaultProps, ...DEFAULT_SPECTOR_PROPS };
|
|
17
|
+
// @ts-ignore DEPRECATED For backwards compatibility luma.registerDevices
|
|
18
|
+
WebGLDevice.adapter = this;
|
|
19
|
+
}
|
|
20
|
+
/** Check if WebGL 2 is available */
|
|
21
|
+
isSupported() {
|
|
22
|
+
return typeof WebGL2RenderingContext !== 'undefined';
|
|
23
|
+
}
|
|
24
|
+
/** Force any created WebGL contexts to be WebGL2 contexts, polyfilled with WebGL1 extensions */
|
|
25
|
+
enforceWebGL2(enable) {
|
|
26
|
+
enforceWebGL2(enable);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get a device instance from a GL context
|
|
30
|
+
* Creates and instruments the device if not already created
|
|
31
|
+
* @param gl
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
async attach(gl) {
|
|
35
|
+
if (gl instanceof WebGLDevice) {
|
|
36
|
+
return gl;
|
|
37
|
+
}
|
|
38
|
+
// @ts-expect-error
|
|
39
|
+
if (gl?.device instanceof Device) {
|
|
40
|
+
// @ts-expect-error
|
|
41
|
+
return gl.device;
|
|
42
|
+
}
|
|
43
|
+
if (!isWebGL(gl)) {
|
|
44
|
+
throw new Error('Invalid WebGL2RenderingContext');
|
|
45
|
+
}
|
|
46
|
+
return new WebGLDevice({ gl: gl });
|
|
47
|
+
}
|
|
48
|
+
async create(props = {}) {
|
|
49
|
+
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
|
|
50
|
+
const promises = [];
|
|
51
|
+
// Load webgl and spector debug scripts from CDN if requested
|
|
52
|
+
if (props.debug) {
|
|
53
|
+
promises.push(loadWebGLDeveloperTools());
|
|
54
|
+
}
|
|
55
|
+
if (props.debugWithSpectorJS) {
|
|
56
|
+
promises.push(loadSpectorJS(props));
|
|
57
|
+
}
|
|
58
|
+
// Wait for page to load: if canvas is a string we need to query the DOM for the canvas element.
|
|
59
|
+
// We only wait when props.canvas is string to avoids setting the global page onload callback unless necessary.
|
|
60
|
+
if (typeof props.canvas === 'string') {
|
|
61
|
+
promises.push(CanvasContext.pageLoaded);
|
|
62
|
+
}
|
|
63
|
+
// Wait for all the loads to settle before creating the context.
|
|
64
|
+
// The Device.create() functions are async, so in contrast to the constructor, we can `await` here.
|
|
65
|
+
const results = await Promise.allSettled(promises);
|
|
66
|
+
for (const result of results) {
|
|
67
|
+
if (result.status === 'rejected') {
|
|
68
|
+
log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
|
|
72
|
+
const device = new WebGLDevice(props);
|
|
73
|
+
// Log some debug info about the newly created context
|
|
74
|
+
const message = `\
|
|
75
|
+
Created ${device.type}${device.debug ? ' debug' : ''} context: \
|
|
76
|
+
${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
77
|
+
log.probe(LOG_LEVEL, message)();
|
|
78
|
+
log.table(LOG_LEVEL, device.info)();
|
|
79
|
+
log.groupEnd(LOG_LEVEL)();
|
|
80
|
+
return device;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Check if supplied parameter is a WebGL2RenderingContext */
|
|
84
|
+
function isWebGL(gl) {
|
|
85
|
+
if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
// Look for debug contexts, headless gl etc
|
|
89
|
+
return Boolean(gl && Number.isFinite(gl._version));
|
|
90
|
+
}
|
|
91
|
+
export const webgl2Adapter = new WebGLAdapter();
|
|
@@ -6,6 +6,7 @@ import type { GLExtensions } from '@luma.gl/constants';
|
|
|
6
6
|
import { WebGLDeviceFeatures } from "./device-helpers/webgl-device-features.js";
|
|
7
7
|
import { WebGLDeviceLimits } from "./device-helpers/webgl-device-limits.js";
|
|
8
8
|
import { WebGLCanvasContext } from "./webgl-canvas-context.js";
|
|
9
|
+
import type { Spector } from "../context/debug/spector-types.js";
|
|
9
10
|
import type { BufferProps, ShaderProps, SamplerProps, TextureProps, ExternalTexture, ExternalTextureProps, FramebufferProps, RenderPipelineProps, ComputePipeline, ComputePipelineProps, RenderPassProps, ComputePass, ComputePassProps, CommandEncoderProps, TransformFeedbackProps, QuerySetProps } from '@luma.gl/core';
|
|
10
11
|
import { WEBGLBuffer } from "./resources/webgl-buffer.js";
|
|
11
12
|
import { WEBGLShader } from "./resources/webgl-shader.js";
|
|
@@ -18,8 +19,6 @@ import { WEBGLTransformFeedback } from "./resources/webgl-transform-feedback.js"
|
|
|
18
19
|
import { WEBGLQuerySet } from "./resources/webgl-query-set.js";
|
|
19
20
|
/** WebGPU style Device API for a WebGL context */
|
|
20
21
|
export declare class WebGLDevice extends Device {
|
|
21
|
-
/** type of this device */
|
|
22
|
-
static readonly type: string;
|
|
23
22
|
/** type of this device */
|
|
24
23
|
readonly type = "webgl";
|
|
25
24
|
/** The underlying WebGL context */
|
|
@@ -33,16 +32,20 @@ export declare class WebGLDevice extends Device {
|
|
|
33
32
|
message: string;
|
|
34
33
|
}>;
|
|
35
34
|
private _resolveContextLost?;
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
/** WebGL2 context. */
|
|
36
|
+
readonly gl: WebGL2RenderingContext;
|
|
37
|
+
readonly debug: boolean;
|
|
38
|
+
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
39
|
+
readonly _canvasSizeInfo: {
|
|
40
|
+
clientWidth: number;
|
|
41
|
+
clientHeight: number;
|
|
42
|
+
devicePixelRatio: number;
|
|
43
|
+
};
|
|
44
|
+
/** State used by luma.gl classes - TODO - not used? */
|
|
45
|
+
readonly _extensions: GLExtensions;
|
|
46
|
+
_polyfilled: boolean;
|
|
47
|
+
/** Instance of Spector.js (if initialized) */
|
|
48
|
+
spectorJS: Spector;
|
|
46
49
|
constructor(props: DeviceProps);
|
|
47
50
|
/**
|
|
48
51
|
* Destroys the context
|
|
@@ -50,7 +53,6 @@ export declare class WebGLDevice extends Device {
|
|
|
50
53
|
*/
|
|
51
54
|
destroy(): void;
|
|
52
55
|
get isLost(): boolean;
|
|
53
|
-
getSize(): [number, number];
|
|
54
56
|
isTextureFormatSupported(format: TextureFormat): boolean;
|
|
55
57
|
isTextureFormatFilterable(format: TextureFormat): boolean;
|
|
56
58
|
isTextureFormatRenderable(format: TextureFormat): boolean;
|
|
@@ -108,20 +110,6 @@ export declare class WebGLDevice extends Device {
|
|
|
108
110
|
stencil?: any;
|
|
109
111
|
}): void;
|
|
110
112
|
resetWebGL(): void;
|
|
111
|
-
/** WebGL2 context. */
|
|
112
|
-
readonly gl: WebGL2RenderingContext;
|
|
113
|
-
readonly debug: boolean;
|
|
114
|
-
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
115
|
-
readonly _canvasSizeInfo: {
|
|
116
|
-
clientWidth: number;
|
|
117
|
-
clientHeight: number;
|
|
118
|
-
devicePixelRatio: number;
|
|
119
|
-
};
|
|
120
|
-
/** State used by luma.gl classes - TODO - not used? */
|
|
121
|
-
readonly _extensions: GLExtensions;
|
|
122
|
-
_polyfilled: boolean;
|
|
123
|
-
/** Instance of Spector.js (if initialized) */
|
|
124
|
-
spectorJS: unknown;
|
|
125
113
|
/**
|
|
126
114
|
* Triggers device (or WebGL context) loss.
|
|
127
115
|
* @note primarily intended for testing how application reacts to device loss
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAC,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAC9F,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAC,MAAM,EAAE,aAAa,EAAM,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAC/C,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
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { Device,
|
|
5
|
-
import {
|
|
4
|
+
import { Device, log } from '@luma.gl/core';
|
|
5
|
+
import { WebGLStateTracker } from "../context/state-tracker/webgl-state-tracker.js";
|
|
6
6
|
import { createBrowserContext } from "../context/helpers/create-browser-context.js";
|
|
7
7
|
import { getDeviceInfo } from "./device-helpers/webgl-device-info.js";
|
|
8
8
|
import { WebGLDeviceFeatures } from "./device-helpers/webgl-device-features.js";
|
|
9
9
|
import { WebGLDeviceLimits } from "./device-helpers/webgl-device-limits.js";
|
|
10
10
|
import { WebGLCanvasContext } from "./webgl-canvas-context.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { initializeSpectorJS } from "../context/debug/spector.js";
|
|
12
|
+
import { makeDebugContext } from "../context/debug/webgl-developer-tools.js";
|
|
13
13
|
import { isTextureFormatSupported, isTextureFormatRenderable, isTextureFormatFilterable } from "./converters/texture-formats.js";
|
|
14
|
+
import { uid } from "../utils/uid.js";
|
|
14
15
|
import { WEBGLBuffer } from "./resources/webgl-buffer.js";
|
|
15
16
|
import { WEBGLShader } from "./resources/webgl-shader.js";
|
|
16
17
|
import { WEBGLSampler } from "./resources/webgl-sampler.js";
|
|
@@ -27,15 +28,12 @@ import { setGLParameters, getGLParameters, resetGLParameters } from "../context/
|
|
|
27
28
|
import { withGLParameters } from "../context/state-tracker/with-parameters.js";
|
|
28
29
|
import { clear } from "../classic/clear.js";
|
|
29
30
|
import { getWebGLExtension } from "../context/helpers/webgl-extensions.js";
|
|
30
|
-
const LOG_LEVEL = 1;
|
|
31
31
|
/** WebGPU style Device API for a WebGL context */
|
|
32
32
|
export class WebGLDevice extends Device {
|
|
33
33
|
//
|
|
34
34
|
// Public `Device` API
|
|
35
35
|
//
|
|
36
36
|
/** type of this device */
|
|
37
|
-
static type = 'webgl';
|
|
38
|
-
/** type of this device */
|
|
39
37
|
type = 'webgl';
|
|
40
38
|
/** The underlying WebGL context */
|
|
41
39
|
handle;
|
|
@@ -45,77 +43,21 @@ export class WebGLDevice extends Device {
|
|
|
45
43
|
canvasContext;
|
|
46
44
|
lost;
|
|
47
45
|
_resolveContextLost;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* @param gl
|
|
59
|
-
* @returns
|
|
60
|
-
*/
|
|
61
|
-
static attach(gl) {
|
|
62
|
-
if (gl instanceof WebGLDevice) {
|
|
63
|
-
return gl;
|
|
64
|
-
}
|
|
65
|
-
// @ts-expect-error
|
|
66
|
-
if (gl?.device instanceof Device) {
|
|
67
|
-
// @ts-expect-error
|
|
68
|
-
return gl.device;
|
|
69
|
-
}
|
|
70
|
-
if (!isWebGL(gl)) {
|
|
71
|
-
throw new Error('Invalid WebGL2RenderingContext');
|
|
72
|
-
}
|
|
73
|
-
return new WebGLDevice({ gl: gl });
|
|
74
|
-
}
|
|
75
|
-
static async create(props = {}) {
|
|
76
|
-
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
|
|
77
|
-
const promises = [];
|
|
78
|
-
// Load webgl and spector debug scripts from CDN if requested
|
|
79
|
-
if (props.debug) {
|
|
80
|
-
promises.push(loadWebGLDeveloperTools());
|
|
81
|
-
}
|
|
82
|
-
if (props.spector) {
|
|
83
|
-
promises.push(loadSpectorJS());
|
|
84
|
-
}
|
|
85
|
-
// Wait for page to load: if canvas is a string we need to query the DOM for the canvas element.
|
|
86
|
-
// We only wait when props.canvas is string to avoids setting the global page onload callback unless necessary.
|
|
87
|
-
if (typeof props.canvas === 'string') {
|
|
88
|
-
promises.push(CanvasContext.pageLoaded);
|
|
89
|
-
}
|
|
90
|
-
// Wait for all the loads to settle before creating the context.
|
|
91
|
-
// The Device.create() functions are async, so in contrast to the constructor, we can `await` here.
|
|
92
|
-
const results = await Promise.allSettled(promises);
|
|
93
|
-
for (const result of results) {
|
|
94
|
-
if (result.status === 'rejected') {
|
|
95
|
-
log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
|
|
99
|
-
// @ts-expect-error
|
|
100
|
-
if (props.gl?.device) {
|
|
101
|
-
log.warn('reattaching existing device')();
|
|
102
|
-
return WebGLDevice.attach(props.gl);
|
|
103
|
-
}
|
|
104
|
-
const device = new WebGLDevice(props);
|
|
105
|
-
// Log some debug info about the newly created context
|
|
106
|
-
const message = `\
|
|
107
|
-
Created ${device.type}${device.debug ? ' debug' : ''} context: \
|
|
108
|
-
${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
109
|
-
log.probe(LOG_LEVEL, message)();
|
|
110
|
-
log.table(LOG_LEVEL, device.info)();
|
|
111
|
-
log.groupEnd(LOG_LEVEL)();
|
|
112
|
-
return device;
|
|
113
|
-
}
|
|
46
|
+
/** WebGL2 context. */
|
|
47
|
+
gl;
|
|
48
|
+
debug = false;
|
|
49
|
+
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
50
|
+
_canvasSizeInfo = { clientWidth: 0, clientHeight: 0, devicePixelRatio: 1 };
|
|
51
|
+
/** State used by luma.gl classes - TODO - not used? */
|
|
52
|
+
_extensions = {};
|
|
53
|
+
_polyfilled = false;
|
|
54
|
+
/** Instance of Spector.js (if initialized) */
|
|
55
|
+
spectorJS;
|
|
114
56
|
//
|
|
115
57
|
// Public API
|
|
116
58
|
//
|
|
117
59
|
constructor(props) {
|
|
118
|
-
super({ ...props, id: props.id || 'webgl-device' });
|
|
60
|
+
super({ ...props, id: props.id || uid('webgl-device') });
|
|
119
61
|
// If attaching to an already attached context, return the attached device
|
|
120
62
|
// @ts-expect-error device is attached to context
|
|
121
63
|
const device = props.gl?.device;
|
|
@@ -128,22 +70,25 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
128
70
|
this.lost = new Promise(resolve => {
|
|
129
71
|
this._resolveContextLost = resolve;
|
|
130
72
|
});
|
|
131
|
-
|
|
132
|
-
gl ||= createBrowserContext(this.canvasContext.canvas, {
|
|
73
|
+
this.handle = createBrowserContext(this.canvasContext.canvas, {
|
|
133
74
|
...props,
|
|
134
75
|
onContextLost: (event) => this._resolveContextLost?.({
|
|
135
76
|
reason: 'destroyed',
|
|
136
77
|
message: 'Entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
137
78
|
})
|
|
138
79
|
});
|
|
139
|
-
|
|
80
|
+
this.gl = this.handle;
|
|
81
|
+
if (!this.handle) {
|
|
140
82
|
throw new Error('WebGL context creation failed');
|
|
141
83
|
}
|
|
142
|
-
|
|
143
|
-
|
|
84
|
+
// Add spector debug instrumentation to context
|
|
85
|
+
// We need to trust spector integration to decide if spector should be initialized
|
|
86
|
+
// We also run spector instrumentation first, otherwise spector can clobber luma instrumentation.
|
|
87
|
+
this.spectorJS = initializeSpectorJS({ ...this.props, gl: this.handle });
|
|
88
|
+
// Instrument context
|
|
144
89
|
this.gl.device = this; // Update GL context: Link webgl context back to device
|
|
145
90
|
this.gl._version = 2; // Update GL context: Store WebGL version field on gl context (HACK to identify debug contexts)
|
|
146
|
-
// luma Device fields
|
|
91
|
+
// initialize luma Device fields
|
|
147
92
|
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
148
93
|
this.limits = new WebGLDeviceLimits(this.gl);
|
|
149
94
|
this.features = new WebGLDeviceFeatures(this.gl, this._extensions, this.props.disabledFeatures);
|
|
@@ -152,23 +97,17 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
152
97
|
}
|
|
153
98
|
this.canvasContext.resize();
|
|
154
99
|
// Install context state tracking
|
|
155
|
-
|
|
156
|
-
const { enable = true, copyState = false } = props;
|
|
157
|
-
trackContextState(this.gl, {
|
|
158
|
-
enable,
|
|
159
|
-
copyState,
|
|
100
|
+
const glState = new WebGLStateTracker(this.gl, {
|
|
160
101
|
log: (...args) => log.log(1, ...args)()
|
|
161
102
|
});
|
|
162
|
-
|
|
103
|
+
glState.trackState(this.gl, { copyState: false });
|
|
104
|
+
// DEBUG contexts: Add luma debug instrumentation to the context, force log level to at least 1
|
|
163
105
|
if (props.debug) {
|
|
164
106
|
this.gl = makeDebugContext(this.gl, { ...props, throwOnError: true });
|
|
165
107
|
this.debug = true;
|
|
166
108
|
log.level = Math.max(log.level, 1);
|
|
167
109
|
log.warn('WebGL debug mode activated. Performance reduced.')();
|
|
168
110
|
}
|
|
169
|
-
if (props.spector) {
|
|
170
|
-
this.spectorJS = initializeSpectorJS({ ...this.props, canvas: this.handle.canvas });
|
|
171
|
-
}
|
|
172
111
|
}
|
|
173
112
|
/**
|
|
174
113
|
* Destroys the context
|
|
@@ -178,9 +117,6 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
178
117
|
get isLost() {
|
|
179
118
|
return this.gl.isContextLost();
|
|
180
119
|
}
|
|
181
|
-
getSize() {
|
|
182
|
-
return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];
|
|
183
|
-
}
|
|
184
120
|
isTextureFormatSupported(format) {
|
|
185
121
|
return isTextureFormatSupported(this.gl, format, this._extensions);
|
|
186
122
|
}
|
|
@@ -279,16 +215,6 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
279
215
|
//
|
|
280
216
|
// WebGL-only API (not part of `Device` API)
|
|
281
217
|
//
|
|
282
|
-
/** WebGL2 context. */
|
|
283
|
-
gl;
|
|
284
|
-
debug = false;
|
|
285
|
-
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
286
|
-
_canvasSizeInfo = { clientWidth: 0, clientHeight: 0, devicePixelRatio: 1 };
|
|
287
|
-
/** State used by luma.gl classes - TODO - not used? */
|
|
288
|
-
_extensions = {};
|
|
289
|
-
_polyfilled = false;
|
|
290
|
-
/** Instance of Spector.js (if initialized) */
|
|
291
|
-
spectorJS;
|
|
292
218
|
/**
|
|
293
219
|
* Triggers device (or WebGL context) loss.
|
|
294
220
|
* @note primarily intended for testing how application reacts to device loss
|
|
@@ -310,11 +236,13 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
310
236
|
}
|
|
311
237
|
/** Save current WebGL context state onto an internal stack */
|
|
312
238
|
pushState() {
|
|
313
|
-
|
|
239
|
+
const webglState = WebGLStateTracker.get(this.gl);
|
|
240
|
+
webglState.push();
|
|
314
241
|
}
|
|
315
242
|
/** Restores previously saved context state */
|
|
316
243
|
popState() {
|
|
317
|
-
|
|
244
|
+
const webglState = WebGLStateTracker.get(this.gl);
|
|
245
|
+
webglState.pop();
|
|
318
246
|
}
|
|
319
247
|
/**
|
|
320
248
|
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
|
|
@@ -379,14 +307,6 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
379
307
|
return this._extensions;
|
|
380
308
|
}
|
|
381
309
|
}
|
|
382
|
-
/** Check if supplied parameter is a WebGL2RenderingContext */
|
|
383
|
-
function isWebGL(gl) {
|
|
384
|
-
if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
|
|
385
|
-
return true;
|
|
386
|
-
}
|
|
387
|
-
// Look for debug contexts, headless gl etc
|
|
388
|
-
return Boolean(gl && Number.isFinite(gl._version));
|
|
389
|
-
}
|
|
390
310
|
/** Set constant float array attribute */
|
|
391
311
|
function setConstantFloatArray(device, location, array) {
|
|
392
312
|
switch (array.length) {
|
|
@@ -21,6 +21,7 @@ export declare function readPixelsToArray(source: Framebuffer | Texture, options
|
|
|
21
21
|
target?: Uint8Array | Uint16Array | Float32Array;
|
|
22
22
|
sourceWidth?: number;
|
|
23
23
|
sourceHeight?: number;
|
|
24
|
+
sourceDepth?: number;
|
|
24
25
|
sourceType?: number;
|
|
25
26
|
}): Uint8Array | Uint16Array | Float32Array;
|
|
26
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-and-blit.d.ts","sourceRoot":"","sources":["../../src/classic/copy-and-blit.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAEtC,OAAO,EAAC,gBAAgB,EAAC,kDAA+C;AAGxE,OAAO,EAAC,WAAW,EAAC,6CAA0C;AAG9D;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,GAAG,OAAO,EAC7B,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;IAEjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,UAAU,GAAG,WAAW,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"copy-and-blit.d.ts","sourceRoot":"","sources":["../../src/classic/copy-and-blit.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAEtC,OAAO,EAAC,gBAAgB,EAAC,kDAA+C;AAGxE,OAAO,EAAC,WAAW,EAAC,6CAA0C;AAG9D;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,GAAG,OAAO,EAC7B,OAAO,CAAC,EAAE;I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,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAiGT;AAYD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAU1F"}
|
|
@@ -18,27 +18,27 @@ import { WEBGLTexture } from "../adapter/resources/webgl-texture.js";
|
|
|
18
18
|
* @returns pixel array,
|
|
19
19
|
*/
|
|
20
20
|
export function readPixelsToArray(source, options) {
|
|
21
|
-
const { sourceX = 0, sourceY = 0,
|
|
21
|
+
const { sourceX = 0, sourceY = 0, sourceAttachment = 36064 // TODO - support gl.readBuffer
|
|
22
22
|
} = options || {};
|
|
23
23
|
let { target = null,
|
|
24
24
|
// following parameters are auto deduced if not provided
|
|
25
|
-
sourceWidth, sourceHeight, sourceType } = options || {};
|
|
25
|
+
sourceWidth, sourceHeight, sourceDepth, sourceFormat, sourceType } = options || {};
|
|
26
26
|
const { framebuffer, deleteFramebuffer } = getFramebuffer(source);
|
|
27
27
|
// assert(framebuffer);
|
|
28
28
|
const { gl, handle } = framebuffer;
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const attachment = sourceAttachment - 36064;
|
|
30
|
+
sourceWidth ||= framebuffer.width;
|
|
31
|
+
sourceHeight ||= framebuffer.height;
|
|
31
32
|
// TODO - Set and unset gl.readBuffer
|
|
32
33
|
// if (sourceAttachment === GL.COLOR_ATTACHMENT0 && handle === null) {
|
|
33
34
|
// sourceAttachment = GL.FRONT;
|
|
34
35
|
// }
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
sourceDepth = framebuffer.colorAttachments[attachment]?.texture?.depth || 1;
|
|
37
|
+
sourceFormat ||= framebuffer.colorAttachments[attachment]?.texture?.glFormat || 6408;
|
|
37
38
|
// Deduce the type from color attachment if not provided.
|
|
38
|
-
sourceType
|
|
39
|
-
sourceType || framebuffer.colorAttachments[attachment]?.texture?.glType || 5121;
|
|
39
|
+
sourceType ||= framebuffer.colorAttachments[attachment]?.texture?.glType || 5121;
|
|
40
40
|
// Deduce type and allocated pixelArray if needed
|
|
41
|
-
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
|
|
41
|
+
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
|
|
42
42
|
// Pixel array available, if necessary, deduce type from it.
|
|
43
43
|
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
44
44
|
const prevHandle = gl.bindFramebuffer(36160, handle);
|
|
@@ -180,7 +180,8 @@ export function toFramebuffer(texture, props) {
|
|
|
180
180
|
});
|
|
181
181
|
return framebuffer;
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
// eslint-disable-next-line max-params
|
|
184
|
+
function getPixelArray(pixelArray, type, format, width, height, depth) {
|
|
184
185
|
if (pixelArray) {
|
|
185
186
|
return pixelArray;
|
|
186
187
|
}
|