@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-array-equal.d.ts","sourceRoot":"","sources":["../../../src/context/state-tracker/deep-array-equal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deep-array-equal.d.ts","sourceRoot":"","sources":["../../../src/context/state-tracker/deep-array-equal.ts"],"names":[],"mappings":"AAIA,gCAAgC;AAChC,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CAiBtD"}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/** deeply compare two arrays */
|
|
1
5
|
export function deepArrayEqual(x, y) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
const isArrayX = Array.isArray(x) || ArrayBuffer.isView(x);
|
|
6
|
-
const isArrayY = Array.isArray(y) || ArrayBuffer.isView(y);
|
|
7
|
-
if (isArrayX && isArrayY && x.length === y.length) {
|
|
8
|
-
for (let i = 0; i < x.length; ++i) {
|
|
9
|
-
if (x[i] !== y[i]) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
6
|
+
if (x === y) {
|
|
7
|
+
return true;
|
|
12
8
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const isArrayX = Array.isArray(x) || ArrayBuffer.isView(x);
|
|
10
|
+
const isArrayY = Array.isArray(y) || ArrayBuffer.isView(y);
|
|
11
|
+
// @ts-expect-error TODO fix
|
|
12
|
+
if (isArrayX && isArrayY && x.length === y.length) {
|
|
13
|
+
// @ts-expect-error TODO fix
|
|
14
|
+
for (let i = 0; i < x.length; ++i) {
|
|
15
|
+
if (x[i] !== y[i]) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
16
22
|
}
|
|
17
|
-
//# sourceMappingURL=deep-array-equal.js.map
|
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
* gl.state.push() and gl.state.pop() will be available for saving,
|
|
7
7
|
* temporarily modifying, and then restoring state.
|
|
8
8
|
*/
|
|
9
|
-
export declare function trackContextState(gl:
|
|
9
|
+
export declare function trackContextState(gl: WebGL2RenderingContext, options?: {
|
|
10
10
|
enable?: boolean;
|
|
11
11
|
copyState?: boolean;
|
|
12
12
|
log?: any;
|
|
13
|
-
}):
|
|
13
|
+
}): WebGL2RenderingContext;
|
|
14
14
|
/**
|
|
15
15
|
* Saves current WebGL context state onto an internal per-context stack
|
|
16
16
|
*/
|
|
17
|
-
export declare function pushContextState(gl:
|
|
17
|
+
export declare function pushContextState(gl: WebGL2RenderingContext): void;
|
|
18
18
|
/**
|
|
19
19
|
* Restores previously saved WebGL context state
|
|
20
20
|
*/
|
|
21
|
-
export declare function popContextState(gl:
|
|
21
|
+
export declare function popContextState(gl: WebGL2RenderingContext): void;
|
|
22
22
|
//# sourceMappingURL=track-context-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"track-context-state.d.ts","sourceRoot":"","sources":["../../../src/context/state-tracker/track-context-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"track-context-state.d.ts","sourceRoot":"","sources":["../../../src/context/state-tracker/track-context-state.ts"],"names":[],"mappings":"AAmGA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,sBAAsB,EAC1B,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;CACX,GACA,sBAAsB,CAgCxB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,sBAAsB,GAAG,IAAI,CAOjE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,sBAAsB,GAAG,IAAI,CAIhE"}
|
|
@@ -1,147 +1,212 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// Support for listening to context state changes and intercepting state queries
|
|
5
|
+
// NOTE: this system does not handle buffer bindings
|
|
1
6
|
import { assert } from '@luma.gl/core';
|
|
2
7
|
import { GL_PARAMETER_DEFAULTS, GL_HOOKED_SETTERS, NON_CACHE_PARAMETERS } from "../parameters/webgl-parameter-tables.js";
|
|
3
8
|
import { setGLParameters, getGLParameters } from "../parameters/unified-parameter-api.js";
|
|
4
9
|
import { deepArrayEqual } from "./deep-array-equal.js";
|
|
10
|
+
// HELPER CLASS - GLState
|
|
11
|
+
/* eslint-disable no-shadow */
|
|
5
12
|
class GLState {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
13
|
+
gl;
|
|
14
|
+
program = null;
|
|
15
|
+
stateStack = [];
|
|
16
|
+
enable = true;
|
|
17
|
+
cache;
|
|
18
|
+
log;
|
|
19
|
+
constructor(gl, { copyState = false, // Copy cache from params (slow) or initialize from WebGL defaults (fast)
|
|
20
|
+
log = () => { } // Logging function, called when gl parameter change calls are actually issued
|
|
21
|
+
} = {}) {
|
|
22
|
+
this.gl = gl;
|
|
23
|
+
this.cache = copyState ? getGLParameters(gl) : Object.assign({}, GL_PARAMETER_DEFAULTS);
|
|
24
|
+
this.log = log;
|
|
25
|
+
this._updateCache = this._updateCache.bind(this);
|
|
26
|
+
Object.seal(this);
|
|
27
|
+
}
|
|
28
|
+
push(values = {}) {
|
|
29
|
+
this.stateStack.push({});
|
|
30
|
+
}
|
|
31
|
+
pop() {
|
|
32
|
+
assert(this.stateStack.length > 0);
|
|
33
|
+
// Use the saved values in the state stack to restore parameters
|
|
34
|
+
const oldValues = this.stateStack[this.stateStack.length - 1];
|
|
35
|
+
setGLParameters(this.gl, oldValues);
|
|
36
|
+
// Don't pop until we have reset parameters (to make sure other "stack frames" are not affected)
|
|
37
|
+
this.stateStack.pop();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
// interceptor for context set functions - update our cache and our stack
|
|
41
|
+
// values (Object) - the key values for this setter
|
|
42
|
+
* @param values
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
_updateCache(values) {
|
|
46
|
+
let valueChanged = false;
|
|
47
|
+
let oldValue; // = undefined
|
|
48
|
+
const oldValues = this.stateStack.length > 0 ? this.stateStack[this.stateStack.length - 1] : null;
|
|
49
|
+
for (const key in values) {
|
|
50
|
+
assert(key !== undefined);
|
|
51
|
+
const value = values[key];
|
|
52
|
+
const cached = this.cache[key];
|
|
53
|
+
// Check that value hasn't already been shadowed
|
|
54
|
+
if (!deepArrayEqual(value, cached)) {
|
|
55
|
+
valueChanged = true;
|
|
56
|
+
oldValue = cached;
|
|
57
|
+
// First, save current value being shadowed
|
|
58
|
+
// If a state stack frame is active, save the current parameter values for pop
|
|
59
|
+
// but first check that value hasn't already been shadowed and saved
|
|
60
|
+
if (oldValues && !(key in oldValues)) {
|
|
61
|
+
oldValues[key] = cached;
|
|
62
|
+
}
|
|
63
|
+
// Save current value being shadowed
|
|
64
|
+
this.cache[key] = value;
|
|
65
|
+
}
|
|
46
66
|
}
|
|
47
|
-
|
|
48
|
-
}
|
|
67
|
+
return { valueChanged, oldValue };
|
|
49
68
|
}
|
|
50
|
-
return {
|
|
51
|
-
valueChanged,
|
|
52
|
-
oldValue
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
69
|
}
|
|
56
70
|
function getContextState(gl) {
|
|
57
|
-
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
return gl.state;
|
|
58
73
|
}
|
|
74
|
+
// PUBLIC API
|
|
75
|
+
/**
|
|
76
|
+
* Initialize WebGL state caching on a context
|
|
77
|
+
* can be called multiple times to enable/disable
|
|
78
|
+
*
|
|
79
|
+
* @note After calling this function, context state will be cached
|
|
80
|
+
* gl.state.push() and gl.state.pop() will be available for saving,
|
|
81
|
+
* temporarily modifying, and then restoring state.
|
|
82
|
+
*/
|
|
59
83
|
export function trackContextState(gl, options) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
const { enable = true, copyState } = options;
|
|
85
|
+
assert(copyState !== undefined);
|
|
86
|
+
// @ts-expect-error
|
|
87
|
+
if (!gl.state) {
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
// const {polyfillContext} = global_;
|
|
90
|
+
// if (polyfillContext) {
|
|
91
|
+
// polyfillContext(gl);
|
|
92
|
+
// }
|
|
93
|
+
// Create a state cache
|
|
94
|
+
// @ts-expect-error
|
|
95
|
+
gl.state = new GLState(gl, { copyState });
|
|
96
|
+
installProgramSpy(gl);
|
|
97
|
+
// intercept all setter functions in the table
|
|
98
|
+
for (const key in GL_HOOKED_SETTERS) {
|
|
99
|
+
const setter = GL_HOOKED_SETTERS[key];
|
|
100
|
+
installSetterSpy(gl, key, setter);
|
|
101
|
+
}
|
|
102
|
+
// intercept all getter functions in the table
|
|
103
|
+
installGetterOverride(gl, 'getParameter');
|
|
104
|
+
installGetterOverride(gl, 'isEnabled');
|
|
73
105
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const glState = getContextState(gl);
|
|
78
|
-
glState.enable = enable;
|
|
79
|
-
return gl;
|
|
106
|
+
const glState = getContextState(gl);
|
|
107
|
+
glState.enable = enable;
|
|
108
|
+
return gl;
|
|
80
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Saves current WebGL context state onto an internal per-context stack
|
|
112
|
+
*/
|
|
81
113
|
export function pushContextState(gl) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
glState
|
|
88
|
-
}
|
|
89
|
-
glState.push();
|
|
114
|
+
let glState = getContextState(gl);
|
|
115
|
+
if (!glState) {
|
|
116
|
+
trackContextState(gl, { copyState: false });
|
|
117
|
+
glState = getContextState(gl);
|
|
118
|
+
}
|
|
119
|
+
glState.push();
|
|
90
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Restores previously saved WebGL context state
|
|
123
|
+
*/
|
|
91
124
|
export function popContextState(gl) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
125
|
+
const glState = getContextState(gl);
|
|
126
|
+
assert(glState);
|
|
127
|
+
glState.pop();
|
|
95
128
|
}
|
|
129
|
+
// HELPER FUNCTIONS - INSTALL GET/SET INTERCEPTORS (SPYS) ON THE CONTEXT
|
|
130
|
+
/**
|
|
131
|
+
// Overrides a WebGL2RenderingContext state "getter" function
|
|
132
|
+
// to return values directly from cache
|
|
133
|
+
* @param gl
|
|
134
|
+
* @param functionName
|
|
135
|
+
*/
|
|
96
136
|
function installGetterOverride(gl, functionName) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
137
|
+
// Get the original function from the WebGL2RenderingContext
|
|
138
|
+
const originalGetterFunc = gl[functionName].bind(gl);
|
|
139
|
+
// Wrap it with a spy so that we can update our state cache when it gets called
|
|
140
|
+
gl[functionName] = function get(pname) {
|
|
141
|
+
if (pname === undefined || NON_CACHE_PARAMETERS.has(pname)) {
|
|
142
|
+
// Invalid or blacklisted parameter, do not cache
|
|
143
|
+
return originalGetterFunc(pname);
|
|
144
|
+
}
|
|
145
|
+
const glState = getContextState(gl);
|
|
146
|
+
if (!(pname in glState.cache)) {
|
|
147
|
+
// WebGL limits are not prepopulated in the cache, call the original getter when first queried.
|
|
148
|
+
glState.cache[pname] = originalGetterFunc(pname);
|
|
149
|
+
}
|
|
150
|
+
// Optionally call the original function to do a "hard" query from the WebGL2RenderingContext
|
|
151
|
+
return glState.enable
|
|
152
|
+
? // Call the getter the params so that it can e.g. serve from a cache
|
|
153
|
+
glState.cache[pname]
|
|
154
|
+
: // Optionally call the original function to do a "hard" query from the WebGL2RenderingContext
|
|
155
|
+
originalGetterFunc(pname);
|
|
156
|
+
};
|
|
157
|
+
// Set the name of this anonymous function to help in debugging and profiling
|
|
158
|
+
Object.defineProperty(gl[functionName], 'name', {
|
|
159
|
+
value: `${functionName}-from-cache`,
|
|
160
|
+
configurable: false
|
|
161
|
+
});
|
|
112
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
// Overrides a WebGL2RenderingContext state "setter" function
|
|
165
|
+
// to call a setter spy before the actual setter. Allows us to keep a cache
|
|
166
|
+
// updated with a copy of the WebGL context state.
|
|
167
|
+
* @param gl
|
|
168
|
+
* @param functionName
|
|
169
|
+
* @param setter
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
113
172
|
function installSetterSpy(gl, functionName, setter) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const glState = getContextState(gl);
|
|
120
|
-
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
121
|
-
params[_key] = arguments[_key];
|
|
122
|
-
}
|
|
123
|
-
const {
|
|
124
|
-
valueChanged,
|
|
125
|
-
oldValue
|
|
126
|
-
} = setter(glState._updateCache, ...params);
|
|
127
|
-
if (valueChanged) {
|
|
128
|
-
originalSetterFunc(...params);
|
|
173
|
+
// Get the original function from the WebGL2RenderingContext
|
|
174
|
+
if (!gl[functionName]) {
|
|
175
|
+
// TODO - remove?
|
|
176
|
+
// This could happen if we try to intercept WebGL2 method on a WebGL1 context
|
|
177
|
+
return;
|
|
129
178
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
179
|
+
const originalSetterFunc = gl[functionName].bind(gl);
|
|
180
|
+
// Wrap it with a spy so that we can update our state cache when it gets called
|
|
181
|
+
gl[functionName] = function set(...params) {
|
|
182
|
+
// Update the value
|
|
183
|
+
// Call the setter with the state cache and the params so that it can store the parameters
|
|
184
|
+
const glState = getContextState(gl);
|
|
185
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
186
|
+
const { valueChanged, oldValue } = setter(glState._updateCache, ...params);
|
|
187
|
+
// Call the original WebGL2RenderingContext func to make sure the context actually gets updated
|
|
188
|
+
if (valueChanged) {
|
|
189
|
+
originalSetterFunc(...params);
|
|
190
|
+
}
|
|
191
|
+
// Note: if the original function fails to set the value, our state cache will be bad
|
|
192
|
+
// No solution for this at the moment, but assuming that this is unlikely to be a real problem
|
|
193
|
+
// We could call the setter after the originalSetterFunc. Concern is that this would
|
|
194
|
+
// cause different behavior in debug mode, where originalSetterFunc can throw exceptions
|
|
195
|
+
return oldValue;
|
|
196
|
+
};
|
|
197
|
+
// Set the name of this anonymous function to help in debugging and profiling
|
|
198
|
+
Object.defineProperty(gl[functionName], 'name', {
|
|
199
|
+
value: `${functionName}-to-cache`,
|
|
200
|
+
configurable: false
|
|
201
|
+
});
|
|
136
202
|
}
|
|
137
203
|
function installProgramSpy(gl) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
204
|
+
const originalUseProgram = gl.useProgram.bind(gl);
|
|
205
|
+
gl.useProgram = function useProgramLuma(handle) {
|
|
206
|
+
const glState = getContextState(gl);
|
|
207
|
+
if (glState.program !== handle) {
|
|
208
|
+
originalUseProgram(handle);
|
|
209
|
+
glState.program = handle;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
146
212
|
}
|
|
147
|
-
//# sourceMappingURL=track-context-state.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Device } from '@luma.gl/core';
|
|
2
|
-
import { GLParameters } from
|
|
2
|
+
import { GLParameters } from "../parameters/unified-parameter-api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Execute a function with a set of temporary WebGL parameter overrides
|
|
5
5
|
* - Saves current "global" WebGL context settings
|
|
@@ -8,7 +8,7 @@ import { GLParameters } from '../parameters/unified-parameter-api';
|
|
|
8
8
|
* - Restores parameters
|
|
9
9
|
* - Returns the return value of the supplied function
|
|
10
10
|
*/
|
|
11
|
-
export declare function withGLParameters(device: Device |
|
|
11
|
+
export declare function withGLParameters(device: Device | WebGL2RenderingContext, parameters: GLParameters & {
|
|
12
12
|
nocatch?: boolean;
|
|
13
13
|
}, func: any): any;
|
|
14
14
|
//# sourceMappingURL=with-parameters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-parameters.d.ts","sourceRoot":"","sources":["../../../src/context/state-tracker/with-parameters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"with-parameters.d.ts","sourceRoot":"","sources":["../../../src/context/state-tracker/with-parameters.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAC,YAAY,EAAkB,+CAA4C;AAGlF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,GAAG,sBAAsB,EACvC,UAAU,EAAE,YAAY,GAAG;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAC,EAC9C,IAAI,EAAE,GAAG,GACR,GAAG,CA+BL"}
|
|
@@ -1,34 +1,51 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { WebGLDevice } from "../../adapter/webgl-device.js";
|
|
2
5
|
import { setGLParameters } from "../parameters/unified-parameter-api.js";
|
|
3
6
|
import { pushContextState, popContextState } from "./track-context-state.js";
|
|
7
|
+
/**
|
|
8
|
+
* Execute a function with a set of temporary WebGL parameter overrides
|
|
9
|
+
* - Saves current "global" WebGL context settings
|
|
10
|
+
* - Sets the supplies WebGL context parameters,
|
|
11
|
+
* - Executes supplied function
|
|
12
|
+
* - Restores parameters
|
|
13
|
+
* - Returns the return value of the supplied function
|
|
14
|
+
*/
|
|
4
15
|
export function withGLParameters(device, parameters, func) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
nocatch = true
|
|
12
|
-
} = parameters;
|
|
13
|
-
pushContextState(gl);
|
|
14
|
-
setGLParameters(gl, parameters);
|
|
15
|
-
let value;
|
|
16
|
-
if (nocatch) {
|
|
17
|
-
value = func(gl);
|
|
18
|
-
popContextState(gl);
|
|
19
|
-
} else {
|
|
20
|
-
try {
|
|
21
|
-
value = func(gl);
|
|
22
|
-
} finally {
|
|
23
|
-
popContextState(gl);
|
|
16
|
+
const webglDevice = WebGLDevice.attach(device);
|
|
17
|
+
const gl = webglDevice.gl;
|
|
18
|
+
if (isObjectEmpty(parameters)) {
|
|
19
|
+
// Avoid setting state if no parameters provided. Just call and return
|
|
20
|
+
return func(device);
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const { nocatch = true } = parameters;
|
|
23
|
+
pushContextState(gl);
|
|
24
|
+
setGLParameters(gl, parameters);
|
|
25
|
+
// Setup is done, call the function
|
|
26
|
+
let value;
|
|
27
|
+
if (nocatch) {
|
|
28
|
+
// Avoid try catch to minimize stack size impact for safe execution paths
|
|
29
|
+
value = func(gl);
|
|
30
|
+
popContextState(gl);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// Wrap in a try-catch to ensure that parameters are restored on exceptions
|
|
34
|
+
try {
|
|
35
|
+
value = func(gl);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
popContextState(gl);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
27
42
|
}
|
|
43
|
+
// Helpers
|
|
44
|
+
// Returns true if given object is empty, false otherwise.
|
|
28
45
|
function isObjectEmpty(object) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
// @ts-ignore - dummy key variable
|
|
47
|
+
for (const key in object) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
33
51
|
}
|
|
34
|
-
//# sourceMappingURL=with-parameters.js.map
|