@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.7
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 +128 -71
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +20 -19
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +40 -20
- package/dist/adapter/converters/texture-formats.d.ts +16 -11
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +224 -205
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +22 -21
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +89 -43
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +22 -19
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +47 -46
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +35 -34
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +42 -41
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +40 -39
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -1
- 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 +30 -17
- package/dist/adapter/objects/webgl-resource.d.ts +2 -24
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -101
- package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +16 -15
- 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 +32 -31
- 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 +4 -2
- package/dist/adapter/resources/webgl-external-texture.js +6 -5
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -10
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +60 -53
- 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 +20 -12
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +52 -61
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +5 -4
- package/dist/adapter/resources/webgl-shader.d.ts +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +15 -9
- 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 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +39 -32
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +10 -10
- 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 +10 -9
- 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 +3 -2
- package/dist/adapter/webgl-device.d.ts +35 -30
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +110 -109
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +8 -7
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +5 -4
- 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 +19 -19
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +16 -15
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +20 -19
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -6
- package/dist/context/{context → helpers}/create-browser-context.d.ts.map +1 -1
- package/dist/context/{context → helpers}/create-browser-context.js +2 -1
- package/dist/context/{context/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -3
- 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 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +7 -11
- package/dist/context/parameters/webgl-parameter-tables.d.ts +12 -13
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +302 -295
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +2 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -4
- package/dist/context/state-tracker/with-parameters.d.ts +2 -3
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +6 -8
- package/dist/dist.dev.js +1635 -1387
- package/dist/index.cjs +1766 -1534
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +25 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist.min.js +6 -6
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +114 -27
- package/src/adapter/converters/sampler-parameters.ts +12 -3
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +138 -114
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +102 -50
- package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
- package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +4 -3
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +2 -1
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +2 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +36 -14
- package/src/adapter/objects/webgl-resource.ts +7 -125
- package/src/adapter/resources/webgl-buffer.ts +4 -3
- package/src/adapter/resources/webgl-command-buffer.ts +5 -5
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +6 -5
- package/src/adapter/resources/webgl-framebuffer.ts +61 -53
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +20 -11
- package/src/adapter/resources/webgl-render-pipeline.ts +54 -54
- package/src/adapter/resources/webgl-sampler.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +12 -5
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +14 -3
- package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-canvas-context.ts +6 -4
- package/src/adapter/webgl-device.ts +116 -107
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +14 -8
- package/src/classic/copy-and-blit.ts +11 -4
- 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 +27 -14
- package/src/context/{context → helpers}/create-browser-context.ts +3 -2
- 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 +6 -17
- package/src/context/parameters/webgl-parameter-tables.ts +69 -32
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +11 -6
- package/src/context/state-tracker/with-parameters.ts +8 -8
- package/src/index.ts +7 -6
- package/src/types.ts +2 -1
- package/dist/adapter/device-helpers/device-features.d.ts +0 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-features.js +0 -65
- package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
- package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js +0 -92
- 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 -87
- package/dist/context/context/context-data.d.ts.map +0 -1
- package/dist/context/context/context-data.js +0 -33
- package/src/context/context/context-data.ts +0 -44
- /package/dist/context/{context → helpers}/create-browser-context.d.ts +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
import { decodeTextureFormat } from '@luma.gl/core';
|
|
4
5
|
import { GL } from '@luma.gl/constants';
|
|
5
|
-
import {
|
|
6
|
+
import { getWebGLExtension } from "../../context/helpers/webgl-extensions.js";
|
|
7
|
+
import { getGLFromVertexType } from "./vertex-formats.js";
|
|
6
8
|
/* eslint-disable camelcase */
|
|
7
9
|
// TEXTURE FEATURES
|
|
8
10
|
// Define local device feature strings to optimize minification
|
|
@@ -12,8 +14,14 @@ const texture_compression_etc2 = 'texture-compression-etc2';
|
|
|
12
14
|
const texture_compression_etc1_webgl = 'texture-compression-etc1-webgl';
|
|
13
15
|
const texture_compression_pvrtc_webgl = 'texture-compression-pvrtc-webgl';
|
|
14
16
|
const texture_compression_atc_webgl = 'texture-compression-atc-webgl';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
const float32_renderable = 'float32-renderable-webgl';
|
|
18
|
+
const float16_renderable = 'float16-renderable-webgl';
|
|
19
|
+
const rgb9e5ufloat_renderable = 'rgb9e5ufloat_renderable-webgl';
|
|
20
|
+
const snorm8_renderable = 'snorm8-renderable-webgl';
|
|
21
|
+
const norm16_renderable = 'norm16-renderable-webgl';
|
|
22
|
+
const snorm16_renderable = 'snorm16-renderable-webgl';
|
|
23
|
+
const float32_filterable = 'float32-filterable';
|
|
24
|
+
const float16_filterable = 'float16-filterable-webgl';
|
|
17
25
|
// Define local webgl extension strings to optimize minification
|
|
18
26
|
const X_S3TC = 'WEBGL_compressed_texture_s3tc'; // BC1, BC2, BC3
|
|
19
27
|
const X_S3TC_SRGB = 'WEBGL_compressed_texture_s3tc_srgb'; // BC1, BC2, BC3
|
|
@@ -25,19 +33,19 @@ const X_ETC1 = 'WEBGL_compressed_texture_etc1';
|
|
|
25
33
|
const X_PVRTC = 'WEBGL_compressed_texture_pvrtc';
|
|
26
34
|
const X_ATC = 'WEBGL_compressed_texture_atc';
|
|
27
35
|
// Define local webgl extension strings to optimize minification
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
// const DEPTH = 'WEBGL_depth_texture';
|
|
32
|
-
// WebGL1-only extensions
|
|
33
|
-
// const EXT_SRGB = 'EXT_sRGB'; // https://developer.mozilla.org/en-US/docs/Web/API/EXT_sRGB
|
|
36
|
+
const EXT_texture_norm16 = 'EXT_texture_norm16';
|
|
37
|
+
const EXT_render_snorm = 'EXT_render_snorm';
|
|
38
|
+
const EXT_color_buffer_float = 'EXT_color_buffer_float';
|
|
34
39
|
// prettier-ignore
|
|
35
|
-
const
|
|
36
|
-
'float32-renderable-webgl': ['EXT_color_buffer_float'],
|
|
40
|
+
export const TEXTURE_FEATURES = {
|
|
41
|
+
'float32-renderable-webgl': ['EXT_color_buffer_float'],
|
|
37
42
|
'float16-renderable-webgl': ['EXT_color_buffer_half_float'],
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
43
|
+
'rgb9e5ufloat_renderable-webgl': ['WEBGL_render_shared_exponent'],
|
|
44
|
+
'snorm8-renderable-webgl': [EXT_render_snorm],
|
|
45
|
+
'norm16-renderable-webgl': [EXT_texture_norm16],
|
|
46
|
+
'snorm16-renderable-webgl': [EXT_texture_norm16, EXT_render_snorm],
|
|
47
|
+
'float32-filterable': ['OES_texture_float_linear'],
|
|
48
|
+
'float16-filterable-webgl': ['OES_texture_half_float_linear'],
|
|
41
49
|
'texture-filterable-anisotropic-webgl': ['EXT_texture_filter_anisotropic'],
|
|
42
50
|
'texture-blend-float-webgl': ['EXT_float_blend'],
|
|
43
51
|
'texture-compression-bc': [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC],
|
|
@@ -51,17 +59,21 @@ const TEXTURE_FEATURE_CHECKS = {
|
|
|
51
59
|
'texture-compression-pvrtc-webgl': [X_PVRTC],
|
|
52
60
|
'texture-compression-atc-webgl': [X_ATC]
|
|
53
61
|
};
|
|
54
|
-
function checkTextureFeature(gl, feature) {
|
|
55
|
-
const extensions = TEXTURE_FEATURE_CHECKS[feature] || [];
|
|
56
|
-
return extensions.every(extension => gl.getExtension(extension));
|
|
57
|
-
}
|
|
58
|
-
function checkTextureFeatures(gl, features) {
|
|
59
|
-
return features.every(feature => checkTextureFeature(gl, feature));
|
|
60
|
-
}
|
|
61
62
|
/** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
|
|
62
|
-
export function getTextureFeatures(
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
// export function getTextureFeatures(
|
|
64
|
+
// gl: WebGL2RenderingContext,
|
|
65
|
+
// extensions: GLExtensions
|
|
66
|
+
// ): DeviceFeature[] {
|
|
67
|
+
// const textureFeatures = Object.keys(TEXTURE_FEATURES) as DeviceFeature[];
|
|
68
|
+
// return textureFeatures.filter(feature => checkTextureFeature(gl, feature, extensions));
|
|
69
|
+
// }
|
|
70
|
+
export function isTextureFeature(feature) {
|
|
71
|
+
return feature in TEXTURE_FEATURES;
|
|
72
|
+
}
|
|
73
|
+
/** Checks a texture feature (for Device.features). Mainly compressed texture support */
|
|
74
|
+
export function checkTextureFeature(gl, feature, extensions) {
|
|
75
|
+
const textureExtensions = TEXTURE_FEATURES[feature] || [];
|
|
76
|
+
return textureExtensions.every(extension => getWebGLExtension(gl, extension, extensions));
|
|
65
77
|
}
|
|
66
78
|
// TABLES
|
|
67
79
|
/**
|
|
@@ -70,159 +82,164 @@ export function getTextureFeatures(gl) {
|
|
|
70
82
|
*/
|
|
71
83
|
// prettier-ignore
|
|
72
84
|
export const TEXTURE_FORMATS = {
|
|
73
|
-
// Unsized formats that leave the precision up to the driver.
|
|
74
|
-
|
|
85
|
+
// Unsized formats that leave the precision up to the driver. TODO - Fix bpp constants
|
|
86
|
+
'rgb8unorm-unsized': { gl: 6407, b: 4, c: 2, bpp: 4,
|
|
87
|
+
dataFormat: 6407, types: [5121, 33635] },
|
|
88
|
+
'rgba8unorm-unsized': { gl: 6408, b: 4, c: 2, bpp: 4,
|
|
89
|
+
dataFormat: 6408, types: [5121, 32819, 32820] },
|
|
75
90
|
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
76
|
-
'rgb8unorm-unsized': { gl: GL.RGB, b: 4, c: 2, bpp: 4,
|
|
77
|
-
dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5] },
|
|
78
|
-
'rgba8unorm-unsized': { gl: GL.RGBA, b: 4, c: 2, bpp: 4,
|
|
79
|
-
dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4, GL.UNSIGNED_SHORT_5_5_5_1] },
|
|
80
91
|
// 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
81
92
|
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
82
93
|
// 8-bit formats
|
|
83
|
-
'r8unorm': { gl:
|
|
84
|
-
'r8snorm': { gl:
|
|
85
|
-
'r8uint': { gl:
|
|
86
|
-
'r8sint': { gl:
|
|
94
|
+
'r8unorm': { gl: 33321, b: 1, c: 1, rb: true },
|
|
95
|
+
'r8snorm': { gl: 36756, b: 1, c: 1, render: snorm8_renderable },
|
|
96
|
+
'r8uint': { gl: 33330, b: 1, c: 1, rb: true },
|
|
97
|
+
'r8sint': { gl: 33329, b: 1, c: 1, rb: true },
|
|
87
98
|
// 16-bit formats
|
|
88
|
-
'rg8unorm': { gl:
|
|
89
|
-
'rg8snorm': { gl:
|
|
90
|
-
'rg8uint': { gl:
|
|
91
|
-
'rg8sint': { gl:
|
|
92
|
-
'r16uint': { gl:
|
|
93
|
-
'r16sint': { gl:
|
|
94
|
-
'r16float': { gl:
|
|
95
|
-
'r16unorm-webgl': { gl:
|
|
96
|
-
'r16snorm-webgl': { gl:
|
|
99
|
+
'rg8unorm': { gl: 33323, b: 2, c: 2, rb: true },
|
|
100
|
+
'rg8snorm': { gl: 36757, b: 2, c: 2, render: snorm8_renderable },
|
|
101
|
+
'rg8uint': { gl: 33336, b: 2, c: 2, rb: true },
|
|
102
|
+
'rg8sint': { gl: 33335, b: 2, c: 2, rb: true },
|
|
103
|
+
'r16uint': { gl: 33332, b: 2, c: 1, rb: true },
|
|
104
|
+
'r16sint': { gl: 33331, b: 2, c: 1, rb: true },
|
|
105
|
+
'r16float': { gl: 33325, b: 2, c: 1, render: float16_renderable, filter: 'float16-filterable-webgl', rb: true },
|
|
106
|
+
'r16unorm-webgl': { gl: 33322, b: 2, c: 1, f: norm16_renderable, rb: true },
|
|
107
|
+
'r16snorm-webgl': { gl: 36760, b: 2, c: 1, f: snorm16_renderable },
|
|
97
108
|
// Packed 16-bit formats
|
|
98
|
-
'rgba4unorm-webgl': { gl:
|
|
99
|
-
'rgb565unorm-webgl': { gl:
|
|
100
|
-
'rgb5a1unorm-webgl': { gl:
|
|
109
|
+
'rgba4unorm-webgl': { gl: 32854, b: 2, c: 4, wgpu: false, rb: true },
|
|
110
|
+
'rgb565unorm-webgl': { gl: 36194, b: 2, c: 4, wgpu: false, rb: true },
|
|
111
|
+
'rgb5a1unorm-webgl': { gl: 32855, b: 2, c: 4, wgpu: false, rb: true },
|
|
101
112
|
// 24-bit formats
|
|
102
|
-
'rgb8unorm-webgl': { gl:
|
|
103
|
-
'rgb8snorm-webgl': { gl:
|
|
113
|
+
'rgb8unorm-webgl': { gl: 32849, b: 3, c: 3, wgpu: false },
|
|
114
|
+
'rgb8snorm-webgl': { gl: 36758, b: 3, c: 3, wgpu: false },
|
|
104
115
|
// 32-bit formats
|
|
105
|
-
'rgba8unorm': { gl:
|
|
106
|
-
'rgba8unorm-srgb': { gl:
|
|
107
|
-
'rgba8snorm': { gl:
|
|
108
|
-
'rgba8uint': { gl:
|
|
109
|
-
'rgba8sint': { gl:
|
|
116
|
+
'rgba8unorm': { gl: 32856, b: 4, c: 2, bpp: 4 },
|
|
117
|
+
'rgba8unorm-srgb': { gl: 35907, b: 4, c: 4, bpp: 4 },
|
|
118
|
+
'rgba8snorm': { gl: 36759, b: 4, c: 4, render: snorm8_renderable },
|
|
119
|
+
'rgba8uint': { gl: 36220, b: 4, c: 4, bpp: 4 },
|
|
120
|
+
'rgba8sint': { gl: 36238, b: 4, c: 4, bpp: 4 },
|
|
110
121
|
// reverse colors, webgpu only
|
|
111
122
|
'bgra8unorm': { b: 4, c: 4 },
|
|
112
123
|
'bgra8unorm-srgb': { b: 4, c: 4 },
|
|
113
|
-
'rg16uint': { gl:
|
|
114
|
-
'rg16sint': { gl:
|
|
124
|
+
'rg16uint': { gl: 33338, b: 4, c: 1, bpp: 4 },
|
|
125
|
+
'rg16sint': { gl: 33337, b: 4, c: 2, bpp: 4 },
|
|
115
126
|
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
116
|
-
'rg16float': { gl:
|
|
117
|
-
'rg16unorm-webgl': { gl:
|
|
118
|
-
'rg16snorm-webgl': { gl:
|
|
119
|
-
'r32uint': { gl:
|
|
120
|
-
'r32sint': { gl:
|
|
121
|
-
'r32float': { gl:
|
|
127
|
+
'rg16float': { gl: 33327, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true },
|
|
128
|
+
'rg16unorm-webgl': { gl: 33324, b: 2, c: 2, render: norm16_renderable },
|
|
129
|
+
'rg16snorm-webgl': { gl: 36761, b: 2, c: 2, render: snorm16_renderable },
|
|
130
|
+
'r32uint': { gl: 33334, b: 4, c: 1, bpp: 4, rb: true },
|
|
131
|
+
'r32sint': { gl: 33333, b: 4, c: 1, bpp: 4, rb: true },
|
|
132
|
+
'r32float': { gl: 33326, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable },
|
|
122
133
|
// Packed 32-bit formats
|
|
123
|
-
'rgb9e5ufloat': { gl:
|
|
124
|
-
'rg11b10ufloat': { gl:
|
|
125
|
-
'rgb10a2unorm': { gl:
|
|
126
|
-
'
|
|
134
|
+
'rgb9e5ufloat': { gl: 35901, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable }, // , filter: true},
|
|
135
|
+
'rg11b10ufloat': { gl: 35898, b: 4, c: 3, p: 1, render: float32_renderable, rb: true },
|
|
136
|
+
'rgb10a2unorm': { gl: 32857, b: 4, c: 4, p: 1, rb: true },
|
|
137
|
+
'rgb10a2uint-webgl': { b: 4, c: 4, gl: 36975, p: 1, wgpu: false, bpp: 4, rb: true },
|
|
127
138
|
// 48-bit formats
|
|
128
|
-
'rgb16unorm-webgl': { gl:
|
|
129
|
-
'rgb16snorm-webgl': { gl:
|
|
139
|
+
'rgb16unorm-webgl': { gl: 32852, b: 2, c: 3, f: norm16_renderable }, // rgb not renderable
|
|
140
|
+
'rgb16snorm-webgl': { gl: 36762, b: 2, c: 3, f: norm16_renderable }, // rgb not renderable
|
|
130
141
|
// 64-bit formats
|
|
131
|
-
'rg32uint': { gl:
|
|
132
|
-
'rg32sint': { gl:
|
|
133
|
-
'rg32float': { gl:
|
|
134
|
-
'rgba16uint': { gl:
|
|
135
|
-
'rgba16sint': { gl:
|
|
136
|
-
'rgba16float': { gl:
|
|
137
|
-
'rgba16unorm-webgl': { gl:
|
|
138
|
-
'rgba16snorm-webgl': { gl:
|
|
142
|
+
'rg32uint': { gl: 33340, b: 8, c: 2, rb: true },
|
|
143
|
+
'rg32sint': { gl: 33339, b: 8, c: 2, rb: true },
|
|
144
|
+
'rg32float': { gl: 33328, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, rb: true },
|
|
145
|
+
'rgba16uint': { gl: 36214, b: 8, c: 4, rb: true },
|
|
146
|
+
'rgba16sint': { gl: 36232, b: 8, c: 4, rb: true },
|
|
147
|
+
'rgba16float': { gl: 34842, b: 8, c: 4, render: float16_renderable, filter: float16_filterable },
|
|
148
|
+
'rgba16unorm-webgl': { gl: 32859, b: 2, c: 4, render: norm16_renderable, rb: true },
|
|
149
|
+
'rgba16snorm-webgl': { gl: 36763, b: 2, c: 4, render: snorm16_renderable },
|
|
139
150
|
// 96-bit formats (deprecated!)
|
|
140
|
-
'rgb32float-webgl': { gl:
|
|
141
|
-
gl2ext:
|
|
151
|
+
'rgb32float-webgl': { gl: 34837, render: float32_renderable, filter: float32_filterable,
|
|
152
|
+
gl2ext: EXT_color_buffer_float, dataFormat: 6407, types: [5126] },
|
|
142
153
|
// 128-bit formats
|
|
143
|
-
'rgba32uint': { gl:
|
|
144
|
-
'rgba32sint': { gl:
|
|
145
|
-
'rgba32float': { gl:
|
|
154
|
+
'rgba32uint': { gl: 36208, b: 16, c: 4, rb: true },
|
|
155
|
+
'rgba32sint': { gl: 36226, b: 16, c: 4, rb: true },
|
|
156
|
+
'rgba32float': { gl: 34836, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, rb: true },
|
|
146
157
|
// Depth and stencil formats
|
|
147
|
-
'stencil8': { gl:
|
|
148
|
-
'depth16unorm': { gl:
|
|
149
|
-
|
|
150
|
-
'
|
|
158
|
+
'stencil8': { gl: 36168, b: 1, c: 1, attachment: 36128, rb: true }, // 8 stencil bits
|
|
159
|
+
'depth16unorm': { gl: 33189, b: 2, c: 1, attachment: 36096,
|
|
160
|
+
dataFormat: 6402, types: [5123], rb: true }, // 16 depth bits
|
|
161
|
+
'depth24plus': { gl: 33190, b: 3, c: 1, attachment: 36096,
|
|
162
|
+
dataFormat: 6402, types: [5125] },
|
|
163
|
+
'depth32float': { gl: 36012, b: 4, c: 1, attachment: 36096,
|
|
164
|
+
dataFormat: 6402, types: [5126], rb: true },
|
|
151
165
|
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
152
|
-
'depth24plus-stencil8': { gl:
|
|
166
|
+
'depth24plus-stencil8': { gl: 35056, b: 4, c: 2, p: 1, attachment: 33306, rb: true, depthTexture: true,
|
|
167
|
+
dataFormat: 34041, types: [34042] },
|
|
153
168
|
// "depth24unorm-stencil8" feature
|
|
154
|
-
'depth24unorm-stencil8': { gl:
|
|
155
|
-
|
|
156
|
-
|
|
169
|
+
'depth24unorm-stencil8': { gl: 35056, b: 4, c: 2, p: 1, attachment: 33306,
|
|
170
|
+
dataFormat: 34041, types: [34042], rb: true },
|
|
171
|
+
// "depth32float-stencil8" feature - TODO below is render buffer only?
|
|
172
|
+
'depth32float-stencil8': { gl: 36013, b: 5, c: 2, p: 1, attachment: 33306,
|
|
173
|
+
dataFormat: 34041, types: [36269], rb: true },
|
|
157
174
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
158
|
-
'bc1-rgb-unorm-webgl': { gl:
|
|
159
|
-
'bc1-rgb-unorm-srgb-webgl': { gl:
|
|
160
|
-
'bc1-rgba-unorm': { gl:
|
|
161
|
-
'bc1-rgba-unorm-srgb': { gl:
|
|
162
|
-
'bc2-rgba-unorm': { gl:
|
|
163
|
-
'bc2-rgba-unorm-srgb': { gl:
|
|
164
|
-
'bc3-rgba-unorm': { gl:
|
|
165
|
-
'bc3-rgba-unorm-srgb': { gl:
|
|
166
|
-
'bc4-r-unorm': { gl:
|
|
167
|
-
'bc4-r-snorm': { gl:
|
|
168
|
-
'bc5-rg-unorm': { gl:
|
|
169
|
-
'bc5-rg-snorm': { gl:
|
|
170
|
-
'bc6h-rgb-ufloat': { gl:
|
|
171
|
-
'bc6h-rgb-float': { gl:
|
|
172
|
-
'bc7-rgba-unorm': { gl:
|
|
173
|
-
'bc7-rgba-unorm-srgb': { gl:
|
|
175
|
+
'bc1-rgb-unorm-webgl': { gl: 33776, x: X_S3TC, f: texture_compression_bc },
|
|
176
|
+
'bc1-rgb-unorm-srgb-webgl': { gl: 35916, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
177
|
+
'bc1-rgba-unorm': { gl: 33777, x: X_S3TC, f: texture_compression_bc },
|
|
178
|
+
'bc1-rgba-unorm-srgb': { gl: 35916, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
179
|
+
'bc2-rgba-unorm': { gl: 33778, x: X_S3TC, f: texture_compression_bc },
|
|
180
|
+
'bc2-rgba-unorm-srgb': { gl: 35918, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
181
|
+
'bc3-rgba-unorm': { gl: 33779, x: X_S3TC, f: texture_compression_bc },
|
|
182
|
+
'bc3-rgba-unorm-srgb': { gl: 35919, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
183
|
+
'bc4-r-unorm': { gl: 36283, x: X_RGTC, f: texture_compression_bc },
|
|
184
|
+
'bc4-r-snorm': { gl: 36284, x: X_RGTC, f: texture_compression_bc },
|
|
185
|
+
'bc5-rg-unorm': { gl: 36285, x: X_RGTC, f: texture_compression_bc },
|
|
186
|
+
'bc5-rg-snorm': { gl: 36286, x: X_RGTC, f: texture_compression_bc },
|
|
187
|
+
'bc6h-rgb-ufloat': { gl: 36495, x: X_BPTC, f: texture_compression_bc },
|
|
188
|
+
'bc6h-rgb-float': { gl: 36494, x: X_BPTC, f: texture_compression_bc },
|
|
189
|
+
'bc7-rgba-unorm': { gl: 36492, x: X_BPTC, f: texture_compression_bc },
|
|
190
|
+
'bc7-rgba-unorm-srgb': { gl: 36493, x: X_BPTC, f: texture_compression_bc },
|
|
174
191
|
// WEBGL_compressed_texture_etc: device.features.has("texture-compression-etc2")
|
|
175
192
|
// Note: Supposedly guaranteed availability compressed formats in WebGL2, but through CPU decompression
|
|
176
|
-
'etc2-rgb8unorm': { gl:
|
|
177
|
-
'etc2-rgb8unorm-srgb': { gl:
|
|
178
|
-
'etc2-rgb8a1unorm': { gl:
|
|
179
|
-
'etc2-rgb8a1unorm-srgb': { gl:
|
|
180
|
-
'etc2-rgba8unorm': { gl:
|
|
181
|
-
'etc2-rgba8unorm-srgb': { gl:
|
|
182
|
-
'eac-r11unorm': { gl:
|
|
183
|
-
'eac-r11snorm': { gl:
|
|
184
|
-
'eac-rg11unorm': { gl:
|
|
185
|
-
'eac-rg11snorm': { gl:
|
|
193
|
+
'etc2-rgb8unorm': { gl: 37492, f: texture_compression_etc2 },
|
|
194
|
+
'etc2-rgb8unorm-srgb': { gl: 37494, f: texture_compression_etc2 },
|
|
195
|
+
'etc2-rgb8a1unorm': { gl: 37496, f: texture_compression_etc2 },
|
|
196
|
+
'etc2-rgb8a1unorm-srgb': { gl: 37497, f: texture_compression_etc2 },
|
|
197
|
+
'etc2-rgba8unorm': { gl: 37493, f: texture_compression_etc2 },
|
|
198
|
+
'etc2-rgba8unorm-srgb': { gl: 37495, f: texture_compression_etc2 },
|
|
199
|
+
'eac-r11unorm': { gl: 37488, f: texture_compression_etc2 },
|
|
200
|
+
'eac-r11snorm': { gl: 37489, f: texture_compression_etc2 },
|
|
201
|
+
'eac-rg11unorm': { gl: 37490, f: texture_compression_etc2 },
|
|
202
|
+
'eac-rg11snorm': { gl: 37491, f: texture_compression_etc2 },
|
|
186
203
|
// X_ASTC compressed formats: device.features.has("texture-compression-astc")
|
|
187
|
-
'astc-4x4-unorm': { gl:
|
|
188
|
-
'astc-4x4-unorm-srgb': { gl:
|
|
189
|
-
'astc-5x4-unorm': { gl:
|
|
190
|
-
'astc-5x4-unorm-srgb': { gl:
|
|
191
|
-
'astc-5x5-unorm': { gl:
|
|
192
|
-
'astc-5x5-unorm-srgb': { gl:
|
|
193
|
-
'astc-6x5-unorm': { gl:
|
|
194
|
-
'astc-6x5-unorm-srgb': { gl:
|
|
195
|
-
'astc-6x6-unorm': { gl:
|
|
196
|
-
'astc-6x6-unorm-srgb': { gl:
|
|
197
|
-
'astc-8x5-unorm': { gl:
|
|
198
|
-
'astc-8x5-unorm-srgb': { gl:
|
|
199
|
-
'astc-8x6-unorm': { gl:
|
|
200
|
-
'astc-8x6-unorm-srgb': { gl:
|
|
201
|
-
'astc-8x8-unorm': { gl:
|
|
202
|
-
'astc-8x8-unorm-srgb': { gl:
|
|
203
|
-
'astc-10x5-unorm': { gl:
|
|
204
|
-
'astc-10x5-unorm-srgb': { gl:
|
|
205
|
-
'astc-10x6-unorm': { gl:
|
|
206
|
-
'astc-10x6-unorm-srgb': { gl:
|
|
207
|
-
'astc-10x8-unorm': { gl:
|
|
208
|
-
'astc-10x8-unorm-srgb': { gl:
|
|
209
|
-
'astc-10x10-unorm': { gl:
|
|
210
|
-
'astc-10x10-unorm-srgb': { gl:
|
|
211
|
-
'astc-12x10-unorm': { gl:
|
|
212
|
-
'astc-12x10-unorm-srgb': { gl:
|
|
213
|
-
'astc-12x12-unorm': { gl:
|
|
214
|
-
'astc-12x12-unorm-srgb': { gl:
|
|
204
|
+
'astc-4x4-unorm': { gl: 37808, f: texture_compression_astc },
|
|
205
|
+
'astc-4x4-unorm-srgb': { gl: 37840, f: texture_compression_astc },
|
|
206
|
+
'astc-5x4-unorm': { gl: 37809, f: texture_compression_astc },
|
|
207
|
+
'astc-5x4-unorm-srgb': { gl: 37841, f: texture_compression_astc },
|
|
208
|
+
'astc-5x5-unorm': { gl: 37810, f: texture_compression_astc },
|
|
209
|
+
'astc-5x5-unorm-srgb': { gl: 37842, f: texture_compression_astc },
|
|
210
|
+
'astc-6x5-unorm': { gl: 37811, f: texture_compression_astc },
|
|
211
|
+
'astc-6x5-unorm-srgb': { gl: 37843, f: texture_compression_astc },
|
|
212
|
+
'astc-6x6-unorm': { gl: 37812, f: texture_compression_astc },
|
|
213
|
+
'astc-6x6-unorm-srgb': { gl: 37844, f: texture_compression_astc },
|
|
214
|
+
'astc-8x5-unorm': { gl: 37813, f: texture_compression_astc },
|
|
215
|
+
'astc-8x5-unorm-srgb': { gl: 37845, f: texture_compression_astc },
|
|
216
|
+
'astc-8x6-unorm': { gl: 37814, f: texture_compression_astc },
|
|
217
|
+
'astc-8x6-unorm-srgb': { gl: 37846, f: texture_compression_astc },
|
|
218
|
+
'astc-8x8-unorm': { gl: 37815, f: texture_compression_astc },
|
|
219
|
+
'astc-8x8-unorm-srgb': { gl: 37847, f: texture_compression_astc },
|
|
220
|
+
'astc-10x5-unorm': { gl: 37819, f: texture_compression_astc },
|
|
221
|
+
'astc-10x5-unorm-srgb': { gl: 37851, f: texture_compression_astc },
|
|
222
|
+
'astc-10x6-unorm': { gl: 37817, f: texture_compression_astc },
|
|
223
|
+
'astc-10x6-unorm-srgb': { gl: 37849, f: texture_compression_astc },
|
|
224
|
+
'astc-10x8-unorm': { gl: 37818, f: texture_compression_astc },
|
|
225
|
+
'astc-10x8-unorm-srgb': { gl: 37850, f: texture_compression_astc },
|
|
226
|
+
'astc-10x10-unorm': { gl: 37819, f: texture_compression_astc },
|
|
227
|
+
'astc-10x10-unorm-srgb': { gl: 37851, f: texture_compression_astc },
|
|
228
|
+
'astc-12x10-unorm': { gl: 37820, f: texture_compression_astc },
|
|
229
|
+
'astc-12x10-unorm-srgb': { gl: 37852, f: texture_compression_astc },
|
|
230
|
+
'astc-12x12-unorm': { gl: 37821, f: texture_compression_astc },
|
|
231
|
+
'astc-12x12-unorm-srgb': { gl: 37853, f: texture_compression_astc },
|
|
215
232
|
// WEBGL_compressed_texture_pvrtc
|
|
216
|
-
'pvrtc-rgb4unorm-webgl': { gl:
|
|
217
|
-
'pvrtc-rgba4unorm-webgl': { gl:
|
|
218
|
-
'pvrtc-rbg2unorm-webgl': { gl:
|
|
219
|
-
'pvrtc-rgba2unorm-webgl': { gl:
|
|
233
|
+
'pvrtc-rgb4unorm-webgl': { gl: 35840, f: texture_compression_pvrtc_webgl },
|
|
234
|
+
'pvrtc-rgba4unorm-webgl': { gl: 35842, f: texture_compression_pvrtc_webgl },
|
|
235
|
+
'pvrtc-rbg2unorm-webgl': { gl: 35841, f: texture_compression_pvrtc_webgl },
|
|
236
|
+
'pvrtc-rgba2unorm-webgl': { gl: 35843, f: texture_compression_pvrtc_webgl },
|
|
220
237
|
// WEBGL_compressed_texture_etc1
|
|
221
|
-
'etc1-rbg-unorm-webgl': { gl:
|
|
238
|
+
'etc1-rbg-unorm-webgl': { gl: 36196, f: texture_compression_etc1_webgl },
|
|
222
239
|
// WEBGL_compressed_texture_atc
|
|
223
|
-
'atc-rgb-unorm-webgl': { gl:
|
|
224
|
-
'atc-rgba-unorm-webgl': { gl:
|
|
225
|
-
'atc-rgbai-unorm-webgl': { gl:
|
|
240
|
+
'atc-rgb-unorm-webgl': { gl: 35986, f: texture_compression_atc_webgl },
|
|
241
|
+
'atc-rgba-unorm-webgl': { gl: 35986, f: texture_compression_atc_webgl },
|
|
242
|
+
'atc-rgbai-unorm-webgl': { gl: 34798, f: texture_compression_atc_webgl }
|
|
226
243
|
};
|
|
227
244
|
/** Legal combinations for internalFormat, format and type *
|
|
228
245
|
// [GL.DEPTH_COMPONENT]: {types: [GL.UNSIGNED_SHORT, GL.UNSIGNED_INT, GL.UNSIGNED_INT_24_8]},
|
|
@@ -312,41 +329,40 @@ export const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
|
|
|
312
329
|
[GL.RG32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
|
|
313
330
|
// TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
|
|
314
331
|
[GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 16},
|
|
315
|
-
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2
|
|
332
|
+
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2},
|
|
316
333
|
[GL.R11F_G11F_B10F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4}
|
|
317
334
|
};
|
|
318
335
|
*/
|
|
319
336
|
/** @deprecated should be removed */
|
|
320
337
|
const DATA_FORMAT_CHANNELS = {
|
|
321
|
-
[
|
|
322
|
-
[
|
|
323
|
-
[
|
|
324
|
-
[
|
|
325
|
-
[
|
|
326
|
-
[
|
|
327
|
-
[
|
|
328
|
-
[
|
|
329
|
-
[
|
|
330
|
-
[
|
|
331
|
-
[
|
|
332
|
-
[
|
|
333
|
-
[
|
|
338
|
+
[6403]: 1,
|
|
339
|
+
[36244]: 1,
|
|
340
|
+
[33319]: 2,
|
|
341
|
+
[33320]: 2,
|
|
342
|
+
[6407]: 3,
|
|
343
|
+
[36248]: 3,
|
|
344
|
+
[6408]: 4,
|
|
345
|
+
[36249]: 4,
|
|
346
|
+
[6402]: 1,
|
|
347
|
+
[34041]: 1,
|
|
348
|
+
[6406]: 1,
|
|
349
|
+
[6409]: 1,
|
|
350
|
+
[6410]: 2
|
|
334
351
|
};
|
|
335
352
|
/** @deprecated should be removed */
|
|
336
353
|
const TYPE_SIZES = {
|
|
337
|
-
[
|
|
338
|
-
[
|
|
339
|
-
[
|
|
340
|
-
[
|
|
341
|
-
[
|
|
342
|
-
[
|
|
343
|
-
[
|
|
344
|
-
[
|
|
354
|
+
[5126]: 4,
|
|
355
|
+
[5125]: 4,
|
|
356
|
+
[5124]: 4,
|
|
357
|
+
[5123]: 2,
|
|
358
|
+
[5122]: 2,
|
|
359
|
+
[5131]: 2,
|
|
360
|
+
[5120]: 1,
|
|
361
|
+
[5121]: 1
|
|
345
362
|
};
|
|
346
363
|
// FUNCTIONS
|
|
347
364
|
/** Checks if a texture format is supported */
|
|
348
|
-
export function isTextureFormatSupported(gl,
|
|
349
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
365
|
+
export function isTextureFormatSupported(gl, format, extensions) {
|
|
350
366
|
const info = TEXTURE_FORMATS[format];
|
|
351
367
|
if (!info) {
|
|
352
368
|
return false;
|
|
@@ -358,13 +374,13 @@ export function isTextureFormatSupported(gl, formatOrGL) {
|
|
|
358
374
|
// Check extensions
|
|
359
375
|
const extension = info.x || info.gl2ext;
|
|
360
376
|
if (extension) {
|
|
361
|
-
return Boolean(gl
|
|
377
|
+
return Boolean(getWebGLExtension(gl, extension, extensions));
|
|
362
378
|
}
|
|
363
379
|
return true;
|
|
364
380
|
}
|
|
365
|
-
export function isRenderbufferFormatSupported(gl, format) {
|
|
381
|
+
export function isRenderbufferFormatSupported(gl, format, extensions) {
|
|
366
382
|
// Note: Order is important since the function call initializes extensions.
|
|
367
|
-
return isTextureFormatSupported(gl, format) && TEXTURE_FORMATS[format]?.
|
|
383
|
+
return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.rb;
|
|
368
384
|
}
|
|
369
385
|
/**
|
|
370
386
|
* Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
|
|
@@ -391,8 +407,7 @@ export function convertTextureFormatToGL(format) {
|
|
|
391
407
|
return webglFormat;
|
|
392
408
|
}
|
|
393
409
|
/** Checks if a texture format is supported */
|
|
394
|
-
export function getTextureFormatSupport(gl,
|
|
395
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
410
|
+
export function getTextureFormatSupport(gl, format, extensions) {
|
|
396
411
|
const info = TEXTURE_FORMATS[format];
|
|
397
412
|
if (!info) {
|
|
398
413
|
return { supported: false };
|
|
@@ -403,26 +418,28 @@ export function getTextureFormatSupport(gl, formatOrGL) {
|
|
|
403
418
|
// } catch {}
|
|
404
419
|
// Support Check that we have a GL constant
|
|
405
420
|
let supported = info.gl === undefined;
|
|
406
|
-
supported = supported &&
|
|
421
|
+
supported = supported && checkTextureFeature(gl, info.f, extensions);
|
|
407
422
|
// Filtering
|
|
408
423
|
// const filterable = info.filter
|
|
409
|
-
// ?
|
|
424
|
+
// ? checkTextureFeature(gl, infofilter])
|
|
410
425
|
// : decoded && !decoded.signed;
|
|
411
426
|
// const renderable = info.filter
|
|
412
|
-
// ?
|
|
427
|
+
// ? checkTextureFeature(gl, inforender])
|
|
413
428
|
// : decoded && !decoded.signed;
|
|
414
429
|
return {
|
|
415
430
|
supported,
|
|
416
|
-
renderable: supported &&
|
|
417
|
-
filterable: supported &&
|
|
431
|
+
renderable: supported && checkTextureFeature(gl, info.render, extensions),
|
|
432
|
+
filterable: supported && checkTextureFeature(gl, info.filter, extensions),
|
|
418
433
|
blendable: false, // tod,
|
|
419
434
|
storable: false
|
|
420
435
|
};
|
|
421
436
|
}
|
|
422
437
|
/** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
|
|
423
|
-
export function isTextureFormatFilterable(gl,
|
|
424
|
-
|
|
425
|
-
|
|
438
|
+
export function isTextureFormatFilterable(gl, format, extensions) {
|
|
439
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
440
|
+
return false;
|
|
441
|
+
}
|
|
442
|
+
if (format.startsWith('depth') || format.startsWith('stencil')) {
|
|
426
443
|
return false;
|
|
427
444
|
}
|
|
428
445
|
try {
|
|
@@ -435,16 +452,15 @@ export function isTextureFormatFilterable(gl, formatOrGL) {
|
|
|
435
452
|
return false;
|
|
436
453
|
}
|
|
437
454
|
if (format.endsWith('32float')) {
|
|
438
|
-
return Boolean(gl
|
|
455
|
+
return Boolean(getWebGLExtension(gl, 'OES_texture_float_linear, extensions', extensions));
|
|
439
456
|
}
|
|
440
457
|
if (format.endsWith('16float')) {
|
|
441
|
-
return Boolean(gl
|
|
458
|
+
return Boolean(getWebGLExtension(gl, 'OES_texture_half_float_linear, extensions', extensions));
|
|
442
459
|
}
|
|
443
460
|
return true;
|
|
444
461
|
}
|
|
445
|
-
export function isTextureFormatRenderable(gl,
|
|
446
|
-
|
|
447
|
-
if (!isTextureFormatSupported(gl, format)) {
|
|
462
|
+
export function isTextureFormatRenderable(gl, format, extensions) {
|
|
463
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
448
464
|
return false;
|
|
449
465
|
}
|
|
450
466
|
if (typeof format === 'number') {
|
|
@@ -453,15 +469,19 @@ export function isTextureFormatRenderable(gl, formatOrGL) {
|
|
|
453
469
|
// TODO depends on device...
|
|
454
470
|
return true;
|
|
455
471
|
}
|
|
456
|
-
|
|
457
|
-
|
|
472
|
+
/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
|
|
473
|
+
export function getWebGLTextureParameters(format) {
|
|
474
|
+
const formatData = TEXTURE_FORMATS[format];
|
|
458
475
|
const webglFormat = convertTextureFormatToGL(format);
|
|
459
476
|
const decoded = decodeTextureFormat(format);
|
|
460
477
|
return {
|
|
461
478
|
format: webglFormat,
|
|
462
|
-
dataFormat:
|
|
479
|
+
dataFormat: formatData?.dataFormat ||
|
|
480
|
+
getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
|
|
463
481
|
// depth formats don't have a type
|
|
464
|
-
type: decoded.dataType
|
|
482
|
+
type: decoded.dataType
|
|
483
|
+
? getGLFromVertexType(decoded.dataType)
|
|
484
|
+
: formatData?.types?.[0] || 5121,
|
|
465
485
|
// @ts-expect-error
|
|
466
486
|
compressed: decoded.compressed
|
|
467
487
|
};
|
|
@@ -474,9 +494,8 @@ export function getDepthStencilAttachmentWebGL(format) {
|
|
|
474
494
|
return info.attachment;
|
|
475
495
|
}
|
|
476
496
|
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
477
|
-
export function getTextureFormatBytesPerPixel(
|
|
497
|
+
export function getTextureFormatBytesPerPixel(format) {
|
|
478
498
|
// TODO remove webgl1 support
|
|
479
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
480
499
|
const params = getWebGLTextureParameters(format);
|
|
481
500
|
// NOTE(Tarek): Default to RGBA bytes
|
|
482
501
|
const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
|
|
@@ -486,15 +505,15 @@ export function getTextureFormatBytesPerPixel(formatOrGL) {
|
|
|
486
505
|
// DATA TYPE HELPERS
|
|
487
506
|
function getWebGLPixelDataFormat(dataFormat, integer, normalized, format) {
|
|
488
507
|
// WebGL1 formats use same internalFormat
|
|
489
|
-
if (format ===
|
|
508
|
+
if (format === 6408 || format === 6407) {
|
|
490
509
|
return format;
|
|
491
510
|
}
|
|
492
511
|
// prettier-ignore
|
|
493
512
|
switch (dataFormat) {
|
|
494
|
-
case 'r': return integer && !normalized ?
|
|
495
|
-
case 'rg': return integer && !normalized ?
|
|
496
|
-
case 'rgb': return integer && !normalized ?
|
|
497
|
-
case 'rgba': return integer && !normalized ?
|
|
498
|
-
default: return
|
|
513
|
+
case 'r': return integer && !normalized ? 36244 : 6403;
|
|
514
|
+
case 'rg': return integer && !normalized ? 33320 : 33319;
|
|
515
|
+
case 'rgb': return integer && !normalized ? 36248 : 6407;
|
|
516
|
+
case 'rgba': return integer && !normalized ? 36249 : 6408;
|
|
517
|
+
default: return 6408;
|
|
499
518
|
}
|
|
500
519
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vertex-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/vertex-formats.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vertex-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/vertex-formats.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAEvD,KAAK,UAAU,GACX,EAAE,CAAC,aAAa,GAChB,EAAE,CAAC,IAAI,GACP,EAAE,CAAC,cAAc,GACjB,EAAE,CAAC,KAAK,GACR,EAAE,CAAC,YAAY,GACf,EAAE,CAAC,GAAG,GACN,EAAE,CAAC,UAAU,GACb,EAAE,CAAC,KAAK,CAAC;AAEb,0CAA0C;AAC1C,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,YAAY,CAa/F;AAED,sCAAsC;AACtC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,UAAQ,GAAG,UAAU,CAepF;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,UAAU,GAElB,EAAE,CAAC,aAAa,GAChB,EAAE,CAAC,IAAI,GACP,EAAE,CAAC,cAAc,GACjB,EAAE,CAAC,KAAK,GACR,EAAE,CAAC,YAAY,GACf,EAAE,CAAC,GAAG,GACN,EAAE,CAAC,UAAU,GACb,EAAE,CAAC,KAAK,CAqBX"}
|