@luma.gl/webgl 9.0.0-alpha.47 → 9.0.0-alpha.48
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 +73 -40
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +60 -61
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/shader-formats.js +12 -13
- package/dist/adapter/converters/shader-formats.js.map +1 -1
- package/dist/adapter/converters/texture-formats.js +179 -180
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +20 -21
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +2 -2
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +53 -54
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +23 -12
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +31 -32
- package/dist/adapter/helpers/decode-webgl-types.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +29 -30
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +16 -4
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +40 -41
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +38 -39
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +5 -6
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +14 -15
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +25 -26
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +22 -23
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +2 -3
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +7 -8
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +2 -3
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +3 -4
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +27 -28
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +8 -9
- 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 +5 -6
- package/dist/adapter/resources/webgl-vertex-array.js.map +1 -1
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.js +4 -5
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/copy-and-blit.js +16 -17
- package/dist/classic/copy-and-blit.js.map +1 -1
- package/dist/classic/format-utils.js +14 -15
- package/dist/classic/format-utils.js.map +1 -1
- package/dist/classic/typed-array-utils.js +18 -19
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +0 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +256 -257
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +34 -35
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +9 -10
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js +17 -17
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
- package/dist/dist.dev.js +979 -2696
- package/dist/index.cjs +382 -263
- package/dist.min.js +39 -28
- package/package.json +5 -5
- package/src/adapter/converters/device-parameters.ts +40 -25
- package/src/adapter/device-helpers/get-device-info.ts +36 -8
- package/src/adapter/helpers/parse-shader-compiler-log.ts +21 -7
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-device.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.48",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
|
-
"@luma.gl/constants": "9.0.0-alpha.
|
|
48
|
-
"@luma.gl/core": "9.0.0-alpha.
|
|
47
|
+
"@luma.gl/constants": "9.0.0-alpha.48",
|
|
48
|
+
"@luma.gl/core": "9.0.0-alpha.48",
|
|
49
49
|
"@probe.gl/env": "^4.0.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@luma.gl/test-utils": "9.0.0-alpha.
|
|
52
|
+
"@luma.gl/test-utils": "9.0.0-alpha.48"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "e57479712693a82ec918382020dd2593035e29b0"
|
|
55
55
|
}
|
|
@@ -7,10 +7,12 @@ import {
|
|
|
7
7
|
CompareFunction,
|
|
8
8
|
StencilOperation,
|
|
9
9
|
log,
|
|
10
|
-
isObjectEmpty
|
|
10
|
+
isObjectEmpty,
|
|
11
|
+
BlendOperation,
|
|
12
|
+
BlendFactor
|
|
11
13
|
} from '@luma.gl/core';
|
|
12
14
|
import {GL} from '@luma.gl/constants';
|
|
13
|
-
import type {GLParameters} from '@luma.gl/constants';
|
|
15
|
+
import type {GLBlendEquation, GLBlendFunction, GLParameters} from '@luma.gl/constants';
|
|
14
16
|
import {pushContextState, popContextState} from '../../context/state-tracker/track-context-state';
|
|
15
17
|
import {setGLParameters} from '../../context/parameters/unified-parameter-api';
|
|
16
18
|
import {WebGLDevice} from '../webgl-device';
|
|
@@ -207,21 +209,19 @@ export function setDeviceParameters(device: Device, parameters: Parameters) {
|
|
|
207
209
|
|
|
208
210
|
// COLOR STATE
|
|
209
211
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
if (parameters.blendColorOperation || parameters.blendAlphaOperation) {
|
|
213
|
+
gl.enable(GL.BLEND);
|
|
212
214
|
|
|
213
|
-
|
|
215
|
+
const colorEquation = convertBlendOperationToEquation('blendColorOperation', parameters.blendColorOperation || 'add');
|
|
216
|
+
const alphaEquation = convertBlendOperationToEquation('blendAlphaOperation', parameters.blendAlphaOperation || 'add');
|
|
217
|
+
gl.blendEquationSeparate(colorEquation, alphaEquation);
|
|
214
218
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
// let alphaSrcFactor = (blend && blend.alpha && blend.alpha.srcFactor) || 'one';
|
|
222
|
-
// let alphaDstFactor = (blend && blend.alpha && blend.alpha.dstFactor) || 'zero';
|
|
223
|
-
// gl.blendFuncSeparate(colorSrcFactor, colorDstFactor, alphaSrcFactor, alphaDstFactor);
|
|
224
|
-
// }
|
|
219
|
+
const colorSrcFactor = convertBlendFactorToFunction('blendColorSrcFactor', parameters.blendColorSrcFactor || 'one');
|
|
220
|
+
const colorDstFactor = convertBlendFactorToFunction('blendColorDstFactor', parameters.blendColorDstFactor || 'zero');
|
|
221
|
+
const alphaSrcFactor = convertBlendFactorToFunction('blendAlphaSrcFactor', parameters.blendAlphaSrcFactor || 'one');
|
|
222
|
+
const alphaDstFactor = convertBlendFactorToFunction('blendAlphaDstFactor', parameters.blendAlphaDstFactor || 'zero');
|
|
223
|
+
gl.blendFuncSeparate(colorSrcFactor, colorDstFactor, alphaSrcFactor, alphaDstFactor);
|
|
224
|
+
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
/*
|
|
@@ -286,16 +286,31 @@ function convertStencilOperation(parameter: string, value: StencilOperation): GL
|
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
//
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
289
|
+
function convertBlendOperationToEquation(parameter: string, value: BlendOperation): GLBlendEquation {
|
|
290
|
+
return map(parameter, value, {
|
|
291
|
+
'add': GL.FUNC_ADD,
|
|
292
|
+
'subtract': GL.FUNC_SUBTRACT,
|
|
293
|
+
'reverse-subtract': GL.FUNC_REVERSE_SUBTRACT,
|
|
294
|
+
// When using a WebGL 2 context, the following values are available additionally:
|
|
295
|
+
'min': GL.MIN,
|
|
296
|
+
'max': GL.MAX
|
|
297
|
+
} as Record<BlendOperation, GLBlendEquation>);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function convertBlendFactorToFunction(parameter: string, value: BlendFactor): GLBlendFunction {
|
|
301
|
+
return map(parameter, value, {
|
|
302
|
+
'one': GL.ONE,
|
|
303
|
+
'zero': GL.ZERO,
|
|
304
|
+
'src-color': GL.SRC_COLOR,
|
|
305
|
+
'one-minus-src-color': GL.ONE_MINUS_SRC_COLOR,
|
|
306
|
+
'dst-color': GL.DST_COLOR,
|
|
307
|
+
'one-minus-dst-color': GL.ONE_MINUS_DST_COLOR,
|
|
308
|
+
'src-alpha': GL.SRC_ALPHA,
|
|
309
|
+
'one-minus-src-alpha': GL.ONE_MINUS_SRC_ALPHA,
|
|
310
|
+
'dst-alpha': GL.DST_ALPHA,
|
|
311
|
+
'one-minus-dst-alpha': GL.ONE_MINUS_DST_ALPHA,
|
|
312
|
+
} as Record<BlendFactor, GLBlendFunction>);
|
|
313
|
+
}
|
|
299
314
|
|
|
300
315
|
function message(parameter: string, value: any): string {
|
|
301
316
|
return `Illegal parameter ${value} for ${parameter}`;
|
|
@@ -7,29 +7,45 @@ import {isWebGL2} from '../../context/context/webgl-checks';
|
|
|
7
7
|
|
|
8
8
|
/** @returns strings identifying the GPU vendor and driver. */
|
|
9
9
|
export function getDeviceInfo(gl: WebGLRenderingContext): DeviceInfo {
|
|
10
|
+
// "Masked" info is always available, but don't contain much useful information
|
|
10
11
|
const vendorMasked = gl.getParameter(GL.VENDOR);
|
|
11
12
|
const rendererMasked = gl.getParameter(GL.RENDERER);
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
// If we are lucky, unmasked info is available
|
|
13
15
|
// https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/
|
|
14
16
|
const ext = gl.getExtension('WEBGL_debug_renderer_info');
|
|
15
17
|
const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : GL.VENDOR);
|
|
16
18
|
const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : GL.RENDERER);
|
|
17
19
|
const vendor = vendorUnmasked || vendorMasked;
|
|
18
20
|
const renderer = rendererUnmasked || rendererMasked;
|
|
21
|
+
|
|
22
|
+
// Driver version
|
|
23
|
+
const version = gl.getParameter(GL.VERSION) as string;
|
|
24
|
+
|
|
25
|
+
// "Sniff" the GPU type and backend from the info. This works best if unmasked info is available.
|
|
19
26
|
const gpu = identifyGPUVendor(vendor, renderer);
|
|
27
|
+
const gpuBackend = identifyGPUBackend(vendor, renderer);
|
|
28
|
+
|
|
29
|
+
// Determine GLSL version
|
|
30
|
+
// For now, skip parsing of the long version string, just use context type below to deduce version
|
|
31
|
+
// const version = gl.getParameter(GL.SHADING_LANGUAGE_VERSION) as string;
|
|
32
|
+
// const shadingLanguageVersion = parseGLSLVersion(version);
|
|
33
|
+
const shadingLanguage = 'glsl';
|
|
34
|
+
const shadingLanguageVersion = isWebGL2(gl) ? 300 : 100
|
|
35
|
+
|
|
20
36
|
return {
|
|
21
37
|
type: isWebGL2(gl) ? 'webgl2' : 'webgl',
|
|
22
38
|
gpu,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
39
|
+
gpuBackend,
|
|
40
|
+
vendor,
|
|
41
|
+
renderer,
|
|
42
|
+
version,
|
|
43
|
+
shadingLanguage,
|
|
44
|
+
shadingLanguageVersion
|
|
30
45
|
};
|
|
31
46
|
}
|
|
32
47
|
|
|
48
|
+
/** "Sniff" the GPU type from the info. This works best if unmasked info is available. */
|
|
33
49
|
function identifyGPUVendor(vendor: string, renderer: string): 'nvidia' | 'intel' | 'apple' | 'amd' | 'software' | 'unknown' {
|
|
34
50
|
if ((/NVIDIA/i.exec(vendor)) || (/NVIDIA/i.exec(renderer))) {
|
|
35
51
|
return 'nvidia';
|
|
@@ -54,3 +70,15 @@ function identifyGPUVendor(vendor: string, renderer: string): 'nvidia' | 'intel'
|
|
|
54
70
|
|
|
55
71
|
return 'unknown';
|
|
56
72
|
}
|
|
73
|
+
|
|
74
|
+
/** "Sniff" the GPU backend from the info. This works best if unmasked info is available. */
|
|
75
|
+
function identifyGPUBackend(vendor: string, renderer: string): 'angle' | 'metal' | 'unknown' {
|
|
76
|
+
if ((/ANGLE/i.exec(vendor)) || (/ANGLE/i.exec(renderer))) {
|
|
77
|
+
return 'angle';
|
|
78
|
+
}
|
|
79
|
+
if ((/Metal/i.exec(vendor)) || (/Metal/i.exec(renderer))) {
|
|
80
|
+
return 'metal';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return 'unknown';
|
|
84
|
+
}
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import type {CompilerMessage} from '@luma.gl/core';
|
|
5
5
|
|
|
6
|
-
const MESSAGE_TYPES = ['warning', 'error', 'info'];
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* Parse a WebGL-format GLSL compilation log into an array of WebGPU style message records.
|
|
10
8
|
* This follows documented WebGL conventions for compilation logs.
|
|
@@ -22,6 +20,19 @@ export function parseShaderCompilerLog(errLog: string) : readonly CompilerMessag
|
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
const segments: string[] = line.split(':');
|
|
23
|
+
|
|
24
|
+
// Check for messages with no line information `ERROR: unsupported shader version`
|
|
25
|
+
if (segments.length === 2) {
|
|
26
|
+
const [messageType, message] = segments;
|
|
27
|
+
messages.push({
|
|
28
|
+
message: message.trim(),
|
|
29
|
+
type: getMessageType(messageType),
|
|
30
|
+
lineNum: 0,
|
|
31
|
+
linePos: 0
|
|
32
|
+
});
|
|
33
|
+
continue; // eslint-disable-line no-continue
|
|
34
|
+
}
|
|
35
|
+
|
|
25
36
|
const [messageType, linePosition, lineNumber, ...rest] = segments;
|
|
26
37
|
|
|
27
38
|
let lineNum = parseInt(lineNumber, 10);
|
|
@@ -34,13 +45,9 @@ export function parseShaderCompilerLog(errLog: string) : readonly CompilerMessag
|
|
|
34
45
|
linePos = 0;
|
|
35
46
|
}
|
|
36
47
|
|
|
37
|
-
// Ensure supported type
|
|
38
|
-
const lowerCaseType = messageType.toLowerCase();
|
|
39
|
-
const type = (MESSAGE_TYPES.includes(lowerCaseType) ? lowerCaseType : 'info') as 'warning' | 'error' | 'info';
|
|
40
|
-
|
|
41
48
|
messages.push({
|
|
42
49
|
message: rest.join(':').trim(),
|
|
43
|
-
type,
|
|
50
|
+
type: getMessageType(messageType),
|
|
44
51
|
lineNum,
|
|
45
52
|
linePos // TODO
|
|
46
53
|
})
|
|
@@ -48,3 +55,10 @@ export function parseShaderCompilerLog(errLog: string) : readonly CompilerMessag
|
|
|
48
55
|
|
|
49
56
|
return messages;
|
|
50
57
|
}
|
|
58
|
+
|
|
59
|
+
/** Ensure supported type */
|
|
60
|
+
function getMessageType(messageType: string): 'warning' | 'error' | 'info' {
|
|
61
|
+
const MESSAGE_TYPES = ['warning', 'error', 'info'];
|
|
62
|
+
const lowerCaseType = messageType.toLowerCase();
|
|
63
|
+
return (MESSAGE_TYPES.includes(lowerCaseType) ? lowerCaseType : 'info') as 'warning' | 'error' | 'info';
|
|
64
|
+
}
|
|
@@ -54,14 +54,15 @@ export class WEBGLVertexArray extends VertexArray {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
// Set (bind) an elements buffer, for indexed rendering.
|
|
58
|
-
// Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported
|
|
57
|
+
// Set (bind/unbind) an elements buffer, for indexed rendering.
|
|
58
|
+
// Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER or null. Constants not supported
|
|
59
59
|
*
|
|
60
60
|
* @param elementBuffer
|
|
61
61
|
*/
|
|
62
62
|
setIndexBuffer(indexBuffer: Buffer | null): void {
|
|
63
63
|
const buffer = indexBuffer as WEBGLBuffer;
|
|
64
|
-
|
|
64
|
+
// Explicitly allow `null` to support clearing the index buffer
|
|
65
|
+
if (buffer && buffer.glTarget !== GL.ELEMENT_ARRAY_BUFFER) {
|
|
65
66
|
throw new Error('Use .setBuffer()');
|
|
66
67
|
}
|
|
67
68
|
// In WebGL The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject
|
|
@@ -582,8 +582,9 @@ function setConstantUintArray(device: WebGLDevice, location: number, array: Uint
|
|
|
582
582
|
// }
|
|
583
583
|
}
|
|
584
584
|
|
|
585
|
-
/**
|
|
586
|
-
*
|
|
585
|
+
/**
|
|
586
|
+
* Compares contents of two typed arrays
|
|
587
|
+
* @todo max length?
|
|
587
588
|
*/
|
|
588
589
|
function compareConstantArrayValues(v1: TypedArray, v2: TypedArray): boolean {
|
|
589
590
|
if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {
|