@woosh/meep-engine 3.60.9 → 3.61.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 (109) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/package.json +1 -1
  3. package/src/engine/ecs/EntityManager.d.ts +3 -3
  4. package/src/engine/ecs/EntityManager.js +3 -3
  5. package/src/engine/ecs/storage/populateEngineSerializationRegistry.d.ts.map +1 -1
  6. package/src/engine/ecs/storage/populateEngineSerializationRegistry.js +4 -0
  7. package/src/engine/graphics/ecs/decal/v2/Decal.d.ts +46 -2
  8. package/src/engine/graphics/ecs/decal/v2/Decal.d.ts.map +1 -1
  9. package/src/engine/graphics/ecs/decal/v2/Decal.js +74 -5
  10. package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.d.ts.map +1 -1
  11. package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.js +13 -1
  12. package/src/engine/graphics/ecs/decal/v2/DecalSerializationUpgrader_1_2.d.ts +9 -0
  13. package/src/engine/graphics/ecs/decal/v2/DecalSerializationUpgrader_1_2.d.ts.map +1 -0
  14. package/src/engine/graphics/ecs/decal/v2/DecalSerializationUpgrader_1_2.js +37 -0
  15. package/src/engine/graphics3/DecalSystem.d.ts.map +1 -1
  16. package/src/engine/graphics3/DecalSystem.js +462 -447
  17. package/src/engine/graphics3/decal/DECAL_GPU_RECORD.d.ts +14 -0
  18. package/src/engine/graphics3/decal/DECAL_GPU_RECORD.d.ts.map +1 -1
  19. package/src/engine/graphics3/decal/DECAL_GPU_RECORD.js +53 -13
  20. package/src/engine/graphics3/decal/chunk_decal_record.d.ts +6 -1
  21. package/src/engine/graphics3/decal/chunk_decal_record.d.ts.map +1 -1
  22. package/src/engine/graphics3/decal/chunk_decal_record.js +28 -9
  23. package/src/engine/graphics3/decal/decal_gpu_records.d.ts +2 -1
  24. package/src/engine/graphics3/decal/decal_gpu_records.d.ts.map +1 -1
  25. package/src/engine/graphics3/decal/decal_gpu_records.js +26 -5
  26. package/src/engine/graphics3/decal/decal_material_samplers.d.ts +6 -0
  27. package/src/engine/graphics3/decal/decal_material_samplers.d.ts.map +1 -1
  28. package/src/engine/graphics3/decal/decal_material_samplers.js +13 -0
  29. package/src/engine/graphics3/decal/shader_cluster_assign_decals.js +1 -1
  30. package/src/engine/graphics3/decal/shader_cull_decals_frustum.js +1 -1
  31. package/src/engine/graphics3/decal/shader_decal_composite.d.ts +5 -0
  32. package/src/engine/graphics3/decal/shader_decal_composite.d.ts.map +1 -1
  33. package/src/engine/graphics3/decal/shader_decal_composite.js +69 -28
  34. package/src/engine/network/NetworkSession.d.ts +3 -0
  35. package/src/engine/network/NetworkSession.d.ts.map +1 -1
  36. package/src/engine/network/NetworkSession.js +68 -10
  37. package/src/engine/network/README.md +6 -3
  38. package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts +51 -5
  39. package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts.map +1 -1
  40. package/src/engine/network/orchestrator/ServerAuthoritativeClient.js +308 -34
  41. package/src/engine/network/replication/Replicator.d.ts +8 -2
  42. package/src/engine/network/replication/Replicator.d.ts.map +1 -1
  43. package/src/engine/network/replication/Replicator.js +13 -4
  44. package/src/engine/network/sim/ActionLog.d.ts +16 -2
  45. package/src/engine/network/sim/ActionLog.d.ts.map +1 -1
  46. package/src/engine/network/sim/ActionLog.js +33 -2
  47. package/src/engine/network/sim/RewindEngine.d.ts +9 -0
  48. package/src/engine/network/sim/RewindEngine.d.ts.map +1 -1
  49. package/src/engine/network/sim/RewindEngine.js +15 -1
  50. package/src/engine/network/state/FrameBufferRing.d.ts +12 -5
  51. package/src/engine/network/state/FrameBufferRing.d.ts.map +1 -1
  52. package/src/engine/network/state/FrameBufferRing.js +32 -6
  53. package/src/engine/network/time/TimeDilation.d.ts +30 -14
  54. package/src/engine/network/time/TimeDilation.d.ts.map +1 -1
  55. package/src/engine/network/time/TimeDilation.js +47 -17
  56. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  57. package/src/generation/foliage/skeleton/ShootWoodHash.d.ts +3 -2
  58. package/src/generation/foliage/skeleton/ShootWoodHash.d.ts.map +1 -1
  59. package/src/generation/foliage/skeleton/ShootWoodHash.js +25 -2
  60. package/src/shade/renderer/buffer/graph_read_buffer.d.ts +3 -1
  61. package/src/shade/renderer/buffer/graph_read_buffer.d.ts.map +1 -1
  62. package/src/shade/renderer/buffer/graph_read_buffer.js +9 -6
  63. package/src/shade/renderer/buffer/util/shader_buffer_copy_storage_to_storage.d.ts +5 -0
  64. package/src/shade/renderer/buffer/util/shader_buffer_copy_storage_to_storage.d.ts.map +1 -1
  65. package/src/shade/renderer/buffer/util/shader_buffer_copy_storage_to_storage.js +48 -43
  66. package/src/shade/renderer/material/GPUMaterialManager.d.ts.map +1 -1
  67. package/src/shade/renderer/material/GPUMaterialManager.js +117 -35
  68. package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts +2 -2
  69. package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts.map +1 -1
  70. package/src/shade/renderer/material/standard/fragment_gbuffer.js +10 -3
  71. package/src/shade/renderer/material/standard/material_gbuffer_vertex.d.ts +15 -3
  72. package/src/shade/renderer/material/standard/material_gbuffer_vertex.d.ts.map +1 -1
  73. package/src/shade/renderer/material/standard/material_gbuffer_vertex.js +25 -4
  74. package/src/shade/renderer/particles/GPUParticleSystem.d.ts +23 -5
  75. package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
  76. package/src/shade/renderer/particles/GPUParticleSystem.js +294 -20
  77. package/src/shade/renderer/particles/resize/shader_particle_shrink_alive_list.d.ts +21 -0
  78. package/src/shade/renderer/particles/resize/shader_particle_shrink_alive_list.d.ts.map +1 -0
  79. package/src/shade/renderer/particles/resize/shader_particle_shrink_alive_list.js +83 -0
  80. package/src/shade/renderer/particles/resize/shader_particle_shrink_free_list.d.ts +21 -0
  81. package/src/shade/renderer/particles/resize/shader_particle_shrink_free_list.d.ts.map +1 -0
  82. package/src/shade/renderer/particles/resize/shader_particle_shrink_free_list.js +64 -0
  83. package/src/shade/renderer/restir/di/chunk_restir_resolve.d.ts.map +1 -1
  84. package/src/shade/renderer/restir/di/chunk_restir_resolve.js +91 -94
  85. package/src/shade/renderer/restir/reservoir/chunk_rtxdi_stream_sample.js +1 -1
  86. package/src/shade/renderer/shader/chunk/color/rgbe9995/chunk_rgbe9995_decode.d.ts +14 -0
  87. package/src/shade/renderer/shader/chunk/color/rgbe9995/chunk_rgbe9995_decode.d.ts.map +1 -1
  88. package/src/shade/renderer/shader/chunk/color/rgbe9995/chunk_rgbe9995_decode.js +36 -21
  89. package/src/shade/renderer/shader/chunk/color/rgbe9995/chunk_rgbe9995_sample_gather.d.ts +22 -0
  90. package/src/shade/renderer/shader/chunk/color/rgbe9995/chunk_rgbe9995_sample_gather.d.ts.map +1 -0
  91. package/src/shade/renderer/shader/chunk/color/rgbe9995/chunk_rgbe9995_sample_gather.js +64 -0
  92. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_vertex_normal.d.ts.map +1 -1
  93. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_vertex_normal.js +13 -18
  94. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_encode_vertex_normal.d.ts.map +1 -1
  95. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_encode_vertex_normal.js +28 -30
  96. package/src/shade/renderer/shader/chunk/geometry/vec2/chunk_unit_u32_to_vec2.d.ts.map +1 -1
  97. package/src/shade/renderer/shader/chunk/geometry/vec2/chunk_unit_u32_to_vec2.js +15 -16
  98. package/src/shade/renderer/shader/chunk/geometry/vec2/chunk_unit_vec2_to_u32.d.ts +0 -1
  99. package/src/shade/renderer/shader/chunk/geometry/vec2/chunk_unit_vec2_to_u32.d.ts.map +1 -1
  100. package/src/shade/renderer/shader/chunk/geometry/vec2/chunk_unit_vec2_to_u32.js +15 -18
  101. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_bitset_or.d.ts +32 -0
  102. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_bitset_or.d.ts.map +1 -0
  103. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_bitset_or.js +73 -0
  104. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +8 -1
  105. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  106. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +7 -3
  107. package/src/shade/renderer/global_illumination/brick4/cpu/brick4_sh3_color_encode.d.ts +0 -2
  108. package/src/shade/renderer/global_illumination/brick4/cpu/brick4_sh3_color_encode.d.ts.map +0 -1
  109. package/src/shade/renderer/global_illumination/brick4/cpu/brick4_sh3_color_encode.js +0 -6
@@ -0,0 +1,73 @@
1
+ import { UINT32_MAX } from "../../../../../core/binary/UINT32_MAX.js";
2
+ import { WebGPUExtensionType } from "../../../../descriptor/WebGPUExtensionType.js";
3
+ import { CodeChunk } from "../../compiler/CodeChunk.js";
4
+
5
+ /**
6
+ * The index {@link chunk_subgroup_bitset_or} skips.
7
+ *
8
+ * @type {number}
9
+ */
10
+ export const SUBGROUP_BITSET_OR_NONE = UINT32_MAX;
11
+
12
+ /**
13
+ * Set bit `index` of a bitset, one atomic per distinct word the subgroup holds: the lanes holding
14
+ * the first outstanding word take a round, OR together the bits they hold in it — or skip that when
15
+ * they all hold the same bit — one of them sets them with one `atomicOr`, and the rounds repeat
16
+ * until no word is left.
17
+ *
18
+ * `fn subgroup_bitset_or(bits: ptr<storage, array<atomic<u32>>, read_write>, index: u32)`
19
+ *
20
+ * Bit `index` is bit `index & 31` of word `index >> 5`. An index of {@link SUBGROUP_BITSET_OR_NONE},
21
+ * or one whose word is past the end of `bits`, sets nothing. Every lane of the subgroup calls it,
22
+ * from subgroup-uniform control flow.
23
+ *
24
+ * The atomic is made by a lane of the round, so a lane that holds nothing never stands in for one
25
+ * that does — in a fragment shader, a helper invocation given {@link SUBGROUP_BITSET_OR_NONE} can
26
+ * never be the one that writes, and its write would be discarded.
27
+ *
28
+ * A subgroup runs one round per distinct word it holds, so the loop is bounded by its lane count.
29
+ * Indices that follow the screen — a material per pixel — come in runs, and a subgroup ordinarily
30
+ * holds one or two.
31
+ *
32
+ * @see chunk_subgroup_keyed_append for the counting twin
33
+ * @type {CodeChunk}
34
+ */
35
+ export const chunk_subgroup_bitset_or = CodeChunk.from(
36
+ //language=WGSL
37
+ `
38
+ // every lane runs the loop until no lane holds a word; the rounds run on the lanes holding one
39
+ @diagnostic(off, subgroup_uniformity)
40
+ fn subgroup_bitset_or(bits: ptr<storage, array<atomic<u32>>, read_write>, index: u32) {
41
+ const NONE = ${SUBGROUP_BITSET_OR_NONE}u;
42
+
43
+ var outstanding = select(index >> 5u, NONE, index == NONE);
44
+ let bit = 1u << (index & 31u);
45
+
46
+ loop {
47
+ if (!subgroupAny(outstanding != NONE)) {
48
+ break;
49
+ }
50
+
51
+ if (outstanding != NONE) {
52
+ let round_word = subgroupBroadcastFirst(outstanding);
53
+
54
+ if (outstanding == round_word) {
55
+ var round_bits = bit;
56
+
57
+ // a run of one index needs no reduction
58
+ if (!subgroupAll(bit == subgroupBroadcastFirst(bit))) {
59
+ round_bits = subgroupOr(bit);
60
+ }
61
+
62
+ if (subgroupElect() && round_word < arrayLength(bits)) {
63
+ atomicOr(&(*bits)[round_word], round_bits);
64
+ }
65
+
66
+ outstanding = NONE;
67
+ }
68
+ }
69
+ }
70
+ }
71
+ `);
72
+
73
+ chunk_subgroup_bitset_or.addExtension(WebGPUExtensionType.Subgroups);
@@ -3232,7 +3232,14 @@ function inferBuiltinReturnType(name, args) {
3232
3232
  // Both gathers return the four texels of a 2x2 footprint. Saying so here matters more than
3233
3233
  // for most builtins: the shadow chunks immediately swizzle the result (`samples.wzxy`), and
3234
3234
  // an unknown type degrades swizzle codegen downstream.
3235
- if (name === 'textureGather' || name === 'textureGatherCompare') {
3235
+ if (name === 'textureGather') {
3236
+ const first = args[0] !== undefined ? args[0].type : null;
3237
+ const texture = first !== null && first.kind === 'texture' ? first : (args[1] !== undefined ? args[1].type : null);
3238
+ const scalar = texture !== null && texture.kind === 'texture' ? texture.scalar : 'f32';
3239
+ return { kind: 'vec', size: 4, scalar: scalar === 'u32' || /uint$/.test(scalar) ? 'u32'
3240
+ : scalar === 'i32' || /sint$/.test(scalar) ? 'i32' : 'f32' };
3241
+ }
3242
+ if (name === 'textureGatherCompare') {
3236
3243
  return { kind: 'vec', size: 4, scalar: 'f32' };
3237
3244
  }
3238
3245
  if (name === 'textureDimensions') {
@@ -1 +1 @@
1
- {"version":3,"file":"WGSLLanguageCore.d.ts","sourceRoot":"","sources":["../../../../../src/shade/wgsl/emulator/WGSLLanguageCore.js"],"names":[],"mappings":";IAk3DA;;;;;;;;;;;;;OAaG;IACH,+DAyFC"}
1
+ {"version":3,"file":"WGSLLanguageCore.d.ts","sourceRoot":"","sources":["../../../../../src/shade/wgsl/emulator/WGSLLanguageCore.js"],"names":[],"mappings":";IAs3DA;;;;;;;;;;;;;OAaG;IACH,+DAyFC"}
@@ -1347,7 +1347,7 @@ export const WGSLLanguageCore = {
1347
1347
  const tz = w * t.size[2] + oz;
1348
1348
  texel_coord = dim === 1 ? [tx] : (dim === 2 ? [tx, ty] : [tx, ty, tz]);
1349
1349
  }
1350
- const result = new Float32Array(4);
1350
+ const result = t.data instanceof Uint32Array || t.data instanceof Int32Array ? new t.data.constructor(4) : new Float32Array(4);
1351
1351
  cpu_texture_sample(result, sampler ?? FALLBACK_LINEAR_CLAMP_SAMPLER, t, texel_coord);
1352
1352
  return result;
1353
1353
  },
@@ -1504,7 +1504,7 @@ export const WGSLLanguageCore = {
1504
1504
 
1505
1505
  if (extra_b !== undefined) { offset_x = extra_b[0]; offset_y = extra_b[1]; }
1506
1506
 
1507
- const result = new Float32Array(4);
1507
+ const result = t.data instanceof Uint32Array || t.data instanceof Int32Array ? new t.data.constructor(4) : new Float32Array(4);
1508
1508
 
1509
1509
  cpu_texture_gather(
1510
1510
  result,
@@ -1582,7 +1582,7 @@ export const WGSLLanguageCore = {
1582
1582
  throw new Error("textureGatherCompare: the bound sampler has no 'compare' function — WGSL requires a sampler_comparison here. Bind a SamplerDescriptor with `compare` set (the engine's shadow path uses SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR, `compare: \"greater\"` for reverse-Z).");
1583
1583
  }
1584
1584
 
1585
- const result = new Float32Array(4);
1585
+ const result = t.data instanceof Uint32Array || t.data instanceof Int32Array ? new t.data.constructor(4) : new Float32Array(4);
1586
1586
 
1587
1587
  cpu_texture_gather(
1588
1588
  result,
@@ -1773,6 +1773,10 @@ export const WGSLLanguageCore = {
1773
1773
  subgroupOr(value) { return value; },
1774
1774
  subgroupXor(value) { return value; },
1775
1775
 
1776
+ // Votes over a subgroup of one are that one's predicate.
1777
+ subgroupAll(predicate) { return predicate; },
1778
+ subgroupAny(predicate) { return predicate; },
1779
+
1776
1780
  // Scans: exclusive of the only lane is the identity, inclusive of it is its value.
1777
1781
  subgroupExclusiveAdd() { return 0; },
1778
1782
  subgroupExclusiveMul() { return 1; },
@@ -1,2 +0,0 @@
1
- export function brick4_sh3_color_encode(output: any, output_offset: any, input: any, input_offset: any): void;
2
- //# sourceMappingURL=brick4_sh3_color_encode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"brick4_sh3_color_encode.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/global_illumination/brick4/cpu/brick4_sh3_color_encode.js"],"names":[],"mappings":"AAAA,8GAKC"}
@@ -1,6 +0,0 @@
1
- export function brick4_sh3_color_encode(
2
- output, output_offset,
3
- input, input_offset,
4
- ) {
5
- throw new Error("Method not implemented.");
6
- }