@babylonjs/lite-gl 1.24.0 → 1.24.1

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 (55) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +5 -4
  3. package/blend.d.ts +1 -1
  4. package/blend.js +1 -1
  5. package/blend.js.map +1 -1
  6. package/context.d.ts +47 -4
  7. package/context.js +100 -11
  8. package/context.js.map +1 -1
  9. package/depth-stencil.d.ts +3 -2
  10. package/depth-stencil.js +10 -11
  11. package/depth-stencil.js.map +1 -1
  12. package/dynamic-texture.d.ts +6 -3
  13. package/dynamic-texture.js +16 -4
  14. package/dynamic-texture.js.map +1 -1
  15. package/effect.d.ts +12 -3
  16. package/effect.js +35 -24
  17. package/effect.js.map +1 -1
  18. package/family.d.ts +5 -1
  19. package/family.js.map +1 -1
  20. package/framebuffer-validation.d.ts +20 -0
  21. package/framebuffer-validation.js +37 -0
  22. package/framebuffer-validation.js.map +1 -0
  23. package/html-texture.d.ts +2 -2
  24. package/html-texture.js.map +1 -1
  25. package/index.d.ts +3 -2
  26. package/index.js +3 -2
  27. package/index.js.map +1 -1
  28. package/mesh.d.ts +68 -14
  29. package/mesh.js +211 -61
  30. package/mesh.js.map +1 -1
  31. package/package.json +3 -3
  32. package/render-target.d.ts +11 -9
  33. package/render-target.js +50 -35
  34. package/render-target.js.map +1 -1
  35. package/scissor.d.ts +1 -1
  36. package/scissor.js.map +1 -1
  37. package/sprites.d.ts +5 -3
  38. package/sprites.js +24 -23
  39. package/sprites.js.map +1 -1
  40. package/state.d.ts +25 -13
  41. package/state.js +13 -10
  42. package/state.js.map +1 -1
  43. package/text/_gpu/text-instances.js +1 -1
  44. package/text/_gpu/text-instances.js.map +1 -1
  45. package/texture-3d.d.ts +2 -1
  46. package/texture-3d.js +7 -2
  47. package/texture-3d.js.map +1 -1
  48. package/texture-source.d.ts +4 -2
  49. package/texture-source.js +3 -2
  50. package/texture-source.js.map +1 -1
  51. package/texture.d.ts +18 -8
  52. package/texture.js +61 -35
  53. package/texture.js.map +1 -1
  54. package/web-family.d.ts +2 -1
  55. package/web-family.js.map +1 -1
package/texture.js CHANGED
@@ -23,12 +23,12 @@ export const GLSamplingMode = {
23
23
  export function setUnpackState(engine, flipY, premultiplyAlpha, alignment = 4) {
24
24
  const gl = engine.gl;
25
25
  const s = engine._state;
26
- const fy = flipY ? 1 : 0;
26
+ const fy = +flipY;
27
27
  if (s.unpackFlipY !== fy) {
28
28
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, fy);
29
29
  s.unpackFlipY = fy;
30
30
  }
31
- const pm = premultiplyAlpha ? 1 : 0;
31
+ const pm = +premultiplyAlpha;
32
32
  if (s.unpackPremultiplyAlpha !== pm) {
33
33
  gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pm);
34
34
  s.unpackPremultiplyAlpha = pm;
@@ -40,10 +40,11 @@ export function setUnpackState(engine, flipY, premultiplyAlpha, alignment = 4) {
40
40
  }
41
41
  /** Apply sampling and wrap state to the texture currently bound for upload. @internal */
42
42
  export function setBoundTextureParams(gl, minFilter, magFilter, wrapS, wrapT) {
43
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
44
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
45
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);
46
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);
43
+ const target = gl.TEXTURE_2D;
44
+ gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, minFilter);
45
+ gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, magFilter);
46
+ gl.texParameteri(target, gl.TEXTURE_WRAP_S, wrapS);
47
+ gl.texParameteri(target, gl.TEXTURE_WRAP_T, wrapT);
47
48
  }
48
49
  /**
49
50
  * Resolve a Babylon-style sampling preset to GL min/mag filters — the lite-gl
@@ -91,7 +92,8 @@ export function setTexImageSourceSize(tex, source) {
91
92
  * RGBA8 by default; set {@link GLRawTextureOptions.format} / `type` for other
92
93
  * layouts. The pixel data can be replaced later via {@link updateRawTexture};
93
94
  * the sampling and wrap can be changed via {@link updateTextureSamplingMode} /
94
- * {@link updateTextureWrapMode}.
95
+ * {@link updateTextureWrapMode}. Upload data is retained by reference for
96
+ * automatic recovery unless the engine is host-owned (`createHostOwnedGLEngine`).
95
97
  *
96
98
  * @param engine - The engine.
97
99
  * @param data - Initial pixels matching `format` / `type`, or `null` for an
@@ -123,16 +125,24 @@ export function createRawTexture(engine, data, width, height, options) {
123
125
  const internalFormat = opts.internalFormat ?? resolveLdrInternalFormat(gl, format, type);
124
126
  // Mutable upload state — `updateRawTexture` mutates these and re-runs
125
127
  // `upload`, so the context-restore replay (which calls the same `upload`)
126
- // always reproduces the latest contents.
128
+ // always reproduces the latest contents. The replayed dimensions stay
129
+ // paired with the replayed pixels: `tex.width` / `height` may run ahead of
130
+ // them (a render-target resize during loss, applied by its restore).
127
131
  let curData = data;
128
132
  let curWidth = width;
129
133
  let curHeight = height;
130
134
  let curAlign = opts.unpackAlignment ?? 4;
131
- const upload = (target) => {
135
+ const upload = (target, pixels = curData, w = curWidth, h = curHeight, alignment = curAlign) => {
136
+ curData = target._noRestore ? null : pixels;
137
+ curWidth = w;
138
+ curHeight = h;
139
+ curAlign = alignment;
140
+ tex.width = w;
141
+ tex.height = h;
132
142
  const g = target.gl;
133
- setUnpackState(target, tex._invertY ?? invertY, tex._premultiplyAlpha ?? premultiply, curAlign);
143
+ setUnpackState(target, tex._invertY ?? invertY, tex._premultiplyAlpha ?? premultiply, alignment);
134
144
  bindTextureForUpload(target, tex.handle);
135
- g.texImage2D(g.TEXTURE_2D, 0, internalFormat, curWidth, curHeight, 0, format, type, curData);
145
+ g.texImage2D(g.TEXTURE_2D, 0, internalFormat, w, h, 0, format, type, pixels);
136
146
  };
137
147
  const initializeParameters = (target) => {
138
148
  setBoundTextureParams(target.gl, minFilter, magFilter, wrapS, wrapT);
@@ -147,18 +157,10 @@ export function createRawTexture(engine, data, width, height, options) {
147
157
  _disposed: false,
148
158
  _refCount: 1,
149
159
  _upload: upload,
160
+ _updateRaw: upload,
150
161
  _initializeParameters: initializeParameters,
151
162
  _wasReady: true,
152
163
  };
153
- tex._updateRaw = (target, newData, newWidth, newHeight, unpackAlignment) => {
154
- curData = newData;
155
- curWidth = newWidth;
156
- curHeight = newHeight;
157
- curAlign = unpackAlignment;
158
- tex.width = newWidth;
159
- tex.height = newHeight;
160
- upload(target);
161
- };
162
164
  upload(engine);
163
165
  initializeParameters(engine);
164
166
  engine._textures.add(tex);
@@ -338,13 +340,14 @@ export function updateTextureWrapMode(tex, wrapS, wrapT) {
338
340
  }
339
341
  /**
340
342
  * Wrap an existing raw `WebGLTexture` (e.g. one created by a host renderer or a
341
- * previous engine) as a {@link GLTexture} — the lite-gl equivalent of
342
- * ShapeBuilder's `createTextureGraphicsResourceFromExternalWebGLTexture`.
343
+ * previous engine) as a {@link GLTexture}.
343
344
  *
344
345
  * The wrapper does NOT own the underlying handle's upload — it is NOT registered
345
346
  * for context-restore replay (the external owner is responsible for that) and is
346
- * marked ready immediately. `disposeTexture` will still `gl.deleteTexture` it, so
347
- * only wrap a handle whose deletion you intend lite-gl to manage.
347
+ * marked ready immediately. By default `disposeTexture` still `gl.deleteTexture`s
348
+ * the handle; pass `ownsHandle = false` to BORROW a handle the host keeps
349
+ * owning (e.g. a texture shared with another renderer), so disposal only
350
+ * releases the wrapper and its cached bindings.
348
351
  *
349
352
  * @param engine - The engine.
350
353
  * @param handle - The external `WebGLTexture`.
@@ -353,9 +356,10 @@ export function updateTextureWrapMode(tex, wrapS, wrapT) {
353
356
  * @param options - Optional sampling state to apply once (min/mag/wrapS/wrapT).
354
357
  * Upload-only options (`invertY`, `premultiplyAlpha`, `unpackAlignment`,
355
358
  * `internalFormat`) do not apply — the handle's pixels are owned externally.
359
+ * @param ownsHandle - When `false`, `disposeTexture` never deletes `handle`. Default `true`.
356
360
  * @returns A {@link GLTexture} wrapping the handle.
357
361
  */
358
- export function createTextureFromHandle(engine, handle, width, height, options) {
362
+ export function createTextureFromHandle(engine, handle, width, height, options, ownsHandle = true) {
359
363
  const tex = {
360
364
  handle,
361
365
  target: engine.gl.TEXTURE_2D,
@@ -369,6 +373,9 @@ export function createTextureFromHandle(engine, handle, width, height, options)
369
373
  _upload: () => { },
370
374
  _wasReady: true,
371
375
  };
376
+ if (!ownsHandle) {
377
+ tex._borrowed = true;
378
+ }
372
379
  if (options !== undefined) {
373
380
  const gl = engine.gl;
374
381
  bindTextureForUpload(engine, handle);
@@ -379,7 +386,12 @@ export function createTextureFromHandle(engine, handle, width, height, options)
379
386
  /** Asynchronous image upload.The returned texture is immediately usable (1×1
380
387
  * transparent placeholder); `isReady` flips true once the image has been
381
388
  * decoded and uploaded. The decoded `ImageBitmap` is retained on the texture
382
- * for offline-safe `webglcontextrestored` replay. `invertY` and
389
+ * for offline-safe `webglcontextrestored` replay by default; on a host-owned
390
+ * engine (`createHostOwnedGLEngine`), it is closed/released after the upload,
391
+ * and a decode finishing while that engine is lost closes the bitmap and
392
+ * reports a context-loss error through `onError` instead of `onLoad`, even when
393
+ * the host already disposed the texture (e.g. from `onContextLost`). Otherwise,
394
+ * disposing the texture before its decode finishes cancels the load silently. `invertY` and
383
395
  * `premultiplyAlpha` are applied at decode time (`createImageBitmap`'s
384
396
  * `imageOrientation` / `premultiplyAlpha`) because the `UNPACK_*` flags are
385
397
  * ignored for `ImageBitmap` sources. */
@@ -397,7 +409,6 @@ export function loadTexture2D(engine, url, options, onLoad, onError) {
397
409
  const invertY = opts.invertY ?? false;
398
410
  const premultiplyAlpha = opts.premultiplyAlpha ?? false;
399
411
  let bitmap = null;
400
- const placeholderPixels = new Uint8Array([0, 0, 0, 0]);
401
412
  const upload = (target) => {
402
413
  const g = target.gl;
403
414
  // invertY / premultiplyAlpha are applied at decode time via createImageBitmap
@@ -412,7 +423,8 @@ export function loadTexture2D(engine, url, options, onLoad, onError) {
412
423
  tex.height = bitmap.height;
413
424
  }
414
425
  else {
415
- g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, 1, 1, 0, g.RGBA, g.UNSIGNED_BYTE, placeholderPixels);
426
+ // null leaves WebGL2's zero-initialized texel: transparent black.
427
+ g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, 1, 1, 0, g.RGBA, g.UNSIGNED_BYTE, null);
416
428
  }
417
429
  };
418
430
  const initializeParameters = (target) => {
@@ -446,19 +458,29 @@ export function loadTexture2D(engine, url, options, onLoad, onError) {
446
458
  })
447
459
  .then((blob) => createImageBitmap(blob, { premultiplyAlpha: premultiplyAlpha ? "premultiply" : "none", imageOrientation: invertY ? "flipY" : "none" }))
448
460
  .then((bm) => {
461
+ // An opted-out host recreates its resources after a loss, so a load
462
+ // finishing during loss fails — even if the host already disposed
463
+ // the texture — and a callback-wrapping Promise always settles.
464
+ if (engine._noRestore && engine._isLost) {
465
+ bm.close();
466
+ throw new Error(`lite-gl: context lost while loading ${url}`);
467
+ }
449
468
  if (tex._disposed) {
450
469
  bm.close();
451
470
  return;
452
471
  }
453
472
  bitmap = bm;
454
- // If the context is lost mid-flight, defer the upload — the restore
455
- // handler will call _upload again, which will then see `bitmap !== null`
456
- // and replay the real image.
473
+ // Default recovery defers an in-flight image until restore.
457
474
  if (!engine._isLost) {
458
475
  // Through `tex._upload` so a retained mip chain is rebuilt.
459
476
  tex._upload(engine);
460
477
  tex.isReady = true;
461
478
  }
479
+ // An opted-out host releases the bitmap once uploaded.
480
+ if (engine._noRestore) {
481
+ bitmap = null;
482
+ bm.close();
483
+ }
462
484
  tex._wasReady = true;
463
485
  if (onLoad !== undefined) {
464
486
  onLoad(tex);
@@ -534,7 +556,9 @@ export function bindTextureForUpload(engine, handle) {
534
556
  * Deregistration is expected O(1), independent of the live texture count.
535
557
  * Shared references keep the texture registered until its final release;
536
558
  * repeated disposal is a no-op. Unregistered wrappers keep their existing
537
- * handle-deletion semantics without affecting the live registry. */
559
+ * handle-deletion semantics without affecting the live registry; borrowed
560
+ * wrappers (`createTextureFromHandle(…, ownsHandle = false)`) never delete
561
+ * their handle. */
538
562
  export function disposeTexture(tex) {
539
563
  if (tex._disposed) {
540
564
  return;
@@ -546,13 +570,15 @@ export function disposeTexture(tex) {
546
570
  }
547
571
  tex._disposed = true;
548
572
  engine._textures.delete(tex);
549
- if (!engine._isLost && !engine._disposed) {
573
+ if (!tex._borrowed && !engine._isLost && !engine._disposed) {
550
574
  engine.gl.deleteTexture(tex.handle);
551
575
  }
552
576
  const bound = engine._state.boundTextures;
553
577
  for (let u = 0; u < bound.length; u++) {
554
578
  if (bound[u] === tex.handle) {
555
- bound[u] = null;
579
+ // A deleted handle leaves the unit unbound; a borrowed one is still
580
+ // bound in GL, so the slot becomes unknown and the next unbind is issued.
581
+ bound[u] = tex._borrowed ? undefined : null;
556
582
  }
557
583
  }
558
584
  }
@@ -584,7 +610,7 @@ export function resolveLdrInternalFormat(gl, format, type) {
584
610
  }
585
611
  /** Internal — pick a sized internalFormat for `texImage2D`. WebGL2 prefers
586
612
  * sized formats for non-color-renderable / non-readback paths; for the
587
- * NeonBrush use cases (sample-only) the unsized format works too, but sized
613
+ * sample-only use cases the unsized format works too, but sized
588
614
  * is more portable. Shared with the render-target module.
589
615
  * @internal */
590
616
  export function pickSizedInternalFormat(gl, format, type) {
package/texture.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"texture.js","sourceRoot":"","sources":["../src/texture.ts"],"names":[],"mappings":"AAEA;;;gFAGgF;AAChF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B;2CACuC;IACvC,OAAO,EAAE,CAAC;IACV;4CACwC;IACxC,QAAQ,EAAE,CAAC;IACX;6CACyC;IACzC,SAAS,EAAE,CAAC;CACN,CAAC;AA6IX;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,MAAuB,EAAE,KAAc,EAAE,gBAAyB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AAC;YACrB,OAAO,EAAE,CAAC,KAAK,CAAC;QACpB,CAAC;QACD,IAAI,MAAM,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC,IAAI,CAAC;QACnB,CAAC;QACD,IAAI,MAAM,KAAK,EAAE,CAAC,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC,SAAS,CAAC;QACxB,CAAC;IACL,CAAC;IACD,IAAI,IAAI,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,MAAM,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC,OAAO,CAAC;QACtB,CAAC;QACD,IAAI,MAAM,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC,MAAM,CAAC;QACrB,CAAC;IACL,CAAC;IACD,IAAI,IAAI,KAAK,EAAE,CAAC,UAAU,EAAE,CAAC;QACzB,IAAI,MAAM,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC,OAAO,CAAC;QACtB,CAAC;QACD,IAAI,MAAM,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC,MAAM,CAAC;QACrB,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import type { GLEngineContext } from \"./context.js\";\n\n/** High-level sampling presets, mirroring Babylon's `Texture.*_SAMPLINGMODE`\n * numeric constants. Resolve one to GL min/mag filters with\n * {@link getSamplingModeFilters} (≙ Babylon's `_getSamplingParameters`); only\n * `TRILINEAR` samples the mip chain, and only when the texture has mipmaps. */\nexport const GLSamplingMode = {\n /** Nearest mag; nearest min, even with mipmaps.\n * (`Texture.NEAREST_SAMPLINGMODE`) */\n NEAREST: 1,\n /** Linear mag; linear min, even with mipmaps.\n * (`Texture.BILINEAR_SAMPLINGMODE`) */\n BILINEAR: 2,\n /** Linear mag; linear min (`LINEAR_MIPMAP_LINEAR` with mipmaps).\n * (`Texture.TRILINEAR_SAMPLINGMODE`) */\n TRILINEAR: 3,\n} as const;\n\n/** One of the {@link GLSamplingMode} preset values (`1`, `2` or `3`). */\nexport type GLSamplingMode = (typeof GLSamplingMode)[keyof typeof GLSamplingMode];\n\n/** Creation options shared by EVERY texture factory (`createRawTexture`,\n * `createFloatTexture`, `loadTexture2D`, `createTextureFromSource`,\n * `createDynamicTexture`, `createHtmlElementTexture`,\n * `createTextureFromHandle`). All have GL-spec defaults.\n *\n * Babylon-style sampling presets are opt-in so factories don't ship them:\n * spread {@link getSamplingModeFilters} into the options. Mipmaps are not a\n * creation option either: call {@link generateTextureMipMaps} once, after\n * which every later upload and `webglcontextrestored` replay rebuilds the\n * chain. */\nexport interface GLTextureOptions {\n /** Flip rows vertically on upload. Default: false (matches Babylon's\n * default raw-texture behaviour). For raw / dynamic / HTML-element textures\n * this is the default for every update that omits `invertY`. */\n invertY?: boolean;\n /** Default: gl.LINEAR. See {@link getSamplingModeFilters} for presets. */\n minFilter?: GLenum;\n /** Default: gl.LINEAR. */\n magFilter?: GLenum;\n /** Default: gl.CLAMP_TO_EDGE. May be `gl.REPEAT` / `gl.MIRRORED_REPEAT`\n * (NPOT-safe in WebGL2). */\n wrapS?: GLenum;\n /** Default: gl.CLAMP_TO_EDGE. May be `gl.REPEAT` / `gl.MIRRORED_REPEAT`. */\n wrapT?: GLenum;\n /** `gl.pixelStorei(UNPACK_ALIGNMENT)` for the upload (1/2/4/8). Default 4.\n * Use 1 for tightly-packed non-RGBA rows. */\n unpackAlignment?: number;\n /** Premultiply alpha at upload (`UNPACK_PREMULTIPLY_ALPHA_WEBGL`, or\n * decode-time for `loadTexture2D`). Default false. For raw / dynamic /\n * HTML-element textures this is the default for every update that omits it. */\n premultiplyAlpha?: boolean;\n /** Explicit sized internalFormat for `texImage2D`. When provided it is used\n * verbatim and the inline LDR resolver is bypassed — this is how\n * {@link createFloatTexture} injects its `RGBA16F` / `RGBA32F` choice\n * without the byte path ever referencing the float-format table (keeping it\n * tree-shakeable out of RGBA8-only bundles). Default: derived from\n * `format`/`type` via the LDR resolver. */\n internalFormat?: GLenum;\n}\n\n/** Per-update pixel-store flags shared by `updateRawTexture`,\n * `updateDynamicTexture` and `updateHtmlElementTexture` (≙ lite's\n * `DynamicTextureUpdateOptions`, Babylon's `updateRawTexture(…, invertY)`). Each\n * omitted flag falls back to the texture's creation {@link GLTextureOptions}\n * value; the flags of the latest update are reused on `webglcontextrestored`. */\nexport interface GLTextureUpdateOptions {\n /** Flip rows vertically on upload (`UNPACK_FLIP_Y_WEBGL`). */\n invertY?: boolean;\n /** Premultiply alpha on upload (`UNPACK_PREMULTIPLY_ALPHA_WEBGL`). */\n premultiplyAlpha?: boolean;\n}\n\n/**\n * Pure-state texture handle. The `handle` field is MUTABLE so the same logical\n * texture survives a `webglcontextrestored` event — every consumer keeps the\n * same `GLTexture` reference; only the internal `WebGLTexture` is swapped.\n *\n * `loadTexture2D` also uses the same handle for the 1×1 placeholder upload AND\n * the final image upload — so a `bindTexture(tex, unit)` made before the\n * image has decoded remains valid once the image arrives.\n */\nexport interface GLTexture {\n /** The live `WebGLTexture`. MUTABLE — swapped for a fresh handle on\n * `webglcontextrestored` while consumers keep the same `GLTexture` reference. */\n handle: WebGLTexture;\n /** GL texture target (normally `gl.TEXTURE_2D`); 3D textures use their own API. */\n readonly target: GLenum;\n /** Texture width in texels. Updated once an async upload resolves. */\n width: number;\n /** Texture height in texels. Updated once an async upload resolves. */\n height: number;\n /** True when the texture is safe to sample with final content (placeholders\n * read as not-ready until their image/upload completes). */\n isReady: boolean;\n /** The engine that created (and owns) this texture. Texture operations\n * derive their engine from it, so they take the texture alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal */\n _refCount: number;\n /** Replays the latest pixel content into the currently bound texture handle. @internal */\n _upload: (engine: GLEngineContext) => void;\n /** Initializes creation-time sampling state on the bound texture handle. @internal */\n _initializeParameters?: (engine: GLEngineContext) => void;\n /**\n * Snapshot of `isReady` captured on `webglcontextlost` so the restore\n * handler knows whether to flip it back on after `_upload`. Textures\n * that were still mid-load (e.g. `loadTexture2D` whose bitmap hadn't\n * arrived) stay not-ready; the async path will set `isReady=true` once\n * the bitmap finishes decoding into the new handle.\n * @internal\n */\n _wasReady: boolean;\n /**\n * Live re-upload hook installed by `createRawTexture` — lets\n * `updateRawTexture` replace the pixel data (and optionally the size)\n * through the same closure that the context-restore replay uses, keeping\n * restore correct. Absent on image / HTML-element / external textures.\n * @internal\n */\n _updateRaw?: (engine: GLEngineContext, data: ArrayBufferView | null, width: number, height: number, unpackAlignment: number) => void;\n /**\n * Dynamic-texture source captured by `updateDynamicTexture`\n * (`@babylonjs/lite-gl`) and replayed into the fresh handle\n * on `webglcontextrestored`. Null/absent on non-dynamic textures.\n * @internal\n */\n _dynSource?: TexImageSource | null;\n /** `invertY` of the latest raw / dynamic / HTML-element update\n * ({@link GLTextureUpdateOptions}), reused by context-restore replay;\n * `undefined` → the texture's creation `invertY`. @internal */\n _invertY?: boolean;\n /** `premultiplyAlpha` of the latest raw / dynamic / HTML-element update\n * ({@link GLTextureUpdateOptions}), reused by context-restore replay;\n * `undefined` → the texture's creation `premultiplyAlpha`. @internal */\n _premultiplyAlpha?: boolean;\n /**\n * The `handle` the dynamic texture's `texParameteri` filter/wrap state was\n * last applied to. `texParameteri` is per-texture GL state that survives pixel\n * re-uploads, so the dynamic-texture `_upload` re-applies it ONLY when this no\n * longer matches `handle` — i.e. at creation and after `webglcontextrestored`\n * installs a fresh handle — not on every per-frame `updateDynamicTexture`.\n * @internal\n */\n _dynParamsHandle?: WebGLTexture | null;\n /**\n * Set by {@link generateTextureMipMaps} (≙ Babylon\n * `InternalTexture.useMipMaps`, and the 3D API's `_hasMipMaps`). The mip\n * intent is retained: `_upload` is wrapped once so every later level-0\n * upload, including `webglcontextrestored` replay, rebuilds the chain.\n * @internal\n */\n _hasMipMaps?: boolean;\n}\n\n/**\n * Apply the three `UNPACK_*` pixel-store flags through the GL-state cache,\n * eliding redundant `pixelStorei` calls. Centralising this guarantees EVERY\n * upload path sets all three explicitly, so a premultiplying / flipping upload\n * never leaks its flag into a later upload that forgot to set it.\n * @internal\n */\nexport function setUnpackState(engine: GLEngineContext, flipY: boolean, premultiplyAlpha: boolean, alignment = 4): void {\n const gl = engine.gl;\n const s = engine._state;\n const fy = flipY ? 1 : 0;\n if (s.unpackFlipY !== fy) {\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, fy);\n s.unpackFlipY = fy;\n }\n const pm = premultiplyAlpha ? 1 : 0;\n if (s.unpackPremultiplyAlpha !== pm) {\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pm);\n s.unpackPremultiplyAlpha = pm;\n }\n if (s.unpackAlignment !== alignment) {\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, alignment);\n s.unpackAlignment = alignment;\n }\n}\n\n/** Apply sampling and wrap state to the texture currently bound for upload. @internal */\nexport function setBoundTextureParams(gl: WebGL2RenderingContext, minFilter: GLenum, magFilter: GLenum, wrapS: GLenum, wrapT: GLenum): void {\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);\n}\n\n/** GL min/mag filters resolved from a {@link GLSamplingMode} preset. Spread\n * into any {@link GLTextureOptions}, or pass to {@link updateTextureSamplingMode}\n * (or use {@link updateTextureSamplingPreset} directly). */\nexport interface GLSamplingFilters {\n /** `TEXTURE_MIN_FILTER` value. */\n minFilter: GLenum;\n /** `TEXTURE_MAG_FILTER` value. */\n magFilter: GLenum;\n}\n\n/**\n * Resolve a Babylon-style sampling preset to GL min/mag filters — the lite-gl\n * counterpart of Babylon's `_getSamplingParameters(samplingMode, generateMipMaps)`.\n * Pure (no GL context needed; WebGL filter enums are spec constants) and\n * tree-shaken unless imported, so preset-free bundles ship none of it.\n *\n * | Preset | min (no mips) | min (mips) | mag |\n * | ----------- | ------------- | ---------------------- | --------- |\n * | `NEAREST` | `NEAREST` | `NEAREST` | `NEAREST` |\n * | `BILINEAR` | `LINEAR` | `LINEAR` | `LINEAR` |\n * | `TRILINEAR` | `LINEAR` | `LINEAR_MIPMAP_LINEAR` | `LINEAR` |\n *\n * Babylon's mipmapped nearest / bilinear variants are separate modes\n * (`NEAREST_LINEAR_MIPNEAREST` …); pass their raw filters instead.\n *\n * @example\n * ```ts\n * const tex = createRawTexture(engine, data, w, h, getSamplingModeFilters(GLSamplingMode.TRILINEAR, true));\n * generateTextureMipMaps(tex); // required by the mipmapped min filter\n * ```\n *\n * @param samplingMode - The {@link GLSamplingMode} preset.\n * @param useMipMaps - Whether the texture has (or will get, via\n * {@link generateTextureMipMaps}) a mip chain. Default false, so the min\n * filter never references a missing chain.\n * @returns The preset's `{ minFilter, magFilter }`.\n */\nexport function getSamplingModeFilters(samplingMode: GLSamplingMode, useMipMaps = false): GLSamplingFilters {\n // WebGL filter enums: NEAREST 0x2600, LINEAR 0x2601, LINEAR_MIPMAP_LINEAR 0x2703.\n const magFilter = samplingMode === GLSamplingMode.NEAREST ? 0x2600 : 0x2601;\n return { minFilter: useMipMaps && samplingMode === GLSamplingMode.TRILINEAR ? 0x2703 : magFilter, magFilter };\n}\n\n/** Size-bearing fields across the `TexImageSource` variants. @internal */\ninterface TexImageSourceSize {\n width?: number;\n height?: number;\n videoWidth?: number;\n videoHeight?: number;\n naturalWidth?: number;\n naturalHeight?: number;\n displayWidth?: number;\n displayHeight?: number;\n}\n\n/** Write the pixel size of a `TexImageSource` as `texImage2D` will upload it\n * into `tex.width` / `tex.height`: the intrinsic size for video\n * (`videoWidth`), image (`naturalWidth`) and `VideoFrame` (`displayWidth`)\n * sources, `width`/`height` otherwise. Clamped to ≥ 1. Allocation-free — it\n * runs on every dynamic / HTML-element re-upload. @internal */\nexport function setTexImageSourceSize(tex: GLTexture, source: TexImageSourceSize): void {\n tex.width = (source.videoWidth ?? source.naturalWidth ?? source.displayWidth ?? source.width) || 1;\n tex.height = (source.videoHeight ?? source.naturalHeight ?? source.displayHeight ?? source.height) || 1;\n}\n\n/** Options for {@link createRawTexture}: the shared {@link GLTextureOptions}\n * plus the pixel `format` / `type` of `data`. */\nexport interface GLRawTextureOptions extends GLTextureOptions {\n /** Pixel format of `data` (`gl.RGBA`, `gl.RGB`, `gl.RG`, `gl.RED`,\n * `gl.LUMINANCE`…). Default `gl.RGBA`. */\n format?: GLenum;\n /** Pixel type of `data`. Default `gl.UNSIGNED_BYTE`. For float data, prefer\n * {@link createFloatTexture}, which also picks the sized float internalFormat. */\n type?: GLenum;\n}\n\n/**\n * Create a raw texture from a typed array (or an uninitialised allocation).\n * RGBA8 by default; set {@link GLRawTextureOptions.format} / `type` for other\n * layouts. The pixel data can be replaced later via {@link updateRawTexture};\n * the sampling and wrap can be changed via {@link updateTextureSamplingMode} /\n * {@link updateTextureWrapMode}.\n *\n * @param engine - The engine.\n * @param data - Initial pixels matching `format` / `type`, or `null` for an\n * uninitialised allocation.\n * @param width - Texture width in texels.\n * @param height - Texture height in texels.\n * @param options - See {@link GLRawTextureOptions}.\n * @returns The new {@link GLTexture}.\n */\nexport function createRawTexture(engine: GLEngineContext, data: ArrayBufferView | null, width: number, height: number, options?: GLRawTextureOptions): GLTexture {\n const gl = engine.gl;\n const handle = gl.createTexture();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createTexture returned null\");\n }\n const opts = options ?? {};\n const format = opts.format ?? gl.RGBA;\n const type = opts.type ?? gl.UNSIGNED_BYTE;\n const minFilter = opts.minFilter ?? gl.LINEAR;\n const magFilter = opts.magFilter ?? gl.LINEAR;\n const wrapS = opts.wrapS ?? gl.CLAMP_TO_EDGE;\n const wrapT = opts.wrapT ?? gl.CLAMP_TO_EDGE;\n const invertY = opts.invertY ?? false;\n const premultiply = opts.premultiplyAlpha ?? false;\n // LDR byte formats are resolved INLINE here; the float-format table in\n // `pickSizedInternalFormat` is deliberately NOT referenced from this path so\n // it tree-shakes out of byte-only bundles. `createFloatTexture` injects its\n // sized float format via `opts.internalFormat`.\n const internalFormat = opts.internalFormat ?? resolveLdrInternalFormat(gl, format, type);\n\n // Mutable upload state — `updateRawTexture` mutates these and re-runs\n // `upload`, so the context-restore replay (which calls the same `upload`)\n // always reproduces the latest contents.\n let curData = data;\n let curWidth = width;\n let curHeight = height;\n let curAlign = opts.unpackAlignment ?? 4;\n\n const upload = (target: GLEngineContext): void => {\n const g = target.gl;\n setUnpackState(target, tex._invertY ?? invertY, tex._premultiplyAlpha ?? premultiply, curAlign);\n bindTextureForUpload(target, tex.handle);\n g.texImage2D(g.TEXTURE_2D, 0, internalFormat, curWidth, curHeight, 0, format, type, curData);\n };\n\n const initializeParameters = (target: GLEngineContext): void => {\n setBoundTextureParams(target.gl, minFilter, magFilter, wrapS, wrapT);\n };\n\n const tex: GLTexture = {\n handle,\n target: gl.TEXTURE_2D,\n width,\n height,\n isReady: true,\n _engine: engine,\n _disposed: false,\n _refCount: 1,\n _upload: upload,\n _initializeParameters: initializeParameters,\n _wasReady: true,\n };\n tex._updateRaw = (target: GLEngineContext, newData: ArrayBufferView | null, newWidth: number, newHeight: number, unpackAlignment: number): void => {\n curData = newData;\n curWidth = newWidth;\n curHeight = newHeight;\n curAlign = unpackAlignment;\n tex.width = newWidth;\n tex.height = newHeight;\n upload(target);\n };\n upload(engine);\n initializeParameters(engine);\n engine._textures.add(tex);\n return tex;\n}\n\n/** Options for {@link createFloatTexture} — the shared {@link GLTextureOptions}\n * plus the float-specific `type` / `format`. */\nexport interface GLFloatTextureOptions extends GLTextureOptions {\n /** Float texel type — `gl.HALF_FLOAT` (default) or `gl.FLOAT`. */\n type?: GLenum;\n /** Color format. Default `gl.RGBA`. */\n format?: GLenum;\n}\n\n/**\n * Create a float / half-float raw texture — the HDR counterpart of\n * {@link createRawTexture}. This is the ONLY texture factory that carries the\n * `RGBA16F` / `RGBA32F` sized-format knowledge (via {@link pickSizedInternalFormat}),\n * so byte-only consumers calling {@link createRawTexture} ship none of it.\n * Defaults to `gl.HALF_FLOAT`; pass `options.type = gl.FLOAT` for full 32-bit.\n * The caller is responsible for the matching engine cap (e.g.\n * `caps.textureFloatLinearFiltering`) when sampling these with `LINEAR`.\n *\n * @param engine - The engine.\n * @param data - Initial pixels (`Float32Array` for FLOAT, `Uint16Array` for\n * HALF_FLOAT), or `null` for an uninitialised allocation.\n * @param width - Texture width in texels (≥ 1).\n * @param height - Texture height in texels (≥ 1).\n * @param options - See {@link GLFloatTextureOptions}.\n * @returns The new {@link GLTexture}.\n */\nexport function createFloatTexture(engine: GLEngineContext, data: ArrayBufferView | null, width: number, height: number, options?: GLFloatTextureOptions): GLTexture {\n const gl = engine.gl;\n const o = options ?? {};\n const format = o.format ?? gl.RGBA;\n const type = o.type ?? gl.HALF_FLOAT;\n // Precompute the sized float internalFormat HERE and pass it through, so\n // `createRawTexture`'s inline LDR resolver is bypassed and the float table\n // stays out of byte-only bundles.\n const internalFormat = pickSizedInternalFormat(gl, format, type);\n return createRawTexture(engine, data, width, height, { ...o, format, type, internalFormat });\n}\n\n/**\n * Generate the mip chain for a texture from its level-0 contents and keep it\n * current (≙ Babylon's `useMipMaps` / lite-gl's `generateTexture3DMipMaps`).\n * The intent is retained: every later level-0 upload — `updateRawTexture`,\n * `updateDynamicTexture`, `updateHtmlElementTexture`, the `loadTexture2D` image\n * arrival and `webglcontextrestored` replay — rebuilds the chain, so a\n * mipmapped min filter never samples an incomplete texture. Only bundles that\n * call it pay for mipmapping. Calling it again just regenerates now.\n *\n * Binds for upload (unit 0). The format must be filterable (float textures need\n * the matching linear-filtering cap). Render targets use\n * `generateRenderTargetMipMaps` instead. No-op on a lost/disposed context or a\n * disposed texture.\n *\n * @param tex - The texture whose mip chain to generate.\n */\nexport function generateTextureMipMaps(tex: GLTexture): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed || tex.handle === null) {\n return;\n }\n bindTextureForUpload(engine, tex.handle);\n engine.gl.generateMipmap(engine.gl.TEXTURE_2D);\n if (!tex._hasMipMaps) {\n tex._hasMipMaps = true;\n // Every `_upload` that runs (update / restore-registry replay) leaves\n // this texture bound for upload; handle/RT textures are never replayed.\n const upload = tex._upload;\n tex._upload = (target: GLEngineContext): void => {\n upload(target);\n target.gl.generateMipmap(target.gl.TEXTURE_2D);\n };\n }\n}\n\n/**\n * Re-upload the pixel data (and optionally resize) of a texture created by\n * {@link createRawTexture} — the lite-gl equivalent of Babylon's\n * `updateRawTexture` / `_uploadDataToTextureDirectly`. Goes through the same\n * upload closure used by context-restore, so the new contents survive a context\n * loss, and rebuilds the mip chain after {@link generateTextureMipMaps}. No-op\n * on a lost/disposed/non-raw texture.\n *\n * @param tex - The raw texture to update.\n * @param data - New pixel data (must match the original `format`/`type`).\n * @param options - Optional new `width`/`height` (default: unchanged),\n * `unpackAlignment` (default 4) and `invertY` / `premultiplyAlpha` (default:\n * the creation values; ≙ Babylon's `updateRawTexture(…, invertY)`). The flags\n * are reused by context-restore replay.\n */\nexport function updateRawTexture(\n tex: GLTexture,\n data: ArrayBufferView | null,\n options?: GLTextureUpdateOptions & { width?: number; height?: number; unpackAlignment?: number }\n): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed || tex._updateRaw === undefined) {\n return;\n }\n const o = options ?? {};\n tex._invertY = o.invertY;\n tex._premultiplyAlpha = o.premultiplyAlpha;\n tex._updateRaw(engine, data, o.width ?? tex.width, o.height ?? tex.height, o.unpackAlignment ?? 4);\n if (tex._hasMipMaps) {\n // `_updateRaw` leaves the texture bound for upload (unit 0).\n engine.gl.generateMipmap(engine.gl.TEXTURE_2D);\n }\n}\n\n/**\n * Update a texture's raw GL min/mag sampling filters (e.g. `gl.NEAREST`,\n * `gl.LINEAR_MIPMAP_LINEAR`). A mipmapped min filter needs\n * {@link generateTextureMipMaps}; for Babylon-style presets use\n * {@link updateTextureSamplingPreset}. Binds for upload (unit 0) so the\n * `texParameteri` lands on this texture. The change is not replayed on\n * `webglcontextrestored` (creation options are). No-op on a lost/disposed\n * context or a disposed texture.\n *\n * @param tex - The texture to update.\n * @param minFilter - `TEXTURE_MIN_FILTER` value.\n * @param magFilter - `TEXTURE_MAG_FILTER` value.\n */\nexport function updateTextureSamplingMode(tex: GLTexture, minFilter: GLenum, magFilter: GLenum): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed) {\n return;\n }\n const gl = engine.gl;\n bindTextureForUpload(engine, tex.handle);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);\n}\n\n/**\n * Update a texture's sampling mode from a Babylon-style preset — the lite-gl\n * equivalent of Babylon's\n * `updateTextureSamplingMode(samplingMode, texture, generateMipMaps)`. The\n * filters come from {@link getSamplingModeFilters}, using the mipmapped\n * `TRILINEAR` min filter when the texture already has mipmaps (from\n * {@link generateTextureMipMaps}) or `generateMipMaps` is true. Like Babylon,\n * `generateMipMaps` only generates (and retains) the chain for `TRILINEAR`,\n * right after the filters are set; `NEAREST` / `BILINEAR` never sample mips.\n * Unlike Babylon, an existing chain is not regenerated (lite-gl already\n * rebuilds it on every upload); call {@link generateTextureMipMaps} to force it.\n *\n * Kept separate from the raw {@link updateTextureSamplingMode} so raw-filter\n * callers don't bundle the preset and mipmap code. Same binding, replay and\n * lost/disposed behavior.\n *\n * @param tex - The texture to update.\n * @param samplingMode - The {@link GLSamplingMode} preset.\n * @param generateMipMaps - Generate the mip chain now (`TRILINEAR` only). Default false.\n */\nexport function updateTextureSamplingPreset(tex: GLTexture, samplingMode: GLSamplingMode, generateMipMaps?: boolean): void {\n // ≙ Babylon: mips are generated only for a mipmapped preset (`TRILINEAR`).\n const generate = generateMipMaps === true && samplingMode === GLSamplingMode.TRILINEAR;\n const filters = getSamplingModeFilters(samplingMode, generate || tex._hasMipMaps === true);\n updateTextureSamplingMode(tex, filters.minFilter, filters.magFilter);\n // An existing chain is already rebuilt on every upload; call\n // `generateTextureMipMaps` directly to force a regeneration.\n if (generate && !tex._hasMipMaps) {\n generateTextureMipMaps(tex);\n }\n}\n\n/**\n * Whether a texture holds its final content and can be sampled — the function\n * form of {@link GLTexture.isReady}, mirroring `isEffectReady(effect)`\n * (≙ Babylon's `texture.isReady()`). False while `loadTexture2D` is still\n * decoding (the 1×1 placeholder is bound meanwhile), after disposal, and while\n * the context is lost/disposed.\n *\n * @param tex - The texture to query.\n * @returns `true` when the texture is ready to sample.\n */\nexport function isTextureReady(tex: GLTexture): boolean {\n const engine = tex._engine;\n return tex.isReady && !tex._disposed && !engine._isLost && !engine._disposed;\n}\n\n/** Update a texture's S/T wrap modes (`gl.CLAMP_TO_EDGE` / `gl.REPEAT` /\n * `gl.MIRRORED_REPEAT`) — the lite-gl equivalent of Babylon's\n * `updateTextureWrappingMode`. No-op on a lost/disposed context. */\nexport function updateTextureWrapMode(tex: GLTexture, wrapS: GLenum, wrapT: GLenum): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed) {\n return;\n }\n const gl = engine.gl;\n bindTextureForUpload(engine, tex.handle);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);\n}\n\n/**\n * Wrap an existing raw `WebGLTexture` (e.g. one created by a host renderer or a\n * previous engine) as a {@link GLTexture} — the lite-gl equivalent of\n * ShapeBuilder's `createTextureGraphicsResourceFromExternalWebGLTexture`.\n *\n * The wrapper does NOT own the underlying handle's upload — it is NOT registered\n * for context-restore replay (the external owner is responsible for that) and is\n * marked ready immediately. `disposeTexture` will still `gl.deleteTexture` it, so\n * only wrap a handle whose deletion you intend lite-gl to manage.\n *\n * @param engine - The engine.\n * @param handle - The external `WebGLTexture`.\n * @param width - Texture width in texels.\n * @param height - Texture height in texels.\n * @param options - Optional sampling state to apply once (min/mag/wrapS/wrapT).\n * Upload-only options (`invertY`, `premultiplyAlpha`, `unpackAlignment`,\n * `internalFormat`) do not apply — the handle's pixels are owned externally.\n * @returns A {@link GLTexture} wrapping the handle.\n */\nexport function createTextureFromHandle(engine: GLEngineContext, handle: WebGLTexture, width: number, height: number, options?: GLTextureOptions): GLTexture {\n const tex: GLTexture = {\n handle,\n target: engine.gl.TEXTURE_2D,\n width,\n height,\n isReady: true,\n _engine: engine,\n _disposed: false,\n _refCount: 1,\n // External handle — restore replay is the external owner's job.\n _upload: () => {},\n _wasReady: true,\n };\n if (options !== undefined) {\n const gl = engine.gl;\n bindTextureForUpload(engine, handle);\n setBoundTextureParams(gl, options.minFilter ?? gl.LINEAR, options.magFilter ?? gl.LINEAR, options.wrapS ?? gl.CLAMP_TO_EDGE, options.wrapT ?? gl.CLAMP_TO_EDGE);\n }\n return tex;\n}\n\n/** Asynchronous image upload.The returned texture is immediately usable (1×1\n * transparent placeholder); `isReady` flips true once the image has been\n * decoded and uploaded. The decoded `ImageBitmap` is retained on the texture\n * for offline-safe `webglcontextrestored` replay. `invertY` and\n * `premultiplyAlpha` are applied at decode time (`createImageBitmap`'s\n * `imageOrientation` / `premultiplyAlpha`) because the `UNPACK_*` flags are\n * ignored for `ImageBitmap` sources. */\nexport function loadTexture2D(engine: GLEngineContext, url: string, options?: GLTextureOptions, onLoad?: (tex: GLTexture) => void, onError?: (err: Error) => void): GLTexture {\n const gl = engine.gl;\n const handle = gl.createTexture();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createTexture returned null\");\n }\n const opts = options ?? {};\n const minFilter = opts.minFilter ?? gl.LINEAR;\n const magFilter = opts.magFilter ?? gl.LINEAR;\n const wrapS = opts.wrapS ?? gl.CLAMP_TO_EDGE;\n const wrapT = opts.wrapT ?? gl.CLAMP_TO_EDGE;\n const invertY = opts.invertY ?? false;\n const premultiplyAlpha = opts.premultiplyAlpha ?? false;\n\n let bitmap: ImageBitmap | null = null;\n const placeholderPixels = new Uint8Array([0, 0, 0, 0]);\n\n const upload = (target: GLEngineContext): void => {\n const g = target.gl;\n // invertY / premultiplyAlpha are applied at decode time via createImageBitmap\n // because UNPACK_FLIP_Y_WEBGL / UNPACK_PREMULTIPLY_ALPHA_WEBGL are IGNORED for\n // ImageBitmap sources (and the transparent 1×1 placeholder is invariant to\n // both), so keep flip + premultiply off here.\n setUnpackState(target, false, false);\n bindTextureForUpload(target, tex.handle);\n if (bitmap !== null) {\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, bitmap);\n tex.width = bitmap.width;\n tex.height = bitmap.height;\n } else {\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, 1, 1, 0, g.RGBA, g.UNSIGNED_BYTE, placeholderPixels);\n }\n };\n\n const initializeParameters = (target: GLEngineContext): void => {\n setBoundTextureParams(target.gl, minFilter, magFilter, wrapS, wrapT);\n };\n\n const tex: GLTexture = {\n handle,\n target: gl.TEXTURE_2D,\n width: 1,\n height: 1,\n isReady: false,\n _engine: engine,\n _disposed: false,\n _refCount: 1,\n _upload: upload,\n _initializeParameters: initializeParameters,\n _wasReady: false,\n };\n // Placeholder upload — makes the texture sampleable before the real image arrives.\n upload(engine);\n initializeParameters(engine);\n engine._textures.add(tex);\n\n // Fetch + decode the real image. Re-uploads via the same closure once the\n // bitmap is in hand (so context-restore replay sees the real image too).\n fetch(url)\n .then((r) => {\n if (!r.ok) {\n throw new Error(`lite-gl: fetch ${url} -> HTTP ${r.status}`);\n }\n return r.blob();\n })\n .then((blob) => createImageBitmap(blob, { premultiplyAlpha: premultiplyAlpha ? \"premultiply\" : \"none\", imageOrientation: invertY ? \"flipY\" : \"none\" }))\n .then((bm) => {\n if (tex._disposed) {\n bm.close();\n return;\n }\n bitmap = bm;\n // If the context is lost mid-flight, defer the upload — the restore\n // handler will call _upload again, which will then see `bitmap !== null`\n // and replay the real image.\n if (!engine._isLost) {\n // Through `tex._upload` so a retained mip chain is rebuilt.\n tex._upload(engine);\n tex.isReady = true;\n }\n tex._wasReady = true;\n if (onLoad !== undefined) {\n onLoad(tex);\n }\n })\n .catch((err: unknown) => {\n const e = err instanceof Error ? err : new Error(String(err));\n if (onError !== undefined) {\n onError(e);\n } else {\n console.error(\"lite-gl: loadTexture2D failed\", e);\n }\n });\n\n return tex;\n}\n\n/** Cached bind of `tex` on sampler `unit`. Skips `gl.activeTexture` and/or\n * `gl.bindTexture` when nothing changes. No-op when `tex._disposed` or the\n * context is lost/disposed. Use {@link unbindTexture} to clear a unit. */\nexport function bindTexture(tex: GLTexture, unit: number): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed) {\n return;\n }\n bindTextureRaw(engine, unit, tex.handle);\n}\n\n/** Unbind `TEXTURE_2D` on sampler `unit` (cached, like {@link bindTexture}).\n * No-op on a lost/disposed context. */\nexport function unbindTexture(engine: GLEngineContext, unit: number): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n bindTextureRaw(engine, unit, null);\n}\n\n/** @internal — for callers that already hold a raw `WebGLTexture`. Not part of\n * the public API: `bindTexture` (public) and the texture `_upload` closures bind\n * through the cache, so consumers never call this directly. */\nexport function bindTextureRaw(engine: GLEngineContext, unit: number, handle: WebGLTexture | null): void {\n const s = engine._state;\n const gl = engine.gl;\n if (s.boundTextures[unit] === handle) {\n return;\n }\n if (s.activeTextureUnit !== unit) {\n gl.activeTexture(gl.TEXTURE0 + unit);\n s.activeTextureUnit = unit;\n }\n gl.bindTexture(gl.TEXTURE_2D, handle);\n s.boundTextures[unit] = handle;\n}\n\n/** @internal Bind `handle` on texture unit 0 **for an upload** (`texImage2D`).\n * Unlike {@link bindTextureRaw} — which elides the entire bind when the handle is\n * already bound on the unit (correct for *sampling*, where the active unit is\n * irrelevant) — an upload writes into the texture on the ACTIVE unit. A prior\n * multi-sampler draw may have left a non-zero unit active while this handle is\n * still bound on unit 0, so we must force unit 0 active even on a bind cache-hit,\n * keeping the `_state` cache coherent. */\nexport function bindTextureForUpload(engine: GLEngineContext, handle: WebGLTexture): void {\n const s = engine._state;\n const gl = engine.gl;\n if (s.activeTextureUnit !== 0) {\n gl.activeTexture(gl.TEXTURE0);\n s.activeTextureUnit = 0;\n }\n if (s.boundTextures[0] !== handle) {\n gl.bindTexture(gl.TEXTURE_2D, handle);\n s.boundTextures[0] = handle;\n }\n}\n\n/** Disposes the texture. Walks `_state.boundTextures` and clears every slot\n * that still references the handle — otherwise a later `bindTexture(unit, B)`\n * to the same unit would be wrongly elided when slot still showed handle A.\n * Deregistration is expected O(1), independent of the live texture count.\n * Shared references keep the texture registered until its final release;\n * repeated disposal is a no-op. Unregistered wrappers keep their existing\n * handle-deletion semantics without affecting the live registry. */\nexport function disposeTexture(tex: GLTexture): void {\n if (tex._disposed) {\n return;\n }\n const engine = tex._engine;\n if (tex._refCount > 1) {\n tex._refCount--;\n return;\n }\n tex._disposed = true;\n engine._textures.delete(tex);\n if (!engine._isLost && !engine._disposed) {\n engine.gl.deleteTexture(tex.handle);\n }\n const bound = engine._state.boundTextures;\n for (let u = 0; u < bound.length; u++) {\n if (bound[u] === tex.handle) {\n bound[u] = null;\n }\n }\n}\n\n/** Internal — resolve the sized internalFormat for the LDR (byte) `texImage2D`\n * paths ONLY: RGBA→RGBA8, RGB→RGB8, RG→RG8, RED→R8, LUMINANCE passthrough.\n * Deliberately knows nothing about FLOAT / HALF_FLOAT so the float-format table\n * in {@link pickSizedInternalFormat} tree-shakes out of byte-only bundles.\n * Shared with the render-target module (which validates the format first).\n * @internal */\nexport function resolveLdrInternalFormat(gl: WebGL2RenderingContext, format: GLenum, type: GLenum): GLenum {\n if (type === gl.UNSIGNED_BYTE) {\n if (format === gl.RGBA) {\n return gl.RGBA8;\n }\n if (format === gl.RGB) {\n return gl.RGB8;\n }\n if (format === gl.RG) {\n return gl.RG8;\n }\n if (format === gl.RED) {\n return gl.R8;\n }\n if (format === gl.LUMINANCE) {\n return gl.LUMINANCE;\n }\n }\n return format;\n}\n\n/** Internal — pick a sized internalFormat for `texImage2D`. WebGL2 prefers\n * sized formats for non-color-renderable / non-readback paths; for the\n * NeonBrush use cases (sample-only) the unsized format works too, but sized\n * is more portable. Shared with the render-target module.\n * @internal */\nexport function pickSizedInternalFormat(gl: WebGL2RenderingContext, format: GLenum, type: GLenum): GLenum {\n if (type === gl.UNSIGNED_BYTE) {\n if (format === gl.RGBA) {\n return gl.RGBA8;\n }\n if (format === gl.RGB) {\n return gl.RGB8;\n }\n if (format === gl.LUMINANCE) {\n return gl.LUMINANCE;\n }\n }\n if (type === gl.FLOAT) {\n if (format === gl.RGBA) {\n return gl.RGBA32F;\n }\n if (format === gl.RGB) {\n return gl.RGB32F;\n }\n }\n if (type === gl.HALF_FLOAT) {\n if (format === gl.RGBA) {\n return gl.RGBA16F;\n }\n if (format === gl.RGB) {\n return gl.RGB16F;\n }\n }\n return format;\n}\n"]}
1
+ {"version":3,"file":"texture.js","sourceRoot":"","sources":["../src/texture.ts"],"names":[],"mappings":"AAEA;;;gFAGgF;AAChF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B;2CACuC;IACvC,OAAO,EAAE,CAAC;IACV;4CACwC;IACxC,QAAQ,EAAE,CAAC;IACX;6CACyC;IACzC,SAAS,EAAE,CAAC;CACN,CAAC;AAoJX;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,MAAuB,EAAE,KAAc,EAAE,gBAAyB,EAAE,SAAS,GAAG,CAAC;IAC5G,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;IACrB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC;IAClB,IAAI,CAAC,CAAC,WAAW,KAAK,EAAE,EAAE,CAAC;QACvB,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,mBAAmB,EAAE,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B,CAAC,EAA0B,EAAE,MAAc,EAAE,IAAY;IAC5F,IAAI,IAAI,KAAK,EAAE,CAAC,aAAa,EAAE,CAAC;QAC5B,IAAI,MAAM,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC,KAAK,CAAC;QACpB,CAAC;QACD,IAAI,MAAM,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC,IAAI,CAAC;QACnB,CAAC;QACD,IAAI,MAAM,KAAK,EAAE,CAAC,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC,SAAS,CAAC;QACxB,CAAC;IACL,CAAC;IACD,IAAI,IAAI,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,MAAM,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC,OAAO,CAAC;QACtB,CAAC;QACD,IAAI,MAAM,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC,MAAM,CAAC;QACrB,CAAC;IACL,CAAC;IACD,IAAI,IAAI,KAAK,EAAE,CAAC,UAAU,EAAE,CAAC;QACzB,IAAI,MAAM,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC,OAAO,CAAC;QACtB,CAAC;QACD,IAAI,MAAM,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC,MAAM,CAAC;QACrB,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import type { GLEngineContext } from \"./context.js\";\n\n/** High-level sampling presets, mirroring Babylon's `Texture.*_SAMPLINGMODE`\n * numeric constants. Resolve one to GL min/mag filters with\n * {@link getSamplingModeFilters} (≙ Babylon's `_getSamplingParameters`); only\n * `TRILINEAR` samples the mip chain, and only when the texture has mipmaps. */\nexport const GLSamplingMode = {\n /** Nearest mag; nearest min, even with mipmaps.\n * (`Texture.NEAREST_SAMPLINGMODE`) */\n NEAREST: 1,\n /** Linear mag; linear min, even with mipmaps.\n * (`Texture.BILINEAR_SAMPLINGMODE`) */\n BILINEAR: 2,\n /** Linear mag; linear min (`LINEAR_MIPMAP_LINEAR` with mipmaps).\n * (`Texture.TRILINEAR_SAMPLINGMODE`) */\n TRILINEAR: 3,\n} as const;\n\n/** One of the {@link GLSamplingMode} preset values (`1`, `2` or `3`). */\nexport type GLSamplingMode = (typeof GLSamplingMode)[keyof typeof GLSamplingMode];\n\n/** Creation options shared by EVERY texture factory (`createRawTexture`,\n * `createFloatTexture`, `loadTexture2D`, `createTextureFromSource`,\n * `createDynamicTexture`, `createHtmlElementTexture`,\n * `createTextureFromHandle`). All have GL-spec defaults.\n *\n * Babylon-style sampling presets are opt-in so factories don't ship them:\n * spread {@link getSamplingModeFilters} into the options. Mipmaps are not a\n * creation option either: call {@link generateTextureMipMaps} once, after\n * which every later upload and `webglcontextrestored` replay rebuilds the\n * chain. */\nexport interface GLTextureOptions {\n /** Flip rows vertically on upload. Default: false (matches Babylon's\n * default raw-texture behaviour). For raw / dynamic / HTML-element textures\n * this is the default for every update that omits `invertY`. */\n invertY?: boolean;\n /** Default: gl.LINEAR. See {@link getSamplingModeFilters} for presets. */\n minFilter?: GLenum;\n /** Default: gl.LINEAR. */\n magFilter?: GLenum;\n /** Default: gl.CLAMP_TO_EDGE. May be `gl.REPEAT` / `gl.MIRRORED_REPEAT`\n * (NPOT-safe in WebGL2). */\n wrapS?: GLenum;\n /** Default: gl.CLAMP_TO_EDGE. May be `gl.REPEAT` / `gl.MIRRORED_REPEAT`. */\n wrapT?: GLenum;\n /** `gl.pixelStorei(UNPACK_ALIGNMENT)` for the upload (1/2/4/8). Default 4.\n * Use 1 for tightly-packed non-RGBA rows. */\n unpackAlignment?: number;\n /** Premultiply alpha at upload (`UNPACK_PREMULTIPLY_ALPHA_WEBGL`, or\n * decode-time for `loadTexture2D`). Default false. For raw / dynamic /\n * HTML-element textures this is the default for every update that omits it. */\n premultiplyAlpha?: boolean;\n /** Explicit sized internalFormat for `texImage2D`. When provided it is used\n * verbatim and the inline LDR resolver is bypassed — this is how\n * {@link createFloatTexture} injects its `RGBA16F` / `RGBA32F` choice\n * without the byte path ever referencing the float-format table (keeping it\n * tree-shakeable out of RGBA8-only bundles). Default: derived from\n * `format`/`type` via the LDR resolver. */\n internalFormat?: GLenum;\n}\n\n/** Per-update pixel-store flags shared by `updateRawTexture`,\n * `updateDynamicTexture` and `updateHtmlElementTexture` (≙ lite's\n * `DynamicTextureUpdateOptions`, Babylon's `updateRawTexture(…, invertY)`). Each\n * omitted flag falls back to the texture's creation {@link GLTextureOptions}\n * value; the flags of the latest update are reused on `webglcontextrestored`. */\nexport interface GLTextureUpdateOptions {\n /** Flip rows vertically on upload (`UNPACK_FLIP_Y_WEBGL`). */\n invertY?: boolean;\n /** Premultiply alpha on upload (`UNPACK_PREMULTIPLY_ALPHA_WEBGL`). */\n premultiplyAlpha?: boolean;\n}\n\n/**\n * Pure-state texture handle. The `handle` field is MUTABLE so the same logical\n * texture survives a `webglcontextrestored` event — every consumer keeps the\n * same `GLTexture` reference; only the internal `WebGLTexture` is swapped.\n *\n * `loadTexture2D` also uses the same handle for the 1×1 placeholder upload AND\n * the final image upload — so a `bindTexture(tex, unit)` made before the\n * image has decoded remains valid once the image arrives.\n */\nexport interface GLTexture {\n /** The live `WebGLTexture`. MUTABLE — swapped for a fresh handle on\n * `webglcontextrestored` while consumers keep the same `GLTexture` reference. */\n handle: WebGLTexture;\n /** GL texture target (normally `gl.TEXTURE_2D`); 3D textures use their own API. */\n readonly target: GLenum;\n /** Texture width in texels. Updated once an async upload resolves. */\n width: number;\n /** Texture height in texels. Updated once an async upload resolves. */\n height: number;\n /** True when the texture is safe to sample with final content (placeholders\n * read as not-ready until their image/upload completes). */\n isReady: boolean;\n /** The engine that created (and owns) this texture. Texture operations\n * derive their engine from it, so they take the texture alone. @internal */\n _engine: GLEngineContext;\n /** @internal */\n _disposed: boolean;\n /** @internal */\n _refCount: number;\n /** Replays the latest pixel content into the currently bound texture handle. @internal */\n _upload: (engine: GLEngineContext) => void;\n /** Initializes creation-time sampling state on the bound texture handle. @internal */\n _initializeParameters?: (engine: GLEngineContext) => void;\n /**\n * Snapshot of `isReady` captured on `webglcontextlost` so the restore\n * handler knows whether to flip it back on after `_upload`. Textures\n * that were still mid-load (e.g. `loadTexture2D` whose bitmap hadn't\n * arrived) stay not-ready; the async path will set `isReady=true` once\n * the bitmap finishes decoding into the new handle.\n * @internal\n */\n _wasReady: boolean;\n /**\n * Live re-upload hook installed by `createRawTexture` — lets\n * `updateRawTexture` replace the pixel data (and optionally the size)\n * through the same closure that the context-restore replay uses, keeping\n * restore correct. Absent on image / HTML-element / external textures.\n * @internal\n */\n _updateRaw?: (engine: GLEngineContext, data: ArrayBufferView | null, width: number, height: number, unpackAlignment: number) => void;\n /**\n * Dynamic-texture source captured by `updateDynamicTexture`\n * (`@babylonjs/lite-gl`) and replayed into the fresh handle\n * on `webglcontextrestored`. Null/absent on non-dynamic textures.\n * @internal\n */\n _dynSource?: TexImageSource | null;\n /**\n * `true` for a {@link createTextureFromHandle} wrapper created with\n * `ownsHandle = false`: `disposeTexture` releases the wrapper without\n * deleting the borrowed `WebGLTexture`.\n * @internal\n */\n _borrowed?: boolean;\n /** `invertY` of the latest raw / dynamic / HTML-element update\n * ({@link GLTextureUpdateOptions}), reused by context-restore replay;\n * `undefined` → the texture's creation `invertY`. @internal */\n _invertY?: boolean;\n /** `premultiplyAlpha` of the latest raw / dynamic / HTML-element update\n * ({@link GLTextureUpdateOptions}), reused by context-restore replay;\n * `undefined` → the texture's creation `premultiplyAlpha`. @internal */\n _premultiplyAlpha?: boolean;\n /**\n * The `handle` the dynamic texture's `texParameteri` filter/wrap state was\n * last applied to. `texParameteri` is per-texture GL state that survives pixel\n * re-uploads, so the dynamic-texture `_upload` re-applies it ONLY when this no\n * longer matches `handle` — i.e. at creation and after `webglcontextrestored`\n * installs a fresh handle — not on every per-frame `updateDynamicTexture`.\n * @internal\n */\n _dynParamsHandle?: WebGLTexture | null;\n /**\n * Set by {@link generateTextureMipMaps} (≙ Babylon\n * `InternalTexture.useMipMaps`, and the 3D API's `_hasMipMaps`). The mip\n * intent is retained: `_upload` is wrapped once so every later level-0\n * upload, including `webglcontextrestored` replay, rebuilds the chain.\n * @internal\n */\n _hasMipMaps?: boolean;\n}\n\n/**\n * Apply the three `UNPACK_*` pixel-store flags through the GL-state cache,\n * eliding redundant `pixelStorei` calls. Centralising this guarantees EVERY\n * upload path sets all three explicitly, so a premultiplying / flipping upload\n * never leaks its flag into a later upload that forgot to set it.\n * @internal\n */\nexport function setUnpackState(engine: GLEngineContext, flipY: boolean, premultiplyAlpha: boolean, alignment = 4): void {\n const gl = engine.gl;\n const s = engine._state;\n const fy = +flipY;\n if (s.unpackFlipY !== fy) {\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, fy);\n s.unpackFlipY = fy;\n }\n const pm = +premultiplyAlpha;\n if (s.unpackPremultiplyAlpha !== pm) {\n gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pm);\n s.unpackPremultiplyAlpha = pm;\n }\n if (s.unpackAlignment !== alignment) {\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, alignment);\n s.unpackAlignment = alignment;\n }\n}\n\n/** Apply sampling and wrap state to the texture currently bound for upload. @internal */\nexport function setBoundTextureParams(gl: WebGL2RenderingContext, minFilter: GLenum, magFilter: GLenum, wrapS: GLenum, wrapT: GLenum): void {\n const target = gl.TEXTURE_2D;\n gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, minFilter);\n gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, magFilter);\n gl.texParameteri(target, gl.TEXTURE_WRAP_S, wrapS);\n gl.texParameteri(target, gl.TEXTURE_WRAP_T, wrapT);\n}\n\n/** GL min/mag filters resolved from a {@link GLSamplingMode} preset. Spread\n * into any {@link GLTextureOptions}, or pass to {@link updateTextureSamplingMode}\n * (or use {@link updateTextureSamplingPreset} directly). */\nexport interface GLSamplingFilters {\n /** `TEXTURE_MIN_FILTER` value. */\n minFilter: GLenum;\n /** `TEXTURE_MAG_FILTER` value. */\n magFilter: GLenum;\n}\n\n/**\n * Resolve a Babylon-style sampling preset to GL min/mag filters — the lite-gl\n * counterpart of Babylon's `_getSamplingParameters(samplingMode, generateMipMaps)`.\n * Pure (no GL context needed; WebGL filter enums are spec constants) and\n * tree-shaken unless imported, so preset-free bundles ship none of it.\n *\n * | Preset | min (no mips) | min (mips) | mag |\n * | ----------- | ------------- | ---------------------- | --------- |\n * | `NEAREST` | `NEAREST` | `NEAREST` | `NEAREST` |\n * | `BILINEAR` | `LINEAR` | `LINEAR` | `LINEAR` |\n * | `TRILINEAR` | `LINEAR` | `LINEAR_MIPMAP_LINEAR` | `LINEAR` |\n *\n * Babylon's mipmapped nearest / bilinear variants are separate modes\n * (`NEAREST_LINEAR_MIPNEAREST` …); pass their raw filters instead.\n *\n * @example\n * ```ts\n * const tex = createRawTexture(engine, data, w, h, getSamplingModeFilters(GLSamplingMode.TRILINEAR, true));\n * generateTextureMipMaps(tex); // required by the mipmapped min filter\n * ```\n *\n * @param samplingMode - The {@link GLSamplingMode} preset.\n * @param useMipMaps - Whether the texture has (or will get, via\n * {@link generateTextureMipMaps}) a mip chain. Default false, so the min\n * filter never references a missing chain.\n * @returns The preset's `{ minFilter, magFilter }`.\n */\nexport function getSamplingModeFilters(samplingMode: GLSamplingMode, useMipMaps = false): GLSamplingFilters {\n // WebGL filter enums: NEAREST 0x2600, LINEAR 0x2601, LINEAR_MIPMAP_LINEAR 0x2703.\n const magFilter = samplingMode === GLSamplingMode.NEAREST ? 0x2600 : 0x2601;\n return { minFilter: useMipMaps && samplingMode === GLSamplingMode.TRILINEAR ? 0x2703 : magFilter, magFilter };\n}\n\n/** Size-bearing fields across the `TexImageSource` variants. @internal */\ninterface TexImageSourceSize {\n width?: number;\n height?: number;\n videoWidth?: number;\n videoHeight?: number;\n naturalWidth?: number;\n naturalHeight?: number;\n displayWidth?: number;\n displayHeight?: number;\n}\n\n/** Write the pixel size of a `TexImageSource` as `texImage2D` will upload it\n * into `tex.width` / `tex.height`: the intrinsic size for video\n * (`videoWidth`), image (`naturalWidth`) and `VideoFrame` (`displayWidth`)\n * sources, `width`/`height` otherwise. Clamped to ≥ 1. Allocation-free — it\n * runs on every dynamic / HTML-element re-upload. @internal */\nexport function setTexImageSourceSize(tex: GLTexture, source: TexImageSourceSize): void {\n tex.width = (source.videoWidth ?? source.naturalWidth ?? source.displayWidth ?? source.width) || 1;\n tex.height = (source.videoHeight ?? source.naturalHeight ?? source.displayHeight ?? source.height) || 1;\n}\n\n/** Options for {@link createRawTexture}: the shared {@link GLTextureOptions}\n * plus the pixel `format` / `type` of `data`. */\nexport interface GLRawTextureOptions extends GLTextureOptions {\n /** Pixel format of `data` (`gl.RGBA`, `gl.RGB`, `gl.RG`, `gl.RED`,\n * `gl.LUMINANCE`…). Default `gl.RGBA`. */\n format?: GLenum;\n /** Pixel type of `data`. Default `gl.UNSIGNED_BYTE`. For float data, prefer\n * {@link createFloatTexture}, which also picks the sized float internalFormat. */\n type?: GLenum;\n}\n\n/**\n * Create a raw texture from a typed array (or an uninitialised allocation).\n * RGBA8 by default; set {@link GLRawTextureOptions.format} / `type` for other\n * layouts. The pixel data can be replaced later via {@link updateRawTexture};\n * the sampling and wrap can be changed via {@link updateTextureSamplingMode} /\n * {@link updateTextureWrapMode}. Upload data is retained by reference for\n * automatic recovery unless the engine is host-owned (`createHostOwnedGLEngine`).\n *\n * @param engine - The engine.\n * @param data - Initial pixels matching `format` / `type`, or `null` for an\n * uninitialised allocation.\n * @param width - Texture width in texels.\n * @param height - Texture height in texels.\n * @param options - See {@link GLRawTextureOptions}.\n * @returns The new {@link GLTexture}.\n */\nexport function createRawTexture(engine: GLEngineContext, data: ArrayBufferView | null, width: number, height: number, options?: GLRawTextureOptions): GLTexture {\n const gl = engine.gl;\n const handle = gl.createTexture();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createTexture returned null\");\n }\n const opts = options ?? {};\n const format = opts.format ?? gl.RGBA;\n const type = opts.type ?? gl.UNSIGNED_BYTE;\n const minFilter = opts.minFilter ?? gl.LINEAR;\n const magFilter = opts.magFilter ?? gl.LINEAR;\n const wrapS = opts.wrapS ?? gl.CLAMP_TO_EDGE;\n const wrapT = opts.wrapT ?? gl.CLAMP_TO_EDGE;\n const invertY = opts.invertY ?? false;\n const premultiply = opts.premultiplyAlpha ?? false;\n // LDR byte formats are resolved INLINE here; the float-format table in\n // `pickSizedInternalFormat` is deliberately NOT referenced from this path so\n // it tree-shakes out of byte-only bundles. `createFloatTexture` injects its\n // sized float format via `opts.internalFormat`.\n const internalFormat = opts.internalFormat ?? resolveLdrInternalFormat(gl, format, type);\n\n // Mutable upload state — `updateRawTexture` mutates these and re-runs\n // `upload`, so the context-restore replay (which calls the same `upload`)\n // always reproduces the latest contents. The replayed dimensions stay\n // paired with the replayed pixels: `tex.width` / `height` may run ahead of\n // them (a render-target resize during loss, applied by its restore).\n let curData = data;\n let curWidth = width;\n let curHeight = height;\n let curAlign = opts.unpackAlignment ?? 4;\n\n const upload = (target: GLEngineContext, pixels = curData, w = curWidth, h = curHeight, alignment = curAlign): void => {\n curData = target._noRestore ? null : pixels;\n curWidth = w;\n curHeight = h;\n curAlign = alignment;\n tex.width = w;\n tex.height = h;\n const g = target.gl;\n setUnpackState(target, tex._invertY ?? invertY, tex._premultiplyAlpha ?? premultiply, alignment);\n bindTextureForUpload(target, tex.handle);\n g.texImage2D(g.TEXTURE_2D, 0, internalFormat, w, h, 0, format, type, pixels);\n };\n\n const initializeParameters = (target: GLEngineContext): void => {\n setBoundTextureParams(target.gl, minFilter, magFilter, wrapS, wrapT);\n };\n\n const tex: GLTexture = {\n handle,\n target: gl.TEXTURE_2D,\n width,\n height,\n isReady: true,\n _engine: engine,\n _disposed: false,\n _refCount: 1,\n _upload: upload,\n _updateRaw: upload,\n _initializeParameters: initializeParameters,\n _wasReady: true,\n };\n upload(engine);\n initializeParameters(engine);\n engine._textures.add(tex);\n return tex;\n}\n\n/** Options for {@link createFloatTexture} — the shared {@link GLTextureOptions}\n * plus the float-specific `type` / `format`. */\nexport interface GLFloatTextureOptions extends GLTextureOptions {\n /** Float texel type — `gl.HALF_FLOAT` (default) or `gl.FLOAT`. */\n type?: GLenum;\n /** Color format. Default `gl.RGBA`. */\n format?: GLenum;\n}\n\n/**\n * Create a float / half-float raw texture — the HDR counterpart of\n * {@link createRawTexture}. This is the ONLY texture factory that carries the\n * `RGBA16F` / `RGBA32F` sized-format knowledge (via {@link pickSizedInternalFormat}),\n * so byte-only consumers calling {@link createRawTexture} ship none of it.\n * Defaults to `gl.HALF_FLOAT`; pass `options.type = gl.FLOAT` for full 32-bit.\n * The caller is responsible for the matching engine cap (e.g.\n * `caps.textureFloatLinearFiltering`) when sampling these with `LINEAR`.\n *\n * @param engine - The engine.\n * @param data - Initial pixels (`Float32Array` for FLOAT, `Uint16Array` for\n * HALF_FLOAT), or `null` for an uninitialised allocation.\n * @param width - Texture width in texels (≥ 1).\n * @param height - Texture height in texels (≥ 1).\n * @param options - See {@link GLFloatTextureOptions}.\n * @returns The new {@link GLTexture}.\n */\nexport function createFloatTexture(engine: GLEngineContext, data: ArrayBufferView | null, width: number, height: number, options?: GLFloatTextureOptions): GLTexture {\n const gl = engine.gl;\n const o = options ?? {};\n const format = o.format ?? gl.RGBA;\n const type = o.type ?? gl.HALF_FLOAT;\n // Precompute the sized float internalFormat HERE and pass it through, so\n // `createRawTexture`'s inline LDR resolver is bypassed and the float table\n // stays out of byte-only bundles.\n const internalFormat = pickSizedInternalFormat(gl, format, type);\n return createRawTexture(engine, data, width, height, { ...o, format, type, internalFormat });\n}\n\n/**\n * Generate the mip chain for a texture from its level-0 contents and keep it\n * current (≙ Babylon's `useMipMaps` / lite-gl's `generateTexture3DMipMaps`).\n * The intent is retained: every later level-0 upload — `updateRawTexture`,\n * `updateDynamicTexture`, `updateHtmlElementTexture`, the `loadTexture2D` image\n * arrival and `webglcontextrestored` replay — rebuilds the chain, so a\n * mipmapped min filter never samples an incomplete texture. Only bundles that\n * call it pay for mipmapping. Calling it again just regenerates now.\n *\n * Binds for upload (unit 0). The format must be filterable (float textures need\n * the matching linear-filtering cap). Render targets use\n * `generateRenderTargetMipMaps` instead. No-op on a lost/disposed context or a\n * disposed texture.\n *\n * @param tex - The texture whose mip chain to generate.\n */\nexport function generateTextureMipMaps(tex: GLTexture): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed || tex.handle === null) {\n return;\n }\n bindTextureForUpload(engine, tex.handle);\n engine.gl.generateMipmap(engine.gl.TEXTURE_2D);\n if (!tex._hasMipMaps) {\n tex._hasMipMaps = true;\n // Every `_upload` that runs (update / restore-registry replay) leaves\n // this texture bound for upload; handle/RT textures are never replayed.\n const upload = tex._upload;\n tex._upload = (target: GLEngineContext): void => {\n upload(target);\n target.gl.generateMipmap(target.gl.TEXTURE_2D);\n };\n }\n}\n\n/**\n * Re-upload the pixel data (and optionally resize) of a texture created by\n * {@link createRawTexture} — the lite-gl equivalent of Babylon's\n * `updateRawTexture` / `_uploadDataToTextureDirectly`. Goes through the same\n * upload closure used by context-restore, so the new contents survive a context\n * loss, and rebuilds the mip chain after {@link generateTextureMipMaps}. No-op\n * on a lost/disposed/non-raw texture.\n *\n * @param tex - The raw texture to update.\n * @param data - New pixel data (must match the original `format`/`type`).\n * @param options - Optional new `width`/`height` (default: unchanged),\n * `unpackAlignment` (default 4) and `invertY` / `premultiplyAlpha` (default:\n * the creation values; ≙ Babylon's `updateRawTexture(…, invertY)`). The flags\n * are reused by context-restore replay.\n */\nexport function updateRawTexture(\n tex: GLTexture,\n data: ArrayBufferView | null,\n options?: GLTextureUpdateOptions & { width?: number; height?: number; unpackAlignment?: number }\n): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed || tex._updateRaw === undefined) {\n return;\n }\n const o = options ?? {};\n tex._invertY = o.invertY;\n tex._premultiplyAlpha = o.premultiplyAlpha;\n tex._updateRaw(engine, data, o.width ?? tex.width, o.height ?? tex.height, o.unpackAlignment ?? 4);\n if (tex._hasMipMaps) {\n // `_updateRaw` leaves the texture bound for upload (unit 0).\n engine.gl.generateMipmap(engine.gl.TEXTURE_2D);\n }\n}\n\n/**\n * Update a texture's raw GL min/mag sampling filters (e.g. `gl.NEAREST`,\n * `gl.LINEAR_MIPMAP_LINEAR`). A mipmapped min filter needs\n * {@link generateTextureMipMaps}; for Babylon-style presets use\n * {@link updateTextureSamplingPreset}. Binds for upload (unit 0) so the\n * `texParameteri` lands on this texture. The change is not replayed on\n * `webglcontextrestored` (creation options are). No-op on a lost/disposed\n * context or a disposed texture.\n *\n * @param tex - The texture to update.\n * @param minFilter - `TEXTURE_MIN_FILTER` value.\n * @param magFilter - `TEXTURE_MAG_FILTER` value.\n */\nexport function updateTextureSamplingMode(tex: GLTexture, minFilter: GLenum, magFilter: GLenum): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed) {\n return;\n }\n const gl = engine.gl;\n bindTextureForUpload(engine, tex.handle);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);\n}\n\n/**\n * Update a texture's sampling mode from a Babylon-style preset — the lite-gl\n * equivalent of Babylon's\n * `updateTextureSamplingMode(samplingMode, texture, generateMipMaps)`. The\n * filters come from {@link getSamplingModeFilters}, using the mipmapped\n * `TRILINEAR` min filter when the texture already has mipmaps (from\n * {@link generateTextureMipMaps}) or `generateMipMaps` is true. Like Babylon,\n * `generateMipMaps` only generates (and retains) the chain for `TRILINEAR`,\n * right after the filters are set; `NEAREST` / `BILINEAR` never sample mips.\n * Unlike Babylon, an existing chain is not regenerated (lite-gl already\n * rebuilds it on every upload); call {@link generateTextureMipMaps} to force it.\n *\n * Kept separate from the raw {@link updateTextureSamplingMode} so raw-filter\n * callers don't bundle the preset and mipmap code. Same binding, replay and\n * lost/disposed behavior.\n *\n * @param tex - The texture to update.\n * @param samplingMode - The {@link GLSamplingMode} preset.\n * @param generateMipMaps - Generate the mip chain now (`TRILINEAR` only). Default false.\n */\nexport function updateTextureSamplingPreset(tex: GLTexture, samplingMode: GLSamplingMode, generateMipMaps?: boolean): void {\n // ≙ Babylon: mips are generated only for a mipmapped preset (`TRILINEAR`).\n const generate = generateMipMaps === true && samplingMode === GLSamplingMode.TRILINEAR;\n const filters = getSamplingModeFilters(samplingMode, generate || tex._hasMipMaps === true);\n updateTextureSamplingMode(tex, filters.minFilter, filters.magFilter);\n // An existing chain is already rebuilt on every upload; call\n // `generateTextureMipMaps` directly to force a regeneration.\n if (generate && !tex._hasMipMaps) {\n generateTextureMipMaps(tex);\n }\n}\n\n/**\n * Whether a texture holds its final content and can be sampled — the function\n * form of {@link GLTexture.isReady}, mirroring `isEffectReady(effect)`\n * (≙ Babylon's `texture.isReady()`). False while `loadTexture2D` is still\n * decoding (the 1×1 placeholder is bound meanwhile), after disposal, and while\n * the context is lost/disposed.\n *\n * @param tex - The texture to query.\n * @returns `true` when the texture is ready to sample.\n */\nexport function isTextureReady(tex: GLTexture): boolean {\n const engine = tex._engine;\n return tex.isReady && !tex._disposed && !engine._isLost && !engine._disposed;\n}\n\n/** Update a texture's S/T wrap modes (`gl.CLAMP_TO_EDGE` / `gl.REPEAT` /\n * `gl.MIRRORED_REPEAT`) — the lite-gl equivalent of Babylon's\n * `updateTextureWrappingMode`. No-op on a lost/disposed context. */\nexport function updateTextureWrapMode(tex: GLTexture, wrapS: GLenum, wrapT: GLenum): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed) {\n return;\n }\n const gl = engine.gl;\n bindTextureForUpload(engine, tex.handle);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);\n}\n\n/**\n * Wrap an existing raw `WebGLTexture` (e.g. one created by a host renderer or a\n * previous engine) as a {@link GLTexture}.\n *\n * The wrapper does NOT own the underlying handle's upload — it is NOT registered\n * for context-restore replay (the external owner is responsible for that) and is\n * marked ready immediately. By default `disposeTexture` still `gl.deleteTexture`s\n * the handle; pass `ownsHandle = false` to BORROW a handle the host keeps\n * owning (e.g. a texture shared with another renderer), so disposal only\n * releases the wrapper and its cached bindings.\n *\n * @param engine - The engine.\n * @param handle - The external `WebGLTexture`.\n * @param width - Texture width in texels.\n * @param height - Texture height in texels.\n * @param options - Optional sampling state to apply once (min/mag/wrapS/wrapT).\n * Upload-only options (`invertY`, `premultiplyAlpha`, `unpackAlignment`,\n * `internalFormat`) do not apply — the handle's pixels are owned externally.\n * @param ownsHandle - When `false`, `disposeTexture` never deletes `handle`. Default `true`.\n * @returns A {@link GLTexture} wrapping the handle.\n */\nexport function createTextureFromHandle(engine: GLEngineContext, handle: WebGLTexture, width: number, height: number, options?: GLTextureOptions, ownsHandle = true): GLTexture {\n const tex: GLTexture = {\n handle,\n target: engine.gl.TEXTURE_2D,\n width,\n height,\n isReady: true,\n _engine: engine,\n _disposed: false,\n _refCount: 1,\n // External handle — restore replay is the external owner's job.\n _upload: () => {},\n _wasReady: true,\n };\n if (!ownsHandle) {\n tex._borrowed = true;\n }\n if (options !== undefined) {\n const gl = engine.gl;\n bindTextureForUpload(engine, handle);\n setBoundTextureParams(gl, options.minFilter ?? gl.LINEAR, options.magFilter ?? gl.LINEAR, options.wrapS ?? gl.CLAMP_TO_EDGE, options.wrapT ?? gl.CLAMP_TO_EDGE);\n }\n return tex;\n}\n\n/** Asynchronous image upload.The returned texture is immediately usable (1×1\n * transparent placeholder); `isReady` flips true once the image has been\n * decoded and uploaded. The decoded `ImageBitmap` is retained on the texture\n * for offline-safe `webglcontextrestored` replay by default; on a host-owned\n * engine (`createHostOwnedGLEngine`), it is closed/released after the upload,\n * and a decode finishing while that engine is lost closes the bitmap and\n * reports a context-loss error through `onError` instead of `onLoad`, even when\n * the host already disposed the texture (e.g. from `onContextLost`). Otherwise,\n * disposing the texture before its decode finishes cancels the load silently. `invertY` and\n * `premultiplyAlpha` are applied at decode time (`createImageBitmap`'s\n * `imageOrientation` / `premultiplyAlpha`) because the `UNPACK_*` flags are\n * ignored for `ImageBitmap` sources. */\nexport function loadTexture2D(engine: GLEngineContext, url: string, options?: GLTextureOptions, onLoad?: (tex: GLTexture) => void, onError?: (err: Error) => void): GLTexture {\n const gl = engine.gl;\n const handle = gl.createTexture();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createTexture returned null\");\n }\n const opts = options ?? {};\n const minFilter = opts.minFilter ?? gl.LINEAR;\n const magFilter = opts.magFilter ?? gl.LINEAR;\n const wrapS = opts.wrapS ?? gl.CLAMP_TO_EDGE;\n const wrapT = opts.wrapT ?? gl.CLAMP_TO_EDGE;\n const invertY = opts.invertY ?? false;\n const premultiplyAlpha = opts.premultiplyAlpha ?? false;\n\n let bitmap: ImageBitmap | null = null;\n\n const upload = (target: GLEngineContext): void => {\n const g = target.gl;\n // invertY / premultiplyAlpha are applied at decode time via createImageBitmap\n // because UNPACK_FLIP_Y_WEBGL / UNPACK_PREMULTIPLY_ALPHA_WEBGL are IGNORED for\n // ImageBitmap sources (and the transparent 1×1 placeholder is invariant to\n // both), so keep flip + premultiply off here.\n setUnpackState(target, false, false);\n bindTextureForUpload(target, tex.handle);\n if (bitmap !== null) {\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, bitmap);\n tex.width = bitmap.width;\n tex.height = bitmap.height;\n } else {\n // null leaves WebGL2's zero-initialized texel: transparent black.\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, 1, 1, 0, g.RGBA, g.UNSIGNED_BYTE, null);\n }\n };\n\n const initializeParameters = (target: GLEngineContext): void => {\n setBoundTextureParams(target.gl, minFilter, magFilter, wrapS, wrapT);\n };\n\n const tex: GLTexture = {\n handle,\n target: gl.TEXTURE_2D,\n width: 1,\n height: 1,\n isReady: false,\n _engine: engine,\n _disposed: false,\n _refCount: 1,\n _upload: upload,\n _initializeParameters: initializeParameters,\n _wasReady: false,\n };\n // Placeholder upload — makes the texture sampleable before the real image arrives.\n upload(engine);\n initializeParameters(engine);\n engine._textures.add(tex);\n\n // Fetch + decode the real image. Re-uploads via the same closure once the\n // bitmap is in hand (so context-restore replay sees the real image too).\n fetch(url)\n .then((r) => {\n if (!r.ok) {\n throw new Error(`lite-gl: fetch ${url} -> HTTP ${r.status}`);\n }\n return r.blob();\n })\n .then((blob) => createImageBitmap(blob, { premultiplyAlpha: premultiplyAlpha ? \"premultiply\" : \"none\", imageOrientation: invertY ? \"flipY\" : \"none\" }))\n .then((bm) => {\n // An opted-out host recreates its resources after a loss, so a load\n // finishing during loss fails — even if the host already disposed\n // the texture — and a callback-wrapping Promise always settles.\n if (engine._noRestore && engine._isLost) {\n bm.close();\n throw new Error(`lite-gl: context lost while loading ${url}`);\n }\n if (tex._disposed) {\n bm.close();\n return;\n }\n bitmap = bm;\n // Default recovery defers an in-flight image until restore.\n if (!engine._isLost) {\n // Through `tex._upload` so a retained mip chain is rebuilt.\n tex._upload(engine);\n tex.isReady = true;\n }\n // An opted-out host releases the bitmap once uploaded.\n if (engine._noRestore) {\n bitmap = null;\n bm.close();\n }\n tex._wasReady = true;\n if (onLoad !== undefined) {\n onLoad(tex);\n }\n })\n .catch((err: unknown) => {\n const e = err instanceof Error ? err : new Error(String(err));\n if (onError !== undefined) {\n onError(e);\n } else {\n console.error(\"lite-gl: loadTexture2D failed\", e);\n }\n });\n\n return tex;\n}\n\n/** Cached bind of `tex` on sampler `unit`. Skips `gl.activeTexture` and/or\n * `gl.bindTexture` when nothing changes. No-op when `tex._disposed` or the\n * context is lost/disposed. Use {@link unbindTexture} to clear a unit. */\nexport function bindTexture(tex: GLTexture, unit: number): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed) {\n return;\n }\n bindTextureRaw(engine, unit, tex.handle);\n}\n\n/** Unbind `TEXTURE_2D` on sampler `unit` (cached, like {@link bindTexture}).\n * No-op on a lost/disposed context. */\nexport function unbindTexture(engine: GLEngineContext, unit: number): void {\n if (engine._isLost || engine._disposed) {\n return;\n }\n bindTextureRaw(engine, unit, null);\n}\n\n/** @internal — for callers that already hold a raw `WebGLTexture`. Not part of\n * the public API: `bindTexture` (public) and the texture `_upload` closures bind\n * through the cache, so consumers never call this directly. */\nexport function bindTextureRaw(engine: GLEngineContext, unit: number, handle: WebGLTexture | null): void {\n const s = engine._state;\n const gl = engine.gl;\n if (s.boundTextures[unit] === handle) {\n return;\n }\n if (s.activeTextureUnit !== unit) {\n gl.activeTexture(gl.TEXTURE0 + unit);\n s.activeTextureUnit = unit;\n }\n gl.bindTexture(gl.TEXTURE_2D, handle);\n s.boundTextures[unit] = handle;\n}\n\n/** @internal Bind `handle` on texture unit 0 **for an upload** (`texImage2D`).\n * Unlike {@link bindTextureRaw} — which elides the entire bind when the handle is\n * already bound on the unit (correct for *sampling*, where the active unit is\n * irrelevant) — an upload writes into the texture on the ACTIVE unit. A prior\n * multi-sampler draw may have left a non-zero unit active while this handle is\n * still bound on unit 0, so we must force unit 0 active even on a bind cache-hit,\n * keeping the `_state` cache coherent. */\nexport function bindTextureForUpload(engine: GLEngineContext, handle: WebGLTexture): void {\n const s = engine._state;\n const gl = engine.gl;\n if (s.activeTextureUnit !== 0) {\n gl.activeTexture(gl.TEXTURE0);\n s.activeTextureUnit = 0;\n }\n if (s.boundTextures[0] !== handle) {\n gl.bindTexture(gl.TEXTURE_2D, handle);\n s.boundTextures[0] = handle;\n }\n}\n\n/** Disposes the texture. Walks `_state.boundTextures` and clears every slot\n * that still references the handle — otherwise a later `bindTexture(unit, B)`\n * to the same unit would be wrongly elided when slot still showed handle A.\n * Deregistration is expected O(1), independent of the live texture count.\n * Shared references keep the texture registered until its final release;\n * repeated disposal is a no-op. Unregistered wrappers keep their existing\n * handle-deletion semantics without affecting the live registry; borrowed\n * wrappers (`createTextureFromHandle(…, ownsHandle = false)`) never delete\n * their handle. */\nexport function disposeTexture(tex: GLTexture): void {\n if (tex._disposed) {\n return;\n }\n const engine = tex._engine;\n if (tex._refCount > 1) {\n tex._refCount--;\n return;\n }\n tex._disposed = true;\n engine._textures.delete(tex);\n if (!tex._borrowed && !engine._isLost && !engine._disposed) {\n engine.gl.deleteTexture(tex.handle);\n }\n const bound = engine._state.boundTextures;\n for (let u = 0; u < bound.length; u++) {\n if (bound[u] === tex.handle) {\n // A deleted handle leaves the unit unbound; a borrowed one is still\n // bound in GL, so the slot becomes unknown and the next unbind is issued.\n bound[u] = tex._borrowed ? undefined : null;\n }\n }\n}\n\n/** Internal — resolve the sized internalFormat for the LDR (byte) `texImage2D`\n * paths ONLY: RGBA→RGBA8, RGB→RGB8, RG→RG8, RED→R8, LUMINANCE passthrough.\n * Deliberately knows nothing about FLOAT / HALF_FLOAT so the float-format table\n * in {@link pickSizedInternalFormat} tree-shakes out of byte-only bundles.\n * Shared with the render-target module (which validates the format first).\n * @internal */\nexport function resolveLdrInternalFormat(gl: WebGL2RenderingContext, format: GLenum, type: GLenum): GLenum {\n if (type === gl.UNSIGNED_BYTE) {\n if (format === gl.RGBA) {\n return gl.RGBA8;\n }\n if (format === gl.RGB) {\n return gl.RGB8;\n }\n if (format === gl.RG) {\n return gl.RG8;\n }\n if (format === gl.RED) {\n return gl.R8;\n }\n if (format === gl.LUMINANCE) {\n return gl.LUMINANCE;\n }\n }\n return format;\n}\n\n/** Internal — pick a sized internalFormat for `texImage2D`. WebGL2 prefers\n * sized formats for non-color-renderable / non-readback paths; for the\n * sample-only use cases the unsized format works too, but sized\n * is more portable. Shared with the render-target module.\n * @internal */\nexport function pickSizedInternalFormat(gl: WebGL2RenderingContext, format: GLenum, type: GLenum): GLenum {\n if (type === gl.UNSIGNED_BYTE) {\n if (format === gl.RGBA) {\n return gl.RGBA8;\n }\n if (format === gl.RGB) {\n return gl.RGB8;\n }\n if (format === gl.LUMINANCE) {\n return gl.LUMINANCE;\n }\n }\n if (type === gl.FLOAT) {\n if (format === gl.RGBA) {\n return gl.RGBA32F;\n }\n if (format === gl.RGB) {\n return gl.RGB32F;\n }\n }\n if (type === gl.HALF_FLOAT) {\n if (format === gl.RGBA) {\n return gl.RGBA16F;\n }\n if (format === gl.RGB) {\n return gl.RGB16F;\n }\n }\n return format;\n}\n"]}
package/web-family.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { GLBlendMode, GLBlendState } from "./blend.js";
2
- import type { GLEngineContext, createGLEngine, disposeGLEngine, getRenderingCanvas } from "./context.js";
2
+ import type { GLEngineContext, createGLEngine, createHostOwnedGLEngine, disposeGLEngine, getRenderingCanvas } from "./context.js";
3
3
  import type { GLDepthState, GLStencilOpState, GLStencilState } from "./depth-stencil.js";
4
4
  import type { clearDynamicTextureSource, updateDynamicTexture } from "./dynamic-texture.js";
5
5
  import type { GLEffect } from "./effect.js";
@@ -75,6 +75,7 @@ export interface WebGLFamily extends GLFamily {
75
75
  /** WebGL2 operations that create or destroy an engine or exchange data with browser or WebGL objects. */
76
76
  export interface WebGLHostOps {
77
77
  readonly createGLEngine: typeof createGLEngine;
78
+ readonly createHostOwnedGLEngine: typeof createHostOwnedGLEngine;
78
79
  readonly disposeGLEngine: typeof disposeGLEngine;
79
80
  readonly getRenderingCanvas: typeof getRenderingCanvas;
80
81
  readonly createTextureFromHandle: typeof createTextureFromHandle;
package/web-family.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"web-family.js","sourceRoot":"","sources":["../src/web-family.ts"],"names":[],"mappings":"","sourcesContent":["import type { GLBlendMode, GLBlendState } from \"./blend.js\";\nimport type { GLEngineContext, createGLEngine, disposeGLEngine, getRenderingCanvas } from \"./context.js\";\nimport type { GLDepthState, GLStencilOpState, GLStencilState } from \"./depth-stencil.js\";\nimport type { clearDynamicTextureSource, updateDynamicTexture } from \"./dynamic-texture.js\";\nimport type { GLEffect } from \"./effect.js\";\nimport type { GLEffectWaitOptions } from \"./effect-ready.js\";\nimport type { GLEffectWrapper, GLEffectWrapperOptions } from \"./effect-renderer.js\";\nimport type { GLFamily } from \"./family.js\";\nimport type { GLPerfCounter } from \"./gpu-frame-time.js\";\nimport type { createHtmlElementTexture, updateHtmlElementTexture } from \"./html-texture.js\";\nimport type { GLAttributeDescriptor, GLIndexBuffer, GLMeshVao, GLVertexBuffer } from \"./mesh.js\";\nimport type { GLFloatRenderTargetOptions, GLReadPixelsOptions, GLRenderTarget, GLRenderTargetOptions, readRenderTargetPixelsToBuffer } from \"./render-target.js\";\nimport type { GLSprite, GLSpriteRenderer, GLSpriteRendererOptions } from \"./sprites.js\";\nimport type { GLDefaultTextData } from \"./text/default-text-data.js\";\nimport type { GLFont } from \"./text/font.js\";\nimport type { GLGlyphCurves, GLGlyphStorage, GLQuadCurve } from \"./text/glyph-storage.js\";\nimport type { GLTextLayoutOptions } from \"./text/layout.js\";\nimport type { GLGlyphRun, GLTextData, GLTextDataUpdate } from \"./text/text-data.js\";\nimport type { GLTextLayer, GLTextLayerOptions, GLTextRenderer, GLTextRendererOptions } from \"./text/text-renderer.js\";\nimport type {\n GLFloatTextureOptions,\n GLRawTextureOptions,\n GLSamplingFilters,\n GLSamplingMode,\n GLTexture,\n GLTextureOptions,\n GLTextureUpdateOptions,\n createTextureFromHandle,\n} from \"./texture.js\";\nimport type { GLPixelsTexture3DOptions, GLTexture3D } from \"./texture-3d.js\";\nimport type { createTextureFromSource } from \"./texture-source.js\";\n\n/** The WebGL2 backend's types for the backend-neutral contract. */\nexport interface WebGLFamily extends GLFamily {\n readonly engine: GLEngineContext;\n readonly effect: GLEffect;\n readonly effectWrapper: GLEffectWrapper;\n readonly texture: GLTexture;\n readonly texture3D: GLTexture3D;\n readonly renderTarget: GLRenderTarget;\n readonly vertexBuffer: GLVertexBuffer;\n readonly indexBuffer: GLIndexBuffer;\n readonly meshVao: GLMeshVao;\n readonly spriteRenderer: GLSpriteRenderer;\n readonly font: GLFont;\n readonly glyphStorage: GLGlyphStorage;\n readonly textData: GLTextData;\n readonly defaultTextData: GLDefaultTextData;\n readonly textLayer: GLTextLayer;\n readonly textRenderer: GLTextRenderer;\n readonly perfCounter: GLPerfCounter;\n readonly noTexture: null;\n readonly instanceCount: number;\n readonly vertexBufferArgs: [dynamic?: boolean];\n readonly floatArray: Float32Array | number[];\n readonly rawTextureData: ArrayBufferView | null;\n readonly rawTextureOptions: GLRawTextureOptions;\n readonly textureOptions: GLTextureOptions;\n readonly renderTargetOptions: GLRenderTargetOptions;\n readonly attributeDescriptor: GLAttributeDescriptor;\n readonly blendMode: GLBlendMode;\n readonly effectWaitOptions: GLEffectWaitOptions;\n readonly effectWrapperOptions: GLEffectWrapperOptions;\n readonly textureUpdateOptions: GLTextureUpdateOptions;\n readonly floatTextureOptions: GLFloatTextureOptions;\n readonly samplingMode: GLSamplingMode;\n readonly samplingFilters: GLSamplingFilters;\n readonly texture3DOptions: GLPixelsTexture3DOptions;\n readonly floatRenderTargetOptions: GLFloatRenderTargetOptions;\n readonly readPixelsOptions: GLReadPixelsOptions;\n readonly blendState: GLBlendState;\n readonly depthState: GLDepthState;\n readonly stencilState: GLStencilState;\n readonly stencilOpState: GLStencilOpState;\n readonly spriteRendererOptions: GLSpriteRendererOptions;\n readonly sprite: GLSprite;\n readonly glyphCurves: GLGlyphCurves;\n readonly quadCurve: GLQuadCurve;\n readonly glyphRun: GLGlyphRun;\n readonly textDataUpdate: GLTextDataUpdate;\n readonly textLayoutOptions: GLTextLayoutOptions;\n readonly textLayerOptions: GLTextLayerOptions;\n readonly textRendererOptions: GLTextRendererOptions;\n}\n\n/** WebGL2 operations that create or destroy an engine or exchange data with browser or WebGL objects. */\nexport interface WebGLHostOps {\n readonly createGLEngine: typeof createGLEngine;\n readonly disposeGLEngine: typeof disposeGLEngine;\n readonly getRenderingCanvas: typeof getRenderingCanvas;\n readonly createTextureFromHandle: typeof createTextureFromHandle;\n readonly createTextureFromSource: typeof createTextureFromSource;\n readonly updateDynamicTexture: typeof updateDynamicTexture;\n readonly clearDynamicTextureSource: typeof clearDynamicTextureSource;\n readonly createHtmlElementTexture: typeof createHtmlElementTexture;\n readonly updateHtmlElementTexture: typeof updateHtmlElementTexture;\n readonly readRenderTargetPixelsToBuffer: typeof readRenderTargetPixelsToBuffer;\n}\n"]}
1
+ {"version":3,"file":"web-family.js","sourceRoot":"","sources":["../src/web-family.ts"],"names":[],"mappings":"","sourcesContent":["import type { GLBlendMode, GLBlendState } from \"./blend.js\";\nimport type { GLEngineContext, createGLEngine, createHostOwnedGLEngine, disposeGLEngine, getRenderingCanvas } from \"./context.js\";\nimport type { GLDepthState, GLStencilOpState, GLStencilState } from \"./depth-stencil.js\";\nimport type { clearDynamicTextureSource, updateDynamicTexture } from \"./dynamic-texture.js\";\nimport type { GLEffect } from \"./effect.js\";\nimport type { GLEffectWaitOptions } from \"./effect-ready.js\";\nimport type { GLEffectWrapper, GLEffectWrapperOptions } from \"./effect-renderer.js\";\nimport type { GLFamily } from \"./family.js\";\nimport type { GLPerfCounter } from \"./gpu-frame-time.js\";\nimport type { createHtmlElementTexture, updateHtmlElementTexture } from \"./html-texture.js\";\nimport type { GLAttributeDescriptor, GLIndexBuffer, GLMeshVao, GLVertexBuffer } from \"./mesh.js\";\nimport type { GLFloatRenderTargetOptions, GLReadPixelsOptions, GLRenderTarget, GLRenderTargetOptions, readRenderTargetPixelsToBuffer } from \"./render-target.js\";\nimport type { GLSprite, GLSpriteRenderer, GLSpriteRendererOptions } from \"./sprites.js\";\nimport type { GLDefaultTextData } from \"./text/default-text-data.js\";\nimport type { GLFont } from \"./text/font.js\";\nimport type { GLGlyphCurves, GLGlyphStorage, GLQuadCurve } from \"./text/glyph-storage.js\";\nimport type { GLTextLayoutOptions } from \"./text/layout.js\";\nimport type { GLGlyphRun, GLTextData, GLTextDataUpdate } from \"./text/text-data.js\";\nimport type { GLTextLayer, GLTextLayerOptions, GLTextRenderer, GLTextRendererOptions } from \"./text/text-renderer.js\";\nimport type {\n GLFloatTextureOptions,\n GLRawTextureOptions,\n GLSamplingFilters,\n GLSamplingMode,\n GLTexture,\n GLTextureOptions,\n GLTextureUpdateOptions,\n createTextureFromHandle,\n} from \"./texture.js\";\nimport type { GLPixelsTexture3DOptions, GLTexture3D } from \"./texture-3d.js\";\nimport type { createTextureFromSource } from \"./texture-source.js\";\n\n/** The WebGL2 backend's types for the backend-neutral contract. */\nexport interface WebGLFamily extends GLFamily {\n readonly engine: GLEngineContext;\n readonly effect: GLEffect;\n readonly effectWrapper: GLEffectWrapper;\n readonly texture: GLTexture;\n readonly texture3D: GLTexture3D;\n readonly renderTarget: GLRenderTarget;\n readonly vertexBuffer: GLVertexBuffer;\n readonly indexBuffer: GLIndexBuffer;\n readonly meshVao: GLMeshVao;\n readonly spriteRenderer: GLSpriteRenderer;\n readonly font: GLFont;\n readonly glyphStorage: GLGlyphStorage;\n readonly textData: GLTextData;\n readonly defaultTextData: GLDefaultTextData;\n readonly textLayer: GLTextLayer;\n readonly textRenderer: GLTextRenderer;\n readonly perfCounter: GLPerfCounter;\n readonly noTexture: null;\n readonly instanceCount: number;\n readonly vertexBufferArgs: [dynamic?: boolean];\n readonly floatArray: Float32Array | number[];\n readonly rawTextureData: ArrayBufferView | null;\n readonly rawTextureOptions: GLRawTextureOptions;\n readonly textureOptions: GLTextureOptions;\n readonly renderTargetOptions: GLRenderTargetOptions;\n readonly attributeDescriptor: GLAttributeDescriptor;\n readonly blendMode: GLBlendMode;\n readonly effectWaitOptions: GLEffectWaitOptions;\n readonly effectWrapperOptions: GLEffectWrapperOptions;\n readonly textureUpdateOptions: GLTextureUpdateOptions;\n readonly floatTextureOptions: GLFloatTextureOptions;\n readonly samplingMode: GLSamplingMode;\n readonly samplingFilters: GLSamplingFilters;\n readonly texture3DOptions: GLPixelsTexture3DOptions;\n readonly floatRenderTargetOptions: GLFloatRenderTargetOptions;\n readonly readPixelsOptions: GLReadPixelsOptions;\n readonly blendState: GLBlendState;\n readonly depthState: GLDepthState;\n readonly stencilState: GLStencilState;\n readonly stencilOpState: GLStencilOpState;\n readonly spriteRendererOptions: GLSpriteRendererOptions;\n readonly sprite: GLSprite;\n readonly glyphCurves: GLGlyphCurves;\n readonly quadCurve: GLQuadCurve;\n readonly glyphRun: GLGlyphRun;\n readonly textDataUpdate: GLTextDataUpdate;\n readonly textLayoutOptions: GLTextLayoutOptions;\n readonly textLayerOptions: GLTextLayerOptions;\n readonly textRendererOptions: GLTextRendererOptions;\n}\n\n/** WebGL2 operations that create or destroy an engine or exchange data with browser or WebGL objects. */\nexport interface WebGLHostOps {\n readonly createGLEngine: typeof createGLEngine;\n readonly createHostOwnedGLEngine: typeof createHostOwnedGLEngine;\n readonly disposeGLEngine: typeof disposeGLEngine;\n readonly getRenderingCanvas: typeof getRenderingCanvas;\n readonly createTextureFromHandle: typeof createTextureFromHandle;\n readonly createTextureFromSource: typeof createTextureFromSource;\n readonly updateDynamicTexture: typeof updateDynamicTexture;\n readonly clearDynamicTextureSource: typeof clearDynamicTextureSource;\n readonly createHtmlElementTexture: typeof createHtmlElementTexture;\n readonly updateHtmlElementTexture: typeof updateHtmlElementTexture;\n readonly readRenderTargetPixelsToBuffer: typeof readRenderTargetPixelsToBuffer;\n}\n"]}