@luma.gl/webgl 9.0.0-alpha.46 → 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/LICENSE +34 -0
- 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.d.ts +5 -11
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +16 -13
- 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.d.ts +2 -0
- package/dist/classic/typed-array-utils.d.ts.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 +987 -2700
- package/dist/index.cjs +390 -267
- 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-transform-feedback.ts +13 -16
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-device.ts +3 -2
- package/src/classic/typed-array-utils.ts +2 -0
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
|
+
}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import type {PrimitiveTopology, ShaderLayout, TransformFeedbackProps} from '@luma.gl/core';
|
|
2
|
-
import {log, TransformFeedback, Buffer} from '@luma.gl/core';
|
|
2
|
+
import {log, TransformFeedback, Buffer, BufferRange} from '@luma.gl/core';
|
|
3
3
|
import {GL} from '@luma.gl/constants';
|
|
4
4
|
import {WebGLDevice} from '../webgl-device';
|
|
5
5
|
import {WEBGLBuffer} from '../..';
|
|
6
6
|
import {getGLPrimitive} from '../helpers/webgl-topology-utils';
|
|
7
7
|
|
|
8
|
-
/** For bindRange */
|
|
9
|
-
type BufferRange = {
|
|
10
|
-
buffer: Buffer;
|
|
11
|
-
byteOffset?: number;
|
|
12
|
-
byteLength?: number;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
8
|
export class WEBGLTransformFeedback extends TransformFeedback {
|
|
16
9
|
readonly device: WebGLDevice;
|
|
17
10
|
readonly gl2: WebGL2RenderingContext;
|
|
@@ -72,7 +65,7 @@ export class WEBGLTransformFeedback extends TransformFeedback {
|
|
|
72
65
|
|
|
73
66
|
// SUBCLASS
|
|
74
67
|
|
|
75
|
-
setBuffers(buffers: Record<string, Buffer | BufferRange>) {
|
|
68
|
+
setBuffers(buffers: Record<string, Buffer | BufferRange>): void {
|
|
76
69
|
this.buffers = {};
|
|
77
70
|
this.unusedBuffers = {};
|
|
78
71
|
|
|
@@ -81,17 +74,16 @@ export class WEBGLTransformFeedback extends TransformFeedback {
|
|
|
81
74
|
this.setBuffer(bufferName, buffers[bufferName]);
|
|
82
75
|
}
|
|
83
76
|
});
|
|
84
|
-
return this;
|
|
85
77
|
}
|
|
86
78
|
|
|
87
|
-
setBuffer(locationOrName: string | number, bufferOrRange: Buffer | BufferRange) {
|
|
79
|
+
setBuffer(locationOrName: string | number, bufferOrRange: Buffer | BufferRange): void {
|
|
88
80
|
const location = this._getVaryingIndex(locationOrName);
|
|
89
81
|
const {buffer, byteLength, byteOffset} = this._getBufferRange(bufferOrRange);
|
|
90
82
|
|
|
91
83
|
if (location < 0) {
|
|
92
84
|
this.unusedBuffers[locationOrName] = buffer;
|
|
93
85
|
log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();
|
|
94
|
-
return
|
|
86
|
+
return;
|
|
95
87
|
}
|
|
96
88
|
|
|
97
89
|
this.buffers[location] = {buffer, byteLength, byteOffset};
|
|
@@ -101,8 +93,14 @@ export class WEBGLTransformFeedback extends TransformFeedback {
|
|
|
101
93
|
if (!this.bindOnUse) {
|
|
102
94
|
this._bindBuffer(location, buffer, byteOffset, byteLength);
|
|
103
95
|
}
|
|
96
|
+
}
|
|
104
97
|
|
|
105
|
-
|
|
98
|
+
getBuffer(locationOrName: string | number): Buffer | BufferRange | null {
|
|
99
|
+
if (isIndex(locationOrName)) {
|
|
100
|
+
return this.buffers[locationOrName] || null;
|
|
101
|
+
}
|
|
102
|
+
const location = this._getVaryingIndex(locationOrName);
|
|
103
|
+
return location >= 0 ? this.buffers[location] : null;
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
bind(funcOrHandle = this.handle) {
|
|
@@ -146,7 +144,7 @@ export class WEBGLTransformFeedback extends TransformFeedback {
|
|
|
146
144
|
return {buffer, byteOffset, byteLength};
|
|
147
145
|
}
|
|
148
146
|
|
|
149
|
-
protected _getVaryingIndex(locationOrName: string | number) {
|
|
147
|
+
protected _getVaryingIndex(locationOrName: string | number): number {
|
|
150
148
|
if (isIndex(locationOrName)) {
|
|
151
149
|
return Number(locationOrName);
|
|
152
150
|
}
|
|
@@ -182,14 +180,13 @@ export class WEBGLTransformFeedback extends TransformFeedback {
|
|
|
182
180
|
buffer: Buffer,
|
|
183
181
|
byteOffset = 0,
|
|
184
182
|
byteLength?: number
|
|
185
|
-
):
|
|
183
|
+
): void {
|
|
186
184
|
const handle = buffer && (buffer as WEBGLBuffer).handle;
|
|
187
185
|
if (!handle || byteLength === undefined) {
|
|
188
186
|
this.gl2.bindBufferBase(GL.TRANSFORM_FEEDBACK_BUFFER, index, handle);
|
|
189
187
|
} else {
|
|
190
188
|
this.gl2.bindBufferRange(GL.TRANSFORM_FEEDBACK_BUFFER, index, handle, byteOffset, byteLength);
|
|
191
189
|
}
|
|
192
|
-
return this;
|
|
193
190
|
}
|
|
194
191
|
}
|
|
195
192
|
|
|
@@ -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) {
|
|
@@ -9,6 +9,7 @@ const ERR_TYPE_DEDUCTION = 'Failed to deduce GL constant from typed array';
|
|
|
9
9
|
/**
|
|
10
10
|
* Converts TYPED ARRAYS to corresponding GL constant
|
|
11
11
|
* Used to auto deduce gl parameter types
|
|
12
|
+
* @deprecated Use getDataTypeFromTypedArray
|
|
12
13
|
* @param arrayOrType
|
|
13
14
|
* @returns
|
|
14
15
|
*/
|
|
@@ -40,6 +41,7 @@ export function getGLTypeFromTypedArray(arrayOrType: TypedArray): GLDataType {
|
|
|
40
41
|
/**
|
|
41
42
|
* Converts GL constant to corresponding TYPED ARRAY
|
|
42
43
|
* Used to auto deduce gl parameter types
|
|
44
|
+
* @deprecated Use getTypedArrayFromDataType
|
|
43
45
|
* @param glType
|
|
44
46
|
* @param param1
|
|
45
47
|
* @returns
|