@luma.gl/webgl 9.2.6 → 9.3.0-alpha.4
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/helpers/get-shader-layout-from-glsl.js +11 -8
- package/dist/adapter/helpers/get-shader-layout-from-glsl.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +20 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +2 -3
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +9 -5
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-fence.d.ts +14 -0
- package/dist/adapter/resources/webgl-fence.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-fence.js +49 -0
- package/dist/adapter/resources/webgl-fence.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +9 -6
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +1 -2
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +21 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +148 -22
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +5 -5
- package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -1
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +22 -23
- package/dist/adapter/webgl-adapter.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +16 -6
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +4 -2
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +39 -24
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +4 -4
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +6 -6
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
- package/dist/context/helpers/create-browser-context.js +46 -36
- package/dist/context/helpers/create-browser-context.js.map +1 -1
- package/dist/context/helpers/webgl-context-data.d.ts +5 -1
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -1
- package/dist/context/helpers/webgl-context-data.js +9 -10
- package/dist/context/helpers/webgl-context-data.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts +1 -1
- package/dist/context/parameters/unified-parameter-api.js +2 -2
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/state-tracker/webgl-state-tracker.js +2 -2
- package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -1
- package/dist/dist.dev.js +567 -318
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +550 -314
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/fill-array.js +1 -1
- package/dist/utils/fill-array.js.map +1 -1
- package/package.json +5 -5
- package/src/adapter/helpers/get-shader-layout-from-glsl.ts +11 -9
- package/src/adapter/helpers/parse-shader-compiler-log.ts +23 -1
- package/src/adapter/resources/webgl-command-buffer.ts +18 -22
- package/src/adapter/resources/webgl-fence.ts +55 -0
- package/src/adapter/resources/webgl-render-pass.ts +10 -6
- package/src/adapter/resources/webgl-render-pipeline.ts +1 -2
- package/src/adapter/resources/webgl-texture.ts +209 -37
- package/src/adapter/resources/webgl-transform-feedback.ts +5 -5
- package/src/adapter/webgl-adapter.ts +26 -24
- package/src/adapter/webgl-canvas-context.ts +19 -8
- package/src/adapter/webgl-device.ts +41 -29
- package/src/context/debug/spector.ts +4 -4
- package/src/context/debug/webgl-developer-tools.ts +15 -6
- package/src/context/helpers/create-browser-context.ts +54 -43
- package/src/context/helpers/webgl-context-data.ts +17 -11
- package/src/context/parameters/unified-parameter-api.ts +2 -2
- package/src/context/state-tracker/webgl-state-tracker.ts +2 -2
- package/src/index.ts +1 -0
- package/src/utils/fill-array.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { WEBGLTexture } from "./adapter/resources/webgl-texture.js";
|
|
|
8
8
|
export { WEBGLShader } from "./adapter/resources/webgl-shader.js";
|
|
9
9
|
export { WEBGLSampler } from "./adapter/resources/webgl-sampler.js";
|
|
10
10
|
export { WEBGLFramebuffer } from "./adapter/resources/webgl-framebuffer.js";
|
|
11
|
+
export { WEBGLFence } from "./adapter/resources/webgl-fence.js";
|
|
11
12
|
export { WEBGLRenderPipeline } from "./adapter/resources/webgl-render-pipeline.js";
|
|
12
13
|
export { WEBGLCommandEncoder } from "./adapter/resources/webgl-command-encoder.js";
|
|
13
14
|
export { WEBGLRenderPass } from "./adapter/resources/webgl-render-pass.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,YAAY,EAAC,iBAAiB,EAAC,wDAAqD;AAGpF,OAAO,EAAC,aAAa,EAAC,mCAAgC;AACtD,YAAY,EAAC,YAAY,EAAC,mCAAgC;AAG1D,OAAO,EAAC,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EA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Texture } from "./adapter/resources/webgl-texture.js";
|
|
|
13
13
|
export { WEBGLShader } from "./adapter/resources/webgl-shader.js";
|
|
14
14
|
export { WEBGLSampler } from "./adapter/resources/webgl-sampler.js";
|
|
15
15
|
export { WEBGLFramebuffer } from "./adapter/resources/webgl-framebuffer.js";
|
|
16
|
+
export { WEBGLFence } from "./adapter/resources/webgl-fence.js";
|
|
16
17
|
export { WEBGLRenderPipeline } from "./adapter/resources/webgl-render-pipeline.js";
|
|
17
18
|
// export {WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';
|
|
18
19
|
export { WEBGLCommandEncoder } from "./adapter/resources/webgl-command-encoder.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAWpC,wBAAwB;AACxB,OAAO,EAAC,aAAa,EAAC,mCAAgC;AAGtD,uBAAuB;AACvB,OAAO,EAAC,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAElE,yBAAyB;AACzB,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,mFAAmF;AACnF,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,OAAO,EAAC,gBAAgB,EAAC,iDAA8C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAWpC,wBAAwB;AACxB,OAAO,EAAC,aAAa,EAAC,mCAAgC;AAGtD,uBAAuB;AACvB,OAAO,EAAC,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAElE,yBAAyB;AACzB,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,mFAAmF;AACnF,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,OAAO,EAAC,gBAAgB,EAAC,iDAA8C;AACvE,OAAO,EAAC,UAAU,EAAC,2CAAwC;AAE3D,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,mFAAmF;AACnF,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,OAAO,EAAC,eAAe,EAAC,iDAA8C;AACtE,2EAA2E;AAC3E,OAAO,EAAC,gBAAgB,EAAC,kDAA+C;AAExE,wBAAwB;AACxB,OAAO,EAAC,sBAAsB,EAAC,wDAAqD;AAEpF,wBAAwB;AAExB,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,kDAA+C;AAEjG,yBAAyB;AACzB,OAAO,EAAC,uBAAuB,EAAC,yDAAsD;AACtF,OAAO,EAAC,iBAAiB,EAAC,uDAAoD;AAE9E,0BAA0B;AAC1B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,sDAAmD;AAEpD,OAAO,EAAC,gBAAgB,EAAC,mDAAgD"}
|
package/dist/utils/fill-array.js
CHANGED
|
@@ -8,7 +8,7 @@ export function fillArray(options) {
|
|
|
8
8
|
const total = count * length;
|
|
9
9
|
let copied = 0;
|
|
10
10
|
for (let i = start; copied < length; copied++) {
|
|
11
|
-
target[i++] = source[copied];
|
|
11
|
+
target[i++] = source[copied] ?? 0;
|
|
12
12
|
}
|
|
13
13
|
while (copied < total) {
|
|
14
14
|
// If we have copied less than half, copy everything we got
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill-array.js","sourceRoot":"","sources":["../../src/utils/fill-array.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,sEAAsE;AACtE,MAAM,UAAU,SAAS,CA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AC,CAAC;YACzD,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,UAAU,CAAC,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;YACjE,MAAM,GAAG,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0-alpha.4",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl core API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@luma.gl/core": "
|
|
43
|
+
"@luma.gl/core": "9.2.0-alpha.6"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/constants": "9.
|
|
46
|
+
"@luma.gl/constants": "9.3.0-alpha.4",
|
|
47
47
|
"@math.gl/types": "^4.1.0",
|
|
48
|
-
"@probe.gl/env": "^4.
|
|
48
|
+
"@probe.gl/env": "^4.1.1"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "7486e7b0377fb6ab961b4499828681bede60f3b1"
|
|
51
51
|
}
|
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
VaryingBinding,
|
|
11
11
|
AttributeShaderType
|
|
12
12
|
} from '@luma.gl/core';
|
|
13
|
-
import {getVariableShaderTypeInfo} from '@luma.gl/core';
|
|
13
|
+
import {getVariableShaderTypeInfo, assertDefined} from '@luma.gl/core';
|
|
14
14
|
|
|
15
15
|
import {GL, GLUniformType} from '@luma.gl/constants';
|
|
16
16
|
import {
|
|
@@ -252,7 +252,11 @@ function readUniformBlocks(
|
|
|
252
252
|
// ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.
|
|
253
253
|
// const uniformRowMajor = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);
|
|
254
254
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
255
|
-
const
|
|
255
|
+
const uniformIndex = uniformIndices[i];
|
|
256
|
+
if (uniformIndex === undefined) {
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
const activeInfo = gl.getActiveUniform(program, uniformIndex);
|
|
256
260
|
if (!activeInfo) {
|
|
257
261
|
throw new Error('activeInfo');
|
|
258
262
|
}
|
|
@@ -314,13 +318,11 @@ function parseUniformName(name: string): {name: string; length: number; isArray:
|
|
|
314
318
|
// if array name then clean the array brackets
|
|
315
319
|
const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
|
|
316
320
|
const matches = UNIFORM_NAME_REGEXP.exec(name);
|
|
317
|
-
|
|
318
|
-
throw new Error(`Failed to parse GLSL uniform name ${name}`);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
+
const uniformName = assertDefined(matches?.[1], `Failed to parse GLSL uniform name ${name}`);
|
|
321
322
|
return {
|
|
322
|
-
name:
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
name: uniformName,
|
|
324
|
+
// TODO - is this a bug, shouldn't we return the value?
|
|
325
|
+
length: matches?.[2] ? 1 : 0,
|
|
326
|
+
isArray: Boolean(matches?.[2])
|
|
325
327
|
};
|
|
326
328
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type
|
|
5
|
+
import {type CompilerMessage} from '@luma.gl/core';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Parse a WebGL-format GLSL compilation log into an array of WebGPU style message records.
|
|
@@ -20,21 +20,43 @@ export function parseShaderCompilerLog(errLog: string): readonly CompilerMessage
|
|
|
20
20
|
continue; // eslint-disable-line no-continue
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const lineWithTrimmedWhitespace = line.trim();
|
|
24
|
+
|
|
23
25
|
const segments: string[] = line.split(':');
|
|
26
|
+
const trimmedMessageType = segments[0]?.trim();
|
|
24
27
|
|
|
25
28
|
// Check for messages with no line information `ERROR: unsupported shader version`
|
|
26
29
|
if (segments.length === 2) {
|
|
27
30
|
const [messageType, message] = segments;
|
|
31
|
+
if (!messageType || !message) {
|
|
32
|
+
messages.push({
|
|
33
|
+
message: lineWithTrimmedWhitespace,
|
|
34
|
+
type: getMessageType(trimmedMessageType || 'info'),
|
|
35
|
+
lineNum: 0,
|
|
36
|
+
linePos: 0
|
|
37
|
+
});
|
|
38
|
+
continue; // eslint-disable-line no-continue
|
|
39
|
+
}
|
|
28
40
|
messages.push({
|
|
29
41
|
message: message.trim(),
|
|
30
42
|
type: getMessageType(messageType),
|
|
31
43
|
lineNum: 0,
|
|
32
44
|
linePos: 0
|
|
33
45
|
});
|
|
46
|
+
|
|
34
47
|
continue; // eslint-disable-line no-continue
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
const [messageType, linePosition, lineNumber, ...rest] = segments;
|
|
51
|
+
if (!messageType || !linePosition || !lineNumber) {
|
|
52
|
+
messages.push({
|
|
53
|
+
message: segments.slice(1).join(':').trim() || lineWithTrimmedWhitespace,
|
|
54
|
+
type: getMessageType(trimmedMessageType || 'info'),
|
|
55
|
+
lineNum: 0,
|
|
56
|
+
linePos: 0
|
|
57
|
+
});
|
|
58
|
+
continue; // eslint-disable-line no-continue
|
|
59
|
+
}
|
|
38
60
|
|
|
39
61
|
let lineNum = parseInt(lineNumber, 10);
|
|
40
62
|
if (isNaN(lineNum)) {
|
|
@@ -2,23 +2,19 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
CopyBufferToBufferOptions,
|
|
7
|
-
CopyBufferToTextureOptions,
|
|
8
|
-
CopyTextureToBufferOptions,
|
|
9
|
-
CopyTextureToTextureOptions
|
|
10
|
-
// ClearTextureOptions,
|
|
11
|
-
// TextureReadOptions
|
|
12
|
-
} from '@luma.gl/core';
|
|
13
|
-
import {CommandBuffer, Texture, Framebuffer} from '@luma.gl/core';
|
|
14
5
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
6
|
+
type CopyBufferToBufferOptions,
|
|
7
|
+
type CopyBufferToTextureOptions,
|
|
8
|
+
type CopyTextureToBufferOptions,
|
|
9
|
+
type CopyTextureToTextureOptions,
|
|
10
|
+
// type ClearTextureOptions,
|
|
11
|
+
// type TextureReadOptions
|
|
12
|
+
CommandBuffer,
|
|
13
|
+
Texture,
|
|
14
|
+
Framebuffer,
|
|
15
|
+
assertDefined
|
|
16
|
+
} from '@luma.gl/core';
|
|
17
|
+
import {GL, type GLTextureTarget, type GLTextureCubeMapTarget} from '@luma.gl/constants';
|
|
22
18
|
|
|
23
19
|
import {WebGLDevice} from '../webgl-device';
|
|
24
20
|
import {WEBGLBuffer} from './webgl-buffer';
|
|
@@ -145,7 +141,7 @@ function _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferO
|
|
|
145
141
|
height = options.sourceTexture.height,
|
|
146
142
|
depthOrArrayLayers = 0,
|
|
147
143
|
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
|
|
148
|
-
origin = [0, 0],
|
|
144
|
+
origin = [0, 0, 0],
|
|
149
145
|
|
|
150
146
|
/** Destination buffer */
|
|
151
147
|
destinationBuffer,
|
|
@@ -181,9 +177,9 @@ function _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferO
|
|
|
181
177
|
const webglBuffer = destinationBuffer as WEBGLBuffer;
|
|
182
178
|
const sourceWidth = width || framebuffer.width;
|
|
183
179
|
const sourceHeight = height || framebuffer.height;
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
);
|
|
180
|
+
const colorAttachment0 = assertDefined(framebuffer.colorAttachments[0]);
|
|
181
|
+
|
|
182
|
+
const sourceParams = getTextureFormatWebGL(colorAttachment0.texture.props.format);
|
|
187
183
|
const sourceFormat = sourceParams.format;
|
|
188
184
|
const sourceType = sourceParams.type;
|
|
189
185
|
|
|
@@ -256,7 +252,7 @@ function _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextur
|
|
|
256
252
|
origin = [0, 0],
|
|
257
253
|
|
|
258
254
|
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to. */
|
|
259
|
-
destinationOrigin = [0, 0],
|
|
255
|
+
destinationOrigin = [0, 0, 0],
|
|
260
256
|
|
|
261
257
|
/** Texture to copy to/from. */
|
|
262
258
|
destinationTexture
|
|
@@ -275,7 +271,7 @@ function _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextur
|
|
|
275
271
|
} = options;
|
|
276
272
|
|
|
277
273
|
const {framebuffer, destroyFramebuffer} = getFramebuffer(sourceTexture);
|
|
278
|
-
const [sourceX, sourceY] = origin;
|
|
274
|
+
const [sourceX = 0, sourceY = 0] = origin;
|
|
279
275
|
const [destinationX, destinationY, destinationZ] = destinationOrigin;
|
|
280
276
|
|
|
281
277
|
// @ts-expect-error native bindFramebuffer is overridden by our state tracker
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Fence, type FenceProps} from '@luma.gl/core';
|
|
6
|
+
import {WebGLDevice} from '../webgl-device';
|
|
7
|
+
|
|
8
|
+
/** WebGL fence implemented with gl.fenceSync */
|
|
9
|
+
export class WEBGLFence extends Fence {
|
|
10
|
+
readonly device: WebGLDevice;
|
|
11
|
+
readonly gl: WebGL2RenderingContext;
|
|
12
|
+
readonly handle: WebGLSync;
|
|
13
|
+
readonly signaled: Promise<void>;
|
|
14
|
+
private _signaled = false;
|
|
15
|
+
|
|
16
|
+
constructor(device: WebGLDevice, props: FenceProps = {}) {
|
|
17
|
+
super(device, {});
|
|
18
|
+
this.device = device;
|
|
19
|
+
this.gl = device.gl;
|
|
20
|
+
|
|
21
|
+
const sync = this.props.handle || this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
22
|
+
if (!sync) {
|
|
23
|
+
throw new Error('Failed to create WebGL fence');
|
|
24
|
+
}
|
|
25
|
+
this.handle = sync;
|
|
26
|
+
|
|
27
|
+
this.signaled = new Promise(resolve => {
|
|
28
|
+
const poll = () => {
|
|
29
|
+
const status = this.gl.clientWaitSync(this.handle, 0, 0);
|
|
30
|
+
if (status === this.gl.ALREADY_SIGNALED || status === this.gl.CONDITION_SATISFIED) {
|
|
31
|
+
this._signaled = true;
|
|
32
|
+
resolve();
|
|
33
|
+
} else {
|
|
34
|
+
setTimeout(poll, 1);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
poll();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
isSignaled(): boolean {
|
|
42
|
+
if (this._signaled) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
const status = this.gl.getSyncParameter(this.handle, this.gl.SYNC_STATUS);
|
|
46
|
+
this._signaled = status === this.gl.SIGNALED;
|
|
47
|
+
return this._signaled;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
destroy(): void {
|
|
51
|
+
if (!this.destroyed) {
|
|
52
|
+
this.gl.deleteSync(this.handle);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -24,6 +24,12 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
24
24
|
super(device, props);
|
|
25
25
|
this.device = device;
|
|
26
26
|
|
|
27
|
+
if (!props?.framebuffer) {
|
|
28
|
+
// Default-framebuffer rendering bypasses CanvasContext.getCurrentFramebuffer(),
|
|
29
|
+
// so flush any deferred canvas resize before deriving viewport state.
|
|
30
|
+
device.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
// If no viewport is provided, apply reasonably defaults
|
|
28
34
|
let viewport: NumberArray4 | undefined;
|
|
29
35
|
if (!props?.parameters?.viewport) {
|
|
@@ -50,7 +56,8 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
50
56
|
(_, i) => GL.COLOR_ATTACHMENT0 + i
|
|
51
57
|
);
|
|
52
58
|
this.device.gl.drawBuffers(drawBuffers);
|
|
53
|
-
} else {
|
|
59
|
+
} else if (!this.props.framebuffer) {
|
|
60
|
+
// Default framebuffer only supports GL.BACK/GL.NONE draw buffers
|
|
54
61
|
this.device.gl.drawBuffers([GL.BACK]);
|
|
55
62
|
}
|
|
56
63
|
|
|
@@ -110,12 +117,9 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
110
117
|
if (parameters.blendConstant) {
|
|
111
118
|
glParameters.blendColor = parameters.blendConstant;
|
|
112
119
|
}
|
|
113
|
-
if (parameters.stencilReference) {
|
|
114
|
-
// eslint-disable-next-line no-console
|
|
115
|
-
console.warn('RenderPassParameters.stencilReference not yet implemented in WebGL');
|
|
116
|
-
// parameters.stencilFunc = [func, ref, mask];
|
|
117
|
-
// Does this work?
|
|
120
|
+
if (parameters.stencilReference !== undefined) {
|
|
118
121
|
glParameters[GL.STENCIL_REF] = parameters.stencilReference;
|
|
122
|
+
glParameters[GL.STENCIL_BACK_REF] = parameters.stencilReference;
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
if ('colorMask' in parameters) {
|
|
@@ -452,8 +452,7 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
452
452
|
if ((location as GL) === GL.INVALID_INDEX) {
|
|
453
453
|
throw new Error(`Invalid uniform block name ${name}`);
|
|
454
454
|
}
|
|
455
|
-
gl.uniformBlockBinding(this.handle,
|
|
456
|
-
// console.debug(binding, location);
|
|
455
|
+
gl.uniformBlockBinding(this.handle, location, uniformBufferIndex);
|
|
457
456
|
if (value instanceof WEBGLBuffer) {
|
|
458
457
|
gl.bindBufferBase(GL.UNIFORM_BUFFER, uniformBufferIndex, value.handle);
|
|
459
458
|
} else {
|