@luma.gl/webgl 9.0.0-beta.4 → 9.0.0-beta.5
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.js +240 -158
- package/dist/adapter/converters/sampler-parameters.d.ts +0 -4
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +73 -68
- package/dist/adapter/converters/shader-formats.js +33 -46
- package/dist/adapter/converters/texture-formats.d.ts +9 -18
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +454 -871
- package/dist/adapter/converters/vertex-formats.js +52 -61
- package/dist/adapter/device-helpers/device-features.d.ts +2 -5
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +56 -87
- package/dist/adapter/device-helpers/device-limits.d.ts +2 -4
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +88 -83
- package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +79 -63
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +6 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.js +52 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +4 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js +87 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +50 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js +92 -0
- package/dist/adapter/helpers/decode-webgl-types.js +87 -76
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +261 -226
- package/dist/adapter/helpers/parse-shader-compiler-log.js +46 -37
- package/dist/adapter/helpers/set-uniform.d.ts +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +67 -82
- package/dist/adapter/helpers/webgl-topology-utils.js +77 -93
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +18 -12
- package/dist/adapter/objects/webgl-renderbuffer.js +76 -80
- package/dist/adapter/objects/webgl-resource.d.ts +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +204 -154
- package/dist/adapter/resources/webgl-buffer.d.ts +2 -3
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +160 -119
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +268 -171
- package/dist/adapter/resources/webgl-command-encoder.js +32 -40
- package/dist/adapter/resources/webgl-external-texture.js +92 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +167 -139
- package/dist/adapter/resources/webgl-render-pass.js +121 -95
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +11 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +378 -228
- package/dist/adapter/resources/webgl-sampler.d.ts +0 -2
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +43 -34
- package/dist/adapter/resources/webgl-shader.d.ts +10 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +106 -45
- package/dist/adapter/resources/webgl-texture.d.ts +2 -6
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +614 -699
- 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 +143 -145
- package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +229 -158
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +58 -37
- package/dist/adapter/webgl-device.d.ts +7 -15
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +440 -381
- package/dist/classic/accessor.js +132 -102
- package/dist/classic/clear.d.ts +2 -2
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +73 -73
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +176 -177
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.js +38 -32
- package/dist/classic/typed-array-utils.js +95 -81
- package/dist/context/{polyfill → context}/context-data.d.ts +2 -1
- package/dist/context/context/context-data.d.ts.map +1 -0
- package/dist/context/context/context-data.js +33 -0
- package/dist/context/context/create-browser-context.d.ts +1 -6
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js +62 -49
- package/dist/context/debug/spector.js +54 -50
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -2
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +102 -76
- package/dist/context/parameters/unified-parameter-api.d.ts +3 -3
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +95 -46
- package/dist/context/parameters/webgl-parameter-tables.d.ts +110 -99
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +456 -404
- package/dist/context/state-tracker/deep-array-equal.js +18 -14
- package/dist/context/state-tracker/track-context-state.d.ts +4 -4
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +190 -126
- 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 +45 -29
- package/dist/dist.dev.js +2568 -3786
- package/dist/index.cjs +1346 -2464
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -26
- package/dist/types.js +2 -1
- package/dist.min.js +9 -42
- package/package.json +11 -15
- package/src/adapter/converters/device-parameters.ts +0 -1
- package/src/adapter/converters/sampler-parameters.ts +0 -17
- package/src/adapter/converters/texture-formats.ts +86 -154
- package/src/adapter/device-helpers/webgl-device-features.ts +69 -0
- package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +3 -4
- package/src/adapter/device-helpers/{device-limits.ts → webgl-device-limits.ts} +25 -23
- package/src/adapter/helpers/get-shader-layout.ts +17 -28
- package/src/adapter/helpers/set-uniform.ts +1 -3
- package/src/adapter/objects/constants-to-keys.ts +1 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +4 -4
- package/src/adapter/objects/webgl-resource.ts +3 -18
- package/src/adapter/resources/webgl-buffer.ts +6 -11
- package/src/adapter/resources/webgl-command-buffer.ts +20 -30
- package/src/adapter/resources/webgl-external-texture.ts +2 -3
- package/src/adapter/resources/webgl-framebuffer.ts +4 -5
- package/src/adapter/resources/webgl-render-pass.ts +7 -7
- package/src/adapter/resources/webgl-render-pipeline.ts +106 -31
- package/src/adapter/resources/webgl-sampler.ts +5 -9
- package/src/adapter/resources/webgl-shader.ts +57 -10
- package/src/adapter/resources/webgl-texture.ts +29 -103
- package/src/adapter/resources/webgl-transform-feedback.ts +14 -15
- package/src/adapter/resources/webgl-vertex-array.ts +16 -18
- package/src/adapter/webgl-canvas-context.ts +1 -7
- package/src/adapter/webgl-device.ts +18 -67
- package/src/classic/clear.ts +13 -14
- package/src/classic/copy-and-blit.ts +1 -2
- package/src/context/context/context-data.ts +44 -0
- package/src/context/context/create-browser-context.ts +7 -32
- package/src/context/debug/webgl-developer-tools.ts +6 -8
- package/src/context/parameters/unified-parameter-api.ts +3 -3
- package/src/context/parameters/webgl-parameter-tables.ts +66 -75
- package/src/context/state-tracker/track-context-state.ts +18 -17
- package/src/context/state-tracker/with-parameters.ts +1 -1
- package/src/index.ts +2 -17
- package/dist/adapter/converters/device-parameters.js.map +0 -1
- package/dist/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/adapter/converters/shader-formats.js.map +0 -1
- package/dist/adapter/converters/texture-formats.js.map +0 -1
- package/dist/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/adapter/device-helpers/device-features.js.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.d.ts +0 -2
- package/dist/adapter/device-helpers/is-old-ie.d.ts.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.js +0 -9
- package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
- package/dist/adapter/helpers/set-uniform.js.map +0 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +0 -1
- package/dist/adapter/objects/constants-to-keys.js.map +0 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
- package/dist/adapter/objects/webgl-resource.js.map +0 -1
- package/dist/adapter/resources/webgl-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
- package/dist/adapter/resources/webgl-sampler.js.map +0 -1
- package/dist/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/adapter/resources/webgl-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-transform-feedback.js.map +0 -1
- package/dist/adapter/resources/webgl-vertex-array.js.map +0 -1
- package/dist/adapter/webgl-canvas-context.js.map +0 -1
- package/dist/adapter/webgl-device.js.map +0 -1
- package/dist/classic/accessor.js.map +0 -1
- package/dist/classic/clear.js.map +0 -1
- package/dist/classic/copy-and-blit.js.map +0 -1
- package/dist/classic/format-utils.js.map +0 -1
- package/dist/classic/typed-array-utils.js.map +0 -1
- package/dist/context/context/create-browser-context.js.map +0 -1
- package/dist/context/context/create-headless-context.d.ts +0 -9
- package/dist/context/context/create-headless-context.d.ts.map +0 -1
- package/dist/context/context/create-headless-context.js +0 -42
- package/dist/context/context/create-headless-context.js.map +0 -1
- package/dist/context/context/webgl-checks.d.ts +0 -13
- package/dist/context/context/webgl-checks.d.ts.map +0 -1
- package/dist/context/context/webgl-checks.js +0 -31
- package/dist/context/context/webgl-checks.js.map +0 -1
- package/dist/context/debug/spector.js.map +0 -1
- package/dist/context/debug/webgl-developer-tools.js.map +0 -1
- package/dist/context/parameters/unified-parameter-api.js.map +0 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
- package/dist/context/polyfill/context-data.d.ts.map +0 -1
- package/dist/context/polyfill/context-data.js +0 -12
- package/dist/context/polyfill/context-data.js.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.d.ts +0 -2
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +0 -85
- package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
- package/dist/context/polyfill/polyfill-context.d.ts +0 -5
- package/dist/context/polyfill/polyfill-context.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-context.js +0 -87
- package/dist/context/polyfill/polyfill-context.js.map +0 -1
- package/dist/context/polyfill/polyfill-table.d.ts +0 -48
- package/dist/context/polyfill/polyfill-table.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-table.js +0 -137
- package/dist/context/polyfill/polyfill-table.js.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts +0 -2
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -265
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
- package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
- package/dist/context/state-tracker/track-context-state.js.map +0 -1
- package/dist/context/state-tracker/with-parameters.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/adapter/device-helpers/device-features.ts +0 -161
- package/src/adapter/device-helpers/is-old-ie.ts +0 -14
- package/src/context/context/create-headless-context.ts +0 -51
- package/src/context/context/webgl-checks.ts +0 -51
- package/src/context/polyfill/context-data.ts +0 -30
- package/src/context/polyfill/get-parameter-polyfill.ts +0 -122
- package/src/context/polyfill/polyfill-context.ts +0 -104
- package/src/context/polyfill/polyfill-table.ts +0 -167
- package/src/context/polyfill/polyfill-vertex-array-object.ts +0 -365
|
@@ -1,71 +1,87 @@
|
|
|
1
|
-
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
|
+
/** @returns strings identifying the GPU vendor and driver. */
|
|
2
5
|
export function getDeviceInfo(gl) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
// "Masked" info is always available, but don't contain much useful information
|
|
7
|
+
const vendorMasked = gl.getParameter(GL.VENDOR);
|
|
8
|
+
const rendererMasked = gl.getParameter(GL.RENDERER);
|
|
9
|
+
// If we are lucky, unmasked info is available
|
|
10
|
+
// https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/
|
|
11
|
+
const ext = gl.getExtension('WEBGL_debug_renderer_info');
|
|
12
|
+
const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : GL.VENDOR);
|
|
13
|
+
const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : GL.RENDERER);
|
|
14
|
+
const vendor = vendorUnmasked || vendorMasked;
|
|
15
|
+
const renderer = rendererUnmasked || rendererMasked;
|
|
16
|
+
// Driver version
|
|
17
|
+
const version = gl.getParameter(GL.VERSION);
|
|
18
|
+
// "Sniff" the GPU type and backend from the info. This works best if unmasked info is available.
|
|
19
|
+
const gpu = identifyGPUVendor(vendor, renderer);
|
|
20
|
+
const gpuBackend = identifyGPUBackend(vendor, renderer);
|
|
21
|
+
const gpuType = identifyGPUType(vendor, renderer);
|
|
22
|
+
// Determine GLSL version
|
|
23
|
+
// For now, skip parsing of the long version string, just use context type below to deduce version
|
|
24
|
+
// const version = gl.getParameter(GL.SHADING_LANGUAGE_VERSION) as string;
|
|
25
|
+
// const shadingLanguageVersion = parseGLSLVersion(version);
|
|
26
|
+
const shadingLanguage = 'glsl';
|
|
27
|
+
const shadingLanguageVersion = 300;
|
|
28
|
+
return {
|
|
29
|
+
type: 'webgl',
|
|
30
|
+
gpu,
|
|
31
|
+
gpuType,
|
|
32
|
+
gpuBackend,
|
|
33
|
+
vendor,
|
|
34
|
+
renderer,
|
|
35
|
+
version,
|
|
36
|
+
shadingLanguage,
|
|
37
|
+
shadingLanguageVersion
|
|
38
|
+
};
|
|
27
39
|
}
|
|
40
|
+
/** "Sniff" the GPU type from the info. This works best if unmasked info is available. */
|
|
28
41
|
function identifyGPUVendor(vendor, renderer) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
if ((/NVIDIA/i.exec(vendor)) || (/NVIDIA/i.exec(renderer))) {
|
|
43
|
+
return 'nvidia';
|
|
44
|
+
}
|
|
45
|
+
if ((/INTEL/i.exec(vendor)) || (/INTEL/i.exec(renderer))) {
|
|
46
|
+
return 'intel';
|
|
47
|
+
}
|
|
48
|
+
if ((/Apple/i.exec(vendor)) || (/Apple/i.exec(renderer))) {
|
|
49
|
+
return 'apple';
|
|
50
|
+
}
|
|
51
|
+
if ((/AMD/i.exec(vendor)) ||
|
|
52
|
+
(/AMD/i.exec(renderer)) ||
|
|
53
|
+
(/ATI/i.exec(vendor)) ||
|
|
54
|
+
(/ATI/i.exec(renderer))) {
|
|
55
|
+
return 'amd';
|
|
56
|
+
}
|
|
57
|
+
if ((/SwiftShader/i.exec(vendor)) || (/SwiftShader/i.exec(renderer))) {
|
|
58
|
+
return 'software';
|
|
59
|
+
}
|
|
60
|
+
return 'unknown';
|
|
45
61
|
}
|
|
62
|
+
/** "Sniff" the GPU backend from the info. This works best if unmasked info is available. */
|
|
46
63
|
function identifyGPUBackend(vendor, renderer) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
if ((/Metal/i.exec(vendor)) || (/Metal/i.exec(renderer))) {
|
|
65
|
+
return 'metal';
|
|
66
|
+
}
|
|
67
|
+
if ((/ANGLE/i.exec(vendor)) || (/ANGLE/i.exec(renderer))) {
|
|
68
|
+
return 'opengl';
|
|
69
|
+
}
|
|
70
|
+
return 'unknown';
|
|
54
71
|
}
|
|
55
72
|
function identifyGPUType(vendor, renderer) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
if ((/SwiftShader/i.exec(vendor)) || (/SwiftShader/i.exec(renderer))) {
|
|
74
|
+
return 'cpu';
|
|
75
|
+
}
|
|
76
|
+
const gpuVendor = identifyGPUVendor(vendor, renderer);
|
|
77
|
+
switch (gpuVendor) {
|
|
78
|
+
case 'intel':
|
|
79
|
+
return 'integrated';
|
|
80
|
+
case 'software':
|
|
81
|
+
return 'cpu';
|
|
82
|
+
case 'unknown':
|
|
83
|
+
return 'unknown';
|
|
84
|
+
default:
|
|
85
|
+
return 'discrete';
|
|
86
|
+
}
|
|
70
87
|
}
|
|
71
|
-
//# sourceMappingURL=get-device-info.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeviceFeature } from '@luma.gl/core';
|
|
2
|
+
/** Get WebGPU style feature strings */
|
|
3
|
+
export declare function getDeviceFeatures(gl: WebGL2RenderingContext): Set<DeviceFeature>;
|
|
4
|
+
/** Extract all WebGL features */
|
|
5
|
+
export declare function getWebGLFeatures(gl: WebGL2RenderingContext): Set<DeviceFeature>;
|
|
6
|
+
//# sourceMappingURL=webgl-device-features.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-device-features.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/webgl-device-features.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAG5C,uCAAuC;AACvC,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,sBAAsB,GAAG,GAAG,CAAC,aAAa,CAAC,CAiBhF;AAED,iCAAiC;AACjC,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,sBAAsB,GAAG,GAAG,CAAC,aAAa,CAAC,CAW/E"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { getTextureFeatures } from '../converters/texture-formats';
|
|
4
|
+
/** Get WebGPU style feature strings */
|
|
5
|
+
export function getDeviceFeatures(gl) {
|
|
6
|
+
const features = getWebGLFeatures(gl);
|
|
7
|
+
// texture features
|
|
8
|
+
// features.add('texture-compression-bc');
|
|
9
|
+
for (const textureFeature of getTextureFeatures(gl)) {
|
|
10
|
+
features.add(textureFeature);
|
|
11
|
+
}
|
|
12
|
+
// TODO
|
|
13
|
+
// features.add('depth-clip-control'); // GPUPrimitiveState.clampDepth
|
|
14
|
+
// features.add('depth24unorm-stencil8'); // GPUTextureFormat 'depth24unorm-stencil8'.
|
|
15
|
+
// features.add('depth32float-stencil8'); // GPUTextureFormat 'depth32float-stencil8'.
|
|
16
|
+
// features.add('timestamp-query'); // GPUQueryType "timestamp-query"
|
|
17
|
+
// "indirect-first-instance"
|
|
18
|
+
return features;
|
|
19
|
+
}
|
|
20
|
+
/** Extract all WebGL features */
|
|
21
|
+
export function getWebGLFeatures(gl) {
|
|
22
|
+
// Enable EXT_float_blend first: https://developer.mozilla.org/en-US/docs/Web/API/EXT_float_blend
|
|
23
|
+
gl.getExtension('EXT_color_buffer_float');
|
|
24
|
+
const features = new Set();
|
|
25
|
+
for (const feature of Object.keys(WEBGL_FEATURES)) {
|
|
26
|
+
if (isFeatureSupported(gl, feature)) {
|
|
27
|
+
features.add(feature);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return features;
|
|
31
|
+
}
|
|
32
|
+
function isFeatureSupported(gl, feature) {
|
|
33
|
+
const featureInfo = WEBGL_FEATURES[feature];
|
|
34
|
+
// string value requires checking the corresponding WebGL extension
|
|
35
|
+
return typeof featureInfo === 'string'
|
|
36
|
+
? Boolean(gl.getExtension(featureInfo))
|
|
37
|
+
: Boolean(featureInfo);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Defines luma.gl "feature" names and semantics
|
|
41
|
+
* when value is 'string' it is the name of the extension that enables this feature
|
|
42
|
+
*/
|
|
43
|
+
const WEBGL_FEATURES = {
|
|
44
|
+
webgl: true,
|
|
45
|
+
glsl: true,
|
|
46
|
+
'uniforms-webgl': true,
|
|
47
|
+
'transform-feedback-webgl': true,
|
|
48
|
+
'constant-attributes-webgl': true,
|
|
49
|
+
'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2',
|
|
50
|
+
'shader-status-async-webgl': 'KHR_parallel_shader_compile'
|
|
51
|
+
// Textures are handled by getTextureFeatures()
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-device-info.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/webgl-device-info.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAGzC,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,EAAE,EAAE,sBAAsB,GAAG,UAAU,CAuCpE"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
|
+
/** @returns strings identifying the GPU vendor and driver. */
|
|
5
|
+
export function getDeviceInfo(gl) {
|
|
6
|
+
// "Masked" info is always available, but don't contain much useful information
|
|
7
|
+
const vendorMasked = gl.getParameter(GL.VENDOR);
|
|
8
|
+
const rendererMasked = gl.getParameter(GL.RENDERER);
|
|
9
|
+
// If we are lucky, unmasked info is available
|
|
10
|
+
// https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/
|
|
11
|
+
const ext = gl.getExtension('WEBGL_debug_renderer_info');
|
|
12
|
+
const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : GL.VENDOR);
|
|
13
|
+
const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : GL.RENDERER);
|
|
14
|
+
const vendor = vendorUnmasked || vendorMasked;
|
|
15
|
+
const renderer = rendererUnmasked || rendererMasked;
|
|
16
|
+
// Driver version
|
|
17
|
+
const version = gl.getParameter(GL.VERSION);
|
|
18
|
+
// "Sniff" the GPU type and backend from the info. This works best if unmasked info is available.
|
|
19
|
+
const gpu = identifyGPUVendor(vendor, renderer);
|
|
20
|
+
const gpuBackend = identifyGPUBackend(vendor, renderer);
|
|
21
|
+
const gpuType = identifyGPUType(vendor, renderer);
|
|
22
|
+
// Determine GLSL version
|
|
23
|
+
// For now, skip parsing of the long version string, just use context type below to deduce version
|
|
24
|
+
// const version = gl.getParameter(GL.SHADING_LANGUAGE_VERSION) as string;
|
|
25
|
+
// const shadingLanguageVersion = parseGLSLVersion(version);
|
|
26
|
+
const shadingLanguage = 'glsl';
|
|
27
|
+
const shadingLanguageVersion = 300;
|
|
28
|
+
return {
|
|
29
|
+
type: 'webgl',
|
|
30
|
+
gpu,
|
|
31
|
+
gpuType,
|
|
32
|
+
gpuBackend,
|
|
33
|
+
vendor,
|
|
34
|
+
renderer,
|
|
35
|
+
version,
|
|
36
|
+
shadingLanguage,
|
|
37
|
+
shadingLanguageVersion
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** "Sniff" the GPU type from the info. This works best if unmasked info is available. */
|
|
41
|
+
function identifyGPUVendor(vendor, renderer) {
|
|
42
|
+
if ((/NVIDIA/i.exec(vendor)) || (/NVIDIA/i.exec(renderer))) {
|
|
43
|
+
return 'nvidia';
|
|
44
|
+
}
|
|
45
|
+
if ((/INTEL/i.exec(vendor)) || (/INTEL/i.exec(renderer))) {
|
|
46
|
+
return 'intel';
|
|
47
|
+
}
|
|
48
|
+
if ((/Apple/i.exec(vendor)) || (/Apple/i.exec(renderer))) {
|
|
49
|
+
return 'apple';
|
|
50
|
+
}
|
|
51
|
+
if ((/AMD/i.exec(vendor)) ||
|
|
52
|
+
(/AMD/i.exec(renderer)) ||
|
|
53
|
+
(/ATI/i.exec(vendor)) ||
|
|
54
|
+
(/ATI/i.exec(renderer))) {
|
|
55
|
+
return 'amd';
|
|
56
|
+
}
|
|
57
|
+
if ((/SwiftShader/i.exec(vendor)) || (/SwiftShader/i.exec(renderer))) {
|
|
58
|
+
return 'software';
|
|
59
|
+
}
|
|
60
|
+
return 'unknown';
|
|
61
|
+
}
|
|
62
|
+
/** "Sniff" the GPU backend from the info. This works best if unmasked info is available. */
|
|
63
|
+
function identifyGPUBackend(vendor, renderer) {
|
|
64
|
+
if ((/Metal/i.exec(vendor)) || (/Metal/i.exec(renderer))) {
|
|
65
|
+
return 'metal';
|
|
66
|
+
}
|
|
67
|
+
if ((/ANGLE/i.exec(vendor)) || (/ANGLE/i.exec(renderer))) {
|
|
68
|
+
return 'opengl';
|
|
69
|
+
}
|
|
70
|
+
return 'unknown';
|
|
71
|
+
}
|
|
72
|
+
function identifyGPUType(vendor, renderer) {
|
|
73
|
+
if ((/SwiftShader/i.exec(vendor)) || (/SwiftShader/i.exec(renderer))) {
|
|
74
|
+
return 'cpu';
|
|
75
|
+
}
|
|
76
|
+
const gpuVendor = identifyGPUVendor(vendor, renderer);
|
|
77
|
+
switch (gpuVendor) {
|
|
78
|
+
case 'intel':
|
|
79
|
+
return 'integrated';
|
|
80
|
+
case 'software':
|
|
81
|
+
return 'cpu';
|
|
82
|
+
case 'unknown':
|
|
83
|
+
return 'unknown';
|
|
84
|
+
default:
|
|
85
|
+
return 'discrete';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { DeviceLimits } from '@luma.gl/core';
|
|
2
|
+
import { GL } from '@luma.gl/constants';
|
|
3
|
+
/** Populate a WebGPU style device limits */
|
|
4
|
+
export declare function getDeviceLimits(gl: WebGL2RenderingContext): DeviceLimits;
|
|
5
|
+
/** WebGL context limits */
|
|
6
|
+
export type WebGLLimits = {
|
|
7
|
+
[GL.ALIASED_LINE_WIDTH_RANGE]: [number, number];
|
|
8
|
+
[GL.ALIASED_POINT_SIZE_RANGE]: [number, number];
|
|
9
|
+
[GL.MAX_TEXTURE_SIZE]: number;
|
|
10
|
+
[GL.MAX_CUBE_MAP_TEXTURE_SIZE]: number;
|
|
11
|
+
[GL.MAX_TEXTURE_IMAGE_UNITS]: number;
|
|
12
|
+
[GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS]: number;
|
|
13
|
+
[GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS]: number;
|
|
14
|
+
[GL.MAX_RENDERBUFFER_SIZE]: number;
|
|
15
|
+
[GL.MAX_VARYING_VECTORS]: number;
|
|
16
|
+
[GL.MAX_VERTEX_ATTRIBS]: number;
|
|
17
|
+
[GL.MAX_VERTEX_UNIFORM_VECTORS]: number;
|
|
18
|
+
[GL.MAX_FRAGMENT_UNIFORM_VECTORS]: number;
|
|
19
|
+
[GL.MAX_VIEWPORT_DIMS]: [number, number];
|
|
20
|
+
[GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT]: number;
|
|
21
|
+
[GL.MAX_3D_TEXTURE_SIZE]: number;
|
|
22
|
+
[GL.MAX_ARRAY_TEXTURE_LAYERS]: number;
|
|
23
|
+
[GL.MAX_COLOR_ATTACHMENTS]: number;
|
|
24
|
+
[GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: number;
|
|
25
|
+
[GL.MAX_COMBINED_UNIFORM_BLOCKS]: number;
|
|
26
|
+
[GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: number;
|
|
27
|
+
[GL.MAX_DRAW_BUFFERS]: number;
|
|
28
|
+
[GL.MAX_ELEMENT_INDEX]: number;
|
|
29
|
+
[GL.MAX_ELEMENTS_INDICES]: number;
|
|
30
|
+
[GL.MAX_ELEMENTS_VERTICES]: number;
|
|
31
|
+
[GL.MAX_FRAGMENT_INPUT_COMPONENTS]: number;
|
|
32
|
+
[GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: number;
|
|
33
|
+
[GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: number;
|
|
34
|
+
[GL.MAX_SAMPLES]: number;
|
|
35
|
+
[GL.MAX_TEXTURE_LOD_BIAS]: number;
|
|
36
|
+
[GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: number;
|
|
37
|
+
[GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: number;
|
|
38
|
+
[GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: number;
|
|
39
|
+
[GL.MAX_UNIFORM_BLOCK_SIZE]: number;
|
|
40
|
+
[GL.MAX_UNIFORM_BUFFER_BINDINGS]: number;
|
|
41
|
+
[GL.MAX_VARYING_COMPONENTS]: number;
|
|
42
|
+
[GL.MAX_VERTEX_OUTPUT_COMPONENTS]: number;
|
|
43
|
+
[GL.MAX_VERTEX_UNIFORM_BLOCKS]: number;
|
|
44
|
+
[GL.MAX_VERTEX_UNIFORM_COMPONENTS]: number;
|
|
45
|
+
[GL.MIN_PROGRAM_TEXEL_OFFSET]: number;
|
|
46
|
+
[GL.MAX_PROGRAM_TEXEL_OFFSET]: number;
|
|
47
|
+
[GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: number;
|
|
48
|
+
};
|
|
49
|
+
export declare function getWebGLLimits(gl: WebGL2RenderingContext): WebGLLimits;
|
|
50
|
+
//# sourceMappingURL=webgl-device-limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-device-limits.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/webgl-device-limits.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
|
+
/** Populate a WebGPU style device limits */
|
|
5
|
+
export function getDeviceLimits(gl) {
|
|
6
|
+
return {
|
|
7
|
+
maxTextureDimension1D: 0, // WebGL does not support 1D textures
|
|
8
|
+
maxTextureDimension2D: gl.getParameter(GL.MAX_TEXTURE_SIZE),
|
|
9
|
+
maxTextureDimension3D: gl.getParameter(GL.MAX_3D_TEXTURE_SIZE),
|
|
10
|
+
maxTextureArrayLayers: gl.getParameter(GL.MAX_ARRAY_TEXTURE_LAYERS),
|
|
11
|
+
maxBindGroups: 1, // TBD - if we emulate bind groups we could support any number...
|
|
12
|
+
maxDynamicUniformBuffersPerPipelineLayout: 0, // TBD
|
|
13
|
+
maxDynamicStorageBuffersPerPipelineLayout: 0, // TBD
|
|
14
|
+
maxSampledTexturesPerShaderStage: gl.getParameter(GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS), // TBD
|
|
15
|
+
maxSamplersPerShaderStage: gl.getParameter(GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
|
|
16
|
+
maxStorageBuffersPerShaderStage: 0, // TBD
|
|
17
|
+
maxStorageTexturesPerShaderStage: 0, // TBD
|
|
18
|
+
maxUniformBuffersPerShaderStage: gl.getParameter(GL.MAX_UNIFORM_BUFFER_BINDINGS),
|
|
19
|
+
maxUniformBufferBindingSize: gl.getParameter(GL.MAX_UNIFORM_BLOCK_SIZE),
|
|
20
|
+
maxStorageBufferBindingSize: 0,
|
|
21
|
+
minUniformBufferOffsetAlignment: gl.getParameter(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT),
|
|
22
|
+
minStorageBufferOffsetAlignment: 0, // TBD
|
|
23
|
+
maxVertexBuffers: 0,
|
|
24
|
+
maxVertexAttributes: gl.getParameter(GL.MAX_VERTEX_ATTRIBS),
|
|
25
|
+
maxVertexBufferArrayStride: 2048, // TBD, this is just the default value from WebGPU
|
|
26
|
+
maxInterStageShaderComponents: gl.getParameter(GL.MAX_VARYING_COMPONENTS),
|
|
27
|
+
maxComputeWorkgroupStorageSize: 0, // WebGL does not support compute shaders
|
|
28
|
+
maxComputeInvocationsPerWorkgroup: 0, // WebGL does not support compute shaders
|
|
29
|
+
maxComputeWorkgroupSizeX: 0, // WebGL does not support compute shaders
|
|
30
|
+
maxComputeWorkgroupSizeY: 0, // WebGL does not support compute shaders
|
|
31
|
+
maxComputeWorkgroupSizeZ: 0, // WebGL does not support compute shaders
|
|
32
|
+
maxComputeWorkgroupsPerDimension: 0 // WebGL does not support compute shaders
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function getWebGLLimits(gl) {
|
|
36
|
+
function get(pname) {
|
|
37
|
+
return gl.getParameter(pname);
|
|
38
|
+
}
|
|
39
|
+
function get2(pname, defaultValue) {
|
|
40
|
+
return gl.getParameter(pname) || defaultValue;
|
|
41
|
+
}
|
|
42
|
+
// function getMaxAnistropy() {
|
|
43
|
+
// const extension = gl.getExtension('EXT_texture_filter_anisotropic');
|
|
44
|
+
// }
|
|
45
|
+
return {
|
|
46
|
+
[GL.ALIASED_LINE_WIDTH_RANGE]: get(GL.ALIASED_LINE_WIDTH_RANGE),
|
|
47
|
+
[GL.ALIASED_POINT_SIZE_RANGE]: get(GL.ALIASED_POINT_SIZE_RANGE),
|
|
48
|
+
[GL.MAX_TEXTURE_SIZE]: get(GL.MAX_TEXTURE_SIZE),
|
|
49
|
+
[GL.MAX_CUBE_MAP_TEXTURE_SIZE]: get(GL.MAX_CUBE_MAP_TEXTURE_SIZE), // GLint
|
|
50
|
+
[GL.MAX_TEXTURE_IMAGE_UNITS]: get(GL.MAX_TEXTURE_IMAGE_UNITS), // GLint
|
|
51
|
+
[GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS]: get(GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS), // GLint
|
|
52
|
+
[GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS]: get(GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS), // GLint
|
|
53
|
+
[GL.MAX_RENDERBUFFER_SIZE]: get(GL.MAX_RENDERBUFFER_SIZE), // GLint
|
|
54
|
+
[GL.MAX_VARYING_VECTORS]: get(GL.MAX_VARYING_VECTORS), // GLint
|
|
55
|
+
[GL.MAX_VERTEX_ATTRIBS]: get(GL.MAX_VERTEX_ATTRIBS), // GLint
|
|
56
|
+
[GL.MAX_VERTEX_UNIFORM_VECTORS]: get(GL.MAX_VERTEX_UNIFORM_VECTORS), // GLint
|
|
57
|
+
[GL.MAX_FRAGMENT_UNIFORM_VECTORS]: get(GL.MAX_FRAGMENT_UNIFORM_VECTORS), // GLint
|
|
58
|
+
[GL.MAX_VIEWPORT_DIMS]: get(GL.MAX_VIEWPORT_DIMS),
|
|
59
|
+
// Extensions
|
|
60
|
+
[GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT]: get(GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT), // getMaxAnistropy(),
|
|
61
|
+
// WebGL2 Limits
|
|
62
|
+
[GL.MAX_3D_TEXTURE_SIZE]: get2(GL.MAX_3D_TEXTURE_SIZE), // GLint
|
|
63
|
+
[GL.MAX_ARRAY_TEXTURE_LAYERS]: get2(GL.MAX_ARRAY_TEXTURE_LAYERS), // GLint
|
|
64
|
+
// [GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: get2(GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL), // GLint64
|
|
65
|
+
[GL.MAX_COLOR_ATTACHMENTS]: get2(GL.MAX_COLOR_ATTACHMENTS), // GLint
|
|
66
|
+
[GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: get2(GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS), // GLint64
|
|
67
|
+
[GL.MAX_COMBINED_UNIFORM_BLOCKS]: get2(GL.MAX_COMBINED_UNIFORM_BLOCKS), // GLint
|
|
68
|
+
[GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: get2(GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS), // GLint64
|
|
69
|
+
[GL.MAX_DRAW_BUFFERS]: get2(GL.MAX_DRAW_BUFFERS), // GLint
|
|
70
|
+
[GL.MAX_ELEMENT_INDEX]: get2(GL.MAX_ELEMENT_INDEX), // GLint64
|
|
71
|
+
[GL.MAX_ELEMENTS_INDICES]: get2(GL.MAX_ELEMENTS_INDICES), // GLint
|
|
72
|
+
[GL.MAX_ELEMENTS_VERTICES]: get2(GL.MAX_ELEMENTS_VERTICES), // GLint
|
|
73
|
+
[GL.MAX_FRAGMENT_INPUT_COMPONENTS]: get2(GL.MAX_FRAGMENT_INPUT_COMPONENTS), // GLint
|
|
74
|
+
[GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: get2(GL.MAX_FRAGMENT_UNIFORM_BLOCKS), // GLint
|
|
75
|
+
[GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: get2(GL.MAX_FRAGMENT_UNIFORM_COMPONENTS), // GLint
|
|
76
|
+
[GL.MAX_SAMPLES]: get2(GL.MAX_SAMPLES), // GLint
|
|
77
|
+
// [GL.MAX_SERVER_WAIT_TIMEOUT]: get2(GL.MAX_SERVER_WAIT_TIMEOUT), // GLint64
|
|
78
|
+
[GL.MAX_TEXTURE_LOD_BIAS]: get2(GL.MAX_TEXTURE_LOD_BIAS), // GLfloat
|
|
79
|
+
[GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: get2(GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS), // GLint
|
|
80
|
+
[GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: get2(GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS), // GLint
|
|
81
|
+
[GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: get2(GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS), // GLint
|
|
82
|
+
[GL.MAX_UNIFORM_BLOCK_SIZE]: get2(GL.MAX_UNIFORM_BLOCK_SIZE), // GLint64
|
|
83
|
+
[GL.MAX_UNIFORM_BUFFER_BINDINGS]: get2(GL.MAX_UNIFORM_BUFFER_BINDINGS), // GLint
|
|
84
|
+
[GL.MAX_VARYING_COMPONENTS]: get2(GL.MAX_VARYING_COMPONENTS), // GLint
|
|
85
|
+
[GL.MAX_VERTEX_OUTPUT_COMPONENTS]: get2(GL.MAX_VERTEX_OUTPUT_COMPONENTS), // GLint
|
|
86
|
+
[GL.MAX_VERTEX_UNIFORM_BLOCKS]: get2(GL.MAX_VERTEX_UNIFORM_BLOCKS), // GLint
|
|
87
|
+
[GL.MAX_VERTEX_UNIFORM_COMPONENTS]: get2(GL.MAX_VERTEX_UNIFORM_COMPONENTS), // GLint
|
|
88
|
+
[GL.MIN_PROGRAM_TEXEL_OFFSET]: get2(GL.MIN_PROGRAM_TEXEL_OFFSET), // GLint
|
|
89
|
+
[GL.MAX_PROGRAM_TEXEL_OFFSET]: get2(GL.MAX_PROGRAM_TEXEL_OFFSET), // GLint
|
|
90
|
+
[GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: get2(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT) // GLint
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -1,89 +1,100 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
|
+
/** Check is uniform is of sampler type */
|
|
1
5
|
export function isSamplerUniform(type) {
|
|
2
|
-
|
|
6
|
+
return SAMPLER_TYPES.includes(type);
|
|
3
7
|
}
|
|
4
|
-
const SAMPLER_TYPES = [
|
|
8
|
+
const SAMPLER_TYPES = [
|
|
9
|
+
GL.SAMPLER_2D,
|
|
10
|
+
GL.SAMPLER_CUBE,
|
|
11
|
+
GL.SAMPLER_3D,
|
|
12
|
+
GL.SAMPLER_2D_SHADOW,
|
|
13
|
+
GL.SAMPLER_2D_ARRAY,
|
|
14
|
+
GL.SAMPLER_2D_ARRAY_SHADOW,
|
|
15
|
+
GL.SAMPLER_CUBE_SHADOW,
|
|
16
|
+
GL.INT_SAMPLER_2D,
|
|
17
|
+
GL.INT_SAMPLER_3D,
|
|
18
|
+
GL.INT_SAMPLER_CUBE,
|
|
19
|
+
GL.INT_SAMPLER_2D_ARRAY,
|
|
20
|
+
GL.UNSIGNED_INT_SAMPLER_2D,
|
|
21
|
+
GL.UNSIGNED_INT_SAMPLER_3D,
|
|
22
|
+
GL.UNSIGNED_INT_SAMPLER_CUBE,
|
|
23
|
+
GL.UNSIGNED_INT_SAMPLER_2D_ARRAY
|
|
24
|
+
];
|
|
25
|
+
// Composite types table
|
|
5
26
|
const COMPOSITE_GL_TYPES = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
[GL.FLOAT]: [GL.FLOAT, 1, 'float', 'f32', 'float32'],
|
|
28
|
+
[GL.FLOAT_VEC2]: [GL.FLOAT, 2, 'vec2', 'vec2<f32>', 'float32x2'],
|
|
29
|
+
[GL.FLOAT_VEC3]: [GL.FLOAT, 3, 'vec3', 'vec3<f32>', 'float32x3'],
|
|
30
|
+
[GL.FLOAT_VEC4]: [GL.FLOAT, 4, 'vec4', 'vec4<f32>', 'float32x4'],
|
|
31
|
+
[GL.INT]: [GL.INT, 1, 'int', 'i32', 'sint32'],
|
|
32
|
+
[GL.INT_VEC2]: [GL.INT, 2, 'ivec2', 'vec2<i32>', 'sint32x2'],
|
|
33
|
+
[GL.INT_VEC3]: [GL.INT, 3, 'ivec3', 'vec3<i32>', 'sint32x3'],
|
|
34
|
+
[GL.INT_VEC4]: [GL.INT, 4, 'ivec4', 'vec4<i32>', 'sint32x4'],
|
|
35
|
+
[GL.UNSIGNED_INT]: [GL.UNSIGNED_INT, 1, 'uint', 'u32', 'uint32'],
|
|
36
|
+
[GL.UNSIGNED_INT_VEC2]: [GL.UNSIGNED_INT, 2, 'uvec2', 'vec2<u32>', 'uint32x2'],
|
|
37
|
+
[GL.UNSIGNED_INT_VEC3]: [GL.UNSIGNED_INT, 3, 'uvec3', 'vec3<u32>', 'uint32x3'],
|
|
38
|
+
[GL.UNSIGNED_INT_VEC4]: [GL.UNSIGNED_INT, 4, 'uvec4', 'vec4<u32>', 'uint32x4'],
|
|
39
|
+
[GL.BOOL]: [GL.FLOAT, 1, 'bool', 'f32', 'float32'],
|
|
40
|
+
[GL.BOOL_VEC2]: [GL.FLOAT, 2, 'bvec2', 'vec2<f32>', 'float32x2'],
|
|
41
|
+
[GL.BOOL_VEC3]: [GL.FLOAT, 3, 'bvec3', 'vec3<f32>', 'float32x3'],
|
|
42
|
+
[GL.BOOL_VEC4]: [GL.FLOAT, 4, 'bvec4', 'vec4<f32>', 'float32x4'],
|
|
43
|
+
// TODO - are sizes/components below correct?
|
|
44
|
+
[GL.FLOAT_MAT2]: [GL.FLOAT, 8, 'mat2', 'mat2x2<f32>'], // 4
|
|
45
|
+
[GL.FLOAT_MAT2x3]: [GL.FLOAT, 8, 'mat2x3', 'mat2x3<f32>'], // 6
|
|
46
|
+
[GL.FLOAT_MAT2x4]: [GL.FLOAT, 8, 'mat2x4', 'mat2x4<f32>'], // 8
|
|
47
|
+
[GL.FLOAT_MAT3x2]: [GL.FLOAT, 12, 'mat3x2', 'mat3x2<f32>'], // 6
|
|
48
|
+
[GL.FLOAT_MAT3]: [GL.FLOAT, 12, 'mat3', 'mat3x3<f32>'], // 9
|
|
49
|
+
[GL.FLOAT_MAT3x4]: [GL.FLOAT, 12, 'mat3x4', 'mat3x4<f32>'], // 12
|
|
50
|
+
[GL.FLOAT_MAT4x2]: [GL.FLOAT, 16, 'mat4x2', 'mat4x2<f32>'], // 8
|
|
51
|
+
[GL.FLOAT_MAT4x3]: [GL.FLOAT, 16, 'mat4x3', 'mat4x3<f32>'], // 12
|
|
52
|
+
[GL.FLOAT_MAT4]: [GL.FLOAT, 16, 'mat4', 'mat4x4<f32>'] // 16
|
|
31
53
|
};
|
|
54
|
+
/** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
|
|
32
55
|
export function decodeGLUniformType(glUniformType) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
format,
|
|
40
|
-
components,
|
|
41
|
-
glType
|
|
42
|
-
};
|
|
56
|
+
const typeAndSize = COMPOSITE_GL_TYPES[glUniformType];
|
|
57
|
+
if (!typeAndSize) {
|
|
58
|
+
throw new Error('uniform');
|
|
59
|
+
}
|
|
60
|
+
const [glType, components, , format] = typeAndSize;
|
|
61
|
+
return { format, components, glType };
|
|
43
62
|
}
|
|
63
|
+
/** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
|
|
44
64
|
export function decodeGLAttributeType(glAttributeType) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
attributeType,
|
|
53
|
-
vertexFormat,
|
|
54
|
-
components
|
|
55
|
-
};
|
|
65
|
+
const typeAndSize = COMPOSITE_GL_TYPES[glAttributeType];
|
|
66
|
+
if (!typeAndSize) {
|
|
67
|
+
throw new Error('attribute');
|
|
68
|
+
}
|
|
69
|
+
const [, components, , shaderType, vertexFormat] = typeAndSize;
|
|
70
|
+
// TODO sanity - if (shaderType.startsWith('mat' ...))
|
|
71
|
+
const attributeType = shaderType;
|
|
72
|
+
return { attributeType, vertexFormat, components }; // , glType};
|
|
56
73
|
}
|
|
74
|
+
/** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */
|
|
57
75
|
export function decomposeCompositeGLDataType(compositeGLDataType) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
type,
|
|
65
|
-
components
|
|
66
|
-
};
|
|
76
|
+
const typeAndSize = COMPOSITE_GL_TYPES[compositeGLDataType];
|
|
77
|
+
if (!typeAndSize) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const [type, components] = typeAndSize;
|
|
81
|
+
return { type, components };
|
|
67
82
|
}
|
|
68
83
|
export function getCompositeGLDataType(type, components) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
name
|
|
84
|
-
};
|
|
84
|
+
switch (type) {
|
|
85
|
+
case GL.BYTE:
|
|
86
|
+
case GL.UNSIGNED_BYTE:
|
|
87
|
+
case GL.SHORT:
|
|
88
|
+
case GL.UNSIGNED_SHORT:
|
|
89
|
+
type = GL.FLOAT;
|
|
90
|
+
break;
|
|
91
|
+
default:
|
|
92
|
+
}
|
|
93
|
+
for (const glType in COMPOSITE_GL_TYPES) {
|
|
94
|
+
const [compType, compComponents, name] = COMPOSITE_GL_TYPES[glType];
|
|
95
|
+
if (compType === type && compComponents === components) {
|
|
96
|
+
return { glType: Number(glType), name };
|
|
97
|
+
}
|
|
85
98
|
}
|
|
86
|
-
|
|
87
|
-
return null;
|
|
99
|
+
return null;
|
|
88
100
|
}
|
|
89
|
-
//# sourceMappingURL=decode-webgl-types.js.map
|