@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.6
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 +71 -11
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +3 -2
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +40 -20
- package/dist/adapter/converters/texture-formats.d.ts +10 -7
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +76 -64
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +2 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +18 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +77 -43
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +17 -14
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +2 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +6 -5
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +2 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +2 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +24 -11
- package/dist/adapter/objects/webgl-resource.d.ts +2 -24
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -100
- package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +2 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +7 -6
- package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -2
- package/dist/adapter/resources/webgl-external-texture.js +3 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -8
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +25 -23
- package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-query-set.js +136 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +15 -7
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +34 -49
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +12 -6
- package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
- package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-texture-view.js +18 -0
- package/dist/adapter/resources/webgl-texture.d.ts +4 -3
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +12 -7
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +2 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +5 -4
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +3 -2
- package/dist/adapter/webgl-device.d.ts +29 -27
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +90 -94
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +4 -3
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +3 -2
- package/dist/classic/copy-and-blit.d.ts +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +5 -4
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +2 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +2 -1
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -6
- package/dist/context/helpers/create-browser-context.d.ts +35 -0
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -0
- package/dist/context/helpers/create-browser-context.js +67 -0
- package/dist/context/helpers/webgl-context-data.d.ts +13 -0
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
- package/dist/context/helpers/webgl-context-data.js +21 -0
- package/dist/context/helpers/webgl-extensions.d.ts +4 -0
- package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
- package/dist/context/helpers/webgl-extensions.js +10 -0
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +4 -3
- package/dist/context/parameters/webgl-parameter-tables.d.ts +10 -0
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +29 -16
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +2 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -4
- package/dist/context/state-tracker/with-parameters.d.ts +1 -1
- 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 +941 -730
- package/dist/index.cjs +732 -565
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +25 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist.min.js +5 -5
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +105 -16
- package/src/adapter/converters/sampler-parameters.ts +12 -3
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +87 -66
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +83 -51
- package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
- package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +4 -3
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +2 -1
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +2 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +35 -13
- package/src/adapter/objects/webgl-resource.ts +6 -124
- package/src/adapter/resources/webgl-buffer.ts +4 -3
- package/src/adapter/resources/webgl-command-buffer.ts +5 -5
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +3 -2
- package/src/adapter/resources/webgl-framebuffer.ts +34 -29
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +17 -8
- package/src/adapter/resources/webgl-render-pipeline.ts +41 -48
- package/src/adapter/resources/webgl-sampler.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +12 -5
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +9 -2
- package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-canvas-context.ts +6 -4
- package/src/adapter/webgl-device.ts +94 -90
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +12 -6
- package/src/classic/copy-and-blit.ts +11 -4
- package/src/classic/format-utils.ts +2 -1
- package/src/classic/typed-array-utils.ts +3 -7
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +27 -14
- package/src/context/{context → helpers}/create-browser-context.ts +3 -2
- package/src/context/helpers/webgl-context-data.ts +31 -0
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +2 -1
- package/src/context/parameters/webgl-parameter-tables.ts +69 -32
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +11 -6
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +3 -2
- package/src/types.ts +2 -1
- package/src/context/context/context-data.ts +0 -44
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {
|
|
5
6
|
DeviceProps,
|
|
6
7
|
DeviceInfo,
|
|
7
|
-
DeviceLimits,
|
|
8
|
-
DeviceFeature,
|
|
9
8
|
CanvasContextProps,
|
|
10
9
|
TextureFormat,
|
|
11
10
|
VertexArray,
|
|
@@ -16,16 +15,16 @@ import type {
|
|
|
16
15
|
TypedArray
|
|
17
16
|
} from '@luma.gl/core';
|
|
18
17
|
import {Device, CanvasContext, log, uid, assert} from '@luma.gl/core';
|
|
19
|
-
import {
|
|
18
|
+
import type {GLExtensions} from '@luma.gl/constants';
|
|
20
19
|
import {
|
|
21
20
|
popContextState,
|
|
22
21
|
pushContextState,
|
|
23
22
|
trackContextState
|
|
24
23
|
} from '../context/state-tracker/track-context-state';
|
|
25
|
-
import {createBrowserContext} from '../context/
|
|
24
|
+
import {createBrowserContext} from '../context/helpers/create-browser-context';
|
|
26
25
|
import {getDeviceInfo} from './device-helpers/webgl-device-info';
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
26
|
+
import {WebGLDeviceFeatures} from './device-helpers/webgl-device-features';
|
|
27
|
+
import {WebGLDeviceLimits} from './device-helpers/webgl-device-limits';
|
|
29
28
|
import {WebGLCanvasContext} from './webgl-canvas-context';
|
|
30
29
|
import {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';
|
|
31
30
|
import {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';
|
|
@@ -55,7 +54,8 @@ import type {
|
|
|
55
54
|
ComputePassProps,
|
|
56
55
|
// CommandEncoder,
|
|
57
56
|
CommandEncoderProps,
|
|
58
|
-
TransformFeedbackProps
|
|
57
|
+
TransformFeedbackProps,
|
|
58
|
+
QuerySetProps
|
|
59
59
|
} from '@luma.gl/core';
|
|
60
60
|
|
|
61
61
|
import {WEBGLBuffer} from './resources/webgl-buffer';
|
|
@@ -68,11 +68,13 @@ import {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';
|
|
|
68
68
|
import {WEBGLCommandEncoder} from './resources/webgl-command-encoder';
|
|
69
69
|
import {WEBGLVertexArray} from './resources/webgl-vertex-array';
|
|
70
70
|
import {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';
|
|
71
|
+
import {WEBGLQuerySet} from './resources/webgl-query-set';
|
|
71
72
|
|
|
72
73
|
import {readPixelsToArray, readPixelsToBuffer} from '../classic/copy-and-blit';
|
|
73
74
|
import {setGLParameters, getGLParameters} from '../context/parameters/unified-parameter-api';
|
|
74
75
|
import {withGLParameters} from '../context/state-tracker/with-parameters';
|
|
75
76
|
import {clear} from '../classic/clear';
|
|
77
|
+
import {getWebGLExtension} from '../context/helpers/webgl-extensions';
|
|
76
78
|
|
|
77
79
|
const LOG_LEVEL = 1;
|
|
78
80
|
|
|
@@ -88,26 +90,17 @@ export class WebGLDevice extends Device {
|
|
|
88
90
|
return typeof WebGL2RenderingContext !== 'undefined';
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
readonly canvasContext: WebGLCanvasContext;
|
|
93
|
-
|
|
93
|
+
/** The underlying WebGL context */
|
|
94
94
|
readonly handle: WebGL2RenderingContext;
|
|
95
|
+
features: WebGLDeviceFeatures;
|
|
96
|
+
limits: WebGLDeviceLimits;
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return this._features;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
get limits(): DeviceLimits {
|
|
102
|
-
this._limits = this._limits || getDeviceLimits(this.gl);
|
|
103
|
-
return this._limits;
|
|
104
|
-
}
|
|
98
|
+
readonly info: DeviceInfo;
|
|
99
|
+
readonly canvasContext: WebGLCanvasContext;
|
|
105
100
|
|
|
106
101
|
readonly lost: Promise<{reason: 'destroyed'; message: string}>;
|
|
107
102
|
|
|
108
103
|
private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;
|
|
109
|
-
private _features?: Set<DeviceFeature>;
|
|
110
|
-
private _limits?: DeviceLimits;
|
|
111
104
|
|
|
112
105
|
//
|
|
113
106
|
// Static methods, expected to be present by `luma.createDevice()`
|
|
@@ -137,27 +130,31 @@ export class WebGLDevice extends Device {
|
|
|
137
130
|
static async create(props: DeviceProps = {}): Promise<WebGLDevice> {
|
|
138
131
|
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
|
|
139
132
|
|
|
140
|
-
|
|
141
|
-
// to avoid setting page onload callback unless necessary
|
|
142
|
-
if (typeof props.canvas === 'string') {
|
|
143
|
-
await CanvasContext.pageLoaded;
|
|
144
|
-
}
|
|
133
|
+
const promises: Promise<unknown>[] = [];
|
|
145
134
|
|
|
146
135
|
// Load webgl and spector debug scripts from CDN if requested
|
|
147
|
-
if (
|
|
148
|
-
|
|
136
|
+
if (props.debug) {
|
|
137
|
+
promises.push(loadWebGLDeveloperTools());
|
|
149
138
|
}
|
|
150
139
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (log.get('spector') || spector) {
|
|
154
|
-
await loadSpectorJS();
|
|
140
|
+
if (props.spector) {
|
|
141
|
+
promises.push(loadSpectorJS());
|
|
155
142
|
}
|
|
156
143
|
|
|
144
|
+
// Wait for page to load: if canvas is a string we need to query the DOM for the canvas element.
|
|
145
|
+
// We only wait when props.canvas is string to avoids setting the global page onload callback unless necessary.
|
|
146
|
+
if (typeof props.canvas === 'string') {
|
|
147
|
+
promises.push(CanvasContext.pageLoaded);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Wait for all the loads to settle before creating the context.
|
|
151
|
+
// The Device.create() functions are async, so in contrast to the constructor, we can `await` here.
|
|
152
|
+
await Promise.all(promises);
|
|
153
|
+
|
|
157
154
|
log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
|
|
158
155
|
|
|
159
156
|
// @ts-expect-error
|
|
160
|
-
if (props.gl
|
|
157
|
+
if (props.gl?.device) {
|
|
161
158
|
return WebGLDevice.attach(props.gl);
|
|
162
159
|
}
|
|
163
160
|
|
|
@@ -190,41 +187,39 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
190
187
|
}
|
|
191
188
|
|
|
192
189
|
// Create and instrument context
|
|
193
|
-
const canvas = props.canvas || props.
|
|
190
|
+
const canvas = props.gl?.canvas || props.canvas;
|
|
194
191
|
this.canvasContext = new WebGLCanvasContext(this, {...props, canvas});
|
|
195
192
|
|
|
196
193
|
this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {
|
|
197
194
|
this._resolveContextLost = resolve;
|
|
198
195
|
});
|
|
199
196
|
|
|
200
|
-
const onContextLost = (event: Event) =>
|
|
201
|
-
this._resolveContextLost?.({
|
|
202
|
-
reason: 'destroyed',
|
|
203
|
-
message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
204
|
-
});
|
|
205
|
-
|
|
206
197
|
let gl: WebGL2RenderingContext | null = props.gl || null;
|
|
207
|
-
gl
|
|
208
|
-
|
|
209
|
-
(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
198
|
+
gl ||= createBrowserContext(this.canvasContext.canvas, {
|
|
199
|
+
...props,
|
|
200
|
+
onContextLost: (event: Event) =>
|
|
201
|
+
this._resolveContextLost?.({
|
|
202
|
+
reason: 'destroyed',
|
|
203
|
+
message: 'Entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
|
|
213
207
|
if (!gl) {
|
|
214
208
|
throw new Error('WebGL context creation failed');
|
|
215
209
|
}
|
|
216
210
|
|
|
217
211
|
this.handle = gl;
|
|
218
|
-
this.gl =
|
|
219
|
-
|
|
212
|
+
this.gl = gl;
|
|
213
|
+
|
|
214
|
+
(this.gl as any).device = this; // Update GL context: Link webgl context back to device
|
|
215
|
+
(this.gl as any)._version = 2; // Update GL context: Store WebGL version field on gl context (HACK to identify debug contexts)
|
|
220
216
|
|
|
221
217
|
// luma Device fields
|
|
222
|
-
this.info = getDeviceInfo(this.gl);
|
|
218
|
+
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
219
|
+
this.features = new WebGLDeviceFeatures(this.gl, this._extensions);
|
|
220
|
+
this.limits = new WebGLDeviceLimits(this.gl);
|
|
223
221
|
|
|
224
|
-
|
|
225
|
-
this.gl.device = this;
|
|
226
|
-
// @ts-expect-error Annotate webgl context to handle
|
|
227
|
-
this.gl._version = this.isWebGL2 ? 2 : 1;
|
|
222
|
+
this.canvasContext.resize();
|
|
228
223
|
|
|
229
224
|
// Install context state tracking
|
|
230
225
|
// @ts-expect-error - hidden parameters
|
|
@@ -236,26 +231,23 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
236
231
|
});
|
|
237
232
|
|
|
238
233
|
// DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1
|
|
239
|
-
if (
|
|
234
|
+
if (props.debug) {
|
|
240
235
|
this.gl = makeDebugContext(this.gl, {...props, throwOnError: true});
|
|
241
236
|
this.debug = true;
|
|
242
237
|
log.level = Math.max(log.level, 1);
|
|
243
238
|
log.warn('WebGL debug mode activated. Performance reduced.')();
|
|
244
239
|
}
|
|
245
240
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);
|
|
249
|
-
this.spector = initializeSpectorJS({...this.props, canvas});
|
|
241
|
+
if (props.spector) {
|
|
242
|
+
this.spectorJS = initializeSpectorJS({...this.props, canvas: this.handle.canvas});
|
|
250
243
|
}
|
|
251
244
|
}
|
|
252
245
|
|
|
253
246
|
/**
|
|
254
247
|
* Destroys the context
|
|
255
|
-
* @note Has no effect for browser contexts, there is no browser API for destroying contexts
|
|
248
|
+
* @note Has no effect for WebGL browser contexts, there is no browser API for destroying contexts
|
|
256
249
|
*/
|
|
257
|
-
destroy(): void {
|
|
258
|
-
}
|
|
250
|
+
destroy(): void {}
|
|
259
251
|
|
|
260
252
|
get isLost(): boolean {
|
|
261
253
|
return this.gl.isContextLost();
|
|
@@ -266,15 +258,15 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
266
258
|
}
|
|
267
259
|
|
|
268
260
|
isTextureFormatSupported(format: TextureFormat): boolean {
|
|
269
|
-
return isTextureFormatSupported(this.gl, format);
|
|
261
|
+
return isTextureFormatSupported(this.gl, format, this._extensions);
|
|
270
262
|
}
|
|
271
263
|
|
|
272
264
|
isTextureFormatFilterable(format: TextureFormat): boolean {
|
|
273
|
-
return isTextureFormatFilterable(this.gl, format);
|
|
265
|
+
return isTextureFormatFilterable(this.gl, format, this._extensions);
|
|
274
266
|
}
|
|
275
267
|
|
|
276
268
|
isTextureFormatRenderable(format: TextureFormat): boolean {
|
|
277
|
-
return isTextureFormatRenderable(this.gl, format);
|
|
269
|
+
return isTextureFormatRenderable(this.gl, format, this._extensions);
|
|
278
270
|
}
|
|
279
271
|
|
|
280
272
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
@@ -308,12 +300,20 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
308
300
|
return new WEBGLFramebuffer(this, props);
|
|
309
301
|
}
|
|
310
302
|
|
|
311
|
-
|
|
312
|
-
return new
|
|
303
|
+
createVertexArray(props: VertexArrayProps): VertexArray {
|
|
304
|
+
return new WEBGLVertexArray(this, props);
|
|
313
305
|
}
|
|
314
306
|
|
|
315
|
-
|
|
316
|
-
return new
|
|
307
|
+
createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback {
|
|
308
|
+
return new WEBGLTransformFeedback(this, props);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
createQuerySet(props: QuerySetProps): WEBGLQuerySet {
|
|
312
|
+
return new WEBGLQuerySet(this, props);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {
|
|
316
|
+
return new WEBGLRenderPipeline(this, props);
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
beginRenderPass(props: RenderPassProps): WEBGLRenderPass {
|
|
@@ -328,10 +328,6 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
328
328
|
throw new Error('ComputePass not supported in WebGL');
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback {
|
|
332
|
-
return new WEBGLTransformFeedback(this, props);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
331
|
private renderPass: WEBGLRenderPass | null = null;
|
|
336
332
|
|
|
337
333
|
getDefaultRenderPass(): WEBGLRenderPass {
|
|
@@ -360,7 +356,7 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
360
356
|
|
|
361
357
|
//
|
|
362
358
|
// TEMPORARY HACKS - will be removed in v9.1
|
|
363
|
-
//
|
|
359
|
+
//
|
|
364
360
|
|
|
365
361
|
/** @deprecated - should use command encoder */
|
|
366
362
|
override readPixelsToArrayWebGL(
|
|
@@ -410,10 +406,15 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
410
406
|
withGLParameters(this, parameters, func);
|
|
411
407
|
}
|
|
412
408
|
|
|
413
|
-
override clearWebGL(options?: {
|
|
409
|
+
override clearWebGL(options?: {
|
|
410
|
+
framebuffer?: Framebuffer;
|
|
411
|
+
color?: any;
|
|
412
|
+
depth?: any;
|
|
413
|
+
stencil?: any;
|
|
414
|
+
}): void {
|
|
414
415
|
clear(this, options);
|
|
415
416
|
}
|
|
416
|
-
|
|
417
|
+
|
|
417
418
|
//
|
|
418
419
|
// WebGL-only API (not part of `Device` API)
|
|
419
420
|
//
|
|
@@ -426,19 +427,11 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
426
427
|
readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};
|
|
427
428
|
|
|
428
429
|
/** State used by luma.gl classes - TODO - not used? */
|
|
429
|
-
readonly _extensions:
|
|
430
|
+
readonly _extensions: GLExtensions = {};
|
|
430
431
|
_polyfilled: boolean = false;
|
|
431
432
|
|
|
432
433
|
/** Instance of Spector.js (if initialized) */
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
private _webglLimits?: WebGLLimits;
|
|
436
|
-
|
|
437
|
-
/** Return WebGL specific limits */
|
|
438
|
-
get webglLimits(): WebGLLimits {
|
|
439
|
-
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
440
|
-
return this._webglLimits;
|
|
441
|
-
}
|
|
434
|
+
spectorJS: unknown;
|
|
442
435
|
|
|
443
436
|
/**
|
|
444
437
|
* Triggers device (or WebGL context) loss.
|
|
@@ -446,7 +439,8 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
446
439
|
*/
|
|
447
440
|
override loseDevice(): boolean {
|
|
448
441
|
let deviceLossTriggered = false;
|
|
449
|
-
const
|
|
442
|
+
const extensions = this.getExtension('WEBGL_lose_context');
|
|
443
|
+
const ext = extensions.WEBGL_lose_context;
|
|
450
444
|
if (ext) {
|
|
451
445
|
deviceLossTriggered = true;
|
|
452
446
|
ext.loseContext();
|
|
@@ -507,11 +501,15 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
507
501
|
* so they need to be updated before every render
|
|
508
502
|
* @todo - remember/cache values to avoid setting them unnecessarily?
|
|
509
503
|
*/
|
|
510
|
-
|
|
511
|
-
|
|
504
|
+
setConstantAttributeWebGL(location: number, constant: TypedArray): void {
|
|
505
|
+
const maxVertexAttributes = this.limits.maxVertexAttributes;
|
|
506
|
+
this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
|
|
512
507
|
const currentConstant = this._constants[location];
|
|
513
508
|
if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {
|
|
514
|
-
log.info(
|
|
509
|
+
log.info(
|
|
510
|
+
1,
|
|
511
|
+
`setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`
|
|
512
|
+
)();
|
|
515
513
|
}
|
|
516
514
|
this._constants[location] = constant;
|
|
517
515
|
|
|
@@ -529,6 +527,12 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
529
527
|
assert(false);
|
|
530
528
|
}
|
|
531
529
|
}
|
|
530
|
+
|
|
531
|
+
/** Ensure extensions are only requested once */
|
|
532
|
+
getExtension(name: keyof GLExtensions): GLExtensions {
|
|
533
|
+
getWebGLExtension(this.gl, name, this._extensions);
|
|
534
|
+
return this._extensions;
|
|
535
|
+
}
|
|
532
536
|
}
|
|
533
537
|
|
|
534
538
|
/** Check if supplied parameter is a WebGL2RenderingContext */
|
package/src/classic/accessor.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {assert, checkProps, Buffer, AccessorObject} from '@luma.gl/core';
|
|
@@ -58,7 +59,7 @@ export class Accessor implements AccessorObject {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
constructor(...accessors: AccessorObject[]) {
|
|
61
|
-
accessors.forEach(
|
|
62
|
+
accessors.forEach(accessor => this._assign(accessor)); // Merge in sequence
|
|
62
63
|
Object.freeze(this);
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -151,10 +152,10 @@ export class Accessor implements AccessorObject {
|
|
|
151
152
|
if (this.divisor === undefined) delete this.divisor;
|
|
152
153
|
if (this.normalized === undefined) delete this.normalized;
|
|
153
154
|
if (this.integer === undefined) delete this.integer;
|
|
154
|
-
|
|
155
|
+
|
|
155
156
|
if (this.buffer === undefined) delete this.buffer;
|
|
156
157
|
if (this.index === undefined) delete this.index;
|
|
157
|
-
|
|
158
|
+
|
|
158
159
|
return this;
|
|
159
160
|
}
|
|
160
161
|
}
|
package/src/classic/clear.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {Device, Framebuffer, assert} from '@luma.gl/core';
|
|
@@ -18,8 +19,8 @@ const GL_DEPTH_STENCIL = 0x84f9;
|
|
|
18
19
|
// Should disappear if asserts are removed
|
|
19
20
|
const ERR_ARGUMENTS = 'clear: bad arguments';
|
|
20
21
|
|
|
21
|
-
/**
|
|
22
|
-
* Optionally clears depth, color and stencil buffers
|
|
22
|
+
/**
|
|
23
|
+
* Optionally clears depth, color and stencil buffers
|
|
23
24
|
* @deprecated Set clear color when creating a RenderPass.
|
|
24
25
|
*/
|
|
25
26
|
export function clear(
|
|
@@ -65,15 +66,20 @@ export function clear(
|
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
/**
|
|
69
|
-
* WebGL2 - clear a specific drawing buffer
|
|
69
|
+
/**
|
|
70
|
+
* WebGL2 - clear a specific drawing buffer
|
|
70
71
|
* @deprecated Set clear color when creating a RenderPass
|
|
71
72
|
*/
|
|
72
73
|
export function clearBuffer(
|
|
73
74
|
device: Device,
|
|
74
75
|
options?: {framebuffer?: Framebuffer; buffer?: any; drawBuffer?: any; value?: any}
|
|
75
76
|
) {
|
|
76
|
-
const {
|
|
77
|
+
const {
|
|
78
|
+
framebuffer = null,
|
|
79
|
+
buffer = GL_COLOR,
|
|
80
|
+
drawBuffer = 0,
|
|
81
|
+
value = [0, 0, 0, 0]
|
|
82
|
+
} = options || {};
|
|
77
83
|
const gl = (device as WebGLDevice).gl;
|
|
78
84
|
withGLParameters(gl, {framebuffer}, () => {
|
|
79
85
|
// Method selection per OpenGL ES 3 docs
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {assert, Buffer, Texture, Framebuffer, FramebufferProps} from '@luma.gl/core';
|
|
5
6
|
import {GL} from '@luma.gl/constants';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
+
import {WEBGLTextureView} from '../adapter/resources/webgl-texture-view';
|
|
8
9
|
import {WEBGLFramebuffer} from '../adapter/resources/webgl-framebuffer';
|
|
9
10
|
import {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';
|
|
10
11
|
import {glFormatToComponents, glTypeToBytes} from './format-utils';
|
|
@@ -66,7 +67,7 @@ export function readPixelsToArray(
|
|
|
66
67
|
// Deduce the type from color attachment if not provided.
|
|
67
68
|
sourceType =
|
|
68
69
|
sourceType ||
|
|
69
|
-
(framebuffer.colorAttachments[attachment] as
|
|
70
|
+
(framebuffer.colorAttachments[attachment] as WEBGLTextureView)?.texture?.type ||
|
|
70
71
|
GL.UNSIGNED_BYTE;
|
|
71
72
|
|
|
72
73
|
// Deduce type and allocated pixelArray if needed
|
|
@@ -106,7 +107,13 @@ export function readPixelsToBuffer(
|
|
|
106
107
|
sourceType?: number;
|
|
107
108
|
}
|
|
108
109
|
): WEBGLBuffer {
|
|
109
|
-
const {
|
|
110
|
+
const {
|
|
111
|
+
target,
|
|
112
|
+
sourceX = 0,
|
|
113
|
+
sourceY = 0,
|
|
114
|
+
sourceFormat = GL.RGBA,
|
|
115
|
+
targetByteOffset = 0
|
|
116
|
+
} = options || {};
|
|
110
117
|
// following parameters are auto deduced if not provided
|
|
111
118
|
let {sourceWidth, sourceHeight, sourceType} = options || {};
|
|
112
119
|
const {framebuffer, deleteFramebuffer} = getFramebuffer(source);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {TypedArray, TypedArrayConstructor} from '@luma.gl/core';
|
|
@@ -108,12 +109,7 @@ export function flipRows(options: {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
export function scalePixels(options: {
|
|
113
|
-
data: TypedArray;
|
|
114
|
-
width: number;
|
|
115
|
-
height: number;
|
|
116
|
-
}): {
|
|
112
|
+
export function scalePixels(options: {data: TypedArray; width: number; height: number}): {
|
|
117
113
|
data: Uint8Array;
|
|
118
114
|
width: number;
|
|
119
115
|
height: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {log, loadScript} from '@luma.gl/core';
|
|
@@ -34,8 +35,8 @@ export async function loadSpectorJS(props?: SpectorProps) {
|
|
|
34
35
|
if (!globalThis.SPECTOR) {
|
|
35
36
|
try {
|
|
36
37
|
await loadScript(SPECTOR_CDN_URL);
|
|
37
|
-
} catch(error) {
|
|
38
|
-
log.warn(String(error))
|
|
38
|
+
} catch (error) {
|
|
39
|
+
log.warn(String(error));
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -64,14 +65,16 @@ export function initializeSpectorJS(props?: SpectorProps) {
|
|
|
64
65
|
// enables recording some extra information merged in the capture like texture memory sizes and formats
|
|
65
66
|
spector.spyCanvases();
|
|
66
67
|
// A callback when results are ready
|
|
67
|
-
spector?.onCaptureStarted.add((capture: unknown) =>
|
|
68
|
+
spector?.onCaptureStarted.add((capture: unknown) =>
|
|
69
|
+
log.info('Spector capture started:', capture)()
|
|
70
|
+
);
|
|
68
71
|
spector?.onCapture.add((capture: unknown) => {
|
|
69
72
|
log.info('Spector capture complete:', capture)();
|
|
70
73
|
// Use undocumented Spector API to open the UI with our capture
|
|
71
74
|
// See https://github.com/BabylonJS/Spector.js/blob/767ad1195a25b85a85c381f400eb50a979239eca/src/spector.ts#L124
|
|
72
|
-
spector?.getResultUI()
|
|
75
|
+
spector?.getResultUI();
|
|
73
76
|
spector?.resultView.display();
|
|
74
|
-
spector?.resultView.addCapture(capture)
|
|
77
|
+
spector?.resultView.addCapture(capture);
|
|
75
78
|
});
|
|
76
79
|
}
|
|
77
80
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {log, loadScript} from '@luma.gl/core';
|
|
5
6
|
// Rename constant to prevent inlining. We need the full set of constants for generating debug strings.
|
|
6
7
|
import {GL as GLEnum} from '@luma.gl/constants';
|
|
7
|
-
import {isBrowser} from '@probe.gl/env'
|
|
8
|
+
import {isBrowser} from '@probe.gl/env';
|
|
8
9
|
|
|
9
10
|
const WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';
|
|
10
11
|
|
|
@@ -24,10 +25,10 @@ type DebugContextProps = {
|
|
|
24
25
|
type ContextData = {
|
|
25
26
|
realContext?: WebGL2RenderingContext;
|
|
26
27
|
debugContext?: WebGL2RenderingContext;
|
|
27
|
-
}
|
|
28
|
+
};
|
|
28
29
|
|
|
29
30
|
// Helper to get shared context data
|
|
30
|
-
function
|
|
31
|
+
function getWebGLContextData(gl: any): ContextData {
|
|
31
32
|
gl.luma = gl.luma || {};
|
|
32
33
|
return gl.luma;
|
|
33
34
|
}
|
|
@@ -38,7 +39,7 @@ declare global {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
|
-
* Loads Khronos WebGLDeveloperTools from CDN if not already installed
|
|
42
|
+
* Loads Khronos WebGLDeveloperTools from CDN if not already installed
|
|
42
43
|
* const WebGLDebugUtils = require('webgl-debug');
|
|
43
44
|
* @see https://github.com/KhronosGroup/WebGLDeveloperTools
|
|
44
45
|
* @see https://github.com/vorg/webgl-debug
|
|
@@ -54,7 +55,10 @@ export async function loadWebGLDeveloperTools(): Promise<void> {
|
|
|
54
55
|
|
|
55
56
|
// Returns (a potentially new) context with debug instrumentation turned off or on.
|
|
56
57
|
// Note that this actually returns a new context
|
|
57
|
-
export function makeDebugContext(
|
|
58
|
+
export function makeDebugContext(
|
|
59
|
+
gl: WebGL2RenderingContext,
|
|
60
|
+
props: DebugContextProps = {}
|
|
61
|
+
): WebGL2RenderingContext | null {
|
|
58
62
|
// Return null to ensure we don't try to create a context in this case (TODO what case is that?)
|
|
59
63
|
if (!gl) {
|
|
60
64
|
return null;
|
|
@@ -65,19 +69,22 @@ export function makeDebugContext(gl: WebGL2RenderingContext, props: DebugContext
|
|
|
65
69
|
|
|
66
70
|
// Returns the real context from either of the real/debug contexts
|
|
67
71
|
function getRealContext(gl: WebGL2RenderingContext): WebGL2RenderingContext {
|
|
68
|
-
const data =
|
|
72
|
+
const data = getWebGLContextData(gl);
|
|
69
73
|
// If the context has a realContext member, it is a debug context so return the realContext
|
|
70
74
|
return data.realContext ? data.realContext : gl;
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
// Returns the debug context from either of the real/debug contexts
|
|
74
|
-
function getDebugContext(
|
|
78
|
+
function getDebugContext(
|
|
79
|
+
gl: WebGL2RenderingContext,
|
|
80
|
+
props: DebugContextProps
|
|
81
|
+
): WebGL2RenderingContext {
|
|
75
82
|
if (!globalThis.WebGLDebugUtils) {
|
|
76
83
|
log.warn('webgl-debug not loaded')();
|
|
77
84
|
return gl;
|
|
78
85
|
}
|
|
79
86
|
|
|
80
|
-
const data =
|
|
87
|
+
const data = getWebGLContextData(gl);
|
|
81
88
|
|
|
82
89
|
// If this already has a debug context, return it.
|
|
83
90
|
if (data.debugContext) {
|
|
@@ -98,7 +105,7 @@ function getDebugContext(gl: WebGL2RenderingContext, props: DebugContextProps):
|
|
|
98
105
|
glDebug[key] = GLEnum[key];
|
|
99
106
|
}
|
|
100
107
|
}
|
|
101
|
-
|
|
108
|
+
|
|
102
109
|
// Ensure we have a clean prototype on the instrumented object
|
|
103
110
|
// Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction
|
|
104
111
|
// by synchronizing the WebGL errors after each WebGL call.
|
|
@@ -119,7 +126,7 @@ function getDebugContext(gl: WebGL2RenderingContext, props: DebugContextProps):
|
|
|
119
126
|
|
|
120
127
|
function getFunctionString(functionName: string, functionArgs): string {
|
|
121
128
|
// Cover bug in webgl-debug-tools
|
|
122
|
-
functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);
|
|
129
|
+
functionArgs = Array.from(functionArgs).map(arg => (arg === undefined ? 'undefined' : arg));
|
|
123
130
|
let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);
|
|
124
131
|
args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;
|
|
125
132
|
return `gl.${functionName}(${args})`;
|
|
@@ -127,7 +134,7 @@ function getFunctionString(functionName: string, functionArgs): string {
|
|
|
127
134
|
|
|
128
135
|
function onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {
|
|
129
136
|
// Cover bug in webgl-debug-tools
|
|
130
|
-
args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);
|
|
137
|
+
args = Array.from(args).map(arg => (arg === undefined ? 'undefined' : arg));
|
|
131
138
|
const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
|
|
132
139
|
const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
133
140
|
const message = `${errorMessage} in gl.${functionName}(${functionArgs})`;
|
|
@@ -139,7 +146,11 @@ function onGLError(props: DebugContextProps, err, functionName: string, args: an
|
|
|
139
146
|
}
|
|
140
147
|
|
|
141
148
|
// Don't generate function string until it is needed
|
|
142
|
-
function onValidateGLFunc(
|
|
149
|
+
function onValidateGLFunc(
|
|
150
|
+
props: DebugContextProps,
|
|
151
|
+
functionName: string,
|
|
152
|
+
functionArgs: any[]
|
|
153
|
+
): void {
|
|
143
154
|
let functionString: string = '';
|
|
144
155
|
if (log.level >= 1) {
|
|
145
156
|
functionString = getFunctionString(functionName, functionArgs);
|
|
@@ -149,7 +160,9 @@ function onValidateGLFunc(props: DebugContextProps, functionName: string, functi
|
|
|
149
160
|
// If array of breakpoint strings supplied, check if any of them is contained in current GLEnum function
|
|
150
161
|
if (props.break && props.break.length > 0) {
|
|
151
162
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
152
|
-
const isBreakpoint = props.break.every(
|
|
163
|
+
const isBreakpoint = props.break.every(
|
|
164
|
+
(breakOn: string) => functionString.indexOf(breakOn) !== -1
|
|
165
|
+
);
|
|
153
166
|
if (isBreakpoint) {
|
|
154
167
|
debugger; // eslint-disable-line
|
|
155
168
|
}
|