@luma.gl/webgl 9.1.0-alpha.15 → 9.1.0-alpha.17

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.
Files changed (69) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts +3 -3
  2. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  3. package/dist/adapter/converters/sampler-parameters.js +6 -4
  4. package/dist/adapter/converters/texture-formats.d.ts +49 -11
  5. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  6. package/dist/adapter/converters/texture-formats.js +150 -160
  7. package/dist/adapter/helpers/format-utils.d.ts.map +1 -1
  8. package/dist/adapter/helpers/format-utils.js +6 -0
  9. package/dist/adapter/helpers/webgl-texture-utils.d.ts +34 -30
  10. package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
  11. package/dist/adapter/helpers/webgl-texture-utils.js +52 -256
  12. package/dist/adapter/resources/webgl-command-buffer.d.ts +59 -2
  13. package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
  14. package/dist/adapter/resources/webgl-command-buffer.js +87 -31
  15. package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
  16. package/dist/adapter/resources/webgl-command-encoder.js +3 -0
  17. package/dist/adapter/resources/webgl-external-texture.js +14 -0
  18. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  19. package/dist/adapter/resources/webgl-framebuffer.js +1 -2
  20. package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
  21. package/dist/adapter/resources/webgl-render-pass.js +38 -20
  22. package/dist/adapter/resources/webgl-render-pipeline.d.ts +1 -1
  23. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  24. package/dist/adapter/resources/webgl-render-pipeline.js +30 -16
  25. package/dist/adapter/resources/webgl-shader.d.ts +1 -0
  26. package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
  27. package/dist/adapter/resources/webgl-shader.js +7 -5
  28. package/dist/adapter/resources/webgl-texture.d.ts +8 -14
  29. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  30. package/dist/adapter/resources/webgl-texture.js +119 -208
  31. package/dist/adapter/webgl-adapter.d.ts.map +1 -1
  32. package/dist/adapter/webgl-adapter.js +4 -10
  33. package/dist/adapter/webgl-device.d.ts +8 -3
  34. package/dist/adapter/webgl-device.d.ts.map +1 -1
  35. package/dist/adapter/webgl-device.js +53 -22
  36. package/dist/context/debug/spector-types.js +1 -1
  37. package/dist/context/debug/spector.d.ts +5 -5
  38. package/dist/context/debug/spector.d.ts.map +1 -1
  39. package/dist/context/debug/spector.js +6 -6
  40. package/dist/context/debug/webgl-developer-tools.d.ts +2 -3
  41. package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
  42. package/dist/context/debug/webgl-developer-tools.js +6 -19
  43. package/dist/context/helpers/create-browser-context.d.ts +6 -22
  44. package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
  45. package/dist/context/helpers/create-browser-context.js +40 -32
  46. package/dist/dist.dev.js +366 -400
  47. package/dist/dist.min.js +2 -2
  48. package/dist/index.cjs +341 -384
  49. package/dist/index.cjs.map +3 -3
  50. package/package.json +4 -4
  51. package/src/adapter/converters/device-parameters.ts +3 -3
  52. package/src/adapter/converters/sampler-parameters.ts +6 -4
  53. package/src/adapter/converters/texture-formats.ts +171 -177
  54. package/src/adapter/helpers/format-utils.ts +6 -0
  55. package/src/adapter/helpers/webgl-texture-utils.ts +99 -75
  56. package/src/adapter/resources/webgl-command-buffer.ts +124 -40
  57. package/src/adapter/resources/webgl-command-encoder.ts +6 -0
  58. package/src/adapter/resources/webgl-external-texture.ts +14 -0
  59. package/src/adapter/resources/webgl-framebuffer.ts +1 -2
  60. package/src/adapter/resources/webgl-render-pass.ts +44 -23
  61. package/src/adapter/resources/webgl-render-pipeline.ts +32 -16
  62. package/src/adapter/resources/webgl-shader.ts +8 -6
  63. package/src/adapter/resources/webgl-texture.ts +126 -235
  64. package/src/adapter/webgl-adapter.ts +4 -12
  65. package/src/adapter/webgl-device.ts +88 -48
  66. package/src/context/debug/spector-types.ts +1 -1
  67. package/src/context/debug/spector.ts +11 -11
  68. package/src/context/debug/webgl-developer-tools.ts +8 -31
  69. package/src/context/helpers/create-browser-context.ts +53 -63
@@ -1,7 +1,7 @@
1
+ import { TypedArray } from '@math.gl/types';
1
2
  import type { ExternalImage } from '@luma.gl/core';
2
3
  import { Buffer, Texture, Framebuffer, FramebufferProps } from '@luma.gl/core';
3
4
  import { GL, GLTextureTarget, GLTextureCubeMapTarget, GLTexelDataFormat, GLPixelType } from '@luma.gl/constants';
4
- import { TypedArray } from '@math.gl/types';
5
5
  import { WEBGLFramebuffer } from "../resources/webgl-framebuffer.js";
6
6
  import { WEBGLBuffer } from "../resources/webgl-buffer.js";
7
7
  /**
@@ -71,7 +71,9 @@ export declare function initializeTextureStorage(gl: WebGL2RenderingContext, lev
71
71
  /**
72
72
  * Copy a region of compressed data from a GPU memory buffer into this texture.
73
73
  */
74
- export declare function copyExternalImageToMipLevel(gl: WebGL2RenderingContext, handle: WebGLTexture, image: ExternalImage, options: WebGLCopyTextureOptions): void;
74
+ export declare function copyExternalImageToMipLevel(gl: WebGL2RenderingContext, handle: WebGLTexture, image: ExternalImage, options: WebGLCopyTextureOptions & {
75
+ flipY?: boolean;
76
+ }): void;
75
77
  /**
76
78
  * Copy a region of data from a CPU memory buffer into this texture.
77
79
  */
@@ -93,7 +95,7 @@ export declare function getWebGLCubeFaceTarget(glTarget: GLTextureTarget, dimens
93
95
  * Wrapper for the messy WebGL texture API
94
96
  *
95
97
  export function clearMipLevel(gl: WebGL2RenderingContext, options: WebGLSetTextureOptions): void {
96
- const {dimension, width, height, depth = 0, level = 0} = options;
98
+ const {dimension, width, height, depth = 0, mipLevel = 0} = options;
97
99
  const {glInternalFormat, glFormat, glType, compressed} = options;
98
100
  const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
99
101
 
@@ -102,10 +104,10 @@ export function clearMipLevel(gl: WebGL2RenderingContext, options: WebGLSetTextu
102
104
  case '3d':
103
105
  if (compressed) {
104
106
  // prettier-ignore
105
- gl.compressedTexImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, null);
107
+ gl.compressedTexImage3D(glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, null);
106
108
  } else {
107
109
  // prettier-ignore
108
- gl.texImage3D( glTarget, level, glInternalFormat, width, height, depth, BORDER, glFormat, glType, null);
110
+ gl.texImage3D( glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, glFormat, glType, null);
109
111
  }
110
112
  break;
111
113
 
@@ -113,10 +115,10 @@ export function clearMipLevel(gl: WebGL2RenderingContext, options: WebGLSetTextu
113
115
  case 'cube':
114
116
  if (compressed) {
115
117
  // prettier-ignore
116
- gl.compressedTexImage2D(glTarget, level, glInternalFormat, width, height, BORDER, null);
118
+ gl.compressedTexImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, null);
117
119
  } else {
118
120
  // prettier-ignore
119
- gl.texImage2D(glTarget, level, glInternalFormat, width, height, BORDER, glFormat, glType, null);
121
+ gl.texImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, glFormat, glType, null);
120
122
  }
121
123
  break;
122
124
 
@@ -124,7 +126,7 @@ export function clearMipLevel(gl: WebGL2RenderingContext, options: WebGLSetTextu
124
126
  throw new Error(dimension);
125
127
  }
126
128
  }
127
-
129
+ */
128
130
  /**
129
131
  * Set a texture mip level to the contents of an external image.
130
132
  * Wrapper for the messy WebGL texture API
@@ -305,6 +307,27 @@ export function setMipLevelFromGPUBuffer(
305
307
  gl.bindBuffer(GL.PIXEL_UNPACK_BUFFER, null);
306
308
  }
307
309
  */
310
+ export type ReadPixelsToArrayOptions = {
311
+ sourceX?: number;
312
+ sourceY?: number;
313
+ sourceFormat?: number;
314
+ sourceAttachment?: number;
315
+ target?: Uint8Array | Uint16Array | Float32Array;
316
+ sourceWidth?: number;
317
+ sourceHeight?: number;
318
+ sourceDepth?: number;
319
+ sourceType?: number;
320
+ };
321
+ export type ReadPixelsToBufferOptions = {
322
+ sourceX?: number;
323
+ sourceY?: number;
324
+ sourceFormat?: number;
325
+ target?: Buffer;
326
+ targetByteOffset?: number;
327
+ sourceWidth?: number;
328
+ sourceHeight?: number;
329
+ sourceType?: number;
330
+ };
308
331
  /**
309
332
  * Copies data from a type or a Texture object into ArrayBuffer object.
310
333
  * App can provide targetPixelArray or have it auto allocated by this method
@@ -316,17 +339,7 @@ export function setMipLevelFromGPUBuffer(
316
339
  * @param options
317
340
  * @returns pixel array,
318
341
  */
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;
342
+ export declare function readPixelsToArray(source: Framebuffer | Texture, options?: ReadPixelsToArrayOptions): Uint8Array | Uint16Array | Float32Array;
330
343
  /**
331
344
  * Copies data from a Framebuffer or a Texture object into a Buffer object.
332
345
  * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transffer.
@@ -334,21 +347,12 @@ export declare function readPixelsToArray(source: Framebuffer | Texture, options
334
347
  * @param source
335
348
  * @param options
336
349
  */
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;
350
+ export declare function readPixelsToBuffer(source: Framebuffer | Texture, options?: ReadPixelsToBufferOptions): WEBGLBuffer;
347
351
  /**
348
352
  * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)
349
353
  * @deprecated Use CommandEncoder
350
354
  */
351
- export declare function copyToTexture(source: Framebuffer | Texture, target: Texture | GL, options?: {
355
+ export declare function copyToTexture(sourceTexture: Framebuffer | Texture, destinationTexture: Texture | GL, options?: {
352
356
  sourceX?: number;
353
357
  sourceY?: number;
354
358
  targetX?: number;
@@ -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;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,oBAAoB,CAAC;AAE5B,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAC,gBAAgB,EAAC,0CAAuC;AAGhE,OAAO,EAAC,WAAW,EAAC,qCAAkC;AAMtD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,eAAe,CAAC;IAC1B,gBAAgB,EAAE,EAAE,CAAC;IACrB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,IAAI,GAAG,IAAI,GA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AAa,CAC3B,aAAa,EAAE,WAAW,GAAG,OAAO,EACpC,kBAAkB,EAAE,OAAO,GAAG,EAAE,EAChC,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,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"}
@@ -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
- switch (dimension) {
45
- case '2d-array':
46
- case '3d':
47
- gl.bindTexture(glTarget, handle);
48
- // prettier-ignore
49
- gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);
50
- gl.bindTexture(glTarget, null);
51
- break;
52
- case '2d':
53
- case 'cube':
54
- gl.bindTexture(glTarget, handle);
55
- // prettier-ignore
56
- gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);
57
- gl.bindTexture(glTarget, null);
58
- break;
59
- default:
60
- throw new Error(dimension);
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.
@@ -156,224 +160,6 @@ export function getWebGLTextureTarget(dimension) {
156
160
  export function getWebGLCubeFaceTarget(glTarget, dimension, level) {
157
161
  return dimension === 'cube' ? 34069 + level : glTarget;
158
162
  }
159
- // texImage methods
160
- /**
161
- * Clear a texture mip level.
162
- * Wrapper for the messy WebGL texture API
163
- *
164
- export function clearMipLevel(gl: WebGL2RenderingContext, options: WebGLSetTextureOptions): void {
165
- const {dimension, width, height, depth = 0, level = 0} = options;
166
- const {glInternalFormat, glFormat, glType, compressed} = options;
167
- const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
168
-
169
- switch (dimension) {
170
- case '2d-array':
171
- case '3d':
172
- if (compressed) {
173
- // prettier-ignore
174
- gl.compressedTexImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, null);
175
- } else {
176
- // prettier-ignore
177
- gl.texImage3D( glTarget, level, glInternalFormat, width, height, depth, BORDER, glFormat, glType, null);
178
- }
179
- break;
180
-
181
- case '2d':
182
- case 'cube':
183
- if (compressed) {
184
- // prettier-ignore
185
- gl.compressedTexImage2D(glTarget, level, glInternalFormat, width, height, BORDER, null);
186
- } else {
187
- // prettier-ignore
188
- gl.texImage2D(glTarget, level, glInternalFormat, width, height, BORDER, glFormat, glType, null);
189
- }
190
- break;
191
-
192
- default:
193
- throw new Error(dimension);
194
- }
195
- }
196
-
197
- /**
198
- * Set a texture mip level to the contents of an external image.
199
- * Wrapper for the messy WebGL texture API
200
- * @note Corresponds to WebGPU device.queue.copyExternalImageToTexture()
201
- *
202
- export function setMipLevelFromExternalImage(
203
- gl: WebGL2RenderingContext,
204
- image: ExternalImage,
205
- options: WebGLSetTextureOptions
206
- ): void {
207
- const {dimension, width, height, depth = 0, level = 0} = options;
208
- const {glInternalFormat, glType} = options;
209
-
210
- const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
211
-
212
- // TODO - we can't change texture width (due to WebGPU limitations) -
213
- // and the width/heigh of an external image is implicit, so why do we need to extract it?
214
- // So what width height do we supply? The image size or the texture size?
215
- // const {width, height} = Texture.getExternalImageSize(image);
216
-
217
- switch (dimension) {
218
- case '2d-array':
219
- case '3d':
220
- // prettier-ignore
221
- gl.texImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, glInternalFormat, glType, image);
222
- break;
223
-
224
- case '2d':
225
- case 'cube':
226
- // prettier-ignore
227
- gl.texImage2D(glTarget, level, glInternalFormat, width, height, BORDER, glInternalFormat, glType, image);
228
- break;
229
-
230
- default:
231
- throw new Error(dimension);
232
- }
233
- }
234
-
235
- /**
236
- * Set a texture mip level from CPU memory
237
- * Wrapper for the messy WebGL texture API
238
- * @note Not available (directly) in WebGPU
239
- *
240
- export function setMipLevelFromTypedArray(
241
- gl: WebGL2RenderingContext,
242
- data: TypedArray,
243
- parameters: {},
244
- options: {
245
- dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
246
- height: number;
247
- width: number;
248
- depth?: number;
249
- level?: number;
250
- offset?: number;
251
- glTarget: GLTextureTarget;
252
- glInternalFormat: GL;
253
- glFormat: GL;
254
- glType: GL;
255
- compressed?: boolean;
256
- }
257
- ): void {
258
- const {dimension, width, height, depth = 0, level = 0, offset = 0} = options;
259
- const {glInternalFormat, glFormat, glType, compressed} = options;
260
-
261
- const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
262
-
263
- withGLParameters(gl, parameters, () => {
264
- switch (dimension) {
265
- case '2d-array':
266
- case '3d':
267
- if (compressed) {
268
- // prettier-ignore
269
- gl.compressedTexImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, data);
270
- } else {
271
- // prettier-ignore
272
- gl.texImage3D( glTarget, level, glInternalFormat, width, height, depth, BORDER, glFormat, glType, data);
273
- }
274
- break;
275
-
276
- case '2d':
277
- if (compressed) {
278
- // prettier-ignore
279
- gl.compressedTexImage2D(glTarget, level, glInternalFormat, width, height, BORDER, data);
280
- } else {
281
- // prettier-ignore
282
- gl.texImage2D( glTarget, level, glInternalFormat, width, height, BORDER, glFormat, glType, data, offset);
283
- }
284
- break;
285
-
286
- default:
287
- throw new Error(dimension);
288
- }
289
- });
290
- }
291
-
292
- /**
293
- * Set a texture level from CPU memory
294
- * @note Not available (directly) in WebGPU
295
- _setMipLevelFromTypedArray(
296
- depth: number,
297
- level: number,
298
- data: TextureLevelData,
299
- offset = 0,
300
- parameters
301
- ): void {
302
- withGLParameters(this.gl, parameters, () => {
303
- switch (this.props.dimension) {
304
- case '2d-array':
305
- case '3d':
306
- if (this.compressed) {
307
- // prettier-ignore
308
- this.device.gl.compressedTexImage3D(this.glTarget, level, this.glInternalFormat, data.width, data.height, depth, BORDER, data.data);
309
- } else {
310
- // prettier-ignore
311
- this.gl.texImage3D( this.glTarget, level, this.glInternalFormat, this.width, this.height, depth, BORDER, this.glFormat, this.glType, data.data);
312
- }
313
- break;
314
-
315
- case '2d':
316
- if (this.compressed) {
317
- // prettier-ignore
318
- this.device.gl.compressedTexImage2D(this.glTarget, level, this.glInternalFormat, data.width, data.height, BORDER, data.data);
319
- } else {
320
- // prettier-ignore
321
- this.device.gl.texImage2D( this.glTarget, level, this.glInternalFormat, this.width, this.height, BORDER, this.glFormat, this.glType, data.data, offset);
322
- }
323
- break;
324
-
325
- default:
326
- throw new Error(this.props.dimension);
327
- }
328
- });
329
- }
330
-
331
- * Set a texture level from a GPU buffer
332
- *
333
- export function setMipLevelFromGPUBuffer(
334
- gl: WebGL2RenderingContext,
335
- buffer: Buffer,
336
- options: WebGLSetTextureOptions
337
- ): void {
338
- const {dimension, width, height, depth = 0, level = 0, byteOffset = 0} = options;
339
- const {glInternalFormat, glFormat, glType, compressed} = options;
340
- const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);
341
-
342
- const webglBuffer = buffer as WEBGLBuffer;
343
- const imageSize = buffer.byteLength;
344
-
345
- // In WebGL the source buffer is not a parameter. Instead it needs to be bound to a special bind point
346
- gl.bindBuffer(GL.PIXEL_UNPACK_BUFFER, webglBuffer.handle);
347
-
348
- switch (dimension) {
349
- case '2d-array':
350
- case '3d':
351
- if (compressed) {
352
- // prettier-ignore
353
- gl.compressedTexImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, imageSize, byteOffset);
354
- } else {
355
- // prettier-ignore
356
- gl.texImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, glFormat, glType, byteOffset);
357
- }
358
- break;
359
-
360
- case '2d':
361
- if (compressed) {
362
- // prettier-ignore
363
- gl.compressedTexImage2D(glTarget, level, glInternalFormat, width, height, BORDER, imageSize, byteOffset);
364
- } else {
365
- // prettier-ignore
366
- gl.texImage2D(glTarget, level, glInternalFormat, width, height, BORDER, glFormat, glType, byteOffset);
367
- }
368
- break;
369
-
370
- default:
371
- throw new Error(dimension);
372
- }
373
-
374
- gl.bindBuffer(GL.PIXEL_UNPACK_BUFFER, null);
375
- }
376
- */
377
163
  /**
378
164
  * Copies data from a type or a Texture object into ArrayBuffer object.
379
165
  * App can provide targetPixelArray or have it auto allocated by this method
@@ -386,7 +172,7 @@ export function setMipLevelFromGPUBuffer(
386
172
  * @returns pixel array,
387
173
  */
388
174
  export function readPixelsToArray(source, options) {
389
- const { sourceX = 0, sourceY = 0, sourceAttachment = 36064 // TODO - support gl.readBuffer
175
+ const { sourceX = 0, sourceY = 0, sourceAttachment = 0 // TODO - support gl.readBuffer
390
176
  } = options || {};
391
177
  let { target = null,
392
178
  // following parameters are auto deduced if not provided
@@ -394,24 +180,33 @@ export function readPixelsToArray(source, options) {
394
180
  const { framebuffer, deleteFramebuffer } = getFramebuffer(source);
395
181
  // assert(framebuffer);
396
182
  const { gl, handle } = framebuffer;
397
- const attachment = sourceAttachment - 36064;
398
183
  sourceWidth ||= framebuffer.width;
399
184
  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;
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;
406
191
  // Deduce the type from color attachment if not provided.
407
- sourceType ||= framebuffer.colorAttachments[attachment]?.texture?.glType || 5121;
192
+ sourceType ||= texture?.glType || 5121;
408
193
  // Deduce type and allocated pixelArray if needed
409
194
  target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);
410
195
  // Pixel array available, if necessary, deduce type from it.
411
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)
412
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));
413
208
  gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
414
- // @ts-expect-error
209
+ gl.readBuffer(36064);
415
210
  gl.bindFramebuffer(36160, prevHandle || null);
416
211
  if (deleteFramebuffer) {
417
212
  framebuffer.destroy();
@@ -448,11 +243,11 @@ export function readPixelsToBuffer(source, options) {
448
243
  // TODO(donmccurdy): Do we have tests to confirm this is working?
449
244
  const commandEncoder = source.device.createCommandEncoder();
450
245
  commandEncoder.copyTextureToBuffer({
451
- source: source,
246
+ sourceTexture: source,
452
247
  width: sourceWidth,
453
248
  height: sourceHeight,
454
249
  origin: [sourceX, sourceY],
455
- destination: webglBufferTarget,
250
+ destinationBuffer: webglBufferTarget,
456
251
  byteOffset: targetByteOffset
457
252
  });
458
253
  commandEncoder.destroy();
@@ -466,14 +261,14 @@ export function readPixelsToBuffer(source, options) {
466
261
  * @deprecated Use CommandEncoder
467
262
  */
468
263
  // eslint-disable-next-line complexity, max-statements
469
- export function copyToTexture(source, target, options) {
264
+ export function copyToTexture(sourceTexture, destinationTexture, options) {
470
265
  const { sourceX = 0, sourceY = 0,
471
266
  // attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer
472
267
  targetMipmaplevel = 0, targetInternalFormat = 6408 } = options || {};
473
268
  let { targetX, targetY, targetZ, width, // defaults to target width
474
269
  height // defaults to target height
475
270
  } = options || {};
476
- const { framebuffer, deleteFramebuffer } = getFramebuffer(source);
271
+ const { framebuffer, deleteFramebuffer } = getFramebuffer(sourceTexture);
477
272
  // assert(framebuffer);
478
273
  const webglFramebuffer = framebuffer;
479
274
  const { device, handle } = webglFramebuffer;
@@ -489,8 +284,8 @@ export function copyToTexture(source, target, options) {
489
284
  // assert(target);
490
285
  let texture = null;
491
286
  let textureTarget;
492
- if (target instanceof WEBGLTexture) {
493
- texture = target;
287
+ if (destinationTexture instanceof WEBGLTexture) {
288
+ texture = destinationTexture;
494
289
  width = Number.isFinite(width) ? width : texture.width;
495
290
  height = Number.isFinite(height) ? height : texture.height;
496
291
  texture?.bind(0);
@@ -549,14 +344,15 @@ export function toFramebuffer(texture, props) {
549
344
  return framebuffer;
550
345
  }
551
346
  // eslint-disable-next-line max-params
552
- function getPixelArray(pixelArray, type, format, width, height, depth) {
347
+ function getPixelArray(pixelArray, glType, glFormat, width, height, depth) {
553
348
  if (pixelArray) {
554
349
  return pixelArray;
555
350
  }
351
+ // const formatInfo = decodeTextureFormat(format);
556
352
  // 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);
353
+ glType ||= 5121;
354
+ const ArrayType = getTypedArrayFromGLType(glType, { clamped: false });
355
+ const components = glFormatToComponents(glFormat);
560
356
  // TODO - check for composite type (components = 1).
561
357
  return new ArrayType(width * height * components);
562
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 Command = CopyBufferToBufferCommand | CopyBufferToTextureCommand | CopyTextureToBufferCommand | CopyTextureToTextureCommand;
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,EAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,aAAa,EAAuB,MAAM,eAAe,CAAC;AAClE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAEtC,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,CAA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