@luma.gl/webgl 9.1.0-alpha.9 → 9.1.0-beta.3
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 +3 -3
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +1 -0
- package/dist/adapter/converters/device-parameters.js.map +1 -0
- package/dist/adapter/converters/sampler-parameters.js +7 -4
- package/dist/adapter/converters/sampler-parameters.js.map +1 -0
- package/dist/adapter/converters/shader-formats.js +1 -0
- package/dist/adapter/converters/shader-formats.js.map +1 -0
- package/dist/adapter/converters/vertex-formats.js +1 -0
- package/dist/adapter/converters/vertex-formats.js.map +1 -0
- package/dist/adapter/converters/webgl-texture-table.d.ts +40 -0
- package/dist/adapter/converters/webgl-texture-table.d.ts.map +1 -0
- package/dist/adapter/converters/webgl-texture-table.js +304 -0
- package/dist/adapter/converters/webgl-texture-table.js.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +2 -2
- package/dist/adapter/device-helpers/webgl-device-features.js.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js.map +1 -0
- package/dist/adapter/helpers/decode-webgl-types.js +1 -0
- package/dist/adapter/helpers/decode-webgl-types.js.map +1 -0
- package/dist/adapter/helpers/format-utils.d.ts.map +1 -0
- package/dist/{classic → adapter/helpers}/format-utils.js +7 -0
- package/dist/adapter/helpers/format-utils.js.map +1 -0
- 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 +5 -4
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js +1 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -0
- package/dist/adapter/helpers/set-uniform.js +1 -0
- package/dist/adapter/helpers/set-uniform.js.map +1 -0
- package/dist/adapter/helpers/typed-array-utils.d.ts.map +1 -0
- package/dist/{classic → adapter/helpers}/typed-array-utils.js +1 -0
- package/dist/adapter/helpers/typed-array-utils.js.map +1 -0
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +96 -25
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +225 -236
- package/dist/adapter/helpers/webgl-texture-utils.js.map +1 -0
- package/dist/adapter/helpers/webgl-topology-utils.js +1 -0
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -0
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +4 -1
- package/dist/adapter/resources/webgl-buffer.js.map +1 -0
- package/dist/adapter/resources/webgl-command-buffer.d.ts +59 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +89 -32
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -0
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -0
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -0
- package/dist/adapter/resources/webgl-external-texture.js +15 -0
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -0
- package/dist/adapter/resources/webgl-framebuffer.d.ts +33 -35
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +70 -75
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -0
- package/dist/adapter/resources/webgl-query-set.js +1 -0
- package/dist/adapter/resources/webgl-query-set.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +33 -18
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +3 -4
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +44 -22
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgl-sampler.js +1 -0
- package/dist/adapter/resources/webgl-sampler.js.map +1 -0
- package/dist/adapter/resources/webgl-shader.d.ts +1 -0
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +13 -6
- package/dist/adapter/resources/webgl-shader.js.map +1 -0
- package/dist/adapter/resources/webgl-texture-view.js +1 -0
- package/dist/adapter/resources/webgl-texture-view.js.map +1 -0
- package/dist/adapter/resources/webgl-texture.d.ts +32 -20
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +163 -218
- package/dist/adapter/resources/webgl-texture.js.map +1 -0
- package/dist/adapter/resources/webgl-transform-feedback.js +1 -0
- package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -0
- package/dist/adapter/resources/webgl-vertex-array.js +1 -0
- package/dist/adapter/resources/webgl-vertex-array.js.map +1 -0
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +5 -10
- package/dist/adapter/webgl-adapter.js.map +1 -0
- package/dist/adapter/webgl-canvas-context.d.ts +4 -6
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +13 -17
- package/dist/adapter/webgl-canvas-context.js.map +1 -0
- package/dist/adapter/webgl-device.d.ts +20 -19
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +75 -51
- package/dist/adapter/webgl-device.js.map +1 -0
- package/dist/context/debug/spector-types.js +2 -1
- package/dist/context/debug/spector-types.js.map +1 -0
- package/dist/context/debug/spector.d.ts +5 -5
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +7 -6
- package/dist/context/debug/spector.js.map +1 -0
- package/dist/context/debug/webgl-developer-tools.d.ts +2 -3
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -19
- package/dist/context/debug/webgl-developer-tools.js.map +1 -0
- package/dist/context/helpers/create-browser-context.d.ts +6 -22
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
- package/dist/context/helpers/create-browser-context.js +41 -32
- package/dist/context/helpers/create-browser-context.js.map +1 -0
- package/dist/context/helpers/webgl-context-data.js +1 -0
- package/dist/context/helpers/webgl-context-data.js.map +1 -0
- package/dist/context/helpers/webgl-extensions.js +1 -0
- package/dist/context/helpers/webgl-extensions.js.map +1 -0
- package/dist/context/parameters/unified-parameter-api.js +1 -0
- package/dist/context/parameters/unified-parameter-api.js.map +1 -0
- 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 +3 -2
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js.map +1 -0
- package/dist/context/state-tracker/deep-array-equal.js +1 -0
- package/dist/context/state-tracker/deep-array-equal.js.map +1 -0
- package/dist/context/state-tracker/webgl-state-tracker.js +1 -0
- package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -0
- package/dist/context/state-tracker/with-parameters.js +1 -0
- package/dist/context/state-tracker/with-parameters.js.map +1 -0
- package/dist/deprecated/accessor.d.ts.map +1 -0
- package/dist/{classic → deprecated}/accessor.js +37 -1
- package/dist/deprecated/accessor.js.map +1 -0
- package/dist/dist.dev.js +2234 -2373
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +2124 -2256
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/fill-array.d.ts +4 -4
- package/dist/utils/fill-array.d.ts.map +1 -1
- package/dist/utils/fill-array.js +1 -0
- package/dist/utils/fill-array.js.map +1 -0
- package/dist/utils/load-script.js +1 -0
- package/dist/utils/load-script.js.map +1 -0
- package/dist/utils/split-uniforms-and-bindings.d.ts +1 -1
- package/dist/utils/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/utils/split-uniforms-and-bindings.js +1 -0
- package/dist/utils/split-uniforms-and-bindings.js.map +1 -0
- package/dist/utils/uid.js +1 -0
- package/dist/utils/uid.js.map +1 -0
- package/package.json +5 -5
- package/src/adapter/converters/device-parameters.ts +3 -3
- package/src/adapter/converters/sampler-parameters.ts +6 -4
- package/src/adapter/converters/webgl-texture-table.ts +404 -0
- package/src/adapter/device-helpers/webgl-device-features.ts +5 -2
- package/src/{classic → adapter/helpers}/format-utils.ts +6 -0
- package/src/adapter/helpers/get-shader-layout.ts +7 -4
- package/src/adapter/helpers/webgl-texture-utils.ts +400 -57
- package/src/adapter/resources/webgl-buffer.ts +3 -1
- package/src/adapter/resources/webgl-command-buffer.ts +125 -41
- package/src/adapter/resources/webgl-command-encoder.ts +6 -0
- package/src/adapter/resources/webgl-external-texture.ts +14 -0
- package/src/adapter/resources/webgl-framebuffer.ts +79 -85
- package/src/adapter/resources/webgl-render-pass.ts +56 -42
- package/src/adapter/resources/webgl-render-pipeline.ts +56 -26
- package/src/adapter/resources/webgl-shader.ts +15 -7
- package/src/adapter/resources/webgl-texture.ts +188 -250
- package/src/adapter/webgl-adapter.ts +4 -12
- package/src/adapter/webgl-canvas-context.ts +16 -19
- package/src/adapter/webgl-device.ts +125 -88
- package/src/context/debug/spector-types.ts +1 -1
- package/src/context/debug/spector.ts +11 -11
- package/src/context/debug/webgl-developer-tools.ts +8 -31
- package/src/context/helpers/create-browser-context.ts +53 -63
- package/src/context/parameters/webgl-parameter-tables.ts +2 -2
- package/src/{classic → deprecated}/accessor.ts +44 -3
- package/src/index.ts +2 -5
- package/src/utils/fill-array.ts +4 -4
- package/src/utils/split-uniforms-and-bindings.ts +3 -3
- package/dist/adapter/converters/texture-formats.d.ts +0 -83
- package/dist/adapter/converters/texture-formats.d.ts.map +0 -1
- package/dist/adapter/converters/texture-formats.js +0 -511
- package/dist/classic/accessor.d.ts.map +0 -1
- package/dist/classic/clear.d.ts +0 -22
- package/dist/classic/clear.d.ts.map +0 -1
- package/dist/classic/clear.js +0 -86
- package/dist/classic/copy-and-blit.d.ts +0 -64
- package/dist/classic/copy-and-blit.d.ts.map +0 -1
- package/dist/classic/copy-and-blit.js +0 -194
- package/dist/classic/format-utils.d.ts.map +0 -1
- package/dist/classic/typed-array-utils.d.ts.map +0 -1
- package/src/adapter/converters/texture-formats.ts +0 -657
- package/src/classic/clear.ts +0 -115
- package/src/classic/copy-and-blit.ts +0 -323
- /package/dist/{classic → adapter/helpers}/format-utils.d.ts +0 -0
- /package/dist/{classic → adapter/helpers}/typed-array-utils.d.ts +0 -0
- /package/dist/{classic → deprecated}/accessor.d.ts +0 -0
- /package/src/{classic → adapter/helpers}/typed-array-utils.ts +0 -0
|
@@ -5,37 +5,13 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* ContextProps
|
|
7
7
|
* @param onContextLost
|
|
8
|
-
* @param onContextRestored
|
|
9
|
-
*
|
|
10
|
-
* BROWSER CONTEXT PARAMETERS
|
|
11
|
-
* @param debug Instrument context (at the expense of performance).
|
|
12
|
-
* @param alpha Default render target has an alpha buffer.
|
|
13
|
-
* @param depth Default render target has a depth buffer of at least 16 bits.
|
|
14
|
-
* @param stencil Default render target has a stencil buffer of at least 8 bits.
|
|
15
|
-
* @param antialias Boolean that indicates whether or not to perform anti-aliasing.
|
|
16
|
-
* @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.
|
|
17
|
-
* @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten
|
|
18
|
-
* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.
|
|
8
|
+
* @param onContextRestored *
|
|
19
9
|
*/
|
|
20
10
|
type ContextProps = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
antialias?: boolean; // indicates whether or not to perform anti-aliasing.
|
|
26
|
-
depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.
|
|
27
|
-
failIfMajorPerformanceCaveat?: boolean; // indicates if a context will be created if the system performance is low or if no hardware GPU is available.
|
|
28
|
-
powerPreference?: 'default' | 'high-performance' | 'low-power';
|
|
29
|
-
premultipliedAlpha?: boolean; // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.
|
|
30
|
-
preserveDrawingBuffer?: boolean; // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const DEFAULT_CONTEXT_PROPS: ContextProps = {
|
|
34
|
-
powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons
|
|
35
|
-
// eslint-disable-next-line no-console
|
|
36
|
-
onContextLost: () => console.error('WebGL context lost'),
|
|
37
|
-
// eslint-disable-next-line no-console
|
|
38
|
-
onContextRestored: () => console.info('WebGL context restored')
|
|
11
|
+
/** Called when a context is lost */
|
|
12
|
+
onContextLost: (event: Event) => void;
|
|
13
|
+
/** Called when a context is restored */
|
|
14
|
+
onContextRestored: (event: Event) => void;
|
|
39
15
|
};
|
|
40
16
|
|
|
41
17
|
/**
|
|
@@ -45,53 +21,67 @@ const DEFAULT_CONTEXT_PROPS: ContextProps = {
|
|
|
45
21
|
*/
|
|
46
22
|
export function createBrowserContext(
|
|
47
23
|
canvas: HTMLCanvasElement | OffscreenCanvas,
|
|
48
|
-
props: ContextProps
|
|
24
|
+
props: ContextProps,
|
|
25
|
+
webglContextAttributes: WebGLContextAttributes
|
|
49
26
|
): WebGL2RenderingContext {
|
|
50
|
-
props = {...DEFAULT_CONTEXT_PROPS, ...props};
|
|
51
|
-
|
|
52
27
|
// Try to extract any extra information about why context creation failed
|
|
53
|
-
let errorMessage =
|
|
54
|
-
const onCreateError = error => (errorMessage = error.statusMessage || errorMessage);
|
|
55
|
-
canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
|
|
56
|
-
|
|
57
|
-
// Create the desired context
|
|
58
|
-
let gl: WebGL2RenderingContext | null = null;
|
|
28
|
+
let errorMessage = '';
|
|
29
|
+
// const onCreateError = error => (errorMessage = error.statusMessage || errorMessage);
|
|
59
30
|
|
|
60
|
-
//
|
|
31
|
+
// Avoid multiple listeners?
|
|
32
|
+
// canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);
|
|
33
|
+
// canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
|
|
61
34
|
|
|
62
|
-
|
|
63
|
-
|
|
35
|
+
const webglProps: WebGLContextAttributes = {
|
|
36
|
+
preserveDrawingBuffer: true,
|
|
37
|
+
// failIfMajorPerformanceCaveat: true,
|
|
38
|
+
...webglContextAttributes
|
|
39
|
+
};
|
|
64
40
|
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
// props.failIfMajorPerformanceCaveat = false;
|
|
41
|
+
// Create the desired context
|
|
42
|
+
let gl: WebGL2RenderingContext | null = null;
|
|
68
43
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
44
|
+
// Create a webgl2 context
|
|
45
|
+
gl ||= canvas.getContext('webgl2', webglProps);
|
|
46
|
+
if (webglProps.failIfMajorPerformanceCaveat) {
|
|
47
|
+
errorMessage ||=
|
|
48
|
+
'Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.';
|
|
49
|
+
}
|
|
72
50
|
|
|
73
|
-
//
|
|
74
|
-
|
|
51
|
+
// Creation failed with failIfMajorPerformanceCaveat - Try a Software GPU
|
|
52
|
+
if (!gl && !webglContextAttributes.failIfMajorPerformanceCaveat) {
|
|
53
|
+
webglProps.failIfMajorPerformanceCaveat = false;
|
|
54
|
+
gl = canvas.getContext('webgl2', webglProps);
|
|
55
|
+
// @ts-expect-error
|
|
56
|
+
gl.luma ||= {};
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
gl.luma.softwareRenderer = true;
|
|
59
|
+
}
|
|
75
60
|
|
|
76
61
|
if (!gl) {
|
|
77
|
-
|
|
62
|
+
gl = canvas.getContext('webgl', {}) as WebGL2RenderingContext;
|
|
63
|
+
if (gl) {
|
|
64
|
+
gl = null;
|
|
65
|
+
errorMessage ||= 'Your browser only supports WebGL1';
|
|
66
|
+
}
|
|
78
67
|
}
|
|
79
68
|
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
canvas.addEventListener('webglcontextlost', (event: Event) => onContextLost(event), false);
|
|
84
|
-
}
|
|
85
|
-
if (props.onContextRestored) {
|
|
86
|
-
// Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.
|
|
87
|
-
const {onContextRestored} = props;
|
|
88
|
-
canvas.addEventListener(
|
|
89
|
-
'webglcontextrestored',
|
|
90
|
-
(event: Event) => onContextRestored(event),
|
|
91
|
-
false
|
|
92
|
-
);
|
|
69
|
+
if (!gl) {
|
|
70
|
+
errorMessage ||= 'Your browser does not support WebGL';
|
|
71
|
+
throw new Error(`Failed to create WebGL context: ${errorMessage}`);
|
|
93
72
|
}
|
|
94
73
|
|
|
74
|
+
// Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.
|
|
75
|
+
const {onContextLost, onContextRestored} = props;
|
|
76
|
+
canvas.addEventListener('webglcontextlost', (event: Event) => onContextLost(event), false);
|
|
77
|
+
canvas.addEventListener(
|
|
78
|
+
'webglcontextrestored',
|
|
79
|
+
(event: Event) => onContextRestored(event),
|
|
80
|
+
false
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// @ts-expect-error
|
|
84
|
+
gl.luma ||= {};
|
|
95
85
|
return gl;
|
|
96
86
|
}
|
|
97
87
|
|
|
@@ -412,9 +412,9 @@ export const GL_HOOKED_SETTERS = {
|
|
|
412
412
|
update({
|
|
413
413
|
[pname]: value
|
|
414
414
|
}),
|
|
415
|
-
hint: (update: UpdateFunc, pname: GL,
|
|
415
|
+
hint: (update: UpdateFunc, pname: GL, value: GL) =>
|
|
416
416
|
update({
|
|
417
|
-
[pname]:
|
|
417
|
+
[pname]: value
|
|
418
418
|
}),
|
|
419
419
|
|
|
420
420
|
// SPECIFIC SETTERS
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {Buffer} from '@luma.gl/core';
|
|
6
|
-
import {GL} from '@luma.gl/constants';
|
|
7
|
-
import {
|
|
5
|
+
import {Buffer, log} from '@luma.gl/core';
|
|
6
|
+
import {GL, GLDataType, GLPixelType} from '@luma.gl/constants';
|
|
7
|
+
import {TypedArrayConstructor} from '@math.gl/types';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Attribute descriptor object
|
|
@@ -81,6 +81,7 @@ export class Accessor implements AccessorObject {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
constructor(...accessors: AccessorObject[]) {
|
|
84
|
+
log.warn('Accessor will be removed in next minor release');
|
|
84
85
|
accessors.forEach(accessor => this._assign(accessor)); // Merge in sequence
|
|
85
86
|
Object.freeze(this);
|
|
86
87
|
}
|
|
@@ -180,5 +181,45 @@ export class Accessor implements AccessorObject {
|
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Converts GL constant to corresponding TYPED ARRAY
|
|
186
|
+
* Used to auto deduce gl parameter types
|
|
187
|
+
* @deprecated Use getTypedArrayFromDataType
|
|
188
|
+
* @param glType
|
|
189
|
+
* @param param1
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
192
|
+
// eslint-disable-next-line complexity
|
|
193
|
+
function getTypedArrayFromGLType(
|
|
194
|
+
glType: GLDataType | GLPixelType,
|
|
195
|
+
options?: {
|
|
196
|
+
clamped?: boolean;
|
|
197
|
+
}
|
|
198
|
+
): TypedArrayConstructor {
|
|
199
|
+
const {clamped = true} = options || {};
|
|
200
|
+
// Sorted in some order of likelihood to reduce amount of comparisons
|
|
201
|
+
switch (glType) {
|
|
202
|
+
case GL.FLOAT:
|
|
203
|
+
return Float32Array;
|
|
204
|
+
case GL.UNSIGNED_SHORT:
|
|
205
|
+
case GL.UNSIGNED_SHORT_5_6_5:
|
|
206
|
+
case GL.UNSIGNED_SHORT_4_4_4_4:
|
|
207
|
+
case GL.UNSIGNED_SHORT_5_5_5_1:
|
|
208
|
+
return Uint16Array;
|
|
209
|
+
case GL.UNSIGNED_INT:
|
|
210
|
+
return Uint32Array;
|
|
211
|
+
case GL.UNSIGNED_BYTE:
|
|
212
|
+
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
213
|
+
case GL.BYTE:
|
|
214
|
+
return Int8Array;
|
|
215
|
+
case GL.SHORT:
|
|
216
|
+
return Int16Array;
|
|
217
|
+
case GL.INT:
|
|
218
|
+
return Int32Array;
|
|
219
|
+
default:
|
|
220
|
+
throw new Error('Failed to deduce typed array type from GL constant');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
183
224
|
// TEST EXPORTS
|
|
184
225
|
export {DEFAULT_ACCESSOR_VALUES};
|
package/src/index.ts
CHANGED
|
@@ -38,7 +38,7 @@ export {WEBGLVertexArray} from './adapter/resources/webgl-vertex-array';
|
|
|
38
38
|
export {WEBGLTransformFeedback} from './adapter/resources/webgl-transform-feedback';
|
|
39
39
|
|
|
40
40
|
// WebGL adapter classes
|
|
41
|
-
export {Accessor} from './
|
|
41
|
+
export {Accessor} from './deprecated/accessor';
|
|
42
42
|
export type {AccessorObject} from './types';
|
|
43
43
|
|
|
44
44
|
// Unified parameter API
|
|
@@ -46,12 +46,9 @@ export type {AccessorObject} from './types';
|
|
|
46
46
|
export {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';
|
|
47
47
|
|
|
48
48
|
// HELPERS - EXPERIMENTAL
|
|
49
|
-
export {
|
|
49
|
+
export {getShaderLayoutFromGLSL} from './adapter/helpers/get-shader-layout';
|
|
50
50
|
export {WebGLStateTracker} from './context/state-tracker/webgl-state-tracker';
|
|
51
51
|
|
|
52
|
-
// TEST EXPORTS
|
|
53
|
-
export {TEXTURE_FORMATS as _TEXTURE_FORMATS} from './adapter/converters/texture-formats';
|
|
54
|
-
|
|
55
52
|
// DEPRECATED TEST EXPORTS
|
|
56
53
|
export {
|
|
57
54
|
resetGLParameters,
|
package/src/utils/fill-array.ts
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {NumericArray} from '@math.gl/types';
|
|
6
6
|
|
|
7
7
|
// Uses copyWithin to significantly speed up typed array value filling
|
|
8
8
|
export function fillArray(options: {
|
|
9
|
-
target:
|
|
10
|
-
source:
|
|
9
|
+
target: NumericArray;
|
|
10
|
+
source: NumericArray;
|
|
11
11
|
start?: number;
|
|
12
12
|
count?: number;
|
|
13
|
-
}):
|
|
13
|
+
}): NumericArray {
|
|
14
14
|
const {target, source, start = 0, count = 1} = options;
|
|
15
15
|
const length = source.length;
|
|
16
16
|
const total = count * length;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type {UniformValue, Binding} from '@luma.gl/core';
|
|
6
6
|
import {isNumericArray} from '@math.gl/types';
|
|
7
7
|
|
|
8
|
-
export function isUniformValue(value: unknown):
|
|
8
|
+
export function isUniformValue(value: unknown): value is UniformValue {
|
|
9
9
|
return isNumericArray(value) !== null || typeof value === 'number' || typeof value === 'boolean';
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -21,9 +21,9 @@ export function splitUniformsAndBindings(
|
|
|
21
21
|
Object.keys(uniforms).forEach(name => {
|
|
22
22
|
const uniform = uniforms[name];
|
|
23
23
|
if (isUniformValue(uniform)) {
|
|
24
|
-
result.uniforms[name] = uniform
|
|
24
|
+
result.uniforms[name] = uniform;
|
|
25
25
|
} else {
|
|
26
|
-
result.bindings[name] = uniform
|
|
26
|
+
result.bindings[name] = uniform;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { TextureFormat, DeviceFeature } from '@luma.gl/core';
|
|
2
|
-
import { GL, GLPixelType, GLExtensions, GLTexelDataFormat } from '@luma.gl/constants';
|
|
3
|
-
export declare const TEXTURE_FEATURES: Partial<Record<DeviceFeature, string[]>>;
|
|
4
|
-
/** Return a list of texture feature strings (for Device.features). Mainly compressed texture support */
|
|
5
|
-
export declare function isTextureFeature(feature: DeviceFeature): boolean;
|
|
6
|
-
/** Checks a texture feature (for Device.features). Mainly compressed texture support */
|
|
7
|
-
export declare function checkTextureFeature(gl: WebGL2RenderingContext, feature: DeviceFeature, extensions: GLExtensions): boolean;
|
|
8
|
-
/** Map a format to webgl and constants */
|
|
9
|
-
type Format = {
|
|
10
|
-
gl?: GL;
|
|
11
|
-
/** format requires WebGL2, when using a WebGL 1 context, color renderbuffer formats are limited */
|
|
12
|
-
gl2ext?: string;
|
|
13
|
-
/** (bytes per pixel), for memory usage calculations. */
|
|
14
|
-
b?: number;
|
|
15
|
-
/** channels */
|
|
16
|
-
c?: number;
|
|
17
|
-
bpp?: number;
|
|
18
|
-
/** packed */
|
|
19
|
-
p?: number;
|
|
20
|
-
/** compressed */
|
|
21
|
-
x?: string;
|
|
22
|
-
/** for compressed texture formats */
|
|
23
|
-
f?: DeviceFeature;
|
|
24
|
-
/** renderable if feature is present */
|
|
25
|
-
render?: DeviceFeature;
|
|
26
|
-
/** filterable if feature is present */
|
|
27
|
-
filter?: DeviceFeature;
|
|
28
|
-
/** If not supported on WebGPU */
|
|
29
|
-
wgpu?: false;
|
|
30
|
-
types?: GLPixelType[];
|
|
31
|
-
dataFormat?: GLTexelDataFormat;
|
|
32
|
-
/** Depth and stencil format attachment points. If set, needs to be a Renderbuffer unless depthTexture is set */
|
|
33
|
-
attachment?: GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
|
|
34
|
-
/** if depthTexture is set this is a depth/stencil format that can be set to a texture */
|
|
35
|
-
depthTexture?: boolean;
|
|
36
|
-
/** @deprecated can this format be used with renderbuffers */
|
|
37
|
-
rb?: boolean;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Texture format data -
|
|
41
|
-
* Exported but can change without notice
|
|
42
|
-
*/
|
|
43
|
-
export declare const TEXTURE_FORMATS: Record<TextureFormat, Format>;
|
|
44
|
-
/** Checks if a texture format is supported */
|
|
45
|
-
export declare function isTextureFormatSupported(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
|
|
46
|
-
export declare function isRenderbufferFormatSupported(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
|
|
47
|
-
/** Checks if a texture format is supported */
|
|
48
|
-
export declare function getTextureFormatSupport(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): {
|
|
49
|
-
supported: boolean;
|
|
50
|
-
filterable?: boolean;
|
|
51
|
-
renderable?: boolean;
|
|
52
|
-
blendable?: boolean;
|
|
53
|
-
storable?: boolean;
|
|
54
|
-
};
|
|
55
|
-
/** Checks whether linear filtering (interpolated sampling) is available for floating point textures */
|
|
56
|
-
export declare function isTextureFormatFilterable(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
|
|
57
|
-
export declare function isTextureFormatRenderable(gl: WebGL2RenderingContext, format: TextureFormat, extensions: GLExtensions): boolean;
|
|
58
|
-
/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
|
|
59
|
-
export declare function getTextureFormatWebGL(format: TextureFormat): {
|
|
60
|
-
internalFormat: GL;
|
|
61
|
-
format: GLTexelDataFormat;
|
|
62
|
-
type: GLPixelType;
|
|
63
|
-
compressed: boolean;
|
|
64
|
-
};
|
|
65
|
-
export declare function getDepthStencilAttachmentWebGL(format: TextureFormat): GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
|
|
66
|
-
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
67
|
-
export declare function getTextureFormatBytesPerPixel(format: TextureFormat): number;
|
|
68
|
-
export declare function getWebGLPixelDataFormat(channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra', integer: boolean, normalized: boolean, format: GL): GLTexelDataFormat;
|
|
69
|
-
export {};
|
|
70
|
-
/**
|
|
71
|
-
* Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
|
|
72
|
-
export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
|
|
73
|
-
if (typeof format === 'string') {
|
|
74
|
-
return format;
|
|
75
|
-
}
|
|
76
|
-
const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
|
|
77
|
-
if (!entry) {
|
|
78
|
-
throw new Error(`Unknown texture format ${format}`);
|
|
79
|
-
}
|
|
80
|
-
return entry[0] as TextureFormat;
|
|
81
|
-
}
|
|
82
|
-
*/
|
|
83
|
-
//# sourceMappingURL=texture-formats.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"texture-formats.d.ts","sourceRoot":"","sources":["../../../src/adapter/converters/texture-formats.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAC,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AA2CpF,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAA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