@luma.gl/webgl 9.0.0-alpha.5 → 9.0.0-alpha.50
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/LICENSE +3 -1
- package/dist/adapter/converters/device-parameters.d.ts +23 -4
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +101 -73
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +6 -6
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +74 -111
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/shader-formats.d.ts +9 -0
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -0
- package/dist/adapter/converters/shader-formats.js +52 -0
- package/dist/adapter/converters/shader-formats.js.map +1 -0
- package/dist/adapter/converters/texture-formats.d.ts +32 -44
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +309 -346
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts +9 -3
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +53 -22
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.d.ts +1 -1
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +17 -23
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.d.ts +3 -3
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +54 -58
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- 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 +31 -22
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/device-helpers/is-old-ie.d.ts.map +1 -1
- package/dist/adapter/device-helpers/is-old-ie.js +2 -1
- package/dist/adapter/device-helpers/is-old-ie.js.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.d.ts +26 -0
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -0
- package/dist/adapter/helpers/decode-webgl-types.js +89 -0
- package/dist/adapter/helpers/decode-webgl-types.js.map +1 -0
- package/dist/adapter/helpers/get-shader-info.d.ts +9 -0
- package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -0
- package/dist/adapter/helpers/get-shader-info.js +25 -0
- package/dist/adapter/helpers/get-shader-info.js.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -48
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +87 -143
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +16 -11
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +51 -82
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts +16 -0
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/webgl-topology-utils.js +103 -0
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -0
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -3
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -29
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +15 -12
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +36 -44
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +6 -9
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +26 -83
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts +19 -11
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +60 -88
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +15 -9
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +175 -48
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +7 -6
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +10 -20
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +21 -24
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +63 -173
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +19 -4
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +99 -11
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +55 -21
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +108 -270
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +6 -5
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +11 -21
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts +3 -4
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +21 -34
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +62 -42
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +137 -256
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +47 -0
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-transform-feedback.js +164 -0
- package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -0
- package/dist/adapter/resources/webgl-vertex-array.d.ts +67 -0
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-vertex-array.js +167 -0
- package/dist/adapter/resources/webgl-vertex-array.js.map +1 -0
- package/dist/adapter/webgl-canvas-context.d.ts +6 -7
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +10 -23
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +76 -41
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +219 -129
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +3 -3
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +26 -52
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/clear.d.ts +22 -0
- package/dist/classic/clear.d.ts.map +1 -0
- package/dist/classic/clear.js +88 -0
- package/dist/classic/clear.js.map +1 -0
- package/dist/classic/copy-and-blit.d.ts +62 -0
- package/dist/classic/copy-and-blit.d.ts.map +1 -0
- package/dist/classic/copy-and-blit.js +191 -0
- package/dist/classic/copy-and-blit.js.map +1 -0
- package/dist/classic/format-utils.d.ts +3 -0
- package/dist/classic/format-utils.d.ts.map +1 -0
- package/dist/classic/format-utils.js +37 -0
- package/dist/classic/format-utils.js.map +1 -0
- package/dist/classic/typed-array-utils.d.ts +17 -17
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +18 -39
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/create-browser-context.d.ts +40 -0
- package/dist/context/context/create-browser-context.d.ts.map +1 -0
- package/dist/context/context/create-browser-context.js +53 -0
- package/dist/context/context/create-browser-context.js.map +1 -0
- package/dist/context/context/create-headless-context.d.ts +9 -0
- package/dist/context/context/create-headless-context.d.ts.map +1 -0
- package/dist/context/context/create-headless-context.js +42 -0
- package/dist/context/context/create-headless-context.js.map +1 -0
- package/dist/context/context/webgl-checks.d.ts.map +1 -1
- package/dist/context/context/webgl-checks.js +1 -4
- package/dist/context/context/webgl-checks.js.map +1 -1
- package/dist/context/debug/spector.d.ts +1 -2
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +8 -20
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts +2 -2
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +15 -39
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +9 -8
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +9 -19
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +105 -106
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +267 -286
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfill/context-data.d.ts +13 -0
- package/dist/context/polyfill/context-data.d.ts.map +1 -0
- package/dist/context/polyfill/context-data.js +12 -0
- package/dist/context/polyfill/context-data.js.map +1 -0
- package/dist/context/polyfill/get-parameter-polyfill.d.ts +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +37 -43
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-context.js +22 -30
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts +8 -8
- package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +18 -41
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js +17 -87
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +0 -4
- package/dist/context/state-tracker/deep-array-equal.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +26 -62
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts +2 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +8 -10
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/dist.dev.js +8555 -0
- package/dist/index.cjs +6602 -0
- package/dist/index.d.ts +26 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -26
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist.min.js +49 -0
- package/package.json +21 -9
- package/src/adapter/converters/device-parameters.ts +144 -41
- package/src/adapter/converters/sampler-parameters.ts +103 -41
- package/src/adapter/converters/shader-formats.ts +44 -0
- package/src/adapter/converters/texture-formats.ts +268 -195
- package/src/adapter/converters/vertex-formats.ts +71 -10
- package/src/adapter/device-helpers/device-features.ts +14 -3
- package/src/adapter/device-helpers/device-limits.ts +5 -3
- package/src/adapter/device-helpers/get-device-info.ts +53 -18
- package/src/adapter/device-helpers/is-old-ie.ts +3 -0
- package/src/adapter/helpers/{uniforms.ts → decode-webgl-types.ts} +39 -21
- package/src/adapter/helpers/get-shader-info.ts +41 -0
- package/src/adapter/helpers/get-shader-layout.ts +121 -146
- package/src/adapter/helpers/parse-shader-compiler-log.ts +24 -8
- package/src/adapter/helpers/set-uniform.ts +39 -35
- package/src/adapter/helpers/webgl-topology-utils.ts +103 -0
- package/src/adapter/objects/constants-to-keys.ts +6 -25
- package/src/adapter/objects/webgl-renderbuffer.ts +43 -37
- package/src/adapter/objects/webgl-resource.ts +16 -23
- package/src/adapter/resources/webgl-buffer.ts +67 -62
- package/src/adapter/resources/webgl-command-buffer.ts +327 -25
- package/src/adapter/resources/webgl-command-encoder.ts +20 -12
- package/src/adapter/resources/webgl-external-texture.ts +5 -2
- package/src/adapter/resources/webgl-framebuffer.ts +90 -134
- package/src/adapter/resources/webgl-render-pass.ts +166 -4
- package/src/adapter/resources/webgl-render-pipeline.ts +256 -192
- package/src/adapter/resources/webgl-sampler.ts +16 -10
- package/src/adapter/resources/webgl-shader.ts +14 -11
- package/src/adapter/resources/webgl-texture.ts +138 -99
- package/src/adapter/resources/webgl-transform-feedback.ts +202 -0
- package/src/adapter/resources/webgl-vertex-array.ts +283 -0
- package/src/adapter/webgl-canvas-context.ts +16 -14
- package/src/adapter/webgl-device.ts +328 -79
- package/src/classic/accessor.ts +8 -18
- package/src/classic/clear.ts +113 -0
- package/src/classic/copy-and-blit.ts +311 -0
- package/src/classic/format-utils.ts +46 -0
- package/src/classic/typed-array-utils.ts +21 -27
- package/src/context/context/create-browser-context.ts +140 -0
- package/src/context/context/create-headless-context.ts +51 -0
- package/src/context/context/webgl-checks.ts +3 -1
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +23 -15
- package/src/context/parameters/unified-parameter-api.ts +23 -14
- package/src/context/parameters/webgl-parameter-tables.ts +120 -98
- package/src/context/polyfill/context-data.ts +30 -0
- package/src/context/polyfill/get-parameter-polyfill.ts +11 -7
- package/src/context/polyfill/polyfill-context.ts +10 -9
- package/src/context/polyfill/polyfill-table.ts +21 -16
- package/src/context/polyfill/polyfill-vertex-array-object.ts +5 -0
- package/src/context/state-tracker/deep-array-equal.ts +2 -0
- package/src/context/state-tracker/track-context-state.ts +14 -11
- package/src/context/state-tracker/with-parameters.ts +13 -4
- package/src/index.ts +70 -35
- package/src/types.ts +5 -0
- package/dist/adapter/converters/renderbuffer-formats.d.ts +0 -16
- package/dist/adapter/converters/renderbuffer-formats.d.ts.map +0 -1
- package/dist/adapter/converters/renderbuffer-formats.js +0 -185
- package/dist/adapter/converters/renderbuffer-formats.js.map +0 -1
- package/dist/adapter/helpers/attribute-utils.d.ts +0 -11
- package/dist/adapter/helpers/attribute-utils.d.ts.map +0 -1
- package/dist/adapter/helpers/attribute-utils.js +0 -81
- package/dist/adapter/helpers/attribute-utils.js.map +0 -1
- package/dist/adapter/helpers/uniforms.d.ts +0 -26
- package/dist/adapter/helpers/uniforms.d.ts.map +0 -1
- package/dist/adapter/helpers/uniforms.js +0 -99
- package/dist/adapter/helpers/uniforms.js.map +0 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +0 -27
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +0 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +0 -84
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +0 -1
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/dist/classic/buffer.d.ts +0 -95
- package/dist/classic/buffer.d.ts.map +0 -1
- package/dist/classic/buffer.js +0 -384
- package/dist/classic/buffer.js.map +0 -1
- package/dist/context/context/context-state.d.ts +0 -18
- package/dist/context/context/context-state.d.ts.map +0 -1
- package/dist/context/context/context-state.js +0 -26
- package/dist/context/context/context-state.js.map +0 -1
- package/dist/context/context/create-context.d.ts +0 -41
- package/dist/context/context/create-context.d.ts.map +0 -1
- package/dist/context/context/create-context.js +0 -49
- package/dist/context/context/create-context.js.map +0 -1
- package/dist/context/context/device-pixels.d.ts +0 -25
- package/dist/context/context/device-pixels.d.ts.map +0 -1
- package/dist/context/context/device-pixels.js +0 -98
- package/dist/context/context/device-pixels.js.map +0 -1
- package/dist/es5/adapter/converters/device-parameters.js +0 -170
- package/dist/es5/adapter/converters/device-parameters.js.map +0 -1
- package/dist/es5/adapter/converters/renderbuffer-formats.js +0 -163
- package/dist/es5/adapter/converters/renderbuffer-formats.js.map +0 -1
- package/dist/es5/adapter/converters/sampler-parameters.js +0 -226
- package/dist/es5/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/es5/adapter/converters/texture-formats.js +0 -1031
- package/dist/es5/adapter/converters/texture-formats.js.map +0 -1
- package/dist/es5/adapter/converters/vertex-formats.js +0 -45
- package/dist/es5/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/es5/adapter/device-helpers/device-features.js +0 -144
- package/dist/es5/adapter/device-helpers/device-features.js.map +0 -1
- package/dist/es5/adapter/device-helpers/device-limits.js +0 -64
- package/dist/es5/adapter/device-helpers/device-limits.js.map +0 -1
- package/dist/es5/adapter/device-helpers/get-device-info.js +0 -55
- package/dist/es5/adapter/device-helpers/get-device-info.js.map +0 -1
- package/dist/es5/adapter/device-helpers/is-old-ie.js +0 -16
- package/dist/es5/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/es5/adapter/helpers/attribute-utils.js +0 -91
- package/dist/es5/adapter/helpers/attribute-utils.js.map +0 -1
- package/dist/es5/adapter/helpers/get-shader-layout.js +0 -371
- package/dist/es5/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/es5/adapter/helpers/parse-shader-compiler-log.js +0 -72
- package/dist/es5/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
- package/dist/es5/adapter/helpers/set-uniform.js +0 -125
- package/dist/es5/adapter/helpers/set-uniform.js.map +0 -1
- package/dist/es5/adapter/helpers/uniforms.js +0 -112
- package/dist/es5/adapter/helpers/uniforms.js.map +0 -1
- package/dist/es5/adapter/objects/constants-to-keys.js +0 -54
- package/dist/es5/adapter/objects/constants-to-keys.js.map +0 -1
- package/dist/es5/adapter/objects/webgl-renderbuffer.js +0 -150
- package/dist/es5/adapter/objects/webgl-renderbuffer.js.map +0 -1
- package/dist/es5/adapter/objects/webgl-resource.js +0 -292
- package/dist/es5/adapter/objects/webgl-resource.js.map +0 -1
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js +0 -137
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-buffer.js +0 -243
- package/dist/es5/adapter/resources/webgl-buffer.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-command-buffer.js +0 -96
- package/dist/es5/adapter/resources/webgl-command-buffer.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-command-encoder.js +0 -98
- package/dist/es5/adapter/resources/webgl-command-encoder.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-external-texture.js +0 -2
- package/dist/es5/adapter/resources/webgl-external-texture.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-framebuffer.js +0 -345
- package/dist/es5/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-render-pass.js +0 -61
- package/dist/es5/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-render-pipeline.js +0 -505
- package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-sampler.js +0 -96
- package/dist/es5/adapter/resources/webgl-sampler.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-shader.js +0 -149
- package/dist/es5/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-texture.js +0 -986
- package/dist/es5/adapter/resources/webgl-texture.js.map +0 -1
- package/dist/es5/adapter/webgl-canvas-context.js +0 -97
- package/dist/es5/adapter/webgl-canvas-context.js.map +0 -1
- package/dist/es5/adapter/webgl-device.js +0 -399
- package/dist/es5/adapter/webgl-device.js.map +0 -1
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/classic/accessor.js +0 -181
- package/dist/es5/classic/accessor.js.map +0 -1
- package/dist/es5/classic/buffer.js +0 -470
- package/dist/es5/classic/buffer.js.map +0 -1
- package/dist/es5/classic/typed-array-utils.js +0 -126
- package/dist/es5/classic/typed-array-utils.js.map +0 -1
- package/dist/es5/context/context/context-state.js +0 -31
- package/dist/es5/context/context/context-state.js.map +0 -1
- package/dist/es5/context/context/create-context.js +0 -69
- package/dist/es5/context/context/create-context.js.map +0 -1
- package/dist/es5/context/context/device-pixels.js +0 -115
- package/dist/es5/context/context/device-pixels.js.map +0 -1
- package/dist/es5/context/context/webgl-checks.js +0 -54
- package/dist/es5/context/context/webgl-checks.js.map +0 -1
- package/dist/es5/context/debug/spector.js +0 -133
- package/dist/es5/context/debug/spector.js.map +0 -1
- package/dist/es5/context/debug/webgl-developer-tools.js +0 -198
- package/dist/es5/context/debug/webgl-developer-tools.js.map +0 -1
- package/dist/es5/context/parameters/unified-parameter-api.js +0 -97
- package/dist/es5/context/parameters/unified-parameter-api.js.map +0 -1
- package/dist/es5/context/parameters/webgl-parameter-tables.js +0 -392
- package/dist/es5/context/parameters/webgl-parameter-tables.js.map +0 -1
- package/dist/es5/context/polyfill/get-parameter-polyfill.js +0 -81
- package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +0 -1
- package/dist/es5/context/polyfill/polyfill-context.js +0 -135
- package/dist/es5/context/polyfill/polyfill-context.js.map +0 -1
- package/dist/es5/context/polyfill/polyfill-table.js +0 -166
- package/dist/es5/context/polyfill/polyfill-table.js.map +0 -1
- package/dist/es5/context/polyfill/polyfill-vertex-array-object.js +0 -341
- package/dist/es5/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
- package/dist/es5/context/state-tracker/deep-array-equal.js +0 -28
- package/dist/es5/context/state-tracker/deep-array-equal.js.map +0 -1
- package/dist/es5/context/state-tracker/track-context-state.js +0 -211
- package/dist/es5/context/state-tracker/track-context-state.js.map +0 -1
- package/dist/es5/context/state-tracker/with-parameters.js +0 -44
- package/dist/es5/context/state-tracker/with-parameters.js.map +0 -1
- package/dist/es5/index.js +0 -276
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/init.js +0 -10
- package/dist/es5/init.js.map +0 -1
- package/dist/es5/types/webgl.js +0 -6
- package/dist/es5/types/webgl.js.map +0 -1
- package/dist/es5/types.js +0 -2
- package/dist/es5/types.js.map +0 -1
- package/dist/esm/adapter/converters/device-parameters.js +0 -155
- package/dist/esm/adapter/converters/device-parameters.js.map +0 -1
- package/dist/esm/adapter/converters/renderbuffer-formats.js +0 -185
- package/dist/esm/adapter/converters/renderbuffer-formats.js.map +0 -1
- package/dist/esm/adapter/converters/sampler-parameters.js +0 -208
- package/dist/esm/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/esm/adapter/converters/texture-formats.js +0 -954
- package/dist/esm/adapter/converters/texture-formats.js.map +0 -1
- package/dist/esm/adapter/converters/vertex-formats.js +0 -35
- package/dist/esm/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/esm/adapter/device-helpers/device-features.js +0 -102
- package/dist/esm/adapter/device-helpers/device-features.js.map +0 -1
- package/dist/esm/adapter/device-helpers/device-limits.js +0 -91
- package/dist/esm/adapter/device-helpers/device-limits.js.map +0 -1
- package/dist/esm/adapter/device-helpers/get-device-info.js +0 -44
- package/dist/esm/adapter/device-helpers/get-device-info.js.map +0 -1
- package/dist/esm/adapter/device-helpers/is-old-ie.js +0 -8
- package/dist/esm/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/esm/adapter/helpers/attribute-utils.js +0 -81
- package/dist/esm/adapter/helpers/attribute-utils.js.map +0 -1
- package/dist/esm/adapter/helpers/get-shader-layout.js +0 -306
- package/dist/esm/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/esm/adapter/helpers/parse-shader-compiler-log.js +0 -37
- package/dist/esm/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
- package/dist/esm/adapter/helpers/set-uniform.js +0 -115
- package/dist/esm/adapter/helpers/set-uniform.js.map +0 -1
- package/dist/esm/adapter/helpers/uniforms.js +0 -99
- package/dist/esm/adapter/helpers/uniforms.js.map +0 -1
- package/dist/esm/adapter/objects/constants-to-keys.js +0 -42
- package/dist/esm/adapter/objects/constants-to-keys.js.map +0 -1
- package/dist/esm/adapter/objects/webgl-renderbuffer.js +0 -94
- package/dist/esm/adapter/objects/webgl-renderbuffer.js.map +0 -1
- package/dist/esm/adapter/objects/webgl-resource.js +0 -216
- package/dist/esm/adapter/objects/webgl-resource.js.map +0 -1
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js +0 -84
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-buffer.js +0 -164
- package/dist/esm/adapter/resources/webgl-buffer.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-command-buffer.js +0 -65
- package/dist/esm/adapter/resources/webgl-command-buffer.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-command-encoder.js +0 -53
- package/dist/esm/adapter/resources/webgl-command-encoder.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-external-texture.js +0 -2
- package/dist/esm/adapter/resources/webgl-external-texture.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-framebuffer.js +0 -265
- package/dist/esm/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-render-pass.js +0 -19
- package/dist/esm/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-render-pipeline.js +0 -400
- package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-sampler.js +0 -50
- package/dist/esm/adapter/resources/webgl-sampler.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-shader.js +0 -75
- package/dist/esm/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-texture.js +0 -833
- package/dist/esm/adapter/resources/webgl-texture.js.map +0 -1
- package/dist/esm/adapter/webgl-canvas-context.js +0 -54
- package/dist/esm/adapter/webgl-canvas-context.js.map +0 -1
- package/dist/esm/adapter/webgl-device.js +0 -280
- package/dist/esm/adapter/webgl-device.js.map +0 -1
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/classic/accessor.js +0 -144
- package/dist/esm/classic/accessor.js.map +0 -1
- package/dist/esm/classic/buffer.js +0 -384
- package/dist/esm/classic/buffer.js.map +0 -1
- package/dist/esm/classic/typed-array-utils.js +0 -112
- package/dist/esm/classic/typed-array-utils.js.map +0 -1
- package/dist/esm/context/context/context-state.js +0 -26
- package/dist/esm/context/context/context-state.js.map +0 -1
- package/dist/esm/context/context/create-context.js +0 -49
- package/dist/esm/context/context/create-context.js.map +0 -1
- package/dist/esm/context/context/device-pixels.js +0 -98
- package/dist/esm/context/context/device-pixels.js.map +0 -1
- package/dist/esm/context/context/webgl-checks.js +0 -34
- package/dist/esm/context/context/webgl-checks.js.map +0 -1
- package/dist/esm/context/debug/spector.js +0 -76
- package/dist/esm/context/debug/spector.js.map +0 -1
- package/dist/esm/context/debug/webgl-developer-tools.js +0 -121
- package/dist/esm/context/debug/webgl-developer-tools.js.map +0 -1
- package/dist/esm/context/parameters/unified-parameter-api.js +0 -65
- package/dist/esm/context/parameters/unified-parameter-api.js.map +0 -1
- package/dist/esm/context/parameters/webgl-parameter-tables.js +0 -445
- package/dist/esm/context/parameters/webgl-parameter-tables.js.map +0 -1
- package/dist/esm/context/polyfill/get-parameter-polyfill.js +0 -91
- package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +0 -1
- package/dist/esm/context/polyfill/polyfill-context.js +0 -92
- package/dist/esm/context/polyfill/polyfill-context.js.map +0 -1
- package/dist/esm/context/polyfill/polyfill-table.js +0 -160
- package/dist/esm/context/polyfill/polyfill-table.js.map +0 -1
- package/dist/esm/context/polyfill/polyfill-vertex-array-object.js +0 -335
- package/dist/esm/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
- package/dist/esm/context/state-tracker/deep-array-equal.js +0 -21
- package/dist/esm/context/state-tracker/deep-array-equal.js.map +0 -1
- package/dist/esm/context/state-tracker/track-context-state.js +0 -183
- package/dist/esm/context/state-tracker/track-context-state.js.map +0 -1
- package/dist/esm/context/state-tracker/with-parameters.js +0 -36
- package/dist/esm/context/state-tracker/with-parameters.js.map +0 -1
- package/dist/esm/index.js +0 -27
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/init.js +0 -4
- package/dist/esm/init.js.map +0 -1
- package/dist/esm/types/webgl.js +0 -2
- package/dist/esm/types/webgl.js.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
- package/dist/init.d.ts +0 -2
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -4
- package/dist/init.js.map +0 -1
- package/dist/types/webgl.d.ts +0 -145
- package/dist/types/webgl.d.ts.map +0 -1
- package/dist/types/webgl.js +0 -2
- package/dist/types/webgl.js.map +0 -1
- package/src/adapter/converters/renderbuffer-formats.ts +0 -92
- package/src/adapter/helpers/attribute-utils.ts +0 -61
- package/src/adapter/objects/webgl-vertex-array-object.ts +0 -111
- package/src/bundle.ts +0 -4
- package/src/classic/buffer.ts +0 -474
- package/src/context/context/context-state.ts +0 -41
- package/src/context/context/create-context.ts +0 -110
- package/src/context/context/device-pixels.ts +0 -152
- package/src/init.ts +0 -4
- package/src/types/webgl.ts +0 -284
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
2
4
|
import type {
|
|
3
5
|
DeviceProps,
|
|
4
6
|
DeviceInfo,
|
|
5
7
|
DeviceLimits,
|
|
6
8
|
DeviceFeature,
|
|
7
9
|
CanvasContextProps,
|
|
8
|
-
TextureFormat
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
TextureFormat,
|
|
11
|
+
VertexArray,
|
|
12
|
+
VertexArrayProps,
|
|
13
|
+
TypedArray
|
|
14
|
+
} from '@luma.gl/core';
|
|
15
|
+
import {Device, CanvasContext, log, uid, assert} from '@luma.gl/core';
|
|
11
16
|
import {isBrowser} from '@probe.gl/env';
|
|
12
17
|
import {polyfillContext} from '../context/polyfill/polyfill-context';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
import {
|
|
19
|
+
popContextState,
|
|
20
|
+
pushContextState,
|
|
21
|
+
trackContextState
|
|
22
|
+
} from '../context/state-tracker/track-context-state';
|
|
23
|
+
import {createBrowserContext} from '../context/context/create-browser-context';
|
|
24
|
+
import {
|
|
25
|
+
createHeadlessContext,
|
|
26
|
+
isHeadlessGLRegistered
|
|
27
|
+
} from '../context/context/create-headless-context';
|
|
16
28
|
import {getDeviceInfo} from './device-helpers/get-device-info';
|
|
17
29
|
import {getDeviceFeatures} from './device-helpers/device-features';
|
|
18
30
|
import {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';
|
|
19
|
-
import WebGLCanvasContext from './webgl-canvas-context';
|
|
31
|
+
import {WebGLCanvasContext} from './webgl-canvas-context';
|
|
20
32
|
import {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';
|
|
21
33
|
import {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';
|
|
22
34
|
import {
|
|
@@ -29,48 +41,53 @@ import {
|
|
|
29
41
|
import type {
|
|
30
42
|
BufferProps,
|
|
31
43
|
ShaderProps,
|
|
32
|
-
Sampler,
|
|
44
|
+
// Sampler,
|
|
33
45
|
SamplerProps,
|
|
34
46
|
TextureProps,
|
|
35
47
|
ExternalTexture,
|
|
36
48
|
ExternalTextureProps,
|
|
37
49
|
FramebufferProps,
|
|
38
|
-
RenderPipeline,
|
|
50
|
+
// RenderPipeline,
|
|
39
51
|
RenderPipelineProps,
|
|
40
52
|
ComputePipeline,
|
|
41
53
|
ComputePipelineProps,
|
|
42
|
-
RenderPass,
|
|
54
|
+
// RenderPass,
|
|
43
55
|
RenderPassProps,
|
|
44
56
|
ComputePass,
|
|
45
|
-
ComputePassProps
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
import
|
|
52
|
-
import
|
|
53
|
-
import
|
|
54
|
-
import
|
|
55
|
-
import
|
|
57
|
+
ComputePassProps,
|
|
58
|
+
// CommandEncoder,
|
|
59
|
+
CommandEncoderProps,
|
|
60
|
+
TransformFeedbackProps
|
|
61
|
+
} from '@luma.gl/core';
|
|
62
|
+
|
|
63
|
+
import {WEBGLBuffer} from './resources/webgl-buffer';
|
|
64
|
+
import {WEBGLShader} from './resources/webgl-shader';
|
|
65
|
+
import {WEBGLSampler} from './resources/webgl-sampler';
|
|
66
|
+
import {WEBGLTexture} from './resources/webgl-texture';
|
|
67
|
+
import {WEBGLFramebuffer} from './resources/webgl-framebuffer';
|
|
68
|
+
import {WEBGLRenderPass} from './resources/webgl-render-pass';
|
|
69
|
+
import {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';
|
|
70
|
+
import {WEBGLCommandEncoder} from './resources/webgl-command-encoder';
|
|
71
|
+
import {WEBGLVertexArray} from './resources/webgl-vertex-array';
|
|
72
|
+
import {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';
|
|
56
73
|
|
|
57
74
|
const LOG_LEVEL = 1;
|
|
58
75
|
|
|
59
|
-
let counter = 0;
|
|
60
|
-
|
|
61
76
|
/** WebGPU style Device API for a WebGL context */
|
|
62
|
-
export
|
|
63
|
-
//
|
|
77
|
+
export class WebGLDevice extends Device {
|
|
78
|
+
//
|
|
79
|
+
// Public `Device` API
|
|
80
|
+
//
|
|
64
81
|
|
|
65
82
|
static type: string = 'webgl';
|
|
66
83
|
|
|
67
84
|
static isSupported(): boolean {
|
|
68
|
-
return typeof WebGLRenderingContext !== 'undefined';
|
|
85
|
+
return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();
|
|
69
86
|
}
|
|
70
87
|
|
|
71
88
|
readonly info: DeviceInfo;
|
|
72
89
|
readonly canvasContext: WebGLCanvasContext;
|
|
73
|
-
|
|
90
|
+
|
|
74
91
|
readonly handle: WebGLRenderingContext;
|
|
75
92
|
|
|
76
93
|
get features(): Set<DeviceFeature> {
|
|
@@ -83,36 +100,15 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
83
100
|
return this._limits;
|
|
84
101
|
}
|
|
85
102
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
/** WebGL1 typed context. Can always be used. */
|
|
89
|
-
readonly gl: WebGLRenderingContext;
|
|
90
|
-
/** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */
|
|
91
|
-
readonly gl2: WebGL2RenderingContext;
|
|
92
|
-
readonly debug: boolean = false;
|
|
93
|
-
|
|
94
|
-
/** `true` if this is a WebGL1 context. @note `false` if WebGL2 */
|
|
95
|
-
readonly isWebGL1: boolean;
|
|
96
|
-
/** `true` if this is a WebGL2 context. @note `false` if WebGL1 */
|
|
97
|
-
readonly isWebGL2: boolean;
|
|
98
|
-
|
|
99
|
-
get webglLimits(): WebGLLimits {
|
|
100
|
-
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
101
|
-
return this._webglLimits;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private _features: Set<DeviceFeature>;
|
|
105
|
-
private _limits: DeviceLimits;
|
|
106
|
-
private _webglLimits: WebGLLimits;
|
|
103
|
+
readonly lost: Promise<{reason: 'destroyed'; message: string}>;
|
|
107
104
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
readonly _extensions: Record<string, any> = {};
|
|
112
|
-
_polyfilled: boolean = false;
|
|
105
|
+
private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;
|
|
106
|
+
private _features?: Set<DeviceFeature>;
|
|
107
|
+
private _limits?: DeviceLimits;
|
|
113
108
|
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
//
|
|
110
|
+
// Static methods, expected to be present by `luma.createDevice()`
|
|
111
|
+
//
|
|
116
112
|
|
|
117
113
|
/**
|
|
118
114
|
* Get a device instance from a GL context
|
|
@@ -135,7 +131,7 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
135
131
|
return new WebGLDevice({gl: gl as WebGLRenderingContext});
|
|
136
132
|
}
|
|
137
133
|
|
|
138
|
-
static async create(props
|
|
134
|
+
static async create(props: DeviceProps = {}): Promise<WebGLDevice> {
|
|
139
135
|
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');
|
|
140
136
|
|
|
141
137
|
// Wait for page to load. Only wait when props. canvas is string
|
|
@@ -145,33 +141,66 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
145
141
|
}
|
|
146
142
|
|
|
147
143
|
// Load webgl and spector debug scripts from CDN if requested
|
|
148
|
-
if (props.debug) {
|
|
144
|
+
if (log.get('debug') || props.debug) {
|
|
149
145
|
await loadWebGLDeveloperTools();
|
|
150
146
|
}
|
|
147
|
+
|
|
151
148
|
// @ts-expect-error spector not on props
|
|
152
|
-
|
|
149
|
+
const {spector} = props;
|
|
150
|
+
if (log.get('spector') || spector) {
|
|
153
151
|
await loadSpectorJS();
|
|
154
152
|
}
|
|
155
153
|
|
|
156
|
-
log.probe(LOG_LEVEL, 'DOM is loaded')();
|
|
154
|
+
log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
|
|
155
|
+
|
|
156
|
+
// @ts-expect-error
|
|
157
|
+
if (props.gl && props.gl.device) {
|
|
158
|
+
return WebGLDevice.attach(props.gl);
|
|
159
|
+
}
|
|
160
|
+
|
|
157
161
|
return new WebGLDevice(props);
|
|
158
162
|
}
|
|
159
163
|
|
|
164
|
+
//
|
|
165
|
+
// Public API
|
|
166
|
+
//
|
|
167
|
+
|
|
160
168
|
constructor(props: DeviceProps) {
|
|
161
|
-
super(props);
|
|
169
|
+
super({...props, id: props.id || uid('webgl-device')});
|
|
162
170
|
|
|
163
171
|
// If attaching to an already attached context, return the attached device
|
|
164
172
|
// @ts-expect-error device is attached to context
|
|
165
173
|
const device: WebGLDevice | undefined = props.gl?.device;
|
|
166
174
|
if (device) {
|
|
167
|
-
|
|
168
|
-
return device;
|
|
175
|
+
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
169
176
|
}
|
|
170
177
|
|
|
171
178
|
// Create and instrument context
|
|
172
179
|
this.canvasContext = new WebGLCanvasContext(this, props);
|
|
173
180
|
|
|
174
|
-
this.
|
|
181
|
+
this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {
|
|
182
|
+
this._resolveContextLost = resolve;
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const onContextLost = (event: Event) =>
|
|
186
|
+
this._resolveContextLost?.({
|
|
187
|
+
reason: 'destroyed',
|
|
188
|
+
message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl || null;
|
|
192
|
+
gl =
|
|
193
|
+
gl ||
|
|
194
|
+
(isBrowser()
|
|
195
|
+
? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost})
|
|
196
|
+
: null);
|
|
197
|
+
gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);
|
|
198
|
+
|
|
199
|
+
if (!gl) {
|
|
200
|
+
throw new Error('WebGL context creation failed');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
this.handle = gl;
|
|
175
204
|
this.gl = this.handle;
|
|
176
205
|
this.gl2 = this.gl as WebGL2RenderingContext;
|
|
177
206
|
this.isWebGL2 = isWebGL2(this.gl);
|
|
@@ -182,13 +211,20 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
182
211
|
|
|
183
212
|
// @ts-expect-error Link webgl context back to device
|
|
184
213
|
this.gl.device = this;
|
|
185
|
-
// @ts-expect-error Annotate webgl context to handle
|
|
214
|
+
// @ts-expect-error Annotate webgl context to handle
|
|
186
215
|
this.gl._version = this.isWebGL2 ? 2 : 1;
|
|
187
216
|
|
|
188
217
|
// Add subset of WebGL2 methods to WebGL1 context
|
|
189
218
|
polyfillContext(this.gl);
|
|
219
|
+
|
|
190
220
|
// Install context state tracking
|
|
191
|
-
|
|
221
|
+
// @ts-expect-error - hidden parameters
|
|
222
|
+
const {enable = true, copyState = false} = props;
|
|
223
|
+
trackContextState(this.gl, {
|
|
224
|
+
enable,
|
|
225
|
+
copyState,
|
|
226
|
+
log: (...args: any[]) => log.log(1, ...args)()
|
|
227
|
+
});
|
|
192
228
|
|
|
193
229
|
// DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1
|
|
194
230
|
if (isBrowser() && props.debug) {
|
|
@@ -218,16 +254,11 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`
|
|
|
218
254
|
* Destroys the context
|
|
219
255
|
* @note Has no effect for browser contexts, there is no browser API for destroying contexts
|
|
220
256
|
*/
|
|
221
|
-
destroy() {
|
|
222
|
-
|
|
257
|
+
destroy(): void {
|
|
258
|
+
const ext = this.gl.getExtension('STACKGL_destroy_context');
|
|
223
259
|
if (ext) {
|
|
224
260
|
ext.destroy();
|
|
225
261
|
}
|
|
226
|
-
// ext = this.gl.getExtension('WEBGL_lose_context');
|
|
227
|
-
// if (ext) {
|
|
228
|
-
// // TODO - disconnect context lost callbacks?
|
|
229
|
-
// ext.loseContext();
|
|
230
|
-
// }
|
|
231
262
|
}
|
|
232
263
|
|
|
233
264
|
get isLost(): boolean {
|
|
@@ -254,7 +285,9 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`
|
|
|
254
285
|
|
|
255
286
|
/** Returns a WebGL2RenderingContext or throws an error */
|
|
256
287
|
assertWebGL2(): WebGL2RenderingContext {
|
|
257
|
-
|
|
288
|
+
if (!this.gl2) {
|
|
289
|
+
throw new Error('Requires WebGL2');
|
|
290
|
+
}
|
|
258
291
|
return this.gl2;
|
|
259
292
|
}
|
|
260
293
|
|
|
@@ -264,8 +297,9 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`
|
|
|
264
297
|
throw new Error('WebGL only supports a single canvas');
|
|
265
298
|
}
|
|
266
299
|
|
|
267
|
-
|
|
268
|
-
|
|
300
|
+
createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WEBGLBuffer {
|
|
301
|
+
const newProps = this._getBufferProps(props);
|
|
302
|
+
return new WEBGLBuffer(this, newProps);
|
|
269
303
|
}
|
|
270
304
|
|
|
271
305
|
_createTexture(props: TextureProps): WEBGLTexture {
|
|
@@ -292,6 +326,10 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`
|
|
|
292
326
|
return new WEBGLRenderPipeline(this, props);
|
|
293
327
|
}
|
|
294
328
|
|
|
329
|
+
override createVertexArray(props: VertexArrayProps): VertexArray {
|
|
330
|
+
return new WEBGLVertexArray(this, props);
|
|
331
|
+
}
|
|
332
|
+
|
|
295
333
|
beginRenderPass(props: RenderPassProps): WEBGLRenderPass {
|
|
296
334
|
return new WEBGLRenderPass(this, props);
|
|
297
335
|
}
|
|
@@ -301,10 +339,14 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`
|
|
|
301
339
|
}
|
|
302
340
|
|
|
303
341
|
beginComputePass(props: ComputePassProps): ComputePass {
|
|
304
|
-
throw new Error('
|
|
342
|
+
throw new Error('ComputePass not supported in WebGL');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback {
|
|
346
|
+
return new WEBGLTransformFeedback(this, props);
|
|
305
347
|
}
|
|
306
348
|
|
|
307
|
-
private renderPass: WEBGLRenderPass;
|
|
349
|
+
private renderPass: WEBGLRenderPass | null = null;
|
|
308
350
|
|
|
309
351
|
getDefaultRenderPass(): WEBGLRenderPass {
|
|
310
352
|
this.renderPass =
|
|
@@ -315,16 +357,143 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`
|
|
|
315
357
|
return this.renderPass;
|
|
316
358
|
}
|
|
317
359
|
|
|
360
|
+
override createCommandEncoder(props?: CommandEncoderProps): WEBGLCommandEncoder {
|
|
361
|
+
return new WEBGLCommandEncoder(this, props);
|
|
362
|
+
}
|
|
363
|
+
|
|
318
364
|
/**
|
|
319
365
|
* Offscreen Canvas Support: Commit the frame
|
|
320
366
|
* https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit
|
|
321
367
|
* Chrome's offscreen canvas does not require gl.commit
|
|
322
368
|
*/
|
|
323
369
|
submit(): void {
|
|
324
|
-
this.renderPass
|
|
370
|
+
this.renderPass?.end();
|
|
325
371
|
this.renderPass = null;
|
|
326
372
|
// this.canvasContext.commit();
|
|
327
373
|
}
|
|
374
|
+
|
|
375
|
+
//
|
|
376
|
+
// WebGL-only API (not part of `Device` API)
|
|
377
|
+
//
|
|
378
|
+
|
|
379
|
+
/** WebGL1 typed context. Can always be used. */
|
|
380
|
+
readonly gl: WebGLRenderingContext;
|
|
381
|
+
/** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */
|
|
382
|
+
readonly gl2: WebGL2RenderingContext | null = null;
|
|
383
|
+
readonly debug: boolean = false;
|
|
384
|
+
|
|
385
|
+
/** `true` if this is a WebGL1 context. @note `false` if WebGL2 */
|
|
386
|
+
readonly isWebGL1: boolean;
|
|
387
|
+
/** `true` if this is a WebGL2 context. @note `false` if WebGL1 */
|
|
388
|
+
readonly isWebGL2: boolean;
|
|
389
|
+
|
|
390
|
+
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
391
|
+
readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};
|
|
392
|
+
|
|
393
|
+
/** State used by luma.gl classes - TODO - not used? */
|
|
394
|
+
readonly _extensions: Record<string, any> = {};
|
|
395
|
+
_polyfilled: boolean = false;
|
|
396
|
+
|
|
397
|
+
/** Instance of Spector.js (if initialized) */
|
|
398
|
+
spector;
|
|
399
|
+
|
|
400
|
+
private _webglLimits?: WebGLLimits;
|
|
401
|
+
|
|
402
|
+
/** Return WebGL specific limits */
|
|
403
|
+
get webglLimits(): WebGLLimits {
|
|
404
|
+
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
405
|
+
return this._webglLimits;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Triggers device (or WebGL context) loss.
|
|
410
|
+
* @note primarily intended for testing how application reacts to device loss
|
|
411
|
+
*/
|
|
412
|
+
override loseDevice(): boolean {
|
|
413
|
+
let deviceLossTriggered = false;
|
|
414
|
+
const ext = this.gl.getExtension('WEBGL_lose_context');
|
|
415
|
+
if (ext) {
|
|
416
|
+
deviceLossTriggered = true;
|
|
417
|
+
ext.loseContext();
|
|
418
|
+
// ext.loseContext should trigger context loss callback but the platform may not do this, so do it explicitly
|
|
419
|
+
}
|
|
420
|
+
this._resolveContextLost?.({
|
|
421
|
+
reason: 'destroyed',
|
|
422
|
+
message: 'Application triggered context loss'
|
|
423
|
+
});
|
|
424
|
+
return deviceLossTriggered;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** Save current WebGL context state onto an internal stack */
|
|
428
|
+
pushState(): void {
|
|
429
|
+
pushContextState(this.gl);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** Restores previously saved context state */
|
|
433
|
+
popState(): void {
|
|
434
|
+
popContextState(this.gl);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
|
|
439
|
+
* luma.gl ids and props can be inspected
|
|
440
|
+
*/
|
|
441
|
+
setSpectorMetadata(handle: unknown, props: Record<string, unknown>) {
|
|
442
|
+
// @ts-expect-error
|
|
443
|
+
// eslint-disable-next-line camelcase
|
|
444
|
+
handle.__SPECTOR_Metadata = props;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant
|
|
449
|
+
* Be aware that there are some duplicates especially for constants that are 0,
|
|
450
|
+
* so this isn't guaranteed to return the right key in all cases.
|
|
451
|
+
*/
|
|
452
|
+
getGLKey(value: unknown, gl?: WebGLRenderingContext): string {
|
|
453
|
+
// @ts-ignore expect-error depends on settings
|
|
454
|
+
gl = gl || this.gl2 || this.gl;
|
|
455
|
+
const number = Number(value);
|
|
456
|
+
for (const key in gl) {
|
|
457
|
+
// @ts-ignore expect-error depends on settings
|
|
458
|
+
if (gl[key] === number) {
|
|
459
|
+
return `GL.${key}`;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
// No constant found. Stringify the value and return it.
|
|
463
|
+
return String(value);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** Store constants */
|
|
467
|
+
_constants: (TypedArray | null)[];
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Set a constant value for a location. Disabled attributes at that location will read from this value
|
|
471
|
+
* @note WebGL constants are stored globally on the WebGL context, not the VertexArray
|
|
472
|
+
* so they need to be updated before every render
|
|
473
|
+
* @todo - remember/cache values to avoid setting them unnecessarily?
|
|
474
|
+
*/
|
|
475
|
+
setConstantAttribute(location: number, constant: TypedArray): void {
|
|
476
|
+
this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);
|
|
477
|
+
const currentConstant = this._constants[location];
|
|
478
|
+
if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {
|
|
479
|
+
log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();
|
|
480
|
+
}
|
|
481
|
+
this._constants[location] = constant;
|
|
482
|
+
|
|
483
|
+
switch (constant.constructor) {
|
|
484
|
+
case Float32Array:
|
|
485
|
+
setConstantFloatArray(this, location, constant as Float32Array);
|
|
486
|
+
break;
|
|
487
|
+
case Int32Array:
|
|
488
|
+
setConstantIntArray(this, location, constant as Int32Array);
|
|
489
|
+
break;
|
|
490
|
+
case Uint32Array:
|
|
491
|
+
setConstantUintArray(this, location, constant as Uint32Array);
|
|
492
|
+
break;
|
|
493
|
+
default:
|
|
494
|
+
assert(false);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
328
497
|
}
|
|
329
498
|
|
|
330
499
|
/** Check if supplied parameter is a WebGLRenderingContext */
|
|
@@ -339,7 +508,6 @@ function isWebGL(gl: any): boolean {
|
|
|
339
508
|
return Boolean(gl && Number.isFinite(gl._version));
|
|
340
509
|
}
|
|
341
510
|
|
|
342
|
-
|
|
343
511
|
/** Check if supplied parameter is a WebGL2RenderingContext */
|
|
344
512
|
function isWebGL2(gl: any): boolean {
|
|
345
513
|
if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
|
|
@@ -348,3 +516,84 @@ function isWebGL2(gl: any): boolean {
|
|
|
348
516
|
// Look for debug contexts, headless gl etc
|
|
349
517
|
return Boolean(gl && gl._version === 2);
|
|
350
518
|
}
|
|
519
|
+
|
|
520
|
+
/** Set constant float array attribute */
|
|
521
|
+
function setConstantFloatArray(device: WebGLDevice, location: number, array: Float32Array): void {
|
|
522
|
+
switch (array.length) {
|
|
523
|
+
case 1:
|
|
524
|
+
device.gl.vertexAttrib1fv(location, array);
|
|
525
|
+
break;
|
|
526
|
+
case 2:
|
|
527
|
+
device.gl.vertexAttrib2fv(location, array);
|
|
528
|
+
break;
|
|
529
|
+
case 3:
|
|
530
|
+
device.gl.vertexAttrib3fv(location, array);
|
|
531
|
+
break;
|
|
532
|
+
case 4:
|
|
533
|
+
device.gl.vertexAttrib4fv(location, array);
|
|
534
|
+
break;
|
|
535
|
+
default:
|
|
536
|
+
assert(false);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** Set constant signed int array attribute */
|
|
541
|
+
function setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {
|
|
542
|
+
device.assertWebGL2();
|
|
543
|
+
device.gl2?.vertexAttribI4iv(location, array);
|
|
544
|
+
// TODO - not clear if we need to use the special forms, more testing needed
|
|
545
|
+
// switch (array.length) {
|
|
546
|
+
// case 1:
|
|
547
|
+
// gl.vertexAttribI1iv(location, array);
|
|
548
|
+
// break;
|
|
549
|
+
// case 2:
|
|
550
|
+
// gl.vertexAttribI2iv(location, array);
|
|
551
|
+
// break;
|
|
552
|
+
// case 3:
|
|
553
|
+
// gl.vertexAttribI3iv(location, array);
|
|
554
|
+
// break;
|
|
555
|
+
// case 4:
|
|
556
|
+
// break;
|
|
557
|
+
// default:
|
|
558
|
+
// assert(false);
|
|
559
|
+
// }
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/** Set constant unsigned int array attribute */
|
|
563
|
+
function setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {
|
|
564
|
+
device.assertWebGL2();
|
|
565
|
+
device.gl2?.vertexAttribI4uiv(location, array);
|
|
566
|
+
// TODO - not clear if we need to use the special forms, more testing needed
|
|
567
|
+
// switch (array.length) {
|
|
568
|
+
// case 1:
|
|
569
|
+
// gl.vertexAttribI1uiv(location, array);
|
|
570
|
+
// break;
|
|
571
|
+
// case 2:
|
|
572
|
+
// gl.vertexAttribI2uiv(location, array);
|
|
573
|
+
// break;
|
|
574
|
+
// case 3:
|
|
575
|
+
// gl.vertexAttribI3uiv(location, array);
|
|
576
|
+
// break;
|
|
577
|
+
// case 4:
|
|
578
|
+
// gl.vertexAttribI4uiv(location, array);
|
|
579
|
+
// break;
|
|
580
|
+
// default:
|
|
581
|
+
// assert(false);
|
|
582
|
+
// }
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Compares contents of two typed arrays
|
|
587
|
+
* @todo max length?
|
|
588
|
+
*/
|
|
589
|
+
function compareConstantArrayValues(v1: TypedArray, v2: TypedArray): boolean {
|
|
590
|
+
if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
593
|
+
for (let i = 0; i < v1.length; ++i) {
|
|
594
|
+
if (v1[i] !== v2[i]) {
|
|
595
|
+
return false;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return true;
|
|
599
|
+
}
|
package/src/classic/accessor.ts
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {getTypedArrayFromGLType} from './typed-array-utils';
|
|
4
|
-
|
|
5
|
-
// export interface AccessorObject {
|
|
6
|
-
// offset?: number;
|
|
7
|
-
// stride?: number;
|
|
8
|
-
// type?: number;
|
|
9
|
-
// size?: number;
|
|
10
|
-
// divisor?: number;
|
|
11
|
-
// normalized?: boolean;
|
|
12
|
-
// integer?: boolean;
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
13
3
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
import {assert, checkProps, Buffer, AccessorObject} from '@luma.gl/core';
|
|
5
|
+
import {GL} from '@luma.gl/constants';
|
|
6
|
+
import {getTypedArrayFromGLType} from './typed-array-utils';
|
|
17
7
|
|
|
18
8
|
const DEFAULT_ACCESSOR_VALUES = {
|
|
19
9
|
offset: 0,
|
|
@@ -32,7 +22,7 @@ const PROP_CHECKS = {
|
|
|
32
22
|
}
|
|
33
23
|
};
|
|
34
24
|
|
|
35
|
-
export
|
|
25
|
+
export class Accessor implements AccessorObject {
|
|
36
26
|
offset?: number;
|
|
37
27
|
stride?: number;
|
|
38
28
|
type?: number;
|
|
@@ -97,8 +87,8 @@ export default class Accessor implements AccessorObject {
|
|
|
97
87
|
this.type = props.type;
|
|
98
88
|
|
|
99
89
|
// Auto-deduce integer type?
|
|
100
|
-
if (props.type === GL.INT || props.type === GL.UNSIGNED_INT) {
|
|
101
|
-
|
|
90
|
+
if ((props.type as GL) === GL.INT || (props.type as GL) === GL.UNSIGNED_INT) {
|
|
91
|
+
this.integer = true;
|
|
102
92
|
}
|
|
103
93
|
}
|
|
104
94
|
if (props.size !== undefined) {
|