@luma.gl/webgl 9.1.0-alpha.9 → 9.1.0-beta.1
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 +3 -3
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +1 -0
- package/dist/adapter/converters/device-parameters.js.map +1 -0
- package/dist/adapter/converters/sampler-parameters.js +7 -4
- package/dist/adapter/converters/sampler-parameters.js.map +1 -0
- package/dist/adapter/converters/shader-formats.js +1 -0
- package/dist/adapter/converters/shader-formats.js.map +1 -0
- package/dist/adapter/converters/vertex-formats.js +1 -0
- package/dist/adapter/converters/vertex-formats.js.map +1 -0
- package/dist/adapter/converters/webgl-texture-table.d.ts +40 -0
- package/dist/adapter/converters/webgl-texture-table.d.ts.map +1 -0
- package/dist/adapter/converters/webgl-texture-table.js +304 -0
- package/dist/adapter/converters/webgl-texture-table.js.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +2 -2
- package/dist/adapter/device-helpers/webgl-device-features.js.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js.map +1 -0
- package/dist/adapter/helpers/decode-webgl-types.js +1 -0
- package/dist/adapter/helpers/decode-webgl-types.js.map +1 -0
- package/dist/adapter/helpers/format-utils.d.ts.map +1 -0
- package/dist/{classic → adapter/helpers}/format-utils.js +7 -0
- package/dist/adapter/helpers/format-utils.js.map +1 -0
- 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 +5 -4
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js +1 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -0
- package/dist/adapter/helpers/set-uniform.js +1 -0
- package/dist/adapter/helpers/set-uniform.js.map +1 -0
- package/dist/adapter/helpers/typed-array-utils.d.ts.map +1 -0
- package/dist/{classic → adapter/helpers}/typed-array-utils.js +1 -0
- package/dist/adapter/helpers/typed-array-utils.js.map +1 -0
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +96 -25
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +225 -236
- package/dist/adapter/helpers/webgl-texture-utils.js.map +1 -0
- package/dist/adapter/helpers/webgl-topology-utils.js +1 -0
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -0
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +4 -1
- package/dist/adapter/resources/webgl-buffer.js.map +1 -0
- package/dist/adapter/resources/webgl-command-buffer.d.ts +59 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +89 -32
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -0
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -0
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -0
- package/dist/adapter/resources/webgl-external-texture.js +15 -0
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -0
- package/dist/adapter/resources/webgl-framebuffer.d.ts +33 -35
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +70 -75
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -0
- package/dist/adapter/resources/webgl-query-set.js +1 -0
- package/dist/adapter/resources/webgl-query-set.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +33 -18
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +3 -4
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +44 -22
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgl-sampler.js +1 -0
- package/dist/adapter/resources/webgl-sampler.js.map +1 -0
- package/dist/adapter/resources/webgl-shader.d.ts +1 -0
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +13 -6
- package/dist/adapter/resources/webgl-shader.js.map +1 -0
- package/dist/adapter/resources/webgl-texture-view.js +1 -0
- package/dist/adapter/resources/webgl-texture-view.js.map +1 -0
- package/dist/adapter/resources/webgl-texture.d.ts +32 -20
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +163 -218
- package/dist/adapter/resources/webgl-texture.js.map +1 -0
- package/dist/adapter/resources/webgl-transform-feedback.js +1 -0
- package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -0
- package/dist/adapter/resources/webgl-vertex-array.js +1 -0
- package/dist/adapter/resources/webgl-vertex-array.js.map +1 -0
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +5 -10
- package/dist/adapter/webgl-adapter.js.map +1 -0
- package/dist/adapter/webgl-canvas-context.d.ts +4 -6
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +13 -17
- package/dist/adapter/webgl-canvas-context.js.map +1 -0
- package/dist/adapter/webgl-device.d.ts +20 -19
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +75 -51
- package/dist/adapter/webgl-device.js.map +1 -0
- package/dist/context/debug/spector-types.js +2 -1
- package/dist/context/debug/spector-types.js.map +1 -0
- package/dist/context/debug/spector.d.ts +5 -5
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +7 -6
- package/dist/context/debug/spector.js.map +1 -0
- 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 +7 -19
- package/dist/context/debug/webgl-developer-tools.js.map +1 -0
- package/dist/context/helpers/create-browser-context.d.ts +6 -22
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
- package/dist/context/helpers/create-browser-context.js +41 -32
- package/dist/context/helpers/create-browser-context.js.map +1 -0
- package/dist/context/helpers/webgl-context-data.js +1 -0
- package/dist/context/helpers/webgl-context-data.js.map +1 -0
- package/dist/context/helpers/webgl-extensions.js +1 -0
- package/dist/context/helpers/webgl-extensions.js.map +1 -0
- package/dist/context/parameters/unified-parameter-api.js +1 -0
- package/dist/context/parameters/unified-parameter-api.js.map +1 -0
- package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +3 -2
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js.map +1 -0
- package/dist/context/state-tracker/deep-array-equal.js +1 -0
- package/dist/context/state-tracker/deep-array-equal.js.map +1 -0
- package/dist/context/state-tracker/webgl-state-tracker.js +1 -0
- package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -0
- package/dist/context/state-tracker/with-parameters.js +1 -0
- package/dist/context/state-tracker/with-parameters.js.map +1 -0
- package/dist/deprecated/accessor.d.ts.map +1 -0
- package/dist/{classic → deprecated}/accessor.js +37 -1
- package/dist/deprecated/accessor.js.map +1 -0
- package/dist/dist.dev.js +2234 -2373
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +2124 -2256
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/fill-array.d.ts +4 -4
- package/dist/utils/fill-array.d.ts.map +1 -1
- package/dist/utils/fill-array.js +1 -0
- package/dist/utils/fill-array.js.map +1 -0
- package/dist/utils/load-script.js +1 -0
- package/dist/utils/load-script.js.map +1 -0
- package/dist/utils/split-uniforms-and-bindings.d.ts +1 -1
- package/dist/utils/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/utils/split-uniforms-and-bindings.js +1 -0
- package/dist/utils/split-uniforms-and-bindings.js.map +1 -0
- package/dist/utils/uid.js +1 -0
- package/dist/utils/uid.js.map +1 -0
- package/package.json +5 -5
- package/src/adapter/converters/device-parameters.ts +3 -3
- package/src/adapter/converters/sampler-parameters.ts +6 -4
- package/src/adapter/converters/webgl-texture-table.ts +404 -0
- package/src/adapter/device-helpers/webgl-device-features.ts +5 -2
- package/src/{classic → adapter/helpers}/format-utils.ts +6 -0
- package/src/adapter/helpers/get-shader-layout.ts +7 -4
- package/src/adapter/helpers/webgl-texture-utils.ts +400 -57
- package/src/adapter/resources/webgl-buffer.ts +3 -1
- package/src/adapter/resources/webgl-command-buffer.ts +125 -41
- package/src/adapter/resources/webgl-command-encoder.ts +6 -0
- package/src/adapter/resources/webgl-external-texture.ts +14 -0
- package/src/adapter/resources/webgl-framebuffer.ts +79 -85
- package/src/adapter/resources/webgl-render-pass.ts +56 -42
- package/src/adapter/resources/webgl-render-pipeline.ts +56 -26
- package/src/adapter/resources/webgl-shader.ts +15 -7
- package/src/adapter/resources/webgl-texture.ts +188 -250
- package/src/adapter/webgl-adapter.ts +4 -12
- package/src/adapter/webgl-canvas-context.ts +16 -19
- package/src/adapter/webgl-device.ts +125 -88
- package/src/context/debug/spector-types.ts +1 -1
- package/src/context/debug/spector.ts +11 -11
- package/src/context/debug/webgl-developer-tools.ts +8 -31
- package/src/context/helpers/create-browser-context.ts +53 -63
- package/src/context/parameters/webgl-parameter-tables.ts +2 -2
- package/src/{classic → deprecated}/accessor.ts +44 -3
- package/src/index.ts +2 -5
- package/src/utils/fill-array.ts +4 -4
- package/src/utils/split-uniforms-and-bindings.ts +3 -3
- package/dist/adapter/converters/texture-formats.d.ts +0 -83
- package/dist/adapter/converters/texture-formats.d.ts.map +0 -1
- package/dist/adapter/converters/texture-formats.js +0 -511
- package/dist/classic/accessor.d.ts.map +0 -1
- package/dist/classic/clear.d.ts +0 -22
- package/dist/classic/clear.d.ts.map +0 -1
- package/dist/classic/clear.js +0 -86
- package/dist/classic/copy-and-blit.d.ts +0 -64
- package/dist/classic/copy-and-blit.d.ts.map +0 -1
- package/dist/classic/copy-and-blit.js +0 -194
- package/dist/classic/format-utils.d.ts.map +0 -1
- package/dist/classic/typed-array-utils.d.ts.map +0 -1
- package/src/adapter/converters/texture-formats.ts +0 -657
- package/src/classic/clear.ts +0 -115
- package/src/classic/copy-and-blit.ts +0 -323
- /package/dist/{classic → adapter/helpers}/format-utils.d.ts +0 -0
- /package/dist/{classic → adapter/helpers}/typed-array-utils.d.ts +0 -0
- /package/dist/{classic → deprecated}/accessor.d.ts +0 -0
- /package/src/{classic → adapter/helpers}/typed-array-utils.ts +0 -0
|
@@ -1,511 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { decodeTextureFormat } from '@luma.gl/core';
|
|
5
|
-
import { GL } from '@luma.gl/constants';
|
|
6
|
-
import { getWebGLExtension } from "../../context/helpers/webgl-extensions.js";
|
|
7
|
-
import { getGLFromVertexType } from "./vertex-formats.js";
|
|
8
|
-
/* eslint-disable camelcase */
|
|
9
|
-
// TEXTURE FEATURES
|
|
10
|
-
// Define local device feature strings to optimize minification
|
|
11
|
-
const texture_compression_bc = 'texture-compression-bc';
|
|
12
|
-
const texture_compression_astc = 'texture-compression-astc';
|
|
13
|
-
const texture_compression_etc2 = 'texture-compression-etc2';
|
|
14
|
-
const texture_compression_etc1_webgl = 'texture-compression-etc1-webgl';
|
|
15
|
-
const texture_compression_pvrtc_webgl = 'texture-compression-pvrtc-webgl';
|
|
16
|
-
const texture_compression_atc_webgl = 'texture-compression-atc-webgl';
|
|
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';
|
|
25
|
-
// Define local webgl extension strings to optimize minification
|
|
26
|
-
const X_S3TC = 'WEBGL_compressed_texture_s3tc'; // BC1, BC2, BC3
|
|
27
|
-
const X_S3TC_SRGB = 'WEBGL_compressed_texture_s3tc_srgb'; // BC1, BC2, BC3
|
|
28
|
-
const X_RGTC = 'EXT_texture_compression_rgtc'; // BC4, BC5
|
|
29
|
-
const X_BPTC = 'EXT_texture_compression_bptc'; // BC6, BC7
|
|
30
|
-
const X_ETC2 = 'WEBGL_compressed_texture_etc'; // Renamed from 'WEBGL_compressed_texture_es3'
|
|
31
|
-
const X_ASTC = 'WEBGL_compressed_texture_astc';
|
|
32
|
-
const X_ETC1 = 'WEBGL_compressed_texture_etc1';
|
|
33
|
-
const X_PVRTC = 'WEBGL_compressed_texture_pvrtc';
|
|
34
|
-
const X_ATC = 'WEBGL_compressed_texture_atc';
|
|
35
|
-
// Define local webgl extension strings to optimize minification
|
|
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';
|
|
39
|
-
// prettier-ignore
|
|
40
|
-
export const TEXTURE_FEATURES = {
|
|
41
|
-
'float32-renderable-webgl': ['EXT_color_buffer_float'],
|
|
42
|
-
'float16-renderable-webgl': ['EXT_color_buffer_half_float'],
|
|
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'],
|
|
49
|
-
'texture-filterable-anisotropic-webgl': ['EXT_texture_filter_anisotropic'],
|
|
50
|
-
'texture-blend-float-webgl': ['EXT_float_blend'],
|
|
51
|
-
'texture-compression-bc': [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC],
|
|
52
|
-
// 'texture-compression-bc3-srgb-webgl': [X_S3TC_SRGB],
|
|
53
|
-
// 'texture-compression-bc3-webgl': [X_S3TC],
|
|
54
|
-
'texture-compression-bc5-webgl': [X_RGTC],
|
|
55
|
-
'texture-compression-bc7-webgl': [X_BPTC],
|
|
56
|
-
'texture-compression-etc2': [X_ETC2],
|
|
57
|
-
'texture-compression-astc': [X_ASTC],
|
|
58
|
-
'texture-compression-etc1-webgl': [X_ETC1],
|
|
59
|
-
'texture-compression-pvrtc-webgl': [X_PVRTC],
|
|
60
|
-
'texture-compression-atc-webgl': [X_ATC]
|
|
61
|
-
};
|
|
62
|
-
/** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
|
|
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));
|
|
77
|
-
}
|
|
78
|
-
// TABLES
|
|
79
|
-
/**
|
|
80
|
-
* Texture format data -
|
|
81
|
-
* Exported but can change without notice
|
|
82
|
-
*/
|
|
83
|
-
// prettier-ignore
|
|
84
|
-
export const TEXTURE_FORMATS = {
|
|
85
|
-
// 8-bit formats
|
|
86
|
-
'r8unorm': { gl: 33321, b: 1, c: 1, rb: true },
|
|
87
|
-
'r8snorm': { gl: 36756, b: 1, c: 1, render: snorm8_renderable },
|
|
88
|
-
'r8uint': { gl: 33330, b: 1, c: 1, rb: true },
|
|
89
|
-
'r8sint': { gl: 33329, b: 1, c: 1, rb: true },
|
|
90
|
-
// 16-bit formats
|
|
91
|
-
'rg8unorm': { gl: 33323, b: 2, c: 2, rb: true },
|
|
92
|
-
'rg8snorm': { gl: 36757, b: 2, c: 2, render: snorm8_renderable },
|
|
93
|
-
'rg8uint': { gl: 33336, b: 2, c: 2, rb: true },
|
|
94
|
-
'rg8sint': { gl: 33335, b: 2, c: 2, rb: true },
|
|
95
|
-
'r16uint': { gl: 33332, b: 2, c: 1, rb: true },
|
|
96
|
-
'r16sint': { gl: 33331, b: 2, c: 1, rb: true },
|
|
97
|
-
'r16float': { gl: 33325, b: 2, c: 1, render: float16_renderable, filter: 'float16-filterable-webgl', rb: true },
|
|
98
|
-
'r16unorm-webgl': { gl: 33322, b: 2, c: 1, f: norm16_renderable, rb: true },
|
|
99
|
-
'r16snorm-webgl': { gl: 36760, b: 2, c: 1, f: snorm16_renderable },
|
|
100
|
-
// Packed 16-bit formats
|
|
101
|
-
'rgba4unorm-webgl': { gl: 32854, b: 2, c: 4, wgpu: false, rb: true },
|
|
102
|
-
'rgb565unorm-webgl': { gl: 36194, b: 2, c: 4, wgpu: false, rb: true },
|
|
103
|
-
'rgb5a1unorm-webgl': { gl: 32855, b: 2, c: 4, wgpu: false, rb: true },
|
|
104
|
-
// 24-bit formats
|
|
105
|
-
'rgb8unorm-webgl': { gl: 32849, b: 3, c: 3, wgpu: false },
|
|
106
|
-
'rgb8snorm-webgl': { gl: 36758, b: 3, c: 3, wgpu: false },
|
|
107
|
-
// 32-bit formats
|
|
108
|
-
'rgba8unorm': { gl: 32856, b: 4, c: 2, bpp: 4 },
|
|
109
|
-
'rgba8unorm-srgb': { gl: 35907, b: 4, c: 4, bpp: 4 },
|
|
110
|
-
'rgba8snorm': { gl: 36759, b: 4, c: 4, render: snorm8_renderable },
|
|
111
|
-
'rgba8uint': { gl: 36220, b: 4, c: 4, bpp: 4 },
|
|
112
|
-
'rgba8sint': { gl: 36238, b: 4, c: 4, bpp: 4 },
|
|
113
|
-
// reverse colors, webgpu only
|
|
114
|
-
'bgra8unorm': { b: 4, c: 4 },
|
|
115
|
-
'bgra8unorm-srgb': { b: 4, c: 4 },
|
|
116
|
-
'rg16uint': { gl: 33338, b: 4, c: 1, bpp: 4 },
|
|
117
|
-
'rg16sint': { gl: 33337, b: 4, c: 2, bpp: 4 },
|
|
118
|
-
'rg16float': { gl: 33327, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true },
|
|
119
|
-
'rg16unorm-webgl': { gl: 33324, b: 2, c: 2, render: norm16_renderable },
|
|
120
|
-
'rg16snorm-webgl': { gl: 36761, b: 2, c: 2, render: snorm16_renderable },
|
|
121
|
-
'r32uint': { gl: 33334, b: 4, c: 1, bpp: 4, rb: true },
|
|
122
|
-
'r32sint': { gl: 33333, b: 4, c: 1, bpp: 4, rb: true },
|
|
123
|
-
'r32float': { gl: 33326, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable },
|
|
124
|
-
// Packed 32-bit formats
|
|
125
|
-
'rgb9e5ufloat': { gl: 35901, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable }, // , filter: true},
|
|
126
|
-
'rg11b10ufloat': { gl: 35898, b: 4, c: 3, p: 1, render: float32_renderable, rb: true },
|
|
127
|
-
'rgb10a2unorm': { gl: 32857, b: 4, c: 4, p: 1, rb: true },
|
|
128
|
-
'rgb10a2uint-webgl': { b: 4, c: 4, gl: 36975, p: 1, wgpu: false, bpp: 4, rb: true },
|
|
129
|
-
// 48-bit formats
|
|
130
|
-
'rgb16unorm-webgl': { gl: 32852, b: 2, c: 3, f: norm16_renderable }, // rgb not renderable
|
|
131
|
-
'rgb16snorm-webgl': { gl: 36762, b: 2, c: 3, f: norm16_renderable }, // rgb not renderable
|
|
132
|
-
// 64-bit formats
|
|
133
|
-
'rg32uint': { gl: 33340, b: 8, c: 2, rb: true },
|
|
134
|
-
'rg32sint': { gl: 33339, b: 8, c: 2, rb: true },
|
|
135
|
-
'rg32float': { gl: 33328, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, rb: true },
|
|
136
|
-
'rgba16uint': { gl: 36214, b: 8, c: 4, rb: true },
|
|
137
|
-
'rgba16sint': { gl: 36232, b: 8, c: 4, rb: true },
|
|
138
|
-
'rgba16float': { gl: 34842, b: 8, c: 4, render: float16_renderable, filter: float16_filterable },
|
|
139
|
-
'rgba16unorm-webgl': { gl: 32859, b: 2, c: 4, render: norm16_renderable, rb: true },
|
|
140
|
-
'rgba16snorm-webgl': { gl: 36763, b: 2, c: 4, render: snorm16_renderable },
|
|
141
|
-
// 96-bit formats (deprecated!)
|
|
142
|
-
'rgb32float-webgl': { gl: 34837, render: float32_renderable, filter: float32_filterable,
|
|
143
|
-
gl2ext: EXT_color_buffer_float, dataFormat: 6407, types: [5126] },
|
|
144
|
-
// 128-bit formats
|
|
145
|
-
'rgba32uint': { gl: 36208, b: 16, c: 4, rb: true },
|
|
146
|
-
'rgba32sint': { gl: 36226, b: 16, c: 4, rb: true },
|
|
147
|
-
'rgba32float': { gl: 34836, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, rb: true },
|
|
148
|
-
// Depth and stencil formats
|
|
149
|
-
'stencil8': { gl: 36168, b: 1, c: 1, attachment: 36128, rb: true }, // 8 stencil bits
|
|
150
|
-
'depth16unorm': { gl: 33189, b: 2, c: 1, attachment: 36096,
|
|
151
|
-
dataFormat: 6402, types: [5123], rb: true }, // 16 depth bits
|
|
152
|
-
'depth24plus': { gl: 33190, b: 3, c: 1, attachment: 36096,
|
|
153
|
-
dataFormat: 6402, types: [5125] },
|
|
154
|
-
'depth32float': { gl: 36012, b: 4, c: 1, attachment: 36096,
|
|
155
|
-
dataFormat: 6402, types: [5126], rb: true },
|
|
156
|
-
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
157
|
-
'depth24plus-stencil8': { gl: 35056, b: 4, c: 2, p: 1, attachment: 33306, rb: true, depthTexture: true,
|
|
158
|
-
dataFormat: 34041, types: [34042] },
|
|
159
|
-
// "depth32float-stencil8" feature - TODO below is render buffer only?
|
|
160
|
-
'depth32float-stencil8': { gl: 36013, b: 5, c: 2, p: 1, attachment: 33306,
|
|
161
|
-
dataFormat: 34041, types: [36269], rb: true },
|
|
162
|
-
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
163
|
-
'bc1-rgb-unorm-webgl': { gl: 33776, x: X_S3TC, f: texture_compression_bc },
|
|
164
|
-
'bc1-rgb-unorm-srgb-webgl': { gl: 35916, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
165
|
-
'bc1-rgba-unorm': { gl: 33777, x: X_S3TC, f: texture_compression_bc },
|
|
166
|
-
'bc1-rgba-unorm-srgb': { gl: 35916, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
167
|
-
'bc2-rgba-unorm': { gl: 33778, x: X_S3TC, f: texture_compression_bc },
|
|
168
|
-
'bc2-rgba-unorm-srgb': { gl: 35918, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
169
|
-
'bc3-rgba-unorm': { gl: 33779, x: X_S3TC, f: texture_compression_bc },
|
|
170
|
-
'bc3-rgba-unorm-srgb': { gl: 35919, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
171
|
-
'bc4-r-unorm': { gl: 36283, x: X_RGTC, f: texture_compression_bc },
|
|
172
|
-
'bc4-r-snorm': { gl: 36284, x: X_RGTC, f: texture_compression_bc },
|
|
173
|
-
'bc5-rg-unorm': { gl: 36285, x: X_RGTC, f: texture_compression_bc },
|
|
174
|
-
'bc5-rg-snorm': { gl: 36286, x: X_RGTC, f: texture_compression_bc },
|
|
175
|
-
'bc6h-rgb-ufloat': { gl: 36495, x: X_BPTC, f: texture_compression_bc },
|
|
176
|
-
'bc6h-rgb-float': { gl: 36494, x: X_BPTC, f: texture_compression_bc },
|
|
177
|
-
'bc7-rgba-unorm': { gl: 36492, x: X_BPTC, f: texture_compression_bc },
|
|
178
|
-
'bc7-rgba-unorm-srgb': { gl: 36493, x: X_BPTC, f: texture_compression_bc },
|
|
179
|
-
// WEBGL_compressed_texture_etc: device.features.has("texture-compression-etc2")
|
|
180
|
-
// Note: Supposedly guaranteed availability compressed formats in WebGL2, but through CPU decompression
|
|
181
|
-
'etc2-rgb8unorm': { gl: 37492, f: texture_compression_etc2 },
|
|
182
|
-
'etc2-rgb8unorm-srgb': { gl: 37494, f: texture_compression_etc2 },
|
|
183
|
-
'etc2-rgb8a1unorm': { gl: 37496, f: texture_compression_etc2 },
|
|
184
|
-
'etc2-rgb8a1unorm-srgb': { gl: 37497, f: texture_compression_etc2 },
|
|
185
|
-
'etc2-rgba8unorm': { gl: 37493, f: texture_compression_etc2 },
|
|
186
|
-
'etc2-rgba8unorm-srgb': { gl: 37495, f: texture_compression_etc2 },
|
|
187
|
-
'eac-r11unorm': { gl: 37488, f: texture_compression_etc2 },
|
|
188
|
-
'eac-r11snorm': { gl: 37489, f: texture_compression_etc2 },
|
|
189
|
-
'eac-rg11unorm': { gl: 37490, f: texture_compression_etc2 },
|
|
190
|
-
'eac-rg11snorm': { gl: 37491, f: texture_compression_etc2 },
|
|
191
|
-
// X_ASTC compressed formats: device.features.has("texture-compression-astc")
|
|
192
|
-
'astc-4x4-unorm': { gl: 37808, f: texture_compression_astc },
|
|
193
|
-
'astc-4x4-unorm-srgb': { gl: 37840, f: texture_compression_astc },
|
|
194
|
-
'astc-5x4-unorm': { gl: 37809, f: texture_compression_astc },
|
|
195
|
-
'astc-5x4-unorm-srgb': { gl: 37841, f: texture_compression_astc },
|
|
196
|
-
'astc-5x5-unorm': { gl: 37810, f: texture_compression_astc },
|
|
197
|
-
'astc-5x5-unorm-srgb': { gl: 37842, f: texture_compression_astc },
|
|
198
|
-
'astc-6x5-unorm': { gl: 37811, f: texture_compression_astc },
|
|
199
|
-
'astc-6x5-unorm-srgb': { gl: 37843, f: texture_compression_astc },
|
|
200
|
-
'astc-6x6-unorm': { gl: 37812, f: texture_compression_astc },
|
|
201
|
-
'astc-6x6-unorm-srgb': { gl: 37844, f: texture_compression_astc },
|
|
202
|
-
'astc-8x5-unorm': { gl: 37813, f: texture_compression_astc },
|
|
203
|
-
'astc-8x5-unorm-srgb': { gl: 37845, f: texture_compression_astc },
|
|
204
|
-
'astc-8x6-unorm': { gl: 37814, f: texture_compression_astc },
|
|
205
|
-
'astc-8x6-unorm-srgb': { gl: 37846, f: texture_compression_astc },
|
|
206
|
-
'astc-8x8-unorm': { gl: 37815, f: texture_compression_astc },
|
|
207
|
-
'astc-8x8-unorm-srgb': { gl: 37847, f: texture_compression_astc },
|
|
208
|
-
'astc-10x5-unorm': { gl: 37819, f: texture_compression_astc },
|
|
209
|
-
'astc-10x5-unorm-srgb': { gl: 37851, f: texture_compression_astc },
|
|
210
|
-
'astc-10x6-unorm': { gl: 37817, f: texture_compression_astc },
|
|
211
|
-
'astc-10x6-unorm-srgb': { gl: 37849, f: texture_compression_astc },
|
|
212
|
-
'astc-10x8-unorm': { gl: 37818, f: texture_compression_astc },
|
|
213
|
-
'astc-10x8-unorm-srgb': { gl: 37850, f: texture_compression_astc },
|
|
214
|
-
'astc-10x10-unorm': { gl: 37819, f: texture_compression_astc },
|
|
215
|
-
'astc-10x10-unorm-srgb': { gl: 37851, f: texture_compression_astc },
|
|
216
|
-
'astc-12x10-unorm': { gl: 37820, f: texture_compression_astc },
|
|
217
|
-
'astc-12x10-unorm-srgb': { gl: 37852, f: texture_compression_astc },
|
|
218
|
-
'astc-12x12-unorm': { gl: 37821, f: texture_compression_astc },
|
|
219
|
-
'astc-12x12-unorm-srgb': { gl: 37853, f: texture_compression_astc },
|
|
220
|
-
// WEBGL_compressed_texture_pvrtc
|
|
221
|
-
'pvrtc-rgb4unorm-webgl': { gl: 35840, f: texture_compression_pvrtc_webgl },
|
|
222
|
-
'pvrtc-rgba4unorm-webgl': { gl: 35842, f: texture_compression_pvrtc_webgl },
|
|
223
|
-
'pvrtc-rbg2unorm-webgl': { gl: 35841, f: texture_compression_pvrtc_webgl },
|
|
224
|
-
'pvrtc-rgba2unorm-webgl': { gl: 35843, f: texture_compression_pvrtc_webgl },
|
|
225
|
-
// WEBGL_compressed_texture_etc1
|
|
226
|
-
'etc1-rbg-unorm-webgl': { gl: 36196, f: texture_compression_etc1_webgl },
|
|
227
|
-
// WEBGL_compressed_texture_atc
|
|
228
|
-
'atc-rgb-unorm-webgl': { gl: 35986, f: texture_compression_atc_webgl },
|
|
229
|
-
'atc-rgba-unorm-webgl': { gl: 35986, f: texture_compression_atc_webgl },
|
|
230
|
-
'atc-rgbai-unorm-webgl': { gl: 34798, f: texture_compression_atc_webgl }
|
|
231
|
-
};
|
|
232
|
-
/** Legal combinations for internalFormat, format and type *
|
|
233
|
-
// [GL.DEPTH_COMPONENT]: {types: [GL.UNSIGNED_SHORT, GL.UNSIGNED_INT, GL.UNSIGNED_INT_24_8]},
|
|
234
|
-
// [GL.DEPTH_STENCIL]: ,
|
|
235
|
-
// Sized texture format
|
|
236
|
-
// R
|
|
237
|
-
[GL.R8]: {dataFormat: GL.RED, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
238
|
-
[GL.R16F]: {dataFormat: GL.RED, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
239
|
-
[GL.R8UI]: {dataFormat: GL.RED_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
240
|
-
// // RG
|
|
241
|
-
[GL.RG8]: {dataFormat: GL.RG, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
242
|
-
[GL.RG16F]: {dataFormat: GL.RG, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
243
|
-
[GL.RG8UI]: {dataFormat: GL.RG_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
244
|
-
// // RGB
|
|
245
|
-
[GL.RGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
246
|
-
[GL.SRGB8]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
247
|
-
[GL.RGB16F]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
248
|
-
[GL.RGB8UI]: {dataFormat: GL.RGB_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
249
|
-
// // RGBA
|
|
250
|
-
|
|
251
|
-
[GL.RGB565]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_6_5], gl2: true},
|
|
252
|
-
[GL.R11F_G11F_B10F]: {dataFormat: GL.RGB, types: [GL.UNSIGNED_INT_10F_11F_11F_REV, GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
253
|
-
[GL.RGB9_E5]: {dataFormat: GL.RGB, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
254
|
-
[GL.RGBA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true},
|
|
255
|
-
[GL.SRGB8_ALPHA8]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE], gl2: true, gl1ext: EXT_SRGB},
|
|
256
|
-
[GL.RGB5_A1]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_5_5_5_1], gl2: true},
|
|
257
|
-
[GL.RGBA4]: {dataFormat: GL.RGBA, types: [GL.UNSIGNED_BYTE, GL.UNSIGNED_SHORT_4_4_4_4], gl2: true},
|
|
258
|
-
[GL.RGBA16F]: {dataFormat: GL.RGBA, types: [GL.HALF_FLOAT, GL.FLOAT], gl2: true},
|
|
259
|
-
[GL.RGBA8UI]: {dataFormat: GL.RGBA_INTEGER, types: [GL.UNSIGNED_BYTE], gl2: true}
|
|
260
|
-
*/
|
|
261
|
-
/* This table is now baked into the above table
|
|
262
|
-
type RenderbufferFormat = {
|
|
263
|
-
bpp: number;
|
|
264
|
-
gl2?: boolean;
|
|
265
|
-
ext?: string;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
export const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
|
|
269
|
-
[GL.DEPTH_COMPONENT16]: {bpp: 2}, // 16 depth bits.
|
|
270
|
-
// TODO - Not clear which webgpu value to map this to.
|
|
271
|
-
// [GL.DEPTH_COMPONENT24]: {gl2: true, bpp: 3},
|
|
272
|
-
[GL.DEPTH_COMPONENT32F]: {gl2: true, bpp: 4},
|
|
273
|
-
|
|
274
|
-
[GL.STENCIL_INDEX8]: {bpp: 1}, // 8 stencil bits.
|
|
275
|
-
|
|
276
|
-
[GL.DEPTH_STENCIL]: {bpp: 4},
|
|
277
|
-
[GL.DEPTH24_STENCIL8]: {gl2: true, bpp: 4},
|
|
278
|
-
[GL.DEPTH32F_STENCIL8]: {gl2: true, bpp: 5},
|
|
279
|
-
|
|
280
|
-
// When using a WebGL 1 context, color renderbuffer formats are limited
|
|
281
|
-
[GL.RGBA4]: {gl2: true, bpp: 2},
|
|
282
|
-
[GL.RGB565]: {gl2: true, bpp: 2},
|
|
283
|
-
[GL.RGB5_A1]: {gl2: true, bpp: 2},
|
|
284
|
-
|
|
285
|
-
// When using a WebGL 2 context, the following values are available additionally:
|
|
286
|
-
[GL.R8]: {gl2: true, bpp: 1},
|
|
287
|
-
[GL.R8UI]: {gl2: true, bpp: 1},
|
|
288
|
-
[GL.R8I]: {gl2: true, bpp: 1},
|
|
289
|
-
[GL.R16UI]: {gl2: true, bpp: 2},
|
|
290
|
-
[GL.R16I]: {gl2: true, bpp: 2},
|
|
291
|
-
[GL.R32UI]: {gl2: true, bpp: 4},
|
|
292
|
-
[GL.R32I]: {gl2: true, bpp: 4},
|
|
293
|
-
[GL.RG8]: {gl2: true, bpp: 2},
|
|
294
|
-
[GL.RG8UI]: {gl2: true, bpp: 2},
|
|
295
|
-
[GL.RG8I]: {gl2: true, bpp: 2},
|
|
296
|
-
[GL.RG16UI]: {gl2: true, bpp: 4},
|
|
297
|
-
[GL.RG16I]: {gl2: true, bpp: 4},
|
|
298
|
-
[GL.RG32UI]: {gl2: true, bpp: 8},
|
|
299
|
-
[GL.RG32I]: {gl2: true, bpp: 8},
|
|
300
|
-
[GL.RGB8]: {gl2: true, bpp: 3},
|
|
301
|
-
[GL.RGBA8]: {gl2: true, bpp: 4},
|
|
302
|
-
// [GL.SRGB8_ALPHA8]: {gl2: true, gl1: SRGB}, // When using the EXT_sRGB WebGL1 extension
|
|
303
|
-
[GL.RGB10_A2]: {gl2: true, bpp: 4},
|
|
304
|
-
[GL.RGBA8UI]: {gl2: true, bpp: 4},
|
|
305
|
-
[GL.RGBA8I]: {gl2: true, bpp: 4},
|
|
306
|
-
[GL.RGB10_A2UI]: {gl2: true, bpp: 4},
|
|
307
|
-
[GL.RGBA16UI]: {gl2: true, bpp: 8},
|
|
308
|
-
[GL.RGBA16I]: {gl2: true, bpp: 8},
|
|
309
|
-
[GL.RGBA32I]: {gl2: true, bpp: 16},
|
|
310
|
-
[GL.RGBA32UI]: {gl2: true, bpp: 16},
|
|
311
|
-
|
|
312
|
-
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
313
|
-
[GL.R16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 2},
|
|
314
|
-
[GL.RG16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4},
|
|
315
|
-
[GL.RGBA16F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
|
|
316
|
-
[GL.R32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4},
|
|
317
|
-
[GL.RG32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
|
|
318
|
-
// TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
|
|
319
|
-
[GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 16},
|
|
320
|
-
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2},
|
|
321
|
-
[GL.R11F_G11F_B10F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4}
|
|
322
|
-
};
|
|
323
|
-
*/
|
|
324
|
-
/** @deprecated should be removed */
|
|
325
|
-
const DATA_FORMAT_CHANNELS = {
|
|
326
|
-
[6403]: 1,
|
|
327
|
-
[36244]: 1,
|
|
328
|
-
[33319]: 2,
|
|
329
|
-
[33320]: 2,
|
|
330
|
-
[6407]: 3,
|
|
331
|
-
[36248]: 3,
|
|
332
|
-
[6408]: 4,
|
|
333
|
-
[36249]: 4,
|
|
334
|
-
[6402]: 1,
|
|
335
|
-
[34041]: 1,
|
|
336
|
-
[6406]: 1,
|
|
337
|
-
[6409]: 1,
|
|
338
|
-
[6410]: 2
|
|
339
|
-
};
|
|
340
|
-
/** @deprecated should be removed */
|
|
341
|
-
const TYPE_SIZES = {
|
|
342
|
-
[5126]: 4,
|
|
343
|
-
[5125]: 4,
|
|
344
|
-
[5124]: 4,
|
|
345
|
-
[5123]: 2,
|
|
346
|
-
[5122]: 2,
|
|
347
|
-
[5131]: 2,
|
|
348
|
-
[5120]: 1,
|
|
349
|
-
[5121]: 1
|
|
350
|
-
};
|
|
351
|
-
// FUNCTIONS
|
|
352
|
-
/** Checks if a texture format is supported */
|
|
353
|
-
export function isTextureFormatSupported(gl, format, extensions) {
|
|
354
|
-
const info = TEXTURE_FORMATS[format];
|
|
355
|
-
if (!info) {
|
|
356
|
-
return false;
|
|
357
|
-
}
|
|
358
|
-
// Check that we have a GL constant
|
|
359
|
-
if (info.gl === undefined) {
|
|
360
|
-
return false;
|
|
361
|
-
}
|
|
362
|
-
const feature = info.f;
|
|
363
|
-
if (feature) {
|
|
364
|
-
return checkTextureFeature(gl, feature, extensions);
|
|
365
|
-
}
|
|
366
|
-
// Check extensions
|
|
367
|
-
const extension = info.x || info.gl2ext;
|
|
368
|
-
if (extension) {
|
|
369
|
-
return Boolean(getWebGLExtension(gl, extension, extensions));
|
|
370
|
-
}
|
|
371
|
-
return true;
|
|
372
|
-
}
|
|
373
|
-
export function isRenderbufferFormatSupported(gl, format, extensions) {
|
|
374
|
-
// Note: Order is important since the function call initializes extensions.
|
|
375
|
-
return isTextureFormatSupported(gl, format, extensions) && Boolean(TEXTURE_FORMATS[format]?.rb);
|
|
376
|
-
}
|
|
377
|
-
/** Checks if a texture format is supported */
|
|
378
|
-
export function getTextureFormatSupport(gl, format, extensions) {
|
|
379
|
-
const info = TEXTURE_FORMATS[format];
|
|
380
|
-
if (!info) {
|
|
381
|
-
return { supported: false };
|
|
382
|
-
}
|
|
383
|
-
// let decoded;
|
|
384
|
-
// try {
|
|
385
|
-
// decoded = decodeTextureFormat(format);
|
|
386
|
-
// } catch {}
|
|
387
|
-
// Support Check that we have a GL constant
|
|
388
|
-
let supported = info.gl === undefined;
|
|
389
|
-
supported = supported && checkTextureFeature(gl, info.f, extensions);
|
|
390
|
-
// Filtering
|
|
391
|
-
// const filterable = info.filter
|
|
392
|
-
// ? checkTextureFeature(gl, infofilter])
|
|
393
|
-
// : decoded && !decoded.signed;
|
|
394
|
-
// const renderable = info.filter
|
|
395
|
-
// ? checkTextureFeature(gl, inforender])
|
|
396
|
-
// : decoded && !decoded.signed;
|
|
397
|
-
return {
|
|
398
|
-
supported,
|
|
399
|
-
renderable: supported && checkTextureFeature(gl, info.render, extensions),
|
|
400
|
-
filterable: supported && checkTextureFeature(gl, info.filter, extensions),
|
|
401
|
-
blendable: false, // tod,
|
|
402
|
-
storable: false
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
/** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
|
|
406
|
-
export function isTextureFormatFilterable(gl, format, extensions) {
|
|
407
|
-
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
408
|
-
return false;
|
|
409
|
-
}
|
|
410
|
-
if (format.startsWith('depth') || format.startsWith('stencil')) {
|
|
411
|
-
return false;
|
|
412
|
-
}
|
|
413
|
-
try {
|
|
414
|
-
const decoded = decodeTextureFormat(format);
|
|
415
|
-
if (decoded.signed) {
|
|
416
|
-
return false;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
catch {
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
if (format.endsWith('32float')) {
|
|
423
|
-
return Boolean(getWebGLExtension(gl, 'OES_texture_float_linear, extensions', extensions));
|
|
424
|
-
}
|
|
425
|
-
if (format.endsWith('16float')) {
|
|
426
|
-
return Boolean(getWebGLExtension(gl, 'OES_texture_half_float_linear, extensions', extensions));
|
|
427
|
-
}
|
|
428
|
-
return true;
|
|
429
|
-
}
|
|
430
|
-
export function isTextureFormatRenderable(gl, format, extensions) {
|
|
431
|
-
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
432
|
-
return false;
|
|
433
|
-
}
|
|
434
|
-
if (typeof format === 'number') {
|
|
435
|
-
return false; // isTextureFormatFilterableWebGL(gl, format);
|
|
436
|
-
}
|
|
437
|
-
// TODO depends on device...
|
|
438
|
-
return true;
|
|
439
|
-
}
|
|
440
|
-
/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
|
|
441
|
-
export function getTextureFormatWebGL(format) {
|
|
442
|
-
const formatData = TEXTURE_FORMATS[format];
|
|
443
|
-
const webglFormat = convertTextureFormatToGL(format);
|
|
444
|
-
const decoded = decodeTextureFormat(format);
|
|
445
|
-
return {
|
|
446
|
-
internalFormat: webglFormat,
|
|
447
|
-
format: formatData?.dataFormat ||
|
|
448
|
-
getWebGLPixelDataFormat(decoded.channels, decoded.integer, decoded.normalized, webglFormat),
|
|
449
|
-
// depth formats don't have a type
|
|
450
|
-
type: decoded.dataType
|
|
451
|
-
? getGLFromVertexType(decoded.dataType)
|
|
452
|
-
: formatData?.types?.[0] || 5121,
|
|
453
|
-
compressed: decoded.compressed || false
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
export function getDepthStencilAttachmentWebGL(format) {
|
|
457
|
-
const info = TEXTURE_FORMATS[format];
|
|
458
|
-
if (!info?.attachment) {
|
|
459
|
-
throw new Error(`${format} is not a depth stencil format`);
|
|
460
|
-
}
|
|
461
|
-
return info.attachment;
|
|
462
|
-
}
|
|
463
|
-
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
464
|
-
export function getTextureFormatBytesPerPixel(format) {
|
|
465
|
-
// TODO remove webgl1 support
|
|
466
|
-
const params = getTextureFormatWebGL(format);
|
|
467
|
-
// NOTE(Tarek): Default to RGBA bytes
|
|
468
|
-
const channels = DATA_FORMAT_CHANNELS[params.format] || 4;
|
|
469
|
-
const channelSize = TYPE_SIZES[params.type] || 1;
|
|
470
|
-
return channels * channelSize;
|
|
471
|
-
}
|
|
472
|
-
// DATA TYPE HELPERS
|
|
473
|
-
export function getWebGLPixelDataFormat(channels, integer, normalized, format) {
|
|
474
|
-
// WebGL1 formats use same internalFormat
|
|
475
|
-
if (format === 6408 || format === 6407) {
|
|
476
|
-
return format;
|
|
477
|
-
}
|
|
478
|
-
// prettier-ignore
|
|
479
|
-
switch (channels) {
|
|
480
|
-
case 'r': return integer && !normalized ? 36244 : 6403;
|
|
481
|
-
case 'rg': return integer && !normalized ? 33320 : 33319;
|
|
482
|
-
case 'rgb': return integer && !normalized ? 36248 : 6407;
|
|
483
|
-
case 'rgba': return integer && !normalized ? 36249 : 6408;
|
|
484
|
-
case 'bgra': throw new Error('bgra pixels not supported by WebGL');
|
|
485
|
-
default: return 6408;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Map WebGPU style texture format strings to GL constants
|
|
490
|
-
*/
|
|
491
|
-
function convertTextureFormatToGL(format) {
|
|
492
|
-
const formatInfo = TEXTURE_FORMATS[format];
|
|
493
|
-
const webglFormat = formatInfo?.gl;
|
|
494
|
-
if (webglFormat === undefined) {
|
|
495
|
-
throw new Error(`Unsupported texture format ${format}`);
|
|
496
|
-
}
|
|
497
|
-
return webglFormat;
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
|
|
501
|
-
export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
|
|
502
|
-
if (typeof format === 'string') {
|
|
503
|
-
return format;
|
|
504
|
-
}
|
|
505
|
-
const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
|
|
506
|
-
if (!entry) {
|
|
507
|
-
throw new Error(`Unknown texture format ${format}`);
|
|
508
|
-
}
|
|
509
|
-
return entry[0] as TextureFormat;
|
|
510
|
-
}
|
|
511
|
-
*/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAIhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sCAAsC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,QAAA,MAAM,uBAAuB;;;;;;;;CAQ5B,CAAC;AAEF,qBAAa,QAAS,YAAW,cAAc;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,MAAM;IAOtE,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM;IAY1D,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,cAAc,EAAE,GAAG,QAAQ;gBAI5C,GAAG,SAAS,EAAE,cAAc,EAAE;IAK1C,QAAQ,IAAI,MAAM;IAOlB,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAKD,OAAO,CAAC,KAAK,GAAE,cAAmB,GAAG,IAAI;CA2E1C;AAGD,OAAO,EAAC,uBAAuB,EAAC,CAAC"}
|
package/dist/classic/clear.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Device, Framebuffer } from '@luma.gl/core';
|
|
2
|
-
/**
|
|
3
|
-
* Optionally clears depth, color and stencil buffers
|
|
4
|
-
* @deprecated Set clear color when creating a RenderPass.
|
|
5
|
-
*/
|
|
6
|
-
export declare function clear(device: Device, options?: {
|
|
7
|
-
framebuffer?: Framebuffer;
|
|
8
|
-
color?: any;
|
|
9
|
-
depth?: any;
|
|
10
|
-
stencil?: any;
|
|
11
|
-
}): void;
|
|
12
|
-
/**
|
|
13
|
-
* WebGL2 - clear a specific drawing buffer
|
|
14
|
-
* @deprecated Set clear color when creating a RenderPass
|
|
15
|
-
*/
|
|
16
|
-
export declare function clearBuffer(device: Device, options?: {
|
|
17
|
-
framebuffer?: Framebuffer;
|
|
18
|
-
buffer?: any;
|
|
19
|
-
drawBuffer?: any;
|
|
20
|
-
value?: any;
|
|
21
|
-
}): void;
|
|
22
|
-
//# sourceMappingURL=clear.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/classic/clear.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAclD;;;GAGG;AACH,wBAAgB,KAAK,CACnB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAA;CAAC,GAC7E,IAAI,CAsCN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,MAAM,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAA;CAAC,QA2CnF"}
|
package/dist/classic/clear.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { withGLParameters } from "../context/state-tracker/with-parameters.js";
|
|
5
|
-
// Should collapse during minification
|
|
6
|
-
const GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
7
|
-
const GL_STENCIL_BUFFER_BIT = 0x00000400;
|
|
8
|
-
const GL_COLOR_BUFFER_BIT = 0x00004000;
|
|
9
|
-
const GL_COLOR = 0x1800;
|
|
10
|
-
const GL_DEPTH = 0x1801;
|
|
11
|
-
const GL_STENCIL = 0x1802;
|
|
12
|
-
const GL_DEPTH_STENCIL = 0x84f9;
|
|
13
|
-
/**
|
|
14
|
-
* Optionally clears depth, color and stencil buffers
|
|
15
|
-
* @deprecated Set clear color when creating a RenderPass.
|
|
16
|
-
*/
|
|
17
|
-
export function clear(device, options) {
|
|
18
|
-
const { framebuffer = null, color = null, depth = null, stencil = null } = options || {};
|
|
19
|
-
const parameters = {};
|
|
20
|
-
if (framebuffer) {
|
|
21
|
-
parameters.framebuffer = framebuffer;
|
|
22
|
-
}
|
|
23
|
-
let clearFlags = 0;
|
|
24
|
-
if (color) {
|
|
25
|
-
clearFlags |= GL_COLOR_BUFFER_BIT;
|
|
26
|
-
if (color !== true) {
|
|
27
|
-
parameters.clearColor = color;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (depth) {
|
|
31
|
-
clearFlags |= GL_DEPTH_BUFFER_BIT;
|
|
32
|
-
if (depth !== true) {
|
|
33
|
-
parameters.clearDepth = depth;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (stencil) {
|
|
37
|
-
clearFlags |= GL_STENCIL_BUFFER_BIT;
|
|
38
|
-
if (depth !== true) {
|
|
39
|
-
parameters.clearStencil = depth;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// assert(clearFlags !== 0, ERR_ARGUMENTS);
|
|
43
|
-
// Temporarily set any clear "colors" and call clear
|
|
44
|
-
const gl = device.gl;
|
|
45
|
-
withGLParameters(gl, parameters, () => {
|
|
46
|
-
gl.clear(clearFlags);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* WebGL2 - clear a specific drawing buffer
|
|
51
|
-
* @deprecated Set clear color when creating a RenderPass
|
|
52
|
-
*/
|
|
53
|
-
export function clearBuffer(device, options) {
|
|
54
|
-
const { framebuffer = null, buffer = GL_COLOR, drawBuffer = 0, value = [0, 0, 0, 0] } = options || {};
|
|
55
|
-
const gl = device.gl;
|
|
56
|
-
withGLParameters(gl, { framebuffer }, () => {
|
|
57
|
-
// Method selection per OpenGL ES 3 docs
|
|
58
|
-
switch (buffer) {
|
|
59
|
-
case GL_COLOR:
|
|
60
|
-
switch (value.constructor) {
|
|
61
|
-
case Int32Array:
|
|
62
|
-
gl.clearBufferiv(buffer, drawBuffer, value);
|
|
63
|
-
break;
|
|
64
|
-
case Uint32Array:
|
|
65
|
-
gl.clearBufferuiv(buffer, drawBuffer, value);
|
|
66
|
-
break;
|
|
67
|
-
case Float32Array:
|
|
68
|
-
default:
|
|
69
|
-
gl.clearBufferfv(buffer, drawBuffer, value);
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
case GL_DEPTH:
|
|
73
|
-
gl.clearBufferfv(GL_DEPTH, 0, [value]);
|
|
74
|
-
break;
|
|
75
|
-
case GL_STENCIL:
|
|
76
|
-
gl.clearBufferiv(GL_STENCIL, 0, [value]);
|
|
77
|
-
break;
|
|
78
|
-
case GL_DEPTH_STENCIL:
|
|
79
|
-
const [depth, stencil] = value;
|
|
80
|
-
gl.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
// assert(false, ERR_ARGUMENTS);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|