@luma.gl/webgl 9.0.0-alpha.9 → 9.0.0-beta.2
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 +12 -3
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +89 -74
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +4 -10
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +29 -180
- 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 +306 -343
- 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 +9 -25
- 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 +49 -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-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 +58 -138
- 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 -14
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +67 -101
- 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 -25
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +63 -175
- 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 +98 -12
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +34 -20
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +110 -293
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +5 -4
- 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 +5 -5
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +18 -44
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +51 -31
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +123 -244
- 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 +12 -23
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +100 -41
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +217 -158
- 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 +192 -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 +17 -18
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js +11 -19
- package/dist/context/context/create-browser-context.js.map +1 -1
- package/dist/context/context/create-headless-context.d.ts +1 -1
- package/dist/context/context/create-headless-context.d.ts.map +1 -1
- package/dist/context/context/create-headless-context.js +6 -7
- package/dist/context/context/create-headless-context.js.map +1 -1
- 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 +7 -19
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +18 -41
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +5 -5
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +9 -17
- 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 +27 -31
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts +7 -7
- package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +17 -40
- 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 +25 -61
- 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 +9296 -0
- package/dist/index.cjs +6469 -0
- package/dist/index.d.ts +20 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -27
- 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 +52 -0
- package/package.json +21 -9
- package/src/adapter/converters/device-parameters.ts +120 -43
- package/src/adapter/converters/sampler-parameters.ts +54 -126
- package/src/adapter/converters/shader-formats.ts +44 -0
- package/src/adapter/converters/texture-formats.ts +265 -192
- package/src/adapter/converters/vertex-formats.ts +71 -10
- package/src/adapter/device-helpers/device-features.ts +5 -2
- package/src/adapter/device-helpers/device-limits.ts +4 -2
- package/src/adapter/device-helpers/get-device-info.ts +72 -18
- package/src/adapter/device-helpers/is-old-ie.ts +3 -0
- package/src/adapter/helpers/{uniforms.ts → decode-webgl-types.ts} +31 -24
- package/src/adapter/helpers/get-shader-layout.ts +87 -131
- 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 +101 -106
- 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 +86 -133
- package/src/adapter/resources/webgl-render-pass.ts +165 -4
- package/src/adapter/resources/webgl-render-pipeline.ts +209 -205
- package/src/adapter/resources/webgl-sampler.ts +12 -8
- package/src/adapter/resources/webgl-shader.ts +32 -27
- package/src/adapter/resources/webgl-texture.ts +117 -91
- 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 +18 -13
- package/src/adapter/webgl-device.ts +343 -92
- package/src/classic/accessor.ts +8 -5
- package/src/classic/clear.ts +113 -0
- package/src/classic/copy-and-blit.ts +312 -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 +53 -31
- package/src/context/context/create-headless-context.ts +5 -2
- package/src/context/context/webgl-checks.ts +3 -1
- package/src/context/debug/spector.ts +8 -5
- package/src/context/debug/webgl-developer-tools.ts +26 -17
- package/src/context/parameters/unified-parameter-api.ts +15 -9
- 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 +15 -8
- package/src/context/polyfill/polyfill-table.ts +20 -15
- 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 +13 -10
- package/src/context/state-tracker/with-parameters.ts +13 -4
- package/src/index.ts +42 -42
- 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 -392
- 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/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 -103
- package/dist/context/context/device-pixels.js.map +0 -1
- package/dist/es5/adapter/converters/device-parameters.js +0 -185
- 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 -245
- 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 -155
- 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 -391
- 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 -346
- package/dist/es5/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-render-pass.js +0 -62
- package/dist/es5/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/es5/adapter/resources/webgl-render-pipeline.js +0 -530
- 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 -150
- 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 -463
- 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 -478
- 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-browser-context.js +0 -83
- package/dist/es5/context/context/create-browser-context.js.map +0 -1
- package/dist/es5/context/context/create-headless-context.js +0 -60
- package/dist/es5/context/context/create-headless-context.js.map +0 -1
- package/dist/es5/context/context/device-pixels.js +0 -121
- 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 -134
- 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 -290
- 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 -168
- 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 -227
- 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 -112
- 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 -330
- 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 -267
- package/dist/esm/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-render-pass.js +0 -21
- package/dist/esm/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-render-pipeline.js +0 -428
- 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 -76
- package/dist/esm/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/esm/adapter/resources/webgl-texture.js +0 -834
- 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 -337
- 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 -392
- 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-browser-context.js +0 -61
- package/dist/esm/context/context/create-browser-context.js.map +0 -1
- package/dist/esm/context/context/create-headless-context.js +0 -43
- package/dist/esm/context/context/create-headless-context.js.map +0 -1
- package/dist/esm/context/context/device-pixels.js +0 -103
- 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 -63
- 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 -91
- 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 -28
- 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/device-pixels.ts +0 -158
- package/src/init.ts +0 -4
- package/src/types/webgl.ts +0 -284
|
@@ -1,26 +1,38 @@
|
|
|
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
|
+
Framebuffer,
|
|
14
|
+
Buffer,
|
|
15
|
+
Texture,
|
|
16
|
+
TypedArray
|
|
17
|
+
} from '@luma.gl/core';
|
|
18
|
+
import {Device, CanvasContext, log, uid, assert} from '@luma.gl/core';
|
|
11
19
|
import {isBrowser} from '@probe.gl/env';
|
|
12
20
|
import {polyfillContext} from '../context/polyfill/polyfill-context';
|
|
13
|
-
import {
|
|
14
|
-
|
|
21
|
+
import {
|
|
22
|
+
popContextState,
|
|
23
|
+
pushContextState,
|
|
24
|
+
trackContextState
|
|
25
|
+
} from '../context/state-tracker/track-context-state';
|
|
15
26
|
import {createBrowserContext} from '../context/context/create-browser-context';
|
|
16
27
|
import {
|
|
17
28
|
createHeadlessContext,
|
|
18
29
|
isHeadlessGLRegistered
|
|
19
30
|
} from '../context/context/create-headless-context';
|
|
31
|
+
|
|
20
32
|
import {getDeviceInfo} from './device-helpers/get-device-info';
|
|
21
33
|
import {getDeviceFeatures} from './device-helpers/device-features';
|
|
22
34
|
import {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';
|
|
23
|
-
import WebGLCanvasContext from './webgl-canvas-context';
|
|
35
|
+
import {WebGLCanvasContext} from './webgl-canvas-context';
|
|
24
36
|
import {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';
|
|
25
37
|
import {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';
|
|
26
38
|
import {
|
|
@@ -33,37 +45,45 @@ import {
|
|
|
33
45
|
import type {
|
|
34
46
|
BufferProps,
|
|
35
47
|
ShaderProps,
|
|
36
|
-
Sampler,
|
|
48
|
+
// Sampler,
|
|
37
49
|
SamplerProps,
|
|
38
50
|
TextureProps,
|
|
39
51
|
ExternalTexture,
|
|
40
52
|
ExternalTextureProps,
|
|
41
53
|
FramebufferProps,
|
|
42
|
-
RenderPipeline,
|
|
54
|
+
// RenderPipeline,
|
|
43
55
|
RenderPipelineProps,
|
|
44
56
|
ComputePipeline,
|
|
45
57
|
ComputePipelineProps,
|
|
46
|
-
RenderPass,
|
|
58
|
+
// RenderPass,
|
|
47
59
|
RenderPassProps,
|
|
48
60
|
ComputePass,
|
|
49
|
-
ComputePassProps
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
import
|
|
56
|
-
import
|
|
57
|
-
import
|
|
58
|
-
import
|
|
59
|
-
import
|
|
61
|
+
ComputePassProps,
|
|
62
|
+
// CommandEncoder,
|
|
63
|
+
CommandEncoderProps,
|
|
64
|
+
TransformFeedbackProps
|
|
65
|
+
} from '@luma.gl/core';
|
|
66
|
+
|
|
67
|
+
import {WEBGLBuffer} from './resources/webgl-buffer';
|
|
68
|
+
import {WEBGLShader} from './resources/webgl-shader';
|
|
69
|
+
import {WEBGLSampler} from './resources/webgl-sampler';
|
|
70
|
+
import {WEBGLTexture} from './resources/webgl-texture';
|
|
71
|
+
import {WEBGLFramebuffer} from './resources/webgl-framebuffer';
|
|
72
|
+
import {WEBGLRenderPass} from './resources/webgl-render-pass';
|
|
73
|
+
import {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';
|
|
74
|
+
import {WEBGLCommandEncoder} from './resources/webgl-command-encoder';
|
|
75
|
+
import {WEBGLVertexArray} from './resources/webgl-vertex-array';
|
|
76
|
+
import {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';
|
|
77
|
+
|
|
78
|
+
import {readPixelsToArray, readPixelsToBuffer} from '../classic/copy-and-blit';
|
|
79
|
+
import {setGLParameters} from '../context/parameters/unified-parameter-api';
|
|
80
|
+
import {withGLParameters} from '../context/state-tracker/with-parameters';
|
|
81
|
+
import {clear} from '../classic/clear';
|
|
60
82
|
|
|
61
83
|
const LOG_LEVEL = 1;
|
|
62
84
|
|
|
63
|
-
let counter = 0;
|
|
64
|
-
|
|
65
85
|
/** WebGPU style Device API for a WebGL context */
|
|
66
|
-
export
|
|
86
|
+
export class WebGLDevice extends Device {
|
|
67
87
|
//
|
|
68
88
|
// Public `Device` API
|
|
69
89
|
//
|
|
@@ -95,37 +115,6 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
95
115
|
private _features?: Set<DeviceFeature>;
|
|
96
116
|
private _limits?: DeviceLimits;
|
|
97
117
|
|
|
98
|
-
//
|
|
99
|
-
// WebGL-only API (not part of `Device` API)
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
/** WebGL1 typed context. Can always be used. */
|
|
103
|
-
readonly gl: WebGLRenderingContext;
|
|
104
|
-
/** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */
|
|
105
|
-
readonly gl2: WebGL2RenderingContext | null = null;
|
|
106
|
-
readonly debug: boolean = false;
|
|
107
|
-
|
|
108
|
-
/** `true` if this is a WebGL1 context. @note `false` if WebGL2 */
|
|
109
|
-
readonly isWebGL1: boolean;
|
|
110
|
-
/** `true` if this is a WebGL2 context. @note `false` if WebGL1 */
|
|
111
|
-
readonly isWebGL2: boolean;
|
|
112
|
-
|
|
113
|
-
get webglLimits(): WebGLLimits {
|
|
114
|
-
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
115
|
-
return this._webglLimits;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private _webglLimits?: WebGLLimits;
|
|
119
|
-
|
|
120
|
-
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
121
|
-
readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};
|
|
122
|
-
/** State used by luma.gl classes */
|
|
123
|
-
readonly _extensions: Record<string, any> = {};
|
|
124
|
-
_polyfilled: boolean = false;
|
|
125
|
-
|
|
126
|
-
/** Instance of Spector.js (if initialized) */
|
|
127
|
-
spector;
|
|
128
|
-
|
|
129
118
|
//
|
|
130
119
|
// Static methods, expected to be present by `luma.createDevice()`
|
|
131
120
|
//
|
|
@@ -152,7 +141,7 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
152
141
|
}
|
|
153
142
|
|
|
154
143
|
static async create(props: DeviceProps = {}): Promise<WebGLDevice> {
|
|
155
|
-
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');
|
|
144
|
+
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
|
|
156
145
|
|
|
157
146
|
// Wait for page to load. Only wait when props. canvas is string
|
|
158
147
|
// to avoid setting page onload callback unless necessary
|
|
@@ -161,11 +150,13 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
161
150
|
}
|
|
162
151
|
|
|
163
152
|
// Load webgl and spector debug scripts from CDN if requested
|
|
164
|
-
if (props.debug) {
|
|
153
|
+
if (log.get('debug') || props.debug) {
|
|
165
154
|
await loadWebGLDeveloperTools();
|
|
166
155
|
}
|
|
156
|
+
|
|
167
157
|
// @ts-expect-error spector not on props
|
|
168
|
-
|
|
158
|
+
const {spector} = props;
|
|
159
|
+
if (log.get('spector') || spector) {
|
|
169
160
|
await loadSpectorJS();
|
|
170
161
|
}
|
|
171
162
|
|
|
@@ -176,7 +167,18 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
176
167
|
return WebGLDevice.attach(props.gl);
|
|
177
168
|
}
|
|
178
169
|
|
|
179
|
-
|
|
170
|
+
const device = new WebGLDevice(props);
|
|
171
|
+
|
|
172
|
+
// Log some debug info about the newly created context
|
|
173
|
+
const message = `\
|
|
174
|
+
Created ${device.info.type}${device.debug ? ' debug' : ''} context: \
|
|
175
|
+
${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
176
|
+
log.probe(LOG_LEVEL, message)();
|
|
177
|
+
log.table(LOG_LEVEL, device.info)();
|
|
178
|
+
|
|
179
|
+
log.groupEnd(LOG_LEVEL)();
|
|
180
|
+
|
|
181
|
+
return device;
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
//
|
|
@@ -184,7 +186,7 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
184
186
|
//
|
|
185
187
|
|
|
186
188
|
constructor(props: DeviceProps) {
|
|
187
|
-
super(props);
|
|
189
|
+
super({...props, id: props.id || uid('webgl-device')});
|
|
188
190
|
|
|
189
191
|
// If attaching to an already attached context, return the attached device
|
|
190
192
|
// @ts-expect-error device is attached to context
|
|
@@ -194,9 +196,10 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
// Create and instrument context
|
|
197
|
-
|
|
199
|
+
const canvas = props.canvas || props.gl?.canvas;
|
|
200
|
+
this.canvasContext = new WebGLCanvasContext(this, {...props, canvas});
|
|
198
201
|
|
|
199
|
-
this.lost = new Promise<{reason: 'destroyed'; message: string}>(
|
|
202
|
+
this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {
|
|
200
203
|
this._resolveContextLost = resolve;
|
|
201
204
|
});
|
|
202
205
|
|
|
@@ -206,10 +209,12 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
206
209
|
message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
207
210
|
});
|
|
208
211
|
|
|
209
|
-
let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl;
|
|
212
|
+
let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl || null;
|
|
210
213
|
gl =
|
|
211
214
|
gl ||
|
|
212
|
-
(isBrowser()
|
|
215
|
+
(isBrowser()
|
|
216
|
+
? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost})
|
|
217
|
+
: null);
|
|
213
218
|
gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);
|
|
214
219
|
|
|
215
220
|
if (!gl) {
|
|
@@ -221,6 +226,7 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
221
226
|
this.gl2 = this.gl as WebGL2RenderingContext;
|
|
222
227
|
this.isWebGL2 = isWebGL2(this.gl);
|
|
223
228
|
this.isWebGL1 = !this.isWebGL2;
|
|
229
|
+
this.canvasContext.resize();
|
|
224
230
|
|
|
225
231
|
// luma Device fields
|
|
226
232
|
this.info = getDeviceInfo(this.gl);
|
|
@@ -256,43 +262,19 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
256
262
|
const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);
|
|
257
263
|
this.spector = initializeSpectorJS({...this.props, canvas});
|
|
258
264
|
}
|
|
259
|
-
|
|
260
|
-
// Log some debug info about the newly created context
|
|
261
|
-
const message = `\
|
|
262
|
-
Created ${this.info.type}${this.debug ? ' debug' : ''} context: \
|
|
263
|
-
${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;
|
|
264
|
-
log.probe(LOG_LEVEL, message)();
|
|
265
|
-
|
|
266
|
-
log.groupEnd(LOG_LEVEL)();
|
|
267
265
|
}
|
|
268
266
|
|
|
269
267
|
/**
|
|
270
268
|
* Destroys the context
|
|
271
269
|
* @note Has no effect for browser contexts, there is no browser API for destroying contexts
|
|
272
270
|
*/
|
|
273
|
-
destroy() {
|
|
271
|
+
destroy(): void {
|
|
274
272
|
const ext = this.gl.getExtension('STACKGL_destroy_context');
|
|
275
273
|
if (ext) {
|
|
276
274
|
ext.destroy();
|
|
277
275
|
}
|
|
278
276
|
}
|
|
279
277
|
|
|
280
|
-
/**
|
|
281
|
-
* Loses the context
|
|
282
|
-
* @note Triggers context loss, mainly for testing
|
|
283
|
-
*/
|
|
284
|
-
loseDevice() {
|
|
285
|
-
const ext = this.gl.getExtension('WEBGL_lose_context');
|
|
286
|
-
if (ext) {
|
|
287
|
-
ext.loseContext();
|
|
288
|
-
}
|
|
289
|
-
// loseContext should trigger context loss callback but
|
|
290
|
-
this._resolveContextLost?.({
|
|
291
|
-
reason: 'destroyed',
|
|
292
|
-
message: 'Application triggered context loss'
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
|
|
296
278
|
get isLost(): boolean {
|
|
297
279
|
return this.gl.isContextLost();
|
|
298
280
|
}
|
|
@@ -329,8 +311,9 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`
|
|
|
329
311
|
throw new Error('WebGL only supports a single canvas');
|
|
330
312
|
}
|
|
331
313
|
|
|
332
|
-
|
|
333
|
-
|
|
314
|
+
createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WEBGLBuffer {
|
|
315
|
+
const newProps = this._getBufferProps(props);
|
|
316
|
+
return new WEBGLBuffer(this, newProps);
|
|
334
317
|
}
|
|
335
318
|
|
|
336
319
|
_createTexture(props: TextureProps): WEBGLTexture {
|
|
@@ -357,6 +340,10 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`
|
|
|
357
340
|
return new WEBGLRenderPipeline(this, props);
|
|
358
341
|
}
|
|
359
342
|
|
|
343
|
+
override createVertexArray(props: VertexArrayProps): VertexArray {
|
|
344
|
+
return new WEBGLVertexArray(this, props);
|
|
345
|
+
}
|
|
346
|
+
|
|
360
347
|
beginRenderPass(props: RenderPassProps): WEBGLRenderPass {
|
|
361
348
|
return new WEBGLRenderPass(this, props);
|
|
362
349
|
}
|
|
@@ -366,7 +353,11 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`
|
|
|
366
353
|
}
|
|
367
354
|
|
|
368
355
|
beginComputePass(props: ComputePassProps): ComputePass {
|
|
369
|
-
throw new Error('
|
|
356
|
+
throw new Error('ComputePass not supported in WebGL');
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback {
|
|
360
|
+
return new WEBGLTransformFeedback(this, props);
|
|
370
361
|
}
|
|
371
362
|
|
|
372
363
|
private renderPass: WEBGLRenderPass | null = null;
|
|
@@ -380,16 +371,195 @@ ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`
|
|
|
380
371
|
return this.renderPass;
|
|
381
372
|
}
|
|
382
373
|
|
|
374
|
+
override createCommandEncoder(props?: CommandEncoderProps): WEBGLCommandEncoder {
|
|
375
|
+
return new WEBGLCommandEncoder(this, props);
|
|
376
|
+
}
|
|
377
|
+
|
|
383
378
|
/**
|
|
384
379
|
* Offscreen Canvas Support: Commit the frame
|
|
385
380
|
* https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit
|
|
386
381
|
* Chrome's offscreen canvas does not require gl.commit
|
|
387
382
|
*/
|
|
388
383
|
submit(): void {
|
|
389
|
-
this.renderPass?.
|
|
384
|
+
this.renderPass?.end();
|
|
390
385
|
this.renderPass = null;
|
|
391
386
|
// this.canvasContext.commit();
|
|
392
387
|
}
|
|
388
|
+
|
|
389
|
+
//
|
|
390
|
+
// TEMPORARY HACKS - will be removed in v9.1
|
|
391
|
+
//
|
|
392
|
+
|
|
393
|
+
/** @deprecated - should use command encoder */
|
|
394
|
+
override readPixelsToArrayWebGL(
|
|
395
|
+
source: Framebuffer | Texture,
|
|
396
|
+
options?: {
|
|
397
|
+
sourceX?: number;
|
|
398
|
+
sourceY?: number;
|
|
399
|
+
sourceFormat?: number;
|
|
400
|
+
sourceAttachment?: number;
|
|
401
|
+
target?: Uint8Array | Uint16Array | Float32Array;
|
|
402
|
+
// following parameters are auto deduced if not provided
|
|
403
|
+
sourceWidth?: number;
|
|
404
|
+
sourceHeight?: number;
|
|
405
|
+
sourceType?: number;
|
|
406
|
+
}
|
|
407
|
+
): Uint8Array | Uint16Array | Float32Array {
|
|
408
|
+
return readPixelsToArray(source, options);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/** @deprecated - should use command encoder */
|
|
412
|
+
override readPixelsToBufferWebGL2(
|
|
413
|
+
source: Framebuffer | Texture,
|
|
414
|
+
options?: {
|
|
415
|
+
sourceX?: number;
|
|
416
|
+
sourceY?: number;
|
|
417
|
+
sourceFormat?: number;
|
|
418
|
+
target?: Buffer; // A new Buffer object is created when not provided.
|
|
419
|
+
targetByteOffset?: number; // byte offset in buffer object
|
|
420
|
+
// following parameters are auto deduced if not provided
|
|
421
|
+
sourceWidth?: number;
|
|
422
|
+
sourceHeight?: number;
|
|
423
|
+
sourceType?: number;
|
|
424
|
+
}
|
|
425
|
+
): Buffer {
|
|
426
|
+
return readPixelsToBuffer(source, options);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
override setParametersWebGL(parameters: any): void {
|
|
430
|
+
setGLParameters(this, parameters);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
override withParametersWebGL(parameters: any, func: any): any {
|
|
434
|
+
withGLParameters(this, parameters, func);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
override clearWebGL(options?: {framebuffer?: Framebuffer; color?: any; depth?: any; stencil?: any}): void {
|
|
438
|
+
clear(this, options);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
//
|
|
442
|
+
// WebGL-only API (not part of `Device` API)
|
|
443
|
+
//
|
|
444
|
+
|
|
445
|
+
/** WebGL1 typed context. Can always be used. */
|
|
446
|
+
readonly gl: WebGLRenderingContext;
|
|
447
|
+
/** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */
|
|
448
|
+
readonly gl2: WebGL2RenderingContext | null = null;
|
|
449
|
+
readonly debug: boolean = false;
|
|
450
|
+
|
|
451
|
+
/** `true` if this is a WebGL1 context. @note `false` if WebGL2 */
|
|
452
|
+
readonly isWebGL1: boolean;
|
|
453
|
+
/** `true` if this is a WebGL2 context. @note `false` if WebGL1 */
|
|
454
|
+
readonly isWebGL2: boolean;
|
|
455
|
+
|
|
456
|
+
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
457
|
+
readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};
|
|
458
|
+
|
|
459
|
+
/** State used by luma.gl classes - TODO - not used? */
|
|
460
|
+
readonly _extensions: Record<string, any> = {};
|
|
461
|
+
_polyfilled: boolean = false;
|
|
462
|
+
|
|
463
|
+
/** Instance of Spector.js (if initialized) */
|
|
464
|
+
spector;
|
|
465
|
+
|
|
466
|
+
private _webglLimits?: WebGLLimits;
|
|
467
|
+
|
|
468
|
+
/** Return WebGL specific limits */
|
|
469
|
+
get webglLimits(): WebGLLimits {
|
|
470
|
+
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
471
|
+
return this._webglLimits;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Triggers device (or WebGL context) loss.
|
|
476
|
+
* @note primarily intended for testing how application reacts to device loss
|
|
477
|
+
*/
|
|
478
|
+
override loseDevice(): boolean {
|
|
479
|
+
let deviceLossTriggered = false;
|
|
480
|
+
const ext = this.gl.getExtension('WEBGL_lose_context');
|
|
481
|
+
if (ext) {
|
|
482
|
+
deviceLossTriggered = true;
|
|
483
|
+
ext.loseContext();
|
|
484
|
+
// ext.loseContext should trigger context loss callback but the platform may not do this, so do it explicitly
|
|
485
|
+
}
|
|
486
|
+
this._resolveContextLost?.({
|
|
487
|
+
reason: 'destroyed',
|
|
488
|
+
message: 'Application triggered context loss'
|
|
489
|
+
});
|
|
490
|
+
return deviceLossTriggered;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** Save current WebGL context state onto an internal stack */
|
|
494
|
+
pushState(): void {
|
|
495
|
+
pushContextState(this.gl);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** Restores previously saved context state */
|
|
499
|
+
popState(): void {
|
|
500
|
+
popContextState(this.gl);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
|
|
505
|
+
* luma.gl ids and props can be inspected
|
|
506
|
+
*/
|
|
507
|
+
setSpectorMetadata(handle: unknown, props: Record<string, unknown>) {
|
|
508
|
+
// @ts-expect-error
|
|
509
|
+
// eslint-disable-next-line camelcase
|
|
510
|
+
handle.__SPECTOR_Metadata = props;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant
|
|
515
|
+
* Be aware that there are some duplicates especially for constants that are 0,
|
|
516
|
+
* so this isn't guaranteed to return the right key in all cases.
|
|
517
|
+
*/
|
|
518
|
+
getGLKey(value: unknown, gl?: WebGLRenderingContext): string {
|
|
519
|
+
// @ts-ignore expect-error depends on settings
|
|
520
|
+
gl = gl || this.gl2 || this.gl;
|
|
521
|
+
const number = Number(value);
|
|
522
|
+
for (const key in gl) {
|
|
523
|
+
// @ts-ignore expect-error depends on settings
|
|
524
|
+
if (gl[key] === number) {
|
|
525
|
+
return `GL.${key}`;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
// No constant found. Stringify the value and return it.
|
|
529
|
+
return String(value);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** Store constants */
|
|
533
|
+
_constants: (TypedArray | null)[];
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Set a constant value for a location. Disabled attributes at that location will read from this value
|
|
537
|
+
* @note WebGL constants are stored globally on the WebGL context, not the VertexArray
|
|
538
|
+
* so they need to be updated before every render
|
|
539
|
+
* @todo - remember/cache values to avoid setting them unnecessarily?
|
|
540
|
+
*/
|
|
541
|
+
setConstantAttribute(location: number, constant: TypedArray): void {
|
|
542
|
+
this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);
|
|
543
|
+
const currentConstant = this._constants[location];
|
|
544
|
+
if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {
|
|
545
|
+
log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();
|
|
546
|
+
}
|
|
547
|
+
this._constants[location] = constant;
|
|
548
|
+
|
|
549
|
+
switch (constant.constructor) {
|
|
550
|
+
case Float32Array:
|
|
551
|
+
setConstantFloatArray(this, location, constant as Float32Array);
|
|
552
|
+
break;
|
|
553
|
+
case Int32Array:
|
|
554
|
+
setConstantIntArray(this, location, constant as Int32Array);
|
|
555
|
+
break;
|
|
556
|
+
case Uint32Array:
|
|
557
|
+
setConstantUintArray(this, location, constant as Uint32Array);
|
|
558
|
+
break;
|
|
559
|
+
default:
|
|
560
|
+
assert(false);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
393
563
|
}
|
|
394
564
|
|
|
395
565
|
/** Check if supplied parameter is a WebGLRenderingContext */
|
|
@@ -412,3 +582,84 @@ function isWebGL2(gl: any): boolean {
|
|
|
412
582
|
// Look for debug contexts, headless gl etc
|
|
413
583
|
return Boolean(gl && gl._version === 2);
|
|
414
584
|
}
|
|
585
|
+
|
|
586
|
+
/** Set constant float array attribute */
|
|
587
|
+
function setConstantFloatArray(device: WebGLDevice, location: number, array: Float32Array): void {
|
|
588
|
+
switch (array.length) {
|
|
589
|
+
case 1:
|
|
590
|
+
device.gl.vertexAttrib1fv(location, array);
|
|
591
|
+
break;
|
|
592
|
+
case 2:
|
|
593
|
+
device.gl.vertexAttrib2fv(location, array);
|
|
594
|
+
break;
|
|
595
|
+
case 3:
|
|
596
|
+
device.gl.vertexAttrib3fv(location, array);
|
|
597
|
+
break;
|
|
598
|
+
case 4:
|
|
599
|
+
device.gl.vertexAttrib4fv(location, array);
|
|
600
|
+
break;
|
|
601
|
+
default:
|
|
602
|
+
assert(false);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** Set constant signed int array attribute */
|
|
607
|
+
function setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {
|
|
608
|
+
device.assertWebGL2();
|
|
609
|
+
device.gl2?.vertexAttribI4iv(location, array);
|
|
610
|
+
// TODO - not clear if we need to use the special forms, more testing needed
|
|
611
|
+
// switch (array.length) {
|
|
612
|
+
// case 1:
|
|
613
|
+
// gl.vertexAttribI1iv(location, array);
|
|
614
|
+
// break;
|
|
615
|
+
// case 2:
|
|
616
|
+
// gl.vertexAttribI2iv(location, array);
|
|
617
|
+
// break;
|
|
618
|
+
// case 3:
|
|
619
|
+
// gl.vertexAttribI3iv(location, array);
|
|
620
|
+
// break;
|
|
621
|
+
// case 4:
|
|
622
|
+
// break;
|
|
623
|
+
// default:
|
|
624
|
+
// assert(false);
|
|
625
|
+
// }
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/** Set constant unsigned int array attribute */
|
|
629
|
+
function setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {
|
|
630
|
+
device.assertWebGL2();
|
|
631
|
+
device.gl2?.vertexAttribI4uiv(location, array);
|
|
632
|
+
// TODO - not clear if we need to use the special forms, more testing needed
|
|
633
|
+
// switch (array.length) {
|
|
634
|
+
// case 1:
|
|
635
|
+
// gl.vertexAttribI1uiv(location, array);
|
|
636
|
+
// break;
|
|
637
|
+
// case 2:
|
|
638
|
+
// gl.vertexAttribI2uiv(location, array);
|
|
639
|
+
// break;
|
|
640
|
+
// case 3:
|
|
641
|
+
// gl.vertexAttribI3uiv(location, array);
|
|
642
|
+
// break;
|
|
643
|
+
// case 4:
|
|
644
|
+
// gl.vertexAttribI4uiv(location, array);
|
|
645
|
+
// break;
|
|
646
|
+
// default:
|
|
647
|
+
// assert(false);
|
|
648
|
+
// }
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Compares contents of two typed arrays
|
|
653
|
+
* @todo max length?
|
|
654
|
+
*/
|
|
655
|
+
function compareConstantArrayValues(v1: TypedArray, v2: TypedArray): boolean {
|
|
656
|
+
if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
for (let i = 0; i < v1.length; ++i) {
|
|
660
|
+
if (v1[i] !== v2[i]) {
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return true;
|
|
665
|
+
}
|
package/src/classic/accessor.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import {assert, checkProps, Buffer, AccessorObject} from '@luma.gl/core';
|
|
5
|
+
import {GL} from '@luma.gl/constants';
|
|
3
6
|
import {getTypedArrayFromGLType} from './typed-array-utils';
|
|
4
7
|
|
|
5
8
|
const DEFAULT_ACCESSOR_VALUES = {
|
|
@@ -19,7 +22,7 @@ const PROP_CHECKS = {
|
|
|
19
22
|
}
|
|
20
23
|
};
|
|
21
24
|
|
|
22
|
-
export
|
|
25
|
+
export class Accessor implements AccessorObject {
|
|
23
26
|
offset?: number;
|
|
24
27
|
stride?: number;
|
|
25
28
|
type?: number;
|
|
@@ -84,8 +87,8 @@ export default class Accessor implements AccessorObject {
|
|
|
84
87
|
this.type = props.type;
|
|
85
88
|
|
|
86
89
|
// Auto-deduce integer type?
|
|
87
|
-
if (props.type === GL.INT || props.type === GL.UNSIGNED_INT) {
|
|
88
|
-
|
|
90
|
+
if ((props.type as GL) === GL.INT || (props.type as GL) === GL.UNSIGNED_INT) {
|
|
91
|
+
this.integer = true;
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
if (props.size !== undefined) {
|