ugly-game 0.15.45 → 0.15.46

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.
@@ -1,4 +1,32 @@
1
1
  /// <reference types="@webgpu/types" preserve="true" />
2
+ /**
3
+ * Every GPUBuffer owned by one packed creature, stated exhaustively.
4
+ *
5
+ * `setCreatures` replaces the complete packed list. Keeping teardown as a typed
6
+ * record means adding a buffer to `Packed` without adding it here is a compile
7
+ * error instead of a per-frame leak that only appears under a clothed actor.
8
+ */
9
+ const PACKED_BUFFER_KEYS = {
10
+ restB: true,
11
+ restNB: true,
12
+ jointsB: true,
13
+ weightsB: true,
14
+ defB: true,
15
+ defNB: true,
16
+ colB: true,
17
+ uvB: true,
18
+ uv2B: true,
19
+ idxB: true,
20
+ uBuf: true,
21
+ palB: true,
22
+ pB: true,
23
+ instModelB: true,
24
+ instParamB: true,
25
+ };
26
+ function destroyPackedBuffers(packed) {
27
+ for (const key of Object.keys(PACKED_BUFFER_KEYS))
28
+ packed[key]?.destroy();
29
+ }
2
30
  export const MAX_CASCADES = 4; // must match gpuShadow's
3
31
  const SKIN = /* wgsl */ `
4
32
  @group(0) @binding(0) var<storage,read> rest: array<vec4f>;
@@ -423,18 +451,8 @@ export class GpuSkinRenderer {
423
451
  }
424
452
  setCreatures(list) {
425
453
  const dev = this.device, U = GPUBufferUsage;
426
- for (const p of this.packed) {
427
- p.defB.destroy();
428
- p.defNB.destroy();
429
- p.colB.destroy();
430
- p.uvB.destroy();
431
- p.uv2B?.destroy();
432
- p.idxB.destroy();
433
- p.uBuf.destroy();
434
- p.palB.destroy();
435
- p.instModelB?.destroy();
436
- p.instParamB?.destroy();
437
- }
454
+ for (const p of this.packed)
455
+ destroyPackedBuffers(p);
438
456
  this.packed = list.map((c) => {
439
457
  const n = c.rest.length / 3;
440
458
  const rest = new Float32Array(n * 4), restN = new Float32Array(n * 4), joints = new Uint32Array(n * 4), weights = new Float32Array(n * 4);
@@ -578,6 +596,10 @@ export class GpuSkinRenderer {
578
596
  instBG,
579
597
  instModelB,
580
598
  instParamB,
599
+ restB,
600
+ restNB,
601
+ jointsB,
602
+ weightsB,
581
603
  defB,
582
604
  defNB,
583
605
  colB,
@@ -590,6 +612,7 @@ export class GpuSkinRenderer {
590
612
  uBuf,
591
613
  uBG,
592
614
  palB,
615
+ pB,
593
616
  n,
594
617
  model: c.model,
595
618
  mix: c.mix ?? 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-game",
3
- "version": "0.15.45",
3
+ "version": "0.15.46",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {