@luma.gl/webgl 9.2.6 → 9.3.0-alpha.11
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 +1 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +4 -1
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +1 -1
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/shader-formats.d.ts +1 -64
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +1 -64
- package/dist/adapter/converters/shader-formats.js.map +1 -1
- package/dist/adapter/converters/webgl-shadertypes.d.ts +1 -3
- package/dist/adapter/converters/webgl-shadertypes.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-shadertypes.js +2 -7
- package/dist/adapter/converters/webgl-shadertypes.js.map +1 -1
- package/dist/adapter/converters/webgl-texture-table.d.ts +8 -4
- package/dist/adapter/converters/webgl-texture-table.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-texture-table.js +125 -61
- package/dist/adapter/converters/webgl-texture-table.js.map +1 -1
- package/dist/adapter/converters/webgl-vertex-formats.d.ts +1 -1
- package/dist/adapter/converters/webgl-vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-vertex-formats.js +4 -4
- package/dist/adapter/converters/webgl-vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +1 -2
- package/dist/adapter/device-helpers/webgl-device-features.js.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +6 -1
- package/dist/adapter/device-helpers/webgl-device-info.js.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +2 -2
- package/dist/adapter/device-helpers/webgl-device-limits.js.map +1 -1
- package/dist/adapter/helpers/format-utils.d.ts +1 -1
- package/dist/adapter/helpers/format-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/format-utils.js +1 -1
- package/dist/adapter/helpers/format-utils.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout-from-glsl.js +36 -22
- package/dist/adapter/helpers/get-shader-layout-from-glsl.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +22 -2
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- 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 +2 -2
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +9 -9
- package/dist/adapter/helpers/webgl-texture-utils.js.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +3 -3
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -1
- 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 +20 -5
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +7 -8
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +33 -43
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +6 -5
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +23 -8
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-fence.d.ts +14 -0
- package/dist/adapter/resources/webgl-fence.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-fence.js +49 -0
- package/dist/adapter/resources/webgl-fence.js.map +1 -0
- package/dist/adapter/resources/webgl-framebuffer.d.ts +3 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +10 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-query-set.d.ts +37 -31
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-query-set.js +247 -96
- package/dist/adapter/resources/webgl-query-set.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +28 -11
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +17 -21
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +94 -192
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- 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 +1 -1
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +15 -8
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-shared-render-pipeline.d.ts +24 -0
- package/dist/adapter/resources/webgl-shared-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-shared-render-pipeline.js +155 -0
- package/dist/adapter/resources/webgl-shared-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgl-texture.d.ts +42 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +289 -65
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +6 -6
- package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts +2 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js.map +1 -1
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +22 -23
- package/dist/adapter/webgl-adapter.js.map +1 -1
- 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 +16 -6
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +10 -5
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +78 -28
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/adapter/webgl-presentation-context.d.ts +21 -0
- package/dist/adapter/webgl-presentation-context.d.ts.map +1 -0
- package/dist/adapter/webgl-presentation-context.js +64 -0
- package/dist/adapter/webgl-presentation-context.js.map +1 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +5 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/webgl-constants.d.ts +822 -0
- package/dist/constants/webgl-constants.d.ts.map +1 -0
- package/dist/constants/webgl-constants.js +928 -0
- package/dist/constants/webgl-constants.js.map +1 -0
- package/dist/constants/webgl-types.d.ts +480 -0
- package/dist/constants/webgl-types.d.ts.map +1 -0
- package/dist/constants/webgl-types.js +6 -0
- package/dist/constants/webgl-types.js.map +1 -0
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +4 -4
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +11 -9
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
- package/dist/context/helpers/create-browser-context.js +46 -36
- package/dist/context/helpers/create-browser-context.js.map +1 -1
- package/dist/context/helpers/webgl-context-data.d.ts +5 -1
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -1
- package/dist/context/helpers/webgl-context-data.js +9 -10
- package/dist/context/helpers/webgl-context-data.js.map +1 -1
- package/dist/context/helpers/webgl-extensions.d.ts +1 -1
- package/dist/context/helpers/webgl-extensions.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +2 -2
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +2 -2
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfills/polyfill-webgl1-extensions.js +1 -1
- package/dist/context/polyfills/polyfill-webgl1-extensions.js.map +1 -1
- package/dist/context/state-tracker/webgl-state-tracker.js +2 -2
- package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -1
- package/dist/dist.dev.js +1898 -997
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +3 -5255
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/fill-array.js +1 -1
- package/dist/utils/fill-array.js.map +1 -1
- package/dist/webgl-constants.d.ts +2 -0
- package/dist/webgl-constants.d.ts.map +1 -0
- package/dist/webgl-constants.js +5 -0
- package/dist/webgl-constants.js.map +1 -0
- package/dist/webgl-types.d.ts +2 -0
- package/dist/webgl-types.d.ts.map +1 -0
- package/dist/{types.js → webgl-types.js} +1 -1
- package/dist/webgl-types.js.map +1 -0
- package/package.json +19 -5
- package/src/adapter/converters/device-parameters.ts +6 -2
- package/src/adapter/converters/sampler-parameters.ts +1 -1
- package/src/adapter/converters/shader-formats.ts +1 -66
- package/src/adapter/converters/webgl-shadertypes.ts +2 -10
- package/src/adapter/converters/webgl-texture-table.ts +160 -68
- package/src/adapter/converters/webgl-vertex-formats.ts +4 -4
- package/src/adapter/device-helpers/webgl-device-features.ts +2 -3
- package/src/adapter/device-helpers/webgl-device-info.ts +7 -1
- package/src/adapter/device-helpers/webgl-device-limits.ts +2 -2
- package/src/adapter/helpers/format-utils.ts +1 -1
- package/src/adapter/helpers/get-shader-layout-from-glsl.ts +44 -24
- package/src/adapter/helpers/parse-shader-compiler-log.ts +25 -3
- package/src/adapter/helpers/set-uniform.ts +2 -2
- package/src/adapter/helpers/webgl-texture-utils.ts +9 -9
- package/src/adapter/helpers/webgl-topology-utils.ts +3 -3
- package/src/adapter/resources/webgl-buffer.ts +17 -5
- package/src/adapter/resources/webgl-command-buffer.ts +48 -52
- package/src/adapter/resources/webgl-command-encoder.ts +28 -11
- package/src/adapter/resources/webgl-fence.ts +55 -0
- package/src/adapter/resources/webgl-framebuffer.ts +12 -1
- package/src/adapter/resources/webgl-query-set.ts +295 -101
- package/src/adapter/resources/webgl-render-pass.ts +30 -13
- package/src/adapter/resources/webgl-render-pipeline.ts +131 -227
- package/src/adapter/resources/webgl-sampler.ts +1 -1
- package/src/adapter/resources/webgl-shader.ts +15 -8
- package/src/adapter/resources/webgl-shared-render-pipeline.ts +211 -0
- package/src/adapter/resources/webgl-texture.ts +458 -84
- package/src/adapter/resources/webgl-transform-feedback.ts +6 -6
- package/src/adapter/resources/webgl-vertex-array.ts +1 -1
- package/src/adapter/webgl-adapter.ts +26 -24
- package/src/adapter/webgl-canvas-context.ts +19 -8
- package/src/adapter/webgl-device.ts +94 -35
- package/src/adapter/webgl-presentation-context.ts +93 -0
- package/src/constants/index.d.ts.map +1 -0
- package/src/constants/index.js.map +1 -0
- package/src/constants/index.ts +31 -0
- package/src/constants/webgl-constants.d.ts.map +1 -0
- package/src/constants/webgl-constants.js.map +1 -0
- package/src/constants/webgl-constants.ts +1051 -0
- package/src/constants/webgl-types.d.ts.map +1 -0
- package/src/constants/webgl-types.js.map +1 -0
- package/src/constants/webgl-types.ts +813 -0
- package/src/context/debug/spector.ts +4 -4
- package/src/context/debug/webgl-developer-tools.ts +20 -9
- package/src/context/helpers/create-browser-context.ts +54 -43
- package/src/context/helpers/webgl-context-data.ts +17 -11
- package/src/context/helpers/webgl-extensions.ts +1 -1
- package/src/context/parameters/unified-parameter-api.ts +3 -3
- package/src/context/parameters/webgl-parameter-tables.ts +1 -1
- package/src/context/polyfills/polyfill-webgl1-extensions.ts +1 -1
- package/src/context/state-tracker/webgl-state-tracker.ts +2 -2
- package/src/index.ts +27 -0
- package/src/utils/fill-array.ts +1 -1
- package/src/webgl-constants.d.ts.map +1 -0
- package/src/webgl-constants.js.map +1 -0
- package/src/webgl-constants.ts +5 -0
- package/src/webgl-types.d.ts.map +1 -0
- package/src/webgl-types.js.map +1 -0
- package/src/webgl-types.ts +29 -0
- package/dist/types.d.ts +0 -11
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/types.ts +0 -14
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
DeviceTextureFormatCapabilities
|
|
10
10
|
} from '@luma.gl/core';
|
|
11
11
|
import {textureFormatDecoder} from '@luma.gl/core';
|
|
12
|
-
import {GL, GLPixelType, GLExtensions, GLTexelDataFormat} from '@luma.gl/constants';
|
|
12
|
+
import {GL, GLPixelType, GLExtensions, GLTexelDataFormat} from '@luma.gl/webgl/constants';
|
|
13
13
|
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
14
14
|
import {getGLFromVertexType} from './webgl-vertex-formats';
|
|
15
15
|
|
|
@@ -32,32 +32,44 @@ const X_ATC = 'WEBGL_compressed_texture_atc';
|
|
|
32
32
|
const EXT_texture_norm16 = 'EXT_texture_norm16';
|
|
33
33
|
const EXT_render_snorm = 'EXT_render_snorm';
|
|
34
34
|
const EXT_color_buffer_float = 'EXT_color_buffer_float';
|
|
35
|
+
const SNORM8_COLOR_RENDERABLE: DeviceFeature = 'snorm8-renderable-webgl';
|
|
36
|
+
const NORM16_COLOR_RENDERABLE: DeviceFeature = 'norm16-renderable-webgl';
|
|
37
|
+
const SNORM16_COLOR_RENDERABLE: DeviceFeature = 'snorm16-renderable-webgl';
|
|
38
|
+
const FLOAT16_COLOR_RENDERABLE: DeviceFeature = 'float16-renderable-webgl';
|
|
39
|
+
const FLOAT32_COLOR_RENDERABLE: DeviceFeature = 'float32-renderable-webgl';
|
|
40
|
+
const RGB9E5UFLOAT_COLOR_RENDERABLE: DeviceFeature = 'rgb9e5ufloat-renderable-webgl';
|
|
41
|
+
|
|
42
|
+
type TextureFeatureDefinition = {
|
|
43
|
+
extensions?: string[];
|
|
44
|
+
features?: DeviceFeature[];
|
|
45
|
+
};
|
|
35
46
|
|
|
36
|
-
//
|
|
37
|
-
export const TEXTURE_FEATURES: Partial<Record<DeviceFeature,
|
|
38
|
-
'float32-renderable-webgl': [
|
|
39
|
-
'float16-renderable-webgl': ['EXT_color_buffer_half_float'],
|
|
40
|
-
'rgb9e5ufloat-renderable-webgl': ['WEBGL_render_shared_exponent'],
|
|
41
|
-
'snorm8-renderable-webgl': [EXT_render_snorm],
|
|
42
|
-
'norm16-
|
|
43
|
-
'
|
|
47
|
+
// biome-ignore format: preserve layout
|
|
48
|
+
export const TEXTURE_FEATURES: Partial<Record<DeviceFeature, TextureFeatureDefinition>> = {
|
|
49
|
+
'float32-renderable-webgl': {extensions: [EXT_color_buffer_float]},
|
|
50
|
+
'float16-renderable-webgl': {extensions: ['EXT_color_buffer_half_float']},
|
|
51
|
+
'rgb9e5ufloat-renderable-webgl': {extensions: ['WEBGL_render_shared_exponent']},
|
|
52
|
+
'snorm8-renderable-webgl': {extensions: [EXT_render_snorm]},
|
|
53
|
+
'norm16-webgl': {extensions: [EXT_texture_norm16]},
|
|
54
|
+
'norm16-renderable-webgl': {features: ['norm16-webgl']},
|
|
55
|
+
'snorm16-renderable-webgl': {features: ['norm16-webgl'], extensions: [EXT_render_snorm]},
|
|
44
56
|
|
|
45
|
-
'float32-filterable': ['OES_texture_float_linear'],
|
|
46
|
-
'float16-filterable-webgl': ['OES_texture_half_float_linear'],
|
|
47
|
-
'texture-filterable-anisotropic-webgl': ['EXT_texture_filter_anisotropic'],
|
|
57
|
+
'float32-filterable': {extensions: ['OES_texture_float_linear']},
|
|
58
|
+
'float16-filterable-webgl': {extensions: ['OES_texture_half_float_linear']},
|
|
59
|
+
'texture-filterable-anisotropic-webgl': {extensions: ['EXT_texture_filter_anisotropic']},
|
|
48
60
|
|
|
49
|
-
'texture-blend-float-webgl': ['EXT_float_blend'],
|
|
61
|
+
'texture-blend-float-webgl': {extensions: ['EXT_float_blend']},
|
|
50
62
|
|
|
51
|
-
'texture-compression-bc': [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC],
|
|
63
|
+
'texture-compression-bc': {extensions: [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC]},
|
|
52
64
|
// 'texture-compression-bc3-srgb-webgl': [X_S3TC_SRGB],
|
|
53
65
|
// 'texture-compression-bc3-webgl': [X_S3TC],
|
|
54
|
-
'texture-compression-bc5-webgl': [X_RGTC],
|
|
55
|
-
'texture-compression-bc7-webgl': [X_BPTC],
|
|
56
|
-
'texture-compression-etc2': [X_ETC2],
|
|
57
|
-
'texture-compression-astc': [X_ASTC],
|
|
58
|
-
'texture-compression-etc1-webgl': [X_ETC1],
|
|
59
|
-
'texture-compression-pvrtc-webgl': [X_PVRTC],
|
|
60
|
-
'texture-compression-atc-webgl': [X_ATC]
|
|
66
|
+
'texture-compression-bc5-webgl': {extensions: [X_RGTC]},
|
|
67
|
+
'texture-compression-bc7-webgl': {extensions: [X_BPTC]},
|
|
68
|
+
'texture-compression-etc2': {extensions: [X_ETC2]},
|
|
69
|
+
'texture-compression-astc': {extensions: [X_ASTC]},
|
|
70
|
+
'texture-compression-etc1-webgl': {extensions: [X_ETC1]},
|
|
71
|
+
'texture-compression-pvrtc-webgl': {extensions: [X_PVRTC]},
|
|
72
|
+
'texture-compression-atc-webgl': {extensions: [X_ATC]}
|
|
61
73
|
};
|
|
62
74
|
|
|
63
75
|
export function isTextureFeature(feature: DeviceFeature): boolean {
|
|
@@ -70,8 +82,36 @@ export function checkTextureFeature(
|
|
|
70
82
|
feature: DeviceFeature,
|
|
71
83
|
extensions: GLExtensions
|
|
72
84
|
): boolean {
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
return hasTextureFeature(gl, feature, extensions, new Set<DeviceFeature>());
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function hasTextureFeature(
|
|
89
|
+
gl: WebGL2RenderingContext,
|
|
90
|
+
feature: DeviceFeature,
|
|
91
|
+
extensions: GLExtensions,
|
|
92
|
+
seenFeatures: Set<DeviceFeature>
|
|
93
|
+
): boolean {
|
|
94
|
+
const definition = TEXTURE_FEATURES[feature];
|
|
95
|
+
if (!definition) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (seenFeatures.has(feature)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
seenFeatures.add(feature);
|
|
104
|
+
const hasDependentFeatures = (definition.features || []).every(dependentFeature =>
|
|
105
|
+
hasTextureFeature(gl, dependentFeature, extensions, seenFeatures)
|
|
106
|
+
);
|
|
107
|
+
seenFeatures.delete(feature);
|
|
108
|
+
if (!hasDependentFeatures) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (definition.extensions || []).every(extension =>
|
|
113
|
+
Boolean(getWebGLExtension(gl, extension, extensions))
|
|
114
|
+
);
|
|
75
115
|
}
|
|
76
116
|
|
|
77
117
|
// TEXTURE FORMATS
|
|
@@ -81,6 +121,8 @@ type WebGLFormatInfo = {
|
|
|
81
121
|
gl?: GL;
|
|
82
122
|
/** compressed */
|
|
83
123
|
x?: string;
|
|
124
|
+
/** color-renderable capability gate. false means never color-renderable on WebGL. */
|
|
125
|
+
r?: DeviceFeature | false;
|
|
84
126
|
types?: GLPixelType[];
|
|
85
127
|
dataFormat?: GLTexelDataFormat;
|
|
86
128
|
/** if depthTexture is set this is a depth/stencil format that can be set to a texture */
|
|
@@ -95,25 +137,25 @@ type WebGLFormatInfo = {
|
|
|
95
137
|
* Texture format data -
|
|
96
138
|
* Exported but can change without notice
|
|
97
139
|
*/
|
|
98
|
-
//
|
|
140
|
+
// biome-ignore format: preserve layout
|
|
99
141
|
export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
100
142
|
// 8-bit formats
|
|
101
143
|
'r8unorm': {gl: GL.R8, rb: true},
|
|
102
|
-
'r8snorm': {gl: GL.R8_SNORM},
|
|
144
|
+
'r8snorm': {gl: GL.R8_SNORM, r: SNORM8_COLOR_RENDERABLE},
|
|
103
145
|
'r8uint': {gl: GL.R8UI, rb: true},
|
|
104
146
|
'r8sint': {gl: GL.R8I, rb: true},
|
|
105
147
|
|
|
106
148
|
// 16-bit formats
|
|
107
149
|
'rg8unorm': {gl: GL.RG8, rb: true},
|
|
108
|
-
'rg8snorm': {gl: GL.RG8_SNORM},
|
|
150
|
+
'rg8snorm': {gl: GL.RG8_SNORM, r: SNORM8_COLOR_RENDERABLE},
|
|
109
151
|
'rg8uint': {gl: GL.RG8UI, rb: true},
|
|
110
152
|
'rg8sint': {gl: GL.RG8I, rb: true},
|
|
111
153
|
|
|
112
154
|
'r16uint': {gl: GL.R16UI, rb: true},
|
|
113
155
|
'r16sint': {gl: GL.R16I, rb: true},
|
|
114
|
-
'r16float': {gl: GL.R16F, rb: true},
|
|
115
|
-
'r16unorm': {gl: GL.R16_EXT, rb: true},
|
|
116
|
-
'r16snorm': {gl: GL.R16_SNORM_EXT},
|
|
156
|
+
'r16float': {gl: GL.R16F, rb: true, r: FLOAT16_COLOR_RENDERABLE},
|
|
157
|
+
'r16unorm': {gl: GL.R16_EXT, rb: true, r: NORM16_COLOR_RENDERABLE},
|
|
158
|
+
'r16snorm': {gl: GL.R16_SNORM_EXT, r: SNORM16_COLOR_RENDERABLE},
|
|
117
159
|
|
|
118
160
|
// Packed 16-bit formats
|
|
119
161
|
'rgba4unorm-webgl': {gl: GL.RGBA4, rb: true},
|
|
@@ -127,7 +169,7 @@ export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
|
127
169
|
// 32-bit formats
|
|
128
170
|
'rgba8unorm': {gl: GL.RGBA8},
|
|
129
171
|
'rgba8unorm-srgb': {gl: GL.SRGB8_ALPHA8},
|
|
130
|
-
'rgba8snorm': {gl: GL.RGBA8_SNORM},
|
|
172
|
+
'rgba8snorm': {gl: GL.RGBA8_SNORM, r: SNORM8_COLOR_RENDERABLE},
|
|
131
173
|
'rgba8uint': {gl: GL.RGBA8UI},
|
|
132
174
|
'rgba8sint': {gl: GL.RGBA8I},
|
|
133
175
|
// reverse colors, webgpu only
|
|
@@ -136,41 +178,41 @@ export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
|
136
178
|
|
|
137
179
|
'rg16uint': {gl: GL.RG16UI},
|
|
138
180
|
'rg16sint': {gl: GL.RG16I},
|
|
139
|
-
'rg16float': {gl: GL.RG16F, rb: true},
|
|
140
|
-
'rg16unorm': {gl: GL.RG16_EXT},
|
|
141
|
-
'rg16snorm': {gl: GL.RG16_SNORM_EXT},
|
|
181
|
+
'rg16float': {gl: GL.RG16F, rb: true, r: FLOAT16_COLOR_RENDERABLE},
|
|
182
|
+
'rg16unorm': {gl: GL.RG16_EXT, r: NORM16_COLOR_RENDERABLE},
|
|
183
|
+
'rg16snorm': {gl: GL.RG16_SNORM_EXT, r: SNORM16_COLOR_RENDERABLE},
|
|
142
184
|
|
|
143
185
|
'r32uint': {gl: GL.R32UI, rb: true},
|
|
144
186
|
'r32sint': {gl: GL.R32I, rb: true},
|
|
145
|
-
'r32float': {gl: GL.R32F},
|
|
187
|
+
'r32float': {gl: GL.R32F, r: FLOAT32_COLOR_RENDERABLE},
|
|
146
188
|
|
|
147
189
|
// Packed 32-bit formats
|
|
148
|
-
'rgb9e5ufloat': {gl: GL.RGB9_E5}, // , filter: true},
|
|
190
|
+
'rgb9e5ufloat': {gl: GL.RGB9_E5, r: RGB9E5UFLOAT_COLOR_RENDERABLE}, // , filter: true},
|
|
149
191
|
'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, rb: true},
|
|
150
192
|
'rgb10a2unorm': {gl: GL.RGB10_A2, rb: true},
|
|
151
193
|
'rgb10a2uint': {gl: GL.RGB10_A2UI, rb: true},
|
|
152
194
|
|
|
153
195
|
// 48-bit formats
|
|
154
|
-
'rgb16unorm-webgl': {gl: GL.RGB16_EXT}, // rgb not renderable
|
|
155
|
-
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT}, // rgb not renderable
|
|
196
|
+
'rgb16unorm-webgl': {gl: GL.RGB16_EXT, r: false}, // rgb not renderable
|
|
197
|
+
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT, r: false}, // rgb not renderable
|
|
156
198
|
|
|
157
199
|
// 64-bit formats
|
|
158
200
|
'rg32uint': {gl: GL.RG32UI, rb: true},
|
|
159
201
|
'rg32sint': {gl: GL.RG32I, rb: true},
|
|
160
|
-
'rg32float': {gl: GL.RG32F, rb: true},
|
|
202
|
+
'rg32float': {gl: GL.RG32F, rb: true, r: FLOAT32_COLOR_RENDERABLE},
|
|
161
203
|
'rgba16uint': {gl: GL.RGBA16UI, rb: true},
|
|
162
204
|
'rgba16sint': {gl: GL.RGBA16I, rb: true},
|
|
163
|
-
'rgba16float': {gl: GL.RGBA16F},
|
|
164
|
-
'rgba16unorm': {gl: GL.RGBA16_EXT, rb: true},
|
|
165
|
-
'rgba16snorm': {gl: GL.RGBA16_SNORM_EXT},
|
|
205
|
+
'rgba16float': {gl: GL.RGBA16F, r: FLOAT16_COLOR_RENDERABLE},
|
|
206
|
+
'rgba16unorm': {gl: GL.RGBA16_EXT, rb: true, r: NORM16_COLOR_RENDERABLE},
|
|
207
|
+
'rgba16snorm': {gl: GL.RGBA16_SNORM_EXT, r: SNORM16_COLOR_RENDERABLE},
|
|
166
208
|
|
|
167
209
|
// 96-bit formats (deprecated!)
|
|
168
|
-
'rgb32float-webgl': {gl: GL.RGB32F, x: EXT_color_buffer_float, dataFormat: GL.RGB, types: [GL.FLOAT]},
|
|
210
|
+
'rgb32float-webgl': {gl: GL.RGB32F, x: EXT_color_buffer_float, r: FLOAT32_COLOR_RENDERABLE, dataFormat: GL.RGB, types: [GL.FLOAT]},
|
|
169
211
|
|
|
170
212
|
// 128-bit formats
|
|
171
213
|
'rgba32uint': {gl: GL.RGBA32UI, rb: true},
|
|
172
214
|
'rgba32sint': {gl: GL.RGBA32I, rb: true},
|
|
173
|
-
'rgba32float': {gl: GL.RGBA32F, rb: true},
|
|
215
|
+
'rgba32float': {gl: GL.RGBA32F, rb: true, r: FLOAT32_COLOR_RENDERABLE},
|
|
174
216
|
|
|
175
217
|
// Depth and stencil formats
|
|
176
218
|
'stencil8': {gl: GL.STENCIL_INDEX8, rb: true}, // 8 stencil bits
|
|
@@ -237,8 +279,8 @@ export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
|
237
279
|
'astc-8x6-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR},
|
|
238
280
|
'astc-8x8-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_8x8_KHR},
|
|
239
281
|
'astc-8x8-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR},
|
|
240
|
-
'astc-10x5-unorm': {gl: GL.
|
|
241
|
-
'astc-10x5-unorm-srgb': {gl: GL.
|
|
282
|
+
'astc-10x5-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x5_KHR},
|
|
283
|
+
'astc-10x5-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR},
|
|
242
284
|
'astc-10x6-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x6_KHR},
|
|
243
285
|
'astc-10x6-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR},
|
|
244
286
|
'astc-10x8-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x8_KHR},
|
|
@@ -254,7 +296,7 @@ export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
|
254
296
|
|
|
255
297
|
'pvrtc-rgb4unorm-webgl': {gl: GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},
|
|
256
298
|
'pvrtc-rgba4unorm-webgl': {gl: GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},
|
|
257
|
-
'pvrtc-
|
|
299
|
+
'pvrtc-rgb2unorm-webgl': {gl: GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG},
|
|
258
300
|
'pvrtc-rgba2unorm-webgl': {gl: GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG},
|
|
259
301
|
|
|
260
302
|
// WEBGL_compressed_texture_etc1
|
|
@@ -270,26 +312,6 @@ export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
|
270
312
|
|
|
271
313
|
// FUNCTIONS
|
|
272
314
|
|
|
273
|
-
/** Checks if a texture format is supported */
|
|
274
|
-
export function isWebGLTextureFormatCapabilitiesed(
|
|
275
|
-
gl: WebGL2RenderingContext,
|
|
276
|
-
format: TextureFormat,
|
|
277
|
-
extensions: GLExtensions
|
|
278
|
-
): boolean {
|
|
279
|
-
const webglTextureInfo = WEBGL_TEXTURE_FORMATS[format];
|
|
280
|
-
// Check that we have a GL constant
|
|
281
|
-
if (!webglTextureInfo?.gl) {
|
|
282
|
-
return false;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// Check extensions
|
|
286
|
-
const extension = webglTextureInfo.x;
|
|
287
|
-
if (extension) {
|
|
288
|
-
return Boolean(getWebGLExtension(gl, extension, extensions));
|
|
289
|
-
}
|
|
290
|
-
return true;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
315
|
/** Checks if a texture format is supported, renderable, filterable etc */
|
|
294
316
|
export function getTextureFormatCapabilitiesWebGL(
|
|
295
317
|
gl: WebGL2RenderingContext,
|
|
@@ -308,12 +330,29 @@ export function getTextureFormatCapabilitiesWebGL(
|
|
|
308
330
|
supported = supported && Boolean(getWebGLExtension(gl, webglFormatInfo.x, extensions));
|
|
309
331
|
}
|
|
310
332
|
|
|
333
|
+
// WebGL2 exposes STENCIL_INDEX8 for renderbuffers, but standalone stencil textures are not
|
|
334
|
+
// valid texture storage targets. Report them as unsupported texture formats to avoid invalid
|
|
335
|
+
// constructor paths and misleading capability checks.
|
|
336
|
+
if (formatSupport.format === 'stencil8') {
|
|
337
|
+
supported = false;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const renderFeatureSupported =
|
|
341
|
+
webglFormatInfo?.r === false
|
|
342
|
+
? false
|
|
343
|
+
: webglFormatInfo?.r === undefined || checkTextureFeature(gl, webglFormatInfo.r, extensions);
|
|
344
|
+
const renderable =
|
|
345
|
+
supported &&
|
|
346
|
+
formatSupport.render &&
|
|
347
|
+
renderFeatureSupported &&
|
|
348
|
+
isColorRenderableTextureFormat(gl, formatSupport.format, extensions);
|
|
349
|
+
|
|
311
350
|
return {
|
|
312
351
|
format: formatSupport.format,
|
|
313
352
|
// @ts-ignore
|
|
314
353
|
create: supported && formatSupport.create,
|
|
315
354
|
// @ts-ignore
|
|
316
|
-
render:
|
|
355
|
+
render: renderable,
|
|
317
356
|
// @ts-ignore
|
|
318
357
|
filter: supported && formatSupport.filter,
|
|
319
358
|
// @ts-ignore
|
|
@@ -323,6 +362,59 @@ export function getTextureFormatCapabilitiesWebGL(
|
|
|
323
362
|
};
|
|
324
363
|
}
|
|
325
364
|
|
|
365
|
+
function isColorRenderableTextureFormat(
|
|
366
|
+
gl: WebGL2RenderingContext,
|
|
367
|
+
format: TextureFormat,
|
|
368
|
+
extensions: GLExtensions
|
|
369
|
+
): boolean {
|
|
370
|
+
const webglFormatInfo = WEBGL_TEXTURE_FORMATS[format];
|
|
371
|
+
const internalFormat = webglFormatInfo?.gl;
|
|
372
|
+
if (internalFormat === undefined) {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (webglFormatInfo?.x && !getWebGLExtension(gl, webglFormatInfo.x, extensions)) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const previousTexture = gl.getParameter(GL.TEXTURE_BINDING_2D) as WebGLTexture | null;
|
|
381
|
+
const previousFramebuffer = gl.getParameter(GL.FRAMEBUFFER_BINDING) as WebGLFramebuffer | null;
|
|
382
|
+
const texture = gl.createTexture();
|
|
383
|
+
const framebuffer = gl.createFramebuffer();
|
|
384
|
+
if (!texture || !framebuffer) {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Isolate the probe from any prior driver errors so the result reflects only this format.
|
|
389
|
+
const noError = Number(GL.NO_ERROR);
|
|
390
|
+
let error = Number(gl.getError());
|
|
391
|
+
while (error !== noError) {
|
|
392
|
+
error = gl.getError();
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
let renderable = false;
|
|
396
|
+
try {
|
|
397
|
+
gl.bindTexture(GL.TEXTURE_2D, texture);
|
|
398
|
+
gl.texStorage2D(GL.TEXTURE_2D, 1, internalFormat, 1, 1);
|
|
399
|
+
if (Number(gl.getError()) !== noError) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer);
|
|
404
|
+
gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0, GL.TEXTURE_2D, texture, 0);
|
|
405
|
+
renderable =
|
|
406
|
+
Number(gl.checkFramebufferStatus(GL.FRAMEBUFFER)) === Number(GL.FRAMEBUFFER_COMPLETE) &&
|
|
407
|
+
Number(gl.getError()) === noError;
|
|
408
|
+
} finally {
|
|
409
|
+
gl.bindFramebuffer(GL.FRAMEBUFFER, previousFramebuffer);
|
|
410
|
+
gl.deleteFramebuffer(framebuffer);
|
|
411
|
+
gl.bindTexture(GL.TEXTURE_2D, previousTexture);
|
|
412
|
+
gl.deleteTexture(texture);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return renderable;
|
|
416
|
+
}
|
|
417
|
+
|
|
326
418
|
/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
|
|
327
419
|
export function getTextureFormatWebGL(format: TextureFormat): {
|
|
328
420
|
internalFormat: GL;
|
|
@@ -386,7 +478,7 @@ export function getWebGLPixelDataFormat(
|
|
|
386
478
|
if (format === GL.RGBA || format === GL.RGB) {
|
|
387
479
|
return format;
|
|
388
480
|
}
|
|
389
|
-
//
|
|
481
|
+
// biome-ignore format: preserve layout
|
|
390
482
|
switch (channels) {
|
|
391
483
|
case 'r': return integer && !normalized ? GL.RED_INTEGER : GL.RED;
|
|
392
484
|
case 'rg': return integer && !normalized ? GL.RG_INTEGER : GL.RG;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {GL} from '@luma.gl/constants';
|
|
5
|
+
import {GL} from '@luma.gl/webgl/constants';
|
|
6
6
|
import {VertexFormat, NormalizedDataType} from '@luma.gl/core';
|
|
7
7
|
|
|
8
8
|
type GLDataType =
|
|
@@ -18,7 +18,7 @@ type GLDataType =
|
|
|
18
18
|
/** Get vertex format from GL constants */
|
|
19
19
|
export function getVertexFormatFromGL(type: GLDataType, components: 1 | 2 | 3 | 4): VertexFormat {
|
|
20
20
|
const base = getVertexTypeFromGL(type);
|
|
21
|
-
//
|
|
21
|
+
// biome-ignore format: preserve layout
|
|
22
22
|
switch (components) {
|
|
23
23
|
case 1: return base;
|
|
24
24
|
case 2: return `${base}x2`;
|
|
@@ -32,7 +32,7 @@ export function getVertexFormatFromGL(type: GLDataType, components: 1 | 2 | 3 |
|
|
|
32
32
|
|
|
33
33
|
/** Get data type from GL constants */
|
|
34
34
|
export function getVertexTypeFromGL(type: GLDataType, normalized = false): NormalizedDataType {
|
|
35
|
-
//
|
|
35
|
+
// biome-ignore format: preserve layout
|
|
36
36
|
switch (type) {
|
|
37
37
|
// WebGPU does not support normalized 32 bit integer attributes
|
|
38
38
|
case GL.INT: return normalized ? 'sint32' : 'sint32';
|
|
@@ -59,7 +59,7 @@ export function getGLFromVertexType(
|
|
|
59
59
|
| GL.INT
|
|
60
60
|
| GL.HALF_FLOAT
|
|
61
61
|
| GL.FLOAT {
|
|
62
|
-
//
|
|
62
|
+
// biome-ignore format: preserve layout
|
|
63
63
|
switch (dataType) {
|
|
64
64
|
case 'uint8': return GL.UNSIGNED_BYTE;
|
|
65
65
|
case 'sint8': return GL.BYTE;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Provides a function that enables simple checking of which WebGL features are
|
|
7
7
|
|
|
8
8
|
import {DeviceFeature, DeviceFeatures} from '@luma.gl/core';
|
|
9
|
-
import {GLExtensions} from '@luma.gl/constants';
|
|
9
|
+
import {GLExtensions} from '@luma.gl/webgl/constants';
|
|
10
10
|
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
11
11
|
import {
|
|
12
12
|
isTextureFeature,
|
|
@@ -21,13 +21,12 @@ import {
|
|
|
21
21
|
const WEBGL_FEATURES: Partial<Record<DeviceFeature, boolean | string>> = {
|
|
22
22
|
// optional WebGPU features
|
|
23
23
|
'depth-clip-control': 'EXT_depth_clamp', // TODO these seem subtly different
|
|
24
|
-
|
|
24
|
+
'timestamp-query': 'EXT_disjoint_timer_query_webgl2',
|
|
25
25
|
// "indirect-first-instance"
|
|
26
26
|
// Textures are handled by getTextureFeatures()
|
|
27
27
|
// 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
|
|
28
28
|
|
|
29
29
|
// optional WebGL features
|
|
30
|
-
'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2',
|
|
31
30
|
'compilation-status-async-webgl': 'KHR_parallel_shader_compile',
|
|
32
31
|
'polygon-mode-webgl': 'WEBGL_polygon_mode',
|
|
33
32
|
'provoking-vertex-webgl': 'WEBGL_provoking_vertex',
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {DeviceInfo} from '@luma.gl/core';
|
|
6
|
-
import {GL, GLExtensions} from '@luma.gl/constants';
|
|
6
|
+
import {GL, GLExtensions} from '@luma.gl/webgl/constants';
|
|
7
7
|
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
8
8
|
|
|
9
9
|
/** @returns strings identifying the GPU vendor and driver. */
|
|
@@ -99,6 +99,8 @@ function identifyGPUType(
|
|
|
99
99
|
|
|
100
100
|
const gpuVendor = identifyGPUVendor(vendor, renderer);
|
|
101
101
|
switch (gpuVendor) {
|
|
102
|
+
case 'apple':
|
|
103
|
+
return isAppleSiliconGPU(vendor, renderer) ? 'integrated' : 'unknown';
|
|
102
104
|
case 'intel':
|
|
103
105
|
return 'integrated';
|
|
104
106
|
case 'software':
|
|
@@ -109,3 +111,7 @@ function identifyGPUType(
|
|
|
109
111
|
return 'discrete';
|
|
110
112
|
}
|
|
111
113
|
}
|
|
114
|
+
|
|
115
|
+
function isAppleSiliconGPU(vendor: string, renderer: string): boolean {
|
|
116
|
+
return /Apple (M\d|A\d|GPU)/i.test(`${vendor} ${renderer}`);
|
|
117
|
+
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {DeviceLimits} from '@luma.gl/core';
|
|
6
|
-
import {GL} from '@luma.gl/constants';
|
|
6
|
+
import {GL} from '@luma.gl/webgl/constants';
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// biome-ignore format: preserve layout
|
|
9
9
|
export class WebGLDeviceLimits extends DeviceLimits {
|
|
10
10
|
get maxTextureDimension1D() { return 0; } // WebGL does not support 1D textures
|
|
11
11
|
get maxTextureDimension2D() { return this.getParameter(GL.MAX_TEXTURE_SIZE); }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {GL} from '@luma.gl/constants';
|
|
5
|
+
import {GL} from '@luma.gl/webgl/constants';
|
|
6
6
|
|
|
7
7
|
// Returns number of components in a specific readPixels WebGL format
|
|
8
8
|
export function glFormatToComponents(format: GL): 0 | 1 | 2 | 3 | 4 {
|
|
@@ -10,9 +10,9 @@ import type {
|
|
|
10
10
|
VaryingBinding,
|
|
11
11
|
AttributeShaderType
|
|
12
12
|
} from '@luma.gl/core';
|
|
13
|
-
import {getVariableShaderTypeInfo} from '@luma.gl/core';
|
|
13
|
+
import {getVariableShaderTypeInfo, assertDefined, log} from '@luma.gl/core';
|
|
14
14
|
|
|
15
|
-
import {GL, GLUniformType} from '@luma.gl/constants';
|
|
15
|
+
import {GL, GLUniformType} from '@luma.gl/webgl/constants';
|
|
16
16
|
import {
|
|
17
17
|
isGLSamplerType,
|
|
18
18
|
getTextureBindingFromGLSamplerType,
|
|
@@ -252,23 +252,45 @@ function readUniformBlocks(
|
|
|
252
252
|
// ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.
|
|
253
253
|
// const uniformRowMajor = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
|
|
254
254
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
|
|
255
|
+
const uniformIndex = uniformIndices[i];
|
|
256
|
+
if (uniformIndex !== undefined) {
|
|
257
|
+
const activeInfo = gl.getActiveUniform(program, uniformIndex);
|
|
258
|
+
if (!activeInfo) {
|
|
259
|
+
throw new Error('activeInfo');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const format = convertGLUniformTypeToShaderVariableType(uniformType[i]);
|
|
263
|
+
|
|
264
|
+
blockInfo.uniforms.push({
|
|
265
|
+
name: activeInfo.name,
|
|
266
|
+
format,
|
|
267
|
+
type: uniformType[i],
|
|
268
|
+
arrayLength: uniformArrayLength[i],
|
|
269
|
+
byteOffset: uniformOffset[i],
|
|
270
|
+
byteStride: uniformStride[i]
|
|
271
|
+
// matrixStride: uniformStride[i],
|
|
272
|
+
// rowMajor: uniformRowMajor[i]
|
|
273
|
+
});
|
|
258
274
|
}
|
|
275
|
+
}
|
|
259
276
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
277
|
+
const uniformInstancePrefixes = new Set(
|
|
278
|
+
blockInfo.uniforms
|
|
279
|
+
.map(uniform => uniform.name.split('.')[0])
|
|
280
|
+
.filter((instanceName): instanceName is string => Boolean(instanceName))
|
|
281
|
+
);
|
|
282
|
+
const blockAlias = blockInfo.name.replace(/Uniforms$/, '');
|
|
283
|
+
if (
|
|
284
|
+
uniformInstancePrefixes.size === 1 &&
|
|
285
|
+
!uniformInstancePrefixes.has(blockInfo.name) &&
|
|
286
|
+
!uniformInstancePrefixes.has(blockAlias)
|
|
287
|
+
) {
|
|
288
|
+
const [instanceName] = uniformInstancePrefixes;
|
|
289
|
+
log.warn(
|
|
290
|
+
`Uniform block "${blockInfo.name}" uses GLSL instance "${instanceName}". ` +
|
|
291
|
+
`luma.gl binds uniform buffers by block name ("${blockInfo.name}") and alias ("${blockAlias}"). ` +
|
|
292
|
+
'Prefer matching the instance name to one of those to avoid confusing silent mismatches.'
|
|
293
|
+
)();
|
|
272
294
|
}
|
|
273
295
|
|
|
274
296
|
uniformBlocks.push(blockInfo);
|
|
@@ -314,13 +336,11 @@ function parseUniformName(name: string): {name: string; length: number; isArray:
|
|
|
314
336
|
// if array name then clean the array brackets
|
|
315
337
|
const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
|
|
316
338
|
const matches = UNIFORM_NAME_REGEXP.exec(name);
|
|
317
|
-
|
|
318
|
-
throw new Error(`Failed to parse GLSL uniform name ${name}`);
|
|
319
|
-
}
|
|
320
|
-
|
|
339
|
+
const uniformName = assertDefined(matches?.[1], `Failed to parse GLSL uniform name ${name}`);
|
|
321
340
|
return {
|
|
322
|
-
name:
|
|
323
|
-
|
|
324
|
-
|
|
341
|
+
name: uniformName,
|
|
342
|
+
// TODO - is this a bug, shouldn't we return the value?
|
|
343
|
+
length: matches?.[2] ? 1 : 0,
|
|
344
|
+
isArray: Boolean(matches?.[2])
|
|
325
345
|
};
|
|
326
346
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type
|
|
5
|
+
import {type CompilerMessage} from '@luma.gl/core';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Parse a WebGL-format GLSL compilation log into an array of WebGPU style message records.
|
|
@@ -20,29 +20,51 @@ export function parseShaderCompilerLog(errLog: string): readonly CompilerMessage
|
|
|
20
20
|
continue; // eslint-disable-line no-continue
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const lineWithTrimmedWhitespace = line.trim();
|
|
24
|
+
|
|
23
25
|
const segments: string[] = line.split(':');
|
|
26
|
+
const trimmedMessageType = segments[0]?.trim();
|
|
24
27
|
|
|
25
28
|
// Check for messages with no line information `ERROR: unsupported shader version`
|
|
26
29
|
if (segments.length === 2) {
|
|
27
30
|
const [messageType, message] = segments;
|
|
31
|
+
if (!messageType || !message) {
|
|
32
|
+
messages.push({
|
|
33
|
+
message: lineWithTrimmedWhitespace,
|
|
34
|
+
type: getMessageType(trimmedMessageType || 'info'),
|
|
35
|
+
lineNum: 0,
|
|
36
|
+
linePos: 0
|
|
37
|
+
});
|
|
38
|
+
continue; // eslint-disable-line no-continue
|
|
39
|
+
}
|
|
28
40
|
messages.push({
|
|
29
41
|
message: message.trim(),
|
|
30
42
|
type: getMessageType(messageType),
|
|
31
43
|
lineNum: 0,
|
|
32
44
|
linePos: 0
|
|
33
45
|
});
|
|
46
|
+
|
|
34
47
|
continue; // eslint-disable-line no-continue
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
const [messageType, linePosition, lineNumber, ...rest] = segments;
|
|
51
|
+
if (!messageType || !linePosition || !lineNumber) {
|
|
52
|
+
messages.push({
|
|
53
|
+
message: segments.slice(1).join(':').trim() || lineWithTrimmedWhitespace,
|
|
54
|
+
type: getMessageType(trimmedMessageType || 'info'),
|
|
55
|
+
lineNum: 0,
|
|
56
|
+
linePos: 0
|
|
57
|
+
});
|
|
58
|
+
continue; // eslint-disable-line no-continue
|
|
59
|
+
}
|
|
38
60
|
|
|
39
61
|
let lineNum = parseInt(lineNumber, 10);
|
|
40
|
-
if (isNaN(lineNum)) {
|
|
62
|
+
if (Number.isNaN(lineNum)) {
|
|
41
63
|
lineNum = 0;
|
|
42
64
|
}
|
|
43
65
|
|
|
44
66
|
let linePos = parseInt(linePosition, 10);
|
|
45
|
-
if (isNaN(linePos)) {
|
|
67
|
+
if (Number.isNaN(linePos)) {
|
|
46
68
|
linePos = 0;
|
|
47
69
|
}
|
|
48
70
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// Uniforms
|
|
8
8
|
import type {UniformValue} from '@luma.gl/core';
|
|
9
|
-
import {GL, GLUniformType, GLSamplerType} from '@luma.gl/constants';
|
|
9
|
+
import {GL, GLUniformType, GLSamplerType} from '@luma.gl/webgl/constants';
|
|
10
10
|
|
|
11
11
|
/** Set a raw uniform (without type conversion and caching) */
|
|
12
12
|
/* eslint-disable max-len */
|
|
@@ -28,7 +28,7 @@ export function setUniform(
|
|
|
28
28
|
}
|
|
29
29
|
const arrayValue = typeof uniformValue === 'number' ? [uniformValue] : uniformValue;
|
|
30
30
|
|
|
31
|
-
//
|
|
31
|
+
// biome-ignore format: preserve layout
|
|
32
32
|
switch (type) {
|
|
33
33
|
case GL.SAMPLER_2D:
|
|
34
34
|
case GL.SAMPLER_CUBE:
|