@luma.gl/webgl 9.0.0-beta.4 → 9.0.0-beta.6
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/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +297 -155
- package/dist/adapter/converters/sampler-parameters.d.ts +0 -4
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +73 -67
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +53 -46
- package/dist/adapter/converters/texture-formats.d.ts +13 -19
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +474 -879
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +53 -61
- package/dist/adapter/device-helpers/device-features.d.ts +2 -5
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +56 -87
- package/dist/adapter/device-helpers/device-limits.d.ts +2 -4
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +88 -83
- package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +79 -63
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.js +86 -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.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +88 -76
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +261 -225
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +47 -37
- package/dist/adapter/helpers/set-uniform.d.ts +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +68 -82
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +78 -93
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +19 -12
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +86 -77
- package/dist/adapter/objects/webgl-resource.d.ts +3 -25
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +102 -146
- package/dist/adapter/resources/webgl-buffer.d.ts +3 -4
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +161 -119
- package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +266 -168
- package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +33 -39
- package/dist/adapter/resources/webgl-external-texture.js +93 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +8 -10
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +167 -137
- 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 +3 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +124 -90
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +15 -6
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +356 -221
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -3
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +43 -33
- package/dist/adapter/resources/webgl-shader.d.ts +12 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +114 -47
- 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 +6 -9
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +615 -695
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +2 -2
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +141 -143
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +229 -157
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +58 -36
- package/dist/adapter/webgl-device.d.ts +34 -40
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +418 -363
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +132 -101
- package/dist/classic/clear.d.ts +2 -2
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +73 -72
- package/dist/classic/copy-and-blit.d.ts +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +175 -175
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +39 -32
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +96 -81
- package/dist/context/context/context-data.d.ts +14 -0
- package/dist/context/context/context-data.d.ts.map +1 -0
- package/dist/context/context/context-data.js +33 -0
- package/dist/context/context/create-browser-context.d.ts +1 -6
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js +62 -49
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +55 -50
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -2
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +104 -77
- 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/{polyfill/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -2
- 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 +3 -3
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +94 -44
- package/dist/context/parameters/webgl-parameter-tables.d.ts +120 -99
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +469 -404
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +19 -14
- 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 +188 -123
- 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 +43 -26
- package/dist/dist.dev.js +3135 -4142
- package/dist/index.cjs +1766 -2717
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +25 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -1
- package/dist.min.js +9 -42
- package/package.json +11 -15
- package/src/adapter/converters/device-parameters.ts +105 -17
- package/src/adapter/converters/sampler-parameters.ts +12 -20
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +138 -185
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +101 -0
- package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +30 -22
- package/src/adapter/device-helpers/webgl-device-limits.ts +53 -0
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +21 -31
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +3 -4
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +3 -2
- package/src/adapter/objects/webgl-renderbuffer.ts +38 -16
- package/src/adapter/objects/webgl-resource.ts +7 -140
- package/src/adapter/resources/webgl-buffer.ts +10 -14
- package/src/adapter/resources/webgl-command-buffer.ts +24 -34
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +5 -5
- package/src/adapter/resources/webgl-framebuffer.ts +38 -34
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +24 -15
- package/src/adapter/resources/webgl-render-pipeline.ts +138 -70
- package/src/adapter/resources/webgl-sampler.ts +7 -10
- package/src/adapter/resources/webgl-shader.ts +65 -11
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +38 -105
- package/src/adapter/resources/webgl-transform-feedback.ts +16 -22
- package/src/adapter/resources/webgl-vertex-array.ts +20 -21
- package/src/adapter/webgl-canvas-context.ts +7 -11
- package/src/adapter/webgl-device.ts +106 -151
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +25 -20
- package/src/classic/copy-and-blit.ts +12 -6
- package/src/classic/format-utils.ts +2 -1
- package/src/classic/typed-array-utils.ts +3 -7
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +31 -20
- package/src/context/{context → helpers}/create-browser-context.ts +9 -33
- package/src/context/{polyfill/context-data.ts → helpers/webgl-context-data.ts} +3 -2
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +5 -4
- package/src/context/parameters/webgl-parameter-tables.ts +118 -90
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +29 -23
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +4 -18
- package/src/types.ts +2 -1
- package/dist/adapter/converters/device-parameters.js.map +0 -1
- package/dist/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/adapter/converters/shader-formats.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.js.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js.map +0 -1
- 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 -9
- package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/adapter/helpers/decode-webgl-types.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/webgl-topology-utils.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/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/resources/webgl-transform-feedback.js.map +0 -1
- package/dist/adapter/resources/webgl-vertex-array.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/classic/accessor.js.map +0 -1
- package/dist/classic/clear.js.map +0 -1
- package/dist/classic/copy-and-blit.js.map +0 -1
- package/dist/classic/format-utils.js.map +0 -1
- package/dist/classic/typed-array-utils.js.map +0 -1
- 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 -42
- package/dist/context/context/create-headless-context.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 -31
- 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/context-data.d.ts.map +0 -1
- package/dist/context/polyfill/context-data.js +0 -12
- package/dist/context/polyfill/context-data.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 -85
- 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 -87
- 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 -137
- 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 -265
- 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/index.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/adapter/device-helpers/device-features.ts +0 -161
- package/src/adapter/device-helpers/device-limits.ts +0 -155
- package/src/adapter/device-helpers/is-old-ie.ts +0 -14
- package/src/context/context/create-headless-context.ts +0 -51
- package/src/context/context/webgl-checks.ts +0 -51
- package/src/context/polyfill/get-parameter-polyfill.ts +0 -122
- package/src/context/polyfill/polyfill-context.ts +0 -104
- package/src/context/polyfill/polyfill-table.ts +0 -167
- package/src/context/polyfill/polyfill-vertex-array-object.ts +0 -365
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {TextureFormat, DeviceFeature} from '@luma.gl/core';
|
|
5
6
|
import {decodeTextureFormat} from '@luma.gl/core';
|
|
6
|
-
import {GL} from '@luma.gl/constants';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import {GL, GLExtensions} from '@luma.gl/constants';
|
|
8
|
+
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
9
|
+
import {getGLFromVertexType} from './vertex-formats';
|
|
9
10
|
|
|
10
11
|
/* eslint-disable camelcase */
|
|
11
12
|
|
|
@@ -19,6 +20,16 @@ const texture_compression_etc1_webgl: DeviceFeature = 'texture-compression-etc1-
|
|
|
19
20
|
const texture_compression_pvrtc_webgl: DeviceFeature = 'texture-compression-pvrtc-webgl';
|
|
20
21
|
const texture_compression_atc_webgl: DeviceFeature = 'texture-compression-atc-webgl';
|
|
21
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
|
+
|
|
22
33
|
// Define local webgl extension strings to optimize minification
|
|
23
34
|
const X_S3TC = 'WEBGL_compressed_texture_s3tc'; // BC1, BC2, BC3
|
|
24
35
|
const X_S3TC_SRGB = 'WEBGL_compressed_texture_s3tc_srgb'; // BC1, BC2, BC3
|
|
@@ -31,55 +42,58 @@ const X_PVRTC = 'WEBGL_compressed_texture_pvrtc';
|
|
|
31
42
|
const X_ATC = 'WEBGL_compressed_texture_atc';
|
|
32
43
|
|
|
33
44
|
// Define local webgl extension strings to optimize minification
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const EXT_FLOAT_RENDER_WEBGL2 = 'EXT_color_buffer_float';
|
|
38
|
-
// const EXT_HALF_FLOAT_WEBGL1 = 'EXT_color_buffer_half_float';
|
|
39
|
-
// const DEPTH = 'WEBGL_depth_texture';
|
|
40
|
-
|
|
41
|
-
const checkExtension = (gl: WebGLRenderingContext, extension: string): boolean =>
|
|
42
|
-
gl.getExtension(extension);
|
|
43
|
-
const checkExtensions = (gl: WebGLRenderingContext, extensions: string[]): boolean =>
|
|
44
|
-
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';
|
|
45
48
|
|
|
46
49
|
// prettier-ignore
|
|
47
|
-
const
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
51
|
-
'
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'texture-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'texture-compression-
|
|
62
|
-
// 'texture-compression-
|
|
63
|
-
// 'texture-compression-bc3-
|
|
64
|
-
|
|
65
|
-
'texture-compression-
|
|
66
|
-
'texture-compression-
|
|
67
|
-
'texture-compression-
|
|
68
|
-
'texture-compression-
|
|
69
|
-
'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]
|
|
70
74
|
};
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
|
|
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;
|
|
74
87
|
}
|
|
75
88
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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));
|
|
83
97
|
}
|
|
84
98
|
|
|
85
99
|
// TEXTURE FORMATS
|
|
@@ -87,9 +101,6 @@ export function getTextureFeatures(gl: WebGLRenderingContext): DeviceFeature[] {
|
|
|
87
101
|
/** Map a format to webgl and constants */
|
|
88
102
|
type Format = {
|
|
89
103
|
gl?: GL;
|
|
90
|
-
/** If a different unsized format is needed in WebGL1 */
|
|
91
|
-
gl1?: GL;
|
|
92
|
-
gl1ext?: string;
|
|
93
104
|
/** format requires WebGL2, when using a WebGL 1 context, color renderbuffer formats are limited */
|
|
94
105
|
gl2ext?: string;
|
|
95
106
|
|
|
@@ -120,12 +131,12 @@ type Format = {
|
|
|
120
131
|
/** if depthTexture is set this is a depth/stencil format that can be set to a texture */
|
|
121
132
|
depthTexture?: boolean;
|
|
122
133
|
|
|
123
|
-
renderbuffer?: boolean
|
|
134
|
+
renderbuffer?: boolean;
|
|
124
135
|
};
|
|
125
136
|
|
|
126
137
|
// TABLES
|
|
127
138
|
|
|
128
|
-
/**
|
|
139
|
+
/**
|
|
129
140
|
* Texture format data -
|
|
130
141
|
* Exported but can change without notice
|
|
131
142
|
*/
|
|
@@ -134,30 +145,30 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
134
145
|
// Unsized formats that leave the precision up to the driver.
|
|
135
146
|
// TODO - Fix bpp constants
|
|
136
147
|
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
137
|
-
'rgb8unorm-unsized': {gl: GL.RGB,
|
|
148
|
+
'rgb8unorm-unsized': {gl: GL.RGB, b: 4, c: 2, bpp: 4,
|
|
138
149
|
dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5]},
|
|
139
|
-
'rgba8unorm-unsized': {gl: GL.RGBA,
|
|
150
|
+
'rgba8unorm-unsized': {gl: GL.RGBA, b: 4, c: 2, bpp: 4,
|
|
140
151
|
dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4, GL.UNSIGNED_SHORT_5_5_5_1]},
|
|
141
152
|
// 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
142
153
|
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
143
154
|
|
|
144
155
|
// 8-bit formats
|
|
145
156
|
'r8unorm': {gl: GL.R8, b: 1, c: 1, renderbuffer: true},
|
|
146
|
-
'r8snorm': {gl: GL.R8_SNORM, b: 1, c: 1},
|
|
157
|
+
'r8snorm': {gl: GL.R8_SNORM, b: 1, c: 1, render: snorm8_renderable},
|
|
147
158
|
'r8uint': {gl: GL.R8UI, b: 1, c: 1, renderbuffer: true},
|
|
148
159
|
'r8sint': {gl: GL.R8I, b: 1, c: 1, renderbuffer: true},
|
|
149
160
|
|
|
150
161
|
// 16-bit formats
|
|
151
162
|
'rg8unorm': {gl: GL.RG8, b: 2, c: 2, renderbuffer: true},
|
|
152
|
-
'rg8snorm': {gl: GL.RG8_SNORM, b: 2, c: 2},
|
|
163
|
+
'rg8snorm': {gl: GL.RG8_SNORM, b: 2, c: 2, render: snorm8_renderable},
|
|
153
164
|
'rg8uint': {gl: GL.RG8UI, b: 2, c: 2, renderbuffer: true},
|
|
154
165
|
'rg8sint': {gl: GL.RG8I, b: 2, c: 2, renderbuffer: true},
|
|
155
166
|
|
|
156
167
|
'r16uint': {gl: GL.R16UI, b: 2, c: 1, renderbuffer: true},
|
|
157
168
|
'r16sint': {gl: GL.R16I, b: 2, c: 1, renderbuffer: true},
|
|
158
|
-
'r16float': {gl: GL.R16F, b: 2, c: 1, render:
|
|
159
|
-
'r16unorm-webgl': {gl: GL.R16_EXT, b:2, c:1, f:
|
|
160
|
-
'r16snorm-webgl': {gl: GL.R16_SNORM_EXT, b:2, c:1, f:
|
|
169
|
+
'r16float': {gl: GL.R16F, b: 2, c: 1, render: float16_renderable, filter: 'float16-filterable-webgl', renderbuffer: true},
|
|
170
|
+
'r16unorm-webgl': {gl: GL.R16_EXT, b:2, c:1, f: norm16_renderable, renderbuffer: true},
|
|
171
|
+
'r16snorm-webgl': {gl: GL.R16_SNORM_EXT, b:2, c:1, f: snorm16_renderable},
|
|
161
172
|
|
|
162
173
|
// Packed 16-bit formats
|
|
163
174
|
'rgba4unorm-webgl': {gl: GL.RGBA4, b: 2, c: 4, wgpu: false, renderbuffer: true},
|
|
@@ -169,9 +180,9 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
169
180
|
'rgb8snorm-webgl': {gl: GL.RGB8_SNORM, b: 3, c: 3, wgpu: false},
|
|
170
181
|
|
|
171
182
|
// 32-bit formats
|
|
172
|
-
'rgba8unorm': {gl: GL.RGBA8,
|
|
173
|
-
'rgba8unorm-srgb': {gl: GL.SRGB8_ALPHA8,
|
|
174
|
-
'rgba8snorm': {gl: GL.RGBA8_SNORM, b: 4, c: 4},
|
|
183
|
+
'rgba8unorm': {gl: GL.RGBA8, b: 4, c: 2, bpp: 4},
|
|
184
|
+
'rgba8unorm-srgb': {gl: GL.SRGB8_ALPHA8, b: 4, c: 4, bpp: 4},
|
|
185
|
+
'rgba8snorm': {gl: GL.RGBA8_SNORM, b: 4, c: 4, render: snorm8_renderable},
|
|
175
186
|
'rgba8uint': {gl: GL.RGBA8UI, b: 4, c: 4, bpp: 4},
|
|
176
187
|
'rgba8sint': {gl: GL.RGBA8I, b: 4, c: 4, bpp: 4},
|
|
177
188
|
// reverse colors, webgpu only
|
|
@@ -181,54 +192,52 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
181
192
|
'rg16uint': {gl: GL.RG16UI, b: 4, c: 1, bpp: 4},
|
|
182
193
|
'rg16sint': {gl: GL.RG16I, b: 4, c: 2, bpp: 4},
|
|
183
194
|
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
184
|
-
'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render:
|
|
185
|
-
'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2,
|
|
186
|
-
'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2,
|
|
195
|
+
'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, renderbuffer: true},
|
|
196
|
+
'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2, render: norm16_renderable},
|
|
197
|
+
'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2, render: snorm16_renderable},
|
|
187
198
|
|
|
188
199
|
'r32uint': {gl: GL.R32UI, b: 4, c: 1, bpp: 4, renderbuffer: true},
|
|
189
200
|
'r32sint': {gl: GL.R32I, b: 4, c: 1, bpp: 4, renderbuffer: true},
|
|
190
|
-
'r32float': {gl: GL.R32F, bpp: 4, b: 4, c: 1, render:
|
|
201
|
+
'r32float': {gl: GL.R32F, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable},
|
|
191
202
|
|
|
192
203
|
// Packed 32-bit formats
|
|
193
|
-
'rgb9e5ufloat': {gl: GL.RGB9_E5, b: 4, c: 3, p: 1, render:
|
|
194
|
-
'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, b: 4, c: 3, p: 1,render:
|
|
204
|
+
'rgb9e5ufloat': {gl: GL.RGB9_E5, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable}, // , filter: true},
|
|
205
|
+
'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, b: 4, c: 3, p: 1,render: float32_renderable, renderbuffer: true},
|
|
195
206
|
'rgb10a2unorm': {gl: GL.RGB10_A2, b: 4, c: 4, p: 1, renderbuffer: true},
|
|
196
|
-
|
|
197
|
-
'rgb10a2unorm-webgl': {b: 4, c: 4, gl: GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true},
|
|
207
|
+
'rgb10a2uint-webgl': {b: 4, c: 4, gl: GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true},
|
|
198
208
|
|
|
199
209
|
// 48-bit formats
|
|
200
|
-
'rgb16unorm-webgl': {gl: GL.RGB16_EXT, b:2, c:3, f:
|
|
201
|
-
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, b:2, c:3, f:
|
|
210
|
+
'rgb16unorm-webgl': {gl: GL.RGB16_EXT, b:2, c:3, f: norm16_renderable}, // rgb not renderable
|
|
211
|
+
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, b:2, c:3, f: norm16_renderable}, // rgb not renderable
|
|
202
212
|
|
|
203
213
|
// 64-bit formats
|
|
204
214
|
'rg32uint': {gl: GL.RG32UI, b: 8, c: 2, renderbuffer: true},
|
|
205
215
|
'rg32sint': {gl: GL.RG32I, b: 8, c: 2, renderbuffer: true},
|
|
206
|
-
'rg32float': {gl: GL.RG32F, b: 8, c: 2, render:
|
|
216
|
+
'rg32float': {gl: GL.RG32F, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, renderbuffer: true},
|
|
207
217
|
'rgba16uint': {gl: GL.RGBA16UI, b: 8, c: 4, renderbuffer: true},
|
|
208
218
|
'rgba16sint': {gl: GL.RGBA16I, b: 8, c: 4, renderbuffer: true},
|
|
209
|
-
'rgba16float': {gl: GL.RGBA16F,
|
|
210
|
-
'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, b:2, c:4,
|
|
211
|
-
'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT, b:2, c:4,
|
|
219
|
+
'rgba16float': {gl: GL.RGBA16F, b: 8, c: 4, render: float16_renderable, filter: float16_filterable},
|
|
220
|
+
'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, b:2, c:4, render: norm16_renderable, renderbuffer: true},
|
|
221
|
+
'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT, b:2, c:4, render: snorm16_renderable},
|
|
212
222
|
|
|
213
223
|
// 96-bit formats (deprecated!)
|
|
214
|
-
'rgb32float-webgl': {gl: GL.RGB32F,
|
|
215
|
-
gl2ext:
|
|
216
|
-
dataFormat: GL.RGB, types: [GL.FLOAT]},
|
|
224
|
+
'rgb32float-webgl': {gl: GL.RGB32F, render: float32_renderable, filter: float32_filterable,
|
|
225
|
+
gl2ext: EXT_color_buffer_float, dataFormat: GL.RGB, types: [GL.FLOAT]},
|
|
217
226
|
|
|
218
227
|
// 128-bit formats
|
|
219
228
|
'rgba32uint': {gl: GL.RGBA32UI, b: 16, c: 4, renderbuffer: true},
|
|
220
229
|
'rgba32sint': {gl: GL.RGBA32I, b: 16, c: 4, renderbuffer: true},
|
|
221
|
-
'rgba32float': {gl: GL.RGBA32F, b: 16, c: 4, render:
|
|
230
|
+
'rgba32float': {gl: GL.RGBA32F, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, renderbuffer: true},
|
|
222
231
|
|
|
223
232
|
// Depth and stencil formats
|
|
224
|
-
'stencil8': {gl: GL.STENCIL_INDEX8,
|
|
233
|
+
'stencil8': {gl: GL.STENCIL_INDEX8, b: 1, c: 1, attachment: GL.STENCIL_ATTACHMENT, renderbuffer: true}, // 8 stencil bits
|
|
225
234
|
|
|
226
|
-
'depth16unorm': {gl: GL.DEPTH_COMPONENT16,
|
|
235
|
+
'depth16unorm': {gl: GL.DEPTH_COMPONENT16, b: 2, c: 1, attachment: GL.DEPTH_ATTACHMENT, renderbuffer: true}, // 16 depth bits
|
|
227
236
|
'depth24plus': {gl: GL.DEPTH_COMPONENT24, b: 3, c: 1, attachment: GL.DEPTH_ATTACHMENT},
|
|
228
237
|
'depth32float': {gl: GL.DEPTH_COMPONENT32F, b: 4, c: 1, attachment: GL.DEPTH_ATTACHMENT, renderbuffer: true},
|
|
229
238
|
|
|
230
239
|
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
231
|
-
'depth24plus-stencil8': {gl: GL.DEPTH_STENCIL,
|
|
240
|
+
'depth24plus-stencil8': {gl: GL.DEPTH_STENCIL, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true, depthTexture: true},
|
|
232
241
|
// "depth24unorm-stencil8" feature
|
|
233
242
|
'depth24unorm-stencil8': {gl: GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true},
|
|
234
243
|
// "depth32float-stencil8" feature
|
|
@@ -319,8 +328,8 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
319
328
|
};
|
|
320
329
|
|
|
321
330
|
/** Legal combinations for internalFormat, format and type *
|
|
322
|
-
// [GL.DEPTH_COMPONENT]: {types: [GL.UNSIGNED_SHORT, GL.UNSIGNED_INT, GL.UNSIGNED_INT_24_8]
|
|
323
|
-
// [GL.DEPTH_STENCIL]:
|
|
331
|
+
// [GL.DEPTH_COMPONENT]: {types: [GL.UNSIGNED_SHORT, GL.UNSIGNED_INT, GL.UNSIGNED_INT_24_8]},
|
|
332
|
+
// [GL.DEPTH_STENCIL]: ,
|
|
324
333
|
// Sized texture format
|
|
325
334
|
// R
|
|
326
335
|
[GL.R8]: {dataFormat: GL.RED, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
@@ -332,19 +341,19 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
332
341
|
[GL.RG8UI]: {dataFormat: GL.RG_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
333
342
|
// // RGB
|
|
334
343
|
[GL.RGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
335
|
-
[GL.SRGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true
|
|
336
|
-
[GL.RGB16F]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true
|
|
344
|
+
[GL.SRGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
345
|
+
[GL.RGB16F]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
337
346
|
[GL.RGB8UI]: {dataFormat: GL.RGB_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
338
347
|
// // RGBA
|
|
339
348
|
|
|
340
349
|
[GL.RGB565]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5], gl2: true},
|
|
341
350
|
[GL.R11F_G11F_B10F]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_INT_10F_11F_11F_REV, GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
342
|
-
[GL.RGB9_E5]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true
|
|
351
|
+
[GL.RGB9_E5]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
343
352
|
[GL.RGBA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
344
353
|
[GL.SRGB8_ALPHA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true, gl1ext: EXT_SRGB},
|
|
345
354
|
[GL.RGB5_A1]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_5_5_1], gl2: true},
|
|
346
355
|
[GL.RGBA4]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4], gl2: true},
|
|
347
|
-
[GL.RGBA16F]: {dataFormat: GL.RGBA, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true
|
|
356
|
+
[GL.RGBA16F]: {dataFormat: GL.RGBA, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
348
357
|
[GL.RGBA8UI]: {dataFormat: GL.RGBA_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true}
|
|
349
358
|
*/
|
|
350
359
|
|
|
@@ -407,7 +416,7 @@ export const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
|
|
|
407
416
|
[GL.RG32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
|
|
408
417
|
// TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
|
|
409
418
|
[GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 16},
|
|
410
|
-
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2
|
|
419
|
+
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2},
|
|
411
420
|
[GL.R11F_G11F_B10F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4}
|
|
412
421
|
};
|
|
413
422
|
*/
|
|
@@ -445,8 +454,9 @@ const TYPE_SIZES = {
|
|
|
445
454
|
|
|
446
455
|
/** Checks if a texture format is supported */
|
|
447
456
|
export function isTextureFormatSupported(
|
|
448
|
-
gl:
|
|
449
|
-
formatOrGL: TextureFormat | GL
|
|
457
|
+
gl: WebGL2RenderingContext,
|
|
458
|
+
formatOrGL: TextureFormat | GL,
|
|
459
|
+
extensions: GLExtensions
|
|
450
460
|
): boolean {
|
|
451
461
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
452
462
|
const info = TEXTURE_FORMATS[format];
|
|
@@ -454,23 +464,24 @@ export function isTextureFormatSupported(
|
|
|
454
464
|
return false;
|
|
455
465
|
}
|
|
456
466
|
// Check that we have a GL constant
|
|
457
|
-
if (
|
|
467
|
+
if (info.gl === undefined) {
|
|
458
468
|
return false;
|
|
459
469
|
}
|
|
460
470
|
// Check extensions
|
|
461
|
-
const extension = info.x ||
|
|
471
|
+
const extension = info.x || info.gl2ext;
|
|
462
472
|
if (extension) {
|
|
463
|
-
return Boolean(gl
|
|
473
|
+
return Boolean(getWebGLExtension(gl, extension, extensions));
|
|
464
474
|
}
|
|
465
|
-
// if (info.gl1 === undefined && info.gl2 === undefined) {
|
|
466
|
-
// // No info - always supported
|
|
467
|
-
// }
|
|
468
475
|
return true;
|
|
469
476
|
}
|
|
470
477
|
|
|
471
|
-
export function isRenderbufferFormatSupported(
|
|
478
|
+
export function isRenderbufferFormatSupported(
|
|
479
|
+
gl: WebGL2RenderingContext,
|
|
480
|
+
format: TextureFormat,
|
|
481
|
+
extensions: GLExtensions
|
|
482
|
+
): boolean {
|
|
472
483
|
// Note: Order is important since the function call initializes extensions.
|
|
473
|
-
return isTextureFormatSupported(gl, format) && TEXTURE_FORMATS[format]?.renderbuffer;
|
|
484
|
+
return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.renderbuffer;
|
|
474
485
|
}
|
|
475
486
|
|
|
476
487
|
/**
|
|
@@ -480,9 +491,7 @@ export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFor
|
|
|
480
491
|
if (typeof format === 'string') {
|
|
481
492
|
return format;
|
|
482
493
|
}
|
|
483
|
-
const entry = Object.entries(TEXTURE_FORMATS).find(
|
|
484
|
-
([, entry]) => entry.gl === format || entry.gl1 === format
|
|
485
|
-
);
|
|
494
|
+
const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
|
|
486
495
|
if (!entry) {
|
|
487
496
|
throw new Error(`Unknown texture format ${format}`);
|
|
488
497
|
}
|
|
@@ -492,9 +501,9 @@ export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFor
|
|
|
492
501
|
/**
|
|
493
502
|
* Map WebGPU style texture format strings to GL constants
|
|
494
503
|
*/
|
|
495
|
-
export function convertTextureFormatToGL(format: TextureFormat
|
|
504
|
+
export function convertTextureFormatToGL(format: TextureFormat): GL | undefined {
|
|
496
505
|
const formatInfo = TEXTURE_FORMATS[format];
|
|
497
|
-
const webglFormat =
|
|
506
|
+
const webglFormat = formatInfo?.gl;
|
|
498
507
|
if (webglFormat === undefined) {
|
|
499
508
|
throw new Error(`Unsupported texture format ${format}`);
|
|
500
509
|
}
|
|
@@ -503,8 +512,9 @@ export function convertTextureFormatToGL(format: TextureFormat, isWebGL2: boolea
|
|
|
503
512
|
|
|
504
513
|
/** Checks if a texture format is supported */
|
|
505
514
|
export function getTextureFormatSupport(
|
|
506
|
-
gl:
|
|
507
|
-
formatOrGL: TextureFormat | GL
|
|
515
|
+
gl: WebGL2RenderingContext,
|
|
516
|
+
formatOrGL: TextureFormat | GL,
|
|
517
|
+
extensions: GLExtensions
|
|
508
518
|
): {
|
|
509
519
|
supported: boolean;
|
|
510
520
|
filterable?: boolean;
|
|
@@ -523,21 +533,21 @@ export function getTextureFormatSupport(
|
|
|
523
533
|
// } catch {}
|
|
524
534
|
|
|
525
535
|
// Support Check that we have a GL constant
|
|
526
|
-
let supported =
|
|
527
|
-
supported = supported &&
|
|
536
|
+
let supported = info.gl === undefined;
|
|
537
|
+
supported = supported && checkTextureFeature(gl, info.f, extensions);
|
|
528
538
|
|
|
529
539
|
// Filtering
|
|
530
540
|
// const filterable = info.filter
|
|
531
|
-
// ?
|
|
541
|
+
// ? checkTextureFeature(gl, infofilter])
|
|
532
542
|
// : decoded && !decoded.signed;
|
|
533
543
|
// const renderable = info.filter
|
|
534
|
-
// ?
|
|
544
|
+
// ? checkTextureFeature(gl, inforender])
|
|
535
545
|
// : decoded && !decoded.signed;
|
|
536
546
|
|
|
537
547
|
return {
|
|
538
548
|
supported,
|
|
539
|
-
renderable: supported &&
|
|
540
|
-
filterable: supported &&
|
|
549
|
+
renderable: supported && checkTextureFeature(gl, info.render, extensions),
|
|
550
|
+
filterable: supported && checkTextureFeature(gl, info.filter, extensions),
|
|
541
551
|
blendable: false, // tod,
|
|
542
552
|
storable: false
|
|
543
553
|
};
|
|
@@ -545,11 +555,12 @@ export function getTextureFormatSupport(
|
|
|
545
555
|
|
|
546
556
|
/** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
|
|
547
557
|
export function isTextureFormatFilterable(
|
|
548
|
-
gl:
|
|
549
|
-
formatOrGL: TextureFormat | GL
|
|
558
|
+
gl: WebGL2RenderingContext,
|
|
559
|
+
formatOrGL: TextureFormat | GL,
|
|
560
|
+
extensions: GLExtensions
|
|
550
561
|
): boolean {
|
|
551
562
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
552
|
-
if (!isTextureFormatSupported(gl, format)) {
|
|
563
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
553
564
|
return false;
|
|
554
565
|
}
|
|
555
566
|
try {
|
|
@@ -561,31 +572,21 @@ export function isTextureFormatFilterable(
|
|
|
561
572
|
return false;
|
|
562
573
|
}
|
|
563
574
|
if (format.endsWith('32float')) {
|
|
564
|
-
return Boolean(gl
|
|
575
|
+
return Boolean(getWebGLExtension(gl, 'OES_texture_float_linear, extensions', extensions));
|
|
565
576
|
}
|
|
566
577
|
if (format.endsWith('16float')) {
|
|
567
|
-
return Boolean(gl
|
|
578
|
+
return Boolean(getWebGLExtension(gl, 'OES_texture_half_float_linear, extensions', extensions));
|
|
568
579
|
}
|
|
569
|
-
// if (typeof format === 'string') {
|
|
570
|
-
// if (format === 'rgba32float') {
|
|
571
|
-
// return gl.device.features.has('texture-renderable-rgba32float-webgl');
|
|
572
|
-
// }
|
|
573
|
-
// if (format.endsWith('32float')) {
|
|
574
|
-
// return gl.device.features.has('texture-renderable-float32-webgl');
|
|
575
|
-
// }
|
|
576
|
-
// if (format.endsWith('16float')) {
|
|
577
|
-
// return gl.device.features.has('texture-renderable-float16-webgl');
|
|
578
|
-
// }
|
|
579
|
-
// }
|
|
580
580
|
return true;
|
|
581
581
|
}
|
|
582
582
|
|
|
583
583
|
export function isTextureFormatRenderable(
|
|
584
|
-
gl:
|
|
585
|
-
formatOrGL: TextureFormat | GL
|
|
584
|
+
gl: WebGL2RenderingContext,
|
|
585
|
+
formatOrGL: TextureFormat | GL,
|
|
586
|
+
extensions: GLExtensions
|
|
586
587
|
): boolean {
|
|
587
588
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
588
|
-
if (!isTextureFormatSupported(gl, format)) {
|
|
589
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
589
590
|
return false;
|
|
590
591
|
}
|
|
591
592
|
if (typeof format === 'number') {
|
|
@@ -595,9 +596,9 @@ export function isTextureFormatRenderable(
|
|
|
595
596
|
return true;
|
|
596
597
|
}
|
|
597
598
|
|
|
598
|
-
export function getWebGLTextureParameters(formatOrGL: TextureFormat | GL
|
|
599
|
+
export function getWebGLTextureParameters(formatOrGL: TextureFormat | GL) {
|
|
599
600
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
600
|
-
const webglFormat = convertTextureFormatToGL(format
|
|
601
|
+
const webglFormat = convertTextureFormatToGL(format);
|
|
601
602
|
const decoded = decodeTextureFormat(format);
|
|
602
603
|
return {
|
|
603
604
|
format: webglFormat,
|
|
@@ -624,59 +625,11 @@ export function getDepthStencilAttachmentWebGL(
|
|
|
624
625
|
return info.attachment;
|
|
625
626
|
}
|
|
626
627
|
|
|
627
|
-
/**
|
|
628
|
-
* function to test if Float 32 bit format texture can be bound as color attachment
|
|
629
|
-
* @todo Generalize to check arbitrary formats?
|
|
630
|
-
*/
|
|
631
|
-
export function _checkFloat32ColorAttachment(
|
|
632
|
-
gl: WebGLRenderingContext,
|
|
633
|
-
internalFormat = gl.RGBA,
|
|
634
|
-
srcFormat = GL.RGBA,
|
|
635
|
-
srcType = GL.UNSIGNED_BYTE
|
|
636
|
-
) {
|
|
637
|
-
let texture: WebGLTexture | null = null;
|
|
638
|
-
let framebuffer: WebGLFramebuffer | null = null;
|
|
639
|
-
try {
|
|
640
|
-
texture = gl.createTexture();
|
|
641
|
-
gl.bindTexture(GL.TEXTURE_2D, texture);
|
|
642
|
-
|
|
643
|
-
const level = 0;
|
|
644
|
-
const width = 1;
|
|
645
|
-
const height = 1;
|
|
646
|
-
const border = 0;
|
|
647
|
-
const pixel = new Uint8Array([0, 0, 255, 255]); // opaque blue
|
|
648
|
-
gl.texImage2D(
|
|
649
|
-
gl.TEXTURE_2D,
|
|
650
|
-
level,
|
|
651
|
-
internalFormat,
|
|
652
|
-
width,
|
|
653
|
-
height,
|
|
654
|
-
border,
|
|
655
|
-
srcFormat,
|
|
656
|
-
srcType,
|
|
657
|
-
pixel
|
|
658
|
-
);
|
|
659
|
-
|
|
660
|
-
framebuffer = gl.createFramebuffer();
|
|
661
|
-
gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer);
|
|
662
|
-
gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0, GL.TEXTURE_2D, texture, 0);
|
|
663
|
-
const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER) as GL === GL.FRAMEBUFFER_COMPLETE;
|
|
664
|
-
|
|
665
|
-
gl.bindTexture(GL.TEXTURE_2D, null);
|
|
666
|
-
return status;
|
|
667
|
-
} finally {
|
|
668
|
-
gl.deleteTexture(texture);
|
|
669
|
-
gl.deleteFramebuffer(framebuffer);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
628
|
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
674
|
-
export function getTextureFormatBytesPerPixel(
|
|
675
|
-
|
|
676
|
-
isWebGL2: boolean
|
|
677
|
-
): number {
|
|
629
|
+
export function getTextureFormatBytesPerPixel(formatOrGL: TextureFormat | GL): number {
|
|
630
|
+
// TODO remove webgl1 support
|
|
678
631
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
679
|
-
const params = getWebGLTextureParameters(format
|
|
632
|
+
const params = getWebGLTextureParameters(format);
|
|
680
633
|
// NOTE(Tarek): Default to RGBA bytes
|
|
681
634
|
const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
|
|
682
635
|
const channelSize = TYPE_SIZES[params.type] || 1;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {GL} from '@luma.gl/constants';
|
|
5
6
|
import {VertexFormat, VertexType} from '@luma.gl/core';
|
|
6
7
|
|
|
7
|
-
type GLDataType =
|
|
8
|
+
type GLDataType =
|
|
8
9
|
| GL.UNSIGNED_BYTE
|
|
9
10
|
| GL.BYTE
|
|
10
11
|
| GL.UNSIGNED_SHORT
|
|
@@ -14,7 +15,6 @@ type GLDataType =
|
|
|
14
15
|
| GL.HALF_FLOAT
|
|
15
16
|
| GL.FLOAT;
|
|
16
17
|
|
|
17
|
-
|
|
18
18
|
/** Get vertex format from GL constants */
|
|
19
19
|
export function getVertexFormatFromGL(type: GLDataType, components: 1 | 2 | 3 | 4): VertexFormat {
|
|
20
20
|
const base = getVertexTypeFromGL(type);
|