@luma.gl/webgl 9.1.0-alpha.10 → 9.1.0-alpha.12
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/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +1 -2
- package/dist/adapter/helpers/format-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +1 -3
- package/dist/adapter/helpers/typed-array-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +85 -18
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +210 -18
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -3
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +33 -8
- package/dist/adapter/webgl-device.d.ts +1 -2
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +2 -2
- package/dist/deprecated/accessor.d.ts.map +1 -0
- package/dist/{classic → deprecated}/accessor.js +36 -1
- package/dist/deprecated/clear.d.ts.map +1 -0
- package/dist/{classic → deprecated}/clear.js +2 -0
- package/dist/dist.dev.js +490 -432
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +491 -441
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/fill-array.d.ts +4 -4
- package/dist/utils/fill-array.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/adapter/device-helpers/webgl-device-features.ts +5 -2
- package/src/adapter/helpers/get-shader-layout.ts +1 -3
- package/src/adapter/helpers/webgl-texture-utils.ts +356 -37
- package/src/adapter/resources/webgl-render-pass.ts +3 -3
- package/src/adapter/resources/webgl-render-pipeline.ts +10 -3
- package/src/adapter/resources/webgl-texture.ts +41 -8
- package/src/adapter/webgl-device.ts +13 -4
- package/src/{classic → deprecated}/accessor.ts +44 -3
- package/src/{classic → deprecated}/clear.ts +3 -1
- package/src/index.ts +1 -1
- package/src/utils/fill-array.ts +4 -4
- package/dist/classic/accessor.d.ts.map +0 -1
- package/dist/classic/clear.d.ts.map +0 -1
- package/dist/classic/copy-and-blit.d.ts +0 -64
- package/dist/classic/copy-and-blit.d.ts.map +0 -1
- package/dist/classic/copy-and-blit.js +0 -194
- package/dist/classic/format-utils.d.ts.map +0 -1
- package/dist/classic/typed-array-utils.d.ts.map +0 -1
- package/src/classic/copy-and-blit.ts +0 -323
- /package/dist/{classic → adapter/helpers}/format-utils.d.ts +0 -0
- /package/dist/{classic → adapter/helpers}/format-utils.js +0 -0
- /package/dist/{classic → adapter/helpers}/typed-array-utils.d.ts +0 -0
- /package/dist/{classic → adapter/helpers}/typed-array-utils.js +0 -0
- /package/dist/{classic → deprecated}/accessor.d.ts +0 -0
- /package/dist/{classic → deprecated}/clear.d.ts +0 -0
- /package/src/{classic → adapter/helpers}/format-utils.ts +0 -0
- /package/src/{classic → adapter/helpers}/typed-array-utils.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-device-features.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/webgl-device-features.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-device-features.d.ts","sourceRoot":"","sources":["../../../src/adapter/device-helpers/webgl-device-features.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAgChD;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAS,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACrC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;IACnC,SAAS,CAAC,cAAc,qBAA4B;gBAGlD,EAAE,EAAE,sBAAsB,EAC1B,UAAU,EAAE,YAAY,EACxB,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAU1D,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,aAAa,CAAC;IAU5C,GAAG,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;IAuB7C,kBAAkB;IAWlB,WAAW,IACoE,aAAa,EAAE;IAG9F,iCAAiC;IACjC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;CAU3D"}
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
// Provides a function that enables simple checking of which WebGL features are
|
|
6
6
|
import { DeviceFeatures } from '@luma.gl/core';
|
|
7
7
|
import { getWebGLExtension } from "../../context/helpers/webgl-extensions.js";
|
|
8
|
-
import { isTextureFeature, checkTextureFeature } from "../converters/texture-formats.js";
|
|
9
|
-
import { TEXTURE_FEATURES } from "../converters/texture-formats.js";
|
|
8
|
+
import { isTextureFeature, checkTextureFeature, TEXTURE_FEATURES } from "../converters/texture-formats.js";
|
|
10
9
|
/**
|
|
11
10
|
* Defines luma.gl "feature" names and semantics
|
|
12
11
|
* when value is 'string' it is the name of the extension that enables this feature
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/format-utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,qBAmB1C;AAGD,wBAAgB,aAAa,CAAC,IAAI,KAAA,iBAcjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-shader-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-shader-layout.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"get-shader-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-shader-layout.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,eAAe,CAAC;AAKvB;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,sBAAsB,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY,CA2D/F"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { GL } from '@luma.gl/constants';
|
|
5
|
-
import { Accessor } from "../../classic/accessor.js"; // TODO - should NOT depend on classic API
|
|
6
5
|
import { decodeGLUniformType, decodeGLAttributeType, isSamplerUniform } from "./decode-webgl-types.js";
|
|
7
6
|
/**
|
|
8
7
|
* Extract metadata describing binding information for a program's shaders
|
|
@@ -114,8 +113,7 @@ function readVaryings(gl, program) {
|
|
|
114
113
|
}
|
|
115
114
|
const { name, type: compositeType, size } = activeInfo;
|
|
116
115
|
const { glType, components } = decodeGLUniformType(compositeType);
|
|
117
|
-
const
|
|
118
|
-
const varying = { location, name, accessor }; // Base values
|
|
116
|
+
const varying = { location, name, type: glType, size: size * components }; // Base values
|
|
119
117
|
varyings.push(varying);
|
|
120
118
|
}
|
|
121
119
|
varyings.sort((a, b) => a.location - b.location);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-array-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/typed-array-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAE,qBAAqB,EAAC,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAK,UAAU,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAI/D;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,CAuB3E;AAED;;;;;;;GAOG;AAEH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,UAAU,GAAG,WAAW,EAChC,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACA,qBAAqB,CAwBvB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,GAAG,IAAI,CAgBP;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GAAG;IACvF,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAaA"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { ExternalImage } from '@luma.gl/core';
|
|
2
|
-
import {
|
|
2
|
+
import { Buffer, Texture, Framebuffer, FramebufferProps } from '@luma.gl/core';
|
|
3
|
+
import { GL, GLTextureTarget, GLTextureCubeMapTarget, GLTexelDataFormat, GLPixelType } from '@luma.gl/constants';
|
|
3
4
|
import { TypedArray } from '@math.gl/types';
|
|
5
|
+
import { WEBGLFramebuffer } from "../resources/webgl-framebuffer.js";
|
|
6
|
+
import { WEBGLBuffer } from "../resources/webgl-buffer.js";
|
|
7
|
+
/**
|
|
8
|
+
* Options for setting data into a texture
|
|
9
|
+
*/
|
|
4
10
|
export type WebGLSetTextureOptions = {
|
|
5
11
|
dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
|
|
6
12
|
height: number;
|
|
7
13
|
width: number;
|
|
8
|
-
depth
|
|
9
|
-
|
|
14
|
+
depth: number;
|
|
15
|
+
mipLevel?: number;
|
|
10
16
|
glTarget: GLTextureTarget;
|
|
11
17
|
glInternalFormat: GL;
|
|
12
18
|
glFormat: GLTexelDataFormat;
|
|
@@ -16,19 +22,8 @@ export type WebGLSetTextureOptions = {
|
|
|
16
22
|
byteLength?: number;
|
|
17
23
|
};
|
|
18
24
|
/**
|
|
19
|
-
*
|
|
20
|
-
* null - create empty texture of specified format
|
|
21
|
-
* Typed array - init from image data in typed array
|
|
22
|
-
* Buffer|WebGLBuffer - (WEBGL2) init from image data in WebGLBuffer
|
|
23
|
-
* HTMLImageElement|Image - Inits with content of image. Auto width/height
|
|
24
|
-
* HTMLCanvasElement - Inits with contents of canvas. Auto width/height
|
|
25
|
-
* HTMLVideoElement - Creates video texture. Auto width/height
|
|
25
|
+
* Options for copying an image or data into a texture
|
|
26
26
|
*
|
|
27
|
-
* @param x - xOffset from where texture to be updated
|
|
28
|
-
* @param y - yOffset from where texture to be updated
|
|
29
|
-
* @param width - width of the sub image to be updated
|
|
30
|
-
* @param height - height of the sub image to be updated
|
|
31
|
-
* @param level - mip level to be updated
|
|
32
27
|
* @param {GLenum} format - internal format of image data.
|
|
33
28
|
* @param {GLenum} type
|
|
34
29
|
* - format of array (autodetect from type) or
|
|
@@ -39,12 +34,19 @@ export type WebGLSetTextureOptions = {
|
|
|
39
34
|
*/
|
|
40
35
|
export type WebGLCopyTextureOptions = {
|
|
41
36
|
dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
|
|
42
|
-
level
|
|
43
|
-
|
|
37
|
+
/** mip level to be updated */
|
|
38
|
+
mipLevel?: number;
|
|
39
|
+
/** width of the sub image to be updated */
|
|
44
40
|
width: number;
|
|
41
|
+
/** height of the sub image to be updated */
|
|
42
|
+
height: number;
|
|
43
|
+
/** depth of texture to be updated */
|
|
45
44
|
depth?: number;
|
|
45
|
+
/** xOffset from where texture to be updated */
|
|
46
46
|
x?: number;
|
|
47
|
+
/** yOffset from where texture to be updated */
|
|
47
48
|
y?: number;
|
|
49
|
+
/** yOffset from where texture to be updated */
|
|
48
50
|
z?: number;
|
|
49
51
|
glTarget: GLTextureTarget;
|
|
50
52
|
glInternalFormat: GL;
|
|
@@ -69,7 +71,7 @@ export declare function initializeTextureStorage(gl: WebGL2RenderingContext, lev
|
|
|
69
71
|
/**
|
|
70
72
|
* Copy a region of compressed data from a GPU memory buffer into this texture.
|
|
71
73
|
*/
|
|
72
|
-
export declare function
|
|
74
|
+
export declare function copyExternalImageToMipLevel(gl: WebGL2RenderingContext, handle: WebGLTexture, image: ExternalImage, options: WebGLCopyTextureOptions): void;
|
|
73
75
|
/**
|
|
74
76
|
* Copy a region of data from a CPU memory buffer into this texture.
|
|
75
77
|
*/
|
|
@@ -80,6 +82,12 @@ export declare function copyCPUDataToMipLevel(gl: WebGL2RenderingContext, typedA
|
|
|
80
82
|
export declare function copyGPUBufferToMipLevel(gl: WebGL2RenderingContext, webglBuffer: WebGLBuffer, byteLength: number, options: WebGLCopyTextureOptions): void;
|
|
81
83
|
/** Convert a WebGPU style texture constant to a WebGL style texture constant */
|
|
82
84
|
export declare function getWebGLTextureTarget(dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d'): GLTextureTarget;
|
|
85
|
+
/**
|
|
86
|
+
* In WebGL, cube maps specify faces by overriding target instead of using the depth parameter.
|
|
87
|
+
* @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.
|
|
88
|
+
* @returns glTarget unchanged, if dimension !== 'cube'.
|
|
89
|
+
*/
|
|
90
|
+
export declare function getWebGLCubeFaceTarget(glTarget: GLTextureTarget, dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d', level: number): GLTextureTarget | GLTextureCubeMapTarget;
|
|
83
91
|
/**
|
|
84
92
|
* Clear a texture mip level.
|
|
85
93
|
* Wrapper for the messy WebGL texture API
|
|
@@ -297,4 +305,63 @@ export function setMipLevelFromGPUBuffer(
|
|
|
297
305
|
gl.bindBuffer(GL.PIXEL_UNPACK_BUFFER, null);
|
|
298
306
|
}
|
|
299
307
|
*/
|
|
308
|
+
/**
|
|
309
|
+
* Copies data from a type or a Texture object into ArrayBuffer object.
|
|
310
|
+
* App can provide targetPixelArray or have it auto allocated by this method
|
|
311
|
+
* newly allocated by this method unless provided by app.
|
|
312
|
+
* @deprecated Use CommandEncoder.copyTextureToBuffer and Buffer.read
|
|
313
|
+
* @note Slow requires roundtrip to GPU
|
|
314
|
+
*
|
|
315
|
+
* @param source
|
|
316
|
+
* @param options
|
|
317
|
+
* @returns pixel array,
|
|
318
|
+
*/
|
|
319
|
+
export declare function readPixelsToArray(source: Framebuffer | Texture, options?: {
|
|
320
|
+
sourceX?: number;
|
|
321
|
+
sourceY?: number;
|
|
322
|
+
sourceFormat?: number;
|
|
323
|
+
sourceAttachment?: number;
|
|
324
|
+
target?: Uint8Array | Uint16Array | Float32Array;
|
|
325
|
+
sourceWidth?: number;
|
|
326
|
+
sourceHeight?: number;
|
|
327
|
+
sourceDepth?: number;
|
|
328
|
+
sourceType?: number;
|
|
329
|
+
}): Uint8Array | Uint16Array | Float32Array;
|
|
330
|
+
/**
|
|
331
|
+
* Copies data from a Framebuffer or a Texture object into a Buffer object.
|
|
332
|
+
* NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transffer.
|
|
333
|
+
* @deprecated Use CommandEncoder
|
|
334
|
+
* @param source
|
|
335
|
+
* @param options
|
|
336
|
+
*/
|
|
337
|
+
export declare function readPixelsToBuffer(source: Framebuffer | Texture, options?: {
|
|
338
|
+
sourceX?: number;
|
|
339
|
+
sourceY?: number;
|
|
340
|
+
sourceFormat?: number;
|
|
341
|
+
target?: Buffer;
|
|
342
|
+
targetByteOffset?: number;
|
|
343
|
+
sourceWidth?: number;
|
|
344
|
+
sourceHeight?: number;
|
|
345
|
+
sourceType?: number;
|
|
346
|
+
}): WEBGLBuffer;
|
|
347
|
+
/**
|
|
348
|
+
* Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)
|
|
349
|
+
* @deprecated Use CommandEncoder
|
|
350
|
+
*/
|
|
351
|
+
export declare function copyToTexture(source: Framebuffer | Texture, target: Texture | GL, options?: {
|
|
352
|
+
sourceX?: number;
|
|
353
|
+
sourceY?: number;
|
|
354
|
+
targetX?: number;
|
|
355
|
+
targetY?: number;
|
|
356
|
+
targetZ?: number;
|
|
357
|
+
targetMipmaplevel?: number;
|
|
358
|
+
targetInternalFormat?: number;
|
|
359
|
+
width?: number;
|
|
360
|
+
height?: number;
|
|
361
|
+
}): Texture;
|
|
362
|
+
/**
|
|
363
|
+
* Wraps a given texture into a framebuffer object, that can be further used
|
|
364
|
+
* to read data from the texture object.
|
|
365
|
+
*/
|
|
366
|
+
export declare function toFramebuffer(texture: Texture, props?: FramebufferProps): WEBGLFramebuffer;
|
|
300
367
|
//# sourceMappingURL=webgl-texture-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-texture-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgl-texture-utils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-texture-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgl-texture-utils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAE7E,OAAO,EACL,EAAE,EACF,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACZ,MAAM,o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AC,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAiGT;AAYD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAU1F"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
4
|
+
import { Framebuffer } from '@luma.gl/core';
|
|
5
5
|
import { GL } from '@luma.gl/constants';
|
|
6
|
+
import { getGLTypeFromTypedArray, getTypedArrayFromGLType } from "./typed-array-utils.js";
|
|
7
|
+
import { glFormatToComponents, glTypeToBytes } from "./format-utils.js";
|
|
8
|
+
import { WEBGLTexture } from "../resources/webgl-texture.js";
|
|
6
9
|
/** A "border" parameter is required in many WebGL texture APIs, but must always be 0... */
|
|
7
10
|
const BORDER = 0;
|
|
8
11
|
/**
|
|
@@ -32,23 +35,26 @@ export function initializeTextureStorage(gl, levels, options) {
|
|
|
32
35
|
/**
|
|
33
36
|
* Copy a region of compressed data from a GPU memory buffer into this texture.
|
|
34
37
|
*/
|
|
35
|
-
export function
|
|
36
|
-
const {
|
|
38
|
+
export function copyExternalImageToMipLevel(gl, handle, image, options) {
|
|
39
|
+
const { width, height } = options;
|
|
40
|
+
const { dimension, depth = 0, mipLevel = 0 } = options;
|
|
37
41
|
const { x = 0, y = 0, z = 0 } = options;
|
|
38
42
|
const { glFormat, glType } = options;
|
|
39
43
|
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
40
|
-
// width = size.width,
|
|
41
|
-
// height = size.height
|
|
42
44
|
switch (dimension) {
|
|
43
45
|
case '2d-array':
|
|
44
46
|
case '3d':
|
|
47
|
+
gl.bindTexture(glTarget, handle);
|
|
45
48
|
// prettier-ignore
|
|
46
|
-
gl.texSubImage3D(glTarget,
|
|
49
|
+
gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);
|
|
50
|
+
gl.bindTexture(glTarget, null);
|
|
47
51
|
break;
|
|
48
52
|
case '2d':
|
|
49
53
|
case 'cube':
|
|
54
|
+
gl.bindTexture(glTarget, handle);
|
|
50
55
|
// prettier-ignore
|
|
51
|
-
gl.texSubImage2D(glTarget,
|
|
56
|
+
gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);
|
|
57
|
+
gl.bindTexture(glTarget, null);
|
|
52
58
|
break;
|
|
53
59
|
default:
|
|
54
60
|
throw new Error(dimension);
|
|
@@ -58,7 +64,7 @@ export function copyCPUImageToMipLevel(gl, image, options) {
|
|
|
58
64
|
* Copy a region of data from a CPU memory buffer into this texture.
|
|
59
65
|
*/
|
|
60
66
|
export function copyCPUDataToMipLevel(gl, typedArray, options) {
|
|
61
|
-
const { dimension, width, height, depth = 0,
|
|
67
|
+
const { dimension, width, height, depth = 0, mipLevel = 0, byteOffset = 0 } = options;
|
|
62
68
|
const { x = 0, y = 0, z = 0 } = options;
|
|
63
69
|
const { glFormat, glType, compressed } = options;
|
|
64
70
|
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
@@ -68,22 +74,22 @@ export function copyCPUDataToMipLevel(gl, typedArray, options) {
|
|
|
68
74
|
case '3d':
|
|
69
75
|
if (compressed) {
|
|
70
76
|
// prettier-ignore
|
|
71
|
-
gl.compressedTexSubImage3D(glTarget,
|
|
77
|
+
gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, typedArray, byteOffset); // , byteLength
|
|
72
78
|
}
|
|
73
79
|
else {
|
|
74
80
|
// prettier-ignore
|
|
75
|
-
gl.texSubImage3D(glTarget,
|
|
81
|
+
gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, typedArray, byteOffset); // , byteLength
|
|
76
82
|
}
|
|
77
83
|
break;
|
|
78
84
|
case '2d':
|
|
79
85
|
case 'cube':
|
|
80
86
|
if (compressed) {
|
|
81
87
|
// prettier-ignore
|
|
82
|
-
gl.compressedTexSubImage2D(glTarget,
|
|
88
|
+
gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, typedArray, byteOffset); // , byteLength
|
|
83
89
|
}
|
|
84
90
|
else {
|
|
85
91
|
// prettier-ignore
|
|
86
|
-
gl.texSubImage2D(glTarget,
|
|
92
|
+
gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, typedArray, byteOffset); // , byteLength
|
|
87
93
|
}
|
|
88
94
|
break;
|
|
89
95
|
default:
|
|
@@ -94,7 +100,7 @@ export function copyCPUDataToMipLevel(gl, typedArray, options) {
|
|
|
94
100
|
* Copy a region of compressed data from a GPU memory buffer into this texture.
|
|
95
101
|
*/
|
|
96
102
|
export function copyGPUBufferToMipLevel(gl, webglBuffer, byteLength, options) {
|
|
97
|
-
const { dimension, width, height, depth = 0,
|
|
103
|
+
const { dimension, width, height, depth = 0, mipLevel = 0, byteOffset = 0 } = options;
|
|
98
104
|
const { x = 0, y = 0, z = 0 } = options;
|
|
99
105
|
const { glFormat, glType, compressed } = options;
|
|
100
106
|
const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
|
|
@@ -106,22 +112,22 @@ export function copyGPUBufferToMipLevel(gl, webglBuffer, byteLength, options) {
|
|
|
106
112
|
if (compressed) {
|
|
107
113
|
// TODO enable extension?
|
|
108
114
|
// prettier-ignore
|
|
109
|
-
gl.compressedTexSubImage3D(glTarget,
|
|
115
|
+
gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, byteLength, byteOffset);
|
|
110
116
|
}
|
|
111
117
|
else {
|
|
112
118
|
// prettier-ignore
|
|
113
|
-
gl.texSubImage3D(glTarget,
|
|
119
|
+
gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, byteOffset);
|
|
114
120
|
}
|
|
115
121
|
break;
|
|
116
122
|
case '2d':
|
|
117
123
|
case 'cube':
|
|
118
124
|
if (compressed) {
|
|
119
125
|
// prettier-ignore
|
|
120
|
-
gl.compressedTexSubImage2D(glTarget,
|
|
126
|
+
gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, byteLength, byteOffset);
|
|
121
127
|
}
|
|
122
128
|
else {
|
|
123
129
|
// prettier-ignore
|
|
124
|
-
gl.texSubImage2D(glTarget,
|
|
130
|
+
gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, BORDER, glFormat, byteOffset);
|
|
125
131
|
}
|
|
126
132
|
break;
|
|
127
133
|
default:
|
|
@@ -147,7 +153,7 @@ export function getWebGLTextureTarget(dimension) {
|
|
|
147
153
|
* @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.
|
|
148
154
|
* @returns glTarget unchanged, if dimension !== 'cube'.
|
|
149
155
|
*/
|
|
150
|
-
function getWebGLCubeFaceTarget(glTarget, dimension, level) {
|
|
156
|
+
export function getWebGLCubeFaceTarget(glTarget, dimension, level) {
|
|
151
157
|
return dimension === 'cube' ? 34069 + level : glTarget;
|
|
152
158
|
}
|
|
153
159
|
// texImage methods
|
|
@@ -368,3 +374,189 @@ export function setMipLevelFromGPUBuffer(
|
|
|
368
374
|
gl.bindBuffer(GL.PIXEL_UNPACK_BUFFER, null);
|
|
369
375
|
}
|
|
370
376
|
*/
|
|
377
|
+
/**
|
|
378
|
+
* Copies data from a type or a Texture object into ArrayBuffer object.
|
|
379
|
+
* App can provide targetPixelArray or have it auto allocated by this method
|
|
380
|
+
* newly allocated by this method unless provided by app.
|
|
381
|
+
* @deprecated Use CommandEncoder.copyTextureToBuffer and Buffer.read
|
|
382
|
+
* @note Slow requires roundtrip to GPU
|
|
383
|
+
*
|
|
384
|
+
* @param source
|
|
385
|
+
* @param options
|
|
386
|
+
* @returns pixel array,
|
|
387
|
+
*/
|
|
388
|
+
export function readPixelsToArray(source, options) {
|
|
389
|
+
const { sourceX = 0, sourceY = 0, sourceAttachment = 36064 // TODO - support gl.readBuffer
|
|
390
|
+
} = options || {};
|
|
391
|
+
let { target = null,
|
|
392
|
+
// following parameters are auto deduced if not provided
|
|
393
|
+
sourceWidth, sourceHeight, sourceDepth, sourceFormat, sourceType } = options || {};
|
|
394
|
+
const { framebuffer, deleteFramebuffer } = getFramebuffer(source);
|
|
395
|
+
// assert(framebuffer);
|
|
396
|
+
const { gl, handle } = framebuffer;
|
|
397
|
+
const attachment = sourceAttachment - 36064;
|
|
398
|
+
sourceWidth ||= framebuffer.width;
|
|
399
|
+
sourceHeight ||= framebuffer.height;
|
|
400
|
+
// TODO - Set and unset gl.readBuffer
|
|
401
|
+
// if (sourceAttachment === GL.COLOR_ATTACHMENT0 && handle === null) {
|
|
402
|
+
// sourceAttachment = GL.FRONT;
|
|
403
|
+
// }
|
|
404
|
+
sourceDepth = framebuffer.colorAttachments[attachment]?.texture?.depth || 1;
|
|
405
|
+
sourceFormat ||= framebuffer.colorAttachments[attachment]?.texture?.glFormat || 6408;
|
|
406
|
+
// Deduce the type from color attachment if not provided.
|
|
407
|
+
sourceType ||= framebuffer.colorAttachments[attachment]?.texture?.glType || 5121;
|
|
408
|
+
// Deduce type and allocated pixelArray if needed
|
|
409
|
+
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
|
|
410
|
+
// Pixel array available, if necessary, deduce type from it.
|
|
411
|
+
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
412
|
+
const prevHandle = gl.bindFramebuffer(36160, handle);
|
|
413
|
+
gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
|
|
414
|
+
// @ts-expect-error
|
|
415
|
+
gl.bindFramebuffer(36160, prevHandle || null);
|
|
416
|
+
if (deleteFramebuffer) {
|
|
417
|
+
framebuffer.destroy();
|
|
418
|
+
}
|
|
419
|
+
return target;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Copies data from a Framebuffer or a Texture object into a Buffer object.
|
|
423
|
+
* NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transffer.
|
|
424
|
+
* @deprecated Use CommandEncoder
|
|
425
|
+
* @param source
|
|
426
|
+
* @param options
|
|
427
|
+
*/
|
|
428
|
+
export function readPixelsToBuffer(source, options) {
|
|
429
|
+
const { target, sourceX = 0, sourceY = 0, sourceFormat = 6408, targetByteOffset = 0 } = options || {};
|
|
430
|
+
// following parameters are auto deduced if not provided
|
|
431
|
+
let { sourceWidth, sourceHeight, sourceType } = options || {};
|
|
432
|
+
const { framebuffer, deleteFramebuffer } = getFramebuffer(source);
|
|
433
|
+
// assert(framebuffer);
|
|
434
|
+
sourceWidth = sourceWidth || framebuffer.width;
|
|
435
|
+
sourceHeight = sourceHeight || framebuffer.height;
|
|
436
|
+
// Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature
|
|
437
|
+
const webglFramebuffer = framebuffer;
|
|
438
|
+
// deduce type if not available.
|
|
439
|
+
sourceType = sourceType || 5121;
|
|
440
|
+
let webglBufferTarget = target;
|
|
441
|
+
if (!webglBufferTarget) {
|
|
442
|
+
// Create new buffer with enough size
|
|
443
|
+
const components = glFormatToComponents(sourceFormat);
|
|
444
|
+
const byteCount = glTypeToBytes(sourceType);
|
|
445
|
+
const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;
|
|
446
|
+
webglBufferTarget = webglFramebuffer.device.createBuffer({ byteLength });
|
|
447
|
+
}
|
|
448
|
+
// TODO(donmccurdy): Do we have tests to confirm this is working?
|
|
449
|
+
const commandEncoder = source.device.createCommandEncoder();
|
|
450
|
+
commandEncoder.copyTextureToBuffer({
|
|
451
|
+
source: source,
|
|
452
|
+
width: sourceWidth,
|
|
453
|
+
height: sourceHeight,
|
|
454
|
+
origin: [sourceX, sourceY],
|
|
455
|
+
destination: webglBufferTarget,
|
|
456
|
+
byteOffset: targetByteOffset
|
|
457
|
+
});
|
|
458
|
+
commandEncoder.destroy();
|
|
459
|
+
if (deleteFramebuffer) {
|
|
460
|
+
framebuffer.destroy();
|
|
461
|
+
}
|
|
462
|
+
return webglBufferTarget;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)
|
|
466
|
+
* @deprecated Use CommandEncoder
|
|
467
|
+
*/
|
|
468
|
+
// eslint-disable-next-line complexity, max-statements
|
|
469
|
+
export function copyToTexture(source, target, options) {
|
|
470
|
+
const { sourceX = 0, sourceY = 0,
|
|
471
|
+
// attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer
|
|
472
|
+
targetMipmaplevel = 0, targetInternalFormat = 6408 } = options || {};
|
|
473
|
+
let { targetX, targetY, targetZ, width, // defaults to target width
|
|
474
|
+
height // defaults to target height
|
|
475
|
+
} = options || {};
|
|
476
|
+
const { framebuffer, deleteFramebuffer } = getFramebuffer(source);
|
|
477
|
+
// assert(framebuffer);
|
|
478
|
+
const webglFramebuffer = framebuffer;
|
|
479
|
+
const { device, handle } = webglFramebuffer;
|
|
480
|
+
const isSubCopy = typeof targetX !== 'undefined' ||
|
|
481
|
+
typeof targetY !== 'undefined' ||
|
|
482
|
+
typeof targetZ !== 'undefined';
|
|
483
|
+
targetX = targetX || 0;
|
|
484
|
+
targetY = targetY || 0;
|
|
485
|
+
targetZ = targetZ || 0;
|
|
486
|
+
const prevHandle = device.gl.bindFramebuffer(36160, handle);
|
|
487
|
+
// TODO - support gl.readBuffer (WebGL2 only)
|
|
488
|
+
// const prevBuffer = gl.readBuffer(attachment);
|
|
489
|
+
// assert(target);
|
|
490
|
+
let texture = null;
|
|
491
|
+
let textureTarget;
|
|
492
|
+
if (target instanceof WEBGLTexture) {
|
|
493
|
+
texture = target;
|
|
494
|
+
width = Number.isFinite(width) ? width : texture.width;
|
|
495
|
+
height = Number.isFinite(height) ? height : texture.height;
|
|
496
|
+
texture?.bind(0);
|
|
497
|
+
// @ts-ignore
|
|
498
|
+
textureTarget = texture.target;
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
// @ts-ignore
|
|
502
|
+
textureTarget = target;
|
|
503
|
+
}
|
|
504
|
+
if (!isSubCopy) {
|
|
505
|
+
device.gl.copyTexImage2D(textureTarget, targetMipmaplevel, targetInternalFormat, sourceX, sourceY, width, height, 0 /* border must be 0 */);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
switch (textureTarget) {
|
|
509
|
+
case 3553:
|
|
510
|
+
case 34067:
|
|
511
|
+
device.gl.copyTexSubImage2D(textureTarget, targetMipmaplevel, targetX, targetY, sourceX, sourceY, width, height);
|
|
512
|
+
break;
|
|
513
|
+
case 35866:
|
|
514
|
+
case 32879:
|
|
515
|
+
device.gl.copyTexSubImage3D(textureTarget, targetMipmaplevel, targetX, targetY, targetZ, sourceX, sourceY, width, height);
|
|
516
|
+
break;
|
|
517
|
+
default:
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (texture) {
|
|
521
|
+
texture.unbind();
|
|
522
|
+
}
|
|
523
|
+
// @ts-expect-error
|
|
524
|
+
device.gl.bindFramebuffer(36160, prevHandle || null);
|
|
525
|
+
if (deleteFramebuffer) {
|
|
526
|
+
framebuffer.destroy();
|
|
527
|
+
}
|
|
528
|
+
return texture;
|
|
529
|
+
}
|
|
530
|
+
function getFramebuffer(source) {
|
|
531
|
+
if (!(source instanceof Framebuffer)) {
|
|
532
|
+
return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
|
|
533
|
+
}
|
|
534
|
+
return { framebuffer: source, deleteFramebuffer: false };
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Wraps a given texture into a framebuffer object, that can be further used
|
|
538
|
+
* to read data from the texture object.
|
|
539
|
+
*/
|
|
540
|
+
export function toFramebuffer(texture, props) {
|
|
541
|
+
const { device, width, height, id } = texture;
|
|
542
|
+
const framebuffer = device.createFramebuffer({
|
|
543
|
+
...props,
|
|
544
|
+
id: `framebuffer-for-${id}`,
|
|
545
|
+
width,
|
|
546
|
+
height,
|
|
547
|
+
colorAttachments: [texture]
|
|
548
|
+
});
|
|
549
|
+
return framebuffer;
|
|
550
|
+
}
|
|
551
|
+
// eslint-disable-next-line max-params
|
|
552
|
+
function getPixelArray(pixelArray, type, format, width, height, depth) {
|
|
553
|
+
if (pixelArray) {
|
|
554
|
+
return pixelArray;
|
|
555
|
+
}
|
|
556
|
+
// Allocate pixel array if not already available, using supplied type
|
|
557
|
+
type = type || 5121;
|
|
558
|
+
const ArrayType = getTypedArrayFromGLType(type, { clamped: false });
|
|
559
|
+
const components = glFormatToComponents(format);
|
|
560
|
+
// TODO - check for composite type (components = 1).
|
|
561
|
+
return new ArrayType(width * height * components);
|
|
562
|
+
}
|
|
@@ -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,
|
|
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;AAapD,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;IA0BvD,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;IA+BvB;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,UAAU,GAAE,MAAU,EAAE,KAAK,GAAE,YAA2B;CAwCtF"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { RenderPipelineProps, RenderPipelineParameters, PrimitiveTopology } from '@luma.gl/core';
|
|
2
|
-
import type { ShaderLayout, UniformValue, Binding } from '@luma.gl/core';
|
|
3
|
-
import type { RenderPass, VertexArray } from '@luma.gl/core';
|
|
1
|
+
import type { RenderPipelineProps, RenderPipelineParameters, PrimitiveTopology, ShaderLayout, UniformValue, Binding, RenderPass, VertexArray } from '@luma.gl/core';
|
|
4
2
|
import { RenderPipeline } from '@luma.gl/core';
|
|
5
3
|
import { WebGLDevice } from "../webgl-device.js";
|
|
6
4
|
import { WEBGLShader } from "./webgl-shader.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"webgl-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,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ACtC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;QAC7B,WAAW,EAAE,WAAW,CAAC;QACzB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,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;IACxF,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY;IAmB9D;;;;OAIG;IACH,cAAc,IAAI,SAAS,GAAG,SAAS,GAAG,YAAY;IAmBtD,6DAA6D;IACvD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB3C;;;;OAIG;IACH,sBAAsB;IAsBtB,iDAAiD;IACjD,cAAc;IAyFd;;;OAGG;IACH,cAAc;CASf"}
|
|
@@ -107,7 +107,7 @@ export declare class WEBGLTexture extends Texture {
|
|
|
107
107
|
* Copy a region of data from a CPU memory buffer into this texture.
|
|
108
108
|
* @todo - GLUnpackParameters parameters
|
|
109
109
|
*/
|
|
110
|
-
protected _setMipLevel(depth: number,
|
|
110
|
+
protected _setMipLevel(depth: number, mipLevel: number, textureData: Texture2DData, glTarget?: GL): void;
|
|
111
111
|
getActiveUnit(): number;
|
|
112
112
|
bind(textureUnit?: number): number;
|
|
113
113
|
unbind(textureUnit?: number): number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture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