@luma.gl/webgl 9.0.0-beta.4 → 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 +297 -155
- 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 -67
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +53 -46
- package/dist/adapter/converters/texture-formats.d.ts +13 -19
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +474 -879
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +53 -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 +19 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.js +86 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +5 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js +90 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +35 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js +47 -0
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +88 -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 -225
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +47 -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 +68 -82
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +78 -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 +19 -12
- 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 +86 -77
- package/dist/adapter/objects/webgl-resource.d.ts +3 -25
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +102 -146
- package/dist/adapter/resources/webgl-buffer.d.ts +3 -4
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +161 -119
- 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 +266 -168
- 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 +33 -39
- package/dist/adapter/resources/webgl-external-texture.js +93 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +8 -10
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +167 -137
- 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 +124 -90
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +15 -6
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +356 -221
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -3
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +43 -33
- package/dist/adapter/resources/webgl-shader.d.ts +12 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +114 -47
- 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 +6 -9
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +615 -695
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +2 -2
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +141 -143
- 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 +229 -157
- 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 +58 -36
- package/dist/adapter/webgl-device.d.ts +34 -40
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +418 -363
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +132 -101
- package/dist/classic/clear.d.ts +2 -2
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +73 -72
- 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 +175 -175
- 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 +39 -32
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +96 -81
- package/dist/context/context/context-data.d.ts +14 -0
- 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.d.ts.map +1 -1
- package/dist/context/debug/spector.js +55 -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 +104 -77
- 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/{polyfill/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -2
- 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 +3 -3
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +94 -44
- package/dist/context/parameters/webgl-parameter-tables.d.ts +120 -99
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +469 -404
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +19 -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 +188 -123
- package/dist/context/state-tracker/with-parameters.d.ts +2 -2
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +43 -26
- package/dist/dist.dev.js +3135 -4142
- package/dist/index.cjs +1766 -2717
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +25 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -1
- package/dist.min.js +9 -42
- package/package.json +11 -15
- package/src/adapter/converters/device-parameters.ts +105 -17
- package/src/adapter/converters/sampler-parameters.ts +12 -20
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +138 -185
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +101 -0
- package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +30 -22
- package/src/adapter/device-helpers/webgl-device-limits.ts +53 -0
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +21 -31
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +3 -4
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +3 -2
- package/src/adapter/objects/webgl-renderbuffer.ts +38 -16
- package/src/adapter/objects/webgl-resource.ts +7 -140
- package/src/adapter/resources/webgl-buffer.ts +10 -14
- package/src/adapter/resources/webgl-command-buffer.ts +24 -34
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +5 -5
- package/src/adapter/resources/webgl-framebuffer.ts +38 -34
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +24 -15
- package/src/adapter/resources/webgl-render-pipeline.ts +138 -70
- package/src/adapter/resources/webgl-sampler.ts +7 -10
- package/src/adapter/resources/webgl-shader.ts +65 -11
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +38 -105
- package/src/adapter/resources/webgl-transform-feedback.ts +16 -22
- package/src/adapter/resources/webgl-vertex-array.ts +20 -21
- package/src/adapter/webgl-canvas-context.ts +7 -11
- package/src/adapter/webgl-device.ts +106 -151
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +25 -20
- package/src/classic/copy-and-blit.ts +12 -6
- 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 +31 -20
- package/src/context/{context → helpers}/create-browser-context.ts +9 -33
- package/src/context/{polyfill/context-data.ts → helpers/webgl-context-data.ts} +3 -2
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +5 -4
- package/src/context/parameters/webgl-parameter-tables.ts +118 -90
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +29 -23
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +4 -18
- package/src/types.ts +2 -1
- 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/device-limits.ts +0 -155
- 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/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
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
// Feature detection for WebGL
|
|
6
|
+
// Provides a function that enables simple checking of which WebGL features are
|
|
7
|
+
|
|
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';
|
|
13
|
+
|
|
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'
|
|
26
|
+
|
|
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'
|
|
35
|
+
|
|
36
|
+
// Textures are handled by getTextureFeatures()
|
|
37
|
+
};
|
|
38
|
+
|
|
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>();
|
|
49
|
+
|
|
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
|
+
}
|
|
58
|
+
|
|
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
|
+
}
|
|
64
|
+
}
|
|
65
|
+
for (const feature of Object.keys(TEXTURE_FEATURES) as DeviceFeature[]) {
|
|
66
|
+
if (this.has(feature)) {
|
|
67
|
+
yield feature;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
override has(feature: DeviceFeature): boolean {
|
|
74
|
+
// We have already tested this feature
|
|
75
|
+
if (!this.testedFeatures.has(feature)) {
|
|
76
|
+
this.testedFeatures.add(feature);
|
|
77
|
+
|
|
78
|
+
// Check the feature once
|
|
79
|
+
if (isTextureFeature(feature) && checkTextureFeature(this.gl, feature, this.extensions)) {
|
|
80
|
+
this.features.add(feature);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (this.getWebGLFeature(feature)) {
|
|
84
|
+
this.features.add(feature);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return this.features.has(feature);
|
|
88
|
+
}
|
|
89
|
+
|
|
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);
|
|
98
|
+
|
|
99
|
+
return isSupported;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -1,19 +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 {
|
|
6
|
+
import {GL, GLExtensions} from '@luma.gl/constants';
|
|
7
|
+
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
7
8
|
|
|
8
9
|
/** @returns strings identifying the GPU vendor and driver. */
|
|
9
|
-
export function getDeviceInfo(gl:
|
|
10
|
+
export function getDeviceInfo(gl: WebGL2RenderingContext, extensions: GLExtensions): DeviceInfo {
|
|
10
11
|
// "Masked" info is always available, but don't contain much useful information
|
|
11
12
|
const vendorMasked = gl.getParameter(GL.VENDOR);
|
|
12
13
|
const rendererMasked = gl.getParameter(GL.RENDERER);
|
|
13
14
|
|
|
14
15
|
// If we are lucky, unmasked info is available
|
|
15
16
|
// https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/
|
|
16
|
-
|
|
17
|
+
getWebGLExtension(gl, 'WEBGL_debug_renderer_info', extensions);
|
|
18
|
+
const ext = extensions.WEBGL_debug_renderer_info;
|
|
17
19
|
const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : GL.VENDOR);
|
|
18
20
|
const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : GL.RENDERER);
|
|
19
21
|
const vendor = vendorUnmasked || vendorMasked;
|
|
@@ -32,10 +34,10 @@ export function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {
|
|
|
32
34
|
// const version = gl.getParameter(GL.SHADING_LANGUAGE_VERSION) as string;
|
|
33
35
|
// const shadingLanguageVersion = parseGLSLVersion(version);
|
|
34
36
|
const shadingLanguage = 'glsl';
|
|
35
|
-
const shadingLanguageVersion =
|
|
37
|
+
const shadingLanguageVersion = 300;
|
|
36
38
|
|
|
37
39
|
return {
|
|
38
|
-
type:
|
|
40
|
+
type: 'webgl',
|
|
39
41
|
gpu,
|
|
40
42
|
gpuType,
|
|
41
43
|
gpuBackend,
|
|
@@ -48,44 +50,50 @@ export function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {
|
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/** "Sniff" the GPU type from the info. This works best if unmasked info is available. */
|
|
51
|
-
function identifyGPUVendor(
|
|
52
|
-
|
|
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)) {
|
|
53
58
|
return 'nvidia';
|
|
54
59
|
}
|
|
55
|
-
if (
|
|
60
|
+
if (/INTEL/i.exec(vendor) || /INTEL/i.exec(renderer)) {
|
|
56
61
|
return 'intel';
|
|
57
62
|
}
|
|
58
|
-
if (
|
|
63
|
+
if (/Apple/i.exec(vendor) || /Apple/i.exec(renderer)) {
|
|
59
64
|
return 'apple';
|
|
60
65
|
}
|
|
61
66
|
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
/AMD/i.exec(vendor) ||
|
|
68
|
+
/AMD/i.exec(renderer) ||
|
|
69
|
+
/ATI/i.exec(vendor) ||
|
|
70
|
+
/ATI/i.exec(renderer)
|
|
66
71
|
) {
|
|
67
72
|
return 'amd';
|
|
68
73
|
}
|
|
69
|
-
if (
|
|
74
|
+
if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
|
|
70
75
|
return 'software';
|
|
71
76
|
}
|
|
72
|
-
|
|
77
|
+
|
|
73
78
|
return 'unknown';
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
/** "Sniff" the GPU backend from the info. This works best if unmasked info is available. */
|
|
77
82
|
function identifyGPUBackend(vendor: string, renderer: string): 'opengl' | 'metal' | 'unknown' {
|
|
78
|
-
if (
|
|
83
|
+
if (/Metal/i.exec(vendor) || /Metal/i.exec(renderer)) {
|
|
79
84
|
return 'metal';
|
|
80
85
|
}
|
|
81
|
-
if (
|
|
86
|
+
if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
|
|
82
87
|
return 'opengl';
|
|
83
|
-
}
|
|
88
|
+
}
|
|
84
89
|
return 'unknown';
|
|
85
90
|
}
|
|
86
91
|
|
|
87
|
-
function identifyGPUType(
|
|
88
|
-
|
|
92
|
+
function identifyGPUType(
|
|
93
|
+
vendor: string,
|
|
94
|
+
renderer: string
|
|
95
|
+
): 'discrete' | 'integrated' | 'cpu' | 'unknown' {
|
|
96
|
+
if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
|
|
89
97
|
return 'cpu';
|
|
90
98
|
}
|
|
91
99
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {DeviceLimits} from '@luma.gl/core';
|
|
6
|
+
import {GL} from '@luma.gl/constants';
|
|
7
|
+
|
|
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;
|
|
45
|
+
}
|
|
46
|
+
|
|
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
|
+
}
|
|
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 {
|
|
@@ -10,7 +11,6 @@ import type {
|
|
|
10
11
|
} from '@luma.gl/core';
|
|
11
12
|
|
|
12
13
|
import {GL} from '@luma.gl/constants';
|
|
13
|
-
import {isWebGL2} from '../../context/context/webgl-checks';
|
|
14
14
|
import {Accessor} from '../../classic/accessor'; // TODO - should NOT depend on classic API
|
|
15
15
|
import {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './decode-webgl-types';
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ import {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './de
|
|
|
19
19
|
* Note: `linkProgram()` needs to have been called
|
|
20
20
|
* (although linking does not need to have been successful).
|
|
21
21
|
*/
|
|
22
|
-
export function getShaderLayout(gl:
|
|
22
|
+
export function getShaderLayout(gl: WebGL2RenderingContext, program: WebGLProgram): ShaderLayout {
|
|
23
23
|
const shaderLayout: ShaderLayout = {
|
|
24
24
|
attributes: [],
|
|
25
25
|
bindings: []
|
|
@@ -88,7 +88,7 @@ export function getShaderLayout(gl: WebGLRenderingContext, program: WebGLProgram
|
|
|
88
88
|
* linkProgram needs to have been called, although linking does not need to have been successful
|
|
89
89
|
*/
|
|
90
90
|
function readAttributeDeclarations(
|
|
91
|
-
gl:
|
|
91
|
+
gl: WebGL2RenderingContext,
|
|
92
92
|
program: WebGLProgram
|
|
93
93
|
): AttributeDeclaration[] {
|
|
94
94
|
const attributes: AttributeDeclaration[] = [];
|
|
@@ -106,7 +106,7 @@ function readAttributeDeclarations(
|
|
|
106
106
|
if (location >= 0) {
|
|
107
107
|
const {attributeType} = decodeGLAttributeType(compositeType);
|
|
108
108
|
|
|
109
|
-
// 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,
|
|
110
110
|
// so it is arguably a static property of the shader.
|
|
111
111
|
// There is no hint in the shader declarations
|
|
112
112
|
// Heuristic: Any attribute name containing the word "instance" will be assumed to be instanced
|
|
@@ -116,7 +116,7 @@ function readAttributeDeclarations(
|
|
|
116
116
|
name,
|
|
117
117
|
location,
|
|
118
118
|
stepMode,
|
|
119
|
-
type: attributeType
|
|
119
|
+
type: attributeType
|
|
120
120
|
// size - for arrays, size is the number of elements in the array
|
|
121
121
|
});
|
|
122
122
|
}
|
|
@@ -132,17 +132,12 @@ function readAttributeDeclarations(
|
|
|
132
132
|
*
|
|
133
133
|
* linkProgram needs to have been called, although linking does not need to have been successful
|
|
134
134
|
*/
|
|
135
|
-
function readVaryings(gl:
|
|
136
|
-
if (!isWebGL2(gl)) {
|
|
137
|
-
return [];
|
|
138
|
-
}
|
|
139
|
-
const gl2 = gl as WebGL2RenderingContext;
|
|
140
|
-
|
|
135
|
+
function readVaryings(gl: WebGL2RenderingContext, program: WebGLProgram): VaryingBinding[] {
|
|
141
136
|
const varyings: VaryingBinding[] = [];
|
|
142
137
|
|
|
143
138
|
const count = gl.getProgramParameter(program, GL.TRANSFORM_FEEDBACK_VARYINGS);
|
|
144
139
|
for (let location = 0; location < count; location++) {
|
|
145
|
-
const activeInfo =
|
|
140
|
+
const activeInfo = gl.getTransformFeedbackVarying(program, location);
|
|
146
141
|
if (!activeInfo) {
|
|
147
142
|
throw new Error('activeInfo');
|
|
148
143
|
}
|
|
@@ -162,7 +157,7 @@ function readVaryings(gl: WebGLRenderingContext, program: WebGLProgram): Varying
|
|
|
162
157
|
*
|
|
163
158
|
* Query uniform locations and build name to setter map.
|
|
164
159
|
*/
|
|
165
|
-
function readUniformBindings(gl:
|
|
160
|
+
function readUniformBindings(gl: WebGL2RenderingContext, program: WebGLProgram): UniformBinding[] {
|
|
166
161
|
const uniforms: UniformBinding[] = [];
|
|
167
162
|
|
|
168
163
|
const uniformCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORMS);
|
|
@@ -209,23 +204,18 @@ function readUniformBindings(gl: WebGLRenderingContext, program: WebGLProgram):
|
|
|
209
204
|
* @note In WebGL, "active" just means that unused (inactive) blocks may have been optimized away during linking)
|
|
210
205
|
*/
|
|
211
206
|
function readUniformBlocks(
|
|
212
|
-
gl:
|
|
207
|
+
gl: WebGL2RenderingContext,
|
|
213
208
|
program: WebGLProgram
|
|
214
209
|
): UniformBlockBinding[] {
|
|
215
|
-
if (!isWebGL2(gl)) {
|
|
216
|
-
return [];
|
|
217
|
-
}
|
|
218
|
-
const gl2 = gl as WebGL2RenderingContext;
|
|
219
|
-
|
|
220
210
|
const getBlockParameter = (blockIndex: number, pname: GL): any =>
|
|
221
|
-
|
|
211
|
+
gl.getActiveUniformBlockParameter(program, blockIndex, pname);
|
|
222
212
|
|
|
223
213
|
const uniformBlocks: UniformBlockBinding[] = [];
|
|
224
214
|
|
|
225
|
-
const blockCount =
|
|
215
|
+
const blockCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);
|
|
226
216
|
for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
|
|
227
217
|
const blockInfo: UniformBlockBinding = {
|
|
228
|
-
name:
|
|
218
|
+
name: gl.getActiveUniformBlockName(program, blockIndex) || '',
|
|
229
219
|
location: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_BINDING),
|
|
230
220
|
byteLength: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_DATA_SIZE),
|
|
231
221
|
vertex: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),
|
|
@@ -237,23 +227,23 @@ function readUniformBlocks(
|
|
|
237
227
|
const uniformIndices =
|
|
238
228
|
(getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) as number[]) || [];
|
|
239
229
|
|
|
240
|
-
const uniformType =
|
|
241
|
-
const uniformArrayLength =
|
|
242
|
-
// const uniformBlockIndex =
|
|
230
|
+
const uniformType = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.
|
|
231
|
+
const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.
|
|
232
|
+
// const uniformBlockIndex = gl.getActiveUniforms(
|
|
243
233
|
// program,
|
|
244
234
|
// uniformIndices,
|
|
245
235
|
// GL.UNIFORM_BLOCK_INDEX
|
|
246
236
|
// ); // Array of GLint indicating the block indices of the uniforms.
|
|
247
|
-
const uniformOffset =
|
|
248
|
-
const uniformStride =
|
|
249
|
-
// const uniformMatrixStride =
|
|
237
|
+
const uniformOffset = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.
|
|
238
|
+
const uniformStride = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.
|
|
239
|
+
// const uniformMatrixStride = gl.getActiveUniforms(
|
|
250
240
|
// program,
|
|
251
241
|
// uniformIndices,
|
|
252
242
|
// GL.UNIFORM_MATRIX_STRIDE
|
|
253
243
|
// ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.
|
|
254
|
-
// const uniformRowMajor =
|
|
244
|
+
// const uniformRowMajor = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
|
|
255
245
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
256
|
-
const activeInfo =
|
|
246
|
+
const activeInfo = gl.getActiveUniform(program, uniformIndices[i]);
|
|
257
247
|
if (!activeInfo) {
|
|
258
248
|
throw new Error('activeInfo');
|
|
259
249
|
}
|
|
@@ -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
|
/* eslint-disable */
|
|
@@ -10,7 +11,7 @@ import {GL, GLCompositeType, GLSamplerType} from '@luma.gl/constants';
|
|
|
10
11
|
/** Set a raw uniform (without type conversion and caching) */
|
|
11
12
|
/* eslint-disable max-len */
|
|
12
13
|
export function setUniform(
|
|
13
|
-
gl:
|
|
14
|
+
gl: WebGL2RenderingContext,
|
|
14
15
|
location: WebGLUniformLocation,
|
|
15
16
|
type: GLCompositeType | GLSamplerType,
|
|
16
17
|
value: UniformValue
|
|
@@ -29,10 +30,8 @@ export function setUniform(
|
|
|
29
30
|
|
|
30
31
|
// prettier-ignore
|
|
31
32
|
switch (type) {
|
|
32
|
-
// WebGL1 samplers
|
|
33
33
|
case GL.SAMPLER_2D:
|
|
34
34
|
case GL.SAMPLER_CUBE:
|
|
35
|
-
// WebGL2 samplers
|
|
36
35
|
case GL.SAMPLER_3D:
|
|
37
36
|
case GL.SAMPLER_2D_SHADOW:
|
|
38
37
|
case GL.SAMPLER_2D_ARRAY:
|
|
@@ -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)) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {assert} from '@luma.gl/core';
|
|
5
6
|
import {GL} from '@luma.gl/constants';
|
|
6
7
|
|
|
7
8
|
// Resolve a WebGL enumeration name (returns itself if already a number)
|
|
8
|
-
export function getKeyValue(gl:
|
|
9
|
+
export function getKeyValue(gl: WebGL2RenderingContext, name: string | GL): GL {
|
|
9
10
|
// If not a string, return (assume number)
|
|
10
11
|
if (typeof name !== 'string') {
|
|
11
12
|
return name;
|