@luma.gl/webgl 9.3.0-alpha.4 → 9.3.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/webgl-texture-table.d.ts +7 -1
- package/dist/adapter/converters/webgl-texture-table.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-texture-table.js +121 -43
- package/dist/adapter/converters/webgl-texture-table.js.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +1 -2
- package/dist/adapter/device-helpers/webgl-device-features.js.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +5 -0
- package/dist/adapter/device-helpers/webgl-device-info.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout-from-glsl.js +16 -17
- package/dist/adapter/helpers/get-shader-layout-from-glsl.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +19 -4
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +2 -2
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +5 -4
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +20 -7
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-query-set.d.ts +29 -31
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-query-set.js +193 -97
- package/dist/adapter/resources/webgl-query-set.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +12 -0
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +13 -19
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +35 -152
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-shared-render-pipeline.d.ts +24 -0
- package/dist/adapter/resources/webgl-shared-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-shared-render-pipeline.js +152 -0
- package/dist/adapter/resources/webgl-shared-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgl-texture.d.ts +23 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +203 -100
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +4 -2
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +31 -3
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/adapter/webgl-presentation-context.d.ts +21 -0
- package/dist/adapter/webgl-presentation-context.d.ts.map +1 -0
- package/dist/adapter/webgl-presentation-context.js +64 -0
- package/dist/adapter/webgl-presentation-context.js.map +1 -0
- package/dist/dist.dev.js +1332 -788
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +1247 -797
- package/dist/index.cjs.map +4 -4
- package/package.json +3 -3
- package/src/adapter/converters/webgl-texture-table.ts +159 -47
- package/src/adapter/device-helpers/webgl-device-features.ts +1 -2
- package/src/adapter/device-helpers/webgl-device-info.ts +6 -0
- package/src/adapter/helpers/get-shader-layout-from-glsl.ts +18 -19
- package/src/adapter/resources/webgl-buffer.ts +16 -4
- package/src/adapter/resources/webgl-command-buffer.ts +3 -2
- package/src/adapter/resources/webgl-command-encoder.ts +22 -7
- package/src/adapter/resources/webgl-query-set.ts +229 -102
- package/src/adapter/resources/webgl-render-pass.ts +13 -0
- package/src/adapter/resources/webgl-render-pipeline.ts +45 -179
- package/src/adapter/resources/webgl-shared-render-pipeline.ts +208 -0
- package/src/adapter/resources/webgl-texture.ts +326 -121
- package/src/adapter/webgl-device.ts +40 -4
- package/src/adapter/webgl-presentation-context.ts +93 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.3.0-alpha.
|
|
3
|
+
"version": "9.3.0-alpha.6",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl core API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"@luma.gl/core": "9.2.0-alpha.6"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/constants": "9.3.0-alpha.
|
|
46
|
+
"@luma.gl/constants": "9.3.0-alpha.6",
|
|
47
47
|
"@math.gl/types": "^4.1.0",
|
|
48
48
|
"@probe.gl/env": "^4.1.1"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "59fda5480c4d0bb3d64545d4621175221f2b6c7c"
|
|
51
51
|
}
|
|
@@ -32,32 +32,44 @@ const X_ATC = 'WEBGL_compressed_texture_atc';
|
|
|
32
32
|
const EXT_texture_norm16 = 'EXT_texture_norm16';
|
|
33
33
|
const EXT_render_snorm = 'EXT_render_snorm';
|
|
34
34
|
const EXT_color_buffer_float = 'EXT_color_buffer_float';
|
|
35
|
+
const SNORM8_COLOR_RENDERABLE: DeviceFeature = 'snorm8-renderable-webgl';
|
|
36
|
+
const NORM16_COLOR_RENDERABLE: DeviceFeature = 'norm16-renderable-webgl';
|
|
37
|
+
const SNORM16_COLOR_RENDERABLE: DeviceFeature = 'snorm16-renderable-webgl';
|
|
38
|
+
const FLOAT16_COLOR_RENDERABLE: DeviceFeature = 'float16-renderable-webgl';
|
|
39
|
+
const FLOAT32_COLOR_RENDERABLE: DeviceFeature = 'float32-renderable-webgl';
|
|
40
|
+
const RGB9E5UFLOAT_COLOR_RENDERABLE: DeviceFeature = 'rgb9e5ufloat-renderable-webgl';
|
|
41
|
+
|
|
42
|
+
type TextureFeatureDefinition = {
|
|
43
|
+
extensions?: string[];
|
|
44
|
+
features?: DeviceFeature[];
|
|
45
|
+
};
|
|
35
46
|
|
|
36
47
|
// prettier-ignore
|
|
37
|
-
export const TEXTURE_FEATURES: Partial<Record<DeviceFeature,
|
|
38
|
-
'float32-renderable-webgl': [
|
|
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-
|
|
43
|
-
'
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
export const TEXTURE_FEATURES: Partial<Record<DeviceFeature, TextureFeatureDefinition>> = {
|
|
49
|
+
'float32-renderable-webgl': {extensions: [EXT_color_buffer_float]},
|
|
50
|
+
'float16-renderable-webgl': {extensions: ['EXT_color_buffer_half_float']},
|
|
51
|
+
'rgb9e5ufloat-renderable-webgl': {extensions: ['WEBGL_render_shared_exponent']},
|
|
52
|
+
'snorm8-renderable-webgl': {extensions: [EXT_render_snorm]},
|
|
53
|
+
'norm16-webgl': {extensions: [EXT_texture_norm16]},
|
|
54
|
+
'norm16-renderable-webgl': {features: ['norm16-webgl']},
|
|
55
|
+
'snorm16-renderable-webgl': {features: ['norm16-webgl'], extensions: [EXT_render_snorm]},
|
|
56
|
+
|
|
57
|
+
'float32-filterable': {extensions: ['OES_texture_float_linear']},
|
|
58
|
+
'float16-filterable-webgl': {extensions: ['OES_texture_half_float_linear']},
|
|
59
|
+
'texture-filterable-anisotropic-webgl': {extensions: ['EXT_texture_filter_anisotropic']},
|
|
60
|
+
|
|
61
|
+
'texture-blend-float-webgl': {extensions: ['EXT_float_blend']},
|
|
62
|
+
|
|
63
|
+
'texture-compression-bc': {extensions: [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC]},
|
|
52
64
|
// 'texture-compression-bc3-srgb-webgl': [X_S3TC_SRGB],
|
|
53
65
|
// '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]
|
|
66
|
+
'texture-compression-bc5-webgl': {extensions: [X_RGTC]},
|
|
67
|
+
'texture-compression-bc7-webgl': {extensions: [X_BPTC]},
|
|
68
|
+
'texture-compression-etc2': {extensions: [X_ETC2]},
|
|
69
|
+
'texture-compression-astc': {extensions: [X_ASTC]},
|
|
70
|
+
'texture-compression-etc1-webgl': {extensions: [X_ETC1]},
|
|
71
|
+
'texture-compression-pvrtc-webgl': {extensions: [X_PVRTC]},
|
|
72
|
+
'texture-compression-atc-webgl': {extensions: [X_ATC]}
|
|
61
73
|
};
|
|
62
74
|
|
|
63
75
|
export function isTextureFeature(feature: DeviceFeature): boolean {
|
|
@@ -70,8 +82,36 @@ export function checkTextureFeature(
|
|
|
70
82
|
feature: DeviceFeature,
|
|
71
83
|
extensions: GLExtensions
|
|
72
84
|
): boolean {
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
return hasTextureFeature(gl, feature, extensions, new Set<DeviceFeature>());
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function hasTextureFeature(
|
|
89
|
+
gl: WebGL2RenderingContext,
|
|
90
|
+
feature: DeviceFeature,
|
|
91
|
+
extensions: GLExtensions,
|
|
92
|
+
seenFeatures: Set<DeviceFeature>
|
|
93
|
+
): boolean {
|
|
94
|
+
const definition = TEXTURE_FEATURES[feature];
|
|
95
|
+
if (!definition) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (seenFeatures.has(feature)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
seenFeatures.add(feature);
|
|
104
|
+
const hasDependentFeatures = (definition.features || []).every(dependentFeature =>
|
|
105
|
+
hasTextureFeature(gl, dependentFeature, extensions, seenFeatures)
|
|
106
|
+
);
|
|
107
|
+
seenFeatures.delete(feature);
|
|
108
|
+
if (!hasDependentFeatures) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (definition.extensions || []).every(extension =>
|
|
113
|
+
Boolean(getWebGLExtension(gl, extension, extensions))
|
|
114
|
+
);
|
|
75
115
|
}
|
|
76
116
|
|
|
77
117
|
// TEXTURE FORMATS
|
|
@@ -81,6 +121,8 @@ type WebGLFormatInfo = {
|
|
|
81
121
|
gl?: GL;
|
|
82
122
|
/** compressed */
|
|
83
123
|
x?: string;
|
|
124
|
+
/** color-renderable capability gate. false means never color-renderable on WebGL. */
|
|
125
|
+
r?: DeviceFeature | false;
|
|
84
126
|
types?: GLPixelType[];
|
|
85
127
|
dataFormat?: GLTexelDataFormat;
|
|
86
128
|
/** if depthTexture is set this is a depth/stencil format that can be set to a texture */
|
|
@@ -99,21 +141,21 @@ type WebGLFormatInfo = {
|
|
|
99
141
|
export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
100
142
|
// 8-bit formats
|
|
101
143
|
'r8unorm': {gl: GL.R8, rb: true},
|
|
102
|
-
'r8snorm': {gl: GL.R8_SNORM},
|
|
144
|
+
'r8snorm': {gl: GL.R8_SNORM, r: SNORM8_COLOR_RENDERABLE},
|
|
103
145
|
'r8uint': {gl: GL.R8UI, rb: true},
|
|
104
146
|
'r8sint': {gl: GL.R8I, rb: true},
|
|
105
147
|
|
|
106
148
|
// 16-bit formats
|
|
107
149
|
'rg8unorm': {gl: GL.RG8, rb: true},
|
|
108
|
-
'rg8snorm': {gl: GL.RG8_SNORM},
|
|
150
|
+
'rg8snorm': {gl: GL.RG8_SNORM, r: SNORM8_COLOR_RENDERABLE},
|
|
109
151
|
'rg8uint': {gl: GL.RG8UI, rb: true},
|
|
110
152
|
'rg8sint': {gl: GL.RG8I, rb: true},
|
|
111
153
|
|
|
112
154
|
'r16uint': {gl: GL.R16UI, rb: true},
|
|
113
155
|
'r16sint': {gl: GL.R16I, rb: true},
|
|
114
|
-
'r16float': {gl: GL.R16F, rb: true},
|
|
115
|
-
'r16unorm': {gl: GL.R16_EXT, rb: true},
|
|
116
|
-
'r16snorm': {gl: GL.R16_SNORM_EXT},
|
|
156
|
+
'r16float': {gl: GL.R16F, rb: true, r: FLOAT16_COLOR_RENDERABLE},
|
|
157
|
+
'r16unorm': {gl: GL.R16_EXT, rb: true, r: NORM16_COLOR_RENDERABLE},
|
|
158
|
+
'r16snorm': {gl: GL.R16_SNORM_EXT, r: SNORM16_COLOR_RENDERABLE},
|
|
117
159
|
|
|
118
160
|
// Packed 16-bit formats
|
|
119
161
|
'rgba4unorm-webgl': {gl: GL.RGBA4, rb: true},
|
|
@@ -127,7 +169,7 @@ export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
|
127
169
|
// 32-bit formats
|
|
128
170
|
'rgba8unorm': {gl: GL.RGBA8},
|
|
129
171
|
'rgba8unorm-srgb': {gl: GL.SRGB8_ALPHA8},
|
|
130
|
-
'rgba8snorm': {gl: GL.RGBA8_SNORM},
|
|
172
|
+
'rgba8snorm': {gl: GL.RGBA8_SNORM, r: SNORM8_COLOR_RENDERABLE},
|
|
131
173
|
'rgba8uint': {gl: GL.RGBA8UI},
|
|
132
174
|
'rgba8sint': {gl: GL.RGBA8I},
|
|
133
175
|
// reverse colors, webgpu only
|
|
@@ -136,41 +178,41 @@ export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
|
136
178
|
|
|
137
179
|
'rg16uint': {gl: GL.RG16UI},
|
|
138
180
|
'rg16sint': {gl: GL.RG16I},
|
|
139
|
-
'rg16float': {gl: GL.RG16F, rb: true},
|
|
140
|
-
'rg16unorm': {gl: GL.RG16_EXT},
|
|
141
|
-
'rg16snorm': {gl: GL.RG16_SNORM_EXT},
|
|
181
|
+
'rg16float': {gl: GL.RG16F, rb: true, r: FLOAT16_COLOR_RENDERABLE},
|
|
182
|
+
'rg16unorm': {gl: GL.RG16_EXT, r: NORM16_COLOR_RENDERABLE},
|
|
183
|
+
'rg16snorm': {gl: GL.RG16_SNORM_EXT, r: SNORM16_COLOR_RENDERABLE},
|
|
142
184
|
|
|
143
185
|
'r32uint': {gl: GL.R32UI, rb: true},
|
|
144
186
|
'r32sint': {gl: GL.R32I, rb: true},
|
|
145
|
-
'r32float': {gl: GL.R32F},
|
|
187
|
+
'r32float': {gl: GL.R32F, r: FLOAT32_COLOR_RENDERABLE},
|
|
146
188
|
|
|
147
189
|
// Packed 32-bit formats
|
|
148
|
-
'rgb9e5ufloat': {gl: GL.RGB9_E5}, // , filter: true},
|
|
190
|
+
'rgb9e5ufloat': {gl: GL.RGB9_E5, r: RGB9E5UFLOAT_COLOR_RENDERABLE}, // , filter: true},
|
|
149
191
|
'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, rb: true},
|
|
150
192
|
'rgb10a2unorm': {gl: GL.RGB10_A2, rb: true},
|
|
151
193
|
'rgb10a2uint': {gl: GL.RGB10_A2UI, rb: true},
|
|
152
194
|
|
|
153
195
|
// 48-bit formats
|
|
154
|
-
'rgb16unorm-webgl': {gl: GL.RGB16_EXT}, // rgb not renderable
|
|
155
|
-
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT}, // rgb not renderable
|
|
196
|
+
'rgb16unorm-webgl': {gl: GL.RGB16_EXT, r: false}, // rgb not renderable
|
|
197
|
+
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, r: false}, // rgb not renderable
|
|
156
198
|
|
|
157
199
|
// 64-bit formats
|
|
158
200
|
'rg32uint': {gl: GL.RG32UI, rb: true},
|
|
159
201
|
'rg32sint': {gl: GL.RG32I, rb: true},
|
|
160
|
-
'rg32float': {gl: GL.RG32F, rb: true},
|
|
202
|
+
'rg32float': {gl: GL.RG32F, rb: true, r: FLOAT32_COLOR_RENDERABLE},
|
|
161
203
|
'rgba16uint': {gl: GL.RGBA16UI, rb: true},
|
|
162
204
|
'rgba16sint': {gl: GL.RGBA16I, rb: true},
|
|
163
|
-
'rgba16float': {gl: GL.RGBA16F},
|
|
164
|
-
'rgba16unorm': {gl: GL.RGBA16_EXT, rb: true},
|
|
165
|
-
'rgba16snorm': {gl: GL.RGBA16_SNORM_EXT},
|
|
205
|
+
'rgba16float': {gl: GL.RGBA16F, r: FLOAT16_COLOR_RENDERABLE},
|
|
206
|
+
'rgba16unorm': {gl: GL.RGBA16_EXT, rb: true, r: NORM16_COLOR_RENDERABLE},
|
|
207
|
+
'rgba16snorm': {gl: GL.RGBA16_SNORM_EXT, r: SNORM16_COLOR_RENDERABLE},
|
|
166
208
|
|
|
167
209
|
// 96-bit formats (deprecated!)
|
|
168
|
-
'rgb32float-webgl': {gl: GL.RGB32F, x: EXT_color_buffer_float, dataFormat: GL.RGB, types: [GL.FLOAT]},
|
|
210
|
+
'rgb32float-webgl': {gl: GL.RGB32F, x: EXT_color_buffer_float, r: FLOAT32_COLOR_RENDERABLE, dataFormat: GL.RGB, types: [GL.FLOAT]},
|
|
169
211
|
|
|
170
212
|
// 128-bit formats
|
|
171
213
|
'rgba32uint': {gl: GL.RGBA32UI, rb: true},
|
|
172
214
|
'rgba32sint': {gl: GL.RGBA32I, rb: true},
|
|
173
|
-
'rgba32float': {gl: GL.RGBA32F, rb: true},
|
|
215
|
+
'rgba32float': {gl: GL.RGBA32F, rb: true, r: FLOAT32_COLOR_RENDERABLE},
|
|
174
216
|
|
|
175
217
|
// Depth and stencil formats
|
|
176
218
|
'stencil8': {gl: GL.STENCIL_INDEX8, rb: true}, // 8 stencil bits
|
|
@@ -237,8 +279,8 @@ export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
|
237
279
|
'astc-8x6-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR},
|
|
238
280
|
'astc-8x8-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_8x8_KHR},
|
|
239
281
|
'astc-8x8-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR},
|
|
240
|
-
'astc-10x5-unorm': {gl: GL.
|
|
241
|
-
'astc-10x5-unorm-srgb': {gl: GL.
|
|
282
|
+
'astc-10x5-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x5_KHR},
|
|
283
|
+
'astc-10x5-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR},
|
|
242
284
|
'astc-10x6-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x6_KHR},
|
|
243
285
|
'astc-10x6-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR},
|
|
244
286
|
'astc-10x8-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x8_KHR},
|
|
@@ -254,7 +296,7 @@ export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
|
254
296
|
|
|
255
297
|
'pvrtc-rgb4unorm-webgl': {gl: GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},
|
|
256
298
|
'pvrtc-rgba4unorm-webgl': {gl: GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},
|
|
257
|
-
'pvrtc-
|
|
299
|
+
'pvrtc-rgb2unorm-webgl': {gl: GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG},
|
|
258
300
|
'pvrtc-rgba2unorm-webgl': {gl: GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG},
|
|
259
301
|
|
|
260
302
|
// WEBGL_compressed_texture_etc1
|
|
@@ -308,12 +350,29 @@ export function getTextureFormatCapabilitiesWebGL(
|
|
|
308
350
|
supported = supported && Boolean(getWebGLExtension(gl, webglFormatInfo.x, extensions));
|
|
309
351
|
}
|
|
310
352
|
|
|
353
|
+
// WebGL2 exposes STENCIL_INDEX8 for renderbuffers, but standalone stencil textures are not
|
|
354
|
+
// valid texture storage targets. Report them as unsupported texture formats to avoid invalid
|
|
355
|
+
// constructor paths and misleading capability checks.
|
|
356
|
+
if (formatSupport.format === 'stencil8') {
|
|
357
|
+
supported = false;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const renderFeatureSupported =
|
|
361
|
+
webglFormatInfo?.r === false
|
|
362
|
+
? false
|
|
363
|
+
: webglFormatInfo?.r === undefined || checkTextureFeature(gl, webglFormatInfo.r, extensions);
|
|
364
|
+
const renderable =
|
|
365
|
+
supported &&
|
|
366
|
+
formatSupport.render &&
|
|
367
|
+
renderFeatureSupported &&
|
|
368
|
+
isColorRenderableTextureFormat(gl, formatSupport.format, extensions);
|
|
369
|
+
|
|
311
370
|
return {
|
|
312
371
|
format: formatSupport.format,
|
|
313
372
|
// @ts-ignore
|
|
314
373
|
create: supported && formatSupport.create,
|
|
315
374
|
// @ts-ignore
|
|
316
|
-
render:
|
|
375
|
+
render: renderable,
|
|
317
376
|
// @ts-ignore
|
|
318
377
|
filter: supported && formatSupport.filter,
|
|
319
378
|
// @ts-ignore
|
|
@@ -323,6 +382,59 @@ export function getTextureFormatCapabilitiesWebGL(
|
|
|
323
382
|
};
|
|
324
383
|
}
|
|
325
384
|
|
|
385
|
+
function isColorRenderableTextureFormat(
|
|
386
|
+
gl: WebGL2RenderingContext,
|
|
387
|
+
format: TextureFormat,
|
|
388
|
+
extensions: GLExtensions
|
|
389
|
+
): boolean {
|
|
390
|
+
const webglFormatInfo = WEBGL_TEXTURE_FORMATS[format];
|
|
391
|
+
const internalFormat = webglFormatInfo?.gl;
|
|
392
|
+
if (internalFormat === undefined) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (webglFormatInfo?.x && !getWebGLExtension(gl, webglFormatInfo.x, extensions)) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const previousTexture = gl.getParameter(GL.TEXTURE_BINDING_2D) as WebGLTexture | null;
|
|
401
|
+
const previousFramebuffer = gl.getParameter(GL.FRAMEBUFFER_BINDING) as WebGLFramebuffer | null;
|
|
402
|
+
const texture = gl.createTexture();
|
|
403
|
+
const framebuffer = gl.createFramebuffer();
|
|
404
|
+
if (!texture || !framebuffer) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Isolate the probe from any prior driver errors so the result reflects only this format.
|
|
409
|
+
const noError = Number(GL.NO_ERROR);
|
|
410
|
+
let error = Number(gl.getError());
|
|
411
|
+
while (error !== noError) {
|
|
412
|
+
error = gl.getError();
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
let renderable = false;
|
|
416
|
+
try {
|
|
417
|
+
gl.bindTexture(GL.TEXTURE_2D, texture);
|
|
418
|
+
gl.texStorage2D(GL.TEXTURE_2D, 1, internalFormat, 1, 1);
|
|
419
|
+
if (Number(gl.getError()) !== noError) {
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer);
|
|
424
|
+
gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0, GL.TEXTURE_2D, texture, 0);
|
|
425
|
+
renderable =
|
|
426
|
+
Number(gl.checkFramebufferStatus(GL.FRAMEBUFFER)) === Number(GL.FRAMEBUFFER_COMPLETE) &&
|
|
427
|
+
Number(gl.getError()) === noError;
|
|
428
|
+
} finally {
|
|
429
|
+
gl.bindFramebuffer(GL.FRAMEBUFFER, previousFramebuffer);
|
|
430
|
+
gl.deleteFramebuffer(framebuffer);
|
|
431
|
+
gl.bindTexture(GL.TEXTURE_2D, previousTexture);
|
|
432
|
+
gl.deleteTexture(texture);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return renderable;
|
|
436
|
+
}
|
|
437
|
+
|
|
326
438
|
/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
|
|
327
439
|
export function getTextureFormatWebGL(format: TextureFormat): {
|
|
328
440
|
internalFormat: GL;
|
|
@@ -21,13 +21,12 @@ import {
|
|
|
21
21
|
const WEBGL_FEATURES: Partial<Record<DeviceFeature, boolean | string>> = {
|
|
22
22
|
// optional WebGPU features
|
|
23
23
|
'depth-clip-control': 'EXT_depth_clamp', // TODO these seem subtly different
|
|
24
|
-
|
|
24
|
+
'timestamp-query': 'EXT_disjoint_timer_query_webgl2',
|
|
25
25
|
// "indirect-first-instance"
|
|
26
26
|
// Textures are handled by getTextureFeatures()
|
|
27
27
|
// 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
|
|
28
28
|
|
|
29
29
|
// optional WebGL features
|
|
30
|
-
'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2',
|
|
31
30
|
'compilation-status-async-webgl': 'KHR_parallel_shader_compile',
|
|
32
31
|
'polygon-mode-webgl': 'WEBGL_polygon_mode',
|
|
33
32
|
'provoking-vertex-webgl': 'WEBGL_provoking_vertex',
|
|
@@ -99,6 +99,8 @@ function identifyGPUType(
|
|
|
99
99
|
|
|
100
100
|
const gpuVendor = identifyGPUVendor(vendor, renderer);
|
|
101
101
|
switch (gpuVendor) {
|
|
102
|
+
case 'apple':
|
|
103
|
+
return isAppleSiliconGPU(vendor, renderer) ? 'integrated' : 'unknown';
|
|
102
104
|
case 'intel':
|
|
103
105
|
return 'integrated';
|
|
104
106
|
case 'software':
|
|
@@ -109,3 +111,7 @@ function identifyGPUType(
|
|
|
109
111
|
return 'discrete';
|
|
110
112
|
}
|
|
111
113
|
}
|
|
114
|
+
|
|
115
|
+
function isAppleSiliconGPU(vendor: string, renderer: string): boolean {
|
|
116
|
+
return /Apple (M\d|A\d|GPU)/i.test(`${vendor} ${renderer}`);
|
|
117
|
+
}
|
|
@@ -253,26 +253,25 @@ function readUniformBlocks(
|
|
|
253
253
|
// const uniformRowMajor = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
|
|
254
254
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
255
255
|
const uniformIndex = uniformIndices[i];
|
|
256
|
-
if (uniformIndex
|
|
257
|
-
|
|
256
|
+
if (uniformIndex !== undefined) {
|
|
257
|
+
const activeInfo = gl.getActiveUniform(program, uniformIndex);
|
|
258
|
+
if (!activeInfo) {
|
|
259
|
+
throw new Error('activeInfo');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const format = convertGLUniformTypeToShaderVariableType(uniformType[i]);
|
|
263
|
+
|
|
264
|
+
blockInfo.uniforms.push({
|
|
265
|
+
name: activeInfo.name,
|
|
266
|
+
format,
|
|
267
|
+
type: uniformType[i],
|
|
268
|
+
arrayLength: uniformArrayLength[i],
|
|
269
|
+
byteOffset: uniformOffset[i],
|
|
270
|
+
byteStride: uniformStride[i]
|
|
271
|
+
// matrixStride: uniformStride[i],
|
|
272
|
+
// rowMajor: uniformRowMajor[i]
|
|
273
|
+
});
|
|
258
274
|
}
|
|
259
|
-
const activeInfo = gl.getActiveUniform(program, uniformIndex);
|
|
260
|
-
if (!activeInfo) {
|
|
261
|
-
throw new Error('activeInfo');
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const format = convertGLUniformTypeToShaderVariableType(uniformType[i]);
|
|
265
|
-
|
|
266
|
-
blockInfo.uniforms.push({
|
|
267
|
-
name: activeInfo.name,
|
|
268
|
-
format,
|
|
269
|
-
type: uniformType[i],
|
|
270
|
-
arrayLength: uniformArrayLength[i],
|
|
271
|
-
byteOffset: uniformOffset[i],
|
|
272
|
-
byteStride: uniformStride[i]
|
|
273
|
-
// matrixStride: uniformStride[i],
|
|
274
|
-
// rowMajor: uniformRowMajor[i]
|
|
275
|
-
});
|
|
276
275
|
}
|
|
277
276
|
|
|
278
277
|
uniformBlocks.push(blockInfo);
|
|
@@ -56,8 +56,12 @@ export class WEBGLBuffer extends Buffer {
|
|
|
56
56
|
override destroy(): void {
|
|
57
57
|
if (!this.destroyed && this.handle) {
|
|
58
58
|
this.removeStats();
|
|
59
|
-
this.
|
|
60
|
-
|
|
59
|
+
if (!this.props.handle) {
|
|
60
|
+
this.trackDeallocatedMemory();
|
|
61
|
+
this.gl.deleteBuffer(this.handle);
|
|
62
|
+
} else {
|
|
63
|
+
this.trackDeallocatedReferencedMemory('Buffer');
|
|
64
|
+
}
|
|
61
65
|
this.destroyed = true;
|
|
62
66
|
// @ts-expect-error
|
|
63
67
|
this.handle = null;
|
|
@@ -81,7 +85,11 @@ export class WEBGLBuffer extends Buffer {
|
|
|
81
85
|
this.byteLength = byteLength;
|
|
82
86
|
|
|
83
87
|
this._setDebugData(data, byteOffset, byteLength);
|
|
84
|
-
this.
|
|
88
|
+
if (!this.props.handle) {
|
|
89
|
+
this.trackAllocatedMemory(byteLength);
|
|
90
|
+
} else {
|
|
91
|
+
this.trackReferencedMemory(byteLength, 'Buffer');
|
|
92
|
+
}
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
// Allocate a GPU buffer of specified size.
|
|
@@ -107,7 +115,11 @@ export class WEBGLBuffer extends Buffer {
|
|
|
107
115
|
this.byteLength = byteLength;
|
|
108
116
|
|
|
109
117
|
this._setDebugData(null, 0, byteLength);
|
|
110
|
-
this.
|
|
118
|
+
if (!this.props.handle) {
|
|
119
|
+
this.trackAllocatedMemory(byteLength);
|
|
120
|
+
} else {
|
|
121
|
+
this.trackReferencedMemory(byteLength, 'Buffer');
|
|
122
|
+
}
|
|
111
123
|
|
|
112
124
|
return this;
|
|
113
125
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
+
type CommandBufferProps,
|
|
6
7
|
type CopyBufferToBufferOptions,
|
|
7
8
|
type CopyBufferToTextureOptions,
|
|
8
9
|
type CopyTextureToBufferOptions,
|
|
@@ -65,8 +66,8 @@ export class WEBGLCommandBuffer extends CommandBuffer {
|
|
|
65
66
|
readonly handle = null;
|
|
66
67
|
commands: Command[] = [];
|
|
67
68
|
|
|
68
|
-
constructor(device: WebGLDevice) {
|
|
69
|
-
super(device,
|
|
69
|
+
constructor(device: WebGLDevice, props: CommandBufferProps = {}) {
|
|
70
|
+
super(device, props);
|
|
70
71
|
this.device = device;
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {CommandEncoder, CommandEncoderProps} from '@luma.gl/core';
|
|
5
|
+
import {CommandBufferProps, CommandEncoder, CommandEncoderProps} from '@luma.gl/core';
|
|
6
6
|
import type {
|
|
7
7
|
RenderPassProps,
|
|
8
8
|
ComputePass,
|
|
@@ -20,6 +20,7 @@ import type {
|
|
|
20
20
|
import {WEBGLCommandBuffer} from './webgl-command-buffer';
|
|
21
21
|
import {WEBGLRenderPass} from './webgl-render-pass';
|
|
22
22
|
import {WebGLDevice} from '../webgl-device';
|
|
23
|
+
import {WEBGLQuerySet} from './webgl-query-set';
|
|
23
24
|
|
|
24
25
|
export class WEBGLCommandEncoder extends CommandEncoder {
|
|
25
26
|
readonly device: WebGLDevice;
|
|
@@ -30,20 +31,29 @@ export class WEBGLCommandEncoder extends CommandEncoder {
|
|
|
30
31
|
constructor(device: WebGLDevice, props: CommandEncoderProps) {
|
|
31
32
|
super(device, props);
|
|
32
33
|
this.device = device;
|
|
33
|
-
this.commandBuffer = new WEBGLCommandBuffer(device
|
|
34
|
+
this.commandBuffer = new WEBGLCommandBuffer(device, {
|
|
35
|
+
id: `${this.props.id}-command-buffer`
|
|
36
|
+
});
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
override destroy(): void {
|
|
39
|
+
override destroy(): void {
|
|
40
|
+
this.destroyResource();
|
|
41
|
+
}
|
|
37
42
|
|
|
38
|
-
override finish(): WEBGLCommandBuffer {
|
|
43
|
+
override finish(props?: CommandBufferProps): WEBGLCommandBuffer {
|
|
44
|
+
if (props?.id && this.commandBuffer.id !== props.id) {
|
|
45
|
+
this.commandBuffer.id = props.id;
|
|
46
|
+
this.commandBuffer.props.id = props.id;
|
|
47
|
+
}
|
|
48
|
+
this.destroy();
|
|
39
49
|
return this.commandBuffer;
|
|
40
50
|
}
|
|
41
51
|
|
|
42
|
-
beginRenderPass(props: RenderPassProps): WEBGLRenderPass {
|
|
43
|
-
return new WEBGLRenderPass(this.device, props);
|
|
52
|
+
beginRenderPass(props: RenderPassProps = {}): WEBGLRenderPass {
|
|
53
|
+
return new WEBGLRenderPass(this.device, this._applyTimeProfilingToPassProps(props));
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
beginComputePass(props: ComputePassProps): ComputePass {
|
|
56
|
+
beginComputePass(props: ComputePassProps = {}): ComputePass {
|
|
47
57
|
throw new Error('ComputePass not supported in WebGL');
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -81,4 +91,9 @@ export class WEBGLCommandEncoder extends CommandEncoder {
|
|
|
81
91
|
destinationOffset?: number;
|
|
82
92
|
}
|
|
83
93
|
): void {}
|
|
94
|
+
|
|
95
|
+
writeTimestamp(querySet: QuerySet, queryIndex: number): void {
|
|
96
|
+
const webglQuerySet = querySet as WEBGLQuerySet;
|
|
97
|
+
webglQuerySet.writeTimestamp(queryIndex);
|
|
98
|
+
}
|
|
84
99
|
}
|