wuepgg3-track 3.0.3 → 4.0.0

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 (84) hide show
  1. package/dist/{SharedSystems-Czb8QUFv.mjs → SharedSystems-CQUTbUIx.mjs} +675 -433
  2. package/dist/{WebGLRenderer-Bd4vvqtJ.mjs → WebGLRenderer-zlVosyby.mjs} +417 -382
  3. package/dist/{WebGPURenderer-CVU5sf4P.mjs → WebGPURenderer-OAybUJeH.mjs} +277 -258
  4. package/dist/{browserAll-CZ03TD2_.mjs → browserAll-Byje74wY.mjs} +2 -2
  5. package/dist/{colorToUniform-BwrjBKZW.mjs → colorToUniform-COOzkdM9.mjs} +9 -8
  6. package/dist/components/GenomeView/TrackComponents/BamComponents/BamAnnotation.d.ts +1 -1
  7. package/dist/components/GenomeView/TrackComponents/CategoricalComponents/CategoricalAnnotation.d.ts +1 -1
  8. package/dist/components/GenomeView/TrackComponents/DynseqComponents/DynseqTrackComponents.d.ts +2 -3
  9. package/dist/components/GenomeView/TrackComponents/GenomeAlignComponents/GenomeAlignComponents.d.ts +3 -1
  10. package/dist/components/GenomeView/TrackComponents/GenomeAlignComponents/HorizontalFragment.d.ts +1 -0
  11. package/dist/components/GenomeView/TrackComponents/GenomeAlignComponents/MultiAlignmentViewCalculator.d.ts +1 -0
  12. package/dist/components/GenomeView/TrackComponents/GroupedTrackManager.d.ts +3 -0
  13. package/dist/components/GenomeView/TrackComponents/InteractionComponents/InteractionTrackComponent.d.ts +4 -15
  14. package/dist/components/GenomeView/TrackComponents/MethylcComponents/MethylCTrackComputation.d.ts +5 -13
  15. package/dist/components/GenomeView/TrackComponents/QBedComponents/QBedTrackComponents.d.ts +9 -26
  16. package/dist/components/GenomeView/TrackComponents/RulerComponents/Ruler.d.ts +1 -1
  17. package/dist/components/GenomeView/TrackComponents/VcfComponents/Vcf.d.ts +1 -0
  18. package/dist/components/GenomeView/TrackComponents/VcfComponents/VcfTrack.d.ts +5 -24
  19. package/dist/components/GenomeView/TrackComponents/bedComponents/FiberTrackComponent.d.ts +5 -39
  20. package/dist/components/GenomeView/TrackComponents/commonComponents/HoverToolTips/HoverToolTip.d.ts +5 -0
  21. package/dist/components/GenomeView/TrackComponents/commonComponents/OutsideClickDetector.d.ts +1 -1
  22. package/dist/components/GenomeView/TrackComponents/commonComponents/TrackLegend.d.ts +1 -1
  23. package/dist/components/GenomeView/TrackComponents/commonComponents/annotation/AnnotationArrows.d.ts +1 -1
  24. package/dist/components/GenomeView/TrackComponents/commonComponents/numerical/NumericalAggregator.d.ts +2 -1
  25. package/dist/components/GenomeView/TrackComponents/commonComponents/numerical/NumericalTrack.d.ts +3 -1
  26. package/dist/components/GenomeView/TrackComponents/commonComponents/stats/BoxplotTrackComponents.d.ts +3 -37
  27. package/dist/components/GenomeView/TrackComponents/displayModeComponentMap.d.ts +1 -1
  28. package/dist/components/GenomeView/TrackComponents/geneAnnotationTrackComponents/BackgroundedText.d.ts +1 -1
  29. package/dist/components/GenomeView/TrackComponents/geneAnnotationTrackComponents/GeneDetail.d.ts +2 -2
  30. package/dist/components/GenomeView/genomeNavigator/Ruler.d.ts +1 -1
  31. package/dist/components/GenomeView/genomeNavigator/SelectableGenomeArea.d.ts +1 -1
  32. package/dist/components/GenomeView/genomeNavigator/SelectedRegionBox.d.ts +1 -1
  33. package/dist/genome-hub/GenomeSerializer.d.ts +1 -1
  34. package/dist/genome-hub/genome-schema.d.ts +1 -2
  35. package/dist/getLocalData/LocalBigSource.d.ts +47 -0
  36. package/dist/getRemoteData/BigSourceWorker.d.ts +47 -0
  37. package/dist/getRemoteData/BigSourceWorkerGmod.d.ts +14 -5
  38. package/dist/getRemoteData/VcfSource.d.ts +9 -0
  39. package/dist/getRemoteData/hicSource.d.ts +1 -1
  40. package/dist/getRemoteData/io/remoteFile.d.ts +1 -1
  41. package/dist/getRemoteData/tabixSource.d.ts +18 -0
  42. package/dist/getRemoteData/vendor/bbi-js/main/bigwig.d.ts +1 -0
  43. package/dist/getRemoteData/vendor/bbi-js/utils/bin.d.ts +20 -0
  44. package/dist/getRemoteData/vendor/bbi-js/utils/das.d.ts +6 -0
  45. package/dist/getRemoteData/vendor/bbi-js/utils/jszlib.d.ts +1 -0
  46. package/dist/getRemoteData/vendor/bbi-js/utils/sha1.d.ts +1 -0
  47. package/dist/getRemoteData/vendor/bbi-js/utils/spans.d.ts +13 -0
  48. package/dist/{index-lRQCOP9E.mjs → index-BRD1ij9p.mjs} +64989 -66773
  49. package/dist/index.es.js +11 -11
  50. package/dist/index.umd.js +239 -228
  51. package/dist/{init-Bk9eSswv.mjs → init-DVJ9vOmS.mjs} +370 -355
  52. package/dist/models/AlignmentSegment.d.ts +1 -1
  53. package/dist/models/AlignmentStringUtils.d.ts +1 -1
  54. package/dist/models/BamAlignment.d.ts +1 -1
  55. package/dist/models/BedRecord.d.ts +1 -1
  56. package/dist/models/Chromosome.d.ts +1 -1
  57. package/dist/models/ChromosomeInterval.d.ts +1 -1
  58. package/dist/models/DisplayedRegionModel.d.ts +1 -1
  59. package/dist/models/Feature.d.ts +2 -2
  60. package/dist/models/FeatureAggregator.d.ts +4 -5
  61. package/dist/models/FeatureArranger.d.ts +7 -1
  62. package/dist/models/NavigationContext.d.ts +2 -1
  63. package/dist/models/OpenInterval.d.ts +1 -1
  64. package/dist/models/Snp.d.ts +1 -1
  65. package/dist/models/TrackModel.d.ts +3 -1
  66. package/dist/models/genomes/allGenomes.d.ts +20 -0
  67. package/dist/models/genomes/mCalJa1.2.pat.X/mCalJa1.2.pat.X.d.ts +17 -0
  68. package/dist/models/getXSpan/FeaturePlacer.d.ts +2 -9
  69. package/dist/models/trackModels/trackProps.d.ts +1 -0
  70. package/dist/style.css +1 -1
  71. package/dist/trackConfigs/config-menu-components.tsx/ColorConfig.d.ts +2 -1
  72. package/dist/trackConfigs/config-menu-components.tsx/DownsamplingConfig.d.ts +8 -0
  73. package/dist/trackConfigs/config-menu-components.tsx/NumberConfig.d.ts +1 -1
  74. package/dist/types/track-container.d.ts +1 -0
  75. package/dist/webworkerAll-I0QzCLqb.mjs +2 -0
  76. package/package.json +2 -4
  77. package/dist/components/GenomeView/TrackComponents/CommonTrackStateChangeFunctions.tsx/createNewTrackState.d.ts +0 -18
  78. package/dist/components/GenomeView/TrackComponents/CommonTrackStateChangeFunctions.tsx/getDataAfterConfigChange.d.ts +0 -11
  79. package/dist/components/GenomeView/TrackComponents/bedComponents/BedcolorTrack.d.ts +0 -6
  80. package/dist/components/GenomeView/TrackComponents/commonComponents/annotation/AnnotationTrack.d.ts +0 -25
  81. package/dist/components/GenomeView/TrackComponents/commonComponents/annotation/FullDisplayMode.d.ts +0 -45
  82. package/dist/components/testCustomGenome.d.ts +0 -505
  83. package/dist/getRemoteData/JasparSource.d.ts +0 -8
  84. package/dist/webworkerAll-D7VsNxkY.mjs +0 -2
@@ -1,14 +1,14 @@
1
- import { g as E, E as p, f as ae, D as S, c as C, B as T, d as ue, h as A, i as M, w as v, j as y, k as ce, l as de, m as L, n as w, M as k, o as D, p as he, q as pe, s as H, S as z, t as R, A as le, R as fe, e as B } from "./index-lRQCOP9E.mjs";
2
- import { S as F, l as ge, a as me } from "./colorToUniform-BwrjBKZW.mjs";
3
- import { c as _e, u as be, U as ye, B as xe, G as Ge, e as Se, R as Be, t as Pe, S as Te, a as Ce } from "./SharedSystems-Czb8QUFv.mjs";
4
- const x = F.for2d();
5
- class O {
1
+ import { g as E, E as f, c as L, u as ue, f as ce, D as P, d as v, B as T, h as de, i as A, j as M, w as C, k as x, l as he, m as pe, n as D, o as w, M as k, p as z, q as le, s as fe, t as F, S as I, v as R, A as ge, R as me, e as B } from "./index-BRD1ij9p.mjs";
2
+ import { S as O, l as _e, a as be } from "./colorToUniform-COOzkdM9.mjs";
3
+ import { c as xe, u as ye, U as Ge, B as Pe, G as Be, e as Se, R as Te, t as ve, S as Ce, a as Ue } from "./SharedSystems-CQUTbUIx.mjs";
4
+ const y = O.for2d();
5
+ class W {
6
6
  start(e, t, r) {
7
7
  const s = e.renderer, i = s.encoder, n = r.gpuProgram;
8
- this._shader = r, this._geometry = t, i.setGeometry(t, n), x.blendMode = "normal", s.pipeline.getPipeline(
8
+ this._shader = r, this._geometry = t, i.setGeometry(t, n), y.blendMode = "normal", s.pipeline.getPipeline(
9
9
  t,
10
10
  n,
11
- x
11
+ y
12
12
  );
13
13
  const o = s.globalUniforms.bindGroup;
14
14
  i.resetBindGroup(1), i.setBindGroup(0, o, n);
@@ -23,7 +23,7 @@ class O {
23
23
  s.limits.maxBatchableTextures
24
24
  );
25
25
  }
26
- x.blendMode = t.blendMode;
26
+ y.blendMode = t.blendMode;
27
27
  const n = s.bindGroup.getBindGroup(
28
28
  t.bindGroup,
29
29
  r,
@@ -31,21 +31,21 @@ class O {
31
31
  ), o = s.pipeline.getPipeline(
32
32
  this._geometry,
33
33
  r,
34
- x,
34
+ y,
35
35
  t.topology
36
36
  );
37
- t.bindGroup._touch(s.textureGC.count), i.setPipeline(o), i.renderPassEncoder.setBindGroup(1, n), i.renderPassEncoder.drawIndexed(t.size, 1, t.start);
37
+ t.bindGroup._touch(s.gc.now, s.tick), i.setPipeline(o), i.renderPassEncoder.setBindGroup(1, n), i.renderPassEncoder.drawIndexed(t.size, 1, t.start);
38
38
  }
39
39
  }
40
- O.extension = {
40
+ W.extension = {
41
41
  type: [
42
- p.WebGPUPipesAdaptor
42
+ f.WebGPUPipesAdaptor
43
43
  ],
44
44
  name: "batch"
45
45
  };
46
- class I {
46
+ class H {
47
47
  constructor(e) {
48
- this._hash = /* @__PURE__ */ Object.create(null), this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_hash");
48
+ this._hash = /* @__PURE__ */ Object.create(null), this._renderer = e;
49
49
  }
50
50
  contextChange(e) {
51
51
  this._gpu = e;
@@ -56,41 +56,41 @@ class I {
56
56
  _createBindGroup(e, t, r) {
57
57
  const s = this._gpu.device, i = t.layout[r], n = [], o = this._renderer;
58
58
  for (const l in i) {
59
- const h = e.resources[l] ?? e.resources[i[l]];
60
- let f;
61
- if (h._resourceType === "uniformGroup") {
62
- const d = h;
59
+ const p = e.resources[l] ?? e.resources[i[l]];
60
+ let h;
61
+ if (p._resourceType === "uniformGroup") {
62
+ const d = p;
63
63
  o.ubo.updateUniformGroup(d);
64
64
  const _ = d.buffer;
65
- f = {
65
+ h = {
66
66
  buffer: o.buffer.getGPUBuffer(_),
67
67
  offset: 0,
68
68
  size: _.descriptor.size
69
69
  };
70
- } else if (h._resourceType === "buffer") {
71
- const d = h;
72
- f = {
70
+ } else if (p._resourceType === "buffer") {
71
+ const d = p;
72
+ h = {
73
73
  buffer: o.buffer.getGPUBuffer(d),
74
74
  offset: 0,
75
75
  size: d.descriptor.size
76
76
  };
77
- } else if (h._resourceType === "bufferResource") {
78
- const d = h;
79
- f = {
77
+ } else if (p._resourceType === "bufferResource") {
78
+ const d = p;
79
+ h = {
80
80
  buffer: o.buffer.getGPUBuffer(d.buffer),
81
81
  offset: d.offset,
82
82
  size: d.size
83
83
  };
84
- } else if (h._resourceType === "textureSampler") {
85
- const d = h;
86
- f = o.texture.getGpuSampler(d);
87
- } else if (h._resourceType === "textureSource") {
88
- const d = h;
89
- f = o.texture.getGpuSource(d).createView({});
84
+ } else if (p._resourceType === "textureSampler") {
85
+ const d = p;
86
+ h = o.texture.getGpuSampler(d);
87
+ } else if (p._resourceType === "textureSource") {
88
+ const d = p;
89
+ h = o.texture.getGpuSource(d).createView();
90
90
  }
91
91
  n.push({
92
92
  binding: i[l],
93
- resource: f
93
+ resource: h
94
94
  });
95
95
  }
96
96
  const u = o.shader.getProgramData(t).bindGroups[r], c = s.createBindGroup({
@@ -100,29 +100,41 @@ class I {
100
100
  return this._hash[e._key] = c, c;
101
101
  }
102
102
  destroy() {
103
- for (const e of Object.keys(this._hash))
104
- this._hash[e] = null;
105
103
  this._hash = null, this._renderer = null;
106
104
  }
107
105
  }
108
- I.extension = {
106
+ H.extension = {
109
107
  type: [
110
- p.WebGPUSystem
108
+ f.WebGPUSystem
111
109
  ],
112
110
  name: "bindGroup"
113
111
  };
114
- class W {
112
+ class Me {
115
113
  constructor(e) {
116
- this._gpuBuffers = /* @__PURE__ */ Object.create(null), e.renderableGC.addManagedHash(this, "_gpuBuffers");
114
+ this.gpuBuffer = e;
115
+ }
116
+ destroy() {
117
+ this.gpuBuffer.destroy(), this.gpuBuffer = null;
118
+ }
119
+ }
120
+ class V {
121
+ constructor(e) {
122
+ this._renderer = e, this._managedBuffers = new L({
123
+ renderer: e,
124
+ type: "resource",
125
+ onUnload: this.onBufferUnload.bind(this),
126
+ name: "gpuBuffer"
127
+ });
117
128
  }
118
129
  contextChange(e) {
119
130
  this._gpu = e;
120
131
  }
121
132
  getGPUBuffer(e) {
122
- return this._gpuBuffers[e.uid] || this.createGPUBuffer(e);
133
+ var t;
134
+ return e._gcLastUsed = this._renderer.gc.now, ((t = e._gpuData[this._renderer.uid]) == null ? void 0 : t.gpuBuffer) || this.createGPUBuffer(e);
123
135
  }
124
136
  updateBuffer(e) {
125
- const t = this._gpuBuffers[e.uid] || this.createGPUBuffer(e), r = e.data;
137
+ const t = this.getGPUBuffer(e), r = e.data;
126
138
  return e._updateID && r && (e._updateID = 0, this._gpu.device.queue.writeBuffer(
127
139
  t,
128
140
  0,
@@ -134,42 +146,29 @@ class W {
134
146
  }
135
147
  /** dispose all WebGL resources of all managed buffers */
136
148
  destroyAll() {
137
- var e;
138
- for (const t in this._gpuBuffers)
139
- (e = this._gpuBuffers[t]) == null || e.destroy();
140
- this._gpuBuffers = {};
149
+ this._managedBuffers.removeAll();
150
+ }
151
+ onBufferUnload(e) {
152
+ e.off("update", this.updateBuffer, this), e.off("change", this.onBufferChange, this);
141
153
  }
142
154
  createGPUBuffer(e) {
143
- this._gpuBuffers[e.uid] || (e.on("update", this.updateBuffer, this), e.on("change", this.onBufferChange, this), e.on("destroy", this.onBufferDestroy, this));
144
155
  const t = this._gpu.device.createBuffer(e.descriptor);
145
- return e._updateID = 0, e.data && (ae(e.data.buffer, t.getMappedRange()), t.unmap()), this._gpuBuffers[e.uid] = t, t;
156
+ return e._updateID = 0, e._resourceId = ue("resource"), e.data && (ce(e.data.buffer, t.getMappedRange()), t.unmap()), e._gpuData[this._renderer.uid] = new Me(t), this._managedBuffers.add(e) && (e.on("update", this.updateBuffer, this), e.on("change", this.onBufferChange, this)), t;
146
157
  }
147
158
  onBufferChange(e) {
148
- this._gpuBuffers[e.uid].destroy(), e._updateID = 0, this._gpuBuffers[e.uid] = this.createGPUBuffer(e);
149
- }
150
- /**
151
- * Disposes buffer
152
- * @param buffer - buffer with data
153
- */
154
- onBufferDestroy(e) {
155
- this._destroyBuffer(e);
159
+ this._managedBuffers.remove(e), e._updateID = 0, this.createGPUBuffer(e);
156
160
  }
157
161
  destroy() {
158
- this.destroyAll(), this._gpuBuffers = {};
159
- }
160
- _destroyBuffer(e) {
161
- if (e.off("update", this.updateBuffer, this), e.off("change", this.onBufferChange, this), e.off("destroy", this.onBufferDestroy, this), !this._gpuBuffers[e.uid])
162
- return;
163
- this._gpuBuffers[e.uid].destroy(), this._gpuBuffers[e.uid] = null;
162
+ this._managedBuffers.destroy(), this._renderer = null, this._gpu = null;
164
163
  }
165
164
  }
166
- W.extension = {
165
+ V.extension = {
167
166
  type: [
168
- p.WebGPUSystem
167
+ f.WebGPUSystem
169
168
  ],
170
169
  name: "buffer"
171
170
  };
172
- class ve {
171
+ class we {
173
172
  constructor({ minUniformOffsetAlignment: e }) {
174
173
  this._minUniformOffsetAlignment = 256, this.byteIndex = 0, this._minUniformOffsetAlignment = e, this.data = new Float32Array(65535);
175
174
  }
@@ -195,7 +194,7 @@ class ve {
195
194
  this.data = null;
196
195
  }
197
196
  }
198
- class V {
197
+ class N {
199
198
  constructor(e) {
200
199
  this._colorMaskCache = 15, this._renderer = e;
201
200
  }
@@ -206,9 +205,9 @@ class V {
206
205
  this._renderer = null, this._colorMaskCache = null;
207
206
  }
208
207
  }
209
- V.extension = {
208
+ N.extension = {
210
209
  type: [
211
- p.WebGPUSystem
210
+ f.WebGPUSystem
212
211
  ],
213
212
  name: "colorMask"
214
213
  };
@@ -239,7 +238,7 @@ class U {
239
238
  * @returns {WebGLRenderingContext} the WebGL context
240
239
  */
241
240
  async _createDeviceAndAdaptor(e) {
242
- const t = await S.get().getNavigator().gpu.requestAdapter({
241
+ const t = await P.get().getNavigator().gpu.requestAdapter({
243
242
  powerPreference: e.powerPreference,
244
243
  forceFallbackAdapter: e.forceFallbackAdapter
245
244
  }), r = [
@@ -257,7 +256,7 @@ class U {
257
256
  }
258
257
  U.extension = {
259
258
  type: [
260
- p.WebGPUSystem
259
+ f.WebGPUSystem
261
260
  ],
262
261
  name: "device"
263
262
  };
@@ -273,7 +272,7 @@ U.defaultOptions = {
273
272
  */
274
273
  forceFallbackAdapter: !1
275
274
  };
276
- class N {
275
+ class j {
277
276
  constructor(e) {
278
277
  this._boundBindGroup = /* @__PURE__ */ Object.create(null), this._boundVertexBuffer = /* @__PURE__ */ Object.create(null), this._renderer = e;
279
278
  }
@@ -314,7 +313,7 @@ class N {
314
313
  setBindGroup(e, t, r) {
315
314
  if (this._boundBindGroup[e] === t)
316
315
  return;
317
- this._boundBindGroup[e] = t, t._touch(this._renderer.textureGC.count);
316
+ this._boundBindGroup[e] = t, t._touch(this._renderer.gc.now, this._renderer.tick);
318
317
  const s = this._renderer.bindGroup.getBindGroup(t, r, e);
319
318
  this.renderPassEncoder.setBindGroup(e, s);
320
319
  }
@@ -382,12 +381,12 @@ class N {
382
381
  this._gpu = e;
383
382
  }
384
383
  }
385
- N.extension = {
386
- type: [p.WebGPUSystem],
384
+ j.extension = {
385
+ type: [f.WebGPUSystem],
387
386
  name: "encoder",
388
387
  priority: 1
389
388
  };
390
- class j {
389
+ class K {
391
390
  constructor(e) {
392
391
  this._renderer = e;
393
392
  }
@@ -397,20 +396,20 @@ class j {
397
396
  destroy() {
398
397
  }
399
398
  }
400
- j.extension = {
399
+ K.extension = {
401
400
  type: [
402
- p.WebGPUSystem
401
+ f.WebGPUSystem
403
402
  ],
404
403
  name: "limits"
405
404
  };
406
- class K {
405
+ class q {
407
406
  constructor(e) {
408
407
  this._renderTargetStencilState = /* @__PURE__ */ Object.create(null), this._renderer = e, e.renderTarget.onRenderTargetChange.add(this);
409
408
  }
410
409
  onRenderTargetChange(e) {
411
410
  let t = this._renderTargetStencilState[e.uid];
412
411
  t || (t = this._renderTargetStencilState[e.uid] = {
413
- stencilMode: C.DISABLED,
412
+ stencilMode: v.DISABLED,
414
413
  stencilReference: 0
415
414
  }), this._activeRenderTarget = e, this.setStencilMode(t.stencilMode, t.stencilReference);
416
415
  }
@@ -424,9 +423,9 @@ class K {
424
423
  this._renderer.renderTarget.onRenderTargetChange.remove(this), this._renderer = null, this._activeRenderTarget = null, this._renderTargetStencilState = null;
425
424
  }
426
425
  }
427
- K.extension = {
426
+ q.extension = {
428
427
  type: [
429
- p.WebGPUSystem
428
+ f.WebGPUSystem
430
429
  ],
431
430
  name: "stencil"
432
431
  };
@@ -466,7 +465,7 @@ const G = {
466
465
  "mat4x4<f32>": { align: 16, size: 64 },
467
466
  "mat4x4<f16>": { align: 8, size: 32 }
468
467
  };
469
- function Ue(a) {
468
+ function Re(a) {
470
469
  const e = a.map((r) => ({
471
470
  data: r,
472
471
  offset: 0,
@@ -483,7 +482,7 @@ function Ue(a) {
483
482
  }
484
483
  return t = Math.ceil(t / 16) * 16, { uboElements: e, size: t };
485
484
  }
486
- function Me(a, e) {
485
+ function Ee(a, e) {
487
486
  const { size: t, align: r } = G[a.data.type], s = (r - t) / 4, i = a.data.type.indexOf("i32") >= 0 ? "dataInt32" : "data";
488
487
  return `
489
488
  v = uv.${a.data.name};
@@ -503,34 +502,34 @@ function Me(a, e) {
503
502
  }
504
503
  `;
505
504
  }
506
- function we(a) {
507
- return _e(
505
+ function Le(a) {
506
+ return xe(
508
507
  a,
509
508
  "uboWgsl",
510
- Me,
511
- be
509
+ Ee,
510
+ ye
512
511
  );
513
512
  }
514
- class q extends ye {
513
+ class Y extends Ge {
515
514
  constructor() {
516
515
  super({
517
- createUboElements: Ue,
518
- generateUboSync: we
516
+ createUboElements: Re,
517
+ generateUboSync: Le
519
518
  });
520
519
  }
521
520
  }
522
- q.extension = {
523
- type: [p.WebGPUSystem],
521
+ Y.extension = {
522
+ type: [f.WebGPUSystem],
524
523
  name: "ubo"
525
524
  };
526
525
  const b = 128;
527
- class Y {
526
+ class $ {
528
527
  constructor(e) {
529
- this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._buffers = [], this._bindGroups = [], this._bufferResources = [], this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_bindGroupHash"), this._batchBuffer = new ve({ minUniformOffsetAlignment: b });
528
+ this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._buffers = [], this._bindGroups = [], this._bufferResources = [], this._renderer = e, this._batchBuffer = new we({ minUniformOffsetAlignment: b });
530
529
  const t = 256 / b;
531
530
  for (let r = 0; r < t; r++) {
532
531
  let s = T.UNIFORM | T.COPY_DST;
533
- r === 0 && (s |= T.COPY_SRC), this._buffers.push(new ue({
532
+ r === 0 && (s |= T.COPY_SRC), this._buffers.push(new de({
534
533
  data: this._batchBuffer.data,
535
534
  usage: s
536
535
  }));
@@ -540,9 +539,7 @@ class Y {
540
539
  this._uploadBindGroups(), this._resetBindGroups();
541
540
  }
542
541
  _resetBindGroups() {
543
- for (const e in this._bindGroupHash)
544
- this._bindGroupHash[e] = null;
545
- this._batchBuffer.clear();
542
+ this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._batchBuffer.clear();
546
543
  }
547
544
  // just works for single bind groups for now
548
545
  getUniformBindGroup(e, t) {
@@ -568,7 +565,7 @@ class Y {
568
565
  _getBufferResource(e) {
569
566
  if (!this._bufferResources[e]) {
570
567
  const t = this._buffers[e % 2];
571
- this._bufferResources[e] = new xe({
568
+ this._bufferResources[e] = new Pe({
572
569
  buffer: t,
573
570
  offset: (e / 2 | 0) * 256,
574
571
  size: b
@@ -611,46 +608,46 @@ class Y {
611
608
  this._buffers = null;
612
609
  for (let t = 0; t < this._bufferResources.length; t++)
613
610
  this._bufferResources[t].destroy();
614
- this._bufferResources = null, this._batchBuffer.destroy(), this._bindGroupHash = null, this._renderer = null;
611
+ this._bufferResources = null, this._batchBuffer.destroy(), this._renderer = null;
615
612
  }
616
613
  }
617
- Y.extension = {
614
+ $.extension = {
618
615
  type: [
619
- p.WebGPUPipes
616
+ f.WebGPUPipes
620
617
  ],
621
618
  name: "uniformBatch"
622
619
  };
623
- const Re = {
620
+ const Ae = {
624
621
  "point-list": 0,
625
622
  "line-list": 1,
626
623
  "line-strip": 2,
627
624
  "triangle-list": 3,
628
625
  "triangle-strip": 4
629
626
  };
630
- function Ee(a, e, t, r, s) {
627
+ function De(a, e, t, r, s) {
631
628
  return a << 24 | e << 16 | t << 10 | r << 5 | s;
632
629
  }
633
- function Ae(a, e, t, r) {
634
- return t << 6 | a << 3 | r << 1 | e;
630
+ function ke(a, e, t, r, s) {
631
+ return t << 8 | a << 5 | r << 3 | s << 1 | e;
635
632
  }
636
- class $ {
633
+ class X {
637
634
  constructor(e) {
638
- this._moduleCache = /* @__PURE__ */ Object.create(null), this._bufferLayoutsCache = /* @__PURE__ */ Object.create(null), this._bindingNamesCache = /* @__PURE__ */ Object.create(null), this._pipeCache = /* @__PURE__ */ Object.create(null), this._pipeStateCaches = /* @__PURE__ */ Object.create(null), this._colorMask = 15, this._multisampleCount = 1, this._renderer = e;
635
+ this._moduleCache = /* @__PURE__ */ Object.create(null), this._bufferLayoutsCache = /* @__PURE__ */ Object.create(null), this._bindingNamesCache = /* @__PURE__ */ Object.create(null), this._pipeCache = /* @__PURE__ */ Object.create(null), this._pipeStateCaches = /* @__PURE__ */ Object.create(null), this._colorMask = 15, this._multisampleCount = 1, this._colorTargetCount = 1, this._renderer = e;
639
636
  }
640
637
  contextChange(e) {
641
- this._gpu = e, this.setStencilMode(C.DISABLED), this._updatePipeHash();
638
+ this._gpu = e, this.setStencilMode(v.DISABLED), this._updatePipeHash();
642
639
  }
643
640
  setMultisampleCount(e) {
644
641
  this._multisampleCount !== e && (this._multisampleCount = e, this._updatePipeHash());
645
642
  }
646
643
  setRenderTarget(e) {
647
- this._multisampleCount = e.msaaSamples, this._depthStencilAttachment = e.descriptor.depthStencilAttachment ? 1 : 0, this._updatePipeHash();
644
+ this._multisampleCount = e.msaaSamples, this._depthStencilAttachment = e.descriptor.depthStencilAttachment ? 1 : 0, this._colorTargetCount = e.colorTargetCount, this._updatePipeHash();
648
645
  }
649
646
  setColorMask(e) {
650
647
  this._colorMask !== e && (this._colorMask = e, this._updatePipeHash());
651
648
  }
652
649
  setStencilMode(e) {
653
- this._stencilMode !== e && (this._stencilMode = e, this._stencilState = Ge[e], this._updatePipeHash());
650
+ this._stencilMode !== e && (this._stencilMode = e, this._stencilState = Be[e], this._updatePipeHash());
654
651
  }
655
652
  setPipeline(e, t, r, s) {
656
653
  const i = this.getPipeline(e, t, r);
@@ -658,19 +655,20 @@ class $ {
658
655
  }
659
656
  getPipeline(e, t, r, s) {
660
657
  e._layoutKey || (Se(e, t.attributeData), this._generateBufferKey(e)), s || (s = e.topology);
661
- const i = Ee(
658
+ const i = De(
662
659
  e._layoutKey,
663
660
  t._layoutKey,
664
661
  r.data,
665
662
  r._blendModeId,
666
- Re[s]
663
+ Ae[s]
667
664
  );
668
665
  return this._pipeCache[i] ? this._pipeCache[i] : (this._pipeCache[i] = this._createPipeline(e, t, r, s), this._pipeCache[i]);
669
666
  }
670
667
  _createPipeline(e, t, r, s) {
671
- const i = this._gpu.device, n = this._createVertexBufferLayouts(e, t), o = this._renderer.state.getColorTargets(r);
672
- o[0].writeMask = this._stencilMode === C.RENDERING_MASK_ADD ? 0 : this._colorMask;
673
- const u = this._renderer.shader.getProgramData(t).pipeline, c = {
668
+ const i = this._gpu.device, n = this._createVertexBufferLayouts(e, t), o = this._renderer.state.getColorTargets(r, this._colorTargetCount), u = this._stencilMode === v.RENDERING_MASK_ADD ? 0 : this._colorMask;
669
+ for (let h = 0; h < o.length; h++)
670
+ o[h].writeMask = u;
671
+ const c = this._renderer.shader.getProgramData(t).pipeline, l = {
674
672
  // TODO later check if its helpful to create..
675
673
  // layout,
676
674
  vertex: {
@@ -688,19 +686,19 @@ class $ {
688
686
  topology: s,
689
687
  cullMode: r.cullMode
690
688
  },
691
- layout: u,
689
+ layout: c,
692
690
  multisample: {
693
691
  count: this._multisampleCount
694
692
  },
695
693
  // depthStencil,
696
694
  label: "PIXI Pipeline"
697
695
  };
698
- return this._depthStencilAttachment && (c.depthStencil = {
696
+ return this._depthStencilAttachment && (l.depthStencil = {
699
697
  ...this._stencilState,
700
698
  format: "depth24plus-stencil8",
701
699
  depthWriteEnabled: r.depthTest,
702
700
  depthCompare: r.depthTest ? "less" : "always"
703
- }), i.createRenderPipeline(c);
701
+ }), i.createRenderPipeline(l);
704
702
  }
705
703
  _getModule(e) {
706
704
  return this._moduleCache[e] || this._createModule(e);
@@ -769,7 +767,7 @@ class $ {
769
767
  }, o = n.attributes;
770
768
  for (const u in t.attributeData) {
771
769
  const c = e.attributes[u];
772
- (c.divisor ?? 1) !== 1 && v(`Attribute ${u} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`), c.buffer === i && (n.arrayStride = c.stride, n.stepMode = c.instance ? "instance" : "vertex", o.push({
770
+ (c.divisor ?? 1) !== 1 && C(`Attribute ${u} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`), c.buffer === i && (n.arrayStride = c.stride, n.stepMode = c.instance ? "instance" : "vertex", o.push({
773
771
  shaderLocation: t.attributeData[u].location,
774
772
  offset: c.offset,
775
773
  format: c.format
@@ -779,11 +777,12 @@ class $ {
779
777
  }), this._bufferLayoutsCache[r] = s, s;
780
778
  }
781
779
  _updatePipeHash() {
782
- const e = Ae(
780
+ const e = ke(
783
781
  this._stencilMode,
784
782
  this._multisampleCount,
785
783
  this._colorMask,
786
- this._depthStencilAttachment
784
+ this._depthStencilAttachment,
785
+ this._colorTargetCount
787
786
  );
788
787
  this._pipeStateCaches[e] || (this._pipeStateCaches[e] = /* @__PURE__ */ Object.create(null)), this._pipeCache = this._pipeStateCaches[e];
789
788
  }
@@ -791,16 +790,16 @@ class $ {
791
790
  this._renderer = null, this._bufferLayoutsCache = null;
792
791
  }
793
792
  }
794
- $.extension = {
795
- type: [p.WebGPUSystem],
793
+ X.extension = {
794
+ type: [f.WebGPUSystem],
796
795
  name: "pipeline"
797
796
  };
798
- class Le {
797
+ class ze {
799
798
  constructor() {
800
799
  this.contexts = [], this.msaaTextures = [], this.msaaSamples = 1;
801
800
  }
802
801
  }
803
- class ke {
802
+ class Fe {
804
803
  init(e, t) {
805
804
  this._renderer = e, this._renderTargetSystem = t;
806
805
  }
@@ -842,19 +841,19 @@ class ke {
842
841
  );
843
842
  }
844
843
  getDescriptor(e, t, r) {
845
- typeof t == "boolean" && (t = t ? y.ALL : y.NONE);
844
+ typeof t == "boolean" && (t = t ? x.ALL : x.NONE);
846
845
  const s = this._renderTargetSystem, i = s.getGpuRenderTarget(e), n = e.colorTextures.map(
847
846
  (c, l) => {
848
- const h = i.contexts[l];
849
- let f, d;
850
- h ? f = h.getCurrentTexture().createView() : f = this._renderer.texture.getGpuSource(c).createView({
847
+ const p = i.contexts[l];
848
+ let h, d;
849
+ p ? h = p.getCurrentTexture().createView() : h = this._renderer.texture.getGpuSource(c).createView({
851
850
  mipLevelCount: 1
852
- }), i.msaaTextures[l] && (d = f, f = this._renderer.texture.getTextureView(
851
+ }), i.msaaTextures[l] && (d = h, h = this._renderer.texture.getTextureView(
853
852
  i.msaaTextures[l]
854
853
  ));
855
- const _ = t & y.COLOR ? "clear" : "load";
854
+ const _ = t & x.COLOR ? "clear" : "load";
856
855
  return r ?? (r = s.defaultClearColor), {
857
- view: f,
856
+ view: h,
858
857
  resolveTarget: d,
859
858
  clearValue: r,
860
859
  storeOp: "store",
@@ -864,7 +863,7 @@ class ke {
864
863
  );
865
864
  let o;
866
865
  if ((e.stencil || e.depth) && !e.depthStencilTexture && (e.ensureDepthStencilTexture(), e.depthStencilTexture.source.sampleCount = i.msaa ? 4 : 1), e.depthStencilTexture) {
867
- const c = t & y.STENCIL ? "clear" : "load", l = t & y.DEPTH ? "clear" : "load";
866
+ const c = t & x.STENCIL ? "clear" : "load", l = t & x.DEPTH ? "clear" : "load";
868
867
  o = {
869
868
  view: this._renderer.texture.getGpuSource(e.depthStencilTexture.source).createView(),
870
869
  stencilStoreOp: "store",
@@ -884,18 +883,18 @@ class ke {
884
883
  return;
885
884
  const { gpu: i, encoder: n } = this._renderer, o = i.device;
886
885
  if (n.commandEncoder === null) {
887
- const c = o.createCommandEncoder(), l = this.getDescriptor(e, t, r), h = c.beginRenderPass(l);
888
- h.setViewport(s.x, s.y, s.width, s.height, 0, 1), h.end();
889
- const f = c.finish();
890
- o.queue.submit([f]);
886
+ const c = o.createCommandEncoder(), l = this.getDescriptor(e, t, r), p = c.beginRenderPass(l);
887
+ p.setViewport(s.x, s.y, s.width, s.height, 0, 1), p.end();
888
+ const h = c.finish();
889
+ o.queue.submit([h]);
891
890
  } else
892
891
  this.startRenderPass(e, t, r, s);
893
892
  }
894
893
  initGpuRenderTarget(e) {
895
894
  e.isRoot = !0;
896
- const t = new Le();
897
- return e.colorTextures.forEach((r, s) => {
898
- if (r instanceof ce) {
895
+ const t = new ze();
896
+ return t.colorTargetCount = e.colorTextures.length, e.colorTextures.forEach((r, s) => {
897
+ if (r instanceof he) {
899
898
  const i = r.resource.getContext(
900
899
  "webgpu"
901
900
  ), n = r.transparent ? "premultiplied" : "opaque";
@@ -912,7 +911,7 @@ class ke {
912
911
  t.contexts[s] = i;
913
912
  }
914
913
  if (t.msaa = r.source.antialias, r.source.antialias) {
915
- const i = new de({
914
+ const i = new pe({
916
915
  width: 0,
917
916
  height: 0,
918
917
  sampleCount: 4
@@ -944,16 +943,16 @@ class ke {
944
943
  });
945
944
  }
946
945
  }
947
- class X extends Be {
946
+ class Z extends Te {
948
947
  constructor(e) {
949
- super(e), this.adaptor = new ke(), this.adaptor.init(e, this);
948
+ super(e), this.adaptor = new Fe(), this.adaptor.init(e, this);
950
949
  }
951
950
  }
952
- X.extension = {
953
- type: [p.WebGPUSystem],
951
+ Z.extension = {
952
+ type: [f.WebGPUSystem],
954
953
  name: "renderTarget"
955
954
  };
956
- class Z {
955
+ class J {
957
956
  constructor() {
958
957
  this._gpuProgramData = /* @__PURE__ */ Object.create(null);
959
958
  }
@@ -974,9 +973,9 @@ class Z {
974
973
  this._gpu = null, this._gpuProgramData = null;
975
974
  }
976
975
  }
977
- Z.extension = {
976
+ J.extension = {
978
977
  type: [
979
- p.WebGPUSystem
978
+ f.WebGPUSystem
980
979
  ],
981
980
  name: "shader"
982
981
  };
@@ -1125,9 +1124,9 @@ g.max = {
1125
1124
  operation: "max"
1126
1125
  }
1127
1126
  };
1128
- class J {
1127
+ class Q {
1129
1128
  constructor() {
1130
- this.defaultState = new F(), this.defaultState.blend = !0;
1129
+ this.defaultState = new O(), this.defaultState.blend = !0;
1131
1130
  }
1132
1131
  contextChange(e) {
1133
1132
  this.gpu = e;
@@ -1135,27 +1134,29 @@ class J {
1135
1134
  /**
1136
1135
  * Gets the blend mode data for the current state
1137
1136
  * @param state - The state to get the blend mode from
1137
+ * @param count - The number of color targets to create
1138
1138
  */
1139
- getColorTargets(e) {
1140
- return [
1141
- {
1142
- format: "bgra8unorm",
1143
- writeMask: 0,
1144
- blend: g[e.blendMode] || g.normal
1145
- }
1146
- ];
1139
+ getColorTargets(e, t) {
1140
+ const r = g[e.blendMode] || g.normal, s = [], i = {
1141
+ format: "bgra8unorm",
1142
+ writeMask: 0,
1143
+ blend: r
1144
+ };
1145
+ for (let n = 0; n < t; n++)
1146
+ s[n] = i;
1147
+ return s;
1147
1148
  }
1148
1149
  destroy() {
1149
1150
  this.gpu = null;
1150
1151
  }
1151
1152
  }
1152
- J.extension = {
1153
+ Q.extension = {
1153
1154
  type: [
1154
- p.WebGPUSystem
1155
+ f.WebGPUSystem
1155
1156
  ],
1156
1157
  name: "state"
1157
1158
  };
1158
- const De = {
1159
+ const Ie = {
1159
1160
  type: "image",
1160
1161
  upload(a, e, t) {
1161
1162
  const r = a.resource, s = (a.pixelWidth | 0) * (a.pixelHeight | 0), i = r.byteLength / s;
@@ -1174,7 +1175,7 @@ const De = {
1174
1175
  }
1175
1176
  );
1176
1177
  }
1177
- }, Q = {
1178
+ }, ee = {
1178
1179
  "bc1-rgba-unorm": { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
1179
1180
  "bc2-rgba-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
1180
1181
  "bc3-rgba-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
@@ -1182,11 +1183,11 @@ const De = {
1182
1183
  "etc1-rgb-unorm": { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
1183
1184
  "etc2-rgba8unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
1184
1185
  "astc-4x4-unorm": { blockBytes: 16, blockWidth: 4, blockHeight: 4 }
1185
- }, He = { blockBytes: 4, blockWidth: 1, blockHeight: 1 }, ze = {
1186
+ }, Oe = { blockBytes: 4, blockWidth: 1, blockHeight: 1 }, We = {
1186
1187
  type: "compressed",
1187
1188
  upload(a, e, t) {
1188
1189
  let r = a.pixelWidth, s = a.pixelHeight;
1189
- const i = Q[a.format] || He;
1190
+ const i = ee[a.format] || Oe;
1190
1191
  for (let n = 0; n < a.resource.length; n++) {
1191
1192
  const o = a.resource[n], u = Math.ceil(r / i.blockWidth) * i.blockBytes;
1192
1193
  t.device.queue.writeTexture(
@@ -1207,15 +1208,15 @@ const De = {
1207
1208
  ), r = Math.max(r >> 1, 1), s = Math.max(s >> 1, 1);
1208
1209
  }
1209
1210
  }
1210
- }, ee = {
1211
+ }, te = {
1211
1212
  type: "image",
1212
1213
  upload(a, e, t) {
1213
1214
  const r = a.resource;
1214
1215
  if (!r)
1215
1216
  return;
1216
1217
  if (globalThis.HTMLImageElement && r instanceof HTMLImageElement) {
1217
- const o = S.get().createCanvas(r.width, r.height);
1218
- o.getContext("2d").drawImage(r, 0, 0, r.width, r.height), a.resource = o, v("ImageSource: Image element passed, converting to canvas and replacing resource.");
1218
+ const o = P.get().createCanvas(r.width, r.height);
1219
+ o.getContext("2d").drawImage(r, 0, 0, r.width, r.height), a.resource = o, C("ImageSource: Image element passed, converting to canvas and replacing resource.");
1219
1220
  }
1220
1221
  const s = Math.min(e.width, a.resourceWidth || a.pixelWidth), i = Math.min(e.height, a.resourceHeight || a.pixelHeight), n = a.alphaMode === "premultiply-alpha-on-upload";
1221
1222
  t.device.queue.copyExternalImageToTexture(
@@ -1227,13 +1228,13 @@ const De = {
1227
1228
  }
1228
1229
  );
1229
1230
  }
1230
- }, Fe = {
1231
+ }, He = {
1231
1232
  type: "video",
1232
1233
  upload(a, e, t) {
1233
- ee.upload(a, e, t);
1234
+ te.upload(a, e, t);
1234
1235
  }
1235
1236
  };
1236
- class Oe {
1237
+ class Ve {
1237
1238
  constructor(e) {
1238
1239
  this.device = e, this.sampler = e.createSampler({ minFilter: "linear" }), this.pipelines = {};
1239
1240
  }
@@ -1314,8 +1315,8 @@ class Oe {
1314
1315
  baseArrayLayer: u,
1315
1316
  arrayLayerCount: 1
1316
1317
  }), l = i ? 1 : 0;
1317
- for (let h = 1; h < e.mipLevelCount; ++h) {
1318
- const f = r.createView({
1318
+ for (let p = 1; p < e.mipLevelCount; ++p) {
1319
+ const h = r.createView({
1319
1320
  baseMipLevel: l++,
1320
1321
  mipLevelCount: 1,
1321
1322
  dimension: "2d",
@@ -1323,7 +1324,7 @@ class Oe {
1323
1324
  arrayLayerCount: 1
1324
1325
  }), d = n.beginRenderPass({
1325
1326
  colorAttachments: [{
1326
- view: f,
1327
+ view: h,
1327
1328
  storeOp: "store",
1328
1329
  loadOp: "clear",
1329
1330
  clearValue: { r: 0, g: 0, b: 0, a: 0 }
@@ -1338,7 +1339,7 @@ class Oe {
1338
1339
  resource: c
1339
1340
  }]
1340
1341
  });
1341
- d.setPipeline(t), d.setBindGroup(0, _), d.draw(3, 1, 0, 0), d.end(), c = f;
1342
+ d.setPipeline(t), d.setBindGroup(0, _), d.draw(3, 1, 0, 0), d.end(), c = h;
1342
1343
  }
1343
1344
  }
1344
1345
  if (!i) {
@@ -1359,14 +1360,34 @@ class Oe {
1359
1360
  return this.device.queue.submit([n.finish()]), i || r.destroy(), e;
1360
1361
  }
1361
1362
  }
1362
- class te {
1363
+ class Ne {
1363
1364
  constructor(e) {
1364
- this.managedTextures = [], this._gpuSources = /* @__PURE__ */ Object.create(null), this._gpuSamplers = /* @__PURE__ */ Object.create(null), this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._textureViewHash = /* @__PURE__ */ Object.create(null), this._uploads = {
1365
- image: ee,
1366
- buffer: De,
1367
- video: Fe,
1368
- compressed: ze
1369
- }, this._renderer = e, e.renderableGC.addManagedHash(this, "_gpuSources"), e.renderableGC.addManagedHash(this, "_gpuSamplers"), e.renderableGC.addManagedHash(this, "_bindGroupHash"), e.renderableGC.addManagedHash(this, "_textureViewHash");
1365
+ this.textureView = null, this.gpuTexture = e;
1366
+ }
1367
+ /** Destroys this GPU data instance. */
1368
+ destroy() {
1369
+ this.gpuTexture.destroy(), this.textureView = null, this.gpuTexture = null;
1370
+ }
1371
+ }
1372
+ class re {
1373
+ constructor(e) {
1374
+ this._gpuSamplers = /* @__PURE__ */ Object.create(null), this._bindGroupHash = /* @__PURE__ */ Object.create(null), this._uploads = {
1375
+ image: te,
1376
+ buffer: Ie,
1377
+ video: He,
1378
+ compressed: We
1379
+ }, this._renderer = e, e.renderableGC.addManagedHash(this, "_bindGroupHash"), this._managedTextures = new L({
1380
+ renderer: e,
1381
+ type: "resource",
1382
+ onUnload: this.onSourceUnload.bind(this),
1383
+ name: "gpuTextureSource"
1384
+ });
1385
+ }
1386
+ /**
1387
+ * @deprecated since 8.15.0
1388
+ */
1389
+ get managedTextures() {
1390
+ return Object.values(this._managedTextures.items);
1370
1391
  }
1371
1392
  contextChange(e) {
1372
1393
  this._gpu = e;
@@ -1377,16 +1398,17 @@ class te {
1377
1398
  * @returns The initialized texture source.
1378
1399
  */
1379
1400
  initSource(e) {
1380
- return this._gpuSources[e.uid] ? this._gpuSources[e.uid] : this._initSource(e);
1401
+ var t;
1402
+ return ((t = e._gpuData[this._renderer.uid]) == null ? void 0 : t.gpuTexture) || this._initSource(e);
1381
1403
  }
1382
1404
  _initSource(e) {
1383
1405
  if (e.autoGenerateMipmaps) {
1384
- const u = Math.max(e.pixelWidth, e.pixelHeight);
1385
- e.mipLevelCount = Math.floor(Math.log2(u)) + 1;
1406
+ const c = Math.max(e.pixelWidth, e.pixelHeight);
1407
+ e.mipLevelCount = Math.floor(Math.log2(c)) + 1;
1386
1408
  }
1387
1409
  let t = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST;
1388
1410
  e.uploadMethodId !== "compressed" && (t |= GPUTextureUsage.RENDER_ATTACHMENT, t |= GPUTextureUsage.COPY_SRC);
1389
- const r = Q[e.format] || { blockWidth: 1, blockHeight: 1 }, s = Math.ceil(e.pixelWidth / r.blockWidth) * r.blockWidth, i = Math.ceil(e.pixelHeight / r.blockHeight) * r.blockHeight, n = {
1411
+ const r = ee[e.format] || { blockWidth: 1, blockHeight: 1 }, s = Math.ceil(e.pixelWidth / r.blockWidth) * r.blockWidth, i = Math.ceil(e.pixelHeight / r.blockHeight) * r.blockHeight, n = {
1390
1412
  label: e.label,
1391
1413
  size: { width: s, height: i },
1392
1414
  format: e.format,
@@ -1394,28 +1416,25 @@ class te {
1394
1416
  mipLevelCount: e.mipLevelCount,
1395
1417
  dimension: e.dimension,
1396
1418
  usage: t
1397
- }, o = this._gpuSources[e.uid] = this._gpu.device.createTexture(n);
1398
- return this.managedTextures.includes(e) || (e.on("update", this.onSourceUpdate, this), e.on("resize", this.onSourceResize, this), e.on("destroy", this.onSourceDestroy, this), e.on("unload", this.onSourceUnload, this), e.on("updateMipmaps", this.onUpdateMipmaps, this), this.managedTextures.push(e)), this.onSourceUpdate(e), o;
1419
+ }, o = this._gpu.device.createTexture(n);
1420
+ return e._gpuData[this._renderer.uid] = new Ne(o), this._managedTextures.add(e) && (e.on("update", this.onSourceUpdate, this), e.on("resize", this.onSourceResize, this), e.on("updateMipmaps", this.onUpdateMipmaps, this)), this.onSourceUpdate(e), o;
1399
1421
  }
1400
1422
  onSourceUpdate(e) {
1401
1423
  const t = this.getGpuSource(e);
1402
1424
  t && (this._uploads[e.uploadMethodId] && this._uploads[e.uploadMethodId].upload(e, t, this._gpu), e.autoGenerateMipmaps && e.mipLevelCount > 1 && this.onUpdateMipmaps(e));
1403
1425
  }
1404
- onSourceUnload(e) {
1405
- const t = this._gpuSources[e.uid];
1406
- t && (this._gpuSources[e.uid] = null, t.destroy());
1407
- }
1408
1426
  onUpdateMipmaps(e) {
1409
- this._mipmapGenerator || (this._mipmapGenerator = new Oe(this._gpu.device));
1427
+ this._mipmapGenerator || (this._mipmapGenerator = new Ve(this._gpu.device));
1410
1428
  const t = this.getGpuSource(e);
1411
1429
  this._mipmapGenerator.generateMipmap(t);
1412
1430
  }
1413
- onSourceDestroy(e) {
1414
- e.off("update", this.onSourceUpdate, this), e.off("unload", this.onSourceUnload, this), e.off("destroy", this.onSourceDestroy, this), e.off("resize", this.onSourceResize, this), e.off("updateMipmaps", this.onUpdateMipmaps, this), this.managedTextures.splice(this.managedTextures.indexOf(e), 1), this.onSourceUnload(e);
1431
+ onSourceUnload(e) {
1432
+ e.off("update", this.onSourceUpdate, this), e.off("resize", this.onSourceResize, this), e.off("updateMipmaps", this.onUpdateMipmaps, this);
1415
1433
  }
1416
1434
  onSourceResize(e) {
1417
- const t = this._gpuSources[e.uid];
1418
- t ? (t.width !== e.pixelWidth || t.height !== e.pixelHeight) && (this._textureViewHash[e.uid] = null, this._bindGroupHash[e.uid] = null, this.onSourceUnload(e), this.initSource(e)) : this.initSource(e);
1435
+ e._gcLastUsed = this._renderer.gc.now;
1436
+ const t = e._gpuData[this._renderer.uid], r = t == null ? void 0 : t.gpuTexture;
1437
+ r ? (r.width !== e.pixelWidth || r.height !== e.pixelHeight) && (t.destroy(), this._bindGroupHash[e.uid] = null, e._gpuData[this._renderer.uid] = null, this.initSource(e)) : this.initSource(e);
1419
1438
  }
1420
1439
  _initSampler(e) {
1421
1440
  return this._gpuSamplers[e._resourceId] = this._gpu.device.createSampler(e), this._gpuSamplers[e._resourceId];
@@ -1424,7 +1443,8 @@ class te {
1424
1443
  return this._gpuSamplers[e._resourceId] || this._initSampler(e);
1425
1444
  }
1426
1445
  getGpuSource(e) {
1427
- return this._gpuSources[e.uid] || this.initSource(e);
1446
+ var t;
1447
+ return e._gcLastUsed = this._renderer.gc.now, ((t = e._gpuData[this._renderer.uid]) == null ? void 0 : t.gpuTexture) || this.initSource(e);
1428
1448
  }
1429
1449
  /**
1430
1450
  * this returns s bind group for a specific texture, the bind group contains
@@ -1436,33 +1456,32 @@ class te {
1436
1456
  * @returns the bind group for the texture
1437
1457
  */
1438
1458
  getTextureBindGroup(e) {
1439
- return this._bindGroupHash[e.uid] ?? this._createTextureBindGroup(e);
1459
+ return this._bindGroupHash[e.uid] || this._createTextureBindGroup(e);
1440
1460
  }
1441
1461
  _createTextureBindGroup(e) {
1442
1462
  const t = e.source;
1443
1463
  return this._bindGroupHash[e.uid] = new A({
1444
1464
  0: t,
1445
1465
  1: t.style,
1446
- 2: new L({
1466
+ 2: new D({
1447
1467
  uTextureMatrix: { type: "mat3x3<f32>", value: e.textureMatrix.mapCoord }
1448
1468
  })
1449
1469
  }), this._bindGroupHash[e.uid];
1450
1470
  }
1451
1471
  getTextureView(e) {
1452
1472
  const t = e.source;
1453
- return this._textureViewHash[t.uid] ?? this._createTextureView(t);
1454
- }
1455
- _createTextureView(e) {
1456
- return this._textureViewHash[e.uid] = this.getGpuSource(e).createView(), this._textureViewHash[e.uid];
1473
+ t._gcLastUsed = this._renderer.gc.now;
1474
+ let r = t._gpuData[this._renderer.uid], s = null;
1475
+ return r || (this.initSource(t), r = t._gpuData[this._renderer.uid]), s = r.textureView || r.gpuTexture.createView(), s;
1457
1476
  }
1458
1477
  generateCanvas(e) {
1459
- const t = this._renderer, r = t.gpu.device.createCommandEncoder(), s = S.get().createCanvas();
1478
+ const t = this._renderer, r = t.gpu.device.createCommandEncoder(), s = P.get().createCanvas();
1460
1479
  s.width = e.source.pixelWidth, s.height = e.source.pixelHeight;
1461
1480
  const i = s.getContext("webgpu");
1462
1481
  return i.configure({
1463
1482
  device: t.gpu.device,
1464
1483
  usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC,
1465
- format: S.get().getNavigator().gpu.getPreferredCanvasFormat(),
1484
+ format: P.get().getNavigator().gpu.getPreferredCanvasFormat(),
1466
1485
  alphaMode: "premultiplied"
1467
1486
  }), r.copyTextureToTexture({
1468
1487
  texture: t.texture.getGpuSource(e.source),
@@ -1484,41 +1503,41 @@ class te {
1484
1503
  return w.returnCanvasAndContext(r), { pixels: u, width: i, height: n };
1485
1504
  }
1486
1505
  destroy() {
1487
- this.managedTextures.slice().forEach((e) => this.onSourceDestroy(e)), this.managedTextures = null;
1506
+ this._managedTextures.destroy();
1488
1507
  for (const e of Object.keys(this._bindGroupHash)) {
1489
1508
  const t = Number(e), r = this._bindGroupHash[t];
1490
- r == null || r.destroy(), this._bindGroupHash[t] = null;
1509
+ r == null || r.destroy();
1491
1510
  }
1492
- this._renderer = null, this._gpu = null, this._mipmapGenerator = null, this._gpuSources = null, this._bindGroupHash = null, this._textureViewHash = null, this._gpuSamplers = null;
1511
+ this._renderer = null, this._gpu = null, this._mipmapGenerator = null, this._gpuSamplers = null, this._bindGroupHash = null;
1493
1512
  }
1494
1513
  }
1495
- te.extension = {
1514
+ re.extension = {
1496
1515
  type: [
1497
- p.WebGPUSystem
1516
+ f.WebGPUSystem
1498
1517
  ],
1499
1518
  name: "texture"
1500
1519
  };
1501
- class re {
1520
+ class se {
1502
1521
  constructor() {
1503
1522
  this._maxTextures = 0;
1504
1523
  }
1505
1524
  contextChange(e) {
1506
- const t = new L({
1525
+ const t = new D({
1507
1526
  uTransformMatrix: { value: new k(), type: "mat3x3<f32>" },
1508
1527
  uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
1509
1528
  uRound: { value: 0, type: "f32" }
1510
1529
  });
1511
1530
  this._maxTextures = e.limits.maxBatchableTextures;
1512
- const r = D({
1531
+ const r = z({
1513
1532
  name: "graphics",
1514
1533
  bits: [
1515
- he,
1516
- pe(this._maxTextures),
1517
- ge,
1518
- H
1534
+ le,
1535
+ fe(this._maxTextures),
1536
+ _e,
1537
+ F
1519
1538
  ]
1520
1539
  });
1521
- this.shader = new z({
1540
+ this.shader = new I({
1522
1541
  gpuProgram: r,
1523
1542
  resources: {
1524
1543
  // added on the fly!
@@ -1534,22 +1553,22 @@ class re {
1534
1553
  c.setGeometry(o.geometry, s.gpuProgram);
1535
1554
  const l = i.globalUniforms.bindGroup;
1536
1555
  c.setBindGroup(0, l, s.gpuProgram);
1537
- const h = i.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms, !0);
1538
- c.setBindGroup(2, h, s.gpuProgram);
1539
- const f = u.instructions;
1556
+ const p = i.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms, !0);
1557
+ c.setBindGroup(2, p, s.gpuProgram);
1558
+ const h = u.instructions;
1540
1559
  let d = null;
1541
1560
  for (let _ = 0; _ < u.instructionSize; _++) {
1542
- const m = f[_];
1561
+ const m = h[_];
1543
1562
  if (m.topology !== d && (d = m.topology, c.setPipelineFromGeometryProgramAndState(
1544
1563
  o.geometry,
1545
1564
  s.gpuProgram,
1546
1565
  e.state,
1547
1566
  m.topology
1548
1567
  )), s.groups[1] = m.bindGroup, !m.gpuBindGroup) {
1549
- const P = m.textures;
1568
+ const S = m.textures;
1550
1569
  m.bindGroup = E(
1551
- P.textures,
1552
- P.count,
1570
+ S.textures,
1571
+ S.count,
1553
1572
  this._maxTextures
1554
1573
  ), m.gpuBindGroup = i.bindGroup.getBindGroup(
1555
1574
  m.bindGroup,
@@ -1564,23 +1583,23 @@ class re {
1564
1583
  this.shader.destroy(!0), this.shader = null;
1565
1584
  }
1566
1585
  }
1567
- re.extension = {
1586
+ se.extension = {
1568
1587
  type: [
1569
- p.WebGPUPipesAdaptor
1588
+ f.WebGPUPipesAdaptor
1570
1589
  ],
1571
1590
  name: "graphics"
1572
1591
  };
1573
- class se {
1592
+ class ie {
1574
1593
  init() {
1575
- const e = D({
1594
+ const e = z({
1576
1595
  name: "mesh",
1577
1596
  bits: [
1578
- me,
1579
- Pe,
1580
- H
1597
+ be,
1598
+ ve,
1599
+ F
1581
1600
  ]
1582
1601
  });
1583
- this._shader = new z({
1602
+ this._shader = new I({
1584
1603
  gpuProgram: e,
1585
1604
  resources: {
1586
1605
  uTexture: R.EMPTY._source,
@@ -1597,7 +1616,7 @@ class se {
1597
1616
  if (!s)
1598
1617
  s = this._shader, s.groups[2] = r.texture.getTextureBindGroup(t.texture);
1599
1618
  else if (!s.gpuProgram) {
1600
- v("Mesh shader has no gpuProgram", t.shader);
1619
+ C("Mesh shader has no gpuProgram", t.shader);
1601
1620
  return;
1602
1621
  }
1603
1622
  const i = s.gpuProgram;
@@ -1615,44 +1634,44 @@ class se {
1615
1634
  this._shader.destroy(!0), this._shader = null;
1616
1635
  }
1617
1636
  }
1618
- se.extension = {
1637
+ ie.extension = {
1619
1638
  type: [
1620
- p.WebGPUPipesAdaptor
1639
+ f.WebGPUPipesAdaptor
1621
1640
  ],
1622
1641
  name: "mesh"
1623
1642
  };
1624
- const Ie = [
1625
- ...Te,
1626
- q,
1627
- N,
1628
- U,
1643
+ const je = [
1644
+ ...Ce,
1645
+ Y,
1629
1646
  j,
1630
- W,
1631
- te,
1632
- X,
1647
+ U,
1648
+ K,
1649
+ V,
1650
+ re,
1633
1651
  Z,
1634
1652
  J,
1635
- $,
1636
- V,
1637
- K,
1638
- I
1639
- ], We = [...Ce, Y], Ve = [O, se, re], ie = [], ne = [], oe = [];
1640
- B.handleByNamedList(p.WebGPUSystem, ie);
1641
- B.handleByNamedList(p.WebGPUPipes, ne);
1642
- B.handleByNamedList(p.WebGPUPipesAdaptor, oe);
1643
- B.add(...Ie, ...We, ...Ve);
1644
- class qe extends le {
1653
+ Q,
1654
+ X,
1655
+ N,
1656
+ q,
1657
+ H
1658
+ ], Ke = [...Ue, $], qe = [W, ie, se], ne = [], oe = [], ae = [];
1659
+ B.handleByNamedList(f.WebGPUSystem, ne);
1660
+ B.handleByNamedList(f.WebGPUPipes, oe);
1661
+ B.handleByNamedList(f.WebGPUPipesAdaptor, ae);
1662
+ B.add(...je, ...Ke, ...qe);
1663
+ class Ze extends ge {
1645
1664
  constructor() {
1646
1665
  const e = {
1647
1666
  name: "webgpu",
1648
- type: fe.WEBGPU,
1649
- systems: ie,
1650
- renderPipes: ne,
1651
- renderPipeAdaptors: oe
1667
+ type: me.WEBGPU,
1668
+ systems: ne,
1669
+ renderPipes: oe,
1670
+ renderPipeAdaptors: ae
1652
1671
  };
1653
1672
  super(e);
1654
1673
  }
1655
1674
  }
1656
1675
  export {
1657
- qe as WebGPURenderer
1676
+ Ze as WebGPURenderer
1658
1677
  };