@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
|
@@ -1,69 +1,101 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
// Feature detection for WebGL
|
|
5
6
|
// Provides a function that enables simple checking of which WebGL features are
|
|
6
7
|
|
|
7
|
-
import {DeviceFeature} from '@luma.gl/core';
|
|
8
|
-
import {
|
|
8
|
+
import {DeviceFeature, DeviceFeatures} from '@luma.gl/core';
|
|
9
|
+
import {GLExtensions} from '@luma.gl/constants';
|
|
10
|
+
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
11
|
+
import {isTextureFeature, checkTextureFeature} from '../converters/texture-formats';
|
|
12
|
+
import {TEXTURE_FEATURES} from '../converters/texture-formats';
|
|
9
13
|
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Defines luma.gl "feature" names and semantics
|
|
16
|
+
* when value is 'string' it is the name of the extension that enables this feature
|
|
17
|
+
*/
|
|
18
|
+
const WEBGL_FEATURES: Partial<Record<DeviceFeature, boolean | string>> = {
|
|
19
|
+
// optional WebGPU features
|
|
20
|
+
'depth-clip-control': 'EXT_depth_clamp', // TODO these seem subtly different
|
|
21
|
+
// 'timestamp-query' // GPUQueryType "timestamp-query"
|
|
22
|
+
// "indirect-first-instance"
|
|
23
|
+
// Textures are handled by getTextureFeatures()
|
|
24
|
+
// 'depth24unorm-stencil8' // GPUTextureFormat 'depth24unorm-stencil8'
|
|
25
|
+
// 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
|
|
13
26
|
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
// optional WebGL features
|
|
28
|
+
'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2',
|
|
29
|
+
'compilation-status-async-webgl': 'KHR_parallel_shader_compile',
|
|
30
|
+
'polygon-mode-webgl': 'WEBGL_polygon_mode',
|
|
31
|
+
'provoking-vertex-webgl': 'WEBGL_provoking_vertex',
|
|
32
|
+
'shader-clip-cull-distance-webgl': 'WEBGL_clip_cull_distance',
|
|
33
|
+
'shader-noperspective-interpolation-webgl': 'NV_shader_noperspective_interpolation',
|
|
34
|
+
'shader-conservative-depth-webgl': 'EXT_conservative_depth'
|
|
19
35
|
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
// features.add('depth24unorm-stencil8'); // GPUTextureFormat 'depth24unorm-stencil8'.
|
|
23
|
-
// features.add('depth32float-stencil8'); // GPUTextureFormat 'depth32float-stencil8'.
|
|
24
|
-
// features.add('timestamp-query'); // GPUQueryType "timestamp-query"
|
|
25
|
-
// "indirect-first-instance"
|
|
36
|
+
// Textures are handled by getTextureFeatures()
|
|
37
|
+
};
|
|
26
38
|
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
/**
|
|
40
|
+
* WebGL extensions exposed as luma.gl features
|
|
41
|
+
* To minimize GL log noise and improve performance, this class ensures that
|
|
42
|
+
* - WebGL extensions are not queried until the corresponding feature is checked.
|
|
43
|
+
* - WebGL extensions are only queried once.
|
|
44
|
+
*/
|
|
45
|
+
export class WebGLDeviceFeatures extends DeviceFeatures {
|
|
46
|
+
protected gl: WebGL2RenderingContext;
|
|
47
|
+
protected extensions: GLExtensions;
|
|
48
|
+
protected testedFeatures = new Set<DeviceFeature>();
|
|
29
49
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
50
|
+
constructor(gl: WebGL2RenderingContext, extensions: GLExtensions) {
|
|
51
|
+
super();
|
|
52
|
+
this.gl = gl;
|
|
53
|
+
this.extensions = extensions;
|
|
54
|
+
// TODO - is this really needed?
|
|
55
|
+
// Enable EXT_float_blend first: https://developer.mozilla.org/en-US/docs/Web/API/EXT_float_blend
|
|
56
|
+
getWebGLExtension(gl, 'EXT_color_buffer_float', extensions);
|
|
57
|
+
}
|
|
34
58
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
59
|
+
*[Symbol.iterator](): IterableIterator<DeviceFeature> {
|
|
60
|
+
for (const feature of Object.keys(WEBGL_FEATURES) as DeviceFeature[]) {
|
|
61
|
+
if (this.has(feature)) {
|
|
62
|
+
yield feature;
|
|
63
|
+
}
|
|
39
64
|
}
|
|
65
|
+
for (const feature of Object.keys(TEXTURE_FEATURES) as DeviceFeature[]) {
|
|
66
|
+
if (this.has(feature)) {
|
|
67
|
+
yield feature;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return [];
|
|
40
71
|
}
|
|
41
|
-
return features;
|
|
42
|
-
}
|
|
43
72
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return typeof featureInfo === 'string'
|
|
49
|
-
? Boolean(gl.getExtension(featureInfo))
|
|
50
|
-
: Boolean(featureInfo);
|
|
51
|
-
}
|
|
73
|
+
override has(feature: DeviceFeature): boolean {
|
|
74
|
+
// We have already tested this feature
|
|
75
|
+
if (!this.testedFeatures.has(feature)) {
|
|
76
|
+
this.testedFeatures.add(feature);
|
|
52
77
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const WEBGL_FEATURES: Partial<Record<DeviceFeature, boolean | string>> = {
|
|
58
|
-
webgl: true,
|
|
59
|
-
glsl: true,
|
|
78
|
+
// Check the feature once
|
|
79
|
+
if (isTextureFeature(feature) && checkTextureFeature(this.gl, feature, this.extensions)) {
|
|
80
|
+
this.features.add(feature);
|
|
81
|
+
}
|
|
60
82
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
83
|
+
if (this.getWebGLFeature(feature)) {
|
|
84
|
+
this.features.add(feature);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return this.features.has(feature);
|
|
88
|
+
}
|
|
64
89
|
|
|
65
|
-
|
|
66
|
-
|
|
90
|
+
/** Extract all WebGL features */
|
|
91
|
+
protected getWebGLFeature(feature: DeviceFeature): boolean {
|
|
92
|
+
const featureInfo = WEBGL_FEATURES[feature];
|
|
93
|
+
// string value requires checking the corresponding WebGL extension
|
|
94
|
+
const isSupported =
|
|
95
|
+
typeof featureInfo === 'string'
|
|
96
|
+
? Boolean(getWebGLExtension(this.gl, featureInfo, this.extensions))
|
|
97
|
+
: Boolean(featureInfo);
|
|
67
98
|
|
|
68
|
-
|
|
69
|
-
}
|
|
99
|
+
return isSupported;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {DeviceInfo} from '@luma.gl/core';
|
|
5
|
-
import {GL} from '@luma.gl/constants';
|
|
6
|
+
import {GL, GLExtensions} from '@luma.gl/constants';
|
|
7
|
+
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
6
8
|
|
|
7
9
|
/** @returns strings identifying the GPU vendor and driver. */
|
|
8
|
-
export function getDeviceInfo(gl: WebGL2RenderingContext): DeviceInfo {
|
|
10
|
+
export function getDeviceInfo(gl: WebGL2RenderingContext, extensions: GLExtensions): DeviceInfo {
|
|
9
11
|
// "Masked" info is always available, but don't contain much useful information
|
|
10
12
|
const vendorMasked = gl.getParameter(GL.VENDOR);
|
|
11
13
|
const rendererMasked = gl.getParameter(GL.RENDERER);
|
|
12
14
|
|
|
13
15
|
// If we are lucky, unmasked info is available
|
|
14
16
|
// https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/
|
|
15
|
-
|
|
17
|
+
getWebGLExtension(gl, 'WEBGL_debug_renderer_info', extensions);
|
|
18
|
+
const ext = extensions.WEBGL_debug_renderer_info;
|
|
16
19
|
const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : GL.VENDOR);
|
|
17
20
|
const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : GL.RENDERER);
|
|
18
21
|
const vendor = vendorUnmasked || vendorMasked;
|
|
@@ -47,44 +50,50 @@ export function getDeviceInfo(gl: WebGL2RenderingContext): DeviceInfo {
|
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
/** "Sniff" the GPU type from the info. This works best if unmasked info is available. */
|
|
50
|
-
function identifyGPUVendor(
|
|
51
|
-
|
|
53
|
+
function identifyGPUVendor(
|
|
54
|
+
vendor: string,
|
|
55
|
+
renderer: string
|
|
56
|
+
): 'nvidia' | 'intel' | 'apple' | 'amd' | 'software' | 'unknown' {
|
|
57
|
+
if (/NVIDIA/i.exec(vendor) || /NVIDIA/i.exec(renderer)) {
|
|
52
58
|
return 'nvidia';
|
|
53
59
|
}
|
|
54
|
-
if (
|
|
60
|
+
if (/INTEL/i.exec(vendor) || /INTEL/i.exec(renderer)) {
|
|
55
61
|
return 'intel';
|
|
56
62
|
}
|
|
57
|
-
if (
|
|
63
|
+
if (/Apple/i.exec(vendor) || /Apple/i.exec(renderer)) {
|
|
58
64
|
return 'apple';
|
|
59
65
|
}
|
|
60
66
|
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
/AMD/i.exec(vendor) ||
|
|
68
|
+
/AMD/i.exec(renderer) ||
|
|
69
|
+
/ATI/i.exec(vendor) ||
|
|
70
|
+
/ATI/i.exec(renderer)
|
|
65
71
|
) {
|
|
66
72
|
return 'amd';
|
|
67
73
|
}
|
|
68
|
-
if (
|
|
74
|
+
if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
|
|
69
75
|
return 'software';
|
|
70
76
|
}
|
|
71
|
-
|
|
77
|
+
|
|
72
78
|
return 'unknown';
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
/** "Sniff" the GPU backend from the info. This works best if unmasked info is available. */
|
|
76
82
|
function identifyGPUBackend(vendor: string, renderer: string): 'opengl' | 'metal' | 'unknown' {
|
|
77
|
-
if (
|
|
83
|
+
if (/Metal/i.exec(vendor) || /Metal/i.exec(renderer)) {
|
|
78
84
|
return 'metal';
|
|
79
85
|
}
|
|
80
|
-
if (
|
|
86
|
+
if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
|
|
81
87
|
return 'opengl';
|
|
82
|
-
}
|
|
88
|
+
}
|
|
83
89
|
return 'unknown';
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
function identifyGPUType(
|
|
87
|
-
|
|
92
|
+
function identifyGPUType(
|
|
93
|
+
vendor: string,
|
|
94
|
+
renderer: string
|
|
95
|
+
): 'discrete' | 'integrated' | 'cpu' | 'unknown' {
|
|
96
|
+
if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
|
|
88
97
|
return 'cpu';
|
|
89
98
|
}
|
|
90
99
|
|
|
@@ -1,157 +1,53 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
|
-
import
|
|
5
|
+
import {DeviceLimits} from '@luma.gl/core';
|
|
5
6
|
import {GL} from '@luma.gl/constants';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
[GL.MAX_CUBE_MAP_TEXTURE_SIZE]: number;
|
|
45
|
-
[GL.MAX_TEXTURE_IMAGE_UNITS]: number;
|
|
46
|
-
[GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS]: number;
|
|
47
|
-
[GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS]: number;
|
|
48
|
-
[GL.MAX_RENDERBUFFER_SIZE]: number;
|
|
49
|
-
[GL.MAX_VARYING_VECTORS]: number;
|
|
50
|
-
[GL.MAX_VERTEX_ATTRIBS]: number;
|
|
51
|
-
[GL.MAX_VERTEX_UNIFORM_VECTORS]: number;
|
|
52
|
-
[GL.MAX_FRAGMENT_UNIFORM_VECTORS]: number;
|
|
53
|
-
[GL.MAX_VIEWPORT_DIMS]: [number, number];
|
|
54
|
-
|
|
55
|
-
// Extensions
|
|
56
|
-
[GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT]: number;
|
|
57
|
-
|
|
58
|
-
// WebGL2 Limits
|
|
59
|
-
[GL.MAX_3D_TEXTURE_SIZE]: number;
|
|
60
|
-
[GL.MAX_ARRAY_TEXTURE_LAYERS]: number;
|
|
61
|
-
// [GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: number;
|
|
62
|
-
[GL.MAX_COLOR_ATTACHMENTS]: number;
|
|
63
|
-
[GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: number;
|
|
64
|
-
[GL.MAX_COMBINED_UNIFORM_BLOCKS]: number;
|
|
65
|
-
[GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: number;
|
|
66
|
-
[GL.MAX_DRAW_BUFFERS]: number;
|
|
67
|
-
[GL.MAX_ELEMENT_INDEX]: number;
|
|
68
|
-
[GL.MAX_ELEMENTS_INDICES]: number;
|
|
69
|
-
[GL.MAX_ELEMENTS_VERTICES]: number;
|
|
70
|
-
[GL.MAX_FRAGMENT_INPUT_COMPONENTS]: number;
|
|
71
|
-
[GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: number;
|
|
72
|
-
[GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: number;
|
|
73
|
-
[GL.MAX_SAMPLES]: number;
|
|
74
|
-
// [GL.MAX_SERVER_WAIT_TIMEOUT]: number;
|
|
75
|
-
[GL.MAX_TEXTURE_LOD_BIAS]: number;
|
|
76
|
-
[GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: number;
|
|
77
|
-
[GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: number;
|
|
78
|
-
[GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: number;
|
|
79
|
-
[GL.MAX_UNIFORM_BLOCK_SIZE]: number;
|
|
80
|
-
[GL.MAX_UNIFORM_BUFFER_BINDINGS]: number;
|
|
81
|
-
[GL.MAX_VARYING_COMPONENTS]: number;
|
|
82
|
-
[GL.MAX_VERTEX_OUTPUT_COMPONENTS]: number;
|
|
83
|
-
[GL.MAX_VERTEX_UNIFORM_BLOCKS]: number;
|
|
84
|
-
[GL.MAX_VERTEX_UNIFORM_COMPONENTS]: number;
|
|
85
|
-
[GL.MIN_PROGRAM_TEXEL_OFFSET]: number;
|
|
86
|
-
[GL.MAX_PROGRAM_TEXEL_OFFSET]: number;
|
|
87
|
-
[GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: number;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export function getWebGLLimits(gl: WebGL2RenderingContext): WebGLLimits {
|
|
91
|
-
function get<T = number>(pname: number): T {
|
|
92
|
-
return gl.getParameter(pname) as T;
|
|
93
|
-
}
|
|
94
|
-
function get2(pname: number, defaultValue?: number): number;
|
|
95
|
-
function get2<T>(pname: number, defaultValue: T): T;
|
|
96
|
-
function get2<T>(pname: number, defaultValue: T): T {
|
|
97
|
-
return (gl.getParameter(pname) as T) || defaultValue;
|
|
8
|
+
// prettier-ignore
|
|
9
|
+
export class WebGLDeviceLimits extends DeviceLimits {
|
|
10
|
+
get maxTextureDimension1D() { return 0; } // WebGL does not support 1D textures
|
|
11
|
+
get maxTextureDimension2D() { return this.getParameter(GL.MAX_TEXTURE_SIZE); }
|
|
12
|
+
get maxTextureDimension3D() { return this.getParameter(GL.MAX_3D_TEXTURE_SIZE); }
|
|
13
|
+
get maxTextureArrayLayers() { return this.getParameter(GL.MAX_ARRAY_TEXTURE_LAYERS); }
|
|
14
|
+
get maxBindGroups() { return 0; }
|
|
15
|
+
get maxDynamicUniformBuffersPerPipelineLayout() { return 0; } // TBD
|
|
16
|
+
get maxDynamicStorageBuffersPerPipelineLayout() { return 0; } // TBD
|
|
17
|
+
get maxSampledTexturesPerShaderStage() { return this.getParameter(GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS); } // ) TBD
|
|
18
|
+
get maxSamplersPerShaderStage() { return this.getParameter(GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS); }
|
|
19
|
+
get maxStorageBuffersPerShaderStage() { return 0; } // TBD
|
|
20
|
+
get maxStorageTexturesPerShaderStage() { return 0; } // TBD
|
|
21
|
+
get maxUniformBuffersPerShaderStage() { return this.getParameter(GL.MAX_UNIFORM_BUFFER_BINDINGS); }
|
|
22
|
+
get maxUniformBufferBindingSize() { return this.getParameter(GL.MAX_UNIFORM_BLOCK_SIZE); }
|
|
23
|
+
get maxStorageBufferBindingSize() { return 0; }
|
|
24
|
+
get minUniformBufferOffsetAlignment() { return this.getParameter(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT); }
|
|
25
|
+
get minStorageBufferOffsetAlignment() { return 0; }
|
|
26
|
+
get maxVertexBuffers() { return 16; } // WebGL 2 supports 16 buffers, see https://github.com/gpuweb/gpuweb/issues/4284
|
|
27
|
+
get maxVertexAttributes() { return this.getParameter(GL.MAX_VERTEX_ATTRIBS); }
|
|
28
|
+
get maxVertexBufferArrayStride() { return 2048; } // TBD, this is just the default value from WebGPU
|
|
29
|
+
get maxInterStageShaderComponents() { return this.getParameter(GL.MAX_VARYING_COMPONENTS); }
|
|
30
|
+
get maxComputeWorkgroupStorageSize() { return 0; } // WebGL does not support compute shaders
|
|
31
|
+
get maxComputeInvocationsPerWorkgroup() { return 0; } // WebGL does not support compute shaders
|
|
32
|
+
get maxComputeWorkgroupSizeX() { return 0; } // WebGL does not support compute shaders
|
|
33
|
+
get maxComputeWorkgroupSizeY() { return 0; } // WebGL does not support compute shaders
|
|
34
|
+
get maxComputeWorkgroupSizeZ() { return 0; } // WebGL does not support compute shaders
|
|
35
|
+
get maxComputeWorkgroupsPerDimension() { return 0;} // WebGL does not support compute shaders
|
|
36
|
+
|
|
37
|
+
// PRIVATE
|
|
38
|
+
|
|
39
|
+
protected gl: WebGL2RenderingContext;
|
|
40
|
+
protected limits: Partial<Record<GL, number>> = {};
|
|
41
|
+
|
|
42
|
+
constructor(gl: WebGL2RenderingContext) {
|
|
43
|
+
super();
|
|
44
|
+
this.gl = gl;
|
|
98
45
|
}
|
|
99
|
-
// function getMaxAnistropy() {
|
|
100
|
-
// const extension = gl.getExtension('EXT_texture_filter_anisotropic');
|
|
101
|
-
// }
|
|
102
|
-
return {
|
|
103
|
-
[GL.ALIASED_LINE_WIDTH_RANGE]: get(GL.ALIASED_LINE_WIDTH_RANGE),
|
|
104
|
-
[GL.ALIASED_POINT_SIZE_RANGE]: get(GL.ALIASED_POINT_SIZE_RANGE),
|
|
105
|
-
[GL.MAX_TEXTURE_SIZE]: get(GL.MAX_TEXTURE_SIZE),
|
|
106
|
-
[GL.MAX_CUBE_MAP_TEXTURE_SIZE]: get(GL.MAX_CUBE_MAP_TEXTURE_SIZE), // GLint
|
|
107
|
-
[GL.MAX_TEXTURE_IMAGE_UNITS]: get(GL.MAX_TEXTURE_IMAGE_UNITS), // GLint
|
|
108
|
-
[GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS]: get(GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS), // GLint
|
|
109
|
-
[GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS]: get(GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS), // GLint
|
|
110
|
-
[GL.MAX_RENDERBUFFER_SIZE]: get(GL.MAX_RENDERBUFFER_SIZE), // GLint
|
|
111
|
-
[GL.MAX_VARYING_VECTORS]: get(GL.MAX_VARYING_VECTORS), // GLint
|
|
112
|
-
[GL.MAX_VERTEX_ATTRIBS]: get(GL.MAX_VERTEX_ATTRIBS), // GLint
|
|
113
|
-
[GL.MAX_VERTEX_UNIFORM_VECTORS]: get(GL.MAX_VERTEX_UNIFORM_VECTORS), // GLint
|
|
114
|
-
[GL.MAX_FRAGMENT_UNIFORM_VECTORS]: get(GL.MAX_FRAGMENT_UNIFORM_VECTORS), // GLint
|
|
115
|
-
[GL.MAX_VIEWPORT_DIMS]: get(GL.MAX_VIEWPORT_DIMS),
|
|
116
46
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
[
|
|
122
|
-
|
|
123
|
-
// [GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: get2(GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL), // GLint64
|
|
124
|
-
[GL.MAX_COLOR_ATTACHMENTS]: get2(GL.MAX_COLOR_ATTACHMENTS), // GLint
|
|
125
|
-
[GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: get2(
|
|
126
|
-
GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS
|
|
127
|
-
), // GLint64
|
|
128
|
-
[GL.MAX_COMBINED_UNIFORM_BLOCKS]: get2(GL.MAX_COMBINED_UNIFORM_BLOCKS), // GLint
|
|
129
|
-
[GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: get2(GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS), // GLint64
|
|
130
|
-
[GL.MAX_DRAW_BUFFERS]: get2(GL.MAX_DRAW_BUFFERS), // GLint
|
|
131
|
-
[GL.MAX_ELEMENT_INDEX]: get2(GL.MAX_ELEMENT_INDEX), // GLint64
|
|
132
|
-
[GL.MAX_ELEMENTS_INDICES]: get2(GL.MAX_ELEMENTS_INDICES), // GLint
|
|
133
|
-
[GL.MAX_ELEMENTS_VERTICES]: get2(GL.MAX_ELEMENTS_VERTICES), // GLint
|
|
134
|
-
[GL.MAX_FRAGMENT_INPUT_COMPONENTS]: get2(GL.MAX_FRAGMENT_INPUT_COMPONENTS), // GLint
|
|
135
|
-
[GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: get2(GL.MAX_FRAGMENT_UNIFORM_BLOCKS), // GLint
|
|
136
|
-
[GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: get2(GL.MAX_FRAGMENT_UNIFORM_COMPONENTS), // GLint
|
|
137
|
-
[GL.MAX_SAMPLES]: get2(GL.MAX_SAMPLES), // GLint
|
|
138
|
-
// [GL.MAX_SERVER_WAIT_TIMEOUT]: get2(GL.MAX_SERVER_WAIT_TIMEOUT), // GLint64
|
|
139
|
-
[GL.MAX_TEXTURE_LOD_BIAS]: get2(GL.MAX_TEXTURE_LOD_BIAS), // GLfloat
|
|
140
|
-
[GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: get2(
|
|
141
|
-
GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS
|
|
142
|
-
), // GLint
|
|
143
|
-
[GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: get2(GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS), // GLint
|
|
144
|
-
[GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: get2(
|
|
145
|
-
GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS
|
|
146
|
-
), // GLint
|
|
147
|
-
[GL.MAX_UNIFORM_BLOCK_SIZE]: get2(GL.MAX_UNIFORM_BLOCK_SIZE), // GLint64
|
|
148
|
-
[GL.MAX_UNIFORM_BUFFER_BINDINGS]: get2(GL.MAX_UNIFORM_BUFFER_BINDINGS), // GLint
|
|
149
|
-
[GL.MAX_VARYING_COMPONENTS]: get2(GL.MAX_VARYING_COMPONENTS), // GLint
|
|
150
|
-
[GL.MAX_VERTEX_OUTPUT_COMPONENTS]: get2(GL.MAX_VERTEX_OUTPUT_COMPONENTS), // GLint
|
|
151
|
-
[GL.MAX_VERTEX_UNIFORM_BLOCKS]: get2(GL.MAX_VERTEX_UNIFORM_BLOCKS), // GLint
|
|
152
|
-
[GL.MAX_VERTEX_UNIFORM_COMPONENTS]: get2(GL.MAX_VERTEX_UNIFORM_COMPONENTS), // GLint
|
|
153
|
-
[GL.MIN_PROGRAM_TEXEL_OFFSET]: get2(GL.MIN_PROGRAM_TEXEL_OFFSET), // GLint
|
|
154
|
-
[GL.MAX_PROGRAM_TEXEL_OFFSET]: get2(GL.MAX_PROGRAM_TEXEL_OFFSET), // GLint
|
|
155
|
-
[GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: get2(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT) // GLint
|
|
156
|
-
};
|
|
47
|
+
protected getParameter(parameter: GL): number {
|
|
48
|
+
if (this.limits[parameter] === undefined) {
|
|
49
|
+
this.limits[parameter] = this.gl.getParameter(parameter);
|
|
50
|
+
}
|
|
51
|
+
return this.limits[parameter];
|
|
52
|
+
}
|
|
157
53
|
}
|
|
@@ -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 {ShaderUniformType, ShaderAttributeType, VertexFormat} from '@luma.gl/core';
|
|
@@ -67,9 +68,11 @@ const COMPOSITE_GL_TYPES: Record<
|
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
/** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
|
|
70
|
-
export function decodeGLUniformType(
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
export function decodeGLUniformType(glUniformType: GL): {
|
|
72
|
+
format: ShaderUniformType;
|
|
73
|
+
components: number;
|
|
74
|
+
glType: GLDataType;
|
|
75
|
+
} {
|
|
73
76
|
const typeAndSize = COMPOSITE_GL_TYPES[glUniformType];
|
|
74
77
|
if (!typeAndSize) {
|
|
75
78
|
throw new Error('uniform');
|
|
@@ -87,11 +90,11 @@ export function decodeGLAttributeType(glAttributeType: GL): {
|
|
|
87
90
|
} {
|
|
88
91
|
const typeAndSize = COMPOSITE_GL_TYPES[glAttributeType];
|
|
89
92
|
if (!typeAndSize) {
|
|
90
|
-
throw new Error('attribute')
|
|
93
|
+
throw new Error('attribute');
|
|
91
94
|
}
|
|
92
95
|
const [, components, , shaderType, vertexFormat] = typeAndSize;
|
|
93
96
|
// TODO sanity - if (shaderType.startsWith('mat' ...))
|
|
94
|
-
const attributeType = shaderType as unknown as ShaderAttributeType
|
|
97
|
+
const attributeType = shaderType as unknown as ShaderAttributeType;
|
|
95
98
|
return {attributeType, vertexFormat, components}; // , glType};
|
|
96
99
|
}
|
|
97
100
|
|
|
@@ -107,7 +110,10 @@ export function decomposeCompositeGLDataType(
|
|
|
107
110
|
return {type, components};
|
|
108
111
|
}
|
|
109
112
|
|
|
110
|
-
export function getCompositeGLDataType(
|
|
113
|
+
export function getCompositeGLDataType(
|
|
114
|
+
type: GL,
|
|
115
|
+
components
|
|
116
|
+
): {glType: GLDataType; name: string} | null {
|
|
111
117
|
switch (type) {
|
|
112
118
|
case GL.BYTE:
|
|
113
119
|
case GL.UNSIGNED_BYTE:
|
|
@@ -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 type {
|
|
@@ -105,7 +106,7 @@ function readAttributeDeclarations(
|
|
|
105
106
|
if (location >= 0) {
|
|
106
107
|
const {attributeType} = decodeGLAttributeType(compositeType);
|
|
107
108
|
|
|
108
|
-
// Whether an attribute is instanced is essentially fixed by the structure of the shader code,
|
|
109
|
+
// Whether an attribute is instanced is essentially fixed by the structure of the shader code,
|
|
109
110
|
// so it is arguably a static property of the shader.
|
|
110
111
|
// There is no hint in the shader declarations
|
|
111
112
|
// Heuristic: Any attribute name containing the word "instance" will be assumed to be instanced
|
|
@@ -115,7 +116,7 @@ function readAttributeDeclarations(
|
|
|
115
116
|
name,
|
|
116
117
|
location,
|
|
117
118
|
stepMode,
|
|
118
|
-
type: attributeType
|
|
119
|
+
type: attributeType
|
|
119
120
|
// size - for arrays, size is the number of elements in the array
|
|
120
121
|
});
|
|
121
122
|
}
|
|
@@ -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 type {CompilerMessage} from '@luma.gl/core';
|
|
@@ -8,7 +9,7 @@ import type {CompilerMessage} from '@luma.gl/core';
|
|
|
8
9
|
* This follows documented WebGL conventions for compilation logs.
|
|
9
10
|
* Based on https://github.com/wwwtyro/gl-format-compiler-error (public domain)
|
|
10
11
|
*/
|
|
11
|
-
export function parseShaderCompilerLog(errLog: string)
|
|
12
|
+
export function parseShaderCompilerLog(errLog: string): readonly CompilerMessage[] {
|
|
12
13
|
// Parse the error - note: browser and driver dependent
|
|
13
14
|
const lines = errLog.split(/\r?\n/);
|
|
14
15
|
|
|
@@ -30,7 +31,7 @@ export function parseShaderCompilerLog(errLog: string) : readonly CompilerMessag
|
|
|
30
31
|
lineNum: 0,
|
|
31
32
|
linePos: 0
|
|
32
33
|
});
|
|
33
|
-
continue; // eslint-disable-line no-continue
|
|
34
|
+
continue; // eslint-disable-line no-continue
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
const [messageType, linePosition, lineNumber, ...rest] = segments;
|
|
@@ -50,15 +51,18 @@ export function parseShaderCompilerLog(errLog: string) : readonly CompilerMessag
|
|
|
50
51
|
type: getMessageType(messageType),
|
|
51
52
|
lineNum,
|
|
52
53
|
linePos // TODO
|
|
53
|
-
})
|
|
54
|
+
});
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
return messages;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
/** Ensure supported type */
|
|
60
|
-
function getMessageType(messageType: string): 'warning' | 'error' | 'info' {
|
|
61
|
+
function getMessageType(messageType: string): 'warning' | 'error' | 'info' {
|
|
61
62
|
const MESSAGE_TYPES = ['warning', 'error', 'info'];
|
|
62
63
|
const lowerCaseType = messageType.toLowerCase();
|
|
63
|
-
return (MESSAGE_TYPES.includes(lowerCaseType) ? lowerCaseType : 'info') as
|
|
64
|
+
return (MESSAGE_TYPES.includes(lowerCaseType) ? lowerCaseType : 'info') as
|
|
65
|
+
| 'warning'
|
|
66
|
+
| 'error'
|
|
67
|
+
| 'info';
|
|
64
68
|
}
|
|
@@ -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 {GL, GLPrimitiveTopology, GLPrimitive} from '@luma.gl/constants';
|
|
@@ -27,7 +28,10 @@ export function getPrimitiveDrawMode(drawMode: GLPrimitiveTopology): GLPrimitive
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
// Counts the number of complete "primitives" given a number of vertices and a drawMode
|
|
30
|
-
export function getPrimitiveCount(options: {
|
|
31
|
+
export function getPrimitiveCount(options: {
|
|
32
|
+
drawMode: GLPrimitiveTopology;
|
|
33
|
+
vertexCount: number;
|
|
34
|
+
}): number {
|
|
31
35
|
const {drawMode, vertexCount} = options;
|
|
32
36
|
switch (drawMode) {
|
|
33
37
|
case GL.POINTS:
|
|
@@ -48,7 +52,10 @@ export function getPrimitiveCount(options: {drawMode: GLPrimitiveTopology, verte
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
// Counts the number of vertices after splitting the vertex stream into separate "primitives"
|
|
51
|
-
export function getVertexCount(options: {
|
|
55
|
+
export function getVertexCount(options: {
|
|
56
|
+
drawMode: GLPrimitiveTopology;
|
|
57
|
+
vertexCount: number;
|
|
58
|
+
}): number {
|
|
52
59
|
const {drawMode, vertexCount} = options;
|
|
53
60
|
const primitiveCount = getPrimitiveCount({drawMode, vertexCount});
|
|
54
61
|
switch (getPrimitiveDrawMode(drawMode)) {
|