@forgeax/engine-render 0.1.33 → 0.1.35

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 (624) hide show
  1. package/README.md +1062 -127
  2. package/dist/assembly/backend-contract.d.ts +2 -0
  3. package/dist/assembly/backend-contract.d.ts.map +1 -1
  4. package/dist/assembly/barrel-distortion-inspection.d.ts +3 -0
  5. package/dist/assembly/barrel-distortion-inspection.d.ts.map +1 -0
  6. package/dist/assembly/canvas-draw-guard.d.ts +3 -0
  7. package/dist/assembly/canvas-draw-guard.d.ts.map +1 -0
  8. package/dist/assembly/cloud-shadow-entry.d.ts +4 -0
  9. package/dist/assembly/cloud-shadow-entry.d.ts.map +1 -0
  10. package/dist/assembly/device-feature-admission.d.ts +2 -2
  11. package/dist/assembly/dynamic-geometry-host.d.ts +4 -1
  12. package/dist/assembly/dynamic-geometry-host.d.ts.map +1 -1
  13. package/dist/assembly/dynamic-geometry-runtime.d.ts +1 -1
  14. package/dist/assembly/dynamic-geometry-runtime.d.ts.map +1 -1
  15. package/dist/assembly/factory.d.ts +1 -1
  16. package/dist/assembly/factory.d.ts.map +1 -1
  17. package/dist/assembly/host-contract.d.ts +6 -5
  18. package/dist/assembly/host-contract.d.ts.map +1 -1
  19. package/dist/assembly/material/assembly.d.ts.map +1 -1
  20. package/dist/assembly/material/pipeline-helpers.d.ts +5 -0
  21. package/dist/assembly/material/pipeline-helpers.d.ts.map +1 -1
  22. package/dist/assembly/material-shader-policy.d.ts +16 -2
  23. package/dist/assembly/material-shader-policy.d.ts.map +1 -1
  24. package/dist/assembly/material-shader-prewarm.d.ts.map +1 -1
  25. package/dist/assembly/recovery/device-loss-fanout.d.ts.map +1 -1
  26. package/dist/assembly/recovery/renderer-recover.d.ts +2 -0
  27. package/dist/assembly/recovery/renderer-recover.d.ts.map +1 -1
  28. package/dist/assembly/render-feature-post-processes.d.ts +6 -0
  29. package/dist/assembly/render-feature-post-processes.d.ts.map +1 -0
  30. package/dist/assembly/render-target-host.d.ts +5 -0
  31. package/dist/assembly/render-target-host.d.ts.map +1 -1
  32. package/dist/assembly/renderer-facade.d.ts.map +1 -1
  33. package/dist/assembly/renderer-feature-inspection.d.ts +1 -1
  34. package/dist/assembly/renderer-feature-inspection.d.ts.map +1 -1
  35. package/dist/assembly/renderer-frame-transaction.d.ts +12 -0
  36. package/dist/assembly/renderer-frame-transaction.d.ts.map +1 -1
  37. package/dist/assembly/renderer-inspection.d.ts +11 -0
  38. package/dist/assembly/renderer-inspection.d.ts.map +1 -1
  39. package/dist/assembly/webgpu-pbr-ready.d.ts +1 -0
  40. package/dist/assembly/webgpu-pbr-ready.d.ts.map +1 -1
  41. package/dist/assembly/webgpu-ready-per-pass.d.ts +39 -0
  42. package/dist/assembly/webgpu-ready-per-pass.d.ts.map +1 -0
  43. package/dist/assembly/webgpu-ready.d.ts +1 -1
  44. package/dist/assembly/webgpu-ready.d.ts.map +1 -1
  45. package/dist/assembly/webgpu-renderer-bootstrap.d.ts.map +1 -1
  46. package/dist/assembly/webgpu-renderer-observation-owner.d.ts +35 -0
  47. package/dist/assembly/webgpu-renderer-observation-owner.d.ts.map +1 -0
  48. package/dist/assembly/webgpu-renderer.d.ts +2 -1
  49. package/dist/assembly/webgpu-renderer.d.ts.map +1 -1
  50. package/dist/authoring.mjs +2 -4
  51. package/dist/authoring.mjs.map +1 -1
  52. package/dist/barrel-distortion.d.ts +47 -0
  53. package/dist/barrel-distortion.d.ts.map +1 -0
  54. package/dist/chunk-3XUBWRY2.mjs +1842 -0
  55. package/dist/chunk-3XUBWRY2.mjs.map +1 -0
  56. package/dist/{chunk-OO3DRYK7.mjs → chunk-G6HDNGY7.mjs} +2400 -1767
  57. package/dist/chunk-G6HDNGY7.mjs.map +1 -0
  58. package/dist/{chunk-ZDQWGQW7.mjs → chunk-LM5IE7GF.mjs} +4 -4
  59. package/dist/{chunk-ZDQWGQW7.mjs.map → chunk-LM5IE7GF.mjs.map} +1 -1
  60. package/dist/{chunk-VOZWDM3L.mjs → chunk-LNIUIKQ7.mjs} +1514 -498
  61. package/dist/chunk-LNIUIKQ7.mjs.map +1 -0
  62. package/dist/chunk-MXTWKZO4.mjs +3268 -0
  63. package/dist/chunk-MXTWKZO4.mjs.map +1 -0
  64. package/dist/chunk-MZ4C7EHF.mjs +6942 -0
  65. package/dist/chunk-MZ4C7EHF.mjs.map +1 -0
  66. package/dist/chunk-RIPAEGI6.mjs +48 -0
  67. package/dist/chunk-RIPAEGI6.mjs.map +1 -0
  68. package/dist/{chunk-LEAXOMYJ.mjs → chunk-SGPUJW3F.mjs} +117 -5
  69. package/dist/chunk-SGPUJW3F.mjs.map +1 -0
  70. package/dist/{chunk-PA5DRJNI.mjs → chunk-X2KA6WHM.mjs} +29 -4
  71. package/dist/chunk-X2KA6WHM.mjs.map +1 -0
  72. package/dist/{chunk-BLXGONR2.mjs → chunk-XSFB7XXQ.mjs} +51 -4
  73. package/dist/chunk-XSFB7XXQ.mjs.map +1 -0
  74. package/dist/cloud/density.d.ts +55 -0
  75. package/dist/cloud/density.d.ts.map +1 -0
  76. package/dist/cloud/extract.d.ts +25 -0
  77. package/dist/cloud/extract.d.ts.map +1 -0
  78. package/dist/cloud/feature.d.ts +57 -0
  79. package/dist/cloud/feature.d.ts.map +1 -0
  80. package/dist/cloud/frame-context.d.ts +8 -0
  81. package/dist/cloud/frame-context.d.ts.map +1 -0
  82. package/dist/cloud/inspection.d.ts +59 -0
  83. package/dist/cloud/inspection.d.ts.map +1 -0
  84. package/dist/cloud/optics.d.ts +56 -0
  85. package/dist/cloud/optics.d.ts.map +1 -0
  86. package/dist/cloud/parameters.d.ts +73 -0
  87. package/dist/cloud/parameters.d.ts.map +1 -0
  88. package/dist/cloud/resources.d.ts +60 -0
  89. package/dist/cloud/resources.d.ts.map +1 -0
  90. package/dist/cloud/shadow.d.ts +42 -0
  91. package/dist/cloud/shadow.d.ts.map +1 -0
  92. package/dist/cloud/temporal.d.ts +74 -0
  93. package/dist/cloud/temporal.d.ts.map +1 -0
  94. package/dist/components/barrel-distortion.d.ts +13 -0
  95. package/dist/components/barrel-distortion.d.ts.map +1 -0
  96. package/dist/components/cloud-layer.d.ts +29 -0
  97. package/dist/components/cloud-layer.d.ts.map +1 -0
  98. package/dist/components/index.d.ts +2 -0
  99. package/dist/components/index.d.ts.map +1 -1
  100. package/dist/components/instances.d.ts +20 -6
  101. package/dist/components/instances.d.ts.map +1 -1
  102. package/dist/construct-renderer.d.ts +1 -1
  103. package/dist/construct-renderer.d.ts.map +1 -1
  104. package/dist/construct-renderer.mjs +8406 -5785
  105. package/dist/construct-renderer.mjs.map +1 -1
  106. package/dist/device/gpu-residency.d.ts +19 -19
  107. package/dist/device/gpu-residency.d.ts.map +1 -1
  108. package/dist/dynamic-geometry.d.ts +5 -1
  109. package/dist/dynamic-geometry.d.ts.map +1 -1
  110. package/dist/errors/cloud.d.ts +59 -0
  111. package/dist/errors/cloud.d.ts.map +1 -0
  112. package/dist/errors/render.d.ts +20 -5
  113. package/dist/errors/render.d.ts.map +1 -1
  114. package/dist/examples/single-layer-medium-surface.d.ts +47 -0
  115. package/dist/examples/single-layer-medium-surface.d.ts.map +1 -0
  116. package/dist/extract/camera.d.ts.map +1 -1
  117. package/dist/extract/contracts.d.ts +5 -1
  118. package/dist/extract/contracts.d.ts.map +1 -1
  119. package/dist/extract/material-context.d.ts +7 -0
  120. package/dist/extract/material-context.d.ts.map +1 -0
  121. package/dist/features/barrel-distortion.d.ts +29 -0
  122. package/dist/features/barrel-distortion.d.ts.map +1 -0
  123. package/dist/features/error-reporting.d.ts +6 -2
  124. package/dist/features/error-reporting.d.ts.map +1 -1
  125. package/dist/features/host.d.ts +15 -0
  126. package/dist/features/host.d.ts.map +1 -1
  127. package/dist/features/plan.d.ts +10 -0
  128. package/dist/features/plan.d.ts.map +1 -1
  129. package/dist/features/render-graph-contribution.d.ts +5 -0
  130. package/dist/features/render-graph-contribution.d.ts.map +1 -1
  131. package/dist/features/render-graph-raster.d.ts +1 -0
  132. package/dist/features/render-graph-raster.d.ts.map +1 -1
  133. package/dist/features/targets.d.ts +2 -0
  134. package/dist/features/targets.d.ts.map +1 -1
  135. package/dist/features/types.d.ts +48 -0
  136. package/dist/features/types.d.ts.map +1 -1
  137. package/dist/fullscreen-post-process-pass.d.ts +15 -7
  138. package/dist/fullscreen-post-process-pass.d.ts.map +1 -1
  139. package/dist/glyph-text-layout-system.d.ts +1 -1
  140. package/dist/glyph-text-layout-system.d.ts.map +1 -1
  141. package/dist/gpu-dirty-ranges.d.ts +11 -0
  142. package/dist/gpu-dirty-ranges.d.ts.map +1 -0
  143. package/dist/gpu-driven/batch-topology.d.ts +17 -0
  144. package/dist/gpu-driven/batch-topology.d.ts.map +1 -1
  145. package/dist/gpu-driven/material-artifacts.d.ts +6 -0
  146. package/dist/gpu-driven/material-artifacts.d.ts.map +1 -1
  147. package/dist/gpu-driven/prepared-draw.d.ts.map +1 -1
  148. package/dist/gpu-driven/production-raster-material.d.ts +178 -0
  149. package/dist/gpu-driven/production-raster-material.d.ts.map +1 -0
  150. package/dist/gpu-driven/production-raster.d.ts +47 -3
  151. package/dist/gpu-driven/production-raster.d.ts.map +1 -1
  152. package/dist/gpu-driven/resource-allocation.d.ts +31 -0
  153. package/dist/gpu-driven/resource-allocation.d.ts.map +1 -0
  154. package/dist/gpu-driven/shadow-ownership.d.ts +14 -0
  155. package/dist/gpu-driven/shadow-ownership.d.ts.map +1 -0
  156. package/dist/gpu-driven/view-gpu.d.ts +26 -2
  157. package/dist/gpu-driven/view-gpu.d.ts.map +1 -1
  158. package/dist/gpu-scene.d.ts +5 -0
  159. package/dist/gpu-scene.d.ts.map +1 -1
  160. package/dist/hdrp-buffers.d.ts +2 -2
  161. package/dist/hdrp-buffers.d.ts.map +1 -1
  162. package/dist/ibl/frame-resources.d.ts.map +1 -1
  163. package/dist/ibl/skylight-bind-group.d.ts +14 -5
  164. package/dist/ibl/skylight-bind-group.d.ts.map +1 -1
  165. package/dist/index.d.ts +30 -7
  166. package/dist/index.d.ts.map +1 -1
  167. package/dist/index.mjs +780 -9
  168. package/dist/index.mjs.map +1 -1
  169. package/dist/inspection-types.d.ts +135 -1
  170. package/dist/inspection-types.d.ts.map +1 -1
  171. package/dist/instance-buffer-cache.d.ts +4 -4
  172. package/dist/instance-buffer-cache.d.ts.map +1 -1
  173. package/dist/instances.d.ts +47 -100
  174. package/dist/instances.d.ts.map +1 -1
  175. package/dist/internal.mjs +7 -8
  176. package/dist/internal.mjs.map +1 -1
  177. package/dist/pbr-pipeline.d.ts +22 -4
  178. package/dist/pbr-pipeline.d.ts.map +1 -1
  179. package/dist/pipeline/single-layer-medium-passes.d.ts +73 -0
  180. package/dist/pipeline/single-layer-medium-passes.d.ts.map +1 -0
  181. package/dist/pipeline/standard-forward-lane.d.ts.map +1 -1
  182. package/dist/pipeline/standard-output/graph.d.ts.map +1 -1
  183. package/dist/pipeline/standard-output/lut-gpu.d.ts +2 -2
  184. package/dist/pipeline/standard-output/lut-gpu.d.ts.map +1 -1
  185. package/dist/pipeline/standard-output/resources.d.ts +2 -2
  186. package/dist/pipeline/standard-output/resources.d.ts.map +1 -1
  187. package/dist/pipeline/standard-output/types.d.ts +4 -2
  188. package/dist/pipeline/standard-output/types.d.ts.map +1 -1
  189. package/dist/pipeline/standard-pipeline.d.ts.map +1 -1
  190. package/dist/pipeline/standard-post.d.ts.map +1 -1
  191. package/dist/pipeline-builder.d.ts +1 -1
  192. package/dist/pipeline-builder.d.ts.map +1 -1
  193. package/dist/plugin.d.ts.map +1 -1
  194. package/dist/prepare/prepared-graphics-resolver.d.ts +2 -0
  195. package/dist/prepare/prepared-graphics-resolver.d.ts.map +1 -1
  196. package/dist/publication/contract.d.ts +77 -0
  197. package/dist/publication/contract.d.ts.map +1 -0
  198. package/dist/publication/dependencies.d.ts +7 -0
  199. package/dist/publication/dependencies.d.ts.map +1 -0
  200. package/dist/publication/prepare-geometry.d.ts +9 -0
  201. package/dist/publication/prepare-geometry.d.ts.map +1 -0
  202. package/dist/publication/programs.d.ts +5 -0
  203. package/dist/publication/programs.d.ts.map +1 -0
  204. package/dist/publication/publisher.d.ts +33 -0
  205. package/dist/publication/publisher.d.ts.map +1 -0
  206. package/dist/publication/receiver.d.ts +29 -0
  207. package/dist/publication/receiver.d.ts.map +1 -0
  208. package/dist/publication/resource-scope.d.ts +18 -0
  209. package/dist/publication/resource-scope.d.ts.map +1 -0
  210. package/dist/publication/targets.d.ts +33 -0
  211. package/dist/publication/targets.d.ts.map +1 -0
  212. package/dist/publication/video.d.ts +5 -0
  213. package/dist/publication/video.d.ts.map +1 -0
  214. package/dist/record/barrel-distortion-frame.d.ts +15 -0
  215. package/dist/record/barrel-distortion-frame.d.ts.map +1 -0
  216. package/dist/record/dynamic-geometry-consumption.d.ts +10 -2
  217. package/dist/record/dynamic-geometry-consumption.d.ts.map +1 -1
  218. package/dist/record/fold-buckets.d.ts +95 -0
  219. package/dist/record/fold-buckets.d.ts.map +1 -0
  220. package/dist/record/fold-instance-buffer.d.ts +6 -0
  221. package/dist/record/fold-instance-buffer.d.ts.map +1 -0
  222. package/dist/record/frame-lighting.d.ts +1 -0
  223. package/dist/record/frame-lighting.d.ts.map +1 -1
  224. package/dist/record/frame-snapshot.d.ts +43 -9
  225. package/dist/record/frame-snapshot.d.ts.map +1 -1
  226. package/dist/record/frame.d.ts +15 -65
  227. package/dist/record/frame.d.ts.map +1 -1
  228. package/dist/record/gpu-draw-receipts.d.ts +11 -0
  229. package/dist/record/gpu-draw-receipts.d.ts.map +1 -0
  230. package/dist/record/gpu-timing.d.ts +8 -0
  231. package/dist/record/gpu-timing.d.ts.map +1 -1
  232. package/dist/record/helpers.d.ts +2 -2
  233. package/dist/record/helpers.d.ts.map +1 -1
  234. package/dist/record/main-pass-geometry.d.ts +22 -6
  235. package/dist/record/main-pass-geometry.d.ts.map +1 -1
  236. package/dist/record/main-pass-material.d.ts +14 -10
  237. package/dist/record/main-pass-material.d.ts.map +1 -1
  238. package/dist/record/main-pass-sprite-draws.d.ts +3 -16
  239. package/dist/record/main-pass-sprite-draws.d.ts.map +1 -1
  240. package/dist/record/main-pass.d.ts +13 -2
  241. package/dist/record/main-pass.d.ts.map +1 -1
  242. package/dist/record/motion-blur-receipt.d.ts +11 -0
  243. package/dist/record/motion-blur-receipt.d.ts.map +1 -0
  244. package/dist/record/prepared-material-bindings.d.ts +3 -3
  245. package/dist/record/prepared-material-bindings.d.ts.map +1 -1
  246. package/dist/record/probe-blend-buffer.d.ts +16 -0
  247. package/dist/record/probe-blend-buffer.d.ts.map +1 -0
  248. package/dist/record/recovery-pipeline.d.ts.map +1 -1
  249. package/dist/record/render-context.d.ts +24 -5
  250. package/dist/record/render-context.d.ts.map +1 -1
  251. package/dist/record/shadow-pass.d.ts +2 -0
  252. package/dist/record/shadow-pass.d.ts.map +1 -1
  253. package/dist/record/skybox-post-pass.d.ts +1 -1
  254. package/dist/record/skybox-post-pass.d.ts.map +1 -1
  255. package/dist/record/sprite-instance-buffer.d.ts +31 -0
  256. package/dist/record/sprite-instance-buffer.d.ts.map +1 -0
  257. package/dist/record/target-capture-graph.d.ts +19 -0
  258. package/dist/record/target-capture-graph.d.ts.map +1 -0
  259. package/dist/record/typed-frame-graph.d.ts +24 -15
  260. package/dist/record/typed-frame-graph.d.ts.map +1 -1
  261. package/dist/record/view-ubo.d.ts +11 -3
  262. package/dist/record/view-ubo.d.ts.map +1 -1
  263. package/dist/record/volume-params.d.ts +9 -0
  264. package/dist/record/volume-params.d.ts.map +1 -0
  265. package/dist/recovery/render-system-candidate.d.ts +14 -4
  266. package/dist/recovery/render-system-candidate.d.ts.map +1 -1
  267. package/dist/reflection/record-owner.d.ts.map +1 -1
  268. package/dist/render-contract.d.ts +46 -5
  269. package/dist/render-contract.d.ts.map +1 -1
  270. package/dist/render-graph-primitives.d.ts.map +1 -1
  271. package/dist/render-pipeline.d.ts +103 -2
  272. package/dist/render-pipeline.d.ts.map +1 -1
  273. package/dist/render-system-extract-tail.d.ts +3 -2
  274. package/dist/render-system-extract-tail.d.ts.map +1 -1
  275. package/dist/render-system-extract.d.ts +18 -9
  276. package/dist/render-system-extract.d.ts.map +1 -1
  277. package/dist/render-system-presentation.d.ts +23 -0
  278. package/dist/render-system-presentation.d.ts.map +1 -0
  279. package/dist/render-system-producer-roots.d.ts +10 -0
  280. package/dist/render-system-producer-roots.d.ts.map +1 -0
  281. package/dist/render-system-projections.d.ts +3 -2
  282. package/dist/render-system-projections.d.ts.map +1 -1
  283. package/dist/render-system-residency.d.ts +12 -0
  284. package/dist/render-system-residency.d.ts.map +1 -0
  285. package/dist/render-system.d.ts +22 -21
  286. package/dist/render-system.d.ts.map +1 -1
  287. package/dist/scene/probe-blend.d.ts +27 -0
  288. package/dist/scene/probe-blend.d.ts.map +1 -1
  289. package/dist/scene/render-scene.d.ts +18 -7
  290. package/dist/scene/render-scene.d.ts.map +1 -1
  291. package/dist/scene/render-source.d.ts +42 -0
  292. package/dist/scene/render-source.d.ts.map +1 -0
  293. package/dist/scene/source-systems.d.ts +6 -0
  294. package/dist/scene/source-systems.d.ts.map +1 -0
  295. package/dist/ssao-buffers.d.ts +9 -0
  296. package/dist/ssao-buffers.d.ts.map +1 -1
  297. package/dist/surface/dynamic-input.d.ts +133 -0
  298. package/dist/surface/dynamic-input.d.ts.map +1 -0
  299. package/dist/surface/gpu-driven.d.ts +41 -0
  300. package/dist/surface/gpu-driven.d.ts.map +1 -0
  301. package/dist/surface/submission-observation.d.ts +136 -0
  302. package/dist/surface/submission-observation.d.ts.map +1 -0
  303. package/dist/systems/skin-palette-allocator.d.ts.map +1 -1
  304. package/dist/systems/skin-palette-types.d.ts +10 -0
  305. package/dist/systems/skin-palette-types.d.ts.map +1 -1
  306. package/dist/systems/transparent-dispatch.d.ts +2 -2
  307. package/dist/systems/transparent-dispatch.d.ts.map +1 -1
  308. package/dist/systems/transparent-sort-config.d.ts +2 -1
  309. package/dist/systems/transparent-sort-config.d.ts.map +1 -1
  310. package/dist/temporal/gpu.d.ts +13 -1
  311. package/dist/temporal/gpu.d.ts.map +1 -1
  312. package/dist/temporal/index.mjs +6 -7
  313. package/dist/temporal/inspection.d.ts.map +1 -1
  314. package/dist/temporal/standard-scene-data.d.ts.map +1 -1
  315. package/dist/temporal/target-coverage-attachment.d.ts.map +1 -1
  316. package/dist/transmission/single-layer-medium.d.ts +89 -0
  317. package/dist/transmission/single-layer-medium.d.ts.map +1 -0
  318. package/dist/typed-render-graph-primitives.d.ts +14 -2
  319. package/dist/typed-render-graph-primitives.d.ts.map +1 -1
  320. package/dist/volume/component.d.ts +9 -4
  321. package/dist/volume/component.d.ts.map +1 -1
  322. package/dist/volume/extract.d.ts +1 -1
  323. package/dist/volume/extract.d.ts.map +1 -1
  324. package/dist/volume/inspection.d.ts +2 -0
  325. package/dist/volume/inspection.d.ts.map +1 -1
  326. package/dist/volume/passes.d.ts +4 -1
  327. package/dist/volume/passes.d.ts.map +1 -1
  328. package/dist/volume/resources.d.ts.map +1 -1
  329. package/package.json +22 -21
  330. package/src/__tests__/atmosphere-daylight.dawn.test.ts +72 -0
  331. package/src/__tests__/auto-exposure-transaction.integration.test.ts +4 -9
  332. package/src/__tests__/barrel-distortion-lkg.integration.test.ts +353 -0
  333. package/src/__tests__/barrel-distortion.dawn.test.ts +41 -0
  334. package/src/__tests__/barrel-distortion.unit.test.ts +364 -0
  335. package/src/__tests__/construct-renderer-identity.unit.test.ts +49 -0
  336. package/src/__tests__/detached-recovery-graph.unit.test.ts +277 -0
  337. package/src/__tests__/device-feature-admission.unit.test.ts +3 -2
  338. package/src/__tests__/device-loss-fanout.unit.test.ts +36 -1
  339. package/src/__tests__/docs-gate-green.unit.test.ts +112 -1
  340. package/src/__tests__/factory-contract.integration.test.ts +295 -45
  341. package/src/__tests__/feature-depth-input.dawn.test.ts +129 -2
  342. package/src/__tests__/fullscreen-feature-plan.unit.test.ts +14 -3
  343. package/src/__tests__/gpu-dirty-ranges.unit.test.ts +22 -0
  344. package/src/__tests__/gpu-driven-baseline.characterization.test.ts +16 -3
  345. package/src/__tests__/gpu-driven-batch-topology-pbr.unit.test.ts +12 -0
  346. package/src/__tests__/gpu-driven-material-artifacts.unit.test.ts +143 -0
  347. package/src/__tests__/gpu-driven-pbr.dawn.test.ts +5 -6
  348. package/src/__tests__/gpu-driven-production.integration.test.ts +482 -3
  349. package/src/__tests__/gpu-driven-shadow-views.dawn.test.ts +6 -5
  350. package/src/__tests__/gpu-driven-view-gpu-evidence.ts +94 -6
  351. package/src/__tests__/gpu-driven-view-graph.integration.test.ts +18 -2
  352. package/src/__tests__/gpu-driven-view.browser.test.ts +5 -8
  353. package/src/__tests__/gpu-driven-view.dawn.test.ts +6 -2
  354. package/src/__tests__/gpu-driven-view.unit.test.ts +1 -1
  355. package/src/__tests__/gpu-pass-timing-lifecycle.integration.test.ts +1 -0
  356. package/src/__tests__/gpu-pass-timing.browser.test.ts +6 -4
  357. package/src/__tests__/gpu-pass-timing.rhi-null.unit.test.ts +1 -0
  358. package/src/__tests__/gpu-scene.unit.test.ts +119 -9
  359. package/src/__tests__/instance-allocation-failure.unit.test.ts +57 -0
  360. package/src/__tests__/instances-culling.integration.test.ts +10 -36
  361. package/src/__tests__/instances-store.unit.test.ts +97 -305
  362. package/src/__tests__/instances-world-ownership.integration.test.ts +62 -0
  363. package/src/__tests__/ktx2-basis-gpu-consumer.dawn.test.ts +4 -1
  364. package/src/__tests__/main-pass-material-medium-selection.unit.test.ts +145 -0
  365. package/src/__tests__/material-shader-prewarm.unit.test.ts +59 -0
  366. package/src/__tests__/material-snapshot-mutation.integration.test.ts +39 -1
  367. package/src/__tests__/materials-standard-contract.unit.test.ts +0 -1
  368. package/src/__tests__/morph-culling-reentry.dawn.test.ts +5 -5
  369. package/src/__tests__/morph-visual-evidence.integration.test.ts +8 -7
  370. package/src/__tests__/motion-blur-compute.dawn.test.ts +13 -7
  371. package/src/__tests__/motion-blur.pixel.integration.test.ts +2 -2
  372. package/src/__tests__/nineslice-handle-surface.unit.test.ts +4 -4
  373. package/src/__tests__/pbr-view-layout.unit.test.ts +9 -0
  374. package/src/__tests__/physical-clearcoat.integration.test.ts +66 -8
  375. package/src/__tests__/physical-material-budget.unit.test.ts +40 -0
  376. package/src/__tests__/prepared-graphics-capability.unit.test.ts +66 -2
  377. package/src/__tests__/probe-bindings.unit.test.ts +582 -1
  378. package/src/__tests__/probe-scene-dirty.integration.test.ts +28 -1
  379. package/src/__tests__/receipt-observation-retirement.unit.test.ts +65 -0
  380. package/src/__tests__/recovery-candidate-prepare.contract.test.ts +69 -0
  381. package/src/__tests__/render-error-code-owner.test-d.ts +8 -0
  382. package/src/__tests__/render-feature-diagnostics.unit.test.ts +15 -2
  383. package/src/__tests__/render-feature-error-reporting.unit.test.ts +21 -1
  384. package/src/__tests__/render-feature-prepared-diagnostics.unit.test.ts +10 -1
  385. package/src/__tests__/render-feature-retry.unit.test.ts +12 -1
  386. package/src/__tests__/render-scene-mixed-updates.integration.test.ts +145 -19
  387. package/src/__tests__/render-scene-projection.unit.test.ts +36 -11
  388. package/src/__tests__/render-scene-temporal-retry.unit.test.ts +20 -20
  389. package/src/__tests__/render-target-probe-soak.perf.test.ts +2 -2
  390. package/src/__tests__/render-temporal-environment-consumer.browser.test.ts +3 -3
  391. package/src/__tests__/render-temporal-environment-consumer.dawn.test.ts +5 -2
  392. package/src/__tests__/renderer-factory-material-contract.unit.test.ts +42 -8
  393. package/src/__tests__/renderer-frame-generation-fence.integration.test.ts +16 -0
  394. package/src/__tests__/renderer-frame-transaction.integration.test.ts +26 -10
  395. package/src/__tests__/resource-allocation.unit.test.ts +123 -0
  396. package/src/__tests__/single-layer-medium-passes.unit.test.ts +275 -0
  397. package/src/__tests__/skin-motion-regression.unit.test.ts +70 -1
  398. package/src/__tests__/skin-palette-recycling.dawn.test.ts +97 -0
  399. package/src/__tests__/skinned-shadow-caster.test.ts +15 -0
  400. package/src/__tests__/ssr-carrier-public-contract.unit.test.ts +21 -0
  401. package/src/__tests__/ssr-gpu-dispatch.browser.test.ts +4 -4
  402. package/src/__tests__/ssr-gpu-dispatch.dawn.test.ts +2 -2
  403. package/src/__tests__/ssr-gpu-dispatch.ts +1 -1
  404. package/src/__tests__/ssr-receiver-coverage.dawn.test.ts +6 -2
  405. package/src/__tests__/standard-output-chain-contract.unit.test.ts +28 -0
  406. package/src/__tests__/standard-pbr-artifact-assembly.unit.test.ts +46 -1
  407. package/src/__tests__/standard-pipeline.integration.test.ts +182 -1
  408. package/src/__tests__/surface-dynamic-buffer-lifecycle.unit.test.ts +506 -0
  409. package/src/__tests__/surface-submission-observation.unit.test.ts +812 -0
  410. package/src/__tests__/temporal-history-lifecycle.unit.test.ts +32 -0
  411. package/src/__tests__/temporal-performance.integration.test.ts +3 -3
  412. package/src/__tests__/visibility-instances.integration.test.ts +7 -19
  413. package/src/__tests__/visibility-producer-matrix.integration.test.ts +9 -20
  414. package/src/__tests__/volume-optics-oracle.unit.test.ts +4 -2
  415. package/src/__tests__/volumetric-fog-budget-recovery.integration.test.ts +30 -20
  416. package/src/__tests__/volumetric-fog-errors.unit.test.ts +4 -3
  417. package/src/__tests__/volumetric-fog-multiple.unit.test.ts +55 -0
  418. package/src/__tests__/volumetric-fog-spot-frame-optics.integration.test.ts +1 -1
  419. package/src/__tests__/volumetric-fog-stage-readback.dawn.test.ts +113 -9
  420. package/src/__tests__/volumetric-fog-topology.unit.test.ts +5 -3
  421. package/src/assembly/backend-contract.ts +30 -0
  422. package/src/assembly/barrel-distortion-inspection.ts +22 -0
  423. package/src/assembly/canvas-draw-guard.ts +11 -0
  424. package/src/assembly/cloud-shadow-entry.ts +22 -0
  425. package/src/assembly/device-feature-admission.ts +2 -2
  426. package/src/assembly/dynamic-geometry-host.ts +65 -37
  427. package/src/assembly/dynamic-geometry-runtime.ts +7 -1
  428. package/src/assembly/factory.ts +2 -30
  429. package/src/assembly/host-contract.ts +8 -5
  430. package/src/assembly/material/assembly.ts +25 -13
  431. package/src/assembly/material/pipeline-helpers.ts +53 -12
  432. package/src/assembly/material-shader-policy.ts +55 -0
  433. package/src/assembly/material-shader-prewarm.ts +21 -10
  434. package/src/assembly/recovery/device-loss-fanout.ts +13 -0
  435. package/src/assembly/recovery/renderer-recover.ts +50 -18
  436. package/src/assembly/render-feature-post-processes.ts +54 -0
  437. package/src/assembly/render-target-host.ts +57 -47
  438. package/src/assembly/renderer-facade.ts +7 -2
  439. package/src/assembly/renderer-feature-inspection.ts +8 -2
  440. package/src/assembly/renderer-frame-transaction.ts +23 -0
  441. package/src/assembly/renderer-inspection.ts +28 -0
  442. package/src/assembly/skin-palette-owner.ts +1 -1
  443. package/src/assembly/temporal-post-process-prewarm.ts +3 -3
  444. package/src/assembly/webgpu-pbr-ready.ts +9 -1
  445. package/src/assembly/webgpu-ready-per-pass.ts +104 -0
  446. package/src/assembly/webgpu-ready.ts +116 -62
  447. package/src/assembly/webgpu-renderer-bootstrap.ts +0 -12
  448. package/src/assembly/webgpu-renderer-observation-owner.ts +222 -0
  449. package/src/assembly/webgpu-renderer.ts +303 -313
  450. package/src/assembly/webgpu-vertex-layouts.ts +1 -1
  451. package/src/barrel-distortion.ts +247 -0
  452. package/src/cloud/__tests__/cloud-density-parity.dawn.test.ts +173 -0
  453. package/src/cloud/__tests__/cloud-layer-framebuffer-y.dawn.test.ts +265 -0
  454. package/src/cloud/__tests__/cloud-layer.browser.test.ts +432 -0
  455. package/src/cloud/__tests__/cloud-layer.unit.test.ts +634 -0
  456. package/src/cloud/density.ts +600 -0
  457. package/src/cloud/extract.ts +110 -0
  458. package/src/cloud/feature.ts +1810 -0
  459. package/src/cloud/frame-context.ts +42 -0
  460. package/src/cloud/inspection.ts +130 -0
  461. package/src/cloud/optics.ts +285 -0
  462. package/src/cloud/parameters.ts +255 -0
  463. package/src/cloud/resources.ts +122 -0
  464. package/src/cloud/shadow.ts +167 -0
  465. package/src/cloud/temporal.ts +226 -0
  466. package/src/components/barrel-distortion.ts +46 -0
  467. package/src/components/cloud-layer.ts +47 -0
  468. package/src/components/index.ts +2 -0
  469. package/src/components/instances.ts +18 -45
  470. package/src/components/sprite-instances.ts +1 -1
  471. package/src/construct-renderer.ts +1 -1
  472. package/src/device/gpu-residency.ts +26 -25
  473. package/src/dynamic-geometry.ts +12 -1
  474. package/src/errors/cloud.ts +103 -0
  475. package/src/errors/render.ts +47 -8
  476. package/src/examples/single-layer-medium-surface.ts +59 -0
  477. package/src/extract/camera.ts +15 -1
  478. package/src/extract/contracts.ts +5 -0
  479. package/src/extract/material-context.ts +21 -0
  480. package/src/features/barrel-distortion.ts +172 -0
  481. package/src/features/error-reporting.ts +26 -6
  482. package/src/features/host.ts +128 -19
  483. package/src/features/plan.ts +10 -0
  484. package/src/features/render-graph-contribution.ts +9 -0
  485. package/src/features/render-graph-raster.ts +45 -3
  486. package/src/features/targets.ts +66 -0
  487. package/src/features/types.ts +51 -0
  488. package/src/fullscreen-post-process-pass.ts +41 -9
  489. package/src/glyph-text-layout-system.ts +2 -2
  490. package/src/gpu-dirty-ranges.ts +48 -0
  491. package/src/gpu-driven/batch-topology.ts +53 -0
  492. package/src/gpu-driven/material-artifacts.ts +33 -25
  493. package/src/gpu-driven/prepared-draw.ts +12 -4
  494. package/src/gpu-driven/production-raster-material.ts +1894 -0
  495. package/src/gpu-driven/production-raster.ts +825 -784
  496. package/src/gpu-driven/resource-allocation.ts +142 -0
  497. package/src/gpu-driven/shadow-ownership.ts +71 -0
  498. package/src/gpu-driven/view-gpu.ts +164 -10
  499. package/src/gpu-scene.ts +75 -84
  500. package/src/hdrp-buffers.ts +4 -3
  501. package/src/ibl/frame-resources.ts +0 -1
  502. package/src/ibl/skylight-bind-group.ts +62 -32
  503. package/src/index.ts +205 -9
  504. package/src/inspection-types.ts +162 -0
  505. package/src/instance-buffer-cache.ts +4 -4
  506. package/src/instances.ts +152 -569
  507. package/src/pbr-pipeline.ts +230 -30
  508. package/src/pipeline/single-layer-medium-passes.ts +267 -0
  509. package/src/pipeline/standard-forward-lane.ts +313 -57
  510. package/src/pipeline/standard-output/graph.ts +8 -2
  511. package/src/pipeline/standard-output/lut-gpu.ts +3 -3
  512. package/src/pipeline/standard-output/resources.ts +2 -2
  513. package/src/pipeline/standard-output/types.ts +12 -1
  514. package/src/pipeline/standard-pipeline.ts +291 -18
  515. package/src/pipeline/standard-post.ts +90 -24
  516. package/src/pipeline-builder.ts +1 -1
  517. package/src/plugin.ts +4 -0
  518. package/src/points-lines/__tests__/points-lines.bench.ts +17 -8
  519. package/src/prepare/prepared-graphics-resolver.ts +2 -0
  520. package/src/publication/__tests__/derived-geometry.integration.test.ts +177 -0
  521. package/src/publication/__tests__/features.integration.test.ts +122 -0
  522. package/src/publication/__tests__/programs.unit.test.ts +25 -0
  523. package/src/publication/__tests__/publication.integration.test.ts +370 -0
  524. package/src/publication/__tests__/targets.integration.test.ts +120 -0
  525. package/src/publication/__tests__/video.browser.test.ts +50 -0
  526. package/src/publication/contract.ts +104 -0
  527. package/src/publication/dependencies.ts +54 -0
  528. package/src/publication/prepare-geometry.ts +94 -0
  529. package/src/publication/programs.ts +45 -0
  530. package/src/publication/publisher.ts +618 -0
  531. package/src/publication/receiver.ts +297 -0
  532. package/src/publication/resource-scope.ts +31 -0
  533. package/src/publication/targets.ts +182 -0
  534. package/src/publication/video.ts +33 -0
  535. package/src/record/__tests__/main-pass-geometry.unit.test.ts +30 -0
  536. package/src/record/__tests__/material-bg-cache.unit.test.ts +15 -1
  537. package/src/record/__tests__/sprite-material-abi.unit.test.ts +9 -11
  538. package/src/record/__tests__/temporal-payload.unit.test.ts +1 -1
  539. package/src/record/__tests__/transparent-group2-selection.unit.test.ts +11 -0
  540. package/src/record/__tests__/typed-frame-graph-plan.unit.test.ts +1 -0
  541. package/src/record/__tests__/video-texture-view.unit.test.ts +9 -9
  542. package/src/record/__tests__/view-ubo-layout.unit.test.ts +4 -3
  543. package/src/record/barrel-distortion-frame.ts +110 -0
  544. package/src/record/dynamic-geometry-consumption.ts +39 -9
  545. package/src/record/fold-buckets.ts +855 -0
  546. package/src/record/fold-instance-buffer.ts +51 -0
  547. package/src/record/frame-lighting.ts +36 -2
  548. package/src/record/frame-snapshot.ts +45 -9
  549. package/src/record/frame.ts +258 -1105
  550. package/src/record/gpu-draw-receipts.ts +38 -0
  551. package/src/record/gpu-timing.ts +48 -5
  552. package/src/record/helpers.ts +2 -2
  553. package/src/record/main-pass-geometry.ts +272 -84
  554. package/src/record/main-pass-material.ts +102 -36
  555. package/src/record/main-pass-sprite-draws.ts +13 -217
  556. package/src/record/main-pass.ts +164 -27
  557. package/src/record/motion-blur-receipt.ts +91 -0
  558. package/src/record/prepared-material-bindings.ts +11 -6
  559. package/src/record/probe-blend-buffer.ts +180 -0
  560. package/src/record/recovery-pipeline.ts +35 -3
  561. package/src/record/render-context.ts +41 -5
  562. package/src/record/shadow-pass.ts +30 -4
  563. package/src/record/skybox-post-pass.ts +28 -4
  564. package/src/record/sprite-instance-buffer.ts +155 -0
  565. package/src/record/target-capture-graph.ts +258 -0
  566. package/src/record/typed-frame-graph.ts +776 -340
  567. package/src/record/view-ubo.ts +27 -4
  568. package/src/record/volume-params.ts +225 -0
  569. package/src/recovery/render-system-candidate.ts +243 -50
  570. package/src/reflection/record-owner.ts +7 -3
  571. package/src/render-contract.ts +54 -5
  572. package/src/render-graph-primitives.ts +7 -1
  573. package/src/render-pipeline.ts +130 -0
  574. package/src/render-system-extract-tail.ts +90 -78
  575. package/src/render-system-extract.ts +76 -76
  576. package/src/render-system-presentation.ts +56 -0
  577. package/src/render-system-producer-roots.ts +96 -0
  578. package/src/render-system-projections.ts +3 -2
  579. package/src/render-system-residency.ts +159 -0
  580. package/src/render-system.ts +421 -408
  581. package/src/scene/probe-blend.ts +96 -4
  582. package/src/scene/render-scene.ts +416 -337
  583. package/src/scene/render-source.ts +90 -0
  584. package/src/scene/source-systems.ts +33 -0
  585. package/src/ssao-buffers.ts +95 -2
  586. package/src/surface/__tests__/dynamic-input.unit.test.ts +374 -0
  587. package/src/surface/__tests__/gpu-driven.unit.test.ts +87 -0
  588. package/src/surface/dynamic-input.ts +658 -0
  589. package/src/surface/gpu-driven.ts +147 -0
  590. package/src/surface/submission-observation.ts +517 -0
  591. package/src/systems/skin-palette-allocator.ts +5 -1
  592. package/src/systems/skin-palette-types.ts +11 -0
  593. package/src/systems/transparent-dispatch.ts +2 -2
  594. package/src/systems/transparent-sort-config.ts +3 -1
  595. package/src/temporal/gpu.ts +101 -17
  596. package/src/temporal/inspection.ts +7 -1
  597. package/src/temporal/standard-scene-data.ts +5 -0
  598. package/src/temporal/target-coverage-attachment.ts +4 -0
  599. package/src/transmission/__tests__/single-layer-medium.unit.test.ts +149 -0
  600. package/src/transmission/__tests__/standard-transmission.dawn.test.ts +12 -11
  601. package/src/transmission/single-layer-medium.ts +322 -0
  602. package/src/typed-render-graph-primitives.ts +70 -2
  603. package/src/volume/component.ts +10 -9
  604. package/src/volume/extract.ts +11 -5
  605. package/src/volume/inspection.ts +3 -0
  606. package/src/volume/passes.ts +87 -4
  607. package/src/volume/resources.ts +2 -1
  608. package/dist/chunk-3RTCJTH4.mjs +0 -1610
  609. package/dist/chunk-3RTCJTH4.mjs.map +0 -1
  610. package/dist/chunk-BLXGONR2.mjs.map +0 -1
  611. package/dist/chunk-ILQ5MEZF.mjs +0 -32
  612. package/dist/chunk-ILQ5MEZF.mjs.map +0 -1
  613. package/dist/chunk-LEAXOMYJ.mjs.map +0 -1
  614. package/dist/chunk-NB2S7ZRX.mjs +0 -1783
  615. package/dist/chunk-NB2S7ZRX.mjs.map +0 -1
  616. package/dist/chunk-NNQL7CB3.mjs +0 -1713
  617. package/dist/chunk-NNQL7CB3.mjs.map +0 -1
  618. package/dist/chunk-OO3DRYK7.mjs.map +0 -1
  619. package/dist/chunk-PA5DRJNI.mjs.map +0 -1
  620. package/dist/chunk-PLAXOOX5.mjs +0 -1907
  621. package/dist/chunk-PLAXOOX5.mjs.map +0 -1
  622. package/dist/chunk-RXZ3RGOU.mjs +0 -53
  623. package/dist/chunk-RXZ3RGOU.mjs.map +0 -1
  624. package/dist/chunk-VOZWDM3L.mjs.map +0 -1
@@ -1,1610 +0,0 @@
1
- import { LifecycleConstructionError, GpuDrivenPreparationError, RenderTargetDescriptorInvalidError } from './chunk-NB2S7ZRX.mjs';
2
- import { ok, err, derive } from '@forgeax/engine-types';
3
- import '@forgeax/engine-rhi';
4
- import { vec3 } from '@forgeax/engine-math';
5
- import { STANDARD_PIPELINE_PARAM_SCHEMA, standardPhysicalTextureFields, STANDARD_PHYSICAL_TEXTURE_FIELDS } from '@forgeax/engine-shader';
6
- import { deriveVertexLayoutProjection } from '@forgeax/engine-geometry';
7
-
8
- var DeviceResourceRef = class {
9
- kind;
10
- owner;
11
- generation;
12
- value;
13
- constructor(kind, owner, generation, value) {
14
- this.kind = kind;
15
- this.owner = owner;
16
- this.generation = generation;
17
- this.value = value;
18
- }
19
- isCurrent(scope) {
20
- return scope.accepts(this);
21
- }
22
- isStale(scope) {
23
- return !this.isCurrent(scope);
24
- }
25
- };
26
- function idempotentCleanup(cleanup) {
27
- let cleaned = false;
28
- return (value) => {
29
- if (cleaned) return;
30
- cleaned = true;
31
- return cleanup(value);
32
- };
33
- }
34
- var DeviceScope = class _DeviceScope {
35
- generation;
36
- owner;
37
- parent;
38
- lifecycleState = "active";
39
- resources = /* @__PURE__ */ new Map();
40
- children = [];
41
- constructor(generation, owner, parent) {
42
- this.generation = generation;
43
- this.owner = owner;
44
- this.parent = parent;
45
- parent?.children.push(this);
46
- }
47
- static create(generation, owner) {
48
- if (!Number.isSafeInteger(generation) || generation < 0) {
49
- throw new RangeError("DeviceScope generation must be a non-negative safe integer.");
50
- }
51
- if (owner.length === 0) throw new TypeError("DeviceScope owner must not be empty.");
52
- return new _DeviceScope(generation, owner);
53
- }
54
- get state() {
55
- return this.lifecycleState;
56
- }
57
- get childrenSnapshot() {
58
- return [...this.children];
59
- }
60
- /** Create a renderer-owned child scope without exposing a second device owner. */
61
- createChild(owner) {
62
- if (this.lifecycleState !== "active") {
63
- throw new Error("Cannot create a child DeviceScope from an inactive scope.");
64
- }
65
- if (owner.length === 0) throw new TypeError("DeviceScope child owner must not be empty.");
66
- return new _DeviceScope(this.generation, owner, this);
67
- }
68
- ref(kind, value) {
69
- const ref = new DeviceResourceRef(kind, this.owner, this.generation, value);
70
- this.resources.set(ref, { ref, cleanup: () => void 0 });
71
- return ref;
72
- }
73
- accepts(ref) {
74
- return this.lifecycleState === "active" && ref.owner === this.owner && ref.generation === this.generation;
75
- }
76
- isAlive() {
77
- return this.lifecycleState === "active";
78
- }
79
- resourceDelta() {
80
- return this.resources.size;
81
- }
82
- /** @internal */
83
- _adopt(kind, value, cleanup) {
84
- const ref = new DeviceResourceRef(kind, this.owner, this.generation, value);
85
- this.resources.set(ref, {
86
- ref,
87
- cleanup: idempotentCleanup(cleanup)
88
- });
89
- return ref;
90
- }
91
- /** @internal Remove ownership only after the resource's cleanup succeeded. */
92
- _release(ref) {
93
- this.resources.delete(ref);
94
- }
95
- /** @internal */
96
- _clearResources() {
97
- const resources = [...this.resources.values()];
98
- this.resources.clear();
99
- for (const resource of resources.reverse()) {
100
- try {
101
- const pending = resource.cleanup(resource.ref.value);
102
- if (pending instanceof Promise) void pending.catch(() => void 0);
103
- } catch {
104
- }
105
- }
106
- return resources;
107
- }
108
- /** Mark an active child as retiring without releasing in-flight resources. */
109
- beginRetire() {
110
- if (this.lifecycleState === "active") this.lifecycleState = "retiring";
111
- }
112
- clearChildren() {
113
- for (const child of [...this.children].reverse()) {
114
- child.retire();
115
- }
116
- }
117
- detachChild(child) {
118
- const index = this.children.indexOf(child);
119
- if (index >= 0) this.children.splice(index, 1);
120
- }
121
- retire() {
122
- if (this.lifecycleState !== "active" && this.lifecycleState !== "retiring") return;
123
- this.lifecycleState = "retiring";
124
- this.clearChildren();
125
- this._clearResources();
126
- this.lifecycleState = "retired";
127
- }
128
- abandon() {
129
- if (this.lifecycleState !== "active") return;
130
- this.lifecycleState = "abandoned";
131
- this.clearChildren();
132
- this._clearResources();
133
- }
134
- dispose() {
135
- if (this.lifecycleState === "disposed") return;
136
- this.lifecycleState = "disposed";
137
- this.clearChildren();
138
- this._clearResources();
139
- }
140
- async replace(generation, resources) {
141
- const replacement = new _DeviceScope(generation, this.owner, this);
142
- const transaction = new LifecycleTransaction(replacement);
143
- for (const resource of resources) transaction.add(resource);
144
- const result = await transaction.commit();
145
- if (!result.ok) {
146
- replacement.abandon();
147
- return result;
148
- }
149
- if (!this.isAlive()) {
150
- replacement.dispose();
151
- return transaction.failure("dispose");
152
- }
153
- this.detachChild(replacement);
154
- this.retire();
155
- return ok(replacement);
156
- }
157
- /** @internal */
158
- _receipt() {
159
- return {
160
- owner: this.owner,
161
- generation: this.generation,
162
- resourceCount: this.resources.size
163
- };
164
- }
165
- };
166
- var LifecycleTransaction = class {
167
- constructor(scope, options = {}) {
168
- this.scope = scope;
169
- this.options = options;
170
- }
171
- scope;
172
- resources = [];
173
- options;
174
- committed = false;
175
- add(spec) {
176
- if (this.committed) throw new Error("LifecycleTransaction is already committed.");
177
- this.resources.push(spec);
178
- return this;
179
- }
180
- async commit() {
181
- if (this.committed) return this.failure("create");
182
- this.committed = true;
183
- const created = [];
184
- for (let index = 0; index < this.resources.length; index += 1) {
185
- const spec = this.resources[index];
186
- if (spec === void 0) continue;
187
- try {
188
- if (this.options.failureAt === index + 1) {
189
- throw new Error(`injected lifecycle failure at ${index + 1}`);
190
- }
191
- const value = await spec.create();
192
- if (!this.scope.isAlive()) {
193
- await this.cleanupOne(value, created, idempotentCleanup(spec.cleanup));
194
- return this.failure("dispose");
195
- }
196
- created.push({ spec, value, cleanup: idempotentCleanup(spec.cleanup) });
197
- } catch (cause) {
198
- const cleanupFailures = await this.cleanupCreated(created);
199
- return this.failure("create", spec.kind, cleanupFailures, cause);
200
- }
201
- }
202
- if (!this.scope.isAlive()) {
203
- const cleanupFailures = await this.cleanupCreated(created);
204
- return this.failure("dispose", this.resources.at(-1)?.kind ?? "listener", cleanupFailures);
205
- }
206
- for (const item of created) this.scope._adopt(item.spec.kind, item.value, item.spec.cleanup);
207
- return ok(this.scope);
208
- }
209
- failure(operation, resourceKind = this.resources.at(-1)?.kind ?? "listener", cleanupFailures = [], cause = void 0) {
210
- return err({
211
- primary: new LifecycleConstructionError({
212
- owner: this.scope.owner,
213
- generation: this.scope.generation,
214
- operation,
215
- resourceKind,
216
- cause,
217
- cleanupFailures,
218
- receipt: this.scope._receipt()
219
- }),
220
- cleanupFailures,
221
- receipt: this.scope._receipt()
222
- });
223
- }
224
- async cleanupCreated(created) {
225
- const failures = [];
226
- for (let index = created.length - 1; index >= 0; index -= 1) {
227
- const item = created[index];
228
- if (item === void 0) continue;
229
- try {
230
- await item.cleanup(item.value);
231
- } catch (cause) {
232
- failures.push({ resourceKind: item.spec.kind, cause });
233
- }
234
- }
235
- return failures;
236
- }
237
- async cleanupOne(value, created, cleanup) {
238
- await this.cleanupCreated(created);
239
- try {
240
- await cleanup(value);
241
- } catch {
242
- }
243
- }
244
- };
245
-
246
- // src/gpu-usage.ts
247
- var GPU_BUFFER_USAGE_VERTEX = 32;
248
- var GPU_BUFFER_USAGE_INDEX = 16;
249
- var GPU_BUFFER_USAGE_COPY_DST = 8;
250
- var GPU_BUFFER_USAGE_COPY_SRC = 4;
251
- var GPU_BUFFER_USAGE_UNIFORM = 64;
252
- var GPU_BUFFER_USAGE_STORAGE = 128;
253
- var GPU_BUFFER_USAGE_INDIRECT = 256;
254
- var GPU_BUFFER_USAGE_MAP_READ = 1;
255
- var GPU_BUFFER_USAGE_QUERY_RESOLVE = 512;
256
-
257
- // src/prepare/extended-lighting/resources.ts
258
- var EXTENDED_LIGHTING_TOPOLOGY = "extendedLighting";
259
- var IES_SLICE_CAPACITY = 32;
260
- var COOKIE_SLICE_CAPACITY = 32;
261
- var IES_SLICE_WIDTH = 256;
262
- var IES_SLICE_HEIGHT = 128;
263
- var COOKIE_SLICE_SIZE = 256;
264
- var COOKIE_MATRIX_BYTES = 32 * 16 * Float32Array.BYTES_PER_ELEMENT;
265
- var EXTENDED_LIGHTING_REQUIRED_SAMPLED_TEXTURES = 21;
266
- function extendedLightingSampledTextureCapacityAvailable(maxSampledTexturesPerShaderStage) {
267
- return maxSampledTexturesPerShaderStage !== void 0 && maxSampledTexturesPerShaderStage >= EXTENDED_LIGHTING_REQUIRED_SAMPLED_TEXTURES;
268
- }
269
- function deriveExtendedLightingCapability(device) {
270
- const maxSampledTextures = device.limits.maxSampledTexturesPerShaderStage;
271
- if (!extendedLightingSampledTextureCapacityAvailable(maxSampledTextures)) {
272
- return {
273
- admitted: false,
274
- topology: EXTENDED_LIGHTING_TOPOLOGY,
275
- reason: `maxSampledTexturesPerShaderStage ${maxSampledTextures ?? 0} < ${EXTENDED_LIGHTING_REQUIRED_SAMPLED_TEXTURES}`
276
- };
277
- }
278
- const maxLayers = device.limits.maxTextureArrayLayers ?? 0;
279
- const maxUniformBuffers = device.limits.maxUniformBuffersPerShaderStage ?? 0;
280
- if (maxLayers < IES_SLICE_CAPACITY) {
281
- return {
282
- admitted: false,
283
- topology: EXTENDED_LIGHTING_TOPOLOGY,
284
- reason: `maxTextureArrayLayers ${maxLayers} < ${IES_SLICE_CAPACITY}`
285
- };
286
- }
287
- if (maxUniformBuffers < 1) {
288
- return {
289
- admitted: false,
290
- topology: EXTENDED_LIGHTING_TOPOLOGY,
291
- reason: `maxUniformBuffersPerShaderStage ${maxUniformBuffers} < 1`
292
- };
293
- }
294
- if (!device.caps.storageBuffer || !device.caps.rgba16floatRenderable || !device.caps.samplerAliasing) {
295
- return {
296
- admitted: false,
297
- topology: EXTENDED_LIGHTING_TOPOLOGY,
298
- reason: "required storage-buffer, rgba16float, or sampler capability is unavailable"
299
- };
300
- }
301
- return { admitted: true, topology: EXTENDED_LIGHTING_TOPOLOGY, reason: void 0 };
302
- }
303
- function worldEntityKey(worldId, entityKey) {
304
- return worldId * 4294967296 + entityKey;
305
- }
306
- function instanceCollectionCacheKey(worldId, instance) {
307
- return -(4294967296 + worldEntityKey(worldId, instance.collectionId ?? instance.cacheKey));
308
- }
309
- var ZERO_CAMERA_CLEAR_FALLBACK = [0, 0, 0, 1];
310
- var textureIdentities = /* @__PURE__ */ new WeakMap();
311
- var nextTextureIdentity = 1;
312
- var opaqueResourceIdentities = /* @__PURE__ */ new WeakMap();
313
- var nextOpaqueResourceIdentity = 1;
314
- function getOpaqueResourceIdentity(resource) {
315
- const existing = opaqueResourceIdentities.get(resource);
316
- if (existing !== void 0) return existing;
317
- const identity = nextOpaqueResourceIdentity++;
318
- opaqueResourceIdentities.set(resource, identity);
319
- return identity;
320
- }
321
- function getTextureIdentity(texture) {
322
- const object = texture;
323
- const existing = textureIdentities.get(object);
324
- if (existing !== void 0) return existing;
325
- const identity = nextTextureIdentity++;
326
- textureIdentities.set(object, identity);
327
- return identity;
328
- }
329
- function validateGraphTargetCaptureReadback(input) {
330
- const { bytes, expectedByteLength, sentinel, allowZero = false } = input;
331
- if (bytes.byteLength !== expectedByteLength)
332
- return { ok: false, code: "capture-readback-length" };
333
- if (sentinel?.every((value, index2) => bytes[index2] === value)) {
334
- return { ok: false, code: "capture-readback-untouched-sentinel" };
335
- }
336
- if (!allowZero && bytes.every((value) => value === 0)) {
337
- return { ok: false, code: "capture-readback-empty" };
338
- }
339
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
340
- let index = 0;
341
- for (; index + 3 < bytes.byteLength; index += 4) {
342
- const word = view.getUint32(index, true);
343
- if ((word & 31744) === 31744 || (word & 2080374784) === 2080374784)
344
- return { ok: false, code: "capture-readback-non-finite" };
345
- }
346
- if (index + 1 < bytes.byteLength && (view.getUint16(index, true) & 31744) === 31744)
347
- return { ok: false, code: "capture-readback-non-finite" };
348
- return { ok: true };
349
- }
350
- function makeZeroCameraFallbackSnapshot() {
351
- const identityWorld = new Float32Array(16);
352
- identityWorld[0] = 1;
353
- identityWorld[5] = 1;
354
- identityWorld[10] = 1;
355
- identityWorld[15] = 1;
356
- return {
357
- position: vec3.create(0, 0, 0),
358
- world: identityWorld,
359
- fov: Math.PI / 4,
360
- aspect: 1,
361
- near: 0.1,
362
- far: 100,
363
- // feat-20260613 M6 / w20: synthetic camera defaults to perspective so
364
- // the CSM extract path stays consistent with the previously-implicit
365
- // perspective shape (unchanged behavior; explicit field).
366
- projection: "perspective",
367
- orthoLeft: -1,
368
- orthoRight: 1,
369
- orthoBottom: -1,
370
- orthoTop: 1,
371
- tonemap: "none",
372
- exposure: 1,
373
- whitePoint: 4,
374
- antialias: "none",
375
- bloom: "off",
376
- bloomThreshold: 1,
377
- bloomIntensity: 1,
378
- bloomSoftKnee: 0.5,
379
- bloomScatter: 0.7,
380
- clearColor: ZERO_CAMERA_CLEAR_FALLBACK
381
- };
382
- }
383
-
384
- // src/temporal/coverage.ts
385
- function createTemporalCoverage(width, height) {
386
- if (!Number.isSafeInteger(width) || width <= 0) throw new RangeError("width must be positive.");
387
- if (!Number.isSafeInteger(height) || height <= 0)
388
- throw new RangeError("height must be positive.");
389
- return Object.freeze({ width, height, bytes: 34 * width * height, fullScreen: true });
390
- }
391
- function classifySceneDataCoverage(input) {
392
- const exactContributorIds = input.contributors.filter((c) => c.kind === "exact").map((c) => c.id);
393
- const reactiveContributorIds = input.contributors.filter((c) => c.kind === "reactive").map((c) => c.id);
394
- const available = new Set(input.contributors.map((c) => c.id));
395
- const missing = input.requiredContributorIds.filter((id) => !available.has(id));
396
- return {
397
- exactContributorIds: Object.freeze(exactContributorIds),
398
- reactiveContributorIds: Object.freeze(reactiveContributorIds),
399
- missingContributorIds: Object.freeze(missing.slice(0, 32)),
400
- omittedMissingContributorCount: Math.max(0, missing.length - 32),
401
- complete: missing.length === 0
402
- };
403
- }
404
- function scanSceneDataCoverage(input) {
405
- const classification = classifySceneDataCoverage({
406
- contributors: input.contributorIds.map((id) => ({ id, kind: "exact" })),
407
- requiredContributorIds: input.requiredContributorIds
408
- });
409
- return Object.freeze({
410
- schema: input.schema,
411
- lane: input.lane,
412
- producerId: input.producerId,
413
- ...classification,
414
- contributorIds: Object.freeze([...input.contributorIds])
415
- });
416
- }
417
-
418
- // src/gpu-stage.ts
419
- var GPU_SHADER_STAGE_VERTEX = 1;
420
- var GPU_SHADER_STAGE_FRAGMENT = 2;
421
- var GPU_SHADER_STAGE_COMPUTE = 4;
422
- var BGL_ONLY_SPEC_STUB = Object.freeze({
423
- shader: { id: "", passKind: "forward", variantSet: void 0 },
424
- attachments: { colorFormats: [], depthFormat: void 0, sampleCount: 1 },
425
- geometry: { topology: "triangle-list", vertexLayout: {} },
426
- renderState: void 0
427
- });
428
- function buildPbrMaterialUserRegionEntries(paramSchema = STANDARD_PIPELINE_PARAM_SCHEMA, excludedTextureFields = []) {
429
- const excluded = new Set(excludedTextureFields);
430
- for (const field of standardPhysicalTextureFields(paramSchema)) excluded.add(field);
431
- const derived = derive(
432
- excluded.size === 0 ? paramSchema : paramSchema.filter(
433
- (entry) => !excluded.has(entry.name) || !entry.type.startsWith("texture")
434
- )
435
- );
436
- let entries = derived.bglEntries.map(
437
- (entry) => ({
438
- binding: entry.binding,
439
- visibility: entry.visibility,
440
- ...entry.buffer === void 0 ? {} : { buffer: entry.buffer },
441
- ...entry.sampler === void 0 ? {} : { sampler: entry.sampler },
442
- ...entry.texture === void 0 ? {} : { texture: entry.texture },
443
- ...entry.storageTexture === void 0 ? {} : { storageTexture: entry.storageTexture }
444
- })
445
- );
446
- const ubo = entries[0];
447
- if (ubo !== void 0 && ubo.binding === 0 && ubo.buffer?.type === "uniform") {
448
- entries[0] = {
449
- binding: 0,
450
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT,
451
- buffer: { type: "uniform", hasDynamicOffset: true }
452
- };
453
- } else {
454
- entries = [
455
- {
456
- binding: 0,
457
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT,
458
- buffer: { type: "uniform", hasDynamicOffset: true }
459
- },
460
- ...entries.map((entry) => ({ ...entry, binding: entry.binding + 1 }))
461
- ];
462
- }
463
- return entries;
464
- }
465
- function appendInjection(bgl, kind) {
466
- const start = bgl.length;
467
- switch (kind) {
468
- case "ibl":
469
- return [
470
- // binding start+0: irradianceMap (texture_cube)
471
- {
472
- binding: start,
473
- visibility: GPU_SHADER_STAGE_FRAGMENT,
474
- texture: { sampleType: "float", viewDimension: "cube" }
475
- },
476
- // binding start+1: irradianceSampler
477
- {
478
- binding: start + 1,
479
- visibility: GPU_SHADER_STAGE_FRAGMENT,
480
- sampler: { type: "filtering" }
481
- },
482
- // binding start+2: prefilterMap (texture_cube)
483
- {
484
- binding: start + 2,
485
- visibility: GPU_SHADER_STAGE_FRAGMENT,
486
- texture: { sampleType: "float", viewDimension: "cube" }
487
- },
488
- // binding start+3: prefilterSampler
489
- {
490
- binding: start + 3,
491
- visibility: GPU_SHADER_STAGE_FRAGMENT,
492
- sampler: { type: "filtering" }
493
- },
494
- // binding start+4: brdfLut (texture_2d)
495
- {
496
- binding: start + 4,
497
- visibility: GPU_SHADER_STAGE_FRAGMENT,
498
- texture: { sampleType: "float", viewDimension: "2d" }
499
- },
500
- // binding start+5: brdfLutSampler
501
- {
502
- binding: start + 5,
503
- visibility: GPU_SHADER_STAGE_FRAGMENT,
504
- sampler: { type: "filtering" }
505
- },
506
- // binding start+6: uniform { intensity: f32 }
507
- {
508
- binding: start + 6,
509
- visibility: GPU_SHADER_STAGE_FRAGMENT,
510
- buffer: { type: "uniform" }
511
- }
512
- ];
513
- case "lightmap":
514
- return [
515
- // emissive sampler + texture pair
516
- {
517
- binding: start,
518
- visibility: GPU_SHADER_STAGE_FRAGMENT,
519
- sampler: { type: "filtering" }
520
- },
521
- {
522
- binding: start + 1,
523
- visibility: GPU_SHADER_STAGE_FRAGMENT,
524
- texture: { sampleType: "float", viewDimension: "2d" }
525
- },
526
- // occlusion sampler + texture pair
527
- {
528
- binding: start + 2,
529
- visibility: GPU_SHADER_STAGE_FRAGMENT,
530
- sampler: { type: "filtering" }
531
- },
532
- {
533
- binding: start + 3,
534
- visibility: GPU_SHADER_STAGE_FRAGMENT,
535
- texture: { sampleType: "float", viewDimension: "2d" }
536
- }
537
- ];
538
- case "shadow":
539
- return [
540
- {
541
- binding: start,
542
- visibility: GPU_SHADER_STAGE_FRAGMENT,
543
- sampler: { type: "comparison" }
544
- },
545
- {
546
- binding: start + 1,
547
- visibility: GPU_SHADER_STAGE_FRAGMENT,
548
- texture: { sampleType: "depth", viewDimension: "2d" }
549
- }
550
- ];
551
- case "transmission":
552
- return [
553
- {
554
- binding: start,
555
- visibility: GPU_SHADER_STAGE_FRAGMENT,
556
- sampler: { type: "filtering" }
557
- },
558
- {
559
- binding: start + 1,
560
- visibility: GPU_SHADER_STAGE_FRAGMENT,
561
- texture: { sampleType: "float", viewDimension: "2d" }
562
- }
563
- ];
564
- }
565
- }
566
- function physicalTextureFields(paramSchema) {
567
- return standardPhysicalTextureFields(paramSchema);
568
- }
569
- function appendTextureInjection(_bgl, fields) {
570
- const fieldSet = new Set(fields);
571
- return standardPhysicalTextureFields(
572
- STANDARD_PIPELINE_PARAM_SCHEMA.concat(
573
- fields.map((name) => ({ name, type: "texture2d" }))
574
- )
575
- ).flatMap((field) => {
576
- if (!fieldSet.has(field)) return [];
577
- const canonicalIndex = STANDARD_PHYSICAL_TEXTURE_FIELDS.indexOf(field);
578
- const binding = 26 + canonicalIndex * 2;
579
- return [
580
- {
581
- binding,
582
- visibility: GPU_SHADER_STAGE_FRAGMENT,
583
- sampler: { type: "filtering" }
584
- },
585
- {
586
- binding: binding + 1,
587
- visibility: GPU_SHADER_STAGE_FRAGMENT,
588
- texture: { sampleType: "float", viewDimension: "2d" }
589
- }
590
- ];
591
- });
592
- }
593
- function materialBindGroupLayoutIdentity(shaderId, paramSchema) {
594
- const descriptor = buildBindGroupLayoutDescriptor(
595
- {
596
- shader: { id: shaderId, passKind: "forward", variantSet: void 0 },
597
- attachments: { colorFormats: [], depthFormat: void 0, sampleCount: 1 }},
598
- { kind: "pbr-material-merged", materialParamSchema: paramSchema }
599
- );
600
- return JSON.stringify({
601
- entries: descriptor.entries,
602
- physicalTextureFields: physicalTextureFields(paramSchema)
603
- });
604
- }
605
- function buildPbrViewBglEntries(caps) {
606
- const entries = [
607
- {
608
- binding: 0,
609
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT,
610
- // View captures use the same bind group with a per-face view slot.
611
- // Keeping this dynamic is also valid for the display slot at offset 0.
612
- buffer: { type: "uniform", hasDynamicOffset: true }
613
- },
614
- {
615
- binding: 3,
616
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT,
617
- texture: { sampleType: "depth", viewDimension: "2d" }
618
- },
619
- {
620
- binding: 4,
621
- visibility: GPU_SHADER_STAGE_FRAGMENT,
622
- sampler: { type: "comparison" }
623
- },
624
- // feat-20260612-point-light-shadows-urp-hdrp Round-2 F-1: point shadow
625
- // cube_array depth atlas. Bound to either the real ShadowAtlas
626
- // cube_array view (when point shadows are active) or a 1x1x6 fallback
627
- // cube_array view cleared to 1.0 (fully lit). Visibility is FRAGMENT
628
- // only -- the directional binding 3 is VERTEX|FRAGMENT for shadow
629
- // probe-debug sampling, but the cube atlas has no host-side probe path.
630
- {
631
- binding: 5,
632
- visibility: GPU_SHADER_STAGE_FRAGMENT,
633
- texture: { sampleType: "depth", viewDimension: "cube-array" }
634
- },
635
- // feat-20260612-point-light-shadows-urp-hdrp Round-2 F-1: point shadow
636
- // params UBO. Carries `array<vec4<f32>, 4>` = 64 B with one lane per
637
- // shadow-casting point light slot (shadowAtlasLayer in [0, 4)). Each
638
- // lane stores `(near, far, depthBias, normalBias)` so the fragment-shader
639
- // depth-ref reconstruction (lighting-punctual.wgsl evalPointShadowed)
640
- // can avoid sampling DirectLightSlot for the URP path. The shared
641
- // DirectLightSlot metadata remains the identity owner, so binding 6 is
642
- // unused on HDRP shaders even though the BGL declares it (charter P4 single SSOT
643
- // BGL across pipelines; the HDRP variant simply doesn't reference the
644
- // binding in WGSL, which is allowed).
645
- {
646
- binding: 6,
647
- visibility: GPU_SHADER_STAGE_FRAGMENT,
648
- buffer: { type: "uniform" }
649
- },
650
- // feat-20260613-csm-cascaded-shadow-maps M5 / w28: shadowCasterCascade
651
- // UBO (16 B). Carries the 0-based cascade index of the shadow pass
652
- // currently being rasterized so `shadow_caster.wgsl` can index into
653
- // `view.lightViewProj_X` per cascade. Shifted from binding 5 to
654
- // binding 7 on 2026-06-13 to make room for point-shadow bindings 5/6
655
- // (they predate this feat in main; CSM's slot was the optimal-yield
656
- // give since point-shadow needs FRAGMENT-only and the cascade UBO
657
- // needs vertex-stage too — keeping cascade higher avoids interleaving
658
- // visibility flags within the contiguous shadow-binding cluster).
659
- {
660
- binding: 7,
661
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT,
662
- buffer: { type: "uniform" }
663
- },
664
- // feat-20260625-spot-light-shadow-mapping M3 / w14 (D-5): spot shadow
665
- // atlas. A single `texture_depth_2d` holding up to 4 spot shadows in a 2x2
666
- // tile grid (urp-pipeline.ts spotShadowDepth). FRAGMENT-only — the spot
667
- // shadow factor is reconstructed at fragment time via perspective-divide in
668
- // `evalSpotShadowed` (lighting-punctual.wgsl).
669
- //
670
- // ALWAYS-ON (no caps gate, unlike the point cube_array atlas at binding 5
671
- // which rides POINT_SHADOW_AVAILABLE): spot uses `texture_depth_2d` which is
672
- // compat-safe in every WebGPU profile, so the binding is unconditionally
673
- // declared. The matching WGSL declaration is `spotShadowMap` at @group(0)
674
- // binding 8 in common.wgsl (also unconditional) — the two must stay in
675
- // lock-step or WebGPU validation rejects the bind group at smoke time
676
- // (memory: BGL shape mismatch is a browser-path-only bug). No binding 9
677
- // sampler: spot reuses the comparison sampler at binding 4.
678
- // feat-20260625-spot-light-shadow-mapping M3 / w14 (D-5): spot shadow 2D
679
- // atlas, the LAST view-BG binding. The per-spot fragment-read perspective
680
- // lightViewProj matrices that w24 originally declared at a standalone
681
- // binding 9 uniform buffer were folded into the View UBO (binding 0,
682
- // `view.spotLightViewProj`) in w25 (scope-amend webkit-fallback): the
683
- // standalone binding pushed the WebGL2 fallback fragment uniform-buffer
684
- // count to 12, over GLES 3.0's `max_uniform_buffers_per_shader_stage = 11`,
685
- // crashing pipeline-layout creation on the compat path (this feat's target).
686
- {
687
- binding: 8,
688
- visibility: GPU_SHADER_STAGE_FRAGMENT,
689
- texture: { sampleType: "depth", viewDimension: "2d" }
690
- }
691
- ];
692
- const extendedLighting = caps.extendedLighting ?? true;
693
- if (extendedLighting) {
694
- entries.push(
695
- {
696
- binding: 9,
697
- visibility: GPU_SHADER_STAGE_FRAGMENT,
698
- sampler: { type: "filtering" }
699
- },
700
- {
701
- binding: 11,
702
- visibility: GPU_SHADER_STAGE_FRAGMENT,
703
- texture: { sampleType: "float", viewDimension: "2d-array" }
704
- },
705
- {
706
- binding: 12,
707
- visibility: GPU_SHADER_STAGE_FRAGMENT,
708
- texture: { sampleType: "float", viewDimension: "2d-array" }
709
- },
710
- {
711
- binding: 13,
712
- visibility: GPU_SHADER_STAGE_FRAGMENT,
713
- texture: { sampleType: "float", viewDimension: "2d" }
714
- },
715
- {
716
- binding: 14,
717
- visibility: GPU_SHADER_STAGE_FRAGMENT,
718
- texture: { sampleType: "float", viewDimension: "2d" }
719
- },
720
- {
721
- binding: 15,
722
- visibility: GPU_SHADER_STAGE_FRAGMENT,
723
- buffer: { type: "uniform" }
724
- }
725
- );
726
- } else if (caps.projectorAvailable !== false) {
727
- entries.push(
728
- {
729
- binding: 11,
730
- visibility: GPU_SHADER_STAGE_FRAGMENT,
731
- texture: { sampleType: "float", viewDimension: "2d" }
732
- },
733
- {
734
- binding: 12,
735
- visibility: GPU_SHADER_STAGE_FRAGMENT,
736
- sampler: { type: "filtering" }
737
- }
738
- );
739
- }
740
- entries.push({
741
- binding: 10,
742
- visibility: GPU_SHADER_STAGE_VERTEX,
743
- buffer: { type: "uniform", hasDynamicOffset: true }
744
- });
745
- return entries;
746
- }
747
- function buildPbrPipelineLayouts(device, caps) {
748
- const viewBglRes = device.createBindGroupLayout(
749
- buildBindGroupLayoutDescriptor(BGL_ONLY_SPEC_STUB, { kind: "pbr-view", caps })
750
- );
751
- if (!viewBglRes.ok) throw viewBglRes.error;
752
- const materialBglRes = device.createBindGroupLayout(
753
- buildBindGroupLayoutDescriptor(BGL_ONLY_SPEC_STUB, {
754
- kind: "pbr-material-merged",
755
- caps
756
- })
757
- );
758
- if (!materialBglRes.ok) throw materialBglRes.error;
759
- const meshArrayBglRes = device.createBindGroupLayout(
760
- buildBindGroupLayoutDescriptor(BGL_ONLY_SPEC_STUB, { kind: "pbr-mesh-array", caps })
761
- );
762
- if (!meshArrayBglRes.ok) throw meshArrayBglRes.error;
763
- const instancesBglRes = device.createBindGroupLayout(
764
- buildBindGroupLayoutDescriptor(BGL_ONLY_SPEC_STUB, {
765
- kind: "pbr-instances",
766
- caps: { ...caps, probeBlend: false }
767
- })
768
- );
769
- if (!instancesBglRes.ok) throw instancesBglRes.error;
770
- const probeInstancesBglRes = caps.storageBuffer ? device.createBindGroupLayout(
771
- buildBindGroupLayoutDescriptor(BGL_ONLY_SPEC_STUB, {
772
- kind: "pbr-instances",
773
- caps: { ...caps, probeBlend: true }
774
- })
775
- ) : { ok: true, value: instancesBglRes.value };
776
- if (!probeInstancesBglRes.ok) throw probeInstancesBglRes.error;
777
- const layouts = [
778
- viewBglRes.value,
779
- materialBglRes.value,
780
- meshArrayBglRes.value,
781
- instancesBglRes.value
782
- ];
783
- const pipelineLayoutRes = device.createPipelineLayout({
784
- label: "pbr-pl",
785
- bindGroupLayouts: layouts
786
- });
787
- if (!pipelineLayoutRes.ok) throw pipelineLayoutRes.error;
788
- const probeLayouts = [viewBglRes.value, materialBglRes.value, meshArrayBglRes.value, probeInstancesBglRes.value];
789
- let probePipelineLayout = null;
790
- if (caps.storageBuffer) {
791
- const probePipelineLayoutRes = device.createPipelineLayout({
792
- label: "pbr-probe-pl",
793
- bindGroupLayouts: probeLayouts
794
- });
795
- if (!probePipelineLayoutRes.ok) throw probePipelineLayoutRes.error;
796
- probePipelineLayout = probePipelineLayoutRes.value;
797
- }
798
- return {
799
- pipelineLayout: pipelineLayoutRes.value,
800
- viewBgl: viewBglRes.value,
801
- materialBgl: materialBglRes.value,
802
- meshArrayBgl: meshArrayBglRes.value,
803
- instancesBgl: instancesBglRes.value,
804
- probeInstancesBgl: probeInstancesBglRes.value,
805
- probePipelineLayout,
806
- bindGroupLayouts: layouts
807
- };
808
- }
809
- var SKIN_MATERIAL_SHADER_ID = "forgeax::pbr-skin";
810
- var SHADOW_CASTER_SHADER_ID = "forgeax::default-shadow-caster";
811
- var AUTHORED_STANDARD_ID_RE = /::(?:standard|pbr-skin)(?:-|$)/;
812
- function isStandardPbrSkinMaterialShader(shaderId) {
813
- return shaderId === SKIN_MATERIAL_SHADER_ID || shaderId === "forgeax::default-standard-pbr-skin" || shaderId !== void 0 && /::pbr-skin(?:-|$)/.test(shaderId);
814
- }
815
- function shadowCasterVariantSet(storageBuffer, skinned, gpuDrivenSceneIndex = false, alphaMask = false, vertexColorAvailable = false) {
816
- const skinningDisabled = !skinned;
817
- const defines = {
818
- ALPHA_MASK: alphaMask,
819
- GPU_DRIVEN_SCENE_INDEX_AVAILABLE: gpuDrivenSceneIndex,
820
- GPU_DRIVEN_SCENE_INDEX_EXPLICIT: false,
821
- SKINNING_DISABLED: skinningDisabled,
822
- STORAGE_BUFFER_AVAILABLE: storageBuffer
823
- };
824
- if (vertexColorAvailable) defines.VERTEX_COLOR_AVAILABLE = true;
825
- return Object.entries(defines).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([name, value]) => `${name}=${String(value)}`).join("+");
826
- }
827
- function resolvePipelineGroup2Contract(source) {
828
- const withoutComments = source.replace(/\/\*[\s\S]*?\*\//gu, "").replace(/\/\/.*$/gmu, "");
829
- const bindings = [
830
- ...withoutComments.matchAll(/@group\s*\(\s*2\s*\)\s*@binding\s*\(\s*(\d+)\s*\)/gu)
831
- ].map((match) => Number(match[1]));
832
- const hasSkinBindings = bindings.includes(1) || bindings.includes(2);
833
- const hasClusterBindings = bindings.some((binding) => binding >= 3);
834
- if (hasSkinBindings && hasClusterBindings) return "skin-cluster";
835
- if (hasSkinBindings) return "skin";
836
- if (hasClusterBindings) return "cluster";
837
- return "mesh";
838
- }
839
- function isStandardPbrMaterialShader(shaderId) {
840
- return shaderId === "forgeax::default-standard-pbr" || shaderId === SKIN_MATERIAL_SHADER_ID || shaderId === "forgeax::default-standard-pbr-skin" || shaderId !== void 0 && AUTHORED_STANDARD_ID_RE.test(shaderId);
841
- }
842
- function isCanonicalStandardPbrMaterialShader(shaderId) {
843
- return shaderId === "forgeax::default-standard-pbr" || shaderId === SKIN_MATERIAL_SHADER_ID || shaderId === "forgeax::default-standard-pbr-skin";
844
- }
845
- function buildPbrSkinLayouts(device, caps, pbr) {
846
- const skinMeshArrayBglRes = device.createBindGroupLayout(
847
- buildBindGroupLayoutDescriptor(BGL_ONLY_SPEC_STUB, {
848
- kind: "pbr-skin-mesh-array",
849
- caps
850
- })
851
- );
852
- if (!skinMeshArrayBglRes.ok) throw skinMeshArrayBglRes.error;
853
- const layouts = [
854
- pbr.viewBgl,
855
- pbr.materialBgl,
856
- skinMeshArrayBglRes.value,
857
- pbr.instancesBgl
858
- ];
859
- const pipelineLayoutRes = device.createPipelineLayout({
860
- label: "pbr-skin-pl",
861
- bindGroupLayouts: layouts
862
- });
863
- if (!pipelineLayoutRes.ok) throw pipelineLayoutRes.error;
864
- const probeLayouts = [pbr.viewBgl, pbr.materialBgl, skinMeshArrayBglRes.value, pbr.probeInstancesBgl];
865
- let probePipelineLayout = null;
866
- if (caps.storageBuffer) {
867
- const probePipelineLayoutRes = device.createPipelineLayout({
868
- label: "pbr-skin-probe-pl",
869
- bindGroupLayouts: probeLayouts
870
- });
871
- if (!probePipelineLayoutRes.ok) throw probePipelineLayoutRes.error;
872
- probePipelineLayout = probePipelineLayoutRes.value;
873
- }
874
- return {
875
- pipelineLayout: pipelineLayoutRes.value,
876
- viewBgl: pbr.viewBgl,
877
- materialBgl: pbr.materialBgl,
878
- meshArrayBgl: skinMeshArrayBglRes.value,
879
- instancesBgl: pbr.instancesBgl,
880
- probeInstancesBgl: pbr.probeInstancesBgl,
881
- probePipelineLayout,
882
- bindGroupLayouts: layouts
883
- };
884
- }
885
- function buildGpuDrivenPbrInstancesBindGroupLayout(device, caps) {
886
- if (!caps.storageBuffer) {
887
- throw new Error("GPU-driven PBR instances layout requires storage-buffer capability");
888
- }
889
- const result = device.createBindGroupLayout(
890
- buildBindGroupLayoutDescriptor(BGL_ONLY_SPEC_STUB, {
891
- kind: "pbr-gpu-driven-instances",
892
- caps
893
- })
894
- );
895
- if (!result.ok) throw result.error;
896
- return result.value;
897
- }
898
- function buildGpuDrivenPbrPipelineLayout(device, pbr, gpuDrivenInstancesBgl) {
899
- const result = device.createPipelineLayout({
900
- label: "pbr-gpu-driven-pl",
901
- bindGroupLayouts: [pbr.viewBgl, pbr.materialBgl, pbr.meshArrayBgl, gpuDrivenInstancesBgl]
902
- });
903
- if (!result.ok) throw result.error;
904
- return result.value;
905
- }
906
- function buildGpuDrivenPbrSkinPipelineLayout(device, pbrSkin, gpuDrivenInstancesBgl) {
907
- const result = device.createPipelineLayout({
908
- label: "pbr-skin-gpu-driven-pl",
909
- bindGroupLayouts: [
910
- pbrSkin.viewBgl,
911
- pbrSkin.materialBgl,
912
- pbrSkin.meshArrayBgl,
913
- gpuDrivenInstancesBgl
914
- ]
915
- });
916
- if (!result.ok) throw result.error;
917
- return result.value;
918
- }
919
- function createPbrSkinMeshBindGroupEntries(meshBuffer, meshSize, paletteBuffer, paletteWindowBytes) {
920
- return [
921
- {
922
- binding: 0,
923
- resource: { kind: "buffer", value: { buffer: meshBuffer, offset: 0, size: meshSize } }
924
- },
925
- ...[1, 2].map((binding) => ({
926
- binding,
927
- resource: {
928
- kind: "buffer",
929
- value: {
930
- buffer: paletteBuffer,
931
- offset: 0,
932
- size: paletteWindowBytes
933
- }
934
- }
935
- }))
936
- ];
937
- }
938
- function pbrSkinMeshDynamicOffsets(meshOffset, paletteOffset) {
939
- return [meshOffset, paletteOffset, paletteOffset];
940
- }
941
- var SPRITE_PASS_PER_INSTANCE_REGION_VARIANT_SET = "";
942
- function createHdrpBindGroupLayoutDescriptor() {
943
- const meshBufType = "read-only-storage";
944
- const clusterBufType = "read-only-storage";
945
- return {
946
- label: "hdrp-unified-bgl-group2",
947
- entries: [
948
- {
949
- binding: 0,
950
- // Standard fragment lighting (transmission/refraction and clustered
951
- // evaluation) reads the same mesh transform window as the vertex
952
- // stage. Keep this visibility in the HDRP descriptor aligned with
953
- // the URP mesh-array descriptor; restricting it to vertex makes the
954
- // HDRP pipeline invalid when fs_main accesses `meshes[0]`.
955
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT,
956
- buffer: { type: meshBufType, hasDynamicOffset: true }
957
- },
958
- // Bindings 1 and 2 stay absent for the URP physical isolation gap.
959
- {
960
- binding: 3,
961
- visibility: GPU_SHADER_STAGE_FRAGMENT,
962
- buffer: { type: clusterBufType, hasDynamicOffset: false }
963
- },
964
- {
965
- binding: 4,
966
- visibility: GPU_SHADER_STAGE_FRAGMENT,
967
- buffer: { type: clusterBufType, hasDynamicOffset: false }
968
- },
969
- {
970
- binding: 5,
971
- visibility: GPU_SHADER_STAGE_FRAGMENT,
972
- buffer: { type: clusterBufType, hasDynamicOffset: false }
973
- },
974
- {
975
- binding: 6,
976
- visibility: GPU_SHADER_STAGE_FRAGMENT,
977
- buffer: { type: "uniform", hasDynamicOffset: false }
978
- },
979
- {
980
- binding: 7,
981
- visibility: GPU_SHADER_STAGE_FRAGMENT,
982
- texture: { sampleType: "float", viewDimension: "2d", multisampled: false }
983
- },
984
- {
985
- binding: 8,
986
- visibility: GPU_SHADER_STAGE_FRAGMENT,
987
- sampler: { type: "filtering" }
988
- }
989
- ]
990
- };
991
- }
992
- function createHdrpSkinBindGroupLayoutDescriptor() {
993
- const base = createHdrpBindGroupLayoutDescriptor();
994
- const baseEntries = base.entries;
995
- if (baseEntries === void 0 || baseEntries[0] === void 0) {
996
- throw new Error("HDRP base group(2) layout must declare mesh binding 0");
997
- }
998
- const paletteType = "read-only-storage";
999
- return {
1000
- label: "hdrp-skin-unified-bgl-group2",
1001
- entries: [
1002
- baseEntries[0],
1003
- {
1004
- binding: 1,
1005
- visibility: GPU_SHADER_STAGE_VERTEX,
1006
- buffer: { type: paletteType, hasDynamicOffset: true }
1007
- },
1008
- {
1009
- binding: 2,
1010
- visibility: GPU_SHADER_STAGE_VERTEX,
1011
- buffer: { type: paletteType, hasDynamicOffset: true }
1012
- },
1013
- ...baseEntries.slice(1)
1014
- ]
1015
- };
1016
- }
1017
- function resolveMaterialParamSchema(spec, options) {
1018
- if (options.materialParamSchema !== void 0) return options.materialParamSchema;
1019
- if (options.registry !== void 0) {
1020
- const lookup = options.registry.findMaterialArtifact(spec.shader.id);
1021
- if (lookup.ok) return lookup.value.paramSchema;
1022
- }
1023
- return void 0;
1024
- }
1025
- function buildBindGroupLayoutDescriptor(spec, options) {
1026
- switch (options.kind) {
1027
- case "pbr-view": {
1028
- const caps = options.caps ?? { };
1029
- return {
1030
- label: "pbr-view-bgl",
1031
- entries: buildPbrViewBglEntries(caps)
1032
- };
1033
- }
1034
- case "pbr-mesh-array": {
1035
- const caps = options.caps ?? { storageBuffer: true };
1036
- const meshBufType = caps.storageBuffer ? "read-only-storage" : "uniform";
1037
- return {
1038
- label: "pbr-mesh-array-bgl",
1039
- entries: [
1040
- {
1041
- binding: 0,
1042
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT,
1043
- buffer: { type: meshBufType, hasDynamicOffset: true }
1044
- }
1045
- ]
1046
- };
1047
- }
1048
- case "pbr-instances": {
1049
- const caps = options.caps ?? { storageBuffer: true };
1050
- const meshBufType = caps.storageBuffer ? "read-only-storage" : "uniform";
1051
- const entries = [
1052
- {
1053
- binding: 0,
1054
- visibility: GPU_SHADER_STAGE_VERTEX,
1055
- buffer: { type: meshBufType, hasDynamicOffset: false }
1056
- },
1057
- ...caps.probeBlend === true ? [
1058
- {
1059
- // Per-object fragment lane; the record is always exactly 160B.
1060
- binding: 1,
1061
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1062
- buffer: { type: meshBufType, hasDynamicOffset: true }
1063
- }
1064
- ] : []
1065
- ];
1066
- return {
1067
- label: caps.probeBlend === true ? "pbr-probe-instances-bgl" : "pbr-instances-bgl",
1068
- entries: entries.map(
1069
- (entry) => entry.binding === 0 ? {
1070
- ...entry,
1071
- // Standard transmission reads the same per-instance transform in
1072
- // fs_main to convert glTF unit-space thickness into world metres.
1073
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT
1074
- } : entry
1075
- )
1076
- };
1077
- }
1078
- case "pbr-gpu-driven-instances": {
1079
- const caps = options.caps ?? { storageBuffer: true };
1080
- const meshBufType = caps.storageBuffer ? "read-only-storage" : "uniform";
1081
- return {
1082
- label: "pbr-gpu-driven-instances-bgl",
1083
- entries: [
1084
- {
1085
- binding: 0,
1086
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT,
1087
- buffer: { type: meshBufType, hasDynamicOffset: false }
1088
- },
1089
- {
1090
- // ShadowCaster's scene-index entry still reads the visible row
1091
- // through binding(1). Keep this alias in the dedicated layout so
1092
- // the shared visible bind group can serve both the Standard PBR
1093
- // (binding(2)) and depth-only shadow (binding(1)) consumers.
1094
- binding: 1,
1095
- visibility: GPU_SHADER_STAGE_VERTEX,
1096
- buffer: { type: meshBufType, hasDynamicOffset: false }
1097
- },
1098
- {
1099
- binding: 2,
1100
- visibility: GPU_SHADER_STAGE_VERTEX,
1101
- buffer: { type: meshBufType, hasDynamicOffset: false }
1102
- }
1103
- ]
1104
- };
1105
- }
1106
- case "pbr-skin-mesh-array": {
1107
- const caps = options.caps ?? { storageBuffer: true };
1108
- const meshBufType = caps.storageBuffer ? "read-only-storage" : "uniform";
1109
- return {
1110
- label: "pbr-skin-mesh-array-bgl",
1111
- entries: [
1112
- {
1113
- binding: 0,
1114
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT,
1115
- buffer: { type: meshBufType, hasDynamicOffset: true }
1116
- },
1117
- {
1118
- binding: 1,
1119
- visibility: GPU_SHADER_STAGE_VERTEX,
1120
- buffer: { type: meshBufType, hasDynamicOffset: true }
1121
- },
1122
- {
1123
- binding: 2,
1124
- visibility: GPU_SHADER_STAGE_VERTEX,
1125
- buffer: { type: meshBufType, hasDynamicOffset: true }
1126
- }
1127
- ]
1128
- };
1129
- }
1130
- case "pbr-material-merged": {
1131
- const resolvedSchema = resolveMaterialParamSchema(spec, options);
1132
- const effectiveSchema = resolvedSchema ?? STANDARD_PIPELINE_PARAM_SCHEMA;
1133
- const physicalFields = physicalTextureFields(effectiveSchema);
1134
- const userRegionSchema = isCanonicalStandardPbrMaterialShader(spec.shader.id) ? STANDARD_PIPELINE_PARAM_SCHEMA : effectiveSchema;
1135
- const userRegion = buildPbrMaterialUserRegionEntries(userRegionSchema);
1136
- const afterIbl = [...userRegion, ...appendInjection(userRegion, "ibl")];
1137
- const afterTransmission = [...afterIbl, ...appendInjection(afterIbl, "transmission")];
1138
- const merged = [
1139
- ...options.caps?.transmissionBackdrop === false ? afterIbl : afterTransmission,
1140
- ...appendTextureInjection(afterTransmission, physicalFields)
1141
- ];
1142
- if (options.caps?.storageBuffer ?? true) {
1143
- merged.push({
1144
- binding: 46,
1145
- visibility: GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT,
1146
- buffer: { type: "read-only-storage", hasDynamicOffset: false }
1147
- });
1148
- }
1149
- return {
1150
- label: "pbr-material-skylight-bgl",
1151
- entries: [
1152
- ...merged,
1153
- {
1154
- binding: 47,
1155
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1156
- texture: { sampleType: "float", viewDimension: "cube" }
1157
- }
1158
- ]
1159
- };
1160
- }
1161
- case "unlit-material": {
1162
- const resolvedSchema = resolveMaterialParamSchema(spec, options);
1163
- return {
1164
- label: "unlit-material-bgl",
1165
- entries: buildPbrMaterialUserRegionEntries(resolvedSchema)
1166
- };
1167
- }
1168
- case "hdrp-7-slot": {
1169
- const desc = createHdrpBindGroupLayoutDescriptor();
1170
- return {
1171
- label: desc.label ?? "hdrp-unified-bgl-group2",
1172
- entries: [...desc.entries ?? []]
1173
- };
1174
- }
1175
- case "fullscreen-post": {
1176
- return {
1177
- label: "fullscreen-post-bgl",
1178
- entries: buildFullscreenPostInputEntries(spec)
1179
- };
1180
- }
1181
- case "fullscreen-post-with-params": {
1182
- return {
1183
- label: "fullscreen-post-with-params-bgl",
1184
- entries: [
1185
- ...buildFullscreenPostInputEntries(spec),
1186
- {
1187
- binding: 2,
1188
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1189
- buffer: { type: "uniform" }
1190
- }
1191
- ]
1192
- };
1193
- }
1194
- case "fullscreen-post-with-scene-depth": {
1195
- return {
1196
- label: "fullscreen-post-with-scene-depth-bgl",
1197
- entries: [
1198
- ...buildFullscreenPostInputEntries(spec),
1199
- {
1200
- binding: 2,
1201
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1202
- buffer: { type: "uniform" }
1203
- },
1204
- {
1205
- binding: 3,
1206
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1207
- texture: { sampleType: "depth", viewDimension: "2d" }
1208
- },
1209
- {
1210
- binding: 4,
1211
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1212
- sampler: { type: "non-filtering" }
1213
- }
1214
- ]
1215
- };
1216
- }
1217
- case "fullscreen-post-with-scene-depth-msaa": {
1218
- return {
1219
- label: "fullscreen-post-with-scene-depth-msaa-bgl",
1220
- entries: [
1221
- ...buildFullscreenPostInputEntries(spec),
1222
- {
1223
- binding: 2,
1224
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1225
- buffer: { type: "uniform" }
1226
- },
1227
- {
1228
- binding: 3,
1229
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1230
- texture: { sampleType: "depth", viewDimension: "2d", multisampled: true }
1231
- },
1232
- {
1233
- binding: 4,
1234
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1235
- sampler: { type: "non-filtering" }
1236
- }
1237
- ]
1238
- };
1239
- }
1240
- }
1241
- }
1242
- function buildFullscreenPostInputEntries(spec) {
1243
- const inputFormat = spec.attachments.depthFormat ?? spec.attachments.colorFormats[0];
1244
- const sampleType = inputFormat === "depth32float" || inputFormat === "depth24plus" || inputFormat === "depth24plus-stencil8" || inputFormat === "depth16unorm" ? "depth" : inputFormat === "r32float" ? "unfilterable-float" : "float";
1245
- return [
1246
- {
1247
- binding: 0,
1248
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1249
- texture: { sampleType, viewDimension: "2d" }
1250
- },
1251
- {
1252
- binding: 1,
1253
- visibility: GPU_SHADER_STAGE_FRAGMENT,
1254
- sampler: {
1255
- type: sampleType === "depth" ? "comparison" : "filtering"
1256
- }
1257
- }
1258
- ];
1259
- }
1260
-
1261
- // src/scene/probe-blend-record.ts
1262
- var PROBE_BLEND_RECORD_BYTE_SIZE = 160;
1263
- var PROBE_BLEND_RECORD_STRIDE = 256;
1264
- var PROBE_BLEND_RECORD_CAPACITY = 64;
1265
- function probeBlendRecordOffset(objectKey) {
1266
- if (!Number.isInteger(objectKey) || objectKey < 0) {
1267
- throw new Error("probe blend record requires a non-negative object key");
1268
- }
1269
- return (objectKey + 1) * PROBE_BLEND_RECORD_STRIDE;
1270
- }
1271
-
1272
- // src/targets/material-source.ts
1273
- var sourceBindings = /* @__PURE__ */ new WeakMap();
1274
- function sourceToken() {
1275
- return Object.freeze({});
1276
- }
1277
- function resolveRenderTargetMaterialSource(source) {
1278
- return sourceBindings.get(source);
1279
- }
1280
- function invalid(field, value, expected) {
1281
- return {
1282
- ok: false,
1283
- error: new RenderTargetDescriptorInvalidError({ field, value, expected })
1284
- };
1285
- }
1286
- function createRenderTargetMaterialSource(target, descriptor, options) {
1287
- if (options.aspect !== "color") return invalid("aspect", options.aspect, "color");
1288
- if (options.dimension !== descriptor.shape) {
1289
- return invalid("dimension", options.dimension, `dimension matches ${descriptor.shape}`);
1290
- }
1291
- const mipCount = descriptor.mipLevels === 1 ? 1 : Math.floor(Math.log2(Math.max(descriptor.width, descriptor.height))) + 1;
1292
- if (!Number.isInteger(options.mipLevel) || options.mipLevel < 0 || options.mipLevel >= mipCount) {
1293
- return invalid("mipLevel", options.mipLevel, `an admitted mip level below ${mipCount}`);
1294
- }
1295
- if (!Number.isInteger(options.generation) || options.generation < 0) {
1296
- return invalid("generation", options.generation, "a non-negative device generation");
1297
- }
1298
- const result = {
1299
- ok: true,
1300
- value: Object.freeze({
1301
- source: sourceToken(),
1302
- target,
1303
- generation: options.generation,
1304
- shape: descriptor.shape,
1305
- format: descriptor.format,
1306
- view: Object.freeze({
1307
- dimension: options.dimension,
1308
- mipLevel: options.mipLevel,
1309
- resolveRequired: descriptor.sampleCount === 4
1310
- })
1311
- })
1312
- };
1313
- sourceBindings.set(result.value.source, result.value);
1314
- return result;
1315
- }
1316
-
1317
- // src/systems/pass-selector.ts
1318
- function matchPass(tags, selector) {
1319
- if (Object.keys(selector).length === 0) return true;
1320
- for (const [key, allowedValues] of Object.entries(selector)) {
1321
- const passValue = tags[key];
1322
- if (passValue === void 0) return false;
1323
- if (allowedValues.length === 0) return false;
1324
- if (!allowedValues.includes(passValue)) return false;
1325
- }
1326
- return true;
1327
- }
1328
- function selectPasses(passes, selector) {
1329
- if (Object.keys(selector).length === 0) return passes;
1330
- return passes.filter(
1331
- (p) => matchPass(p.renderState?.tags ?? {}, selector)
1332
- );
1333
- }
1334
-
1335
- // src/gpu-driven/prepared-draw.ts
1336
- function failure(code, detail) {
1337
- return { ok: false, error: new GpuDrivenPreparationError(code, detail) };
1338
- }
1339
- function hasRequiredVertexInputs(expected, actual) {
1340
- return expected.every(
1341
- (input) => actual.some(
1342
- (candidate) => candidate.semantic === input.semantic && candidate.location === input.location && candidate.format === input.format
1343
- )
1344
- );
1345
- }
1346
- function hasMaterialResources(snapshot, receipt) {
1347
- if ((snapshot.material.textureSources?.size ?? 0) > 0 || (snapshot.material.videoTextureFields?.size ?? 0) > 0) {
1348
- return false;
1349
- }
1350
- const textures = snapshot.material.textureHandles;
1351
- const samplers = snapshot.material.samplerHandles;
1352
- const authoredTextures = snapshot.material.authoredTextureFields;
1353
- const authoredSamplers = snapshot.material.authoredSamplerFields;
1354
- return receipt.resourceSlots.every((slot) => {
1355
- if (slot.kind === "storage-buffer") return false;
1356
- if (slot.kind === "texture") {
1357
- if (!authoredTextures?.has(slot.parameter)) return true;
1358
- return textures?.has(slot.parameter) === true || snapshot.material.textureSources?.has(slot.parameter) === true || snapshot.material.videoTextureFields?.has(slot.parameter) === true;
1359
- }
1360
- if (!authoredSamplers?.has(slot.parameter)) return true;
1361
- return samplers?.has(slot.parameter) === true;
1362
- });
1363
- }
1364
- function prepareGpuDrivenDraw(input) {
1365
- const receipt = input.artifact.receipt;
1366
- if (receipt === void 0) {
1367
- return failure("missing-material-receipt", {
1368
- reason: "material-receipt-missing",
1369
- owner: "material",
1370
- expected: "MaterialShaderArtifact.receipt"
1371
- });
1372
- }
1373
- if (receipt.generation !== input.generation) {
1374
- return failure("stale-generation", {
1375
- reason: "generation-stale",
1376
- owner: "generation",
1377
- expectedGeneration: input.generation,
1378
- actualGeneration: receipt.generation
1379
- });
1380
- }
1381
- if (receipt.reflection.layoutIdentity !== input.artifact.layoutIdentity) {
1382
- return failure("reflection-mismatch", {
1383
- reason: "reflection-receipt-mismatch",
1384
- owner: "material",
1385
- expected: input.artifact.layoutIdentity,
1386
- actual: receipt.reflection.layoutIdentity
1387
- });
1388
- }
1389
- if (receipt.uvSets.some((uv) => uv.set > 0) && input.geometry.vertexInputs.length < 3) {
1390
- return failure("missing-uv", {
1391
- reason: "uv-set-missing",
1392
- owner: "geometry",
1393
- expected: `${receipt.uvSets.length} material UV sets`,
1394
- actual: `${input.geometry.vertexInputs.filter((vertex) => vertex.semantic.startsWith("uv")).length} geometry UV sets`
1395
- });
1396
- }
1397
- if (!hasRequiredVertexInputs(receipt.vertexInputs, input.geometry.vertexInputs)) {
1398
- return failure("vertex-input-mismatch", {
1399
- reason: "vertex-semantic-mismatch",
1400
- owner: "geometry",
1401
- expected: receipt.vertexInputs.map((input2) => input2.semantic).join(","),
1402
- actual: input.geometry.vertexInputs.map((input2) => input2.semantic).join(",")
1403
- });
1404
- }
1405
- const hasAlphaMask = receipt.alphaMask.cutoff.length > 0 || receipt.alphaMask.source.length > 0;
1406
- if (hasAlphaMask && (receipt.alphaMask.cutoff.length === 0 || receipt.alphaMask.source.length === 0)) {
1407
- return failure("alpha-mask-mismatch", {
1408
- reason: "alpha-mask-receipt-missing",
1409
- owner: "material",
1410
- expected: "alphaMask.cutoff and alphaMask.source for a masked Pass"
1411
- });
1412
- }
1413
- if (!hasMaterialResources(input.snapshot, receipt)) {
1414
- return failure("resource-not-ready", {
1415
- reason: "material-resource-missing",
1416
- owner: "material",
1417
- expected: receipt.resourceSlots.map((slot) => slot.parameter).join(",")
1418
- });
1419
- }
1420
- const deformation = input.snapshot.skin === void 0 ? "rigid" : "skin";
1421
- if (deformation === "skin") {
1422
- if (input.skinReceipt === void 0 || receipt.skinPaletteAddress === void 0) {
1423
- return failure("skin-receipt-mismatch", {
1424
- reason: "skin-address-missing",
1425
- owner: "skin",
1426
- expected: "skinPaletteAddress and skinReceipt"
1427
- });
1428
- }
1429
- if (input.skinReceipt.identity !== input.snapshot.skin?.identity || input.skinReceipt.generation !== input.snapshot.skin?.generation || input.skinReceipt.group !== receipt.skinPaletteAddress.group || input.skinReceipt.binding !== receipt.skinPaletteAddress.binding) {
1430
- return failure("skin-receipt-mismatch", {
1431
- reason: "skin-address-missing",
1432
- owner: "skin",
1433
- expected: `${receipt.skinPaletteAddress.group}:${receipt.skinPaletteAddress.binding}@${input.snapshot.skin?.generation ?? "<missing>"}`,
1434
- actual: `${input.skinReceipt.group}:${input.skinReceipt.binding}@${input.skinReceipt.generation}`
1435
- });
1436
- }
1437
- }
1438
- return {
1439
- ok: true,
1440
- value: {
1441
- identity: {
1442
- material: input.artifact.material,
1443
- geometry: input.geometry.identity,
1444
- deformation
1445
- },
1446
- receiptGeneration: receipt.generation,
1447
- receiptIdentity: receipt.receiptIdentity,
1448
- directEntry: receipt.directEntry,
1449
- sceneIndexEntry: receipt.sceneIndexEntry,
1450
- materialRow: receipt.materialRow,
1451
- resourceSlots: receipt.resourceSlots,
1452
- uvSets: receipt.uvSets,
1453
- vertexInputs: receipt.vertexInputs,
1454
- alphaMask: receipt.alphaMask,
1455
- skinPaletteAddress: receipt.skinPaletteAddress,
1456
- topology: input.draw.topology,
1457
- indexed: input.draw.kind === "indexed",
1458
- first: input.draw.first,
1459
- count: input.draw.count,
1460
- baseVertex: input.draw.baseVertex
1461
- }
1462
- };
1463
- }
1464
-
1465
- // src/extract/gpu-driven.ts
1466
- function gpuDrivenDrawKey(worldEntity, materialHandle, drawItemIndex) {
1467
- return `${worldEntity}:${materialHandle}:${drawItemIndex}`;
1468
- }
1469
- function gpuDrivenShadowDrawKey(worldEntity, materialHandle, drawItemIndex, passIndex) {
1470
- return `${gpuDrivenDrawKey(worldEntity, materialHandle, drawItemIndex)}:${passIndex}`;
1471
- }
1472
- function gpuDrivenMaterialArtifactKey(input) {
1473
- return [
1474
- input.material,
1475
- input.deformation,
1476
- input.receiptIdentity ?? "<legacy-receipt>",
1477
- input.receiptGeneration
1478
- ].join("|");
1479
- }
1480
- function gpuDrivenSourceDrawItemIndex(draw, compactIndex) {
1481
- return draw.drawItemIndex ?? compactIndex;
1482
- }
1483
- function resolvePreparedGpuDrivenDraw(input) {
1484
- return prepareGpuDrivenDraw(input);
1485
- }
1486
- function gpuDrivenMaterialResourceClass(material) {
1487
- const textures = [...material.textureHandles?.entries() ?? []].map(([name, handle]) => [name, Number(handle)]).sort(([left], [right]) => left.localeCompare(right));
1488
- const samplers = [...material.samplerHandles?.entries() ?? []].map(([name, handle]) => [name, Number(handle)]).sort(([left], [right]) => left.localeCompare(right));
1489
- return JSON.stringify({
1490
- textures,
1491
- samplers
1492
- });
1493
- }
1494
- function hasCpuOnlyMaterialResources(material) {
1495
- return (material.textureSources?.size ?? 0) > 0 || (material.videoTextureFields?.size ?? 0) > 0;
1496
- }
1497
- function buildGpuDrivenDraws(input) {
1498
- const legacy = "submeshes" in input;
1499
- if (!legacy && input.mesh === void 0) return [];
1500
- const parsedMesh = legacy ? void 0 : input.mesh;
1501
- if (!legacy && parsedMesh === void 0) return [];
1502
- const indexed = legacy ? input.indexed : parsedMesh?.indices !== void 0;
1503
- const submeshes = legacy ? input.submeshes : parsedMesh?.submeshes ?? [];
1504
- const layoutProjection = parsedMesh === void 0 ? void 0 : deriveVertexLayoutProjection(parsedMesh.attributes);
1505
- const geometry = {
1506
- identity: parsedMesh === void 0 ? "<no-mesh>" : `${parsedMesh.guid ?? "<no-guid>"}:${layoutProjection?.digest ?? ""}`,
1507
- vertexInputs: (layoutProjection?.attributes ?? []).map((attribute) => ({
1508
- semantic: attribute.key,
1509
- location: attribute.shaderLocation,
1510
- format: attribute.format
1511
- })),
1512
- topology: submeshes[0]?.topology ?? "triangle-list",
1513
- indexed
1514
- };
1515
- let nonIndexedFirst = 0;
1516
- return submeshes.flatMap((submesh, drawItemIndex) => {
1517
- const drawMaterial = input.materials[submesh.materialSlot] ?? input.fallbackMaterial;
1518
- const first = indexed ? submesh.indexOffset : nonIndexedFirst;
1519
- nonIndexedFirst += submesh.vertexCount;
1520
- if (drawMaterial.transparent === true) return [];
1521
- const draw = {
1522
- drawItemIndex,
1523
- kind: indexed ? "indexed" : "non-indexed",
1524
- first,
1525
- count: indexed ? submesh.indexCount : submesh.vertexCount,
1526
- baseVertex: 0,
1527
- materialSlot: submesh.materialSlot,
1528
- topology: submesh.topology,
1529
- pipelineClass: `${drawMaterial.materialShaderId ?? "forgeax::default-unlit"}|${submesh.topology}|${JSON.stringify(drawMaterial.renderState ?? null)}`,
1530
- materialResourceClass: gpuDrivenMaterialResourceClass(drawMaterial)
1531
- };
1532
- const lodRanges = !legacy ? input.lodMeshes?.map((lodMesh) => {
1533
- if (lodMesh === void 0) return void 0;
1534
- const lower = lodMesh.submeshes[drawItemIndex];
1535
- if (lower === void 0) return void 0;
1536
- const lowerIndexed = lodMesh.indices !== void 0;
1537
- const lowerFirst = lowerIndexed ? lower.indexOffset : lodMesh.submeshes.slice(0, drawItemIndex).reduce((offset, entry) => offset + entry.vertexCount, 0);
1538
- return {
1539
- first: lowerFirst,
1540
- count: lowerIndexed ? lower.indexCount : lower.vertexCount,
1541
- baseVertex: 0
1542
- };
1543
- }) : void 0;
1544
- const withLodRanges = lodRanges?.length !== 0 && lodRanges?.every((range) => range !== void 0) ? { lodRanges } : {};
1545
- const prepared = legacy ? input.prepare?.(draw, drawMaterial) : hasCpuOnlyMaterialResources(drawMaterial) ? void 0 : (() => {
1546
- const materialShaderId = drawMaterial.materialShaderId;
1547
- const vertexColorAvailable = geometry.vertexInputs.some(
1548
- (input2) => input2.semantic === "color"
1549
- );
1550
- const sceneIndexProgramKey = Object.entries(
1551
- drawMaterial.materialSceneIndexProgramKeys ?? {}
1552
- ).find(
1553
- ([passName, program]) => program.pass === "forward" && drawMaterial.materialProgramKeys?.[passName] === materialShaderId
1554
- )?.[1]?.specializationKey;
1555
- const artifact = materialShaderId === void 0 ? void 0 : input.getMaterialShaderArtifact?.(sceneIndexProgramKey ?? materialShaderId, {
1556
- vertexColorAvailable,
1557
- deformation: input.baseSnapshot.skin === void 0 ? "rigid" : "skin",
1558
- pass: "forward",
1559
- address: "scene-index"
1560
- });
1561
- const requiresReceipt = isCanonicalStandardPbrMaterialShader(materialShaderId) || sceneIndexProgramKey !== void 0;
1562
- if (artifact === void 0) {
1563
- return input.getMaterialShaderArtifact !== void 0 && requiresReceipt ? new GpuDrivenPreparationError("missing-material-receipt", {
1564
- reason: "material-receipt-missing",
1565
- owner: "material",
1566
- expected: `artifact for ${materialShaderId}`
1567
- }) : void 0;
1568
- }
1569
- const receipt = artifact.receipt;
1570
- if (receipt === void 0) {
1571
- return new GpuDrivenPreparationError("missing-material-receipt", {
1572
- reason: "material-receipt-missing",
1573
- owner: "material",
1574
- expected: `receipt for ${materialShaderId}`
1575
- });
1576
- }
1577
- const skinReceipt = input.baseSnapshot.skin !== void 0 && receipt.skinPaletteAddress !== void 0 ? {
1578
- identity: input.baseSnapshot.skin.identity,
1579
- generation: input.baseSnapshot.skin.generation,
1580
- group: receipt.skinPaletteAddress.group,
1581
- binding: receipt.skinPaletteAddress.binding,
1582
- byteOffset: input.baseSnapshot.skin.byteOffset
1583
- } : void 0;
1584
- const selectedArtifact = artifact === void 0 || sceneIndexProgramKey === void 0 || materialShaderId === void 0 ? artifact : {
1585
- ...artifact,
1586
- material: materialShaderId,
1587
- specializationKey: sceneIndexProgramKey
1588
- };
1589
- const result = resolvePreparedGpuDrivenDraw({
1590
- snapshot: { ...input.baseSnapshot, material: drawMaterial },
1591
- artifact: selectedArtifact ?? artifact,
1592
- geometry: { ...geometry, topology: draw.topology, indexed: draw.kind === "indexed" },
1593
- generation: receipt.generation,
1594
- draw,
1595
- ...skinReceipt === void 0 ? {} : { skinReceipt }
1596
- });
1597
- return result.ok ? result.value : result.error;
1598
- })();
1599
- if (prepared instanceof GpuDrivenPreparationError) {
1600
- return [{ ...draw, preparationError: prepared, ...withLodRanges }];
1601
- }
1602
- return [
1603
- prepared === void 0 ? { ...draw, ...withLodRanges } : { ...draw, prepared, ...withLodRanges }
1604
- ];
1605
- });
1606
- }
1607
-
1608
- export { COOKIE_MATRIX_BYTES, COOKIE_SLICE_CAPACITY, COOKIE_SLICE_SIZE, DeviceScope, EXTENDED_LIGHTING_REQUIRED_SAMPLED_TEXTURES, EXTENDED_LIGHTING_TOPOLOGY, GPU_BUFFER_USAGE_COPY_DST, GPU_BUFFER_USAGE_COPY_SRC, GPU_BUFFER_USAGE_INDEX, GPU_BUFFER_USAGE_INDIRECT, GPU_BUFFER_USAGE_MAP_READ, GPU_BUFFER_USAGE_QUERY_RESOLVE, GPU_BUFFER_USAGE_STORAGE, GPU_BUFFER_USAGE_UNIFORM, GPU_BUFFER_USAGE_VERTEX, GPU_SHADER_STAGE_COMPUTE, GPU_SHADER_STAGE_FRAGMENT, GPU_SHADER_STAGE_VERTEX, IES_SLICE_CAPACITY, IES_SLICE_HEIGHT, IES_SLICE_WIDTH, LifecycleTransaction, PROBE_BLEND_RECORD_BYTE_SIZE, PROBE_BLEND_RECORD_CAPACITY, PROBE_BLEND_RECORD_STRIDE, SHADOW_CASTER_SHADER_ID, SKIN_MATERIAL_SHADER_ID, SPRITE_PASS_PER_INSTANCE_REGION_VARIANT_SET, buildBindGroupLayoutDescriptor, buildGpuDrivenDraws, buildGpuDrivenPbrInstancesBindGroupLayout, buildGpuDrivenPbrPipelineLayout, buildGpuDrivenPbrSkinPipelineLayout, buildPbrMaterialUserRegionEntries, buildPbrPipelineLayouts, buildPbrSkinLayouts, classifySceneDataCoverage, createHdrpBindGroupLayoutDescriptor, createHdrpSkinBindGroupLayoutDescriptor, createPbrSkinMeshBindGroupEntries, createRenderTargetMaterialSource, createTemporalCoverage, deriveExtendedLightingCapability, extendedLightingSampledTextureCapacityAvailable, getOpaqueResourceIdentity, getTextureIdentity, gpuDrivenDrawKey, gpuDrivenMaterialArtifactKey, gpuDrivenShadowDrawKey, gpuDrivenSourceDrawItemIndex, hasRequiredVertexInputs, instanceCollectionCacheKey, isCanonicalStandardPbrMaterialShader, isStandardPbrMaterialShader, isStandardPbrSkinMaterialShader, makeZeroCameraFallbackSnapshot, matchPass, materialBindGroupLayoutIdentity, pbrSkinMeshDynamicOffsets, physicalTextureFields, probeBlendRecordOffset, resolvePipelineGroup2Contract, resolveRenderTargetMaterialSource, scanSceneDataCoverage, selectPasses, shadowCasterVariantSet, validateGraphTargetCaptureReadback, worldEntityKey };
1609
- //# sourceMappingURL=chunk-3RTCJTH4.mjs.map
1610
- //# sourceMappingURL=chunk-3RTCJTH4.mjs.map