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