@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +71 -11
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +3 -2
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +40 -20
- package/dist/adapter/converters/texture-formats.d.ts +10 -7
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +76 -64
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +2 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +18 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +77 -43
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +17 -14
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +2 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +6 -5
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +2 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +2 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +24 -11
- package/dist/adapter/objects/webgl-resource.d.ts +2 -24
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -100
- package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +2 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +7 -6
- package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -2
- package/dist/adapter/resources/webgl-external-texture.js +3 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -8
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +25 -23
- package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-query-set.js +136 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +15 -7
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +34 -49
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +12 -6
- package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
- package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-texture-view.js +18 -0
- package/dist/adapter/resources/webgl-texture.d.ts +4 -3
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +12 -7
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +2 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +5 -4
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +3 -2
- package/dist/adapter/webgl-device.d.ts +29 -27
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +90 -94
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +4 -3
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +3 -2
- package/dist/classic/copy-and-blit.d.ts +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +5 -4
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +2 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +2 -1
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -6
- package/dist/context/helpers/create-browser-context.d.ts +35 -0
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -0
- package/dist/context/helpers/create-browser-context.js +67 -0
- package/dist/context/helpers/webgl-context-data.d.ts +13 -0
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
- package/dist/context/helpers/webgl-context-data.js +21 -0
- package/dist/context/helpers/webgl-extensions.d.ts +4 -0
- package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
- package/dist/context/helpers/webgl-extensions.js +10 -0
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +4 -3
- package/dist/context/parameters/webgl-parameter-tables.d.ts +10 -0
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +29 -16
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +2 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -4
- package/dist/context/state-tracker/with-parameters.d.ts +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +5 -4
- package/dist/dist.dev.js +941 -730
- package/dist/index.cjs +732 -565
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +25 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist.min.js +5 -5
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +105 -16
- package/src/adapter/converters/sampler-parameters.ts +12 -3
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +87 -66
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +83 -51
- package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
- package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +4 -3
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +2 -1
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +2 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +35 -13
- package/src/adapter/objects/webgl-resource.ts +6 -124
- package/src/adapter/resources/webgl-buffer.ts +4 -3
- package/src/adapter/resources/webgl-command-buffer.ts +5 -5
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +3 -2
- package/src/adapter/resources/webgl-framebuffer.ts +34 -29
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +17 -8
- package/src/adapter/resources/webgl-render-pipeline.ts +41 -48
- package/src/adapter/resources/webgl-sampler.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +12 -5
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +9 -2
- package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-canvas-context.ts +6 -4
- package/src/adapter/webgl-device.ts +94 -90
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +12 -6
- package/src/classic/copy-and-blit.ts +11 -4
- package/src/classic/format-utils.ts +2 -1
- package/src/classic/typed-array-utils.ts +3 -7
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +27 -14
- package/src/context/{context → helpers}/create-browser-context.ts +3 -2
- package/src/context/helpers/webgl-context-data.ts +31 -0
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +2 -1
- package/src/context/parameters/webgl-parameter-tables.ts +69 -32
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +11 -6
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +3 -2
- package/src/types.ts +2 -1
- package/src/context/context/context-data.ts +0 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.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/constants": "^9.0.0-beta.4"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/constants": "9.0.0-beta.
|
|
47
|
-
"@luma.gl/core": "9.0.0-beta.
|
|
46
|
+
"@luma.gl/constants": "9.0.0-beta.6",
|
|
47
|
+
"@luma.gl/core": "9.0.0-beta.6",
|
|
48
48
|
"@probe.gl/env": "^4.0.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "cb2f0938d03a65e3588622ac99650b14a10488b6"
|
|
51
51
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {
|
|
@@ -28,7 +29,7 @@ import {WebGLDevice} from '../webgl-device';
|
|
|
28
29
|
* - Returns the return value of the supplied function
|
|
29
30
|
*/
|
|
30
31
|
export function withDeviceAndGLParameters<T = unknown>(
|
|
31
|
-
device: Device,
|
|
32
|
+
device: Device,
|
|
32
33
|
parameters: Parameters,
|
|
33
34
|
glParameters: GLParameters,
|
|
34
35
|
func: (device?: Device) => T
|
|
@@ -143,6 +144,13 @@ export function setDeviceParameters(device: Device, parameters: Parameters) {
|
|
|
143
144
|
);
|
|
144
145
|
}
|
|
145
146
|
|
|
147
|
+
if (parameters.unclippedDepth) {
|
|
148
|
+
if (device.features.has('depth-clip-control')) {
|
|
149
|
+
// EXT_depth_clamp
|
|
150
|
+
gl.enable(GL.DEPTH_CLAMP_EXT);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
146
154
|
if (parameters.depthBias !== undefined) {
|
|
147
155
|
gl.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);
|
|
148
156
|
}
|
|
@@ -151,6 +159,66 @@ export function setDeviceParameters(device: Device, parameters: Parameters) {
|
|
|
151
159
|
// // Handled by depthBias
|
|
152
160
|
// },
|
|
153
161
|
|
|
162
|
+
// WEBGL EXTENSIONS
|
|
163
|
+
|
|
164
|
+
if (device.features.has('provoking-vertex-webgl')) {
|
|
165
|
+
const extensions = webglDevice.getExtension('WEBGL_provoking_vertex');
|
|
166
|
+
const ext = extensions.WEBGL_provoking_vertex;
|
|
167
|
+
|
|
168
|
+
if (parameters.provokingVertex) {
|
|
169
|
+
const vertex = map('provokingVertex', parameters.provokingVertex, {
|
|
170
|
+
first: GL.FIRST_VERTEX_CONVENTION_WEBGL,
|
|
171
|
+
last: GL.LAST_VERTEX_CONVENTION_WEBGL
|
|
172
|
+
});
|
|
173
|
+
ext?.provokingVertexWEBGL(vertex);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (device.features.has('polygon-mode-webgl')) {
|
|
178
|
+
const extensions = webglDevice.getExtension('WEBGL_polygon_mode');
|
|
179
|
+
const ext = extensions.WEBGL_polygon_mode;
|
|
180
|
+
|
|
181
|
+
if (parameters.polygonMode) {
|
|
182
|
+
const mode = map('polygonMode', parameters.provokingVertex, {
|
|
183
|
+
fill: GL.FILL_WEBGL,
|
|
184
|
+
lint: GL.LINE_WEBGL
|
|
185
|
+
});
|
|
186
|
+
ext?.polygonModeWEBGL(GL.FRONT, mode);
|
|
187
|
+
ext?.polygonModeWEBGL(GL.BACK, mode);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (parameters.polygonOffsetLine) {
|
|
191
|
+
gl.enable(GL.POLYGON_OFFSET_LINE_WEBGL);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (device.features.has('shader-clip-cull-distance-webgl')) {
|
|
196
|
+
if (parameters.clipDistance0) {
|
|
197
|
+
gl.enable(GL.CLIP_DISTANCE0_WEBGL);
|
|
198
|
+
}
|
|
199
|
+
if (parameters.clipDistance1) {
|
|
200
|
+
gl.enable(GL.CLIP_DISTANCE1_WEBGL);
|
|
201
|
+
}
|
|
202
|
+
if (parameters.clipDistance2) {
|
|
203
|
+
gl.enable(GL.CLIP_DISTANCE2_WEBGL);
|
|
204
|
+
}
|
|
205
|
+
if (parameters.clipDistance3) {
|
|
206
|
+
gl.enable(GL.CLIP_DISTANCE3_WEBGL);
|
|
207
|
+
}
|
|
208
|
+
if (parameters.clipDistance4) {
|
|
209
|
+
gl.enable(GL.CLIP_DISTANCE4_WEBGL);
|
|
210
|
+
}
|
|
211
|
+
if (parameters.clipDistance5) {
|
|
212
|
+
gl.enable(GL.CLIP_DISTANCE5_WEBGL);
|
|
213
|
+
}
|
|
214
|
+
if (parameters.clipDistance6) {
|
|
215
|
+
gl.enable(GL.CLIP_DISTANCE6_WEBGL);
|
|
216
|
+
}
|
|
217
|
+
if (parameters.clipDistance7) {
|
|
218
|
+
gl.enable(GL.CLIP_DISTANCE7_WEBGL);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
154
222
|
// DEPTH STENCIL
|
|
155
223
|
|
|
156
224
|
if (parameters.depthWriteEnabled !== undefined) {
|
|
@@ -212,14 +280,32 @@ export function setDeviceParameters(device: Device, parameters: Parameters) {
|
|
|
212
280
|
if (parameters.blendColorOperation || parameters.blendAlphaOperation) {
|
|
213
281
|
gl.enable(GL.BLEND);
|
|
214
282
|
|
|
215
|
-
const colorEquation = convertBlendOperationToEquation(
|
|
216
|
-
|
|
283
|
+
const colorEquation = convertBlendOperationToEquation(
|
|
284
|
+
'blendColorOperation',
|
|
285
|
+
parameters.blendColorOperation || 'add'
|
|
286
|
+
);
|
|
287
|
+
const alphaEquation = convertBlendOperationToEquation(
|
|
288
|
+
'blendAlphaOperation',
|
|
289
|
+
parameters.blendAlphaOperation || 'add'
|
|
290
|
+
);
|
|
217
291
|
gl.blendEquationSeparate(colorEquation, alphaEquation);
|
|
218
292
|
|
|
219
|
-
const colorSrcFactor = convertBlendFactorToFunction(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
293
|
+
const colorSrcFactor = convertBlendFactorToFunction(
|
|
294
|
+
'blendColorSrcFactor',
|
|
295
|
+
parameters.blendColorSrcFactor || 'one'
|
|
296
|
+
);
|
|
297
|
+
const colorDstFactor = convertBlendFactorToFunction(
|
|
298
|
+
'blendColorDstFactor',
|
|
299
|
+
parameters.blendColorDstFactor || 'zero'
|
|
300
|
+
);
|
|
301
|
+
const alphaSrcFactor = convertBlendFactorToFunction(
|
|
302
|
+
'blendAlphaSrcFactor',
|
|
303
|
+
parameters.blendAlphaSrcFactor || 'one'
|
|
304
|
+
);
|
|
305
|
+
const alphaDstFactor = convertBlendFactorToFunction(
|
|
306
|
+
'blendAlphaDstFactor',
|
|
307
|
+
parameters.blendAlphaDstFactor || 'zero'
|
|
308
|
+
);
|
|
223
309
|
gl.blendFuncSeparate(colorSrcFactor, colorDstFactor, alphaSrcFactor, alphaDstFactor);
|
|
224
310
|
}
|
|
225
311
|
}
|
|
@@ -286,20 +372,23 @@ function convertStencilOperation(parameter: string, value: StencilOperation): GL
|
|
|
286
372
|
});
|
|
287
373
|
}
|
|
288
374
|
|
|
289
|
-
function convertBlendOperationToEquation(
|
|
375
|
+
function convertBlendOperationToEquation(
|
|
376
|
+
parameter: string,
|
|
377
|
+
value: BlendOperation
|
|
378
|
+
): GLBlendEquation {
|
|
290
379
|
return map(parameter, value, {
|
|
291
|
-
|
|
292
|
-
|
|
380
|
+
add: GL.FUNC_ADD,
|
|
381
|
+
subtract: GL.FUNC_SUBTRACT,
|
|
293
382
|
'reverse-subtract': GL.FUNC_REVERSE_SUBTRACT,
|
|
294
|
-
|
|
295
|
-
|
|
383
|
+
min: GL.MIN,
|
|
384
|
+
max: GL.MAX
|
|
296
385
|
} as Record<BlendOperation, GLBlendEquation>);
|
|
297
386
|
}
|
|
298
387
|
|
|
299
388
|
function convertBlendFactorToFunction(parameter: string, value: BlendFactor): GLBlendFunction {
|
|
300
389
|
return map(parameter, value, {
|
|
301
|
-
|
|
302
|
-
|
|
390
|
+
one: GL.ONE,
|
|
391
|
+
zero: GL.ZERO,
|
|
303
392
|
'src-color': GL.SRC_COLOR,
|
|
304
393
|
'one-minus-src-color': GL.ONE_MINUS_SRC_COLOR,
|
|
305
394
|
'dst-color': GL.DST_COLOR,
|
|
@@ -307,7 +396,7 @@ function convertBlendFactorToFunction(parameter: string, value: BlendFactor): GL
|
|
|
307
396
|
'src-alpha': GL.SRC_ALPHA,
|
|
308
397
|
'one-minus-src-alpha': GL.ONE_MINUS_SRC_ALPHA,
|
|
309
398
|
'dst-alpha': GL.DST_ALPHA,
|
|
310
|
-
'one-minus-dst-alpha': GL.ONE_MINUS_DST_ALPHA
|
|
399
|
+
'one-minus-dst-alpha': GL.ONE_MINUS_DST_ALPHA
|
|
311
400
|
} as Record<BlendFactor, GLBlendFunction>);
|
|
312
401
|
}
|
|
313
402
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
// SAMPLER FILTERS
|
|
@@ -55,7 +56,9 @@ export function convertSamplerParametersToWebGL(props: SamplerProps): GLSamplerP
|
|
|
55
56
|
// HELPERS
|
|
56
57
|
|
|
57
58
|
/** Convert address more */
|
|
58
|
-
function convertAddressMode(
|
|
59
|
+
function convertAddressMode(
|
|
60
|
+
addressMode: 'clamp-to-edge' | 'repeat' | 'mirror-repeat'
|
|
61
|
+
): GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT {
|
|
59
62
|
switch (addressMode) {
|
|
60
63
|
case 'clamp-to-edge':
|
|
61
64
|
return GL.CLAMP_TO_EDGE;
|
|
@@ -82,7 +85,13 @@ function convertMaxFilterMode(maxFilter: 'nearest' | 'linear'): GL.NEAREST | GL.
|
|
|
82
85
|
function convertMinFilterMode(
|
|
83
86
|
minFilter: 'nearest' | 'linear',
|
|
84
87
|
mipmapFilter?: 'nearest' | 'linear'
|
|
85
|
-
):
|
|
88
|
+
):
|
|
89
|
+
| GL.NEAREST
|
|
90
|
+
| GL.LINEAR
|
|
91
|
+
| GL.NEAREST_MIPMAP_NEAREST
|
|
92
|
+
| GL.LINEAR_MIPMAP_NEAREST
|
|
93
|
+
| GL.NEAREST_MIPMAP_LINEAR
|
|
94
|
+
| GL.LINEAR_MIPMAP_LINEAR {
|
|
86
95
|
if (!mipmapFilter) {
|
|
87
96
|
return convertMaxFilterMode(minFilter);
|
|
88
97
|
}
|
|
@@ -1,44 +1,69 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {GL} from '@luma.gl/constants';
|
|
5
6
|
import {ShaderAttributeType, ShaderDataType} from '@luma.gl/core';
|
|
6
7
|
|
|
7
8
|
/** Get shader attribute type from GL constants */
|
|
8
|
-
export function getShaderAttributeTypeFromGL(
|
|
9
|
+
export function getShaderAttributeTypeFromGL(
|
|
10
|
+
type: GL,
|
|
11
|
+
components: 1 | 2 | 3 | 4
|
|
12
|
+
): ShaderAttributeType {
|
|
9
13
|
const dataType = getShaderDataTypeFromGL(type);
|
|
10
14
|
switch (components) {
|
|
11
|
-
case 1:
|
|
12
|
-
|
|
13
|
-
case
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
case 1:
|
|
16
|
+
return dataType;
|
|
17
|
+
case 2:
|
|
18
|
+
return `vec2<${dataType}>`;
|
|
19
|
+
case 3:
|
|
20
|
+
return `vec2<${dataType}>`;
|
|
21
|
+
case 4:
|
|
22
|
+
return `vec2<${dataType}>`;
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(String(components));
|
|
16
25
|
}
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
/** Get shader data type from GL constants */
|
|
20
29
|
export function getShaderDataTypeFromGL(type: GL): ShaderDataType {
|
|
21
30
|
switch (type) {
|
|
22
|
-
case GL.INT:
|
|
23
|
-
|
|
24
|
-
case GL.
|
|
25
|
-
|
|
26
|
-
case GL.
|
|
27
|
-
|
|
28
|
-
case GL.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
case GL.INT:
|
|
32
|
+
return 'i32';
|
|
33
|
+
case GL.UNSIGNED_INT:
|
|
34
|
+
return 'u32';
|
|
35
|
+
case GL.SHORT:
|
|
36
|
+
return 'i32';
|
|
37
|
+
case GL.UNSIGNED_SHORT:
|
|
38
|
+
return 'u32';
|
|
39
|
+
case GL.BYTE:
|
|
40
|
+
return 'i32';
|
|
41
|
+
case GL.UNSIGNED_BYTE:
|
|
42
|
+
return 'u32';
|
|
43
|
+
case GL.FLOAT:
|
|
44
|
+
return 'f32';
|
|
45
|
+
case GL.HALF_FLOAT:
|
|
46
|
+
return 'f16';
|
|
47
|
+
default:
|
|
48
|
+
throw new Error(String(type));
|
|
31
49
|
}
|
|
32
50
|
}
|
|
33
51
|
|
|
34
52
|
/** GetGL constant from shader data type */
|
|
35
|
-
export function getGLFromShaderDataType(
|
|
53
|
+
export function getGLFromShaderDataType(
|
|
54
|
+
type: ShaderDataType
|
|
55
|
+
): GL.INT | GL.UNSIGNED_INT | GL.FLOAT | GL.HALF_FLOAT {
|
|
36
56
|
switch (type) {
|
|
37
57
|
// TODO
|
|
38
|
-
case 'i32':
|
|
39
|
-
|
|
40
|
-
case '
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
case 'i32':
|
|
59
|
+
return GL.INT;
|
|
60
|
+
case 'u32':
|
|
61
|
+
return GL.UNSIGNED_INT;
|
|
62
|
+
case 'f32':
|
|
63
|
+
return GL.FLOAT;
|
|
64
|
+
case 'f16':
|
|
65
|
+
return GL.HALF_FLOAT;
|
|
66
|
+
default:
|
|
67
|
+
throw new Error(String(type));
|
|
43
68
|
}
|
|
44
69
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import type {TextureFormat, DeviceFeature} from '@luma.gl/core';
|
|
5
6
|
import {decodeTextureFormat} from '@luma.gl/core';
|
|
6
|
-
import {GL} from '@luma.gl/constants';
|
|
7
|
+
import {GL, GLExtensions} from '@luma.gl/constants';
|
|
8
|
+
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
7
9
|
import {getGLFromVertexType} from './vertex-formats';
|
|
8
10
|
|
|
9
11
|
/* eslint-disable camelcase */
|
|
@@ -18,8 +20,15 @@ const texture_compression_etc1_webgl: DeviceFeature = 'texture-compression-etc1-
|
|
|
18
20
|
const texture_compression_pvrtc_webgl: DeviceFeature = 'texture-compression-pvrtc-webgl';
|
|
19
21
|
const texture_compression_atc_webgl: DeviceFeature = 'texture-compression-atc-webgl';
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const float32_renderable: DeviceFeature = 'float32-renderable-webgl';
|
|
24
|
+
const float16_renderable: DeviceFeature = 'float16-renderable-webgl';
|
|
25
|
+
const rgb9e5ufloat_renderable: DeviceFeature = 'rgb9e5ufloat_renderable-webgl';
|
|
26
|
+
const snorm8_renderable: DeviceFeature = 'snorm8-renderable-webgl';
|
|
27
|
+
const norm16_renderable: DeviceFeature = 'norm16-renderable-webgl';
|
|
28
|
+
const snorm16_renderable: DeviceFeature = 'snorm16-renderable-webgl';
|
|
29
|
+
|
|
30
|
+
const float32_filterable: DeviceFeature = 'float32-filterable';
|
|
31
|
+
const float16_filterable: DeviceFeature = 'float16-filterable-webgl';
|
|
23
32
|
|
|
24
33
|
// Define local webgl extension strings to optimize minification
|
|
25
34
|
const X_S3TC = 'WEBGL_compressed_texture_s3tc'; // BC1, BC2, BC3
|
|
@@ -33,22 +42,21 @@ const X_PVRTC = 'WEBGL_compressed_texture_pvrtc';
|
|
|
33
42
|
const X_ATC = 'WEBGL_compressed_texture_atc';
|
|
34
43
|
|
|
35
44
|
// Define local webgl extension strings to optimize minification
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
// const DEPTH = 'WEBGL_depth_texture';
|
|
40
|
-
|
|
41
|
-
// WebGL1-only extensions
|
|
42
|
-
// const EXT_SRGB = 'EXT_sRGB'; // https://developer.mozilla.org/en-US/docs/Web/API/EXT_sRGB
|
|
45
|
+
const EXT_texture_norm16 = 'EXT_texture_norm16';
|
|
46
|
+
const EXT_render_snorm = 'EXT_render_snorm';
|
|
47
|
+
const EXT_color_buffer_float = 'EXT_color_buffer_float';
|
|
43
48
|
|
|
44
49
|
// prettier-ignore
|
|
45
|
-
const
|
|
46
|
-
'float32-renderable-webgl': ['EXT_color_buffer_float'],
|
|
50
|
+
export const TEXTURE_FEATURES: Partial<Record<DeviceFeature, string[]>> = {
|
|
51
|
+
'float32-renderable-webgl': ['EXT_color_buffer_float'],
|
|
47
52
|
'float16-renderable-webgl': ['EXT_color_buffer_half_float'],
|
|
48
|
-
'
|
|
53
|
+
'rgb9e5ufloat_renderable-webgl': ['WEBGL_render_shared_exponent'],
|
|
54
|
+
'snorm8-renderable-webgl': [EXT_render_snorm],
|
|
55
|
+
'norm16-renderable-webgl': [EXT_texture_norm16],
|
|
56
|
+
'snorm16-renderable-webgl': [EXT_texture_norm16, EXT_render_snorm],
|
|
49
57
|
|
|
50
|
-
'float32-filterable
|
|
51
|
-
'float16-filterable-
|
|
58
|
+
'float32-filterable': ['OES_texture_float_linear'],
|
|
59
|
+
'float16-filterable-webgl': ['OES_texture_half_float_linear'],
|
|
52
60
|
'texture-filterable-anisotropic-webgl': ['EXT_texture_filter_anisotropic'],
|
|
53
61
|
|
|
54
62
|
'texture-blend-float-webgl': ['EXT_float_blend'],
|
|
@@ -65,19 +73,27 @@ const TEXTURE_FEATURE_CHECKS: Partial<Record<DeviceFeature, string[]>> = {
|
|
|
65
73
|
'texture-compression-atc-webgl': [X_ATC]
|
|
66
74
|
};
|
|
67
75
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
/** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
|
|
77
|
+
// export function getTextureFeatures(
|
|
78
|
+
// gl: WebGL2RenderingContext,
|
|
79
|
+
// extensions: GLExtensions
|
|
80
|
+
// ): DeviceFeature[] {
|
|
81
|
+
// const textureFeatures = Object.keys(TEXTURE_FEATURES) as DeviceFeature[];
|
|
82
|
+
// return textureFeatures.filter(feature => checkTextureFeature(gl, feature, extensions));
|
|
83
|
+
// }
|
|
84
|
+
|
|
85
|
+
export function isTextureFeature(feature: DeviceFeature): boolean {
|
|
86
|
+
return feature in TEXTURE_FEATURES;
|
|
75
87
|
}
|
|
76
88
|
|
|
77
|
-
/**
|
|
78
|
-
export function
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
/** Checks a texture feature (for Device.features). Mainly compressed texture support */
|
|
90
|
+
export function checkTextureFeature(
|
|
91
|
+
gl: WebGL2RenderingContext,
|
|
92
|
+
feature: DeviceFeature,
|
|
93
|
+
extensions: GLExtensions
|
|
94
|
+
): boolean {
|
|
95
|
+
const textureExtensions = TEXTURE_FEATURES[feature] || [];
|
|
96
|
+
return textureExtensions.every(extension => getWebGLExtension(gl, extension, extensions));
|
|
81
97
|
}
|
|
82
98
|
|
|
83
99
|
// TEXTURE FORMATS
|
|
@@ -138,21 +154,21 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
138
154
|
|
|
139
155
|
// 8-bit formats
|
|
140
156
|
'r8unorm': {gl: GL.R8, b: 1, c: 1, renderbuffer: true},
|
|
141
|
-
'r8snorm': {gl: GL.R8_SNORM, b: 1, c: 1},
|
|
157
|
+
'r8snorm': {gl: GL.R8_SNORM, b: 1, c: 1, render: snorm8_renderable},
|
|
142
158
|
'r8uint': {gl: GL.R8UI, b: 1, c: 1, renderbuffer: true},
|
|
143
159
|
'r8sint': {gl: GL.R8I, b: 1, c: 1, renderbuffer: true},
|
|
144
160
|
|
|
145
161
|
// 16-bit formats
|
|
146
162
|
'rg8unorm': {gl: GL.RG8, b: 2, c: 2, renderbuffer: true},
|
|
147
|
-
'rg8snorm': {gl: GL.RG8_SNORM, b: 2, c: 2},
|
|
163
|
+
'rg8snorm': {gl: GL.RG8_SNORM, b: 2, c: 2, render: snorm8_renderable},
|
|
148
164
|
'rg8uint': {gl: GL.RG8UI, b: 2, c: 2, renderbuffer: true},
|
|
149
165
|
'rg8sint': {gl: GL.RG8I, b: 2, c: 2, renderbuffer: true},
|
|
150
166
|
|
|
151
167
|
'r16uint': {gl: GL.R16UI, b: 2, c: 1, renderbuffer: true},
|
|
152
168
|
'r16sint': {gl: GL.R16I, b: 2, c: 1, renderbuffer: true},
|
|
153
|
-
'r16float': {gl: GL.R16F, b: 2, c: 1, render:
|
|
154
|
-
'r16unorm-webgl': {gl: GL.R16_EXT, b:2, c:1, f:
|
|
155
|
-
'r16snorm-webgl': {gl: GL.R16_SNORM_EXT, b:2, c:1, f:
|
|
169
|
+
'r16float': {gl: GL.R16F, b: 2, c: 1, render: float16_renderable, filter: 'float16-filterable-webgl', renderbuffer: true},
|
|
170
|
+
'r16unorm-webgl': {gl: GL.R16_EXT, b:2, c:1, f: norm16_renderable, renderbuffer: true},
|
|
171
|
+
'r16snorm-webgl': {gl: GL.R16_SNORM_EXT, b:2, c:1, f: snorm16_renderable},
|
|
156
172
|
|
|
157
173
|
// Packed 16-bit formats
|
|
158
174
|
'rgba4unorm-webgl': {gl: GL.RGBA4, b: 2, c: 4, wgpu: false, renderbuffer: true},
|
|
@@ -166,7 +182,7 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
166
182
|
// 32-bit formats
|
|
167
183
|
'rgba8unorm': {gl: GL.RGBA8, b: 4, c: 2, bpp: 4},
|
|
168
184
|
'rgba8unorm-srgb': {gl: GL.SRGB8_ALPHA8, b: 4, c: 4, bpp: 4},
|
|
169
|
-
'rgba8snorm': {gl: GL.RGBA8_SNORM, b: 4, c: 4},
|
|
185
|
+
'rgba8snorm': {gl: GL.RGBA8_SNORM, b: 4, c: 4, render: snorm8_renderable},
|
|
170
186
|
'rgba8uint': {gl: GL.RGBA8UI, b: 4, c: 4, bpp: 4},
|
|
171
187
|
'rgba8sint': {gl: GL.RGBA8I, b: 4, c: 4, bpp: 4},
|
|
172
188
|
// reverse colors, webgpu only
|
|
@@ -176,42 +192,42 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
176
192
|
'rg16uint': {gl: GL.RG16UI, b: 4, c: 1, bpp: 4},
|
|
177
193
|
'rg16sint': {gl: GL.RG16I, b: 4, c: 2, bpp: 4},
|
|
178
194
|
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
179
|
-
'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render:
|
|
180
|
-
'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2,
|
|
181
|
-
'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2,
|
|
195
|
+
'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, renderbuffer: true},
|
|
196
|
+
'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2, render: norm16_renderable},
|
|
197
|
+
'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2, render: snorm16_renderable},
|
|
182
198
|
|
|
183
199
|
'r32uint': {gl: GL.R32UI, b: 4, c: 1, bpp: 4, renderbuffer: true},
|
|
184
200
|
'r32sint': {gl: GL.R32I, b: 4, c: 1, bpp: 4, renderbuffer: true},
|
|
185
|
-
'r32float': {gl: GL.R32F, bpp: 4, b: 4, c: 1, render:
|
|
201
|
+
'r32float': {gl: GL.R32F, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable},
|
|
186
202
|
|
|
187
203
|
// Packed 32-bit formats
|
|
188
|
-
'rgb9e5ufloat': {gl: GL.RGB9_E5, b: 4, c: 3, p: 1, render:
|
|
189
|
-
'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, b: 4, c: 3, p: 1,render:
|
|
204
|
+
'rgb9e5ufloat': {gl: GL.RGB9_E5, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable}, // , filter: true},
|
|
205
|
+
'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, b: 4, c: 3, p: 1,render: float32_renderable, renderbuffer: true},
|
|
190
206
|
'rgb10a2unorm': {gl: GL.RGB10_A2, b: 4, c: 4, p: 1, renderbuffer: true},
|
|
191
|
-
'
|
|
207
|
+
'rgb10a2uint-webgl': {b: 4, c: 4, gl: GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true},
|
|
192
208
|
|
|
193
209
|
// 48-bit formats
|
|
194
|
-
'rgb16unorm-webgl': {gl: GL.RGB16_EXT, b:2, c:3, f:
|
|
195
|
-
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, b:2, c:3, f:
|
|
210
|
+
'rgb16unorm-webgl': {gl: GL.RGB16_EXT, b:2, c:3, f: norm16_renderable}, // rgb not renderable
|
|
211
|
+
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, b:2, c:3, f: norm16_renderable}, // rgb not renderable
|
|
196
212
|
|
|
197
213
|
// 64-bit formats
|
|
198
214
|
'rg32uint': {gl: GL.RG32UI, b: 8, c: 2, renderbuffer: true},
|
|
199
215
|
'rg32sint': {gl: GL.RG32I, b: 8, c: 2, renderbuffer: true},
|
|
200
|
-
'rg32float': {gl: GL.RG32F, b: 8, c: 2, render:
|
|
216
|
+
'rg32float': {gl: GL.RG32F, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, renderbuffer: true},
|
|
201
217
|
'rgba16uint': {gl: GL.RGBA16UI, b: 8, c: 4, renderbuffer: true},
|
|
202
218
|
'rgba16sint': {gl: GL.RGBA16I, b: 8, c: 4, renderbuffer: true},
|
|
203
|
-
'rgba16float': {gl: GL.RGBA16F, b: 8, c: 4, render:
|
|
204
|
-
'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, b:2, c:4,
|
|
205
|
-
'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT, b:2, c:4,
|
|
219
|
+
'rgba16float': {gl: GL.RGBA16F, b: 8, c: 4, render: float16_renderable, filter: float16_filterable},
|
|
220
|
+
'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, b:2, c:4, render: norm16_renderable, renderbuffer: true},
|
|
221
|
+
'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT, b:2, c:4, render: snorm16_renderable},
|
|
206
222
|
|
|
207
223
|
// 96-bit formats (deprecated!)
|
|
208
|
-
'rgb32float-webgl': {gl: GL.RGB32F, render:
|
|
209
|
-
gl2ext:
|
|
224
|
+
'rgb32float-webgl': {gl: GL.RGB32F, render: float32_renderable, filter: float32_filterable,
|
|
225
|
+
gl2ext: EXT_color_buffer_float, dataFormat: GL.RGB, types: [GL.FLOAT]},
|
|
210
226
|
|
|
211
227
|
// 128-bit formats
|
|
212
228
|
'rgba32uint': {gl: GL.RGBA32UI, b: 16, c: 4, renderbuffer: true},
|
|
213
229
|
'rgba32sint': {gl: GL.RGBA32I, b: 16, c: 4, renderbuffer: true},
|
|
214
|
-
'rgba32float': {gl: GL.RGBA32F, b: 16, c: 4, render:
|
|
230
|
+
'rgba32float': {gl: GL.RGBA32F, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, renderbuffer: true},
|
|
215
231
|
|
|
216
232
|
// Depth and stencil formats
|
|
217
233
|
'stencil8': {gl: GL.STENCIL_INDEX8, b: 1, c: 1, attachment: GL.STENCIL_ATTACHMENT, renderbuffer: true}, // 8 stencil bits
|
|
@@ -400,7 +416,7 @@ export const RENDERBUFFER_FORMATS: Record<string, RenderbufferFormat> = {
|
|
|
400
416
|
[GL.RG32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 8},
|
|
401
417
|
// TODO - can't get WEBGL_color_buffer_float to work on renderbuffers
|
|
402
418
|
[GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2, bpp: 16},
|
|
403
|
-
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2
|
|
419
|
+
// [GL.RGBA32F]: {ext: EXT_FLOAT_WEBGL2},
|
|
404
420
|
[GL.R11F_G11F_B10F]: {ext: EXT_FLOAT_WEBGL2, bpp: 4}
|
|
405
421
|
};
|
|
406
422
|
*/
|
|
@@ -439,7 +455,8 @@ const TYPE_SIZES = {
|
|
|
439
455
|
/** Checks if a texture format is supported */
|
|
440
456
|
export function isTextureFormatSupported(
|
|
441
457
|
gl: WebGL2RenderingContext,
|
|
442
|
-
formatOrGL: TextureFormat | GL
|
|
458
|
+
formatOrGL: TextureFormat | GL,
|
|
459
|
+
extensions: GLExtensions
|
|
443
460
|
): boolean {
|
|
444
461
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
445
462
|
const info = TEXTURE_FORMATS[format];
|
|
@@ -453,17 +470,18 @@ export function isTextureFormatSupported(
|
|
|
453
470
|
// Check extensions
|
|
454
471
|
const extension = info.x || info.gl2ext;
|
|
455
472
|
if (extension) {
|
|
456
|
-
return Boolean(gl
|
|
473
|
+
return Boolean(getWebGLExtension(gl, extension, extensions));
|
|
457
474
|
}
|
|
458
475
|
return true;
|
|
459
476
|
}
|
|
460
477
|
|
|
461
478
|
export function isRenderbufferFormatSupported(
|
|
462
479
|
gl: WebGL2RenderingContext,
|
|
463
|
-
format: TextureFormat
|
|
480
|
+
format: TextureFormat,
|
|
481
|
+
extensions: GLExtensions
|
|
464
482
|
): boolean {
|
|
465
483
|
// Note: Order is important since the function call initializes extensions.
|
|
466
|
-
return isTextureFormatSupported(gl, format) && TEXTURE_FORMATS[format]?.renderbuffer;
|
|
484
|
+
return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.renderbuffer;
|
|
467
485
|
}
|
|
468
486
|
|
|
469
487
|
/**
|
|
@@ -495,7 +513,8 @@ export function convertTextureFormatToGL(format: TextureFormat): GL | undefined
|
|
|
495
513
|
/** Checks if a texture format is supported */
|
|
496
514
|
export function getTextureFormatSupport(
|
|
497
515
|
gl: WebGL2RenderingContext,
|
|
498
|
-
formatOrGL: TextureFormat | GL
|
|
516
|
+
formatOrGL: TextureFormat | GL,
|
|
517
|
+
extensions: GLExtensions
|
|
499
518
|
): {
|
|
500
519
|
supported: boolean;
|
|
501
520
|
filterable?: boolean;
|
|
@@ -515,20 +534,20 @@ export function getTextureFormatSupport(
|
|
|
515
534
|
|
|
516
535
|
// Support Check that we have a GL constant
|
|
517
536
|
let supported = info.gl === undefined;
|
|
518
|
-
supported = supported &&
|
|
537
|
+
supported = supported && checkTextureFeature(gl, info.f, extensions);
|
|
519
538
|
|
|
520
539
|
// Filtering
|
|
521
540
|
// const filterable = info.filter
|
|
522
|
-
// ?
|
|
541
|
+
// ? checkTextureFeature(gl, infofilter])
|
|
523
542
|
// : decoded && !decoded.signed;
|
|
524
543
|
// const renderable = info.filter
|
|
525
|
-
// ?
|
|
544
|
+
// ? checkTextureFeature(gl, inforender])
|
|
526
545
|
// : decoded && !decoded.signed;
|
|
527
546
|
|
|
528
547
|
return {
|
|
529
548
|
supported,
|
|
530
|
-
renderable: supported &&
|
|
531
|
-
filterable: supported &&
|
|
549
|
+
renderable: supported && checkTextureFeature(gl, info.render, extensions),
|
|
550
|
+
filterable: supported && checkTextureFeature(gl, info.filter, extensions),
|
|
532
551
|
blendable: false, // tod,
|
|
533
552
|
storable: false
|
|
534
553
|
};
|
|
@@ -537,10 +556,11 @@ export function getTextureFormatSupport(
|
|
|
537
556
|
/** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
|
|
538
557
|
export function isTextureFormatFilterable(
|
|
539
558
|
gl: WebGL2RenderingContext,
|
|
540
|
-
formatOrGL: TextureFormat | GL
|
|
559
|
+
formatOrGL: TextureFormat | GL,
|
|
560
|
+
extensions: GLExtensions
|
|
541
561
|
): boolean {
|
|
542
562
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
543
|
-
if (!isTextureFormatSupported(gl, format)) {
|
|
563
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
544
564
|
return false;
|
|
545
565
|
}
|
|
546
566
|
try {
|
|
@@ -552,20 +572,21 @@ export function isTextureFormatFilterable(
|
|
|
552
572
|
return false;
|
|
553
573
|
}
|
|
554
574
|
if (format.endsWith('32float')) {
|
|
555
|
-
return Boolean(gl
|
|
575
|
+
return Boolean(getWebGLExtension(gl, 'OES_texture_float_linear, extensions', extensions));
|
|
556
576
|
}
|
|
557
577
|
if (format.endsWith('16float')) {
|
|
558
|
-
return Boolean(gl
|
|
578
|
+
return Boolean(getWebGLExtension(gl, 'OES_texture_half_float_linear, extensions', extensions));
|
|
559
579
|
}
|
|
560
580
|
return true;
|
|
561
581
|
}
|
|
562
582
|
|
|
563
583
|
export function isTextureFormatRenderable(
|
|
564
584
|
gl: WebGL2RenderingContext,
|
|
565
|
-
formatOrGL: TextureFormat | GL
|
|
585
|
+
formatOrGL: TextureFormat | GL,
|
|
586
|
+
extensions: GLExtensions
|
|
566
587
|
): boolean {
|
|
567
588
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
568
|
-
if (!isTextureFormatSupported(gl, format)) {
|
|
589
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
569
590
|
return false;
|
|
570
591
|
}
|
|
571
592
|
if (typeof format === 'number') {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {GL} from '@luma.gl/constants';
|
|
5
6
|
import {VertexFormat, VertexType} from '@luma.gl/core';
|
|
6
7
|
|
|
7
|
-
type GLDataType =
|
|
8
|
+
type GLDataType =
|
|
8
9
|
| GL.UNSIGNED_BYTE
|
|
9
10
|
| GL.BYTE
|
|
10
11
|
| GL.UNSIGNED_SHORT
|
|
@@ -14,7 +15,6 @@ type GLDataType =
|
|
|
14
15
|
| GL.HALF_FLOAT
|
|
15
16
|
| GL.FLOAT;
|
|
16
17
|
|
|
17
|
-
|
|
18
18
|
/** Get vertex format from GL constants */
|
|
19
19
|
export function getVertexFormatFromGL(type: GLDataType, components: 1 | 2 | 3 | 4): VertexFormat {
|
|
20
20
|
const base = getVertexTypeFromGL(type);
|