@luma.gl/webgl 9.1.0-alpha.16 → 9.1.0-alpha.18
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/sampler-parameters.js +6 -4
- package/dist/adapter/converters/texture-formats.d.ts +49 -11
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +150 -160
- package/dist/adapter/helpers/format-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/format-utils.js +6 -0
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +10 -8
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +46 -32
- package/dist/adapter/resources/webgl-command-buffer.d.ts +59 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +72 -16
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +3 -0
- package/dist/adapter/resources/webgl-external-texture.js +14 -0
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +1 -2
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +29 -17
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +6 -5
- package/dist/adapter/resources/webgl-shader.js +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +8 -14
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +119 -208
- package/dist/adapter/webgl-adapter.js +1 -1
- package/dist/adapter/webgl-device.d.ts +7 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +22 -10
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -0
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +4 -2
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
- package/dist/context/helpers/create-browser-context.js +17 -3
- package/dist/dist.dev.js +219 -269
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +213 -266
- package/dist/index.cjs.map +3 -3
- package/package.json +4 -4
- package/src/adapter/converters/sampler-parameters.ts +6 -4
- package/src/adapter/converters/texture-formats.ts +171 -177
- package/src/adapter/helpers/format-utils.ts +6 -0
- package/src/adapter/helpers/webgl-texture-utils.ts +66 -45
- package/src/adapter/resources/webgl-command-buffer.ts +108 -24
- package/src/adapter/resources/webgl-command-encoder.ts +6 -0
- package/src/adapter/resources/webgl-external-texture.ts +14 -0
- package/src/adapter/resources/webgl-framebuffer.ts +1 -2
- package/src/adapter/resources/webgl-render-pass.ts +33 -20
- package/src/adapter/resources/webgl-render-pipeline.ts +6 -5
- package/src/adapter/resources/webgl-shader.ts +1 -1
- package/src/adapter/resources/webgl-texture.ts +126 -235
- package/src/adapter/webgl-adapter.ts +1 -1
- package/src/adapter/webgl-device.ts +23 -10
- package/src/context/debug/webgl-developer-tools.ts +5 -2
- package/src/context/helpers/create-browser-context.ts +18 -3
|
@@ -6,6 +6,7 @@ import { GL } from '@luma.gl/constants';
|
|
|
6
6
|
import { getGLTypeFromTypedArray, getTypedArrayFromGLType } from "./typed-array-utils.js";
|
|
7
7
|
import { glFormatToComponents, glTypeToBytes } from "./format-utils.js";
|
|
8
8
|
import { WEBGLTexture } from "../resources/webgl-texture.js";
|
|
9
|
+
import { withGLParameters } from "../../context/state-tracker/with-parameters.js";
|
|
9
10
|
/** A "border" parameter is required in many WebGL texture APIs, but must always be 0... */
|
|
10
11
|
const BORDER = 0;
|
|
11
12
|
/**
|
|
@@ -41,24 +42,27 @@ export function copyExternalImageToMipLevel(gl, handle, image, options) {
|
|
|
41
42
|
const { x = 0, y = 0, z = 0 } = options;
|
|
42
43
|
const { glFormat, glType } = options;
|
|
43
44
|
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
45
|
+
const glParameters = options.flipY ? { [37440]: true } : {};
|
|
46
|
+
withGLParameters(gl, glParameters, () => {
|
|
47
|
+
switch (dimension) {
|
|
48
|
+
case '2d-array':
|
|
49
|
+
case '3d':
|
|
50
|
+
gl.bindTexture(glTarget, handle);
|
|
51
|
+
// prettier-ignore
|
|
52
|
+
gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);
|
|
53
|
+
gl.bindTexture(glTarget, null);
|
|
54
|
+
break;
|
|
55
|
+
case '2d':
|
|
56
|
+
case 'cube':
|
|
57
|
+
gl.bindTexture(glTarget, handle);
|
|
58
|
+
// prettier-ignore
|
|
59
|
+
gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);
|
|
60
|
+
gl.bindTexture(glTarget, null);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
throw new Error(dimension);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
62
66
|
}
|
|
63
67
|
/**
|
|
64
68
|
* Copy a region of data from a CPU memory buffer into this texture.
|
|
@@ -168,7 +172,7 @@ export function getWebGLCubeFaceTarget(glTarget, dimension, level) {
|
|
|
168
172
|
* @returns pixel array,
|
|
169
173
|
*/
|
|
170
174
|
export function readPixelsToArray(source, options) {
|
|
171
|
-
const { sourceX = 0, sourceY = 0, sourceAttachment =
|
|
175
|
+
const { sourceX = 0, sourceY = 0, sourceAttachment = 0 // TODO - support gl.readBuffer
|
|
172
176
|
} = options || {};
|
|
173
177
|
let { target = null,
|
|
174
178
|
// following parameters are auto deduced if not provided
|
|
@@ -176,24 +180,33 @@ export function readPixelsToArray(source, options) {
|
|
|
176
180
|
const { framebuffer, deleteFramebuffer } = getFramebuffer(source);
|
|
177
181
|
// assert(framebuffer);
|
|
178
182
|
const { gl, handle } = framebuffer;
|
|
179
|
-
const attachment = sourceAttachment - 36064;
|
|
180
183
|
sourceWidth ||= framebuffer.width;
|
|
181
184
|
sourceHeight ||= framebuffer.height;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
sourceDepth =
|
|
187
|
-
sourceFormat ||=
|
|
185
|
+
const texture = framebuffer.colorAttachments[sourceAttachment]?.texture;
|
|
186
|
+
if (!texture) {
|
|
187
|
+
throw new Error(`Invalid framebuffer attachment ${sourceAttachment}`);
|
|
188
|
+
}
|
|
189
|
+
sourceDepth = texture?.depth || 1;
|
|
190
|
+
sourceFormat ||= texture?.glFormat || 6408;
|
|
188
191
|
// Deduce the type from color attachment if not provided.
|
|
189
|
-
sourceType ||=
|
|
192
|
+
sourceType ||= texture?.glType || 5121;
|
|
190
193
|
// Deduce type and allocated pixelArray if needed
|
|
191
194
|
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
|
|
192
195
|
// Pixel array available, if necessary, deduce type from it.
|
|
193
196
|
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
197
|
+
// Note: luma.gl overrides bindFramebuffer so that we can reliably restore the previous framebuffer (this is the only function for which we do that)
|
|
194
198
|
const prevHandle = gl.bindFramebuffer(36160, handle);
|
|
199
|
+
// Select the color attachment to read from
|
|
200
|
+
gl.readBuffer(36064 + sourceAttachment);
|
|
201
|
+
// There is a lot of hedging in the WebGL2 spec about what formats are guaranteed to be readable
|
|
202
|
+
// (It should always be possible to read RGBA/UNSIGNED_BYTE, but most other combinations are not guaranteed)
|
|
203
|
+
// Querying is possible but expensive:
|
|
204
|
+
// const {device} = framebuffer;
|
|
205
|
+
// texture.glReadFormat ||= gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT);
|
|
206
|
+
// texture.glReadType ||= gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE);
|
|
207
|
+
// console.log('params', device.getGLKey(texture.glReadFormat), device.getGLKey(texture.glReadType));
|
|
195
208
|
gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
|
|
196
|
-
|
|
209
|
+
gl.readBuffer(36064);
|
|
197
210
|
gl.bindFramebuffer(36160, prevHandle || null);
|
|
198
211
|
if (deleteFramebuffer) {
|
|
199
212
|
framebuffer.destroy();
|
|
@@ -331,14 +344,15 @@ export function toFramebuffer(texture, props) {
|
|
|
331
344
|
return framebuffer;
|
|
332
345
|
}
|
|
333
346
|
// eslint-disable-next-line max-params
|
|
334
|
-
function getPixelArray(pixelArray,
|
|
347
|
+
function getPixelArray(pixelArray, glType, glFormat, width, height, depth) {
|
|
335
348
|
if (pixelArray) {
|
|
336
349
|
return pixelArray;
|
|
337
350
|
}
|
|
351
|
+
// const formatInfo = decodeTextureFormat(format);
|
|
338
352
|
// Allocate pixel array if not already available, using supplied type
|
|
339
|
-
|
|
340
|
-
const ArrayType = getTypedArrayFromGLType(
|
|
341
|
-
const components = glFormatToComponents(
|
|
353
|
+
glType ||= 5121;
|
|
354
|
+
const ArrayType = getTypedArrayFromGLType(glType, { clamped: false });
|
|
355
|
+
const components = glFormatToComponents(glFormat);
|
|
342
356
|
// TODO - check for composite type (components = 1).
|
|
343
357
|
return new ArrayType(width * height * components);
|
|
344
358
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CopyBufferToBufferOptions, CopyBufferToTextureOptions, CopyTextureToBufferOptions, CopyTextureToTextureOptions } from '@luma.gl/core';
|
|
2
2
|
import { CommandBuffer } from '@luma.gl/core';
|
|
3
|
-
import { GL } from '@luma.gl/constants';
|
|
3
|
+
import { GL, GLTextureTarget, GLTextureCubeMapTarget } from '@luma.gl/constants';
|
|
4
4
|
import { WebGLDevice } from "../webgl-device.js";
|
|
5
5
|
type CopyBufferToBufferCommand = {
|
|
6
6
|
name: 'copy-buffer-to-buffer';
|
|
@@ -18,14 +18,71 @@ type CopyTextureToTextureCommand = {
|
|
|
18
18
|
name: 'copy-texture-to-texture';
|
|
19
19
|
options: CopyTextureToTextureOptions;
|
|
20
20
|
};
|
|
21
|
-
type
|
|
21
|
+
type ClearTextureCommand = {
|
|
22
|
+
name: 'clear-texture';
|
|
23
|
+
options: {};
|
|
24
|
+
};
|
|
25
|
+
type ReadTextureCommand = {
|
|
26
|
+
name: 'read-texture';
|
|
27
|
+
options: {};
|
|
28
|
+
};
|
|
29
|
+
type Command = CopyBufferToBufferCommand | CopyBufferToTextureCommand | CopyTextureToBufferCommand | CopyTextureToTextureCommand | ClearTextureCommand | ReadTextureCommand;
|
|
22
30
|
export declare class WEBGLCommandBuffer extends CommandBuffer {
|
|
23
31
|
device: WebGLDevice;
|
|
24
32
|
commands: Command[];
|
|
25
33
|
constructor(device: WebGLDevice);
|
|
26
34
|
submitCommands(commands?: Command[]): void;
|
|
27
35
|
}
|
|
36
|
+
/** Clear one mip level of a texture *
|
|
37
|
+
function _clearTexture(device: WebGLDevice, options: ClearTextureOptions) {
|
|
38
|
+
const BORDER = 0;
|
|
39
|
+
const {dimension, width, height, depth = 0, mipLevel = 0} = options;
|
|
40
|
+
const {glInternalFormat, glFormat, glType, compressed} = options;
|
|
41
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
42
|
+
|
|
43
|
+
switch (dimension) {
|
|
44
|
+
case '2d-array':
|
|
45
|
+
case '3d':
|
|
46
|
+
if (compressed) {
|
|
47
|
+
// prettier-ignore
|
|
48
|
+
device.gl.compressedTexImage3D(glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, null);
|
|
49
|
+
} else {
|
|
50
|
+
// prettier-ignore
|
|
51
|
+
device.gl.texImage3D( glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, glFormat, glType, null);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
|
|
55
|
+
case '2d':
|
|
56
|
+
case 'cube':
|
|
57
|
+
if (compressed) {
|
|
58
|
+
// prettier-ignore
|
|
59
|
+
device.gl.compressedTexImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, null);
|
|
60
|
+
} else {
|
|
61
|
+
// prettier-ignore
|
|
62
|
+
device.gl.texImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, glFormat, glType, null);
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
default:
|
|
67
|
+
throw new Error(dimension);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* In WebGL, cube maps specify faces by overriding target instead of using the depth parameter.
|
|
73
|
+
* @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.
|
|
74
|
+
* @returns glTarget unchanged, if dimension !== 'cube'.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getWebGLCubeFaceTarget(glTarget: GLTextureTarget, dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d', level: number): GLTextureTarget | GLTextureCubeMapTarget;
|
|
77
|
+
/**
|
|
78
|
+
* Returns number of components in a specific readPixels WebGL format
|
|
79
|
+
* @todo use shadertypes utils instead?
|
|
80
|
+
*/
|
|
28
81
|
export declare function glFormatToComponents(format: any): 1 | 2 | 3 | 4;
|
|
82
|
+
/**
|
|
83
|
+
* Return byte count for given readPixels WebGL type
|
|
84
|
+
* @todo use shadertypes utils instead?
|
|
85
|
+
*/
|
|
29
86
|
export declare function glTypeToBytes(type: GL): 1 | 2 | 4;
|
|
30
87
|
export {};
|
|
31
88
|
//# sourceMappingURL=webgl-command-buffer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-command-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,
|
|
1
|
+
{"version":3,"file":"webgl-command-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAG5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,aAAa,EAAuB,MAAM,eAAe,CAAC;AAClE,OAAO,EACL,EAAE,EACF,eAAe,EACf,sBAAsB,EAIvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAM5C,KAAK,yBAAyB,GAAG;IAC/B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,yBAAyB,CAAC;CACpC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,0BAA0B,CAAC;CACrC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,0BAA0B,CAAC;CACrC,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,2BAA2B,CAAC;CACtC,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,KAAK,OAAO,GACR,yBAAyB,GACzB,0BAA0B,GAC1B,0BAA0B,GAC1B,2BAA2B,GAC3B,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB,qBAAa,kBAAmB,SAAQ,aAAa;IACnD,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAM;gBAEb,MAAM,EAAE,WAAW;IAK/B,cAAc,CAAC,QAAQ,GAAE,OAAO,EAAkB;CAuBnD;AAiPD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkCI;AAMJ;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,EAClE,KAAK,EAAE,MAAM,GACZ,eAAe,GAAG,sBAAsB,CAE1C;AAqBD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAmB1D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAcjD"}
|
|
@@ -27,6 +27,11 @@ export class WEBGLCommandBuffer extends CommandBuffer {
|
|
|
27
27
|
case 'copy-texture-to-texture':
|
|
28
28
|
_copyTextureToTexture(this.device, command.options);
|
|
29
29
|
break;
|
|
30
|
+
// case 'clear-texture':
|
|
31
|
+
// _clearTexture(this.device, command.options);
|
|
32
|
+
// break;
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(command.name);
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
}
|
|
@@ -207,7 +212,69 @@ function _copyTextureToTexture(device, options) {
|
|
|
207
212
|
framebuffer.destroy();
|
|
208
213
|
}
|
|
209
214
|
}
|
|
210
|
-
|
|
215
|
+
/** Clear one mip level of a texture *
|
|
216
|
+
function _clearTexture(device: WebGLDevice, options: ClearTextureOptions) {
|
|
217
|
+
const BORDER = 0;
|
|
218
|
+
const {dimension, width, height, depth = 0, mipLevel = 0} = options;
|
|
219
|
+
const {glInternalFormat, glFormat, glType, compressed} = options;
|
|
220
|
+
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
221
|
+
|
|
222
|
+
switch (dimension) {
|
|
223
|
+
case '2d-array':
|
|
224
|
+
case '3d':
|
|
225
|
+
if (compressed) {
|
|
226
|
+
// prettier-ignore
|
|
227
|
+
device.gl.compressedTexImage3D(glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, null);
|
|
228
|
+
} else {
|
|
229
|
+
// prettier-ignore
|
|
230
|
+
device.gl.texImage3D( glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, glFormat, glType, null);
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
|
|
234
|
+
case '2d':
|
|
235
|
+
case 'cube':
|
|
236
|
+
if (compressed) {
|
|
237
|
+
// prettier-ignore
|
|
238
|
+
device.gl.compressedTexImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, null);
|
|
239
|
+
} else {
|
|
240
|
+
// prettier-ignore
|
|
241
|
+
device.gl.texImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, glFormat, glType, null);
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
|
|
245
|
+
default:
|
|
246
|
+
throw new Error(dimension);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
*/
|
|
250
|
+
// function _readTexture(device: WebGLDevice, options: CopyTextureToBufferOptions) {}
|
|
251
|
+
// HELPERS
|
|
252
|
+
/**
|
|
253
|
+
* In WebGL, cube maps specify faces by overriding target instead of using the depth parameter.
|
|
254
|
+
* @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.
|
|
255
|
+
* @returns glTarget unchanged, if dimension !== 'cube'.
|
|
256
|
+
*/
|
|
257
|
+
export function getWebGLCubeFaceTarget(glTarget, dimension, level) {
|
|
258
|
+
return dimension === 'cube' ? 34069 + level : glTarget;
|
|
259
|
+
}
|
|
260
|
+
/** Wrap a texture in a framebuffer so that we can use WebGL APIs that work on framebuffers */
|
|
261
|
+
function getFramebuffer(source) {
|
|
262
|
+
if (source instanceof Texture) {
|
|
263
|
+
const { width, height, id } = source;
|
|
264
|
+
const framebuffer = source.device.createFramebuffer({
|
|
265
|
+
id: `framebuffer-for-${id}`,
|
|
266
|
+
width,
|
|
267
|
+
height,
|
|
268
|
+
colorAttachments: [source]
|
|
269
|
+
});
|
|
270
|
+
return { framebuffer, destroyFramebuffer: true };
|
|
271
|
+
}
|
|
272
|
+
return { framebuffer: source, destroyFramebuffer: false };
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Returns number of components in a specific readPixels WebGL format
|
|
276
|
+
* @todo use shadertypes utils instead?
|
|
277
|
+
*/
|
|
211
278
|
export function glFormatToComponents(format) {
|
|
212
279
|
switch (format) {
|
|
213
280
|
case 6406:
|
|
@@ -228,7 +295,10 @@ export function glFormatToComponents(format) {
|
|
|
228
295
|
throw new Error('GLFormat');
|
|
229
296
|
}
|
|
230
297
|
}
|
|
231
|
-
|
|
298
|
+
/**
|
|
299
|
+
* Return byte count for given readPixels WebGL type
|
|
300
|
+
* @todo use shadertypes utils instead?
|
|
301
|
+
*/
|
|
232
302
|
export function glTypeToBytes(type) {
|
|
233
303
|
switch (type) {
|
|
234
304
|
case 5121:
|
|
@@ -244,17 +314,3 @@ export function glTypeToBytes(type) {
|
|
|
244
314
|
throw new Error('GLType');
|
|
245
315
|
}
|
|
246
316
|
}
|
|
247
|
-
// Helper methods
|
|
248
|
-
function getFramebuffer(source) {
|
|
249
|
-
if (source instanceof Texture) {
|
|
250
|
-
const { width, height, id } = source;
|
|
251
|
-
const framebuffer = source.device.createFramebuffer({
|
|
252
|
-
id: `framebuffer-for-${id}`,
|
|
253
|
-
width,
|
|
254
|
-
height,
|
|
255
|
-
colorAttachments: [source]
|
|
256
|
-
});
|
|
257
|
-
return { framebuffer, destroyFramebuffer: true };
|
|
258
|
-
}
|
|
259
|
-
return { framebuffer: source, destroyFramebuffer: false };
|
|
260
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,
|
|
1
|
+
{"version":3,"file":"webgl-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAG3B,QAAQ,EACR,MAAM,EACP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,kBAAkB,EAAC,kCAA+B;AAC1D,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAE5C,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAC;gBAE/B,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB;IAMlD,OAAO,IAAI,IAAI;IAEf,MAAM,IAAI,IAAI;IAQvB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI;IAI5D,mBAAmB,CAAC,OAAO,EAAE,0BAA0B;IAIvD,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,IAAI;IAI9D,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI;IAQvD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IACxC,aAAa;IAEb,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAE5C,eAAe,CACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,GACA,IAAI;CACR"}
|
|
@@ -30,6 +30,9 @@ export class WEBGLCommandEncoder extends CommandEncoder {
|
|
|
30
30
|
copyTextureToTexture(options) {
|
|
31
31
|
this.commandBuffer.commands.push({ name: 'copy-texture-to-texture', options });
|
|
32
32
|
}
|
|
33
|
+
// clearTexture(options: ClearTextureOptions): void {
|
|
34
|
+
// this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});
|
|
35
|
+
// }
|
|
33
36
|
pushDebugGroup(groupLabel) { }
|
|
34
37
|
popDebugGroup() { }
|
|
35
38
|
insertDebugMarker(markerLabel) { }
|
|
@@ -71,6 +71,20 @@ export class WEBGLExternalTexture extends WEBGLTexture {
|
|
|
71
71
|
data.addEventListener('loadeddata', () => this.initialize(props));
|
|
72
72
|
return this;
|
|
73
73
|
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
initialize() {
|
|
77
|
+
// TODO - Video handling, move to ExternalTexture?
|
|
78
|
+
// if (isVideo) {
|
|
79
|
+
// this._video = {
|
|
80
|
+
// video: data,
|
|
81
|
+
// // TODO - should we be using the sampler parameters here?
|
|
82
|
+
// parameters: {},
|
|
83
|
+
// // @ts-expect-error HTMLVideoElement.HAVE_CURRENT_DATA is not declared
|
|
84
|
+
// lastTime: data.readyState >= HTMLVideoElement.HAVE_CURRENT_DATA ? data.currentTime : -1
|
|
85
|
+
// };
|
|
86
|
+
// }
|
|
87
|
+
}
|
|
74
88
|
|
|
75
89
|
update(): this {
|
|
76
90
|
if (this._video) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,gBAAgB,EAA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AAM,EAAE,gBAAgB,CAAC;IAEzB,gBAAgB,EAAE,gBAAgB,EAAE,CAAM;IAC1C,sBAAsB,EAAE,gBAAgB,GAAG,IAAI,CAAQ;gBAE3C,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB;IAsBxD,+CAA+C;IACtC,OAAO,IAAI,IAAI;IAQxB,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAqCnC,mGAAmG;IAYnG;;;;;OAKG;IACH,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,gBAAgB,GAAG,IAAI;CA8BlF;AAqCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BE"}
|
|
@@ -52,8 +52,7 @@ export class WEBGLFramebuffer extends Framebuffer {
|
|
|
52
52
|
this._attachTextureView(attachmentPoint, this.depthStencilAttachment);
|
|
53
53
|
}
|
|
54
54
|
/** Check the status */
|
|
55
|
-
|
|
56
|
-
if (this.props.check !== false) {
|
|
55
|
+
if (this.device.props.debug) {
|
|
57
56
|
const status = this.gl.checkFramebufferStatus(36160);
|
|
58
57
|
if (status !== 36053) {
|
|
59
58
|
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAe,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAChF,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAK,YAAY,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAe,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAChF,OAAO,EAAC,WAAW,EAAC,2BAAwB;AAC5C,OAAO,EAAK,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAOpD,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B,8DAA8D;IAC9D,YAAY,EAAE,YAAY,CAAC;gBAEf,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe;IAoCvD,GAAG,IAAI,IAAI;IAKX,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IACxC,aAAa,IAAI,IAAI;IACrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAO5C;;OAEG;IACH,aAAa,CAAC,UAAU,GAAE,oBAAyB,GAAG,IAAI;IAmD1D,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKpC,iBAAiB,IAAI,IAAI;IAOlC;;OAEG;IACH,SAAS,CAAC,KAAK,IAAI,IAAI;IAkCvB;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,UAAU,GAAE,MAAU,EAAE,KAAK,GAAE,YAA2B;CA8CtF"}
|
|
@@ -5,11 +5,6 @@ import { RenderPass } from '@luma.gl/core';
|
|
|
5
5
|
import { GL } from '@luma.gl/constants';
|
|
6
6
|
import { withGLParameters } from "../../context/state-tracker/with-parameters.js";
|
|
7
7
|
import { setGLParameters } from "../../context/parameters/unified-parameter-api.js";
|
|
8
|
-
// Should collapse during minification
|
|
9
|
-
const GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
10
|
-
const GL_STENCIL_BUFFER_BIT = 0x00000400;
|
|
11
|
-
const GL_COLOR_BUFFER_BIT = 0x00004000;
|
|
12
|
-
const GL_COLOR = 0x1800;
|
|
13
8
|
const COLOR_CHANNELS = [0x1, 0x2, 0x4, 0x8]; // GPUColorWrite RED, GREEN, BLUE, ALPHA
|
|
14
9
|
export class WEBGLRenderPass extends RenderPass {
|
|
15
10
|
device;
|
|
@@ -35,6 +30,14 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
35
30
|
// TODO - do parameters (scissorRect) affect the clear operation?
|
|
36
31
|
this.device.pushState();
|
|
37
32
|
this.setParameters({ viewport, ...this.props.parameters });
|
|
33
|
+
// Specify mapping of draw buffer locations to color attachments
|
|
34
|
+
if (this.props.framebuffer) {
|
|
35
|
+
const drawBuffers = this.props.framebuffer.colorAttachments.map((_, i) => 36064 + i);
|
|
36
|
+
this.device.gl.drawBuffers(drawBuffers);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.device.gl.drawBuffers([1029]);
|
|
40
|
+
}
|
|
38
41
|
// Hack - for now WebGL draws in "immediate mode" (instead of queueing the operations)...
|
|
39
42
|
this.clear();
|
|
40
43
|
}
|
|
@@ -107,16 +110,23 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
107
110
|
clear() {
|
|
108
111
|
const glParameters = { ...this.glParameters };
|
|
109
112
|
let clearMask = 0;
|
|
110
|
-
if (this.props.
|
|
111
|
-
|
|
113
|
+
if (this.props.clearColors) {
|
|
114
|
+
this.props.clearColors.forEach((color, drawBufferIndex) => {
|
|
115
|
+
if (color) {
|
|
116
|
+
this.clearColorBuffer(drawBufferIndex, color);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (this.props.clearColor !== false && this.props.clearColors === undefined) {
|
|
121
|
+
clearMask |= 16384;
|
|
112
122
|
glParameters.clearColor = this.props.clearColor;
|
|
113
123
|
}
|
|
114
124
|
if (this.props.clearDepth !== false) {
|
|
115
|
-
clearMask |=
|
|
125
|
+
clearMask |= 256;
|
|
116
126
|
glParameters.clearDepth = this.props.clearDepth;
|
|
117
127
|
}
|
|
118
128
|
if (this.props.clearStencil !== false) {
|
|
119
|
-
clearMask |=
|
|
129
|
+
clearMask |= 1024;
|
|
120
130
|
glParameters.clearStencil = this.props.clearStencil;
|
|
121
131
|
}
|
|
122
132
|
if (clearMask !== 0) {
|
|
@@ -124,10 +134,6 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
124
134
|
withGLParameters(this.device.gl, glParameters, () => {
|
|
125
135
|
this.device.gl.clear(clearMask);
|
|
126
136
|
});
|
|
127
|
-
// TODO - clear multiple color attachments
|
|
128
|
-
// for (attachment of this.framebuffer.colorAttachments) {
|
|
129
|
-
// this.clearColorBuffer
|
|
130
|
-
// }
|
|
131
137
|
}
|
|
132
138
|
}
|
|
133
139
|
/**
|
|
@@ -137,16 +143,22 @@ export class WEBGLRenderPass extends RenderPass {
|
|
|
137
143
|
withGLParameters(this.device.gl, { framebuffer: this.props.framebuffer }, () => {
|
|
138
144
|
// Method selection per OpenGL ES 3 docs
|
|
139
145
|
switch (value.constructor) {
|
|
146
|
+
case Int8Array:
|
|
147
|
+
case Int16Array:
|
|
140
148
|
case Int32Array:
|
|
141
|
-
this.device.gl.clearBufferiv(
|
|
149
|
+
this.device.gl.clearBufferiv(6144, drawBuffer, value);
|
|
142
150
|
break;
|
|
151
|
+
case Uint8Array:
|
|
152
|
+
case Uint8ClampedArray:
|
|
153
|
+
case Uint16Array:
|
|
143
154
|
case Uint32Array:
|
|
144
|
-
this.device.gl.clearBufferuiv(
|
|
155
|
+
this.device.gl.clearBufferuiv(6144, drawBuffer, value);
|
|
145
156
|
break;
|
|
146
157
|
case Float32Array:
|
|
147
|
-
|
|
148
|
-
this.device.gl.clearBufferfv(GL_COLOR, drawBuffer, value);
|
|
158
|
+
this.device.gl.clearBufferfv(6144, drawBuffer, value);
|
|
149
159
|
break;
|
|
160
|
+
default:
|
|
161
|
+
throw new Error('clearColorBuffer: color must be typed array');
|
|
150
162
|
}
|
|
151
163
|
});
|
|
152
164
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webg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CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;KAC5C,GAAG,OAAO;IAgGF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;cAkBhD,YAAY;IA2B5B,wFAAwF;IAClF,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAkCpF;;;;OAIG;IACH,cAAc,IAAI,SAAS,GAAG,SAAS,GAAG,YAAY;IAmBtD,6DAA6D;IACvD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB3C;;;;OAIG;IACH,sBAAsB;IAuBtB,iDAAiD;IACjD,cAAc;IAyFd;;;OAGG;IACH,cAAc;CASf"}
|
|
@@ -303,11 +303,12 @@ export class WEBGLRenderPipeline extends RenderPipeline {
|
|
|
303
303
|
texturesRenderable = false;
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
306
|
+
// TODO - remove this should be handled by ExternalTexture
|
|
307
|
+
// for (const [, texture] of Object.entries(this.bindings)) {
|
|
308
|
+
// if (texture instanceof WEBGLTexture) {
|
|
309
|
+
// texture.update();
|
|
310
|
+
// }
|
|
311
|
+
// }
|
|
311
312
|
return texturesRenderable;
|
|
312
313
|
}
|
|
313
314
|
/** Apply any bindings (before each draw call) */
|
|
@@ -57,7 +57,7 @@ export class WEBGLShader extends Shader {
|
|
|
57
57
|
gl.shaderSource(this.handle, source);
|
|
58
58
|
gl.compileShader(this.handle);
|
|
59
59
|
// For performance reasons, avoid checking shader compilation errors on production
|
|
60
|
-
if (
|
|
60
|
+
if (!this.device.props.debug) {
|
|
61
61
|
this.compilationStatus = 'pending';
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
@@ -8,14 +8,16 @@ import { WEBGLTextureView } from "./webgl-texture-view.js";
|
|
|
8
8
|
* WebGL... the texture API from hell... hopefully made simpler
|
|
9
9
|
*/
|
|
10
10
|
export declare class WEBGLTexture extends Texture {
|
|
11
|
-
readonly MAX_ATTRIBUTES: number;
|
|
12
11
|
readonly device: WebGLDevice;
|
|
13
12
|
readonly gl: WebGL2RenderingContext;
|
|
14
13
|
handle: WebGLTexture;
|
|
15
14
|
sampler: WEBGLSampler;
|
|
16
15
|
view: WEBGLTextureView;
|
|
17
16
|
mipmaps: boolean;
|
|
17
|
+
/** Whether the internal format is compressed */
|
|
18
|
+
compressed: boolean;
|
|
18
19
|
/**
|
|
20
|
+
* The WebGL target corresponding to the texture type
|
|
19
21
|
* @note `target` cannot be modified by bind:
|
|
20
22
|
* textures are special because when you first bind them to a target,
|
|
21
23
|
* When you first bind a texture as a GL_TEXTURE_2D, you are saying that this texture is a 2D texture.
|
|
@@ -30,27 +32,16 @@ export declare class WEBGLTexture extends Texture {
|
|
|
30
32
|
glType: GLPixelType;
|
|
31
33
|
/** The WebGL constant corresponding to the WebGPU style constant in format */
|
|
32
34
|
glInternalFormat: GL;
|
|
33
|
-
/**
|
|
34
|
-
compressed: boolean;
|
|
35
|
-
/** Texture binding slot */
|
|
35
|
+
/** Texture binding slot - TODO - move to texture view? */
|
|
36
36
|
textureUnit: number;
|
|
37
|
-
/** For automatically updating video */
|
|
38
|
-
_video: {
|
|
39
|
-
video: HTMLVideoElement;
|
|
40
|
-
parameters: any;
|
|
41
|
-
lastTime: number;
|
|
42
|
-
} | null;
|
|
43
37
|
constructor(device: Device, props: TextureProps);
|
|
44
38
|
/**
|
|
45
39
|
* Initialize texture with supplied props
|
|
46
40
|
*/
|
|
47
|
-
|
|
41
|
+
_initialize(propsWithData: TextureProps): void;
|
|
48
42
|
destroy(): void;
|
|
49
|
-
toString(): string;
|
|
50
43
|
createView(props: TextureViewProps): WEBGLTextureView;
|
|
51
44
|
setSampler(sampler?: Sampler | SamplerProps): void;
|
|
52
|
-
/** Update external texture (video frame or canvas) */
|
|
53
|
-
update(): void;
|
|
54
45
|
generateMipmap(params?: {}): void;
|
|
55
46
|
copyExternalImage(options: {
|
|
56
47
|
image: ExternalImage;
|
|
@@ -66,6 +57,7 @@ export declare class WEBGLTexture extends Texture {
|
|
|
66
57
|
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
67
58
|
colorSpace?: 'srgb';
|
|
68
59
|
premultipliedAlpha?: boolean;
|
|
60
|
+
flipY?: boolean;
|
|
69
61
|
}): {
|
|
70
62
|
width: number;
|
|
71
63
|
height: number;
|
|
@@ -96,6 +88,8 @@ export declare class WEBGLTexture extends Texture {
|
|
|
96
88
|
*/
|
|
97
89
|
setTextureCubeArrayData(data: TextureCubeArrayData): void;
|
|
98
90
|
setTextureCubeFaceData(lodData: Texture2DData, face: TextureCubeFace, depth?: number): void;
|
|
91
|
+
/** Update external texture (video frame or canvas) @deprecated Use ExternalTexture */
|
|
92
|
+
update(): void;
|
|
99
93
|
/** @todo update this method to accept LODs */
|
|
100
94
|
setImageDataForFace(options: any): void;
|
|
101
95
|
_getImageDataMap(faceData: Record<string | GL, any>): Record<GL, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,YAAY,
|
|
1
|
+
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,YAAY,EAEZ,eAAe,EACf,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAGvB,OAAO,E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