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