@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,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {TextureFormat, DeviceFeature} from '@luma.gl/core';
|
|
6
|
+
import {decodeTextureFormat} from '@luma.gl/core';
|
|
7
|
+
import {GL, GLExtensions} from '@luma.gl/constants';
|
|
8
|
+
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
9
|
+
import {getGLFromVertexType} from './vertex-formats';
|
|
10
|
+
|
|
11
|
+
/* eslint-disable camelcase */
|
|
5
12
|
|
|
6
13
|
// TEXTURE FEATURES
|
|
7
14
|
|
|
@@ -13,6 +20,16 @@ const texture_compression_etc1_webgl: DeviceFeature = 'texture-compression-etc1-
|
|
|
13
20
|
const texture_compression_pvrtc_webgl: DeviceFeature = 'texture-compression-pvrtc-webgl';
|
|
14
21
|
const texture_compression_atc_webgl: DeviceFeature = 'texture-compression-atc-webgl';
|
|
15
22
|
|
|
23
|
+
const float32_renderable: DeviceFeature = 'float32-renderable-webgl';
|
|
24
|
+
const float16_renderable: DeviceFeature = 'float16-renderable-webgl';
|
|
25
|
+
const rgb9e5ufloat_renderable: DeviceFeature = 'rgb9e5ufloat_renderable-webgl';
|
|
26
|
+
const snorm8_renderable: DeviceFeature = 'snorm8-renderable-webgl';
|
|
27
|
+
const norm16_renderable: DeviceFeature = 'norm16-renderable-webgl';
|
|
28
|
+
const snorm16_renderable: DeviceFeature = 'snorm16-renderable-webgl';
|
|
29
|
+
|
|
30
|
+
const float32_filterable: DeviceFeature = 'float32-filterable';
|
|
31
|
+
const float16_filterable: DeviceFeature = 'float16-filterable-webgl';
|
|
32
|
+
|
|
16
33
|
// Define local webgl extension strings to optimize minification
|
|
17
34
|
const X_S3TC = 'WEBGL_compressed_texture_s3tc'; // BC1, BC2, BC3
|
|
18
35
|
const X_S3TC_SRGB = 'WEBGL_compressed_texture_s3tc_srgb'; // BC1, BC2, BC3
|
|
@@ -25,55 +42,58 @@ const X_PVRTC = 'WEBGL_compressed_texture_pvrtc';
|
|
|
25
42
|
const X_ATC = 'WEBGL_compressed_texture_atc';
|
|
26
43
|
|
|
27
44
|
// Define local webgl extension strings to optimize minification
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const EXT_FLOAT_RENDER_WEBGL2 = 'EXT_color_buffer_float';
|
|
32
|
-
const EXT_HALF_FLOAT_WEBGL1 = 'WEBGL_color_buffer_half_float';
|
|
33
|
-
// const DEPTH = 'WEBGL_depth_texture';
|
|
34
|
-
|
|
35
|
-
const checkExtension = (gl: WebGLRenderingContext, extension: string): boolean =>
|
|
36
|
-
gl.getExtension(extension);
|
|
37
|
-
const checkExtensions = (gl: WebGLRenderingContext, extensions: string[]): boolean =>
|
|
38
|
-
extensions.every((extension) => gl.getExtension(extension));
|
|
45
|
+
const EXT_texture_norm16 = 'EXT_texture_norm16';
|
|
46
|
+
const EXT_render_snorm = 'EXT_render_snorm';
|
|
47
|
+
const EXT_color_buffer_float = 'EXT_color_buffer_float';
|
|
39
48
|
|
|
40
49
|
// prettier-ignore
|
|
41
|
-
const
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
|
|
49
|
-
'
|
|
50
|
-
'
|
|
51
|
-
'texture-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
'texture-compression-
|
|
56
|
-
// 'texture-compression-
|
|
57
|
-
// 'texture-compression-bc3-
|
|
58
|
-
|
|
59
|
-
'texture-compression-
|
|
60
|
-
'texture-compression-
|
|
61
|
-
'texture-compression-
|
|
62
|
-
'texture-compression-
|
|
63
|
-
'texture-compression-
|
|
50
|
+
export const TEXTURE_FEATURES: Partial<Record<DeviceFeature, string[]>> = {
|
|
51
|
+
'float32-renderable-webgl': ['EXT_color_buffer_float'],
|
|
52
|
+
'float16-renderable-webgl': ['EXT_color_buffer_half_float'],
|
|
53
|
+
'rgb9e5ufloat_renderable-webgl': ['WEBGL_render_shared_exponent'],
|
|
54
|
+
'snorm8-renderable-webgl': [EXT_render_snorm],
|
|
55
|
+
'norm16-renderable-webgl': [EXT_texture_norm16],
|
|
56
|
+
'snorm16-renderable-webgl': [EXT_texture_norm16, EXT_render_snorm],
|
|
57
|
+
|
|
58
|
+
'float32-filterable': ['OES_texture_float_linear'],
|
|
59
|
+
'float16-filterable-webgl': ['OES_texture_half_float_linear'],
|
|
60
|
+
'texture-filterable-anisotropic-webgl': ['EXT_texture_filter_anisotropic'],
|
|
61
|
+
|
|
62
|
+
'texture-blend-float-webgl': ['EXT_float_blend'],
|
|
63
|
+
|
|
64
|
+
'texture-compression-bc': [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC],
|
|
65
|
+
// 'texture-compression-bc3-srgb-webgl': [X_S3TC_SRGB],
|
|
66
|
+
// 'texture-compression-bc3-webgl': [X_S3TC],
|
|
67
|
+
'texture-compression-bc5-webgl': [X_RGTC],
|
|
68
|
+
'texture-compression-bc7-webgl': [X_BPTC],
|
|
69
|
+
'texture-compression-etc2': [X_ETC2],
|
|
70
|
+
'texture-compression-astc': [X_ASTC],
|
|
71
|
+
'texture-compression-etc1-webgl': [X_ETC1],
|
|
72
|
+
'texture-compression-pvrtc-webgl': [X_PVRTC],
|
|
73
|
+
'texture-compression-atc-webgl': [X_ATC]
|
|
64
74
|
};
|
|
65
75
|
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
/** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
|
|
77
|
+
// export function getTextureFeatures(
|
|
78
|
+
// gl: WebGL2RenderingContext,
|
|
79
|
+
// extensions: GLExtensions
|
|
80
|
+
// ): DeviceFeature[] {
|
|
81
|
+
// const textureFeatures = Object.keys(TEXTURE_FEATURES) as DeviceFeature[];
|
|
82
|
+
// return textureFeatures.filter(feature => checkTextureFeature(gl, feature, extensions));
|
|
83
|
+
// }
|
|
84
|
+
|
|
85
|
+
export function isTextureFeature(feature: DeviceFeature): boolean {
|
|
86
|
+
return feature in TEXTURE_FEATURES;
|
|
68
87
|
}
|
|
69
88
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
89
|
+
/** Checks a texture feature (for Device.features). Mainly compressed texture support */
|
|
90
|
+
export function checkTextureFeature(
|
|
91
|
+
gl: WebGL2RenderingContext,
|
|
92
|
+
feature: DeviceFeature,
|
|
93
|
+
extensions: GLExtensions
|
|
94
|
+
): boolean {
|
|
95
|
+
const textureExtensions = TEXTURE_FEATURES[feature] || [];
|
|
96
|
+
return textureExtensions.every(extension => getWebGLExtension(gl, extension, extensions));
|
|
77
97
|
}
|
|
78
98
|
|
|
79
99
|
// TEXTURE FORMATS
|
|
@@ -81,106 +101,87 @@ export function getTextureFeatures(gl: WebGLRenderingContext): DeviceFeature[] {
|
|
|
81
101
|
/** Map a format to webgl and constants */
|
|
82
102
|
type Format = {
|
|
83
103
|
gl?: GL;
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
gl1ext?: string;
|
|
87
|
-
gl2ext?: string; // format requires WebGL2, when using a WebGL 1 context, color renderbuffer formats are limited
|
|
104
|
+
/** format requires WebGL2, when using a WebGL 1 context, color renderbuffer formats are limited */
|
|
105
|
+
gl2ext?: string;
|
|
88
106
|
|
|
89
|
-
|
|
107
|
+
/** (bytes per pixel), for memory usage calculations. */
|
|
108
|
+
b?: number;
|
|
90
109
|
/** channels */
|
|
91
110
|
c?: number;
|
|
92
111
|
bpp?: number;
|
|
93
112
|
/** packed */
|
|
94
113
|
p?: number;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
114
|
+
/** compressed */
|
|
115
|
+
x?: string;
|
|
116
|
+
/** for compressed texture formats */
|
|
117
|
+
f?: DeviceFeature;
|
|
118
|
+
/** renderable if feature is present */
|
|
119
|
+
render?: DeviceFeature;
|
|
120
|
+
/** filterable if feature is present */
|
|
98
121
|
filter?: DeviceFeature;
|
|
99
122
|
|
|
100
|
-
|
|
123
|
+
/** If not supported on WebGPU */
|
|
124
|
+
wgpu?: false;
|
|
101
125
|
|
|
102
126
|
types?: number[];
|
|
103
127
|
|
|
104
128
|
dataFormat?: GL;
|
|
129
|
+
/** Depth and stencil format attachment points. If set, needs to be a Renderbuffer unless depthTexture is set */
|
|
105
130
|
attachment?: GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
|
|
131
|
+
/** if depthTexture is set this is a depth/stencil format that can be set to a texture */
|
|
132
|
+
depthTexture?: boolean;
|
|
133
|
+
/** @deprecated can this format be used with renderbuffers */
|
|
134
|
+
rb?: boolean;
|
|
106
135
|
};
|
|
107
136
|
|
|
108
137
|
// TABLES
|
|
109
138
|
|
|
110
|
-
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// R
|
|
115
|
-
[GL.R8]: {dataFormat: GL.RED, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
116
|
-
[GL.R16F]: {dataFormat: GL.RED, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
117
|
-
[GL.R8UI]: {dataFormat: GL.RED_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
118
|
-
// // RG
|
|
119
|
-
[GL.RG8]: {dataFormat: GL.RG, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
120
|
-
[GL.RG16F]: {dataFormat: GL.RG, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
121
|
-
[GL.RG8UI]: {dataFormat: GL.RG_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
122
|
-
// // RGB
|
|
123
|
-
[GL.RGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
124
|
-
[GL.SRGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true, gl1ext: EXT_SRGB},
|
|
125
|
-
[GL.RGB16F]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true, gl1ext: EXT_HALF_FLOAT_WEBGL1},
|
|
126
|
-
[GL.RGB8UI]: {dataFormat: GL.RGB_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
127
|
-
// // RGBA
|
|
128
|
-
|
|
129
|
-
[GL.RGB565]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5], gl2: true},
|
|
130
|
-
[GL.R11F_G11F_B10F]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_INT_10F_11F_11F_REV, GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
131
|
-
[GL.RGB9_E5]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true, gl1ext: EXT_HALF_FLOAT_WEBGL1},
|
|
132
|
-
[GL.RGBA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
133
|
-
[GL.SRGB8_ALPHA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true, gl1ext: EXT_SRGB},
|
|
134
|
-
[GL.RGB5_A1]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_5_5_1], gl2: true},
|
|
135
|
-
[GL.RGBA4]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4], gl2: true},
|
|
136
|
-
[GL.RGBA16F]: {dataFormat: GL.RGBA, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true, gl1ext: EXT_HALF_FLOAT_WEBGL1},
|
|
137
|
-
[GL.RGBA8UI]: {dataFormat: GL.RGBA_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true}
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
/** Texture format data */
|
|
139
|
+
/**
|
|
140
|
+
* Texture format data -
|
|
141
|
+
* Exported but can change without notice
|
|
142
|
+
*/
|
|
141
143
|
// prettier-ignore
|
|
142
144
|
export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
143
|
-
// Unsized formats that leave the precision up to the driver.
|
|
144
|
-
|
|
145
|
-
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
146
|
-
'rgb8unorm-unsized': {gl: GL.RGB, gl1: GL.RGB, b: 4, c: 2, bpp: 4,
|
|
145
|
+
// Unsized formats that leave the precision up to the driver. TODO - Fix bpp constants
|
|
146
|
+
'rgb8unorm-unsized': {gl: GL.RGB, b: 4, c: 2, bpp: 4,
|
|
147
147
|
dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5]},
|
|
148
|
-
'rgba8unorm-unsized': {gl: GL.RGBA,
|
|
148
|
+
'rgba8unorm-unsized': {gl: GL.RGBA, b: 4, c: 2, bpp: 4,
|
|
149
149
|
dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4, GL.UNSIGNED_SHORT_5_5_5_1]},
|
|
150
|
+
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
150
151
|
// 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
151
152
|
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
152
153
|
|
|
153
154
|
// 8-bit formats
|
|
154
|
-
'r8unorm': {gl: GL.R8, b: 1, c: 1},
|
|
155
|
-
'r8snorm': {gl: GL.R8_SNORM, b: 1, c: 1},
|
|
156
|
-
'r8uint': {gl: GL.R8UI, b: 1, c: 1},
|
|
157
|
-
'r8sint': {gl: GL.R8I, b: 1, c: 1},
|
|
155
|
+
'r8unorm': {gl: GL.R8, b: 1, c: 1, rb: true},
|
|
156
|
+
'r8snorm': {gl: GL.R8_SNORM, b: 1, c: 1, render: snorm8_renderable},
|
|
157
|
+
'r8uint': {gl: GL.R8UI, b: 1, c: 1, rb: true},
|
|
158
|
+
'r8sint': {gl: GL.R8I, b: 1, c: 1, rb: true},
|
|
158
159
|
|
|
159
160
|
// 16-bit formats
|
|
160
|
-
'rg8unorm': {gl: GL.RG8, b: 2, c: 2},
|
|
161
|
-
'rg8snorm': {gl: GL.RG8_SNORM, b: 2, c: 2},
|
|
162
|
-
'rg8uint': {gl: GL.RG8UI, b: 2, c: 2},
|
|
163
|
-
'rg8sint': {gl: GL.RG8I, b: 2, c: 2},
|
|
161
|
+
'rg8unorm': {gl: GL.RG8, b: 2, c: 2, rb: true},
|
|
162
|
+
'rg8snorm': {gl: GL.RG8_SNORM, b: 2, c: 2, render: snorm8_renderable},
|
|
163
|
+
'rg8uint': {gl: GL.RG8UI, b: 2, c: 2, rb: true},
|
|
164
|
+
'rg8sint': {gl: GL.RG8I, b: 2, c: 2, rb: true},
|
|
164
165
|
|
|
165
|
-
'r16uint': {gl: GL.R16UI, b: 2, c: 1},
|
|
166
|
-
'r16sint': {gl: GL.R16I, b: 2, c: 1},
|
|
167
|
-
'r16float': {gl: GL.R16F, b: 2, c: 1, render:
|
|
168
|
-
'r16unorm-webgl': {gl: GL.R16_EXT, b:2, c:1, f:
|
|
169
|
-
'r16snorm-webgl': {gl: GL.R16_SNORM_EXT, b:2, c:1, f:
|
|
166
|
+
'r16uint': {gl: GL.R16UI, b: 2, c: 1, rb: true},
|
|
167
|
+
'r16sint': {gl: GL.R16I, b: 2, c: 1, rb: true},
|
|
168
|
+
'r16float': {gl: GL.R16F, b: 2, c: 1, render: float16_renderable, filter: 'float16-filterable-webgl', rb: true},
|
|
169
|
+
'r16unorm-webgl': {gl: GL.R16_EXT, b:2, c:1, f: norm16_renderable, rb: true},
|
|
170
|
+
'r16snorm-webgl': {gl: GL.R16_SNORM_EXT, b:2, c:1, f: snorm16_renderable},
|
|
170
171
|
|
|
171
172
|
// Packed 16-bit formats
|
|
172
|
-
'rgba4unorm-webgl': {gl: GL.RGBA4, b: 2, c: 4, wgpu: false},
|
|
173
|
-
'rgb565unorm-webgl': {gl: GL.RGB565, b: 2, c: 4, wgpu: false},
|
|
174
|
-
'rgb5a1unorm-webgl': {gl: GL.RGB5_A1, b: 2, c: 4, wgpu: false},
|
|
173
|
+
'rgba4unorm-webgl': {gl: GL.RGBA4, b: 2, c: 4, wgpu: false, rb: true},
|
|
174
|
+
'rgb565unorm-webgl': {gl: GL.RGB565, b: 2, c: 4, wgpu: false, rb: true},
|
|
175
|
+
'rgb5a1unorm-webgl': {gl: GL.RGB5_A1, b: 2, c: 4, wgpu: false, rb: true},
|
|
175
176
|
|
|
176
177
|
// 24-bit formats
|
|
177
|
-
'
|
|
178
|
-
'
|
|
178
|
+
'rgb8unorm-webgl': {gl: GL.RGB8, b: 3, c: 3, wgpu: false},
|
|
179
|
+
'rgb8snorm-webgl': {gl: GL.RGB8_SNORM, b: 3, c: 3, wgpu: false},
|
|
179
180
|
|
|
180
181
|
// 32-bit formats
|
|
181
|
-
'rgba8unorm': {gl: GL.RGBA8,
|
|
182
|
-
'rgba8unorm-srgb': {gl: GL.SRGB8_ALPHA8,
|
|
183
|
-
'rgba8snorm': {gl: GL.RGBA8_SNORM, b: 4, c: 4},
|
|
182
|
+
'rgba8unorm': {gl: GL.RGBA8, b: 4, c: 2, bpp: 4},
|
|
183
|
+
'rgba8unorm-srgb': {gl: GL.SRGB8_ALPHA8, b: 4, c: 4, bpp: 4},
|
|
184
|
+
'rgba8snorm': {gl: GL.RGBA8_SNORM, b: 4, c: 4, render: snorm8_renderable},
|
|
184
185
|
'rgba8uint': {gl: GL.RGBA8UI, b: 4, c: 4, bpp: 4},
|
|
185
186
|
'rgba8sint': {gl: GL.RGBA8I, b: 4, c: 4, bpp: 4},
|
|
186
187
|
// reverse colors, webgpu only
|
|
@@ -190,57 +191,62 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
190
191
|
'rg16uint': {gl: GL.RG16UI, b: 4, c: 1, bpp: 4},
|
|
191
192
|
'rg16sint': {gl: GL.RG16I, b: 4, c: 2, bpp: 4},
|
|
192
193
|
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
193
|
-
'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render:
|
|
194
|
-
'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2,
|
|
195
|
-
'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2,
|
|
194
|
+
'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true},
|
|
195
|
+
'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2, render: norm16_renderable},
|
|
196
|
+
'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2, render: snorm16_renderable},
|
|
196
197
|
|
|
197
|
-
'r32uint': {gl: GL.R32UI, b: 4, c: 1, bpp: 4},
|
|
198
|
-
'r32sint': {gl: GL.R32I, b: 4, c: 1, bpp: 4},
|
|
199
|
-
'r32float': {gl: GL.R32F, bpp: 4, b: 4, c: 1, render:
|
|
198
|
+
'r32uint': {gl: GL.R32UI, b: 4, c: 1, bpp: 4, rb: true},
|
|
199
|
+
'r32sint': {gl: GL.R32I, b: 4, c: 1, bpp: 4, rb: true},
|
|
200
|
+
'r32float': {gl: GL.R32F, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable},
|
|
200
201
|
|
|
201
202
|
// Packed 32-bit formats
|
|
202
|
-
'rgb9e5ufloat': {gl: GL.RGB9_E5, b: 4, c: 3, p: 1, render:
|
|
203
|
-
'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, b: 4, c: 3, p: 1,render:
|
|
204
|
-
'rgb10a2unorm': {gl: GL.RGB10_A2, b: 4, c: 4, p: 1},
|
|
205
|
-
|
|
206
|
-
'rgb10a2unorm-webgl': {b: 4, c: 4, gl: GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4},
|
|
203
|
+
'rgb9e5ufloat': {gl: GL.RGB9_E5, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable}, // , filter: true},
|
|
204
|
+
'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, b: 4, c: 3, p: 1,render: float32_renderable, rb: true},
|
|
205
|
+
'rgb10a2unorm': {gl: GL.RGB10_A2, b: 4, c: 4, p: 1, rb: true},
|
|
206
|
+
'rgb10a2uint-webgl': {b: 4, c: 4, gl: GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, rb: true},
|
|
207
207
|
|
|
208
208
|
// 48-bit formats
|
|
209
|
-
'rgb16unorm-webgl': {gl: GL.RGB16_EXT, b:2, c:3, f:
|
|
210
|
-
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, b:2, c:3, f:
|
|
209
|
+
'rgb16unorm-webgl': {gl: GL.RGB16_EXT, b:2, c:3, f: norm16_renderable}, // rgb not renderable
|
|
210
|
+
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, b:2, c:3, f: norm16_renderable}, // rgb not renderable
|
|
211
211
|
|
|
212
212
|
// 64-bit formats
|
|
213
|
-
'rg32uint': {gl: GL.RG32UI, b: 8, c: 2},
|
|
214
|
-
'rg32sint': {gl: GL.RG32I, b: 8, c: 2},
|
|
215
|
-
'rg32float': {gl: GL.RG32F, b: 8, c: 2, render:
|
|
216
|
-
'rgba16uint': {gl: GL.RGBA16UI, b: 8, c: 4},
|
|
217
|
-
'rgba16sint': {gl: GL.RGBA16I, b: 8, c: 4},
|
|
218
|
-
'rgba16float': {gl: GL.RGBA16F,
|
|
219
|
-
'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, b:2, c:4,
|
|
220
|
-
'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT, b:2, c:4,
|
|
213
|
+
'rg32uint': {gl: GL.RG32UI, b: 8, c: 2, rb: true},
|
|
214
|
+
'rg32sint': {gl: GL.RG32I, b: 8, c: 2, rb: true},
|
|
215
|
+
'rg32float': {gl: GL.RG32F, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, rb: true},
|
|
216
|
+
'rgba16uint': {gl: GL.RGBA16UI, b: 8, c: 4, rb: true},
|
|
217
|
+
'rgba16sint': {gl: GL.RGBA16I, b: 8, c: 4, rb: true},
|
|
218
|
+
'rgba16float': {gl: GL.RGBA16F, b: 8, c: 4, render: float16_renderable, filter: float16_filterable},
|
|
219
|
+
'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, b:2, c:4, render: norm16_renderable, rb: true},
|
|
220
|
+
'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT, b:2, c:4, render: snorm16_renderable},
|
|
221
221
|
|
|
222
222
|
// 96-bit formats (deprecated!)
|
|
223
|
-
'rgb32float-webgl': {gl: GL.RGB32F,
|
|
224
|
-
gl2ext:
|
|
225
|
-
dataFormat: GL.RGB, types: [GL.FLOAT]},
|
|
223
|
+
'rgb32float-webgl': {gl: GL.RGB32F, render: float32_renderable, filter: float32_filterable,
|
|
224
|
+
gl2ext: EXT_color_buffer_float, dataFormat: GL.RGB, types: [GL.FLOAT]},
|
|
226
225
|
|
|
227
226
|
// 128-bit formats
|
|
228
|
-
'rgba32uint': {gl: GL.RGBA32UI, b: 16, c: 4},
|
|
229
|
-
'rgba32sint': {gl: GL.RGBA32I, b: 16, c: 4},
|
|
230
|
-
'rgba32float': {gl: GL.RGBA32F,
|
|
227
|
+
'rgba32uint': {gl: GL.RGBA32UI, b: 16, c: 4, rb: true},
|
|
228
|
+
'rgba32sint': {gl: GL.RGBA32I, b: 16, c: 4, rb: true},
|
|
229
|
+
'rgba32float': {gl: GL.RGBA32F, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, rb: true},
|
|
231
230
|
|
|
232
231
|
// Depth and stencil formats
|
|
233
|
-
'stencil8': {gl: GL.STENCIL_INDEX8, b: 1, c: 1, attachment: GL.STENCIL_ATTACHMENT}, // 8 stencil bits
|
|
234
|
-
|
|
235
|
-
'depth16unorm': {gl: GL.DEPTH_COMPONENT16,
|
|
236
|
-
|
|
237
|
-
'
|
|
238
|
-
|
|
239
|
-
'
|
|
232
|
+
'stencil8': {gl: GL.STENCIL_INDEX8, b: 1, c: 1, attachment: GL.STENCIL_ATTACHMENT, rb: true}, // 8 stencil bits
|
|
233
|
+
|
|
234
|
+
'depth16unorm': {gl: GL.DEPTH_COMPONENT16, b: 2, c: 1, attachment: GL.DEPTH_ATTACHMENT,
|
|
235
|
+
dataFormat: GL.DEPTH_COMPONENT, types: [GL.UNSIGNED_SHORT], rb: true}, // 16 depth bits
|
|
236
|
+
'depth24plus': {gl: GL.DEPTH_COMPONENT24, b: 3, c: 1, attachment: GL.DEPTH_ATTACHMENT,
|
|
237
|
+
dataFormat: GL.DEPTH_COMPONENT, types: [GL.UNSIGNED_INT]},
|
|
238
|
+
'depth32float': {gl: GL.DEPTH_COMPONENT32F, b: 4, c: 1, attachment: GL.DEPTH_ATTACHMENT,
|
|
239
|
+
dataFormat: GL.DEPTH_COMPONENT, types: [GL.FLOAT], rb: true},
|
|
240
|
+
|
|
241
|
+
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
242
|
+
'depth24plus-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, rb: true, depthTexture: true,
|
|
243
|
+
dataFormat: GL.DEPTH_STENCIL, types: [GL.UNSIGNED_INT_24_8]},
|
|
240
244
|
// "depth24unorm-stencil8" feature
|
|
241
|
-
'depth24unorm-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT
|
|
242
|
-
|
|
243
|
-
"depth32float-stencil8"
|
|
245
|
+
'depth24unorm-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT,
|
|
246
|
+
dataFormat: GL.DEPTH_STENCIL, types: [GL.UNSIGNED_INT_24_8], rb: true},
|
|
247
|
+
// "depth32float-stencil8" feature - TODO below is render buffer only?
|
|
248
|
+
'depth32float-stencil8': {gl: GL.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT,
|
|
249
|
+
dataFormat: GL.DEPTH_STENCIL, types: [GL.FLOAT_32_UNSIGNED_INT_24_8_REV], rb: true},
|
|
244
250
|
|
|
245
251
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
246
252
|
|
|
@@ -326,48 +332,193 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
326
332
|
'atc-rgbai-unorm-webgl': {gl: GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, f: texture_compression_atc_webgl}
|
|
327
333
|
};
|
|
328
334
|
|
|
329
|
-
|
|
335
|
+
/** Legal combinations for internalFormat, format and type *
|
|
336
|
+
// [GL.DEPTH_COMPONENT]: {types: [GL.UNSIGNED_SHORT, GL.UNSIGNED_INT, GL.UNSIGNED_INT_24_8]},
|
|
337
|
+
// [GL.DEPTH_STENCIL]: ,
|
|
338
|
+
// Sized texture format
|
|
339
|
+
// R
|
|
340
|
+
[GL.R8]: {dataFormat: GL.RED, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
341
|
+
[GL.R16F]: {dataFormat: GL.RED, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
342
|
+
[GL.R8UI]: {dataFormat: GL.RED_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
343
|
+
// // RG
|
|
344
|
+
[GL.RG8]: {dataFormat: GL.RG, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
345
|
+
[GL.RG16F]: {dataFormat: GL.RG, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
346
|
+
[GL.RG8UI]: {dataFormat: GL.RG_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
347
|
+
// // RGB
|
|
348
|
+
[GL.RGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
349
|
+
[GL.SRGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
350
|
+
[GL.RGB16F]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
351
|
+
[GL.RGB8UI]: {dataFormat: GL.RGB_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
352
|
+
// // RGBA
|
|
330
353
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
354
|
+
[GL.RGB565]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5], gl2: true},
|
|
355
|
+
[GL.R11F_G11F_B10F]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_INT_10F_11F_11F_REV, GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
356
|
+
[GL.RGB9_E5]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
357
|
+
[GL.RGBA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
358
|
+
[GL.SRGB8_ALPHA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true, gl1ext: EXT_SRGB},
|
|
359
|
+
[GL.RGB5_A1]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_5_5_1], gl2: true},
|
|
360
|
+
[GL.RGBA4]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4], gl2: true},
|
|
361
|
+
[GL.RGBA16F]: {dataFormat: GL.RGBA, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
362
|
+
[GL.RGBA8UI]: {dataFormat: GL.RGBA_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true}
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
/* This table is now baked into the above table
|
|
366
|
+
type RenderbufferFormat = {
|
|
367
|
+
bpp: number;
|
|
368
|
+
gl2?: boolean;
|
|
369
|
+
ext?: string;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
export const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
|
|
373
|
+
[GL.DEPTH_COMPONENT16]: {bpp: 2}, // 16 depth bits.
|
|
374
|
+
// TODO - Not clear which webgpu value to map this to.
|
|
375
|
+
// [GL.DEPTH_COMPONENT24]: {gl2: true, bpp: 3},
|
|
376
|
+
[GL.DEPTH_COMPONENT32F]: {gl2: true, bpp: 4},
|
|
377
|
+
|
|
378
|
+
[GL.STENCIL_INDEX8]: {bpp: 1}, // 8 stencil bits.
|
|
379
|
+
|
|
380
|
+
[GL.DEPTH_STENCIL]: {bpp: 4},
|
|
381
|
+
[GL.DEPTH24_STENCIL8]: {gl2: true, bpp: 4},
|
|
382
|
+
[GL.DEPTH32F_STENCIL8]: {gl2: true, bpp: 5},
|
|
383
|
+
|
|
384
|
+
// When using a WebGL 1 context, color renderbuffer formats are limited
|
|
385
|
+
[GL.RGBA4]: {gl2: true, bpp: 2},
|
|
386
|
+
[GL.RGB565]: {gl2: true, bpp: 2},
|
|
387
|
+
[GL.RGB5_A1]: {gl2: true, bpp: 2},
|
|
388
|
+
|
|
389
|
+
// When using a WebGL 2 context, the following values are available additionally:
|
|
390
|
+
[GL.R8]: {gl2: true, bpp: 1},
|
|
391
|
+
[GL.R8UI]: {gl2: true, bpp: 1},
|
|
392
|
+
[GL.R8I]: {gl2: true, bpp: 1},
|
|
393
|
+
[GL.R16UI]: {gl2: true, bpp: 2},
|
|
394
|
+
[GL.R16I]: {gl2: true, bpp: 2},
|
|
395
|
+
[GL.R32UI]: {gl2: true, bpp: 4},
|
|
396
|
+
[GL.R32I]: {gl2: true, bpp: 4},
|
|
397
|
+
[GL.RG8]: {gl2: true, bpp: 2},
|
|
398
|
+
[GL.RG8UI]: {gl2: true, bpp: 2},
|
|
399
|
+
[GL.RG8I]: {gl2: true, bpp: 2},
|
|
400
|
+
[GL.RG16UI]: {gl2: true, bpp: 4},
|
|
401
|
+
[GL.RG16I]: {gl2: true, bpp: 4},
|
|
402
|
+
[GL.RG32UI]: {gl2: true, bpp: 8},
|
|
403
|
+
[GL.RG32I]: {gl2: true, bpp: 8},
|
|
404
|
+
[GL.RGB8]: {gl2: true, bpp: 3},
|
|
405
|
+
[GL.RGBA8]: {gl2: true, bpp: 4},
|
|
406
|
+
// [GL.SRGB8_ALPHA8]: {gl2: true, gl1: SRGB}, // When using the EXT_sRGB WebGL1 extension
|
|
407
|
+
[GL.RGB10_A2]: {gl2: true, bpp: 4},
|
|
408
|
+
[GL.RGBA8UI]: {gl2: true, bpp: 4},
|
|
409
|
+
[GL.RGBA8I]: {gl2: true, bpp: 4},
|
|
410
|
+
[GL.RGB10_A2UI]: {gl2: true, bpp: 4},
|
|
411
|
+
[GL.RGBA16UI]: {gl2: true, bpp: 8},
|
|
412
|
+
[GL.RGBA16I]: {gl2: true, bpp: 8},
|
|
413
|
+
[GL.RGBA32I]: {gl2: true, bpp: 16},
|
|
414
|
+
[GL.RGBA32UI]: {gl2: true, bpp: 16},
|
|
415
|
+
|
|
416
|
+
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
417
|
+
[GL.R16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 2},
|
|
418
|
+
[GL.RG16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4},
|
|
419
|
+
[GL.RGBA16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
|
|
420
|
+
[GL.R32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4},
|
|
421
|
+
[GL.RG32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
|
|
422
|
+
// TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
|
|
423
|
+
[GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 16},
|
|
424
|
+
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2},
|
|
425
|
+
[GL.R11F_G11F_B10F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4}
|
|
426
|
+
};
|
|
427
|
+
*/
|
|
428
|
+
|
|
429
|
+
/** @deprecated should be removed */
|
|
430
|
+
const DATA_FORMAT_CHANNELS = {
|
|
431
|
+
[GL.RED]: 1,
|
|
432
|
+
[GL.RED_INTEGER]: 1,
|
|
433
|
+
[GL.RG]: 2,
|
|
434
|
+
[GL.RG_INTEGER]: 2,
|
|
435
|
+
[GL.RGB]: 3,
|
|
436
|
+
[GL.RGB_INTEGER]: 3,
|
|
437
|
+
[GL.RGBA]: 4,
|
|
438
|
+
[GL.RGBA_INTEGER]: 4,
|
|
439
|
+
[GL.DEPTH_COMPONENT]: 1,
|
|
440
|
+
[GL.DEPTH_STENCIL]: 1,
|
|
441
|
+
[GL.ALPHA]: 1,
|
|
442
|
+
[GL.LUMINANCE]: 1,
|
|
443
|
+
[GL.LUMINANCE_ALPHA]: 2
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
/** @deprecated should be removed */
|
|
447
|
+
const TYPE_SIZES = {
|
|
448
|
+
[GL.FLOAT]: 4,
|
|
449
|
+
[GL.UNSIGNED_INT]: 4,
|
|
450
|
+
[GL.INT]: 4,
|
|
451
|
+
[GL.UNSIGNED_SHORT]: 2,
|
|
452
|
+
[GL.SHORT]: 2,
|
|
453
|
+
[GL.HALF_FLOAT]: 2,
|
|
454
|
+
[GL.BYTE]: 1,
|
|
455
|
+
[GL.UNSIGNED_BYTE]: 1
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
// FUNCTIONS
|
|
341
459
|
|
|
342
460
|
/** Checks if a texture format is supported */
|
|
343
461
|
export function isTextureFormatSupported(
|
|
344
|
-
gl:
|
|
345
|
-
|
|
462
|
+
gl: WebGL2RenderingContext,
|
|
463
|
+
format: TextureFormat,
|
|
464
|
+
extensions: GLExtensions
|
|
346
465
|
): boolean {
|
|
347
|
-
const format = getTextureFormat(formatOrGL);
|
|
348
466
|
const info = TEXTURE_FORMATS[format];
|
|
349
467
|
if (!info) {
|
|
350
468
|
return false;
|
|
351
469
|
}
|
|
352
470
|
// Check that we have a GL constant
|
|
353
|
-
if (
|
|
471
|
+
if (info.gl === undefined) {
|
|
354
472
|
return false;
|
|
355
473
|
}
|
|
356
474
|
// Check extensions
|
|
357
|
-
const extension = info.x ||
|
|
475
|
+
const extension = info.x || info.gl2ext;
|
|
358
476
|
if (extension) {
|
|
359
|
-
return Boolean(gl
|
|
477
|
+
return Boolean(getWebGLExtension(gl, extension, extensions));
|
|
360
478
|
}
|
|
361
|
-
// if (info.gl1 === undefined && info.gl2 === undefined) {
|
|
362
|
-
// // No info - always supported
|
|
363
|
-
// }
|
|
364
479
|
return true;
|
|
365
480
|
}
|
|
366
481
|
|
|
482
|
+
export function isRenderbufferFormatSupported(
|
|
483
|
+
gl: WebGL2RenderingContext,
|
|
484
|
+
format: TextureFormat,
|
|
485
|
+
extensions: GLExtensions
|
|
486
|
+
): boolean {
|
|
487
|
+
// Note: Order is important since the function call initializes extensions.
|
|
488
|
+
return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.rb;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
|
|
493
|
+
*/
|
|
494
|
+
export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
|
|
495
|
+
if (typeof format === 'string') {
|
|
496
|
+
return format;
|
|
497
|
+
}
|
|
498
|
+
const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
|
|
499
|
+
if (!entry) {
|
|
500
|
+
throw new Error(`Unknown texture format ${format}`);
|
|
501
|
+
}
|
|
502
|
+
return entry[0] as TextureFormat;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Map WebGPU style texture format strings to GL constants
|
|
507
|
+
*/
|
|
508
|
+
export function convertTextureFormatToGL(format: TextureFormat): GL | undefined {
|
|
509
|
+
const formatInfo = TEXTURE_FORMATS[format];
|
|
510
|
+
const webglFormat = formatInfo?.gl;
|
|
511
|
+
if (webglFormat === undefined) {
|
|
512
|
+
throw new Error(`Unsupported texture format ${format}`);
|
|
513
|
+
}
|
|
514
|
+
return webglFormat;
|
|
515
|
+
}
|
|
516
|
+
|
|
367
517
|
/** Checks if a texture format is supported */
|
|
368
518
|
export function getTextureFormatSupport(
|
|
369
|
-
gl:
|
|
370
|
-
|
|
519
|
+
gl: WebGL2RenderingContext,
|
|
520
|
+
format: TextureFormat,
|
|
521
|
+
extensions: GLExtensions
|
|
371
522
|
): {
|
|
372
523
|
supported: boolean;
|
|
373
524
|
filterable?: boolean;
|
|
@@ -375,32 +526,31 @@ export function getTextureFormatSupport(
|
|
|
375
526
|
blendable?: boolean;
|
|
376
527
|
storable?: boolean;
|
|
377
528
|
} {
|
|
378
|
-
const format = getTextureFormat(formatOrGL);
|
|
379
529
|
const info = TEXTURE_FORMATS[format];
|
|
380
530
|
if (!info) {
|
|
381
531
|
return {supported: false};
|
|
382
532
|
}
|
|
383
|
-
let decoded;
|
|
384
|
-
try {
|
|
385
|
-
|
|
386
|
-
} catch {}
|
|
533
|
+
// let decoded;
|
|
534
|
+
// try {
|
|
535
|
+
// decoded = decodeTextureFormat(format);
|
|
536
|
+
// } catch {}
|
|
387
537
|
|
|
388
538
|
// Support Check that we have a GL constant
|
|
389
|
-
let supported =
|
|
390
|
-
supported = supported &&
|
|
539
|
+
let supported = info.gl === undefined;
|
|
540
|
+
supported = supported && checkTextureFeature(gl, info.f, extensions);
|
|
391
541
|
|
|
392
542
|
// Filtering
|
|
393
|
-
const filterable = info.filter
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const renderable = info.filter
|
|
397
|
-
|
|
398
|
-
|
|
543
|
+
// const filterable = info.filter
|
|
544
|
+
// ? checkTextureFeature(gl, infofilter])
|
|
545
|
+
// : decoded && !decoded.signed;
|
|
546
|
+
// const renderable = info.filter
|
|
547
|
+
// ? checkTextureFeature(gl, inforender])
|
|
548
|
+
// : decoded && !decoded.signed;
|
|
399
549
|
|
|
400
550
|
return {
|
|
401
551
|
supported,
|
|
402
|
-
renderable: supported &&
|
|
403
|
-
filterable: supported &&
|
|
552
|
+
renderable: supported && checkTextureFeature(gl, info.render, extensions),
|
|
553
|
+
filterable: supported && checkTextureFeature(gl, info.filter, extensions),
|
|
404
554
|
blendable: false, // tod,
|
|
405
555
|
storable: false
|
|
406
556
|
};
|
|
@@ -408,11 +558,14 @@ export function getTextureFormatSupport(
|
|
|
408
558
|
|
|
409
559
|
/** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
|
|
410
560
|
export function isTextureFormatFilterable(
|
|
411
|
-
gl:
|
|
412
|
-
|
|
561
|
+
gl: WebGL2RenderingContext,
|
|
562
|
+
format: TextureFormat,
|
|
563
|
+
extensions: GLExtensions
|
|
413
564
|
): boolean {
|
|
414
|
-
|
|
415
|
-
|
|
565
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
568
|
+
if (format.startsWith('depth') || format.startsWith('stencil')) {
|
|
416
569
|
return false;
|
|
417
570
|
}
|
|
418
571
|
try {
|
|
@@ -424,31 +577,20 @@ export function isTextureFormatFilterable(
|
|
|
424
577
|
return false;
|
|
425
578
|
}
|
|
426
579
|
if (format.endsWith('32float')) {
|
|
427
|
-
return Boolean(gl
|
|
580
|
+
return Boolean(getWebGLExtension(gl, 'OES_texture_float_linear, extensions', extensions));
|
|
428
581
|
}
|
|
429
582
|
if (format.endsWith('16float')) {
|
|
430
|
-
return Boolean(gl
|
|
583
|
+
return Boolean(getWebGLExtension(gl, 'OES_texture_half_float_linear, extensions', extensions));
|
|
431
584
|
}
|
|
432
|
-
// if (typeof format === 'string') {
|
|
433
|
-
// if (format === 'rgba32float') {
|
|
434
|
-
// return gl.device.features.has('texture-renderable-rgba32float-webgl');
|
|
435
|
-
// }
|
|
436
|
-
// if (format.endsWith('32float')) {
|
|
437
|
-
// return gl.device.features.has('texture-renderable-float32-webgl');
|
|
438
|
-
// }
|
|
439
|
-
// if (format.endsWith('16float')) {
|
|
440
|
-
// return gl.device.features.has('texture-renderable-float16-webgl');
|
|
441
|
-
// }
|
|
442
|
-
// }
|
|
443
585
|
return true;
|
|
444
586
|
}
|
|
445
587
|
|
|
446
588
|
export function isTextureFormatRenderable(
|
|
447
|
-
gl:
|
|
448
|
-
|
|
589
|
+
gl: WebGL2RenderingContext,
|
|
590
|
+
format: TextureFormat,
|
|
591
|
+
extensions: GLExtensions
|
|
449
592
|
): boolean {
|
|
450
|
-
|
|
451
|
-
if (!isTextureFormatSupported(gl, format)) {
|
|
593
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
452
594
|
return false;
|
|
453
595
|
}
|
|
454
596
|
if (typeof format === 'number') {
|
|
@@ -458,137 +600,39 @@ export function isTextureFormatRenderable(
|
|
|
458
600
|
return true;
|
|
459
601
|
}
|
|
460
602
|
|
|
461
|
-
/**
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
export function getWebGLTextureFormat(gl: WebGLRenderingContext, formatOrGL: TextureFormat | GL): GL | undefined {
|
|
466
|
-
const format = getTextureFormat(formatOrGL);
|
|
467
|
-
const formatInfo = TEXTURE_FORMATS[format];
|
|
468
|
-
const webglFormat = isWebGL2(gl) ? formatInfo?.gl : formatInfo?.gl1;
|
|
469
|
-
// Remap or pass through
|
|
470
|
-
if (typeof format === 'number') {
|
|
471
|
-
return webglFormat || format;
|
|
472
|
-
}
|
|
473
|
-
if (webglFormat === undefined) {
|
|
474
|
-
throw new Error(`Unsupported texture format ${format}`);
|
|
475
|
-
}
|
|
476
|
-
return webglFormat;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
export function getWebGLTextureParameters(gl: WebGLRenderingContext, formatOrGL: TextureFormat | GL) {
|
|
480
|
-
const format = getTextureFormat(formatOrGL);
|
|
481
|
-
const webglFormat = getWebGLTextureFormat(gl, format);
|
|
603
|
+
/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
|
|
604
|
+
export function getWebGLTextureParameters(format: TextureFormat) {
|
|
605
|
+
const formatData = TEXTURE_FORMATS[format];
|
|
606
|
+
const webglFormat = convertTextureFormatToGL(format);
|
|
482
607
|
const decoded = decodeTextureFormat(format);
|
|
483
608
|
return {
|
|
484
609
|
format: webglFormat,
|
|
485
|
-
dataFormat:
|
|
486
|
-
|
|
487
|
-
decoded.integer,
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
610
|
+
dataFormat:
|
|
611
|
+
formatData?.dataFormat ||
|
|
612
|
+
getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
|
|
613
|
+
// depth formats don't have a type
|
|
614
|
+
type: decoded.dataType
|
|
615
|
+
? getGLFromVertexType(decoded.dataType)
|
|
616
|
+
: formatData?.types?.[0] || GL.UNSIGNED_BYTE,
|
|
492
617
|
// @ts-expect-error
|
|
493
618
|
compressed: decoded.compressed
|
|
494
619
|
};
|
|
495
620
|
}
|
|
496
621
|
|
|
497
|
-
export function
|
|
498
|
-
|
|
622
|
+
export function getDepthStencilAttachmentWebGL(
|
|
623
|
+
format: TextureFormat
|
|
499
624
|
): GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT {
|
|
500
|
-
const format = getTextureFormat(formatOrGL);
|
|
501
|
-
if (typeof format === 'number') {
|
|
502
|
-
// TODO
|
|
503
|
-
throw new Error('unsupported depth stencil format')
|
|
504
|
-
}
|
|
505
625
|
const info = TEXTURE_FORMATS[format];
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
throw new Error('not a depth stencil format');
|
|
626
|
+
if (!info?.attachment) {
|
|
627
|
+
throw new Error(`${format} is not a depth stencil format`);
|
|
509
628
|
}
|
|
510
|
-
return attachment;
|
|
629
|
+
return info.attachment;
|
|
511
630
|
}
|
|
512
631
|
|
|
513
|
-
/**
|
|
514
|
-
* function to test if Float 32 bit format texture can be bound as color attachment
|
|
515
|
-
* @todo Generalize to check arbitrary formats?
|
|
516
|
-
*/
|
|
517
|
-
export function _checkFloat32ColorAttachment(
|
|
518
|
-
gl: WebGLRenderingContext,
|
|
519
|
-
internalFormat = gl.RGBA,
|
|
520
|
-
srcFormat = GL.RGBA,
|
|
521
|
-
srcType = GL.UNSIGNED_BYTE
|
|
522
|
-
) {
|
|
523
|
-
let texture: WebGLTexture | null = null;
|
|
524
|
-
let framebuffer: WebGLFramebuffer | null = null;
|
|
525
|
-
try {
|
|
526
|
-
texture = gl.createTexture();
|
|
527
|
-
gl.bindTexture(GL.TEXTURE_2D, texture);
|
|
528
|
-
|
|
529
|
-
const level = 0;
|
|
530
|
-
const width = 1;
|
|
531
|
-
const height = 1;
|
|
532
|
-
const border = 0;
|
|
533
|
-
const pixel = new Uint8Array([0, 0, 255, 255]); // opaque blue
|
|
534
|
-
gl.texImage2D(
|
|
535
|
-
gl.TEXTURE_2D,
|
|
536
|
-
level,
|
|
537
|
-
internalFormat,
|
|
538
|
-
width,
|
|
539
|
-
height,
|
|
540
|
-
border,
|
|
541
|
-
srcFormat,
|
|
542
|
-
srcType,
|
|
543
|
-
pixel
|
|
544
|
-
);
|
|
545
|
-
|
|
546
|
-
framebuffer = gl.createFramebuffer();
|
|
547
|
-
gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer);
|
|
548
|
-
gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0, GL.TEXTURE_2D, texture, 0);
|
|
549
|
-
const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER) === GL.FRAMEBUFFER_COMPLETE;
|
|
550
|
-
|
|
551
|
-
gl.bindTexture(GL.TEXTURE_2D, null);
|
|
552
|
-
return status;
|
|
553
|
-
} finally {
|
|
554
|
-
gl.deleteTexture(texture);
|
|
555
|
-
gl.deleteFramebuffer(framebuffer);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/** @deprecated should be removed */
|
|
560
|
-
const DATA_FORMAT_CHANNELS = {
|
|
561
|
-
[GL.RED]: 1,
|
|
562
|
-
[GL.RED_INTEGER]: 1,
|
|
563
|
-
[GL.RG]: 2,
|
|
564
|
-
[GL.RG_INTEGER]: 2,
|
|
565
|
-
[GL.RGB]: 3,
|
|
566
|
-
[GL.RGB_INTEGER]: 3,
|
|
567
|
-
[GL.RGBA]: 4,
|
|
568
|
-
[GL.RGBA_INTEGER]: 4,
|
|
569
|
-
[GL.DEPTH_COMPONENT]: 1,
|
|
570
|
-
[GL.DEPTH_STENCIL]: 1,
|
|
571
|
-
[GL.ALPHA]: 1,
|
|
572
|
-
[GL.LUMINANCE]: 1,
|
|
573
|
-
[GL.LUMINANCE_ALPHA]: 2
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
/** @deprecated should be removed */
|
|
577
|
-
const TYPE_SIZES = {
|
|
578
|
-
[GL.FLOAT]: 4,
|
|
579
|
-
[GL.UNSIGNED_INT]: 4,
|
|
580
|
-
[GL.INT]: 4,
|
|
581
|
-
[GL.UNSIGNED_SHORT]: 2,
|
|
582
|
-
[GL.SHORT]: 2,
|
|
583
|
-
[GL.HALF_FLOAT]: 2,
|
|
584
|
-
[GL.BYTE]: 1,
|
|
585
|
-
[GL.UNSIGNED_BYTE]: 1
|
|
586
|
-
};
|
|
587
|
-
|
|
588
632
|
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
589
|
-
export function getTextureFormatBytesPerPixel(
|
|
590
|
-
|
|
591
|
-
const params = getWebGLTextureParameters(
|
|
633
|
+
export function getTextureFormatBytesPerPixel(format: TextureFormat): number {
|
|
634
|
+
// TODO remove webgl1 support
|
|
635
|
+
const params = getWebGLTextureParameters(format);
|
|
592
636
|
// NOTE(Tarek): Default to RGBA bytes
|
|
593
637
|
const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
|
|
594
638
|
const channelSize = TYPE_SIZES[params.type] || 1;
|
|
@@ -616,18 +660,3 @@ function getWebGLPixelDataFormat(
|
|
|
616
660
|
default: return GL.RGBA;
|
|
617
661
|
}
|
|
618
662
|
}
|
|
619
|
-
|
|
620
|
-
export function getWebGLDataType(dataType: string): GL {
|
|
621
|
-
// prettier-ignore
|
|
622
|
-
switch (dataType) {
|
|
623
|
-
case 'uint8': return GL.UNSIGNED_BYTE;
|
|
624
|
-
case 'sint8': return GL.BYTE;
|
|
625
|
-
case 'uint16': return GL.UNSIGNED_SHORT;
|
|
626
|
-
case 'sint16': return GL.SHORT;
|
|
627
|
-
case 'uint32': return GL.UNSIGNED_INT;
|
|
628
|
-
case 'sint32': return GL.INT;
|
|
629
|
-
case 'float16': return GL.HALF_FLOAT;
|
|
630
|
-
case 'float32': return GL.FLOAT;
|
|
631
|
-
default: return GL.UNSIGNED_BYTE;
|
|
632
|
-
}
|
|
633
|
-
}
|