@luma.gl/webgl 9.0.0-beta.4 → 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 +297 -155
- package/dist/adapter/converters/sampler-parameters.d.ts +0 -4
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +73 -67
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +53 -46
- package/dist/adapter/converters/texture-formats.d.ts +13 -19
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +474 -879
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +53 -61
- package/dist/adapter/device-helpers/device-features.d.ts +2 -5
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +56 -87
- package/dist/adapter/device-helpers/device-limits.d.ts +2 -4
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +88 -83
- package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +79 -63
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.js +86 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +5 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js +90 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +35 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js +47 -0
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +88 -76
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +261 -225
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +47 -37
- package/dist/adapter/helpers/set-uniform.d.ts +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +68 -82
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +78 -93
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +19 -12
- 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 +86 -77
- package/dist/adapter/objects/webgl-resource.d.ts +3 -25
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +102 -146
- package/dist/adapter/resources/webgl-buffer.d.ts +3 -4
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +161 -119
- 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 +266 -168
- 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 +33 -39
- package/dist/adapter/resources/webgl-external-texture.js +93 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +8 -10
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +167 -137
- 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 +124 -90
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +15 -6
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +356 -221
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -3
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +43 -33
- package/dist/adapter/resources/webgl-shader.d.ts +12 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +114 -47
- 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 +6 -9
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +615 -695
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +2 -2
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +141 -143
- 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 +229 -157
- 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 +58 -36
- package/dist/adapter/webgl-device.d.ts +34 -40
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +418 -363
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +132 -101
- package/dist/classic/clear.d.ts +2 -2
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +73 -72
- 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 +175 -175
- 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 +39 -32
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +96 -81
- package/dist/context/context/context-data.d.ts +14 -0
- package/dist/context/context/context-data.d.ts.map +1 -0
- package/dist/context/context/context-data.js +33 -0
- package/dist/context/context/create-browser-context.d.ts +1 -6
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js +62 -49
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +55 -50
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -2
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +104 -77
- 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/{polyfill/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -2
- 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 +3 -3
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +94 -44
- package/dist/context/parameters/webgl-parameter-tables.d.ts +120 -99
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +469 -404
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +19 -14
- package/dist/context/state-tracker/track-context-state.d.ts +4 -4
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +188 -123
- package/dist/context/state-tracker/with-parameters.d.ts +2 -2
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +43 -26
- package/dist/dist.dev.js +3135 -4142
- package/dist/index.cjs +1766 -2717
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +25 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -1
- package/dist.min.js +9 -42
- package/package.json +11 -15
- package/src/adapter/converters/device-parameters.ts +105 -17
- package/src/adapter/converters/sampler-parameters.ts +12 -20
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +138 -185
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +101 -0
- package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +30 -22
- package/src/adapter/device-helpers/webgl-device-limits.ts +53 -0
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +21 -31
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +3 -4
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +3 -2
- package/src/adapter/objects/webgl-renderbuffer.ts +38 -16
- package/src/adapter/objects/webgl-resource.ts +7 -140
- package/src/adapter/resources/webgl-buffer.ts +10 -14
- package/src/adapter/resources/webgl-command-buffer.ts +24 -34
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +5 -5
- package/src/adapter/resources/webgl-framebuffer.ts +38 -34
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +24 -15
- package/src/adapter/resources/webgl-render-pipeline.ts +138 -70
- package/src/adapter/resources/webgl-sampler.ts +7 -10
- package/src/adapter/resources/webgl-shader.ts +65 -11
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +38 -105
- package/src/adapter/resources/webgl-transform-feedback.ts +16 -22
- package/src/adapter/resources/webgl-vertex-array.ts +20 -21
- package/src/adapter/webgl-canvas-context.ts +7 -11
- package/src/adapter/webgl-device.ts +106 -151
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +25 -20
- package/src/classic/copy-and-blit.ts +12 -6
- 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 +31 -20
- package/src/context/{context → helpers}/create-browser-context.ts +9 -33
- package/src/context/{polyfill/context-data.ts → helpers/webgl-context-data.ts} +3 -2
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +5 -4
- package/src/context/parameters/webgl-parameter-tables.ts +118 -90
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +29 -23
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +4 -18
- package/src/types.ts +2 -1
- package/dist/adapter/converters/device-parameters.js.map +0 -1
- package/dist/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/adapter/converters/shader-formats.js.map +0 -1
- package/dist/adapter/converters/texture-formats.js.map +0 -1
- package/dist/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/adapter/device-helpers/device-features.js.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.d.ts +0 -2
- package/dist/adapter/device-helpers/is-old-ie.d.ts.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.js +0 -9
- package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
- package/dist/adapter/helpers/set-uniform.js.map +0 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +0 -1
- package/dist/adapter/objects/constants-to-keys.js.map +0 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
- package/dist/adapter/objects/webgl-resource.js.map +0 -1
- package/dist/adapter/resources/webgl-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
- package/dist/adapter/resources/webgl-sampler.js.map +0 -1
- package/dist/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/adapter/resources/webgl-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-transform-feedback.js.map +0 -1
- package/dist/adapter/resources/webgl-vertex-array.js.map +0 -1
- package/dist/adapter/webgl-canvas-context.js.map +0 -1
- package/dist/adapter/webgl-device.js.map +0 -1
- package/dist/classic/accessor.js.map +0 -1
- package/dist/classic/clear.js.map +0 -1
- package/dist/classic/copy-and-blit.js.map +0 -1
- package/dist/classic/format-utils.js.map +0 -1
- package/dist/classic/typed-array-utils.js.map +0 -1
- package/dist/context/context/create-browser-context.js.map +0 -1
- package/dist/context/context/create-headless-context.d.ts +0 -9
- package/dist/context/context/create-headless-context.d.ts.map +0 -1
- package/dist/context/context/create-headless-context.js +0 -42
- package/dist/context/context/create-headless-context.js.map +0 -1
- package/dist/context/context/webgl-checks.d.ts +0 -13
- package/dist/context/context/webgl-checks.d.ts.map +0 -1
- package/dist/context/context/webgl-checks.js +0 -31
- package/dist/context/context/webgl-checks.js.map +0 -1
- package/dist/context/debug/spector.js.map +0 -1
- package/dist/context/debug/webgl-developer-tools.js.map +0 -1
- package/dist/context/parameters/unified-parameter-api.js.map +0 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
- package/dist/context/polyfill/context-data.d.ts.map +0 -1
- package/dist/context/polyfill/context-data.js +0 -12
- package/dist/context/polyfill/context-data.js.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.d.ts +0 -2
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +0 -85
- package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
- package/dist/context/polyfill/polyfill-context.d.ts +0 -5
- package/dist/context/polyfill/polyfill-context.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-context.js +0 -87
- package/dist/context/polyfill/polyfill-context.js.map +0 -1
- package/dist/context/polyfill/polyfill-table.d.ts +0 -48
- package/dist/context/polyfill/polyfill-table.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-table.js +0 -137
- package/dist/context/polyfill/polyfill-table.js.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts +0 -2
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -265
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
- package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
- package/dist/context/state-tracker/track-context-state.js.map +0 -1
- package/dist/context/state-tracker/with-parameters.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/adapter/device-helpers/device-features.ts +0 -161
- package/src/adapter/device-helpers/device-limits.ts +0 -155
- package/src/adapter/device-helpers/is-old-ie.ts +0 -14
- package/src/context/context/create-headless-context.ts +0 -51
- package/src/context/context/webgl-checks.ts +0 -51
- package/src/context/polyfill/get-parameter-polyfill.ts +0 -122
- package/src/context/polyfill/polyfill-context.ts +0 -104
- package/src/context/polyfill/polyfill-table.ts +0 -167
- package/src/context/polyfill/polyfill-vertex-array-object.ts +0 -365
|
@@ -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
|
|
|
@@ -12,7 +13,6 @@ type DebugContextProps = {
|
|
|
12
13
|
debug?: boolean;
|
|
13
14
|
throwOnError?: boolean;
|
|
14
15
|
break?: string[];
|
|
15
|
-
webgl2?: boolean;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
// const DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {
|
|
@@ -23,12 +23,12 @@ type DebugContextProps = {
|
|
|
23
23
|
// }
|
|
24
24
|
|
|
25
25
|
type ContextData = {
|
|
26
|
-
realContext?:
|
|
27
|
-
debugContext?:
|
|
28
|
-
}
|
|
26
|
+
realContext?: WebGL2RenderingContext;
|
|
27
|
+
debugContext?: WebGL2RenderingContext;
|
|
28
|
+
};
|
|
29
29
|
|
|
30
30
|
// Helper to get shared context data
|
|
31
|
-
function
|
|
31
|
+
function getWebGLContextData(gl: any): ContextData {
|
|
32
32
|
gl.luma = gl.luma || {};
|
|
33
33
|
return gl.luma;
|
|
34
34
|
}
|
|
@@ -39,7 +39,7 @@ declare global {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Loads Khronos WebGLDeveloperTools from CDN if not already installed
|
|
42
|
+
* Loads Khronos WebGLDeveloperTools from CDN if not already installed
|
|
43
43
|
* const WebGLDebugUtils = require('webgl-debug');
|
|
44
44
|
* @see https://github.com/KhronosGroup/WebGLDeveloperTools
|
|
45
45
|
* @see https://github.com/vorg/webgl-debug
|
|
@@ -55,7 +55,10 @@ export async function loadWebGLDeveloperTools(): Promise<void> {
|
|
|
55
55
|
|
|
56
56
|
// Returns (a potentially new) context with debug instrumentation turned off or on.
|
|
57
57
|
// Note that this actually returns a new context
|
|
58
|
-
export function makeDebugContext(
|
|
58
|
+
export function makeDebugContext(
|
|
59
|
+
gl: WebGL2RenderingContext,
|
|
60
|
+
props: DebugContextProps = {}
|
|
61
|
+
): WebGL2RenderingContext | null {
|
|
59
62
|
// Return null to ensure we don't try to create a context in this case (TODO what case is that?)
|
|
60
63
|
if (!gl) {
|
|
61
64
|
return null;
|
|
@@ -65,20 +68,23 @@ export function makeDebugContext(gl: WebGLRenderingContext, props: DebugContextP
|
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
// Returns the real context from either of the real/debug contexts
|
|
68
|
-
function getRealContext(gl:
|
|
69
|
-
const data =
|
|
71
|
+
function getRealContext(gl: WebGL2RenderingContext): WebGL2RenderingContext {
|
|
72
|
+
const data = getWebGLContextData(gl);
|
|
70
73
|
// If the context has a realContext member, it is a debug context so return the realContext
|
|
71
74
|
return data.realContext ? data.realContext : gl;
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
// Returns the debug context from either of the real/debug contexts
|
|
75
|
-
function getDebugContext(
|
|
78
|
+
function getDebugContext(
|
|
79
|
+
gl: WebGL2RenderingContext,
|
|
80
|
+
props: DebugContextProps
|
|
81
|
+
): WebGL2RenderingContext {
|
|
76
82
|
if (!globalThis.WebGLDebugUtils) {
|
|
77
83
|
log.warn('webgl-debug not loaded')();
|
|
78
84
|
return gl;
|
|
79
85
|
}
|
|
80
86
|
|
|
81
|
-
const data =
|
|
87
|
+
const data = getWebGLContextData(gl);
|
|
82
88
|
|
|
83
89
|
// If this already has a debug context, return it.
|
|
84
90
|
if (data.debugContext) {
|
|
@@ -99,7 +105,7 @@ function getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): W
|
|
|
99
105
|
glDebug[key] = GLEnum[key];
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
|
-
|
|
108
|
+
|
|
103
109
|
// Ensure we have a clean prototype on the instrumented object
|
|
104
110
|
// Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction
|
|
105
111
|
// by synchronizing the WebGL errors after each WebGL call.
|
|
@@ -120,7 +126,7 @@ function getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): W
|
|
|
120
126
|
|
|
121
127
|
function getFunctionString(functionName: string, functionArgs): string {
|
|
122
128
|
// Cover bug in webgl-debug-tools
|
|
123
|
-
functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);
|
|
129
|
+
functionArgs = Array.from(functionArgs).map(arg => (arg === undefined ? 'undefined' : arg));
|
|
124
130
|
let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);
|
|
125
131
|
args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;
|
|
126
132
|
return `gl.${functionName}(${args})`;
|
|
@@ -128,11 +134,10 @@ function getFunctionString(functionName: string, functionArgs): string {
|
|
|
128
134
|
|
|
129
135
|
function onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {
|
|
130
136
|
// Cover bug in webgl-debug-tools
|
|
131
|
-
args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);
|
|
137
|
+
args = Array.from(args).map(arg => (arg === undefined ? 'undefined' : arg));
|
|
132
138
|
const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
|
|
133
139
|
const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
134
|
-
const
|
|
135
|
-
const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;
|
|
140
|
+
const message = `${errorMessage} in gl.${functionName}(${functionArgs})`;
|
|
136
141
|
log.error(message)();
|
|
137
142
|
debugger; // eslint-disable-line
|
|
138
143
|
if (props.throwOnError) {
|
|
@@ -141,7 +146,11 @@ function onGLError(props: DebugContextProps, err, functionName: string, args: an
|
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
// Don't generate function string until it is needed
|
|
144
|
-
function onValidateGLFunc(
|
|
149
|
+
function onValidateGLFunc(
|
|
150
|
+
props: DebugContextProps,
|
|
151
|
+
functionName: string,
|
|
152
|
+
functionArgs: any[]
|
|
153
|
+
): void {
|
|
145
154
|
let functionString: string = '';
|
|
146
155
|
if (log.level >= 1) {
|
|
147
156
|
functionString = getFunctionString(functionName, functionArgs);
|
|
@@ -151,7 +160,9 @@ function onValidateGLFunc(props: DebugContextProps, functionName: string, functi
|
|
|
151
160
|
// If array of breakpoint strings supplied, check if any of them is contained in current GLEnum function
|
|
152
161
|
if (props.break && props.break.length > 0) {
|
|
153
162
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
154
|
-
const isBreakpoint = props.break.every(
|
|
163
|
+
const isBreakpoint = props.break.every(
|
|
164
|
+
(breakOn: string) => functionString.indexOf(breakOn) !== -1
|
|
165
|
+
);
|
|
155
166
|
if (isBreakpoint) {
|
|
156
167
|
debugger; // eslint-disable-line
|
|
157
168
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* ContextProps
|
|
6
|
-
* @param webgl2 Set to false to not create a WebGL2 context (force webgl1)
|
|
7
|
-
* @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)
|
|
8
7
|
* @param onContextLost
|
|
9
8
|
* @param onContextRestored
|
|
10
9
|
*
|
|
@@ -19,9 +18,6 @@
|
|
|
19
18
|
* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.
|
|
20
19
|
*/
|
|
21
20
|
type ContextProps = {
|
|
22
|
-
type?: 'webgl' | 'webgl1' | 'webgl2' | string;
|
|
23
|
-
webgl1?: boolean;
|
|
24
|
-
webgl2?: boolean;
|
|
25
21
|
onContextLost?: (event: Event) => void;
|
|
26
22
|
onContextRestored?: (event: Event) => void;
|
|
27
23
|
alpha?: boolean; // indicates if the canvas contains an alpha buffer.
|
|
@@ -35,8 +31,6 @@ type ContextProps = {
|
|
|
35
31
|
};
|
|
36
32
|
|
|
37
33
|
const DEFAULT_CONTEXT_PROPS: ContextProps = {
|
|
38
|
-
webgl2: true, // Attempt to create a WebGL2 context
|
|
39
|
-
webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)
|
|
40
34
|
powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons
|
|
41
35
|
// eslint-disable-next-line no-console
|
|
42
36
|
onContextLost: () => console.error('WebGL context lost'),
|
|
@@ -52,7 +46,7 @@ const DEFAULT_CONTEXT_PROPS: ContextProps = {
|
|
|
52
46
|
export function createBrowserContext(
|
|
53
47
|
canvas: HTMLCanvasElement | OffscreenCanvas,
|
|
54
48
|
props: ContextProps
|
|
55
|
-
):
|
|
49
|
+
): WebGL2RenderingContext {
|
|
56
50
|
props = {...DEFAULT_CONTEXT_PROPS, ...props};
|
|
57
51
|
|
|
58
52
|
// Try to extract any extra information about why context creation failed
|
|
@@ -61,31 +55,17 @@ export function createBrowserContext(
|
|
|
61
55
|
canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
|
|
62
56
|
|
|
63
57
|
// Create the desired context
|
|
64
|
-
let gl:
|
|
65
|
-
|
|
66
|
-
if (props.type === 'webgl2') {
|
|
67
|
-
props = {...props, webgl1: false};
|
|
68
|
-
}
|
|
69
|
-
if (props.type === 'webgl1') {
|
|
70
|
-
props = {...props, webgl2: false};
|
|
71
|
-
}
|
|
58
|
+
let gl: WebGL2RenderingContext | null = null;
|
|
72
59
|
|
|
73
60
|
// props.failIfMajorPerformanceCaveat = true;
|
|
74
61
|
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
gl = canvas.getContext('webgl2', props) as WebGL2RenderingContext;
|
|
78
|
-
}
|
|
79
|
-
if (!gl && props.webgl1) {
|
|
80
|
-
gl = canvas.getContext('webgl', props) as WebGLRenderingContext;
|
|
81
|
-
}
|
|
62
|
+
// We require webgl2 context
|
|
63
|
+
gl ||= canvas.getContext('webgl2', props) as WebGL2RenderingContext;
|
|
82
64
|
|
|
83
65
|
// Software GPU
|
|
84
66
|
|
|
85
67
|
// props.failIfMajorPerformanceCaveat = false;
|
|
86
|
-
|
|
87
|
-
// gl = canvas.getContext('webgl2', props);
|
|
88
|
-
// }
|
|
68
|
+
|
|
89
69
|
// if (!gl && props.webgl1) {
|
|
90
70
|
// gl = canvas.getContext('webgl', props);
|
|
91
71
|
// }
|
|
@@ -94,11 +74,7 @@ export function createBrowserContext(
|
|
|
94
74
|
canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);
|
|
95
75
|
|
|
96
76
|
if (!gl) {
|
|
97
|
-
throw new Error(
|
|
98
|
-
`Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${
|
|
99
|
-
errorMessage || 'Unknown error'
|
|
100
|
-
}`
|
|
101
|
-
);
|
|
77
|
+
throw new Error(`Failed to create WebGL context: ${errorMessage || 'Unknown error'}`);
|
|
102
78
|
}
|
|
103
79
|
|
|
104
80
|
if (props.onContextLost) {
|
|
@@ -120,7 +96,7 @@ export function createBrowserContext(
|
|
|
120
96
|
}
|
|
121
97
|
|
|
122
98
|
/* TODO - can we call this asynchronously to catch the error events?
|
|
123
|
-
export async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<
|
|
99
|
+
export async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGL2RenderingContext> {
|
|
124
100
|
props = {...DEFAULT_CONTEXT_PROPS, ...props};
|
|
125
101
|
|
|
126
102
|
// Try to extract any extra information about why context creation failed
|
|
@@ -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
|
/**
|
|
@@ -13,7 +14,7 @@ export interface WebGLContextData {
|
|
|
13
14
|
* Gets luma.gl specific state from a context
|
|
14
15
|
* @returns context state
|
|
15
16
|
*/
|
|
16
|
-
export function
|
|
17
|
+
export function getWebGLContextData(gl: WebGL2RenderingContext): WebGLContextData {
|
|
17
18
|
// @ts-expect-error
|
|
18
19
|
const luma = gl.luma as WebGLContextData | null;
|
|
19
20
|
if (!luma) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {GLExtensions} from '@luma.gl/constants';
|
|
6
|
+
|
|
7
|
+
/** Ensure extensions are only requested once */
|
|
8
|
+
export function getWebGLExtension(
|
|
9
|
+
gl: WebGL2RenderingContext,
|
|
10
|
+
name: string,
|
|
11
|
+
extensions: GLExtensions
|
|
12
|
+
): unknown {
|
|
13
|
+
if (extensions[name] === undefined) {
|
|
14
|
+
extensions[name] = gl.getExtension(name) || null;
|
|
15
|
+
}
|
|
16
|
+
return extensions[name];
|
|
17
|
+
}
|
|
@@ -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
|
// Provides a unified API for getting and setting any WebGL parameter
|
|
@@ -24,7 +25,7 @@ export type {GLParameters};
|
|
|
24
25
|
* This object is used to fill in any missing values for composite setter functions
|
|
25
26
|
*/
|
|
26
27
|
export function setGLParameters(
|
|
27
|
-
device: Device |
|
|
28
|
+
device: Device | WebGL2RenderingContext,
|
|
28
29
|
parameters: GLParameters
|
|
29
30
|
): void {
|
|
30
31
|
const webglDevice = WebGLDevice.attach(device);
|
|
@@ -92,7 +93,7 @@ export function setGLParameters(
|
|
|
92
93
|
* by external code needs to be synchronized for the first time
|
|
93
94
|
*/
|
|
94
95
|
export function getGLParameters(
|
|
95
|
-
device: Device |
|
|
96
|
+
device: Device | WebGL2RenderingContext,
|
|
96
97
|
parameters: keyof GLParameters | (keyof GLParameters)[] | GLParameters = GL_PARAMETER_DEFAULTS
|
|
97
98
|
): GLParameters {
|
|
98
99
|
const webglDevice = WebGLDevice.attach(device);
|
|
@@ -123,7 +124,7 @@ export function getGLParameters(
|
|
|
123
124
|
* NOT the canvas size dimensions, so they will have to be properly set after
|
|
124
125
|
* calling this function.
|
|
125
126
|
*/
|
|
126
|
-
export function resetGLParameters(device: Device |
|
|
127
|
+
export function resetGLParameters(device: Device | WebGL2RenderingContext): void {
|
|
127
128
|
setGLParameters(device, GL_PARAMETER_DEFAULTS);
|
|
128
129
|
}
|
|
129
130
|
|