@luma.gl/webgl 9.1.0-alpha.2 → 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 +19 -11
- 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 -3
- 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 +100 -29
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +231 -240
- 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 +71 -76
- 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 +49 -21
- 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 +45 -23
- 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 +33 -21
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +172 -242
- 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 +21 -0
- package/dist/adapter/webgl-adapter.d.ts.map +1 -0
- package/dist/adapter/webgl-adapter.js +86 -0
- 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 +35 -46
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +100 -156
- package/dist/adapter/webgl-device.js.map +1 -0
- package/dist/context/debug/spector-types.d.ts +1108 -0
- package/dist/context/debug/spector-types.d.ts.map +1 -0
- package/dist/context/debug/spector-types.js +698 -0
- package/dist/context/debug/spector-types.js.map +1 -0
- package/dist/context/debug/spector.d.ts +12 -8
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +24 -17
- 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.d.ts +9 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts.map +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js +182 -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.d.ts +43 -0
- package/dist/context/state-tracker/webgl-state-tracker.d.ts.map +1 -0
- package/dist/context/state-tracker/{track-context-state.js → webgl-state-tracker.js} +45 -74
- package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -0
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +6 -4
- 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 +2397 -2430
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +2273 -2298
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- 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.d.ts +7 -0
- package/dist/utils/uid.d.ts.map +1 -0
- package/dist/utils/uid.js +15 -0
- package/dist/utils/uid.js.map +1 -0
- package/package.json +5 -5
- package/src/adapter/converters/device-parameters.ts +21 -15
- 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 -3
- 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 +410 -64
- 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 +80 -86
- package/src/adapter/resources/webgl-render-pass.ts +72 -45
- package/src/adapter/resources/webgl-render-pipeline.ts +58 -27
- package/src/adapter/resources/webgl-shader.ts +15 -7
- package/src/adapter/resources/webgl-texture.ts +202 -274
- package/src/adapter/webgl-adapter.ts +105 -0
- package/src/adapter/webgl-canvas-context.ts +16 -19
- package/src/adapter/webgl-device.ts +144 -210
- package/src/context/debug/spector-types.ts +1154 -0
- package/src/context/debug/spector.ts +38 -29
- 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/context/polyfills/polyfill-webgl1-extensions.ts +202 -0
- package/src/context/state-tracker/{track-context-state.ts → webgl-state-tracker.ts} +55 -94
- package/src/context/state-tracker/with-parameters.ts +5 -4
- package/src/{classic → deprecated}/accessor.ts +44 -3
- package/src/index.ts +7 -12
- package/src/utils/fill-array.ts +4 -4
- package/src/utils/split-uniforms-and-bindings.ts +3 -3
- package/src/utils/uid.ts +16 -0
- 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 -518
- 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 -63
- package/dist/classic/copy-and-blit.d.ts.map +0 -1
- package/dist/classic/copy-and-blit.js +0 -193
- package/dist/classic/format-utils.d.ts.map +0 -1
- package/dist/classic/typed-array-utils.d.ts.map +0 -1
- package/dist/context/state-tracker/track-context-state.d.ts +0 -22
- package/dist/context/state-tracker/track-context-state.d.ts.map +0 -1
- package/src/adapter/converters/texture-formats.ts +0 -665
- package/src/classic/clear.ts +0 -115
- package/src/classic/copy-and-blit.ts +0 -318
- /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
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
DeviceFeature,
|
|
7
|
+
TextureFormat,
|
|
8
|
+
TextureFormatCapabilities,
|
|
9
|
+
DeviceTextureFormatCapabilities
|
|
10
|
+
} from '@luma.gl/core';
|
|
11
|
+
import {decodeTextureFormat} from '@luma.gl/core';
|
|
12
|
+
import {GL, GLPixelType, GLExtensions, GLTexelDataFormat} from '@luma.gl/constants';
|
|
13
|
+
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
14
|
+
import {getGLFromVertexType} from './vertex-formats';
|
|
15
|
+
|
|
16
|
+
/* eslint-disable camelcase */
|
|
17
|
+
|
|
18
|
+
// TEXTURE FEATURES
|
|
19
|
+
|
|
20
|
+
// Define local webgl extension strings to optimize minification
|
|
21
|
+
const X_S3TC = 'WEBGL_compressed_texture_s3tc'; // BC1, BC2, BC3
|
|
22
|
+
const X_S3TC_SRGB = 'WEBGL_compressed_texture_s3tc_srgb'; // BC1, BC2, BC3
|
|
23
|
+
const X_RGTC = 'EXT_texture_compression_rgtc'; // BC4, BC5
|
|
24
|
+
const X_BPTC = 'EXT_texture_compression_bptc'; // BC6, BC7
|
|
25
|
+
const X_ETC2 = 'WEBGL_compressed_texture_etc'; // Renamed from 'WEBGL_compressed_texture_es3'
|
|
26
|
+
const X_ASTC = 'WEBGL_compressed_texture_astc';
|
|
27
|
+
const X_ETC1 = 'WEBGL_compressed_texture_etc1';
|
|
28
|
+
const X_PVRTC = 'WEBGL_compressed_texture_pvrtc';
|
|
29
|
+
const X_ATC = 'WEBGL_compressed_texture_atc';
|
|
30
|
+
|
|
31
|
+
// Define local webgl extension strings to optimize minification
|
|
32
|
+
const EXT_texture_norm16 = 'EXT_texture_norm16';
|
|
33
|
+
const EXT_render_snorm = 'EXT_render_snorm';
|
|
34
|
+
const EXT_color_buffer_float = 'EXT_color_buffer_float';
|
|
35
|
+
|
|
36
|
+
// prettier-ignore
|
|
37
|
+
export const TEXTURE_FEATURES: Partial<Record<DeviceFeature, string[]>> = {
|
|
38
|
+
'float32-renderable-webgl': ['EXT_color_buffer_float'],
|
|
39
|
+
'float16-renderable-webgl': ['EXT_color_buffer_half_float'],
|
|
40
|
+
'rgb9e5ufloat-renderable-webgl': ['WEBGL_render_shared_exponent'],
|
|
41
|
+
'snorm8-renderable-webgl': [EXT_render_snorm],
|
|
42
|
+
'norm16-renderable-webgl': [EXT_texture_norm16],
|
|
43
|
+
'snorm16-renderable-webgl': [EXT_texture_norm16, EXT_render_snorm],
|
|
44
|
+
|
|
45
|
+
'float32-filterable': ['OES_texture_float_linear'],
|
|
46
|
+
'float16-filterable-webgl': ['OES_texture_half_float_linear'],
|
|
47
|
+
'texture-filterable-anisotropic-webgl': ['EXT_texture_filter_anisotropic'],
|
|
48
|
+
|
|
49
|
+
'texture-blend-float-webgl': ['EXT_float_blend'],
|
|
50
|
+
|
|
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
|
+
|
|
63
|
+
export function isTextureFeature(feature: DeviceFeature): boolean {
|
|
64
|
+
return feature in TEXTURE_FEATURES;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Checks a texture feature (for Device.features). Mainly compressed texture support */
|
|
68
|
+
export function checkTextureFeature(
|
|
69
|
+
gl: WebGL2RenderingContext,
|
|
70
|
+
feature: DeviceFeature,
|
|
71
|
+
extensions: GLExtensions
|
|
72
|
+
): boolean {
|
|
73
|
+
const textureExtensions = TEXTURE_FEATURES[feature] || [];
|
|
74
|
+
return textureExtensions.every(extension => getWebGLExtension(gl, extension, extensions));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// TEXTURE FORMATS
|
|
78
|
+
|
|
79
|
+
/** Map a format to webgl and constants */
|
|
80
|
+
type WebGLFormatInfo = {
|
|
81
|
+
gl?: GL;
|
|
82
|
+
/** compressed */
|
|
83
|
+
x?: string;
|
|
84
|
+
types?: GLPixelType[];
|
|
85
|
+
dataFormat?: GLTexelDataFormat;
|
|
86
|
+
/** if depthTexture is set this is a depth/stencil format that can be set to a texture */
|
|
87
|
+
depthTexture?: boolean;
|
|
88
|
+
/** @deprecated can this format be used with renderbuffers */
|
|
89
|
+
rb?: boolean;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// TABLES
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Texture format data -
|
|
96
|
+
* Exported but can change without notice
|
|
97
|
+
*/
|
|
98
|
+
// prettier-ignore
|
|
99
|
+
export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
100
|
+
// 8-bit formats
|
|
101
|
+
'r8unorm': {gl: GL.R8, rb: true},
|
|
102
|
+
'r8snorm': {gl: GL.R8_SNORM},
|
|
103
|
+
'r8uint': {gl: GL.R8UI, rb: true},
|
|
104
|
+
'r8sint': {gl: GL.R8I, rb: true},
|
|
105
|
+
|
|
106
|
+
// 16-bit formats
|
|
107
|
+
'rg8unorm': {gl: GL.RG8, rb: true},
|
|
108
|
+
'rg8snorm': {gl: GL.RG8_SNORM},
|
|
109
|
+
'rg8uint': {gl: GL.RG8UI, rb: true},
|
|
110
|
+
'rg8sint': {gl: GL.RG8I, rb: true},
|
|
111
|
+
|
|
112
|
+
'r16uint': {gl: GL.R16UI, rb: true},
|
|
113
|
+
'r16sint': {gl: GL.R16I, rb: true},
|
|
114
|
+
'r16float': {gl: GL.R16F, rb: true},
|
|
115
|
+
'r16unorm-webgl': {gl: GL.R16_EXT, rb: true},
|
|
116
|
+
'r16snorm-webgl': {gl: GL.R16_SNORM_EXT},
|
|
117
|
+
|
|
118
|
+
// Packed 16-bit formats
|
|
119
|
+
'rgba4unorm-webgl': {gl: GL.RGBA4, rb: true},
|
|
120
|
+
'rgb565unorm-webgl': {gl: GL.RGB565, rb: true},
|
|
121
|
+
'rgb5a1unorm-webgl': {gl: GL.RGB5_A1, rb: true},
|
|
122
|
+
|
|
123
|
+
// 24-bit formats
|
|
124
|
+
'rgb8unorm-webgl': {gl: GL.RGB8},
|
|
125
|
+
'rgb8snorm-webgl': {gl: GL.RGB8_SNORM},
|
|
126
|
+
|
|
127
|
+
// 32-bit formats
|
|
128
|
+
'rgba8unorm': {gl: GL.RGBA8},
|
|
129
|
+
'rgba8unorm-srgb': {gl: GL.SRGB8_ALPHA8},
|
|
130
|
+
'rgba8snorm': {gl: GL.RGBA8_SNORM},
|
|
131
|
+
'rgba8uint': {gl: GL.RGBA8UI},
|
|
132
|
+
'rgba8sint': {gl: GL.RGBA8I},
|
|
133
|
+
// reverse colors, webgpu only
|
|
134
|
+
'bgra8unorm': {},
|
|
135
|
+
'bgra8unorm-srgb': {},
|
|
136
|
+
|
|
137
|
+
'rg16uint': {gl: GL.RG16UI},
|
|
138
|
+
'rg16sint': {gl: GL.RG16I},
|
|
139
|
+
'rg16float': {gl: GL.RG16F, rb: true},
|
|
140
|
+
'rg16unorm-webgl': {gl: GL.RG16_EXT},
|
|
141
|
+
'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT},
|
|
142
|
+
|
|
143
|
+
'r32uint': {gl: GL.R32UI, rb: true},
|
|
144
|
+
'r32sint': {gl: GL.R32I, rb: true},
|
|
145
|
+
'r32float': {gl: GL.R32F},
|
|
146
|
+
|
|
147
|
+
// Packed 32-bit formats
|
|
148
|
+
'rgb9e5ufloat': {gl: GL.RGB9_E5}, // , filter: true},
|
|
149
|
+
'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, rb: true},
|
|
150
|
+
'rgb10a2unorm': {gl: GL.RGB10_A2, rb: true},
|
|
151
|
+
'rgb10a2uint': {gl: GL.RGB10_A2UI, rb: true},
|
|
152
|
+
|
|
153
|
+
// 48-bit formats
|
|
154
|
+
'rgb16unorm-webgl': {gl: GL.RGB16_EXT}, // rgb not renderable
|
|
155
|
+
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT}, // rgb not renderable
|
|
156
|
+
|
|
157
|
+
// 64-bit formats
|
|
158
|
+
'rg32uint': {gl: GL.RG32UI, rb: true},
|
|
159
|
+
'rg32sint': {gl: GL.RG32I, rb: true},
|
|
160
|
+
'rg32float': {gl: GL.RG32F, rb: true},
|
|
161
|
+
'rgba16uint': {gl: GL.RGBA16UI, rb: true},
|
|
162
|
+
'rgba16sint': {gl: GL.RGBA16I, rb: true},
|
|
163
|
+
'rgba16float': {gl: GL.RGBA16F},
|
|
164
|
+
'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, rb: true},
|
|
165
|
+
'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT},
|
|
166
|
+
|
|
167
|
+
// 96-bit formats (deprecated!)
|
|
168
|
+
'rgb32float-webgl': {gl: GL.RGB32F, x: EXT_color_buffer_float, dataFormat: GL.RGB, types: [GL.FLOAT]},
|
|
169
|
+
|
|
170
|
+
// 128-bit formats
|
|
171
|
+
'rgba32uint': {gl: GL.RGBA32UI, rb: true},
|
|
172
|
+
'rgba32sint': {gl: GL.RGBA32I, rb: true},
|
|
173
|
+
'rgba32float': {gl: GL.RGBA32F, rb: true},
|
|
174
|
+
|
|
175
|
+
// Depth and stencil formats
|
|
176
|
+
'stencil8': {gl: GL.STENCIL_INDEX8, rb: true}, // 8 stencil bits
|
|
177
|
+
|
|
178
|
+
'depth16unorm': {gl: GL.DEPTH_COMPONENT16, dataFormat: GL.DEPTH_COMPONENT, types: [GL.UNSIGNED_SHORT], rb: true}, // 16 depth bits
|
|
179
|
+
'depth24plus': {gl: GL.DEPTH_COMPONENT24, dataFormat: GL.DEPTH_COMPONENT, types: [GL.UNSIGNED_INT]},
|
|
180
|
+
'depth32float': {gl: GL.DEPTH_COMPONENT32F, dataFormat: GL.DEPTH_COMPONENT, types: [GL.FLOAT], rb: true},
|
|
181
|
+
|
|
182
|
+
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
183
|
+
'depth24plus-stencil8': {gl: GL.DEPTH24_STENCIL8, rb: true, depthTexture: true, dataFormat: GL.DEPTH_STENCIL, types: [GL.UNSIGNED_INT_24_8]},
|
|
184
|
+
// "depth32float-stencil8" feature - TODO below is render buffer only?
|
|
185
|
+
'depth32float-stencil8': {gl: GL.DEPTH32F_STENCIL8, dataFormat: GL.DEPTH_STENCIL, types: [GL.FLOAT_32_UNSIGNED_INT_24_8_REV], rb: true},
|
|
186
|
+
|
|
187
|
+
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
188
|
+
|
|
189
|
+
'bc1-rgb-unorm-webgl': {gl: GL.COMPRESSED_RGB_S3TC_DXT1_EXT, x: X_S3TC},
|
|
190
|
+
'bc1-rgb-unorm-srgb-webgl': {gl: GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB},
|
|
191
|
+
|
|
192
|
+
'bc1-rgba-unorm': {gl: GL.COMPRESSED_RGBA_S3TC_DXT1_EXT, x: X_S3TC},
|
|
193
|
+
'bc1-rgba-unorm-srgb': {gl: GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB},
|
|
194
|
+
'bc2-rgba-unorm': {gl: GL.COMPRESSED_RGBA_S3TC_DXT3_EXT, x: X_S3TC},
|
|
195
|
+
'bc2-rgba-unorm-srgb': {gl: GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, x: X_S3TC_SRGB},
|
|
196
|
+
'bc3-rgba-unorm': {gl: GL.COMPRESSED_RGBA_S3TC_DXT5_EXT, x: X_S3TC},
|
|
197
|
+
'bc3-rgba-unorm-srgb': {gl: GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, x: X_S3TC_SRGB},
|
|
198
|
+
'bc4-r-unorm': {gl: GL.COMPRESSED_RED_RGTC1_EXT, x: X_RGTC},
|
|
199
|
+
'bc4-r-snorm': {gl: GL.COMPRESSED_SIGNED_RED_RGTC1_EXT, x: X_RGTC},
|
|
200
|
+
'bc5-rg-unorm': {gl: GL.COMPRESSED_RED_GREEN_RGTC2_EXT, x: X_RGTC},
|
|
201
|
+
'bc5-rg-snorm': {gl: GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, x: X_RGTC},
|
|
202
|
+
'bc6h-rgb-ufloat': {gl: GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, x: X_BPTC},
|
|
203
|
+
'bc6h-rgb-float': {gl: GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, x: X_BPTC},
|
|
204
|
+
'bc7-rgba-unorm': {gl: GL.COMPRESSED_RGBA_BPTC_UNORM_EXT, x: X_BPTC},
|
|
205
|
+
'bc7-rgba-unorm-srgb': {gl: GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, x: X_BPTC},
|
|
206
|
+
|
|
207
|
+
// WEBGL_compressed_texture_etc: device.features.has("texture-compression-etc2")
|
|
208
|
+
// Note: Supposedly guaranteed availability compressed formats in WebGL2, but through CPU decompression
|
|
209
|
+
|
|
210
|
+
'etc2-rgb8unorm': {gl: GL.COMPRESSED_RGB8_ETC2},
|
|
211
|
+
'etc2-rgb8unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ETC2},
|
|
212
|
+
'etc2-rgb8a1unorm': {gl: GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2},
|
|
213
|
+
'etc2-rgb8a1unorm-srgb': {gl: GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2},
|
|
214
|
+
'etc2-rgba8unorm': {gl: GL.COMPRESSED_RGBA8_ETC2_EAC},
|
|
215
|
+
'etc2-rgba8unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC},
|
|
216
|
+
|
|
217
|
+
'eac-r11unorm': {gl: GL.COMPRESSED_R11_EAC},
|
|
218
|
+
'eac-r11snorm': {gl: GL.COMPRESSED_SIGNED_R11_EAC},
|
|
219
|
+
'eac-rg11unorm': {gl: GL.COMPRESSED_RG11_EAC},
|
|
220
|
+
'eac-rg11snorm': {gl: GL.COMPRESSED_SIGNED_RG11_EAC},
|
|
221
|
+
|
|
222
|
+
// X_ASTC compressed formats: device.features.has("texture-compression-astc")
|
|
223
|
+
|
|
224
|
+
'astc-4x4-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_4x4_KHR},
|
|
225
|
+
'astc-4x4-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR},
|
|
226
|
+
'astc-5x4-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_5x4_KHR},
|
|
227
|
+
'astc-5x4-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR},
|
|
228
|
+
'astc-5x5-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_5x5_KHR},
|
|
229
|
+
'astc-5x5-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR},
|
|
230
|
+
'astc-6x5-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_6x5_KHR},
|
|
231
|
+
'astc-6x5-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR},
|
|
232
|
+
'astc-6x6-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_6x6_KHR},
|
|
233
|
+
'astc-6x6-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR},
|
|
234
|
+
'astc-8x5-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_8x5_KHR},
|
|
235
|
+
'astc-8x5-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR},
|
|
236
|
+
'astc-8x6-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_8x6_KHR},
|
|
237
|
+
'astc-8x6-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR},
|
|
238
|
+
'astc-8x8-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_8x8_KHR},
|
|
239
|
+
'astc-8x8-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR},
|
|
240
|
+
'astc-10x5-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x10_KHR},
|
|
241
|
+
'astc-10x5-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR},
|
|
242
|
+
'astc-10x6-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x6_KHR},
|
|
243
|
+
'astc-10x6-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR},
|
|
244
|
+
'astc-10x8-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x8_KHR},
|
|
245
|
+
'astc-10x8-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR},
|
|
246
|
+
'astc-10x10-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x10_KHR},
|
|
247
|
+
'astc-10x10-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR},
|
|
248
|
+
'astc-12x10-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_12x10_KHR},
|
|
249
|
+
'astc-12x10-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR},
|
|
250
|
+
'astc-12x12-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_12x12_KHR},
|
|
251
|
+
'astc-12x12-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR},
|
|
252
|
+
|
|
253
|
+
// WEBGL_compressed_texture_pvrtc
|
|
254
|
+
|
|
255
|
+
'pvrtc-rgb4unorm-webgl': {gl: GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},
|
|
256
|
+
'pvrtc-rgba4unorm-webgl': {gl: GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},
|
|
257
|
+
'pvrtc-rbg2unorm-webgl': {gl: GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG},
|
|
258
|
+
'pvrtc-rgba2unorm-webgl': {gl: GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG},
|
|
259
|
+
|
|
260
|
+
// WEBGL_compressed_texture_etc1
|
|
261
|
+
|
|
262
|
+
'etc1-rbg-unorm-webgl': {gl: GL.COMPRESSED_RGB_ETC1_WEBGL},
|
|
263
|
+
|
|
264
|
+
// WEBGL_compressed_texture_atc
|
|
265
|
+
|
|
266
|
+
'atc-rgb-unorm-webgl': {gl: GL.COMPRESSED_RGB_ATC_WEBGL},
|
|
267
|
+
'atc-rgba-unorm-webgl': {gl: GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL},
|
|
268
|
+
'atc-rgbai-unorm-webgl': {gl: GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
// FUNCTIONS
|
|
272
|
+
|
|
273
|
+
/** Checks if a texture format is supported */
|
|
274
|
+
export function isWebGLTextureFormatCapabilitiesed(
|
|
275
|
+
gl: WebGL2RenderingContext,
|
|
276
|
+
format: TextureFormat,
|
|
277
|
+
extensions: GLExtensions
|
|
278
|
+
): boolean {
|
|
279
|
+
const webglTextureInfo = WEBGL_TEXTURE_FORMATS[format];
|
|
280
|
+
// Check that we have a GL constant
|
|
281
|
+
if (!webglTextureInfo?.gl) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Check extensions
|
|
286
|
+
const extension = webglTextureInfo.x;
|
|
287
|
+
if (extension) {
|
|
288
|
+
return Boolean(getWebGLExtension(gl, extension, extensions));
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Checks if a texture format is supported, renderable, filterable etc */
|
|
294
|
+
export function getTextureFormatCapabilitiesWebGL(
|
|
295
|
+
gl: WebGL2RenderingContext,
|
|
296
|
+
formatSupport: TextureFormatCapabilities,
|
|
297
|
+
extensions: GLExtensions
|
|
298
|
+
): DeviceTextureFormatCapabilities {
|
|
299
|
+
let supported = formatSupport.create;
|
|
300
|
+
const webglFormatInfo = WEBGL_TEXTURE_FORMATS[formatSupport.format];
|
|
301
|
+
|
|
302
|
+
// Support Check that we have a GL constant
|
|
303
|
+
if (webglFormatInfo?.gl === undefined) {
|
|
304
|
+
supported = false;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (webglFormatInfo?.x) {
|
|
308
|
+
supported = supported && Boolean(getWebGLExtension(gl, webglFormatInfo.x, extensions));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return {
|
|
312
|
+
format: formatSupport.format,
|
|
313
|
+
// @ts-ignore
|
|
314
|
+
create: supported && formatSupport.create,
|
|
315
|
+
// @ts-ignore
|
|
316
|
+
render: supported && formatSupport.render,
|
|
317
|
+
// @ts-ignore
|
|
318
|
+
filter: supported && formatSupport.filter,
|
|
319
|
+
// @ts-ignore
|
|
320
|
+
blend: supported && formatSupport.blend,
|
|
321
|
+
// @ts-ignore
|
|
322
|
+
store: supported && formatSupport.store
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
|
|
327
|
+
export function getTextureFormatWebGL(format: TextureFormat): {
|
|
328
|
+
internalFormat: GL;
|
|
329
|
+
format: GLTexelDataFormat;
|
|
330
|
+
type: GLPixelType;
|
|
331
|
+
compressed: boolean;
|
|
332
|
+
} {
|
|
333
|
+
const formatData = WEBGL_TEXTURE_FORMATS[format];
|
|
334
|
+
const webglFormat = convertTextureFormatToGL(format);
|
|
335
|
+
const decoded = decodeTextureFormat(format);
|
|
336
|
+
return {
|
|
337
|
+
internalFormat: webglFormat,
|
|
338
|
+
format:
|
|
339
|
+
formatData?.dataFormat ||
|
|
340
|
+
getWebGLPixelDataFormat(decoded.channels, decoded.integer, decoded.normalized, webglFormat),
|
|
341
|
+
// depth formats don't have a type
|
|
342
|
+
type: decoded.dataType
|
|
343
|
+
? getGLFromVertexType(decoded.dataType)
|
|
344
|
+
: formatData?.types?.[0] || GL.UNSIGNED_BYTE,
|
|
345
|
+
compressed: decoded.compressed || false
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function getDepthStencilAttachmentWebGL(
|
|
350
|
+
format: TextureFormat
|
|
351
|
+
): GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT {
|
|
352
|
+
const formatInfo = decodeTextureFormat(format);
|
|
353
|
+
switch (formatInfo.attachment) {
|
|
354
|
+
case 'depth':
|
|
355
|
+
return GL.DEPTH_ATTACHMENT;
|
|
356
|
+
case 'stencil':
|
|
357
|
+
return GL.STENCIL_ATTACHMENT;
|
|
358
|
+
case 'depth-stencil':
|
|
359
|
+
return GL.DEPTH_STENCIL_ATTACHMENT;
|
|
360
|
+
default:
|
|
361
|
+
throw new Error(`Not a depth stencil format: ${format}`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
366
|
+
export function getTextureFormatBytesPerPixel(format: TextureFormat): number {
|
|
367
|
+
const formatInfo = decodeTextureFormat(format);
|
|
368
|
+
return formatInfo.bytesPerPixel;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// DATA TYPE HELPERS
|
|
372
|
+
|
|
373
|
+
export function getWebGLPixelDataFormat(
|
|
374
|
+
channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra',
|
|
375
|
+
integer: boolean,
|
|
376
|
+
normalized: boolean,
|
|
377
|
+
format: GL
|
|
378
|
+
): GLTexelDataFormat {
|
|
379
|
+
// WebGL1 formats use same internalFormat
|
|
380
|
+
if (format === GL.RGBA || format === GL.RGB) {
|
|
381
|
+
return format;
|
|
382
|
+
}
|
|
383
|
+
// prettier-ignore
|
|
384
|
+
switch (channels) {
|
|
385
|
+
case 'r': return integer && !normalized ? GL.RED_INTEGER : GL.RED;
|
|
386
|
+
case 'rg': return integer && !normalized ? GL.RG_INTEGER : GL.RG;
|
|
387
|
+
case 'rgb': return integer && !normalized ? GL.RGB_INTEGER : GL.RGB;
|
|
388
|
+
case 'rgba': return integer && !normalized ? GL.RGBA_INTEGER : GL.RGBA;
|
|
389
|
+
case 'bgra': throw new Error('bgra pixels not supported by WebGL');
|
|
390
|
+
default: return GL.RGBA;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Map WebGPU style texture format strings to GL constants
|
|
396
|
+
*/
|
|
397
|
+
function convertTextureFormatToGL(format: TextureFormat): GL | undefined {
|
|
398
|
+
const formatInfo = WEBGL_TEXTURE_FORMATS[format];
|
|
399
|
+
const webglFormat = formatInfo?.gl;
|
|
400
|
+
if (webglFormat === undefined) {
|
|
401
|
+
throw new Error(`Unsupported texture format ${format}`);
|
|
402
|
+
}
|
|
403
|
+
return webglFormat;
|
|
404
|
+
}
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
import {DeviceFeature, DeviceFeatures} from '@luma.gl/core';
|
|
9
9
|
import {GLExtensions} from '@luma.gl/constants';
|
|
10
10
|
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import {
|
|
12
|
+
isTextureFeature,
|
|
13
|
+
checkTextureFeature,
|
|
14
|
+
TEXTURE_FEATURES
|
|
15
|
+
} from '../converters/webgl-texture-table';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Defines luma.gl "feature" names and semantics
|
|
@@ -21,7 +24,6 @@ const WEBGL_FEATURES: Partial<Record<DeviceFeature, boolean | string>> = {
|
|
|
21
24
|
// 'timestamp-query' // GPUQueryType "timestamp-query"
|
|
22
25
|
// "indirect-first-instance"
|
|
23
26
|
// Textures are handled by getTextureFeatures()
|
|
24
|
-
// 'depth24unorm-stencil8' // GPUTextureFormat 'depth24unorm-stencil8'
|
|
25
27
|
// 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
|
|
26
28
|
|
|
27
29
|
// optional WebGL features
|
|
@@ -10,14 +10,20 @@ export function glFormatToComponents(format) {
|
|
|
10
10
|
case GL.ALPHA:
|
|
11
11
|
case GL.R32F:
|
|
12
12
|
case GL.RED:
|
|
13
|
+
case GL.RED_INTEGER:
|
|
13
14
|
return 1;
|
|
15
|
+
case GL.RG32I:
|
|
16
|
+
case GL.RG32UI:
|
|
14
17
|
case GL.RG32F:
|
|
18
|
+
case GL.RG_INTEGER:
|
|
15
19
|
case GL.RG:
|
|
16
20
|
return 2;
|
|
17
21
|
case GL.RGB:
|
|
22
|
+
case GL.RGB_INTEGER:
|
|
18
23
|
case GL.RGB32F:
|
|
19
24
|
return 3;
|
|
20
25
|
case GL.RGBA:
|
|
26
|
+
case GL.RGBA_INTEGER:
|
|
21
27
|
case GL.RGBA32F:
|
|
22
28
|
return 4;
|
|
23
29
|
// TODO: Add support for additional WebGL2 formats
|
|
@@ -11,7 +11,6 @@ import type {
|
|
|
11
11
|
} from '@luma.gl/core';
|
|
12
12
|
|
|
13
13
|
import {GL} from '@luma.gl/constants';
|
|
14
|
-
import {Accessor} from '../../classic/accessor'; // TODO - should NOT depend on classic API
|
|
15
14
|
import {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './decode-webgl-types';
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -19,7 +18,10 @@ import {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './de
|
|
|
19
18
|
* Note: `linkProgram()` needs to have been called
|
|
20
19
|
* (although linking does not need to have been successful).
|
|
21
20
|
*/
|
|
22
|
-
export function
|
|
21
|
+
export function getShaderLayoutFromGLSL(
|
|
22
|
+
gl: WebGL2RenderingContext,
|
|
23
|
+
program: WebGLProgram
|
|
24
|
+
): ShaderLayout {
|
|
23
25
|
const shaderLayout: ShaderLayout = {
|
|
24
26
|
attributes: [],
|
|
25
27
|
bindings: []
|
|
@@ -40,6 +42,7 @@ export function getShaderLayout(gl: WebGL2RenderingContext, program: WebGLProgra
|
|
|
40
42
|
shaderLayout.bindings.push({
|
|
41
43
|
type: 'uniform',
|
|
42
44
|
name: uniformBlock.name,
|
|
45
|
+
group: 0,
|
|
43
46
|
location: uniformBlock.location,
|
|
44
47
|
visibility: (uniformBlock.vertex ? 0x1 : 0) & (uniformBlock.fragment ? 0x2 : 0),
|
|
45
48
|
minBindingSize: uniformBlock.byteLength,
|
|
@@ -55,6 +58,7 @@ export function getShaderLayout(gl: WebGL2RenderingContext, program: WebGLProgra
|
|
|
55
58
|
shaderLayout.bindings.push({
|
|
56
59
|
type: 'texture',
|
|
57
60
|
name: uniform.name,
|
|
61
|
+
group: 0,
|
|
58
62
|
location: textureUnit,
|
|
59
63
|
viewDimension,
|
|
60
64
|
sampleType
|
|
@@ -143,8 +147,7 @@ function readVaryings(gl: WebGL2RenderingContext, program: WebGLProgram): Varyin
|
|
|
143
147
|
}
|
|
144
148
|
const {name, type: compositeType, size} = activeInfo;
|
|
145
149
|
const {glType, components} = decodeGLUniformType(compositeType);
|
|
146
|
-
const
|
|
147
|
-
const varying = {location, name, accessor}; // Base values
|
|
150
|
+
const varying = {location, name, type: glType, size: size * components}; // Base values
|
|
148
151
|
varyings.push(varying);
|
|
149
152
|
}
|
|
150
153
|
|