@forgeax/engine-render 0.1.19 → 0.1.20

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 (174) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/assembly/factory.d.ts +16 -5
  3. package/dist/assembly/factory.d.ts.map +1 -1
  4. package/dist/{chunk-RJRUS55L.mjs → chunk-4XINDLAY.mjs} +267 -186
  5. package/dist/chunk-4XINDLAY.mjs.map +1 -0
  6. package/dist/{chunk-YTQ5C7YQ.mjs → chunk-CDTWTHZR.mjs} +176 -8
  7. package/dist/chunk-CDTWTHZR.mjs.map +1 -0
  8. package/dist/{chunk-IPXCABEP.mjs → chunk-M2MP4ZOU.mjs} +2 -2
  9. package/dist/chunk-M2MP4ZOU.mjs.map +1 -0
  10. package/dist/{chunk-LOSO4CTV.mjs → chunk-TBQJOK2L.mjs} +67 -3
  11. package/dist/chunk-TBQJOK2L.mjs.map +1 -0
  12. package/dist/components/light-helpers.d.ts.map +1 -1
  13. package/dist/components/spot-light.d.ts +12 -0
  14. package/dist/components/spot-light.d.ts.map +1 -1
  15. package/dist/construct-renderer.mjs +2281 -164
  16. package/dist/construct-renderer.mjs.map +1 -1
  17. package/dist/device/gpu-residency.d.ts +19 -2
  18. package/dist/device/gpu-residency.d.ts.map +1 -1
  19. package/dist/errors/render.d.ts +69 -1
  20. package/dist/errors/render.d.ts.map +1 -1
  21. package/dist/gpu-usage.d.ts +2 -0
  22. package/dist/gpu-usage.d.ts.map +1 -1
  23. package/dist/index.d.ts +7 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.mjs +3 -3
  26. package/dist/internal.mjs +1 -1
  27. package/dist/light-buffer-layout.d.ts +20 -12
  28. package/dist/light-buffer-layout.d.ts.map +1 -1
  29. package/dist/pbr-pipeline.d.ts +6 -3
  30. package/dist/pbr-pipeline.d.ts.map +1 -1
  31. package/dist/pipeline/standard-forward-lane.d.ts.map +1 -1
  32. package/dist/pipeline/standard-pipeline.d.ts.map +1 -1
  33. package/dist/pipeline/standard-profile.d.ts +13 -0
  34. package/dist/pipeline/standard-profile.d.ts.map +1 -1
  35. package/dist/record/frame-lighting.d.ts +2 -0
  36. package/dist/record/frame-lighting.d.ts.map +1 -1
  37. package/dist/record/frame-snapshot.d.ts +37 -1
  38. package/dist/record/frame-snapshot.d.ts.map +1 -1
  39. package/dist/record/frame-targets.d.ts.map +1 -1
  40. package/dist/record/frame.d.ts +3 -2
  41. package/dist/record/frame.d.ts.map +1 -1
  42. package/dist/record/gpu-timing.d.ts +32 -0
  43. package/dist/record/gpu-timing.d.ts.map +1 -0
  44. package/dist/record/main-pass-material.d.ts +1 -1
  45. package/dist/record/main-pass-material.d.ts.map +1 -1
  46. package/dist/record/render-context.d.ts +5 -1
  47. package/dist/record/render-context.d.ts.map +1 -1
  48. package/dist/record/shadow-pass.d.ts.map +1 -1
  49. package/dist/record/typed-frame-graph.d.ts +11 -3
  50. package/dist/record/typed-frame-graph.d.ts.map +1 -1
  51. package/dist/render-contract.d.ts +66 -1
  52. package/dist/render-contract.d.ts.map +1 -1
  53. package/dist/render-data.d.ts +10 -6
  54. package/dist/render-data.d.ts.map +1 -1
  55. package/dist/render-pipeline.d.ts +36 -0
  56. package/dist/render-pipeline.d.ts.map +1 -1
  57. package/dist/render-system-extract.d.ts +55 -3
  58. package/dist/render-system-extract.d.ts.map +1 -1
  59. package/dist/render-system.d.ts +7 -1
  60. package/dist/render-system.d.ts.map +1 -1
  61. package/dist/renderer-inspect.d.ts +29 -0
  62. package/dist/renderer-inspect.d.ts.map +1 -0
  63. package/dist/scene/render-scene.d.ts.map +1 -1
  64. package/dist/temporal/frame.d.ts +44 -0
  65. package/dist/temporal/frame.d.ts.map +1 -0
  66. package/dist/temporal/index.mjs +3 -3
  67. package/dist/typed-render-graph-primitives.d.ts +6 -1
  68. package/dist/typed-render-graph-primitives.d.ts.map +1 -1
  69. package/dist/typed-shadow-atlas.d.ts +10 -0
  70. package/dist/typed-shadow-atlas.d.ts.map +1 -0
  71. package/dist/typed-shadow-passes.d.ts.map +1 -1
  72. package/dist/volume/capability.d.ts +57 -0
  73. package/dist/volume/capability.d.ts.map +1 -0
  74. package/dist/volume/component.d.ts +61 -0
  75. package/dist/volume/component.d.ts.map +1 -0
  76. package/dist/volume/extract.d.ts +11 -0
  77. package/dist/volume/extract.d.ts.map +1 -0
  78. package/dist/volume/inspection.d.ts +38 -0
  79. package/dist/volume/inspection.d.ts.map +1 -0
  80. package/dist/volume/passes.d.ts +38 -0
  81. package/dist/volume/passes.d.ts.map +1 -0
  82. package/dist/volume/recovery.d.ts +38 -0
  83. package/dist/volume/recovery.d.ts.map +1 -0
  84. package/dist/volume/resources.d.ts +57 -0
  85. package/dist/volume/resources.d.ts.map +1 -0
  86. package/dist/volume/temporal.d.ts +35 -0
  87. package/dist/volume/temporal.d.ts.map +1 -0
  88. package/package.json +20 -20
  89. package/src/__tests__/ktx2-basis-gpu-consumer.dawn.test.ts +14 -14
  90. package/src/__tests__/mesh-buffer-usage-surface.unit.test.ts +1 -1
  91. package/src/__tests__/render-error-code-owner.test-d.ts +5 -0
  92. package/src/__tests__/renderer-factory-material-contract.unit.test.ts +28 -0
  93. package/src/__tests__/renderer-frame-transaction.integration.test.ts +1 -1
  94. package/src/__tests__/skinned-shadow-caster.test.ts +21 -0
  95. package/src/__tests__/standard-profile-oracle.unit.test.ts +7 -5
  96. package/src/__tests__/volume-optics-oracle.unit.test.ts +85 -0
  97. package/src/__tests__/volumetric-fog-budget-recovery.integration.test.ts +655 -0
  98. package/src/__tests__/volumetric-fog-component.unit.test.ts +71 -0
  99. package/src/__tests__/volumetric-fog-composite-stage-readback.dawn.test.ts +376 -0
  100. package/src/__tests__/volumetric-fog-errors.unit.test.ts +51 -0
  101. package/src/__tests__/volumetric-fog-inspection.unit.test.ts +77 -0
  102. package/src/__tests__/volumetric-fog-light-capability.unit.test.ts +19 -0
  103. package/src/__tests__/volumetric-fog-light-consumers.integration.test.ts +18 -0
  104. package/src/__tests__/volumetric-fog-light-errors.unit.test.ts +17 -0
  105. package/src/__tests__/volumetric-fog-light-topology.unit.test.ts +21 -0
  106. package/src/__tests__/volumetric-fog-light-transaction.integration.test.ts +53 -0
  107. package/src/__tests__/volumetric-fog-m9-watcher.integration.test.ts +27 -0
  108. package/src/__tests__/volumetric-fog-point-light-owner.integration.test.ts +44 -0
  109. package/src/__tests__/volumetric-fog-point-spot-accumulation.integration.test.ts +49 -0
  110. package/src/__tests__/volumetric-fog-point-spot-contract.unit.test.ts +28 -0
  111. package/src/__tests__/volumetric-fog-point-spot-lkg.integration.test.ts +65 -0
  112. package/src/__tests__/volumetric-fog-point-spot-selection.integration.test.ts +49 -0
  113. package/src/__tests__/volumetric-fog-point-spot-temporal.unit.test.ts +55 -0
  114. package/src/__tests__/volumetric-fog-projector-contract.unit.test.ts +22 -0
  115. package/src/__tests__/volumetric-fog-projector-inspection.unit.test.ts +12 -0
  116. package/src/__tests__/volumetric-fog-projector-surface-volume.integration.test.ts +11 -0
  117. package/src/__tests__/volumetric-fog-projector-transaction.integration.test.ts +26 -0
  118. package/src/__tests__/volumetric-fog-recovery.integration.test.ts +47 -0
  119. package/src/__tests__/volumetric-fog-selected-light-resolution.integration.test.ts +63 -0
  120. package/src/__tests__/volumetric-fog-spot-closure.integration.test.ts +26 -0
  121. package/src/__tests__/volumetric-fog-spot-contract.test-d.ts +21 -0
  122. package/src/__tests__/volumetric-fog-spot-contract.unit.test.ts +27 -0
  123. package/src/__tests__/volumetric-fog-spot-frame-optics.integration.test.ts +14 -0
  124. package/src/__tests__/volumetric-fog-spot-optics.integration.test.ts +29 -0
  125. package/src/__tests__/volumetric-fog-stage-readback.dawn.test.ts +550 -0
  126. package/src/__tests__/volumetric-fog-temporal-selected-light.unit.test.ts +33 -0
  127. package/src/__tests__/volumetric-fog-temporal.unit.test.ts +45 -0
  128. package/src/__tests__/volumetric-fog-topology.unit.test.ts +237 -0
  129. package/src/__tests__/volumetric-fog-transparent.integration.test.ts +27 -0
  130. package/src/assembly/factory.ts +271 -15
  131. package/src/components/light-helpers.ts +4 -0
  132. package/src/components/spot-light.ts +22 -3
  133. package/src/device/gpu-residency.ts +168 -58
  134. package/src/errors/render.ts +119 -1
  135. package/src/gpu-usage.ts +2 -0
  136. package/src/index.ts +38 -1
  137. package/src/light-buffer-layout.ts +59 -26
  138. package/src/pbr-pipeline.ts +33 -10
  139. package/src/pipeline/standard-forward-lane.ts +20 -0
  140. package/src/pipeline/standard-pipeline.ts +20 -0
  141. package/src/pipeline/standard-profile.ts +23 -0
  142. package/src/record/frame-lighting.ts +103 -89
  143. package/src/record/frame-snapshot.ts +41 -1
  144. package/src/record/frame-targets.ts +6 -2
  145. package/src/record/frame.ts +908 -5
  146. package/src/record/gpu-timing.ts +224 -0
  147. package/src/record/main-pass-material.ts +6 -2
  148. package/src/record/render-context.ts +5 -0
  149. package/src/record/shadow-pass.ts +87 -38
  150. package/src/record/typed-frame-graph.ts +143 -8
  151. package/src/render-contract.ts +72 -0
  152. package/src/render-data.ts +50 -22
  153. package/src/render-pipeline.ts +44 -0
  154. package/src/render-system-extract.ts +329 -3
  155. package/src/render-system.ts +79 -0
  156. package/src/renderer-inspect.ts +66 -0
  157. package/src/scene/render-scene.ts +2 -0
  158. package/src/temporal/frame.ts +128 -0
  159. package/src/transmission/__tests__/standard-transmission.dawn.test.ts +2 -3
  160. package/src/typed-render-graph-primitives.ts +32 -2
  161. package/src/typed-shadow-atlas.ts +17 -0
  162. package/src/typed-shadow-passes.ts +6 -5
  163. package/src/volume/capability.ts +173 -0
  164. package/src/volume/component.ts +110 -0
  165. package/src/volume/extract.ts +21 -0
  166. package/src/volume/inspection.ts +78 -0
  167. package/src/volume/passes.ts +680 -0
  168. package/src/volume/recovery.ts +86 -0
  169. package/src/volume/resources.ts +236 -0
  170. package/src/volume/temporal.ts +89 -0
  171. package/dist/chunk-IPXCABEP.mjs.map +0 -1
  172. package/dist/chunk-LOSO4CTV.mjs.map +0 -1
  173. package/dist/chunk-RJRUS55L.mjs.map +0 -1
  174. package/dist/chunk-YTQ5C7YQ.mjs.map +0 -1
@@ -0,0 +1,237 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { describe, expect, it } from 'vitest';
4
+ import { volumetricFogTopology } from '../volume/passes';
5
+ import { deriveVolumetricFogResolvedExtent } from '../volume/resources';
6
+
7
+ const pipelineSource = readFileSync(
8
+ fileURLToPath(new URL('../pipeline/standard-pipeline.ts', import.meta.url)),
9
+ 'utf8',
10
+ );
11
+ const shaderSource = (name: string): string =>
12
+ readFileSync(
13
+ fileURLToPath(new URL(`../../../shader/src/volume/${name}`, import.meta.url)),
14
+ 'utf8',
15
+ );
16
+
17
+ describe('volumetric fog RenderGraph topology', () => {
18
+ it('uses the official quarter-resolution high-quality resolve lane', () => {
19
+ expect(deriveVolumetricFogResolvedExtent({ width: 1920, height: 1080 }, 4)).toEqual({
20
+ width: 480,
21
+ height: 270,
22
+ depth: 1,
23
+ });
24
+ expect(deriveVolumetricFogResolvedExtent({ width: 1920, height: 1080 }, 16)).toEqual({
25
+ width: 240,
26
+ height: 135,
27
+ depth: 1,
28
+ });
29
+ });
30
+
31
+ it('keeps denoise soft while retaining depth-boundary rejection', () => {
32
+ const composite = shaderSource('volume-composite.wgsl');
33
+ expect(composite).toContain('abs(neighbor_depth - center_depth)');
34
+ expect(composite).toContain('abs(neighbor.a - center.a) * 6.0');
35
+ });
36
+
37
+ it('uses the pinned twelve-step ray integration while retaining packed visibility depth', () => {
38
+ const integrate = shaderSource('volume-integrate.wgsl');
39
+ expect(integrate).toContain('let ray_step_count = 12u;');
40
+ expect(integrate).toContain('for (var step = 0u; step < ray_step_count; step = step + 1u)');
41
+ expect(integrate).toContain('let visibility_depth = max(textureNumLayers(froxel) * 4u, 1u);');
42
+ });
43
+
44
+ it('keeps the Beer-Lambert extinction input physically non-negative', () => {
45
+ const integrate = shaderSource('volume-integrate.wgsl');
46
+ expect(integrate).toContain(
47
+ 'let density_value = max(volume_scattering_density(world_position, frame_index), 0.0);',
48
+ );
49
+ });
50
+
51
+ it('keeps the authored path to four ordered passes and two history slots', () => {
52
+ const topology = volumetricFogTopology(true);
53
+ expect(topology.passes).toEqual([
54
+ 'volume-inject',
55
+ 'volume-integrate',
56
+ 'volume-temporal',
57
+ 'volume-composite',
58
+ ]);
59
+ expect(topology.resources).toEqual([
60
+ 'volume-froxel',
61
+ 'volume-resolved-current',
62
+ 'volume-history',
63
+ 'volume-temporal',
64
+ ]);
65
+ expect(topology.colorInput).toBe('linear-hdr');
66
+ expect(topology.depthInput).toBe('scene-depth');
67
+ expect(topology.passes).not.toContain('apply_fog');
68
+ });
69
+
70
+ it('packs four logical visibility slices per rgba8 array texel', () => {
71
+ const resources = readFileSync(
72
+ fileURLToPath(new URL('../volume/resources.ts', import.meta.url)),
73
+ 'utf8',
74
+ );
75
+ const passes = readFileSync(
76
+ fileURLToPath(new URL('../volume/passes.ts', import.meta.url)),
77
+ 'utf8',
78
+ );
79
+ expect(resources).toContain("VOLUME_FROXEL_FORMAT = 'rgba8unorm'");
80
+ expect(passes).toContain('format: VOLUME_FROXEL_FORMAT');
81
+ expect(shaderSource('volume-inject.wgsl')).toContain(
82
+ 'texture_storage_2d_array<rgba8unorm, write>',
83
+ );
84
+ expect(shaderSource('volume-inject.wgsl')).not.toContain('var density : texture_3d');
85
+ expect(shaderSource('volume-integrate.wgsl')).toContain('texture_2d_array<f32>');
86
+ expect(shaderSource('volume-integrate.wgsl')).toContain('texture_3d<f32>');
87
+ expect(shaderSource('volume-integrate.wgsl')).toContain('slice_group');
88
+ });
89
+
90
+ it('uploads the camera depth convention consumed by volume CSM selection', () => {
91
+ const viewUbo = readFileSync(
92
+ fileURLToPath(new URL('../record/view-ubo.ts', import.meta.url)),
93
+ 'utf8',
94
+ );
95
+ expect(viewUbo).toContain('viewPayload[228] = camera.near');
96
+ expect(viewUbo).toContain('viewPayload[229] = camera.far');
97
+ expect(viewUbo).toContain("camera.projection === 'orthographic' ? 1 : 0");
98
+ });
99
+
100
+ it('does not allocate or schedule volume work when fog is off', () => {
101
+ expect(volumetricFogTopology(false)).toEqual({
102
+ passes: [],
103
+ resources: [],
104
+ colorInput: 'linear-hdr',
105
+ depthInput: 'scene-depth',
106
+ });
107
+ });
108
+
109
+ it('places the integrated volume before tone mapping in Standard pipeline source', () => {
110
+ expect(pipelineSource).toContain('volume-composite');
111
+ expect(pipelineSource).toContain('tone mapping');
112
+ expect(pipelineSource.indexOf('volume-composite')).toBeLessThan(
113
+ pipelineSource.indexOf('tone mapping'),
114
+ );
115
+ });
116
+
117
+ it('encodes real volume work and non-constant optical semantics', () => {
118
+ const passes = readFileSync(
119
+ fileURLToPath(new URL('../volume/passes.ts', import.meta.url)),
120
+ 'utf8',
121
+ );
122
+ expect(passes).toContain('pass.dispatchWorkgroups(dispatchX, dispatchY, packedLayers)');
123
+ expect(passes).toContain('pass.dispatchWorkgroups(resolvedDispatchX, resolvedDispatchY, 1)');
124
+ expect(passes).toContain('resolvedExtent');
125
+ expect(passes).toContain('pass.draw(3)');
126
+ expect(shaderSource('volume-inject.wgsl')).not.toContain('scene_depth');
127
+ expect(shaderSource('volume-inject.wgsl')).not.toContain('depth_weight');
128
+ expect(shaderSource('volume-inject.wgsl')).not.toContain('scene_world');
129
+ expect(shaderSource('volume-inject.wgsl')).toContain('fn volume_cascade');
130
+ expect(shaderSource('volume-inject.wgsl')).toContain('fn ray_box_interval');
131
+ expect(shaderSource('volume-inject.wgsl')).toContain('view.inverseViewProj');
132
+ expect(shaderSource('volume-inject.wgsl')).not.toContain('textureSampleLevel(density');
133
+ expect(shaderSource('volume-inject.wgsl')).toContain('stratified32');
134
+ expect(shaderSource('volume-inject.wgsl')).toContain('dither_unorm8');
135
+ expect(shaderSource('volume-integrate.wgsl')).toContain('exp(-sigma_scale');
136
+ expect(shaderSource('volume-integrate.wgsl')).toContain('textureSampleLevel(froxel');
137
+ expect(shaderSource('volume-integrate.wgsl')).toContain('textureStore(resolved');
138
+ expect(shaderSource('volume-temporal.wgsl')).toContain('var lower');
139
+ expect(shaderSource('volume-temporal.wgsl')).toContain('fn bilinear');
140
+ expect(shaderSource('volume-integrate.wgsl')).not.toContain('previous_ndc.z');
141
+ expect(shaderSource('volume-composite.wgsl')).toContain('textureSampleLevel');
142
+ expect(shaderSource('volume-composite.wgsl')).toContain('edge_aware_resolved_volume');
143
+ expect(shaderSource('volume-composite.wgsl')).toContain('textureDimensions(resolved_volume)');
144
+ expect(passes).toContain("{ resource: inputs.density, usage: 'sampled-read' }");
145
+ expect(passes).toContain("viewDimension: '2d-array'");
146
+ expect(shaderSource('volume-composite.wgsl')).toContain('linear_scene_depth');
147
+ expect(shaderSource('volume-composite.wgsl')).toContain('depth_weight');
148
+ expect(shaderSource('volume-temporal.wgsl')).toContain('temporalPreviousViewProj');
149
+ expect(shaderSource('volume-temporal.wgsl')).toContain('fn reproject_uv');
150
+ expect(shaderSource('volume-temporal.wgsl')).toContain(
151
+ 'temporalPreviousViewProj * vec4<f32>(world, 1.0)',
152
+ );
153
+ expect(shaderSource('volume-temporal.wgsl')).toContain('var lower');
154
+ expect(shaderSource('volume-composite.wgsl')).not.toContain('/ 64.0');
155
+ });
156
+
157
+ it('uses fixed logical-slice centers for injection and integration', () => {
158
+ const inject = shaderSource('volume-inject.wgsl');
159
+ const integrate = shaderSource('volume-integrate.wgsl');
160
+ expect(inject).toContain('(f32(logical_slice) + 0.5) / f32(logical_depth)');
161
+ expect(inject).not.toContain('depth_phase');
162
+ expect(integrate).toContain('fn stratified32');
163
+ expect(integrate).toContain('segment_start + segment_length * depth_phase');
164
+ });
165
+
166
+ it('keeps temporal history graph-owned and slot-selectable', () => {
167
+ const passes = readFileSync(
168
+ fileURLToPath(new URL('../volume/passes.ts', import.meta.url)),
169
+ 'utf8',
170
+ );
171
+ const frameSource = readFileSync(
172
+ fileURLToPath(new URL('../record/frame.ts', import.meta.url)),
173
+ 'utf8',
174
+ );
175
+ expect(passes).toContain('historyReadSlot');
176
+ expect(passes).toContain('historyWriteSlot');
177
+ expect(passes).toContain("usage: 'sampled-storage-read-write'");
178
+ expect(passes).not.toContain('temporalInit');
179
+ expect(passes).not.toContain('volume_temporal_init');
180
+ expect(passes).not.toContain('textureStore(volume_history');
181
+ expect(frameSource).toContain('volumetricFogHistoryGraph');
182
+ expect(frameSource).toContain('volumetricFogHistorySlot');
183
+ expect(frameSource).toContain('volumetricFogHistorySignature');
184
+ expect(frameSource).toContain('activeVolumetricFogSignature');
185
+ });
186
+
187
+ it('advances temporal history only after the accepted queue submit', () => {
188
+ const recordSource = readFileSync(
189
+ fileURLToPath(new URL('../record/frame.ts', import.meta.url)),
190
+ 'utf8',
191
+ );
192
+ const submitSource = readFileSync(
193
+ fileURLToPath(new URL('../record/typed-frame-graph.ts', import.meta.url)),
194
+ 'utf8',
195
+ );
196
+ expect(recordSource).toContain('temporalFrameTransaction.stage');
197
+ expect(recordSource).toContain('volumetricFogParamsPendingSlot');
198
+ expect(recordSource).toContain('volumetricFogParamsAcceptedSlot');
199
+ expect(recordSource).toContain('hasVolumetricFogCapability');
200
+ expect(submitSource).toContain('device.queue.submit([preparedCommand.command])');
201
+ expect(submitSource).toContain('commitTemporalGpuSubmit(stagedGpuState)');
202
+ expect(submitSource.indexOf('device.queue.submit([preparedCommand.command])')).toBeLessThan(
203
+ submitSource.indexOf('commitTemporalGpuSubmit(stagedGpuState)'),
204
+ );
205
+ });
206
+
207
+ it('requires the manifest-owned shader bundle in addition to compute/storage caps', async () => {
208
+ const { hasVolumetricFogCapability } = await import('../volume/capability');
209
+ expect(hasVolumetricFogCapability({ compute: true, storageTexture: true }, {})).toBe(true);
210
+ expect(hasVolumetricFogCapability({ compute: true, storageTexture: true }, undefined)).toBe(
211
+ false,
212
+ );
213
+ expect(hasVolumetricFogCapability({ compute: false, storageTexture: true }, {})).toBe(false);
214
+ expect(hasVolumetricFogCapability({ compute: true, storageTexture: false }, {})).toBe(false);
215
+ });
216
+
217
+ it('clears device-bound volume parameter slots during recovery without destroying old handles', () => {
218
+ const renderSystemSource = readFileSync(
219
+ fileURLToPath(new URL('../render-system.ts', import.meta.url)),
220
+ 'utf8',
221
+ );
222
+ const recoverStart = renderSystemSource.indexOf('resetForRecover(): void {');
223
+ expect(recoverStart).toBeGreaterThanOrEqual(0);
224
+ const recoverEnd = renderSystemSource.indexOf(
225
+ 'restorePostProcessResources(): void',
226
+ recoverStart,
227
+ );
228
+ expect(recoverEnd).toBeGreaterThan(recoverStart);
229
+ const recoverSource = renderSystemSource.slice(recoverStart, recoverEnd);
230
+ expect(recoverSource).toContain('frameState.volumetricFogParamsBuffers = [null, null]');
231
+ expect(recoverSource).toContain('frameState.volumetricFogParamsPendingSlot = null');
232
+ expect(recoverSource).toContain('frameState.volumetricFogParamsAcceptedSlot = null');
233
+ expect(recoverSource).toContain('frameState.volumetricFogAcceptedParams = undefined');
234
+ expect(recoverSource).toContain('frameState.volumetricFogPendingParams = undefined');
235
+ expect(recoverSource).not.toContain('destroyBuffer(buffer)');
236
+ });
237
+ });
@@ -0,0 +1,27 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { resolveIntegratedVolumeConsumer } from '../volume/capability';
3
+
4
+ describe('volumetric fog shared consumer contract', () => {
5
+ it('provides one integrated volume to opaque and transparent consumers', () => {
6
+ const resource = {
7
+ identity: 'volume-integrated',
8
+ format: 'rgba16float',
9
+ stage: 'resolved' as const,
10
+ } as const;
11
+ for (const consumer of ['opaque', 'transparent', 'sprite', 'vfx'] as const) {
12
+ expect(resolveIntegratedVolumeConsumer(resource, consumer)).toEqual({
13
+ consumer,
14
+ resource,
15
+ });
16
+ }
17
+ });
18
+
19
+ it('does not let a custom consumer own volume device or history', () => {
20
+ const result = resolveIntegratedVolumeConsumer(
21
+ { identity: 'volume-integrated', format: 'rgba16float', stage: 'resolved' } as const,
22
+ 'custom',
23
+ );
24
+ expect(result).not.toHaveProperty('device');
25
+ expect(result).not.toHaveProperty('history');
26
+ });
27
+ });