@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.7
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 +128 -71
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +20 -19
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +40 -20
- package/dist/adapter/converters/texture-formats.d.ts +16 -11
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +224 -205
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +22 -21
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +89 -43
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +22 -19
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +47 -46
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +35 -34
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +42 -41
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +40 -39
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +30 -17
- package/dist/adapter/objects/webgl-resource.d.ts +2 -24
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -101
- 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 +16 -15
- 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 +32 -31
- package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -2
- package/dist/adapter/resources/webgl-external-texture.js +6 -5
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -10
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +60 -53
- 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 +20 -12
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +52 -61
- 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 +5 -4
- package/dist/adapter/resources/webgl-shader.d.ts +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +15 -9
- 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 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +39 -32
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +10 -10
- 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 +10 -9
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +3 -2
- package/dist/adapter/webgl-device.d.ts +35 -30
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +110 -109
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +8 -7
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +5 -4
- 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 +19 -19
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +16 -15
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +20 -19
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -6
- package/dist/context/{context → helpers}/create-browser-context.d.ts.map +1 -1
- package/dist/context/{context → helpers}/create-browser-context.js +2 -1
- package/dist/context/{context/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -3
- 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 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +7 -11
- package/dist/context/parameters/webgl-parameter-tables.d.ts +12 -13
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +302 -295
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +2 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -4
- package/dist/context/state-tracker/with-parameters.d.ts +2 -3
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +6 -8
- package/dist/dist.dev.js +1635 -1387
- package/dist/index.cjs +1766 -1534
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +25 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist.min.js +6 -6
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +114 -27
- package/src/adapter/converters/sampler-parameters.ts +12 -3
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +138 -114
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +102 -50
- package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
- package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +4 -3
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +2 -1
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +2 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +36 -14
- package/src/adapter/objects/webgl-resource.ts +7 -125
- package/src/adapter/resources/webgl-buffer.ts +4 -3
- package/src/adapter/resources/webgl-command-buffer.ts +5 -5
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +6 -5
- package/src/adapter/resources/webgl-framebuffer.ts +61 -53
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +20 -11
- package/src/adapter/resources/webgl-render-pipeline.ts +54 -54
- package/src/adapter/resources/webgl-sampler.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +12 -5
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +14 -3
- package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-canvas-context.ts +6 -4
- package/src/adapter/webgl-device.ts +116 -107
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +14 -8
- package/src/classic/copy-and-blit.ts +11 -4
- package/src/classic/format-utils.ts +2 -1
- package/src/classic/typed-array-utils.ts +3 -7
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +27 -14
- package/src/context/{context → helpers}/create-browser-context.ts +3 -2
- package/src/context/helpers/webgl-context-data.ts +31 -0
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +6 -17
- package/src/context/parameters/webgl-parameter-tables.ts +69 -32
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +11 -6
- package/src/context/state-tracker/with-parameters.ts +8 -8
- package/src/index.ts +7 -6
- package/src/types.ts +2 -1
- package/dist/adapter/device-helpers/device-features.d.ts +0 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-features.js +0 -65
- package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
- package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js +0 -92
- package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js +0 -87
- package/dist/context/context/context-data.d.ts.map +0 -1
- package/dist/context/context/context-data.js +0 -33
- package/src/context/context/context-data.ts +0 -44
- /package/dist/context/{context → helpers}/create-browser-context.d.ts +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {log, loadScript} from '@luma.gl/core';
|
|
5
6
|
// Rename constant to prevent inlining. We need the full set of constants for generating debug strings.
|
|
6
7
|
import {GL as GLEnum} from '@luma.gl/constants';
|
|
7
|
-
import {isBrowser} from '@probe.gl/env'
|
|
8
|
+
import {isBrowser} from '@probe.gl/env';
|
|
8
9
|
|
|
9
10
|
const WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';
|
|
10
11
|
|
|
@@ -24,10 +25,10 @@ type DebugContextProps = {
|
|
|
24
25
|
type ContextData = {
|
|
25
26
|
realContext?: WebGL2RenderingContext;
|
|
26
27
|
debugContext?: WebGL2RenderingContext;
|
|
27
|
-
}
|
|
28
|
+
};
|
|
28
29
|
|
|
29
30
|
// Helper to get shared context data
|
|
30
|
-
function
|
|
31
|
+
function getWebGLContextData(gl: any): ContextData {
|
|
31
32
|
gl.luma = gl.luma || {};
|
|
32
33
|
return gl.luma;
|
|
33
34
|
}
|
|
@@ -38,7 +39,7 @@ declare global {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
|
-
* Loads Khronos WebGLDeveloperTools from CDN if not already installed
|
|
42
|
+
* Loads Khronos WebGLDeveloperTools from CDN if not already installed
|
|
42
43
|
* const WebGLDebugUtils = require('webgl-debug');
|
|
43
44
|
* @see https://github.com/KhronosGroup/WebGLDeveloperTools
|
|
44
45
|
* @see https://github.com/vorg/webgl-debug
|
|
@@ -54,7 +55,10 @@ export async function loadWebGLDeveloperTools(): Promise<void> {
|
|
|
54
55
|
|
|
55
56
|
// Returns (a potentially new) context with debug instrumentation turned off or on.
|
|
56
57
|
// Note that this actually returns a new context
|
|
57
|
-
export function makeDebugContext(
|
|
58
|
+
export function makeDebugContext(
|
|
59
|
+
gl: WebGL2RenderingContext,
|
|
60
|
+
props: DebugContextProps = {}
|
|
61
|
+
): WebGL2RenderingContext | null {
|
|
58
62
|
// Return null to ensure we don't try to create a context in this case (TODO what case is that?)
|
|
59
63
|
if (!gl) {
|
|
60
64
|
return null;
|
|
@@ -65,19 +69,22 @@ export function makeDebugContext(gl: WebGL2RenderingContext, props: DebugContext
|
|
|
65
69
|
|
|
66
70
|
// Returns the real context from either of the real/debug contexts
|
|
67
71
|
function getRealContext(gl: WebGL2RenderingContext): WebGL2RenderingContext {
|
|
68
|
-
const data =
|
|
72
|
+
const data = getWebGLContextData(gl);
|
|
69
73
|
// If the context has a realContext member, it is a debug context so return the realContext
|
|
70
74
|
return data.realContext ? data.realContext : gl;
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
// Returns the debug context from either of the real/debug contexts
|
|
74
|
-
function getDebugContext(
|
|
78
|
+
function getDebugContext(
|
|
79
|
+
gl: WebGL2RenderingContext,
|
|
80
|
+
props: DebugContextProps
|
|
81
|
+
): WebGL2RenderingContext {
|
|
75
82
|
if (!globalThis.WebGLDebugUtils) {
|
|
76
83
|
log.warn('webgl-debug not loaded')();
|
|
77
84
|
return gl;
|
|
78
85
|
}
|
|
79
86
|
|
|
80
|
-
const data =
|
|
87
|
+
const data = getWebGLContextData(gl);
|
|
81
88
|
|
|
82
89
|
// If this already has a debug context, return it.
|
|
83
90
|
if (data.debugContext) {
|
|
@@ -98,7 +105,7 @@ function getDebugContext(gl: WebGL2RenderingContext, props: DebugContextProps):
|
|
|
98
105
|
glDebug[key] = GLEnum[key];
|
|
99
106
|
}
|
|
100
107
|
}
|
|
101
|
-
|
|
108
|
+
|
|
102
109
|
// Ensure we have a clean prototype on the instrumented object
|
|
103
110
|
// Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction
|
|
104
111
|
// by synchronizing the WebGL errors after each WebGL call.
|
|
@@ -119,7 +126,7 @@ function getDebugContext(gl: WebGL2RenderingContext, props: DebugContextProps):
|
|
|
119
126
|
|
|
120
127
|
function getFunctionString(functionName: string, functionArgs): string {
|
|
121
128
|
// Cover bug in webgl-debug-tools
|
|
122
|
-
functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);
|
|
129
|
+
functionArgs = Array.from(functionArgs).map(arg => (arg === undefined ? 'undefined' : arg));
|
|
123
130
|
let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);
|
|
124
131
|
args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;
|
|
125
132
|
return `gl.${functionName}(${args})`;
|
|
@@ -127,7 +134,7 @@ function getFunctionString(functionName: string, functionArgs): string {
|
|
|
127
134
|
|
|
128
135
|
function onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {
|
|
129
136
|
// Cover bug in webgl-debug-tools
|
|
130
|
-
args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);
|
|
137
|
+
args = Array.from(args).map(arg => (arg === undefined ? 'undefined' : arg));
|
|
131
138
|
const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
|
|
132
139
|
const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
133
140
|
const message = `${errorMessage} in gl.${functionName}(${functionArgs})`;
|
|
@@ -139,7 +146,11 @@ function onGLError(props: DebugContextProps, err, functionName: string, args: an
|
|
|
139
146
|
}
|
|
140
147
|
|
|
141
148
|
// Don't generate function string until it is needed
|
|
142
|
-
function onValidateGLFunc(
|
|
149
|
+
function onValidateGLFunc(
|
|
150
|
+
props: DebugContextProps,
|
|
151
|
+
functionName: string,
|
|
152
|
+
functionArgs: any[]
|
|
153
|
+
): void {
|
|
143
154
|
let functionString: string = '';
|
|
144
155
|
if (log.level >= 1) {
|
|
145
156
|
functionString = getFunctionString(functionName, functionArgs);
|
|
@@ -149,7 +160,9 @@ function onValidateGLFunc(props: DebugContextProps, functionName: string, functi
|
|
|
149
160
|
// If array of breakpoint strings supplied, check if any of them is contained in current GLEnum function
|
|
150
161
|
if (props.break && props.break.length > 0) {
|
|
151
162
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
152
|
-
const isBreakpoint = props.break.every(
|
|
163
|
+
const isBreakpoint = props.break.every(
|
|
164
|
+
(breakOn: string) => functionString.indexOf(breakOn) !== -1
|
|
165
|
+
);
|
|
153
166
|
if (isBreakpoint) {
|
|
154
167
|
debugger; // eslint-disable-line
|
|
155
168
|
}
|
|
@@ -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
|
/**
|
|
@@ -64,7 +65,7 @@ export function createBrowserContext(
|
|
|
64
65
|
// Software GPU
|
|
65
66
|
|
|
66
67
|
// props.failIfMajorPerformanceCaveat = false;
|
|
67
|
-
|
|
68
|
+
|
|
68
69
|
// if (!gl && props.webgl1) {
|
|
69
70
|
// gl = canvas.getContext('webgl', props);
|
|
70
71
|
// }
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Stores luma.gl specific state associated with a context
|
|
7
|
+
*/
|
|
8
|
+
export interface WebGLContextData {
|
|
9
|
+
_polyfilled: boolean;
|
|
10
|
+
_extensions: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Gets luma.gl specific state from a context
|
|
15
|
+
* @returns context state
|
|
16
|
+
*/
|
|
17
|
+
export function getWebGLContextData(gl: WebGL2RenderingContext): WebGLContextData {
|
|
18
|
+
// @ts-expect-error
|
|
19
|
+
const luma = gl.luma as WebGLContextData | null;
|
|
20
|
+
if (!luma) {
|
|
21
|
+
const contextState: WebGLContextData = {
|
|
22
|
+
_polyfilled: false,
|
|
23
|
+
_extensions: {}
|
|
24
|
+
};
|
|
25
|
+
// @ts-expect-error
|
|
26
|
+
gl.luma = contextState;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// @ts-expect-error
|
|
30
|
+
return gl.luma;
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {GLExtensions} from '@luma.gl/constants';
|
|
6
|
+
|
|
7
|
+
/** Ensure extensions are only requested once */
|
|
8
|
+
export function getWebGLExtension(
|
|
9
|
+
gl: WebGL2RenderingContext,
|
|
10
|
+
name: string,
|
|
11
|
+
extensions: GLExtensions
|
|
12
|
+
): unknown {
|
|
13
|
+
if (extensions[name] === undefined) {
|
|
14
|
+
extensions[name] = gl.getExtension(name) || null;
|
|
15
|
+
}
|
|
16
|
+
return extensions[name];
|
|
17
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
// Provides a unified API for getting and setting any WebGL parameter
|
|
5
6
|
// Also knows default values of all parameters, enabling fast cache initialization
|
|
6
7
|
// Provides base functionality for the state caching.
|
|
7
|
-
import {Device} from '@luma.gl/core';
|
|
8
8
|
import type {GLParameters} from '@luma.gl/constants';
|
|
9
9
|
import {
|
|
10
10
|
GL_PARAMETER_DEFAULTS,
|
|
@@ -13,8 +13,6 @@ import {
|
|
|
13
13
|
GL_PARAMETER_GETTERS
|
|
14
14
|
} from './webgl-parameter-tables';
|
|
15
15
|
|
|
16
|
-
import {WebGLDevice} from '../../adapter/webgl-device';
|
|
17
|
-
|
|
18
16
|
export type {GLParameters};
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -23,13 +21,7 @@ export type {GLParameters};
|
|
|
23
21
|
* @note requires a `cache` object to be set on the context (gl.state.cache)
|
|
24
22
|
* This object is used to fill in any missing values for composite setter functions
|
|
25
23
|
*/
|
|
26
|
-
export function setGLParameters(
|
|
27
|
-
device: Device | WebGL2RenderingContext,
|
|
28
|
-
parameters: GLParameters
|
|
29
|
-
): void {
|
|
30
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
31
|
-
const gl = webglDevice.gl;
|
|
32
|
-
|
|
24
|
+
export function setGLParameters(gl: WebGL2RenderingContext, parameters: GLParameters): void {
|
|
33
25
|
if (isObjectEmpty(parameters)) {
|
|
34
26
|
return;
|
|
35
27
|
}
|
|
@@ -92,12 +84,9 @@ export function setGLParameters(
|
|
|
92
84
|
* by external code needs to be synchronized for the first time
|
|
93
85
|
*/
|
|
94
86
|
export function getGLParameters(
|
|
95
|
-
|
|
87
|
+
gl: WebGL2RenderingContext,
|
|
96
88
|
parameters: keyof GLParameters | (keyof GLParameters)[] | GLParameters = GL_PARAMETER_DEFAULTS
|
|
97
89
|
): GLParameters {
|
|
98
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
99
|
-
const gl = webglDevice.gl;
|
|
100
|
-
|
|
101
90
|
// support both arrays of parameters and objects (keys represent parameters)
|
|
102
91
|
|
|
103
92
|
if (typeof parameters === 'number') {
|
|
@@ -123,8 +112,8 @@ export function getGLParameters(
|
|
|
123
112
|
* NOT the canvas size dimensions, so they will have to be properly set after
|
|
124
113
|
* calling this function.
|
|
125
114
|
*/
|
|
126
|
-
export function resetGLParameters(
|
|
127
|
-
setGLParameters(
|
|
115
|
+
export function resetGLParameters(gl: WebGL2RenderingContext): void {
|
|
116
|
+
setGLParameters(gl, GL_PARAMETER_DEFAULTS);
|
|
128
117
|
}
|
|
129
118
|
|
|
130
119
|
// Helpers
|
|
@@ -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
|
// Tables describing WebGL parameters
|
|
@@ -64,15 +65,7 @@ export const GL_PARAMETER_DEFAULTS: GLParameters = {
|
|
|
64
65
|
[GL.STENCIL_BACK_PASS_DEPTH_PASS]: GL.KEEP,
|
|
65
66
|
// Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame.
|
|
66
67
|
[GL.VIEWPORT]: [0, 0, 1024, 1024],
|
|
67
|
-
// WEBGL1 PIXEL PACK/UNPACK MODES
|
|
68
|
-
[GL.PACK_ALIGNMENT]: 4,
|
|
69
|
-
[GL.UNPACK_ALIGNMENT]: 4,
|
|
70
|
-
[GL.UNPACK_FLIP_Y_WEBGL]: false,
|
|
71
|
-
[GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false,
|
|
72
|
-
[GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: GL.BROWSER_DEFAULT_WEBGL,
|
|
73
68
|
|
|
74
|
-
// WEBGL2 / EXTENSIONS
|
|
75
|
-
// gl1: 'OES_standard_derivatives'
|
|
76
69
|
[GL.TRANSFORM_FEEDBACK_BINDING]: null,
|
|
77
70
|
[GL.COPY_READ_BUFFER_BINDING]: null,
|
|
78
71
|
[GL.COPY_WRITE_BUFFER_BINDING]: null,
|
|
@@ -81,6 +74,12 @@ export const GL_PARAMETER_DEFAULTS: GLParameters = {
|
|
|
81
74
|
[GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: GL.DONT_CARE,
|
|
82
75
|
[GL.READ_FRAMEBUFFER_BINDING]: null,
|
|
83
76
|
[GL.RASTERIZER_DISCARD]: false,
|
|
77
|
+
|
|
78
|
+
[GL.PACK_ALIGNMENT]: 4,
|
|
79
|
+
[GL.UNPACK_ALIGNMENT]: 4,
|
|
80
|
+
[GL.UNPACK_FLIP_Y_WEBGL]: false,
|
|
81
|
+
[GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false,
|
|
82
|
+
[GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: GL.BROWSER_DEFAULT_WEBGL,
|
|
84
83
|
[GL.PACK_ROW_LENGTH]: 0,
|
|
85
84
|
[GL.PACK_SKIP_PIXELS]: 0,
|
|
86
85
|
[GL.PACK_SKIP_ROWS]: 0,
|
|
@@ -100,7 +99,7 @@ const pixelStorei = (gl: WebGL2RenderingContext, value: number | boolean, key: G
|
|
|
100
99
|
gl.pixelStorei(key, value);
|
|
101
100
|
|
|
102
101
|
const bindFramebuffer = (gl: WebGL2RenderingContext, value: unknown, key: GL) => {
|
|
103
|
-
const target =
|
|
102
|
+
const target = key === GL.FRAMEBUFFER_BINDING ? GL.DRAW_FRAMEBUFFER : GL.READ_FRAMEBUFFER;
|
|
104
103
|
return gl.bindFramebuffer(target, value);
|
|
105
104
|
};
|
|
106
105
|
|
|
@@ -137,13 +136,15 @@ export const GL_PARAMETER_SETTERS = {
|
|
|
137
136
|
[GL.BLEND_DST_ALPHA]: 'blendFunc',
|
|
138
137
|
[GL.COLOR_CLEAR_VALUE]: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
139
138
|
gl.clearColor(...value),
|
|
140
|
-
[GL.COLOR_WRITEMASK]: (gl: WebGL2RenderingContext, value: [boolean, boolean, boolean, boolean]) =>
|
|
139
|
+
[GL.COLOR_WRITEMASK]: (gl: WebGL2RenderingContext, value: [boolean, boolean, boolean, boolean]) =>
|
|
140
|
+
gl.colorMask(...value),
|
|
141
141
|
[GL.CULL_FACE]: enable,
|
|
142
142
|
[GL.CULL_FACE_MODE]: (gl: WebGL2RenderingContext, value) => gl.cullFace(value),
|
|
143
143
|
[GL.DEPTH_TEST]: enable,
|
|
144
144
|
[GL.DEPTH_CLEAR_VALUE]: (gl: WebGL2RenderingContext, value) => gl.clearDepth(value),
|
|
145
145
|
[GL.DEPTH_FUNC]: (gl: WebGL2RenderingContext, value) => gl.depthFunc(value),
|
|
146
|
-
[GL.DEPTH_RANGE]: (gl: WebGL2RenderingContext, value: [number, number]) =>
|
|
146
|
+
[GL.DEPTH_RANGE]: (gl: WebGL2RenderingContext, value: [number, number]) =>
|
|
147
|
+
gl.depthRange(...value),
|
|
147
148
|
[GL.DEPTH_WRITEMASK]: (gl: WebGL2RenderingContext, value) => gl.depthMask(value),
|
|
148
149
|
[GL.DITHER]: enable,
|
|
149
150
|
[GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: hint,
|
|
@@ -152,9 +153,8 @@ export const GL_PARAMETER_SETTERS = {
|
|
|
152
153
|
[GL.RENDERBUFFER_BINDING]: (gl: WebGL2RenderingContext, value) =>
|
|
153
154
|
gl.bindRenderbuffer(GL.RENDERBUFFER, value),
|
|
154
155
|
[GL.TRANSFORM_FEEDBACK_BINDING]: (gl: WebGL2RenderingContext, value) =>
|
|
155
|
-
|
|
156
|
-
[GL.VERTEX_ARRAY_BINDING]: (gl: WebGL2RenderingContext, value) =>
|
|
157
|
-
(gl ).bindVertexArray(value),
|
|
156
|
+
gl.bindTransformFeedback?.(GL.TRANSFORM_FEEDBACK, value),
|
|
157
|
+
[GL.VERTEX_ARRAY_BINDING]: (gl: WebGL2RenderingContext, value) => gl.bindVertexArray(value),
|
|
158
158
|
// NOTE: FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.
|
|
159
159
|
[GL.FRAMEBUFFER_BINDING]: bindFramebuffer,
|
|
160
160
|
[GL.READ_FRAMEBUFFER_BINDING]: bindFramebuffer,
|
|
@@ -178,7 +178,8 @@ export const GL_PARAMETER_SETTERS = {
|
|
|
178
178
|
[GL.SAMPLE_COVERAGE_VALUE]: 'sampleCoverage',
|
|
179
179
|
[GL.SAMPLE_COVERAGE_INVERT]: 'sampleCoverage',
|
|
180
180
|
[GL.SCISSOR_TEST]: enable,
|
|
181
|
-
[GL.SCISSOR_BOX]: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
181
|
+
[GL.SCISSOR_BOX]: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
182
|
+
gl.scissor(...value),
|
|
182
183
|
[GL.STENCIL_TEST]: enable,
|
|
183
184
|
[GL.STENCIL_CLEAR_VALUE]: (gl: WebGL2RenderingContext, value) => gl.clearStencil(value),
|
|
184
185
|
[GL.STENCIL_WRITEMASK]: (gl: WebGL2RenderingContext, value) =>
|
|
@@ -197,17 +198,41 @@ export const GL_PARAMETER_SETTERS = {
|
|
|
197
198
|
[GL.STENCIL_BACK_FAIL]: 'stencilOpBack',
|
|
198
199
|
[GL.STENCIL_BACK_PASS_DEPTH_FAIL]: 'stencilOpBack',
|
|
199
200
|
[GL.STENCIL_BACK_PASS_DEPTH_PASS]: 'stencilOpBack',
|
|
200
|
-
[GL.VIEWPORT]: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
201
|
+
[GL.VIEWPORT]: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
202
|
+
gl.viewport(...value),
|
|
203
|
+
|
|
204
|
+
// WEBGL2 EXTENSIONS
|
|
201
205
|
|
|
202
|
-
//
|
|
206
|
+
// EXT_depth_clamp https://registry.khronos.org/webgl/extensions/EXT_depth_clamp/
|
|
207
|
+
|
|
208
|
+
[GL.DEPTH_CLAMP_EXT]: enable,
|
|
209
|
+
|
|
210
|
+
// WEBGL_provoking_vertex https://registry.khronos.org/webgl/extensions/WEBGL_provoking_vertex/
|
|
211
|
+
|
|
212
|
+
// [GL.PROVOKING_VERTEX_WEBL]: TODO - extension function needed
|
|
213
|
+
|
|
214
|
+
// WEBGL_polygon_mode https://registry.khronos.org/webgl/extensions/WEBGL_polygon_mode/
|
|
215
|
+
|
|
216
|
+
// POLYGON_MODE_WEBGL TODO - extension function needed
|
|
217
|
+
[GL.POLYGON_OFFSET_LINE_WEBGL]: enable,
|
|
218
|
+
|
|
219
|
+
// WEBGL_clip_cull_distance https://registry.khronos.org/webgl/extensions/WEBGL_clip_cull_distance/
|
|
220
|
+
|
|
221
|
+
[GL.CLIP_DISTANCE0_WEBGL]: enable,
|
|
222
|
+
[GL.CLIP_DISTANCE1_WEBGL]: enable,
|
|
223
|
+
[GL.CLIP_DISTANCE2_WEBGL]: enable,
|
|
224
|
+
[GL.CLIP_DISTANCE3_WEBGL]: enable,
|
|
225
|
+
[GL.CLIP_DISTANCE4_WEBGL]: enable,
|
|
226
|
+
[GL.CLIP_DISTANCE5_WEBGL]: enable,
|
|
227
|
+
[GL.CLIP_DISTANCE6_WEBGL]: enable,
|
|
228
|
+
[GL.CLIP_DISTANCE7_WEBGL]: enable,
|
|
229
|
+
|
|
230
|
+
// PIXEL PACK/UNPACK MODES
|
|
203
231
|
[GL.PACK_ALIGNMENT]: pixelStorei,
|
|
204
232
|
[GL.UNPACK_ALIGNMENT]: pixelStorei,
|
|
205
233
|
[GL.UNPACK_FLIP_Y_WEBGL]: pixelStorei,
|
|
206
234
|
[GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: pixelStorei,
|
|
207
235
|
[GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: pixelStorei,
|
|
208
|
-
|
|
209
|
-
// WEBGL2 PIXEL PACK/UNPACK MODES
|
|
210
|
-
// RASTERIZER_DISCARD ...
|
|
211
236
|
[GL.PACK_ROW_LENGTH]: pixelStorei,
|
|
212
237
|
[GL.PACK_SKIP_PIXELS]: pixelStorei,
|
|
213
238
|
[GL.PACK_SKIP_ROWS]: pixelStorei,
|
|
@@ -224,22 +249,30 @@ export const GL_PARAMETER_SETTERS = {
|
|
|
224
249
|
const handle = framebuffer && 'handle' in framebuffer ? framebuffer.handle : framebuffer;
|
|
225
250
|
return gl.bindFramebuffer(GL.FRAMEBUFFER, handle);
|
|
226
251
|
},
|
|
227
|
-
blend: (gl: WebGL2RenderingContext, value) =>
|
|
228
|
-
|
|
252
|
+
blend: (gl: WebGL2RenderingContext, value) =>
|
|
253
|
+
value ? gl.enable(GL.BLEND) : gl.disable(GL.BLEND),
|
|
254
|
+
blendColor: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
255
|
+
gl.blendColor(...value),
|
|
229
256
|
blendEquation: (gl: WebGL2RenderingContext, args: number | [number, number]) => {
|
|
230
|
-
const separateModes = typeof args === 'number' ? [args, args] as [number, number]: args;
|
|
257
|
+
const separateModes = typeof args === 'number' ? ([args, args] as [number, number]) : args;
|
|
231
258
|
gl.blendEquationSeparate(...separateModes);
|
|
232
259
|
},
|
|
233
|
-
blendFunc: (
|
|
234
|
-
|
|
260
|
+
blendFunc: (
|
|
261
|
+
gl: WebGL2RenderingContext,
|
|
262
|
+
args: [number, number] | [number, number, number, number]
|
|
263
|
+
) => {
|
|
264
|
+
const separateFuncs =
|
|
265
|
+
args?.length === 2 ? ([...args, ...args] as [number, number, number, number]) : args;
|
|
235
266
|
gl.blendFuncSeparate(...separateFuncs);
|
|
236
267
|
},
|
|
237
268
|
|
|
238
|
-
clearColor: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
269
|
+
clearColor: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
270
|
+
gl.clearColor(...value),
|
|
239
271
|
clearDepth: (gl: WebGL2RenderingContext, value) => gl.clearDepth(value),
|
|
240
272
|
clearStencil: (gl: WebGL2RenderingContext, value) => gl.clearStencil(value),
|
|
241
273
|
|
|
242
|
-
colorMask: (gl: WebGL2RenderingContext, value: [boolean, boolean, boolean, boolean]) =>
|
|
274
|
+
colorMask: (gl: WebGL2RenderingContext, value: [boolean, boolean, boolean, boolean]) =>
|
|
275
|
+
gl.colorMask(...value),
|
|
243
276
|
|
|
244
277
|
cull: (gl: WebGL2RenderingContext, value) =>
|
|
245
278
|
value ? gl.enable(GL.CULL_FACE) : gl.disable(GL.CULL_FACE),
|
|
@@ -267,13 +300,16 @@ export const GL_PARAMETER_SETTERS = {
|
|
|
267
300
|
|
|
268
301
|
polygonOffsetFill: (gl: WebGL2RenderingContext, value) =>
|
|
269
302
|
value ? gl.enable(GL.POLYGON_OFFSET_FILL) : gl.disable(GL.POLYGON_OFFSET_FILL),
|
|
270
|
-
polygonOffset: (gl: WebGL2RenderingContext, value: [number, number]) =>
|
|
303
|
+
polygonOffset: (gl: WebGL2RenderingContext, value: [number, number]) =>
|
|
304
|
+
gl.polygonOffset(...value),
|
|
271
305
|
|
|
272
|
-
sampleCoverage: (gl: WebGL2RenderingContext, value: [number, boolean?]) =>
|
|
306
|
+
sampleCoverage: (gl: WebGL2RenderingContext, value: [number, boolean?]) =>
|
|
307
|
+
gl.sampleCoverage(...value),
|
|
273
308
|
|
|
274
309
|
scissorTest: (gl: WebGL2RenderingContext, value) =>
|
|
275
310
|
value ? gl.enable(GL.SCISSOR_TEST) : gl.disable(GL.SCISSOR_TEST),
|
|
276
|
-
scissor: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
311
|
+
scissor: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
312
|
+
gl.scissor(...value),
|
|
277
313
|
|
|
278
314
|
stencilTest: (gl: WebGL2RenderingContext, value) =>
|
|
279
315
|
value ? gl.enable(GL.STENCIL_TEST) : gl.disable(GL.STENCIL_TEST),
|
|
@@ -296,7 +332,8 @@ export const GL_PARAMETER_SETTERS = {
|
|
|
296
332
|
gl.stencilOpSeparate(GL.BACK, backSfail, backDpfail, backDppass);
|
|
297
333
|
},
|
|
298
334
|
|
|
299
|
-
viewport: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
335
|
+
viewport: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>
|
|
336
|
+
gl.viewport(...value)
|
|
300
337
|
};
|
|
301
338
|
|
|
302
339
|
function getValue(glEnum, values, cache) {
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
// Support for listening to context state changes and intercepting state queries
|
|
5
6
|
// NOTE: this system does not handle buffer bindings
|
|
6
7
|
import {assert} from '@luma.gl/core';
|
|
7
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
GL_PARAMETER_DEFAULTS,
|
|
10
|
+
GL_HOOKED_SETTERS,
|
|
11
|
+
NON_CACHE_PARAMETERS
|
|
12
|
+
} from '../parameters/webgl-parameter-tables';
|
|
8
13
|
import {setGLParameters, getGLParameters} from '../parameters/unified-parameter-api';
|
|
9
14
|
import {deepArrayEqual} from './deep-array-equal';
|
|
10
15
|
|
|
@@ -57,7 +62,8 @@ class GLState {
|
|
|
57
62
|
let valueChanged = false;
|
|
58
63
|
let oldValue; // = undefined
|
|
59
64
|
|
|
60
|
-
const oldValues: {[key: number | string]: any} | null =
|
|
65
|
+
const oldValues: {[key: number | string]: any} | null =
|
|
66
|
+
this.stateStack.length > 0 ? this.stateStack[this.stateStack.length - 1] : null;
|
|
61
67
|
|
|
62
68
|
for (const key in values) {
|
|
63
69
|
assert(key !== undefined);
|
|
@@ -152,7 +158,6 @@ export function pushContextState(gl: WebGL2RenderingContext): void {
|
|
|
152
158
|
glState.push();
|
|
153
159
|
}
|
|
154
160
|
|
|
155
|
-
|
|
156
161
|
/**
|
|
157
162
|
* Restores previously saved WebGL context state
|
|
158
163
|
*/
|
|
@@ -190,9 +195,9 @@ function installGetterOverride(gl: WebGL2RenderingContext, functionName: string)
|
|
|
190
195
|
// Optionally call the original function to do a "hard" query from the WebGL2RenderingContext
|
|
191
196
|
return glState.enable
|
|
192
197
|
? // Call the getter the params so that it can e.g. serve from a cache
|
|
193
|
-
|
|
198
|
+
glState.cache[pname]
|
|
194
199
|
: // Optionally call the original function to do a "hard" query from the WebGL2RenderingContext
|
|
195
|
-
|
|
200
|
+
originalGetterFunc(pname);
|
|
196
201
|
};
|
|
197
202
|
|
|
198
203
|
// Set the name of this anonymous function to help in debugging and profiling
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// luma.gl
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
|
-
import type {Device} from '@luma.gl/core';
|
|
5
|
-
import {WebGLDevice} from '../../adapter/webgl-device';
|
|
6
5
|
import {GLParameters, setGLParameters} from '../parameters/unified-parameter-api';
|
|
7
6
|
import {pushContextState, popContextState} from './track-context-state';
|
|
8
7
|
|
|
@@ -14,13 +13,14 @@ import {pushContextState, popContextState} from './track-context-state';
|
|
|
14
13
|
* - Restores parameters
|
|
15
14
|
* - Returns the return value of the supplied function
|
|
16
15
|
*/
|
|
17
|
-
export function withGLParameters(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
export function withGLParameters(
|
|
17
|
+
gl: WebGL2RenderingContext,
|
|
18
|
+
parameters: GLParameters & {nocatch?: boolean},
|
|
19
|
+
func: any
|
|
20
|
+
): any {
|
|
21
21
|
if (isObjectEmpty(parameters)) {
|
|
22
22
|
// Avoid setting state if no parameters provided. Just call and return
|
|
23
|
-
return func(
|
|
23
|
+
return func(gl);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const {nocatch = true} = parameters;
|
package/src/index.ts
CHANGED
|
@@ -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
|
// luma.gl Base WebGL wrapper library
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
// Higher level abstractions can be built on these classes
|
|
9
10
|
|
|
10
11
|
// Types
|
|
11
|
-
export type {
|
|
12
|
+
export type {WebGLDeviceLimits} from './adapter/device-helpers/webgl-device-limits';
|
|
12
13
|
|
|
13
14
|
// WebGL adapter classes
|
|
14
15
|
export {WebGLDevice} from './adapter/webgl-device';
|
|
@@ -30,10 +31,6 @@ export {WEBGLRenderPass} from './adapter/resources/webgl-render-pass';
|
|
|
30
31
|
// export {WEBGLComputePass} from './adapter/resources/webgl-compute-pass';
|
|
31
32
|
export {WEBGLVertexArray} from './adapter/resources/webgl-vertex-array';
|
|
32
33
|
|
|
33
|
-
// Internal WebGL classes
|
|
34
|
-
export type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';
|
|
35
|
-
export {WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';
|
|
36
|
-
|
|
37
34
|
// WebGL adapter classes
|
|
38
35
|
export {WEBGLTransformFeedback} from './adapter/resources/webgl-transform-feedback';
|
|
39
36
|
|
|
@@ -49,6 +46,10 @@ export {setDeviceParameters, withDeviceParameters} from './adapter/converters/de
|
|
|
49
46
|
export {getShaderLayout} from './adapter/helpers/get-shader-layout';
|
|
50
47
|
export {convertGLToTextureFormat} from './adapter/converters/texture-formats';
|
|
51
48
|
|
|
49
|
+
// Internal WebGL classes
|
|
50
|
+
export type {RenderbufferProps as _RenderbufferProps} from './adapter/objects/webgl-renderbuffer';
|
|
51
|
+
export {WEBGLRenderbuffer as _WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';
|
|
52
|
+
|
|
52
53
|
// TEST EXPORTS
|
|
53
54
|
export {TEXTURE_FORMATS as _TEXTURE_FORMATS} from './adapter/converters/texture-formats';
|
|
54
55
|
|
package/src/types.ts
CHANGED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { DeviceFeature } from '@luma.gl/core';
|
|
2
|
-
/** Get WebGPU style feature strings */
|
|
3
|
-
export declare function getDeviceFeatures(gl: WebGL2RenderingContext): Set<DeviceFeature>;
|
|
4
|
-
/** Extract all WebGL features */
|
|
5
|
-
export declare function getWebGLFeatures(gl: WebGL2RenderingContext): Set<DeviceFeature>;
|
|
6
|
-
//# sourceMappingURL=device-features.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device-features.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/device-features.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAG5C,uCAAuC;AACvC,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,sBAAsB,GAAG,GAAG,CAAC,aAAa,CAAC,CAiBhF;AAED,iCAAiC;AACjC,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,sBAAsB,GAAG,GAAG,CAAC,aAAa,CAAC,CAe/E"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// luma.gl, MIT license
|
|
2
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
-
import { getTextureFeatures } from '../converters/texture-formats';
|
|
4
|
-
/** Get WebGPU style feature strings */
|
|
5
|
-
export function getDeviceFeatures(gl) {
|
|
6
|
-
const features = getWebGLFeatures(gl);
|
|
7
|
-
// texture features
|
|
8
|
-
// features.add('texture-compression-bc');
|
|
9
|
-
for (const textureFeature of getTextureFeatures(gl)) {
|
|
10
|
-
features.add(textureFeature);
|
|
11
|
-
}
|
|
12
|
-
// TODO
|
|
13
|
-
// features.add('depth-clip-control'); // GPUPrimitiveState.clampDepth
|
|
14
|
-
// features.add('depth24unorm-stencil8'); // GPUTextureFormat 'depth24unorm-stencil8'.
|
|
15
|
-
// features.add('depth32float-stencil8'); // GPUTextureFormat 'depth32float-stencil8'.
|
|
16
|
-
// features.add('timestamp-query'); // GPUQueryType "timestamp-query"
|
|
17
|
-
// "indirect-first-instance"
|
|
18
|
-
return features;
|
|
19
|
-
}
|
|
20
|
-
/** Extract all WebGL features */
|
|
21
|
-
export function getWebGLFeatures(gl) {
|
|
22
|
-
// Enables EXT_float_blend first: https://developer.mozilla.org/en-US/docs/Web/API/EXT_float_blend
|
|
23
|
-
gl.getExtension('EXT_color_buffer_float');
|
|
24
|
-
gl.getExtension('WEBGL_color_buffer_float');
|
|
25
|
-
gl.getExtension('EXT_float_blend');
|
|
26
|
-
const features = new Set(WEBGL_ALWAYS_FEATURES);
|
|
27
|
-
for (const feature of Object.keys(WEBGL_FEATURES)) {
|
|
28
|
-
// @ts-expect-error
|
|
29
|
-
if (isFeatureSupported(gl, feature)) {
|
|
30
|
-
// @ts-expect-error
|
|
31
|
-
features.add(feature);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return features;
|
|
35
|
-
}
|
|
36
|
-
function isFeatureSupported(gl, feature) {
|
|
37
|
-
const featureInfo = WEBGL_FEATURES[feature];
|
|
38
|
-
if (!featureInfo) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
// Get extension name from table
|
|
42
|
-
const featureDefinition = featureInfo;
|
|
43
|
-
// Check if the value is dependent on checking one or more extensions
|
|
44
|
-
if (typeof featureDefinition === 'boolean') {
|
|
45
|
-
return featureDefinition;
|
|
46
|
-
}
|
|
47
|
-
return Boolean(gl.getExtension(featureDefinition));
|
|
48
|
-
}
|
|
49
|
-
const WEBGL_ALWAYS_FEATURES = ['webgl', 'glsl', 'transform-feedback-webgl'];
|
|
50
|
-
/**
|
|
51
|
-
* Defines luma.gl "feature" names and semantics
|
|
52
|
-
* when value is 'string' it is the name of the extension that enables this feature
|
|
53
|
-
*/
|
|
54
|
-
const WEBGL_FEATURES = {
|
|
55
|
-
'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2',
|
|
56
|
-
'transform-feedback-webgl': true,
|
|
57
|
-
// WEBGL1 SUPPORT
|
|
58
|
-
'texture-blend-float-webgl': 'EXT_float_blend',
|
|
59
|
-
'float32-filterable-linear-webgl': 'OES_texture_float_linear',
|
|
60
|
-
'float16-filterable-linear-webgl': 'OES_texture_half_float_linear',
|
|
61
|
-
'texture-filterable-anisotropic-webgl': 'EXT_texture_filter_anisotropic',
|
|
62
|
-
// FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS
|
|
63
|
-
'float32-renderable-webgl': 'EXT_color_buffer_float',
|
|
64
|
-
'float16-renderable-webgl': 'EXT_color_buffer_half_float',
|
|
65
|
-
};
|