@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,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,22 +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 {
|
|
20
|
-
import {polyfillContext} from '../context/polyfill/polyfill-context';
|
|
18
|
+
import type {GLExtensions} from '@luma.gl/constants';
|
|
21
19
|
import {
|
|
22
20
|
popContextState,
|
|
23
21
|
pushContextState,
|
|
24
22
|
trackContextState
|
|
25
23
|
} from '../context/state-tracker/track-context-state';
|
|
26
|
-
import {createBrowserContext} from '../context/
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} from '../context/context/create-headless-context';
|
|
31
|
-
|
|
32
|
-
import {getDeviceInfo} from './device-helpers/get-device-info';
|
|
33
|
-
import {getDeviceFeatures} from './device-helpers/device-features';
|
|
34
|
-
import {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';
|
|
24
|
+
import {createBrowserContext} from '../context/helpers/create-browser-context';
|
|
25
|
+
import {getDeviceInfo} from './device-helpers/webgl-device-info';
|
|
26
|
+
import {WebGLDeviceFeatures} from './device-helpers/webgl-device-features';
|
|
27
|
+
import {WebGLDeviceLimits} from './device-helpers/webgl-device-limits';
|
|
35
28
|
import {WebGLCanvasContext} from './webgl-canvas-context';
|
|
36
29
|
import {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';
|
|
37
30
|
import {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';
|
|
@@ -61,7 +54,8 @@ import type {
|
|
|
61
54
|
ComputePassProps,
|
|
62
55
|
// CommandEncoder,
|
|
63
56
|
CommandEncoderProps,
|
|
64
|
-
TransformFeedbackProps
|
|
57
|
+
TransformFeedbackProps,
|
|
58
|
+
QuerySetProps
|
|
65
59
|
} from '@luma.gl/core';
|
|
66
60
|
|
|
67
61
|
import {WEBGLBuffer} from './resources/webgl-buffer';
|
|
@@ -74,11 +68,13 @@ import {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';
|
|
|
74
68
|
import {WEBGLCommandEncoder} from './resources/webgl-command-encoder';
|
|
75
69
|
import {WEBGLVertexArray} from './resources/webgl-vertex-array';
|
|
76
70
|
import {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';
|
|
71
|
+
import {WEBGLQuerySet} from './resources/webgl-query-set';
|
|
77
72
|
|
|
78
73
|
import {readPixelsToArray, readPixelsToBuffer} from '../classic/copy-and-blit';
|
|
79
74
|
import {setGLParameters, getGLParameters} from '../context/parameters/unified-parameter-api';
|
|
80
75
|
import {withGLParameters} from '../context/state-tracker/with-parameters';
|
|
81
76
|
import {clear} from '../classic/clear';
|
|
77
|
+
import {getWebGLExtension} from '../context/helpers/webgl-extensions';
|
|
82
78
|
|
|
83
79
|
const LOG_LEVEL = 1;
|
|
84
80
|
|
|
@@ -91,29 +87,20 @@ export class WebGLDevice extends Device {
|
|
|
91
87
|
static type: string = 'webgl';
|
|
92
88
|
|
|
93
89
|
static isSupported(): boolean {
|
|
94
|
-
return typeof
|
|
90
|
+
return typeof WebGL2RenderingContext !== 'undefined';
|
|
95
91
|
}
|
|
96
92
|
|
|
93
|
+
/** The underlying WebGL context */
|
|
94
|
+
readonly handle: WebGL2RenderingContext;
|
|
95
|
+
features: WebGLDeviceFeatures;
|
|
96
|
+
limits: WebGLDeviceLimits;
|
|
97
|
+
|
|
97
98
|
readonly info: DeviceInfo;
|
|
98
99
|
readonly canvasContext: WebGLCanvasContext;
|
|
99
100
|
|
|
100
|
-
readonly handle: WebGLRenderingContext;
|
|
101
|
-
|
|
102
|
-
get features(): Set<DeviceFeature> {
|
|
103
|
-
this._features = this._features || getDeviceFeatures(this.gl);
|
|
104
|
-
return this._features;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
get limits(): DeviceLimits {
|
|
108
|
-
this._limits = this._limits || getDeviceLimits(this.gl);
|
|
109
|
-
return this._limits;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
101
|
readonly lost: Promise<{reason: 'destroyed'; message: string}>;
|
|
113
102
|
|
|
114
103
|
private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;
|
|
115
|
-
private _features?: Set<DeviceFeature>;
|
|
116
|
-
private _limits?: DeviceLimits;
|
|
117
104
|
|
|
118
105
|
//
|
|
119
106
|
// Static methods, expected to be present by `luma.createDevice()`
|
|
@@ -125,7 +112,7 @@ export class WebGLDevice extends Device {
|
|
|
125
112
|
* @param gl
|
|
126
113
|
* @returns
|
|
127
114
|
*/
|
|
128
|
-
static attach(gl: Device |
|
|
115
|
+
static attach(gl: Device | WebGL2RenderingContext): WebGLDevice {
|
|
129
116
|
if (gl instanceof WebGLDevice) {
|
|
130
117
|
return gl;
|
|
131
118
|
}
|
|
@@ -135,35 +122,39 @@ export class WebGLDevice extends Device {
|
|
|
135
122
|
return gl.device as WebGLDevice;
|
|
136
123
|
}
|
|
137
124
|
if (!isWebGL(gl)) {
|
|
138
|
-
throw new Error('Invalid
|
|
125
|
+
throw new Error('Invalid WebGL2RenderingContext');
|
|
139
126
|
}
|
|
140
|
-
return new WebGLDevice({gl: gl as
|
|
127
|
+
return new WebGLDevice({gl: gl as WebGL2RenderingContext});
|
|
141
128
|
}
|
|
142
129
|
|
|
143
130
|
static async create(props: DeviceProps = {}): Promise<WebGLDevice> {
|
|
144
131
|
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
|
|
145
132
|
|
|
146
|
-
|
|
147
|
-
// to avoid setting page onload callback unless necessary
|
|
148
|
-
if (typeof props.canvas === 'string') {
|
|
149
|
-
await CanvasContext.pageLoaded;
|
|
150
|
-
}
|
|
133
|
+
const promises: Promise<unknown>[] = [];
|
|
151
134
|
|
|
152
135
|
// Load webgl and spector debug scripts from CDN if requested
|
|
153
|
-
if (
|
|
154
|
-
|
|
136
|
+
if (props.debug) {
|
|
137
|
+
promises.push(loadWebGLDeveloperTools());
|
|
155
138
|
}
|
|
156
139
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (log.get('spector') || spector) {
|
|
160
|
-
await loadSpectorJS();
|
|
140
|
+
if (props.spector) {
|
|
141
|
+
promises.push(loadSpectorJS());
|
|
161
142
|
}
|
|
162
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
|
+
|
|
163
154
|
log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
|
|
164
155
|
|
|
165
156
|
// @ts-expect-error
|
|
166
|
-
if (props.gl
|
|
157
|
+
if (props.gl?.device) {
|
|
167
158
|
return WebGLDevice.attach(props.gl);
|
|
168
159
|
}
|
|
169
160
|
|
|
@@ -196,48 +187,39 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
196
187
|
}
|
|
197
188
|
|
|
198
189
|
// Create and instrument context
|
|
199
|
-
const canvas = props.canvas || props.
|
|
190
|
+
const canvas = props.gl?.canvas || props.canvas;
|
|
200
191
|
this.canvasContext = new WebGLCanvasContext(this, {...props, canvas});
|
|
201
192
|
|
|
202
193
|
this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {
|
|
203
194
|
this._resolveContextLost = resolve;
|
|
204
195
|
});
|
|
205
196
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
(isBrowser()
|
|
216
|
-
? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost})
|
|
217
|
-
: null);
|
|
218
|
-
gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);
|
|
197
|
+
let gl: WebGL2RenderingContext | null = props.gl || null;
|
|
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
|
+
});
|
|
219
206
|
|
|
220
207
|
if (!gl) {
|
|
221
208
|
throw new Error('WebGL context creation failed');
|
|
222
209
|
}
|
|
223
210
|
|
|
224
211
|
this.handle = gl;
|
|
225
|
-
this.gl =
|
|
226
|
-
this.gl2 = this.gl as WebGL2RenderingContext;
|
|
227
|
-
this.isWebGL2 = isWebGL2(this.gl);
|
|
228
|
-
this.isWebGL1 = !this.isWebGL2;
|
|
229
|
-
this.canvasContext.resize();
|
|
212
|
+
this.gl = gl;
|
|
230
213
|
|
|
231
|
-
//
|
|
232
|
-
this.
|
|
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)
|
|
233
216
|
|
|
234
|
-
//
|
|
235
|
-
this.
|
|
236
|
-
|
|
237
|
-
this.
|
|
217
|
+
// luma Device fields
|
|
218
|
+
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
219
|
+
this.features = new WebGLDeviceFeatures(this.gl, this._extensions);
|
|
220
|
+
this.limits = new WebGLDeviceLimits(this.gl);
|
|
238
221
|
|
|
239
|
-
|
|
240
|
-
polyfillContext(this.gl);
|
|
222
|
+
this.canvasContext.resize();
|
|
241
223
|
|
|
242
224
|
// Install context state tracking
|
|
243
225
|
// @ts-expect-error - hidden parameters
|
|
@@ -249,31 +231,23 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
249
231
|
});
|
|
250
232
|
|
|
251
233
|
// DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1
|
|
252
|
-
if (
|
|
253
|
-
this.gl = makeDebugContext(this.gl, {...props,
|
|
254
|
-
this.gl2 = this.gl as WebGL2RenderingContext;
|
|
234
|
+
if (props.debug) {
|
|
235
|
+
this.gl = makeDebugContext(this.gl, {...props, throwOnError: true});
|
|
255
236
|
this.debug = true;
|
|
256
237
|
log.level = Math.max(log.level, 1);
|
|
257
238
|
log.warn('WebGL debug mode activated. Performance reduced.')();
|
|
258
239
|
}
|
|
259
240
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);
|
|
263
|
-
this.spector = initializeSpectorJS({...this.props, canvas});
|
|
241
|
+
if (props.spector) {
|
|
242
|
+
this.spectorJS = initializeSpectorJS({...this.props, canvas: this.handle.canvas});
|
|
264
243
|
}
|
|
265
244
|
}
|
|
266
245
|
|
|
267
246
|
/**
|
|
268
247
|
* Destroys the context
|
|
269
|
-
* @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
|
|
270
249
|
*/
|
|
271
|
-
destroy(): void {
|
|
272
|
-
const ext = this.gl.getExtension('STACKGL_destroy_context');
|
|
273
|
-
if (ext) {
|
|
274
|
-
ext.destroy();
|
|
275
|
-
}
|
|
276
|
-
}
|
|
250
|
+
destroy(): void {}
|
|
277
251
|
|
|
278
252
|
get isLost(): boolean {
|
|
279
253
|
return this.gl.isContextLost();
|
|
@@ -284,25 +258,15 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
284
258
|
}
|
|
285
259
|
|
|
286
260
|
isTextureFormatSupported(format: TextureFormat): boolean {
|
|
287
|
-
return isTextureFormatSupported(this.gl, format);
|
|
261
|
+
return isTextureFormatSupported(this.gl, format, this._extensions);
|
|
288
262
|
}
|
|
289
263
|
|
|
290
264
|
isTextureFormatFilterable(format: TextureFormat): boolean {
|
|
291
|
-
return isTextureFormatFilterable(this.gl, format);
|
|
265
|
+
return isTextureFormatFilterable(this.gl, format, this._extensions);
|
|
292
266
|
}
|
|
293
267
|
|
|
294
268
|
isTextureFormatRenderable(format: TextureFormat): boolean {
|
|
295
|
-
return isTextureFormatRenderable(this.gl, format);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// WEBGL SPECIFIC METHODS
|
|
299
|
-
|
|
300
|
-
/** Returns a WebGL2RenderingContext or throws an error */
|
|
301
|
-
assertWebGL2(): WebGL2RenderingContext {
|
|
302
|
-
if (!this.gl2) {
|
|
303
|
-
throw new Error('Requires WebGL2');
|
|
304
|
-
}
|
|
305
|
-
return this.gl2;
|
|
269
|
+
return isTextureFormatRenderable(this.gl, format, this._extensions);
|
|
306
270
|
}
|
|
307
271
|
|
|
308
272
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
@@ -336,12 +300,20 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
336
300
|
return new WEBGLFramebuffer(this, props);
|
|
337
301
|
}
|
|
338
302
|
|
|
339
|
-
|
|
340
|
-
return new
|
|
303
|
+
createVertexArray(props: VertexArrayProps): VertexArray {
|
|
304
|
+
return new WEBGLVertexArray(this, props);
|
|
341
305
|
}
|
|
342
306
|
|
|
343
|
-
|
|
344
|
-
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);
|
|
345
317
|
}
|
|
346
318
|
|
|
347
319
|
beginRenderPass(props: RenderPassProps): WEBGLRenderPass {
|
|
@@ -356,10 +328,6 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
356
328
|
throw new Error('ComputePass not supported in WebGL');
|
|
357
329
|
}
|
|
358
330
|
|
|
359
|
-
createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback {
|
|
360
|
-
return new WEBGLTransformFeedback(this, props);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
331
|
private renderPass: WEBGLRenderPass | null = null;
|
|
364
332
|
|
|
365
333
|
getDefaultRenderPass(): WEBGLRenderPass {
|
|
@@ -377,7 +345,7 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
377
345
|
|
|
378
346
|
/**
|
|
379
347
|
* Offscreen Canvas Support: Commit the frame
|
|
380
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/
|
|
348
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/commit
|
|
381
349
|
* Chrome's offscreen canvas does not require gl.commit
|
|
382
350
|
*/
|
|
383
351
|
submit(): void {
|
|
@@ -388,7 +356,7 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
388
356
|
|
|
389
357
|
//
|
|
390
358
|
// TEMPORARY HACKS - will be removed in v9.1
|
|
391
|
-
//
|
|
359
|
+
//
|
|
392
360
|
|
|
393
361
|
/** @deprecated - should use command encoder */
|
|
394
362
|
override readPixelsToArrayWebGL(
|
|
@@ -438,42 +406,32 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
438
406
|
withGLParameters(this, parameters, func);
|
|
439
407
|
}
|
|
440
408
|
|
|
441
|
-
override clearWebGL(options?: {
|
|
409
|
+
override clearWebGL(options?: {
|
|
410
|
+
framebuffer?: Framebuffer;
|
|
411
|
+
color?: any;
|
|
412
|
+
depth?: any;
|
|
413
|
+
stencil?: any;
|
|
414
|
+
}): void {
|
|
442
415
|
clear(this, options);
|
|
443
416
|
}
|
|
444
|
-
|
|
417
|
+
|
|
445
418
|
//
|
|
446
419
|
// WebGL-only API (not part of `Device` API)
|
|
447
420
|
//
|
|
448
421
|
|
|
449
|
-
/**
|
|
450
|
-
readonly gl:
|
|
451
|
-
/** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */
|
|
452
|
-
readonly gl2: WebGL2RenderingContext | null = null;
|
|
422
|
+
/** WebGL2 context. */
|
|
423
|
+
readonly gl: WebGL2RenderingContext;
|
|
453
424
|
readonly debug: boolean = false;
|
|
454
425
|
|
|
455
|
-
/** `true` if this is a WebGL1 context. @note `false` if WebGL2 */
|
|
456
|
-
readonly isWebGL1: boolean;
|
|
457
|
-
/** `true` if this is a WebGL2 context. @note `false` if WebGL1 */
|
|
458
|
-
readonly isWebGL2: boolean;
|
|
459
|
-
|
|
460
426
|
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
461
427
|
readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};
|
|
462
428
|
|
|
463
429
|
/** State used by luma.gl classes - TODO - not used? */
|
|
464
|
-
readonly _extensions:
|
|
430
|
+
readonly _extensions: GLExtensions = {};
|
|
465
431
|
_polyfilled: boolean = false;
|
|
466
432
|
|
|
467
433
|
/** Instance of Spector.js (if initialized) */
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
private _webglLimits?: WebGLLimits;
|
|
471
|
-
|
|
472
|
-
/** Return WebGL specific limits */
|
|
473
|
-
get webglLimits(): WebGLLimits {
|
|
474
|
-
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
475
|
-
return this._webglLimits;
|
|
476
|
-
}
|
|
434
|
+
spectorJS: unknown;
|
|
477
435
|
|
|
478
436
|
/**
|
|
479
437
|
* Triggers device (or WebGL context) loss.
|
|
@@ -481,7 +439,8 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
481
439
|
*/
|
|
482
440
|
override loseDevice(): boolean {
|
|
483
441
|
let deviceLossTriggered = false;
|
|
484
|
-
const
|
|
442
|
+
const extensions = this.getExtension('WEBGL_lose_context');
|
|
443
|
+
const ext = extensions.WEBGL_lose_context;
|
|
485
444
|
if (ext) {
|
|
486
445
|
deviceLossTriggered = true;
|
|
487
446
|
ext.loseContext();
|
|
@@ -519,7 +478,7 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
519
478
|
* Be aware that there are some duplicates especially for constants that are 0,
|
|
520
479
|
* so this isn't guaranteed to return the right key in all cases.
|
|
521
480
|
*/
|
|
522
|
-
getGLKey(value: unknown, gl?:
|
|
481
|
+
getGLKey(value: unknown, gl?: WebGL2RenderingContext): string {
|
|
523
482
|
// @ts-ignore expect-error depends on settings
|
|
524
483
|
gl = gl || this.gl2 || this.gl;
|
|
525
484
|
const number = Number(value);
|
|
@@ -542,11 +501,15 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
542
501
|
* so they need to be updated before every render
|
|
543
502
|
* @todo - remember/cache values to avoid setting them unnecessarily?
|
|
544
503
|
*/
|
|
545
|
-
|
|
546
|
-
|
|
504
|
+
setConstantAttributeWebGL(location: number, constant: TypedArray): void {
|
|
505
|
+
const maxVertexAttributes = this.limits.maxVertexAttributes;
|
|
506
|
+
this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
|
|
547
507
|
const currentConstant = this._constants[location];
|
|
548
508
|
if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {
|
|
549
|
-
log.info(
|
|
509
|
+
log.info(
|
|
510
|
+
1,
|
|
511
|
+
`setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`
|
|
512
|
+
)();
|
|
550
513
|
}
|
|
551
514
|
this._constants[location] = constant;
|
|
552
515
|
|
|
@@ -564,27 +527,21 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
564
527
|
assert(false);
|
|
565
528
|
}
|
|
566
529
|
}
|
|
567
|
-
}
|
|
568
530
|
|
|
569
|
-
/**
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
return
|
|
531
|
+
/** Ensure extensions are only requested once */
|
|
532
|
+
getExtension(name: keyof GLExtensions): GLExtensions {
|
|
533
|
+
getWebGLExtension(this.gl, name, this._extensions);
|
|
534
|
+
return this._extensions;
|
|
573
535
|
}
|
|
574
|
-
if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
|
|
575
|
-
return true;
|
|
576
|
-
}
|
|
577
|
-
// Look for debug contexts, headless gl etc
|
|
578
|
-
return Boolean(gl && Number.isFinite(gl._version));
|
|
579
536
|
}
|
|
580
537
|
|
|
581
538
|
/** Check if supplied parameter is a WebGL2RenderingContext */
|
|
582
|
-
function
|
|
539
|
+
function isWebGL(gl: any): boolean {
|
|
583
540
|
if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
|
|
584
541
|
return true;
|
|
585
542
|
}
|
|
586
543
|
// Look for debug contexts, headless gl etc
|
|
587
|
-
return Boolean(gl && gl._version
|
|
544
|
+
return Boolean(gl && Number.isFinite(gl._version));
|
|
588
545
|
}
|
|
589
546
|
|
|
590
547
|
/** Set constant float array attribute */
|
|
@@ -609,8 +566,7 @@ function setConstantFloatArray(device: WebGLDevice, location: number, array: Flo
|
|
|
609
566
|
|
|
610
567
|
/** Set constant signed int array attribute */
|
|
611
568
|
function setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {
|
|
612
|
-
device.
|
|
613
|
-
device.gl2?.vertexAttribI4iv(location, array);
|
|
569
|
+
device.gl.vertexAttribI4iv(location, array);
|
|
614
570
|
// TODO - not clear if we need to use the special forms, more testing needed
|
|
615
571
|
// switch (array.length) {
|
|
616
572
|
// case 1:
|
|
@@ -631,8 +587,7 @@ function setConstantIntArray(device: WebGLDevice, location: number, array: Int32
|
|
|
631
587
|
|
|
632
588
|
/** Set constant unsigned int array attribute */
|
|
633
589
|
function setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {
|
|
634
|
-
device.
|
|
635
|
-
device.gl2?.vertexAttribI4uiv(location, array);
|
|
590
|
+
device.gl.vertexAttribI4uiv(location, array);
|
|
636
591
|
// TODO - not clear if we need to use the special forms, more testing needed
|
|
637
592
|
// switch (array.length) {
|
|
638
593
|
// case 1:
|
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,15 +19,14 @@ 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(
|
|
26
|
-
|
|
27
|
+
device: Device,
|
|
27
28
|
options?: {framebuffer?: Framebuffer; color?: any; depth?: any; stencil?: any}
|
|
28
29
|
): void {
|
|
29
|
-
const device = WebGLDevice.attach(gl);
|
|
30
30
|
const {framebuffer = null, color = null, depth = null, stencil = null} = options || {};
|
|
31
31
|
const parameters: any = {};
|
|
32
32
|
|
|
@@ -60,50 +60,55 @@ export function clear(
|
|
|
60
60
|
assert(clearFlags !== 0, ERR_ARGUMENTS);
|
|
61
61
|
|
|
62
62
|
// Temporarily set any clear "colors" and call clear
|
|
63
|
-
withGLParameters(device
|
|
64
|
-
device.gl
|
|
63
|
+
withGLParameters(device, parameters, () => {
|
|
64
|
+
const gl = (device as WebGLDevice).gl;
|
|
65
|
+
gl.clear(clearFlags);
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
const {
|
|
78
|
+
framebuffer = null,
|
|
79
|
+
buffer = GL_COLOR,
|
|
80
|
+
drawBuffer = 0,
|
|
81
|
+
value = [0, 0, 0, 0]
|
|
82
|
+
} = options || {};
|
|
83
|
+
const gl = (device as WebGLDevice).gl;
|
|
84
|
+
withGLParameters(gl, {framebuffer}, () => {
|
|
80
85
|
// Method selection per OpenGL ES 3 docs
|
|
81
86
|
switch (buffer) {
|
|
82
87
|
case GL_COLOR:
|
|
83
88
|
switch (value.constructor) {
|
|
84
89
|
case Int32Array:
|
|
85
|
-
|
|
90
|
+
gl.clearBufferiv(buffer, drawBuffer, value);
|
|
86
91
|
break;
|
|
87
92
|
case Uint32Array:
|
|
88
|
-
|
|
93
|
+
gl.clearBufferuiv(buffer, drawBuffer, value);
|
|
89
94
|
break;
|
|
90
95
|
case Float32Array:
|
|
91
96
|
default:
|
|
92
|
-
|
|
97
|
+
gl.clearBufferfv(buffer, drawBuffer, value);
|
|
93
98
|
}
|
|
94
99
|
break;
|
|
95
100
|
|
|
96
101
|
case GL_DEPTH:
|
|
97
|
-
|
|
102
|
+
gl.clearBufferfv(GL_DEPTH, 0, [value]);
|
|
98
103
|
break;
|
|
99
104
|
|
|
100
105
|
case GL_STENCIL:
|
|
101
|
-
|
|
106
|
+
gl.clearBufferiv(GL_STENCIL, 0, [value]);
|
|
102
107
|
break;
|
|
103
108
|
|
|
104
109
|
case GL_DEPTH_STENCIL:
|
|
105
110
|
const [depth, stencil] = value;
|
|
106
|
-
|
|
111
|
+
gl.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);
|
|
107
112
|
break;
|
|
108
113
|
|
|
109
114
|
default:
|
|
@@ -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);
|
|
@@ -240,8 +247,7 @@ export function copyToTexture(
|
|
|
240
247
|
break;
|
|
241
248
|
case GL.TEXTURE_2D_ARRAY:
|
|
242
249
|
case GL.TEXTURE_3D:
|
|
243
|
-
device.
|
|
244
|
-
device.gl2.copyTexSubImage3D(
|
|
250
|
+
device.gl.copyTexSubImage3D(
|
|
245
251
|
textureTarget,
|
|
246
252
|
targetMipmaplevel,
|
|
247
253
|
targetX,
|