@woosh/meep-engine 3.61.1 → 3.61.3
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.
- package/CHANGELOG.md +111 -0
- package/package.json +1 -1
- package/src/engine/network/sim/SimActionExecutor.d.ts +4 -0
- package/src/engine/network/sim/SimActionExecutor.d.ts.map +1 -1
- package/src/engine/network/sim/SimActionExecutor.js +4 -0
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/generation/foliage/material/foliage_atlas_cutout.d.ts.map +1 -1
- package/src/generation/foliage/material/foliage_atlas_cutout.js +21 -5
- package/src/generation/foliage/mesh/tree_cluster_representatives.d.ts +8 -0
- package/src/generation/foliage/mesh/tree_cluster_representatives.d.ts.map +1 -1
- package/src/generation/foliage/mesh/tree_cluster_representatives.js +178 -78
- package/src/generation/foliage/mesh/tree_mesh_build_bark.d.ts.map +1 -1
- package/src/generation/foliage/mesh/tree_mesh_build_bark.js +178 -97
- package/src/generation/foliage/skeleton/ShootLightField.d.ts +1 -0
- package/src/generation/foliage/skeleton/ShootLightField.d.ts.map +1 -1
- package/src/generation/foliage/skeleton/ShootLightField.js +88 -17
- package/src/generation/foliage/skeleton/ShootWoodHash.d.ts +5 -2
- package/src/generation/foliage/skeleton/ShootWoodHash.d.ts.map +1 -1
- package/src/generation/foliage/skeleton/ShootWoodHash.js +191 -25
- package/src/shade/playground/probe_clipmap/README.md +3 -4
- package/src/shade/playground/probe_clipmap/index.html +5 -13
- package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
- package/src/shade/playground/probe_clipmap/main.js +4 -5
- package/src/shade/playground/probe_clipmap_box/README.md +55 -0
- package/src/shade/playground/probe_clipmap_box/index.html +185 -0
- package/src/shade/playground/probe_clipmap_box/main.d.ts +8 -0
- package/src/shade/playground/probe_clipmap_box/main.d.ts.map +1 -0
- package/src/shade/playground/probe_clipmap_box/main.js +323 -0
- package/src/shade/playground/probe_clipmap_box/scene.d.ts +93 -0
- package/src/shade/playground/probe_clipmap_box/scene.d.ts.map +1 -0
- package/src/shade/playground/probe_clipmap_box/scene.js +256 -0
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +56 -12
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
- package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
- package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
- package/src/shade/renderer/geometry/meshlet/meshlet_batch_colored.d.ts +10 -0
- package/src/shade/renderer/geometry/meshlet/meshlet_batch_colored.d.ts.map +1 -0
- package/src/shade/renderer/geometry/meshlet/meshlet_batch_colored.js +54 -0
- package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts +85 -36
- package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +813 -412
- package/src/shade/renderer/geometry/sdf/MESH_SDF.d.ts +7 -0
- package/src/shade/renderer/geometry/sdf/MESH_SDF.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/MESH_SDF.js +8 -0
- package/src/shade/renderer/geometry/sdf/MESH_SDF_BRICK_KEY.d.ts +14 -0
- package/src/shade/renderer/geometry/sdf/MESH_SDF_BRICK_KEY.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/MESH_SDF_BRICK_KEY.js +35 -0
- package/src/shade/renderer/geometry/sdf/MESH_SDF_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/MESH_SDF_STRUCT.js +0 -4
- package/src/shade/renderer/geometry/sdf/bake/MESH_SDF_BAKE.d.ts +55 -10
- package/src/shade/renderer/geometry/sdf/bake/MESH_SDF_BAKE.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/bake/MESH_SDF_BAKE.js +86 -16
- package/src/shade/renderer/geometry/sdf/bake/chunk_mesh_sdf_bake.d.ts +2 -2
- package/src/shade/renderer/geometry/sdf/bake/chunk_mesh_sdf_bake.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/bake/chunk_mesh_sdf_bake.js +28 -2
- package/src/shade/renderer/geometry/sdf/bake/chunk_mesh_sdf_contents.d.ts +54 -0
- package/src/shade/renderer/geometry/sdf/bake/chunk_mesh_sdf_contents.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bake/chunk_mesh_sdf_contents.js +146 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.d.ts +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.js +2 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_content_rehash.d.ts +18 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_content_rehash.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_content_rehash.js +66 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_count.d.ts +17 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_count.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_count.js +66 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.d.ts +5 -3
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.js +15 -14
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_free.d.ts +2 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_free.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_free.js +12 -3
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_key.d.ts +21 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_key.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_key.js +84 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_resolve.d.ts +53 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_resolve.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_resolve.js +343 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_store.d.ts +3 -3
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_store.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_store.js +9 -5
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_take.d.ts +2 -2
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_take.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_take.js +3 -2
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_upload.d.ts +69 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_upload.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_upload.js +294 -0
- package/src/shade/renderer/geometry/sdf/bundle/MODEL_CACHE_BUNDLE.d.ts +16 -0
- package/src/shade/renderer/geometry/sdf/bundle/MODEL_CACHE_BUNDLE.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bundle/MODEL_CACHE_BUNDLE.js +36 -0
- package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.d.ts +126 -0
- package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.js +148 -0
- package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_read.d.ts +10 -0
- package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_read.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_read.js +140 -0
- package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_write.d.ts +8 -0
- package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_write.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_write.js +76 -0
- package/src/shade/renderer/geometry/sdf/chunk_mesh_sdf.d.ts +9 -0
- package/src/shade/renderer/geometry/sdf/chunk_mesh_sdf.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/chunk_mesh_sdf.js +23 -0
- package/src/shade/renderer/geometry/sdf/chunk_mesh_sdf_brick_key.d.ts +13 -0
- package/src/shade/renderer/geometry/sdf/chunk_mesh_sdf_brick_key.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/chunk_mesh_sdf_brick_key.js +23 -0
- package/src/shade/renderer/geometry/sdf/surface/GPUMeshSurfaceCaches.d.ts +262 -0
- package/src/shade/renderer/geometry/sdf/surface/GPUMeshSurfaceCaches.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/GPUMeshSurfaceCaches.js +1819 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BAKE.d.ts +118 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BAKE.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BAKE.js +204 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BLOCK.d.ts +66 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BLOCK.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BLOCK.js +103 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_RESOURCES.d.ts +19 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_RESOURCES.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_RESOURCES.js +23 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_STRUCT.d.ts +15 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_STRUCT.js +70 -0
- package/src/shade/renderer/geometry/sdf/surface/SURFACE_MATERIAL.d.ts +13 -0
- package/src/shade/renderer/geometry/sdf/surface/SURFACE_MATERIAL.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/SURFACE_MATERIAL.js +35 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_block.d.ts +32 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_block.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_block.js +111 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_listed.d.ts +17 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_listed.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_listed.js +49 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_run_find.d.ts +13 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_run_find.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_run_find.js +35 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_sample.d.ts +24 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_sample.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_sample.js +169 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_texel_ray.d.ts +19 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_texel_ray.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_mesh_surface_texel_ray.js +49 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_surface_material_fit.d.ts +19 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_surface_material_fit.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_surface_material_fit.js +67 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_surface_material_read.d.ts +78 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_surface_material_read.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_surface_material_read.js +320 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_surface_material_store.d.ts +15 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_surface_material_store.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/chunk_surface_material_store.js +48 -0
- package/src/shade/renderer/geometry/sdf/surface/mesh_surface_channels.d.ts +51 -0
- package/src/shade/renderer/geometry/sdf/surface/mesh_surface_channels.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/mesh_surface_channels.js +109 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_command.d.ts +11 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_command.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_command.js +51 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_encode.d.ts +26 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_encode.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_encode.js +453 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_list.d.ts +12 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_list.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_list.js +99 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_survey.d.ts +22 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_survey.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_survey.js +140 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_trace.d.ts +32 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_trace.d.ts.map +1 -0
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_trace.js +261 -0
- package/src/shade/renderer/geometry/virtual/runtime/VirtualGeometry.d.ts +2 -2
- package/src/shade/renderer/geometry/virtual/runtime/VirtualGeometry.js +2 -2
- package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.d.ts +6 -6
- package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.js +7 -7
- package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v2/chunk_brick4_sh3_color_decode.d.ts +12 -0
- package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v2/chunk_brick4_sh3_color_decode.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v2/chunk_brick4_sh3_color_decode.js +49 -24
- package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v2/chunk_brick4_sh3_color_encode.d.ts +12 -0
- package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v2/chunk_brick4_sh3_color_encode.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v2/chunk_brick4_sh3_color_encode.js +50 -19
- package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v2/chunk_sh3_compress.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v2/chunk_sh3_compress.js +6 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +20 -8
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +89 -20
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.d.ts +26 -19
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.js +226 -148
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +25 -52
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +29 -69
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_CLIPMAP.d.ts +19 -16
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_CLIPMAP.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_CLIPMAP.js +24 -21
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts +46 -22
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.js +49 -36
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.d.ts +3 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.js +7 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +8 -22
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +15 -51
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.d.ts +1 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.js +6 -13
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.js +0 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.d.ts +4 -4
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.js +9 -34
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.d.ts +4 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.js +15 -39
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_clear.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_clear.js +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_store.d.ts +1 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_store.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_store.js +2 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_take.d.ts +2 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_take.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_take.js +5 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/ProbeClipmapDebugView.d.ts +5 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/ProbeClipmapDebugView.js +16 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_material.d.ts +45 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_material.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_material.js +208 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_indirect.d.ts +24 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_indirect.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_indirect.js +40 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_surfaces.d.ts +34 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_surfaces.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/{graph_probe_clipmap_debug_mesh_cards.js → graph_probe_clipmap_debug_mesh_surfaces.js} +38 -57
- package/src/shade/renderer/global_illumination/probe_clipmap/material/GPUBrickMaterial.d.ts +61 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/GPUBrickMaterial.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/GPUBrickMaterial.js +193 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.d.ts +67 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.js +142 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material_cell.d.ts +32 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material_cell.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material_cell.js +70 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material_store.d.ts +30 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material_store.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material_store.js +71 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/shader_brick_material_gather.d.ts +26 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/shader_brick_material_gather.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/material/shader_brick_material_gather.js +176 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts +23 -12
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.js +72 -52
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +32 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +37 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_INDIRECT_LOBE.d.ts +10 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_INDIRECT_LOBE.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_INDIRECT_LOBE.js +11 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapIndirectLobe.d.ts +11 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapIndirectLobe.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapIndirectLobe.js +15 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts +55 -23
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +134 -69
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_material.d.ts +43 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_material.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_material.js +138 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_indirect_lobe.d.ts +21 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_indirect_lobe.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_indirect_lobe.js +49 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.d.ts +4 -3
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.js +19 -24
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts +2 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.js +14 -19
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_select.d.ts +22 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_select.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_select.js +50 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts +4 -4
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.js +8 -8
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.js +8 -4
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.js +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.d.ts +5 -4
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.js +18 -23
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.js +4 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_diffuse.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_diffuse.js +4 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.d.ts +2 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.js +9 -8
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +2 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts +4 -3
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.js +14 -13
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts +7 -4
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.js +30 -26
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts +6 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +19 -21
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.js +6 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts +2 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.js +6 -6
- package/src/shade/renderer/gpu_primitive/hash_table/chunk_generate_next_linear_congruential_index.d.ts +14 -0
- package/src/shade/renderer/gpu_primitive/hash_table/chunk_generate_next_linear_congruential_index.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/hash_table/chunk_generate_next_linear_congruential_index.js +22 -0
- package/src/shade/renderer/gpu_primitive/hash_table/chunk_hash_table_atomic.d.ts +37 -0
- package/src/shade/renderer/gpu_primitive/hash_table/chunk_hash_table_atomic.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/hash_table/chunk_hash_table_atomic.js +122 -0
- package/src/shade/renderer/gpu_primitive/hash_table/chunk_hash_table_get.d.ts.map +1 -1
- package/src/shade/renderer/gpu_primitive/hash_table/chunk_hash_table_get.js +1 -11
- package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.d.ts +8 -0
- package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.d.ts.map +1 -1
- package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.js +6 -4
- package/src/shade/renderer/light/environment/shader_downsample_environment_map.d.ts.map +1 -1
- package/src/shade/renderer/light/environment/shader_downsample_environment_map.js +5 -1
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/material/resident/GPUResidentMaterialContext.d.ts +1 -1
- package/src/shade/renderer/material/resident/GPUResidentMaterialContext.d.ts.map +1 -1
- package/src/shade/renderer/material/resident/GPUResidentMaterialContext.js +2 -18
- package/src/shade/renderer/material/resident/NEUTRAL_SURFACE.d.ts +17 -0
- package/src/shade/renderer/material/resident/NEUTRAL_SURFACE.d.ts.map +1 -0
- package/src/shade/renderer/material/resident/NEUTRAL_SURFACE.js +16 -0
- package/src/shade/renderer/path_tracer/shader/INDIRECT_TEXTURE_FILTER.d.ts +1 -1
- package/src/shade/renderer/path_tracer/shader/INDIRECT_TEXTURE_FILTER.js +1 -1
- package/src/shade/renderer/path_tracer/shader/IndirectTextureFilter.js +1 -1
- package/src/shade/renderer/path_tracer/shader/chunk_beam_texture_level.d.ts +20 -0
- package/src/shade/renderer/path_tracer/shader/chunk_beam_texture_level.d.ts.map +1 -0
- package/src/shade/renderer/path_tracer/shader/chunk_beam_texture_level.js +65 -0
- package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts +26 -8
- package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.js +170 -142
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/rasterize/forward/chunk_forward_sample_indirect_probe_clipmap.d.ts +1 -1
- package/src/shade/renderer/rasterize/forward/chunk_forward_sample_indirect_probe_clipmap.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/forward/chunk_forward_sample_indirect_probe_clipmap.js +5 -8
- package/src/shade/renderer/scene/GPUSceneContext.d.ts +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.js +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts +15 -4
- package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.js +33 -7
- package/src/shade/renderer/shader/chunk/material/albedo_compress.d.ts +12 -0
- package/src/shade/renderer/shader/chunk/material/albedo_compress.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/material/albedo_compress.js +26 -0
- package/src/shade/renderer/shader/chunk/material/chunk_albedo_compress.d.ts +16 -0
- package/src/shade/renderer/shader/chunk/material/chunk_albedo_compress.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/material/chunk_albedo_compress.js +22 -0
- package/src/shade/renderer/shader/chunk/material/chunk_albedo_uncompress.d.ts +15 -0
- package/src/shade/renderer/shader/chunk/material/chunk_albedo_uncompress.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/material/chunk_albedo_uncompress.js +23 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metal_rough_compress.d.ts +16 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metal_rough_compress.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metal_rough_compress.js +25 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metal_rough_uncompress.d.ts +25 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metal_rough_uncompress.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metal_rough_uncompress.js +36 -0
- package/src/shade/renderer/shader/chunk/material/metal_rough_compress.d.ts +11 -0
- package/src/shade/renderer/shader/chunk/material/metal_rough_compress.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/material/metal_rough_compress.js +38 -0
- package/src/shade/renderer/shader/chunk/noise/chunk_sobol_sample_vec2.d.ts +40 -0
- package/src/shade/renderer/shader/chunk/noise/chunk_sobol_sample_vec2.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/chunk_sobol_sample_vec2.js +75 -0
- package/src/shade/renderer/shader/chunk/noise/chunk_vdc_radical_inverse.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/noise/chunk_vdc_radical_inverse.js +3 -1
- package/src/shade/renderer/shader/chunk/random/chunk_hash_lk.d.ts +28 -0
- package/src/shade/renderer/shader/chunk/random/chunk_hash_lk.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/random/chunk_hash_lk.js +41 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh3_color_add_scaled.d.ts +12 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh3_color_add_scaled.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh3_color_add_scaled.js +24 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot.d.ts +20 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot.js +35 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot_compress.d.ts +28 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot_compress.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot_compress.js +79 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot_fit.d.ts +25 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot_fit.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot_fit.js +89 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot_uncompress.d.ts +31 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot_uncompress.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/spherical_harmonics/pivot/chunk_sh2_color_pivot_uncompress.js +66 -0
- package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_atomic_add.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_atomic_add.js +2 -0
- package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_atomic_load.d.ts +17 -0
- package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_atomic_load.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_atomic_load.js +34 -0
- package/src/shade/renderer/volumetrics/chunk_frustum_unit_box_coverage_multisample.d.ts +18 -0
- package/src/shade/renderer/volumetrics/chunk_frustum_unit_box_coverage_multisample.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/chunk_frustum_unit_box_coverage_multisample.js +31 -23
- package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts +3 -2
- package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.js +4 -0
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.d.ts +2 -5
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.js +3 -20
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_participating_media.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_participating_media.js +5 -6
- package/src/shade/renderer/water/chunk_water_gi.d.ts +1 -1
- package/src/shade/renderer/water/chunk_water_gi.d.ts.map +1 -1
- package/src/shade/renderer/water/chunk_water_gi.js +6 -8
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
- package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
- package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
- package/src/shade/wgsl/emulator/WGSLLanguageCore.js +76 -32
- package/src/core/math/hash/squirrel3.d.ts +0 -17
- package/src/core/math/hash/squirrel3.d.ts.map +0 -1
- package/src/core/math/hash/squirrel3.js +0 -30
- package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.d.ts +0 -213
- package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.js +0 -1468
- package/src/shade/renderer/geometry/sdf/cards/MESH_CARDS.d.ts +0 -82
- package/src/shade/renderer/geometry/sdf/cards/MESH_CARDS.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/MESH_CARDS.js +0 -127
- package/src/shade/renderer/geometry/sdf/cards/MESH_CARD_RESOURCES.d.ts +0 -24
- package/src/shade/renderer/geometry/sdf/cards/MESH_CARD_RESOURCES.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/MESH_CARD_RESOURCES.js +0 -29
- package/src/shade/renderer/geometry/sdf/cards/MESH_CARD_SET_STRUCT.d.ts +0 -12
- package/src/shade/renderer/geometry/sdf/cards/MESH_CARD_SET_STRUCT.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/MESH_CARD_SET_STRUCT.js +0 -31
- package/src/shade/renderer/geometry/sdf/cards/MeshCardCaptureMode.d.ts +0 -11
- package/src/shade/renderer/geometry/sdf/cards/MeshCardCaptureMode.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/MeshCardCaptureMode.js +0 -21
- package/src/shade/renderer/geometry/sdf/cards/chunk_mesh_card_surface.d.ts +0 -29
- package/src/shade/renderer/geometry/sdf/cards/chunk_mesh_card_surface.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/chunk_mesh_card_surface.js +0 -179
- package/src/shade/renderer/geometry/sdf/cards/chunk_mesh_cards.d.ts +0 -17
- package/src/shade/renderer/geometry/sdf/cards/chunk_mesh_cards.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/chunk_mesh_cards.js +0 -107
- package/src/shade/renderer/geometry/sdf/cards/mesh_cards_raster_pass_descriptor.d.ts +0 -65
- package/src/shade/renderer/geometry/sdf/cards/mesh_cards_raster_pass_descriptor.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/mesh_cards_raster_pass_descriptor.js +0 -376
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_capture.d.ts +0 -40
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_capture.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_capture.js +0 -301
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_compact.d.ts +0 -19
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_compact.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_compact.js +0 -61
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_histogram.d.ts +0 -18
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_histogram.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_histogram.js +0 -102
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_log.d.ts +0 -15
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_log.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_log.js +0 -65
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_merge.d.ts +0 -22
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_merge.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_merge.js +0 -136
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_pages.d.ts +0 -20
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_pages.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_pages.js +0 -104
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_args.d.ts +0 -20
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_args.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_args.js +0 -80
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_scatter.d.ts +0 -18
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_scatter.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_scatter.js +0 -113
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_split.d.ts +0 -30
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_split.d.ts.map +0 -1
- package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_split.js +0 -146
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_cards.d.ts +0 -34
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_cards.d.ts.map +0 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_surface.d.ts +0 -31
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_surface.d.ts.map +0 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_surface.js +0 -82
- package/src/shade/renderer/shader/chunk/random/chunk_hash_squirrel3.d.ts +0 -12
- package/src/shade/renderer/shader/chunk/random/chunk_hash_squirrel3.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/random/chunk_hash_squirrel3.js +0 -30
|
@@ -1,1468 +0,0 @@
|
|
|
1
|
-
import { assert } from "../../../../../core/assert.js";
|
|
2
|
-
import { ALLOCATOR_NO_SPACE, OffsetAllocator } from "../../../../../core/binary/allocator/OffsetAllocator.js";
|
|
3
|
-
import Signal from "../../../../../core/events/signal/Signal.js";
|
|
4
|
-
import IdPool from "../../../../../core/IdPool.js";
|
|
5
|
-
import { warn_limited } from "../../../../util/warn_limited.js";
|
|
6
|
-
import { BufferDescriptor } from "../../../../descriptor/buffer/BufferDescriptor.js";
|
|
7
|
-
import { BindGroupDescriptor } from "../../../binding/BindGroupDescriptor.js";
|
|
8
|
-
import { STRUCT_UNINDEXED_DRAW_COMMAND } from "../../../gpu_primitive/indirect/STRUCT_UNINDEXED_DRAW_COMMAND.js";
|
|
9
|
-
import { WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION } from "../../../gpu_primitive/indirect/WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION.js";
|
|
10
|
-
import { graph_import_texture } from "../../../shader/graph/graph_import_texture.js";
|
|
11
|
-
import { GPUTileAtlas2D } from "../../../texture/atlas/GPUTileAtlas2D.js";
|
|
12
|
-
import { MESH_SDF_BAKE_WORKGROUP_SIZE } from "../bake/MESH_SDF_BAKE.js";
|
|
13
|
-
import { MESH_CARD_PAGE_TEXELS } from "./MESH_CARDS.js";
|
|
14
|
-
import { MESH_CARD_SET_STRUCT } from "./MESH_CARD_SET_STRUCT.js";
|
|
15
|
-
import { MeshCardCaptureMode } from "./MeshCardCaptureMode.js";
|
|
16
|
-
import {
|
|
17
|
-
MESH_CARD_RASTER_CELLS_X,
|
|
18
|
-
MESH_CARD_RASTER_CELLS_Y,
|
|
19
|
-
MESH_CARD_RASTER_DEPTH_FORMAT,
|
|
20
|
-
MESH_CARD_RASTER_TARGET_FORMATS,
|
|
21
|
-
MESH_CARDS_RASTER_IMMEDIATE_SIZE,
|
|
22
|
-
MESH_CARDS_RASTER_LAYOUT,
|
|
23
|
-
mesh_cards_raster_pass_descriptor
|
|
24
|
-
} from "./mesh_cards_raster_pass_descriptor.js";
|
|
25
|
-
import { shader_mesh_cards_capture } from "./shader_mesh_cards_capture.js";
|
|
26
|
-
import { MESH_CARDS_RASTER_ARGS_WORKGROUP_SIZE, shader_mesh_cards_raster_args } from "./shader_mesh_cards_raster_args.js";
|
|
27
|
-
import { shader_mesh_cards_raster_scatter } from "./shader_mesh_cards_raster_scatter.js";
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @typedef {import("../../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph} FrameGraph
|
|
31
|
-
* @typedef {import("../../../material/ShadeMaterial.js").ShadeMaterial} ShadeMaterial
|
|
32
|
-
* @typedef {import("../../../material/resident/GPUResidentMaterialContext.js").GPUResidentMaterialContext} GPUResidentMaterialContext
|
|
33
|
-
* @typedef {import("../../../material/GPUMaterialManager.js").GPUMaterialManager} GPUMaterialManager
|
|
34
|
-
* @typedef {import("../../../material/GPUMaterialContext.js").GPUMaterialContext} GPUMaterialContext
|
|
35
|
-
* @typedef {import("../../../../../core/binary/allocator/OffsetAllocator.js").Allocation} Allocation
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/** The id is free. */
|
|
39
|
-
const SET_NONE = 0;
|
|
40
|
-
/** Its geometry's layout is not placed: nothing to capture into yet. */
|
|
41
|
-
const SET_WAITING = 1;
|
|
42
|
-
/** Its first capture is queued or part done; readers find no card set. */
|
|
43
|
-
const SET_CAPTURING = 2;
|
|
44
|
-
/** Captured; it may be queued for a recapture, and reads the last capture until that is done. */
|
|
45
|
-
const SET_RESIDENT = 3;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Texels a page has, and so the capture's threads a page.
|
|
49
|
-
* @type {number}
|
|
50
|
-
*/
|
|
51
|
-
const PAGE_THREADS = MESH_CARD_PAGE_TEXELS * MESH_CARD_PAGE_TEXELS;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Most pages a frame's capture may take: a workgroup a page, in one dispatch row.
|
|
55
|
-
* @type {number}
|
|
56
|
-
*/
|
|
57
|
-
export const MESH_CARD_CAPTURE_BUDGET_MAX = WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Texels across the raster scratch, and down it at most: a frame's raster runs are packed into it in
|
|
61
|
-
* shelves, and one that does not fit waits for the next frame. A frame's first run always fits, at
|
|
62
|
-
* whatever size its region is.
|
|
63
|
-
* @type {number}
|
|
64
|
-
*/
|
|
65
|
-
const RASTER_SCRATCH_SIDE = 2048;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* The raster scratch grows in steps of this many texels a side, so a frame a little larger than the
|
|
69
|
-
* last does not make it again.
|
|
70
|
-
* @type {number}
|
|
71
|
-
*/
|
|
72
|
-
const RASTER_SCRATCH_STEP = 256;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* s_e: the largest component of a material's emissive factor, which the capture stores emissive
|
|
76
|
-
* over. 0 for a material that emits nothing, or that has no emissive factor.
|
|
77
|
-
*
|
|
78
|
-
* @param {ShadeMaterial} material
|
|
79
|
-
* @returns {number}
|
|
80
|
-
*/
|
|
81
|
-
export function mesh_card_emissive_scale_of(material) {
|
|
82
|
-
if (material.isStandardShadeMaterial !== true) {
|
|
83
|
-
return 0;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const e = material.emissive_factor;
|
|
87
|
-
|
|
88
|
-
return Math.max(0, e.r, e.g, e.b);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @template {Uint8Array|Uint32Array} T
|
|
93
|
-
* @param {T} array
|
|
94
|
-
* @param {number} length
|
|
95
|
-
* @returns {T}
|
|
96
|
-
*/
|
|
97
|
-
function grow_typed(array, length) {
|
|
98
|
-
if (array.length >= length) {
|
|
99
|
-
return array;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let size = Math.max(1, array.length);
|
|
103
|
-
|
|
104
|
-
while (size < length) {
|
|
105
|
-
size *= 2;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const grown = new array.constructor(size);
|
|
109
|
-
|
|
110
|
-
grown.set(array);
|
|
111
|
-
|
|
112
|
-
return grown;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Card sets (PROBE_CLIPMAP_PROPOSAL_2026_10_27.md §6.5): one (geometry, material) pair's capture of
|
|
117
|
-
* its geometry's card layout, by card set id, the storage of which {@link GPUGeometrySDFManager}
|
|
118
|
-
* keeps beside its fields and layouts.
|
|
119
|
-
*
|
|
120
|
-
* - A card set's pages are a run of tiles of the card atlas, one a page of the layout, in the
|
|
121
|
-
* layout's order, from page_base. The layout's column tables are the geometry's, shared by every
|
|
122
|
-
* card set of it, so a card set needs no page table of its own.
|
|
123
|
-
* - The atlas is two `rgba8unorm` planes of 8×8 tiles ({@link GPUTileAtlas2D}): √(diffuse albedo)
|
|
124
|
-
* and depth; emissive / s_e and 0.
|
|
125
|
-
* - Its record (`MESH_CARD_SET_STRUCT`) is written when a capture starts.
|
|
126
|
-
*
|
|
127
|
-
* **Lifetime.** {@link acquire} makes a card set for a pair and {@link release} gives it back; the
|
|
128
|
-
* caller keeps one per pair. A card set of an aliased geometry ({@link alias}) is its source's: it
|
|
129
|
-
* captures the source's layout through the source's meshlets. A card set waits until its geometry's layout is placed
|
|
130
|
-
* ({@link set_layout}), is then captured, and turns resident ({@link onResident}) on the frame its
|
|
131
|
-
* last page is recorded: the capture's writes come before any later pass reads it. A layout that
|
|
132
|
-
* goes ({@link drop_layout}) withdraws its card sets ({@link onWithdrawn}) back to waiting.
|
|
133
|
-
*
|
|
134
|
-
* **Capture** ({@link graph_capture}, once a frame) takes at most `budget` pages, first captures in
|
|
135
|
-
* the order they were asked for, then recaptures in the order queued. A card set's pages may span
|
|
136
|
-
* frames. {@link recapture} queues a resident card set again, which reads its last capture until the
|
|
137
|
-
* new one is done; a card set whose capture is under way starts it again.
|
|
138
|
-
*
|
|
139
|
-
* **Modes** ({@link capture_mode}). A traced card set is a run of pages, a thread a texel. A
|
|
140
|
-
* rastered one is taken whole: its cards are drawn into a region of a scratch, a cell a card, and its
|
|
141
|
-
* pages scattered from there into the atlas; the frame's last one may take the budget past its end.
|
|
142
|
-
*/
|
|
143
|
-
export class GPUMeshCardSets {
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @type {GPUDevice}
|
|
147
|
-
*/
|
|
148
|
-
#device;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Sent with a card set id when its first capture is recorded in full.
|
|
152
|
-
* @type {Signal<number>}
|
|
153
|
-
*/
|
|
154
|
-
onResident = new Signal();
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Sent with a resident card set's id when its layout goes; it waits for the next.
|
|
158
|
-
* @type {Signal<number>}
|
|
159
|
-
*/
|
|
160
|
-
onWithdrawn = new Signal();
|
|
161
|
-
|
|
162
|
-
#ids = new IdPool();
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* The source of each aliased geometry id.
|
|
166
|
-
* @type {Map<number, number>}
|
|
167
|
-
*/
|
|
168
|
-
#source_of = new Map();
|
|
169
|
-
|
|
170
|
-
// ---- per card set id ----
|
|
171
|
-
|
|
172
|
-
#state = new Uint8Array(64);
|
|
173
|
-
#geometry = new Uint32Array(64);
|
|
174
|
-
/**
|
|
175
|
-
* Bumped whenever the id's queue entries go stale: given out, given back, its layout gone.
|
|
176
|
-
*/
|
|
177
|
-
#ticket = new Uint32Array(64);
|
|
178
|
-
/** Pages of the capture under way taken so far. */
|
|
179
|
-
#next_page = new Uint32Array(64);
|
|
180
|
-
/** Whether a queue holds a live entry of the id. */
|
|
181
|
-
#queued = new Uint8Array(64);
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @type {(ShadeMaterial|undefined)[]}
|
|
185
|
-
*/
|
|
186
|
-
#material = [];
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* @type {(Allocation|null)[]}
|
|
190
|
-
*/
|
|
191
|
-
#tiles = [];
|
|
192
|
-
|
|
193
|
-
// ---- per geometry id ----
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Pages of each placed layout, by geometry id.
|
|
197
|
-
* @type {Map<number, number>}
|
|
198
|
-
*/
|
|
199
|
-
#layout_pages = new Map();
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Texels a side of each placed layout's largest card, by geometry id: the side of a raster cell.
|
|
203
|
-
* @type {Map<number, number>}
|
|
204
|
-
*/
|
|
205
|
-
#layout_side = new Map();
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* The card sets of each geometry, by geometry id.
|
|
209
|
-
* @type {Map<number, number[]>}
|
|
210
|
-
*/
|
|
211
|
-
#sets_of_geometry = new Map();
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* @type {MeshCardCaptureMode}
|
|
215
|
-
*/
|
|
216
|
-
#capture_mode = MeshCardCaptureMode.Raster;
|
|
217
|
-
|
|
218
|
-
// ---- the queues: (id, ticket) pairs, from a head ----
|
|
219
|
-
|
|
220
|
-
#queue_new = [];
|
|
221
|
-
#head_new = 0;
|
|
222
|
-
#queue_re = [];
|
|
223
|
-
#head_re = 0;
|
|
224
|
-
|
|
225
|
-
// ---- device storage, made on first use ----
|
|
226
|
-
|
|
227
|
-
/** @type {GPUBuffer|null} */
|
|
228
|
-
#records = null;
|
|
229
|
-
#record_capacity = 0;
|
|
230
|
-
#record_scratch = new DataView(new ArrayBuffer(MESH_CARD_SET_STRUCT.size));
|
|
231
|
-
|
|
232
|
-
/** @type {GPUTileAtlas2D|null} */
|
|
233
|
-
#atlas = null;
|
|
234
|
-
/** @type {OffsetAllocator|null} */
|
|
235
|
-
#tile_allocator = null;
|
|
236
|
-
|
|
237
|
-
/** @type {GPUBuffer|null} */
|
|
238
|
-
#runs = null;
|
|
239
|
-
#run_capacity = 0;
|
|
240
|
-
#run_scratch = new Uint32Array(4 * 64);
|
|
241
|
-
|
|
242
|
-
#frame_runs = 0;
|
|
243
|
-
#frame_threads = 0;
|
|
244
|
-
/** Pages of the frame's budget not yet taken. */
|
|
245
|
-
#frame_left = 0;
|
|
246
|
-
|
|
247
|
-
#settings = { run_count: 0, thread_count: 0, groups_x: 0 };
|
|
248
|
-
#bindings = {};
|
|
249
|
-
#pass_data = { albedo: -1, emissive: -1 };
|
|
250
|
-
|
|
251
|
-
// ---- raster capture: a run a whole card set, (first scatter thread, id, region corner, cell side) ----
|
|
252
|
-
|
|
253
|
-
/** @type {GPUBuffer|null} */
|
|
254
|
-
#raster_runs = null;
|
|
255
|
-
/** @type {GPUBuffer|null} */
|
|
256
|
-
#raster_draws = null;
|
|
257
|
-
#raster_run_capacity = 0;
|
|
258
|
-
#raster_run_scratch = new Uint32Array(4 * 64);
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* The material context each of the frame's raster runs draws with.
|
|
262
|
-
* @type {GPUMaterialContext[]}
|
|
263
|
-
*/
|
|
264
|
-
#frame_raster_materials = [];
|
|
265
|
-
|
|
266
|
-
#frame_raster_runs = 0;
|
|
267
|
-
#frame_raster_threads = 0;
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* What a frame's capture draws with, for the raster: set by {@link graph_capture}.
|
|
271
|
-
* @type {GPUMaterialManager|null}
|
|
272
|
-
*/
|
|
273
|
-
#frame_material_contexts = null;
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* What a frame's capture traces with: set by {@link graph_capture}. Only what is traced is made
|
|
277
|
-
* resident, each run's material as its run is taken, so a frame that traces nothing leaves the
|
|
278
|
-
* resident materials as they were.
|
|
279
|
-
* @type {GPUResidentMaterialContext|null}
|
|
280
|
-
*/
|
|
281
|
-
#frame_materials = null;
|
|
282
|
-
|
|
283
|
-
// the frame's shelves in the scratch
|
|
284
|
-
#shelf_x = 0;
|
|
285
|
-
#shelf_y = 0;
|
|
286
|
-
#shelf_height = 0;
|
|
287
|
-
#frame_scratch_width = 0;
|
|
288
|
-
#frame_scratch_height = 0;
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* √(diffuse albedo) and depth, emissive / s_e, then depth through the slab.
|
|
292
|
-
* @type {GPUTexture[]}
|
|
293
|
-
*/
|
|
294
|
-
#raster_targets = [];
|
|
295
|
-
/** @type {GPUTextureView[]} */
|
|
296
|
-
#raster_views = [];
|
|
297
|
-
#raster_width = 0;
|
|
298
|
-
#raster_height = 0;
|
|
299
|
-
|
|
300
|
-
#raster_pass_descriptor = {
|
|
301
|
-
label: "Mesh Card Capture / Raster",
|
|
302
|
-
colorAttachments: MESH_CARD_RASTER_TARGET_FORMATS.map(() => ({
|
|
303
|
-
view: null,
|
|
304
|
-
loadOp: "clear",
|
|
305
|
-
storeOp: "store",
|
|
306
|
-
clearValue: [0, 0, 0, 0],
|
|
307
|
-
})),
|
|
308
|
-
depthStencilAttachment: {
|
|
309
|
-
view: null,
|
|
310
|
-
depthLoadOp: "clear",
|
|
311
|
-
depthStoreOp: "discard",
|
|
312
|
-
depthClearValue: 1,
|
|
313
|
-
},
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
#raster_immediate = new Uint32Array(MESH_CARDS_RASTER_IMMEDIATE_SIZE / 4);
|
|
317
|
-
#raster_immediate_f32 = new Float32Array(this.#raster_immediate.buffer);
|
|
318
|
-
|
|
319
|
-
#raster_args_settings = { run_count: 0 };
|
|
320
|
-
#raster_args_bindings = {};
|
|
321
|
-
#raster_scatter_settings = { run_count: 0, thread_count: 0, groups_x: 0 };
|
|
322
|
-
#raster_scatter_bindings = {};
|
|
323
|
-
#raster_pass_data = { arena: -1, albedo: -1, emissive: -1 };
|
|
324
|
-
/** The buffers group 1 of the draws binds beside the arena, as the frame's capture was recorded. */
|
|
325
|
-
#raster_group_buffers = { mesh_sdf_headers: null, geometries: null, meshlet_metadata: null, meshlet_data: null };
|
|
326
|
-
|
|
327
|
-
/** Card sets turned resident by the frame's capture, sent once it is recorded. */
|
|
328
|
-
#completed = [];
|
|
329
|
-
|
|
330
|
-
// ---- what has been done ----
|
|
331
|
-
|
|
332
|
-
#recaptures_requested = 0;
|
|
333
|
-
#pages_captured = 0;
|
|
334
|
-
#resident_count = 0;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* @param {GPUDevice} device
|
|
338
|
-
*/
|
|
339
|
-
constructor(device) {
|
|
340
|
-
assert.defined(device, 'device');
|
|
341
|
-
|
|
342
|
-
this.#device = device;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Card sets given out.
|
|
347
|
-
* @returns {number}
|
|
348
|
-
*/
|
|
349
|
-
get count() {
|
|
350
|
-
let count = 0;
|
|
351
|
-
|
|
352
|
-
for (let id = 0; id < this.#state.length; id++) {
|
|
353
|
-
if (this.#state[id] !== SET_NONE) {
|
|
354
|
-
count++;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
return count;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* @returns {number}
|
|
363
|
-
*/
|
|
364
|
-
get resident_count() {
|
|
365
|
-
return this.#resident_count;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Recaptures asked of resident card sets, and of captures under way restarted.
|
|
370
|
-
* @returns {number}
|
|
371
|
-
*/
|
|
372
|
-
get recaptures_requested() {
|
|
373
|
-
return this.#recaptures_requested;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Pages the captures have recorded.
|
|
378
|
-
* @returns {number}
|
|
379
|
-
*/
|
|
380
|
-
get pages_captured() {
|
|
381
|
-
return this.#pages_captured;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Whether a frame's capture has anything to do: pages queued, or card sets turned resident with
|
|
386
|
-
* nothing to capture, still to be announced.
|
|
387
|
-
* @returns {boolean}
|
|
388
|
-
*/
|
|
389
|
-
get has_pending_capture() {
|
|
390
|
-
return this.#head_new < this.#queue_new.length
|
|
391
|
-
|| this.#head_re < this.#queue_re.length
|
|
392
|
-
|| this.#completed.length > 0;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Pages waiting for capture over every queue.
|
|
397
|
-
* @returns {number}
|
|
398
|
-
*/
|
|
399
|
-
get pages_queued() {
|
|
400
|
-
let pages = 0;
|
|
401
|
-
|
|
402
|
-
for (const [queue, head] of [[this.#queue_new, this.#head_new], [this.#queue_re, this.#head_re]]) {
|
|
403
|
-
for (let i = head; i < queue.length; i += 2) {
|
|
404
|
-
const id = queue[i];
|
|
405
|
-
|
|
406
|
-
if (queue[i + 1] === this.#ticket[id]) {
|
|
407
|
-
pages += this.#layout_pages.get(this.#geometry[id]) - this.#next_page[id];
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
return pages;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* @returns {MeshCardCaptureMode}
|
|
417
|
-
*/
|
|
418
|
-
get capture_mode() {
|
|
419
|
-
return this.#capture_mode;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* A change captures every card set again in the new mode: resident ones read their last capture
|
|
424
|
-
* until it is done, and captures under way start again.
|
|
425
|
-
*
|
|
426
|
-
* @param {MeshCardCaptureMode} mode
|
|
427
|
-
*/
|
|
428
|
-
set capture_mode(mode) {
|
|
429
|
-
assert.enum(mode, MeshCardCaptureMode, 'mode');
|
|
430
|
-
|
|
431
|
-
if (mode === this.#capture_mode) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
this.#capture_mode = mode;
|
|
436
|
-
|
|
437
|
-
for (let id = 0; id < this.#state.length; id++) {
|
|
438
|
-
const state = this.#state[id];
|
|
439
|
-
|
|
440
|
-
if (state === SET_CAPTURING || state === SET_RESIDENT) {
|
|
441
|
-
this.recapture(id);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Whether readers may use the card set: captured at least once, and its layout still there.
|
|
448
|
-
*
|
|
449
|
-
* @param {number} id
|
|
450
|
-
* @returns {boolean}
|
|
451
|
-
*/
|
|
452
|
-
is_resident(id) {
|
|
453
|
-
return this.#state[id] === SET_RESIDENT;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* The card set's geometry id.
|
|
458
|
-
*
|
|
459
|
-
* @param {number} id
|
|
460
|
-
* @returns {number}
|
|
461
|
-
*/
|
|
462
|
-
geometry_of(id) {
|
|
463
|
-
return this.#geometry[id];
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Every card set's record, by id. Replaced when it grows; take it each frame.
|
|
468
|
-
* @returns {GPUBuffer}
|
|
469
|
-
*/
|
|
470
|
-
get records() {
|
|
471
|
-
this.#ensure_device();
|
|
472
|
-
|
|
473
|
-
return this.#records;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* The card atlas: plane 0 holds √(diffuse albedo) and depth, plane 1 emissive / s_e.
|
|
478
|
-
* @returns {GPUTileAtlas2D}
|
|
479
|
-
*/
|
|
480
|
-
get atlas() {
|
|
481
|
-
this.#ensure_device();
|
|
482
|
-
|
|
483
|
-
return this.#atlas;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
/**
|
|
487
|
-
* A card set for a pair. The caller keeps one per pair.
|
|
488
|
-
*
|
|
489
|
-
* @param {number} geometry the geometry id the pair draws; an aliased one's card set captures its source's
|
|
490
|
-
* layout ({@link alias})
|
|
491
|
-
* @param {ShadeMaterial} material
|
|
492
|
-
* @returns {number} card set id
|
|
493
|
-
*/
|
|
494
|
-
acquire(geometry, material) {
|
|
495
|
-
assert.isNonNegativeInteger(geometry, 'geometry');
|
|
496
|
-
assert.defined(material, 'material');
|
|
497
|
-
|
|
498
|
-
geometry = this.#source_of.get(geometry) ?? geometry;
|
|
499
|
-
|
|
500
|
-
const id = this.#ids.get();
|
|
501
|
-
|
|
502
|
-
this.#ensure_id(id);
|
|
503
|
-
|
|
504
|
-
this.#state[id] = SET_WAITING;
|
|
505
|
-
this.#geometry[id] = geometry;
|
|
506
|
-
this.#material[id] = material;
|
|
507
|
-
this.#ticket[id]++;
|
|
508
|
-
this.#next_page[id] = 0;
|
|
509
|
-
this.#queued[id] = 0;
|
|
510
|
-
|
|
511
|
-
let sets = this.#sets_of_geometry.get(geometry);
|
|
512
|
-
|
|
513
|
-
if (sets === undefined) {
|
|
514
|
-
sets = [];
|
|
515
|
-
this.#sets_of_geometry.set(geometry, sets);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
sets.push(id);
|
|
519
|
-
|
|
520
|
-
if (this.#layout_pages.has(geometry)) {
|
|
521
|
-
this.#start(id);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
return id;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* @param {number} id
|
|
529
|
-
*/
|
|
530
|
-
release(id) {
|
|
531
|
-
assert.notEqual(this.#state[id] ?? SET_NONE, SET_NONE, `card set ${id} is not given out`);
|
|
532
|
-
|
|
533
|
-
if (this.#state[id] === SET_RESIDENT) {
|
|
534
|
-
this.#resident_count--;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
this.#free_tiles(id);
|
|
538
|
-
|
|
539
|
-
this.#state[id] = SET_NONE;
|
|
540
|
-
this.#ticket[id]++;
|
|
541
|
-
this.#queued[id] = 0;
|
|
542
|
-
this.#material[id] = undefined;
|
|
543
|
-
|
|
544
|
-
const sets = this.#sets_of_geometry.get(this.#geometry[id]);
|
|
545
|
-
const at = sets.indexOf(id);
|
|
546
|
-
|
|
547
|
-
sets[at] = sets[sets.length - 1];
|
|
548
|
-
sets.pop();
|
|
549
|
-
|
|
550
|
-
if (sets.length === 0) {
|
|
551
|
-
this.#sets_of_geometry.delete(this.#geometry[id]);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
this.#ids.release(id);
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* The card set's material has changed (its version moved): capture it again. A resident card set
|
|
559
|
-
* reads its last capture until the new one is done.
|
|
560
|
-
*
|
|
561
|
-
* @param {number} id
|
|
562
|
-
*/
|
|
563
|
-
recapture(id) {
|
|
564
|
-
const state = this.#state[id];
|
|
565
|
-
|
|
566
|
-
assert.notEqual(state ?? SET_NONE, SET_NONE, `card set ${id} is not given out`);
|
|
567
|
-
|
|
568
|
-
if (state === SET_WAITING) {
|
|
569
|
-
// its first capture will take the material as it is then
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
this.#recaptures_requested++;
|
|
574
|
-
|
|
575
|
-
// from its first page, whether queued or not
|
|
576
|
-
this.#next_page[id] = 0;
|
|
577
|
-
|
|
578
|
-
if (this.#queued[id] === 0) {
|
|
579
|
-
this.#queued[id] = 1;
|
|
580
|
-
this.#queue_re.push(id, this.#ticket[id]);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* A geometry's layout is placed, with `pages` pages: its card sets can be captured.
|
|
586
|
-
*
|
|
587
|
-
* @param {number} geometry
|
|
588
|
-
* @param {number} pages
|
|
589
|
-
* @param {number} side texels a side of the layout's largest card: its grid's longest axis in
|
|
590
|
-
* voxels, plus one, the lattice having a point at either end
|
|
591
|
-
*/
|
|
592
|
-
set_layout(geometry, pages, side) {
|
|
593
|
-
assert.isNonNegativeInteger(pages, 'pages');
|
|
594
|
-
assert.isPositiveInteger(side, 'side');
|
|
595
|
-
|
|
596
|
-
this.#layout_pages.set(geometry, pages);
|
|
597
|
-
this.#layout_side.set(geometry, side);
|
|
598
|
-
|
|
599
|
-
const sets = this.#sets_of_geometry.get(geometry);
|
|
600
|
-
|
|
601
|
-
if (sets === undefined) {
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
for (let i = 0; i < sets.length; i++) {
|
|
606
|
-
if (this.#state[sets[i]] === SET_WAITING) {
|
|
607
|
-
this.#start(sets[i]);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
* A geometry's layout is gone: its card sets wait for the next.
|
|
614
|
-
*
|
|
615
|
-
* @param {number} geometry
|
|
616
|
-
*/
|
|
617
|
-
drop_layout(geometry) {
|
|
618
|
-
if (!this.#layout_pages.delete(geometry)) {
|
|
619
|
-
return;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
this.#layout_side.delete(geometry);
|
|
623
|
-
|
|
624
|
-
const sets = this.#sets_of_geometry.get(geometry);
|
|
625
|
-
|
|
626
|
-
if (sets === undefined) {
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
for (let i = 0; i < sets.length; i++) {
|
|
631
|
-
const id = sets[i];
|
|
632
|
-
const was = this.#state[id];
|
|
633
|
-
|
|
634
|
-
this.#free_tiles(id);
|
|
635
|
-
|
|
636
|
-
this.#state[id] = SET_WAITING;
|
|
637
|
-
this.#ticket[id]++;
|
|
638
|
-
this.#queued[id] = 0;
|
|
639
|
-
this.#next_page[id] = 0;
|
|
640
|
-
|
|
641
|
-
if (was === SET_RESIDENT) {
|
|
642
|
-
this.#resident_count--;
|
|
643
|
-
this.onWithdrawn.send1(id);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* The geometry `clone` is drawn as `source` from here on: its card sets, and those acquired for it after, capture
|
|
650
|
-
* `source`'s layout through `source`'s meshlets, the two being in one local space. A card set of `clone` waits
|
|
651
|
-
* for `source`'s layout, as one acquired for `source` does.
|
|
652
|
-
*
|
|
653
|
-
* @param {number} clone
|
|
654
|
-
* @param {number} source
|
|
655
|
-
*/
|
|
656
|
-
alias(clone, source) {
|
|
657
|
-
assert.notEqual(clone, source, 'a geometry cannot alias itself');
|
|
658
|
-
|
|
659
|
-
this.#source_of.set(clone, source);
|
|
660
|
-
|
|
661
|
-
// its own layout, if it had one, went with its cache: what it has waits
|
|
662
|
-
this.drop_layout(clone);
|
|
663
|
-
|
|
664
|
-
const sets = this.#sets_of_geometry.get(clone);
|
|
665
|
-
|
|
666
|
-
if (sets === undefined) {
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
this.#sets_of_geometry.delete(clone);
|
|
671
|
-
|
|
672
|
-
for (let i = 0; i < sets.length; i++) {
|
|
673
|
-
const id = sets[i];
|
|
674
|
-
|
|
675
|
-
this.#geometry[id] = source;
|
|
676
|
-
|
|
677
|
-
let of_source = this.#sets_of_geometry.get(source);
|
|
678
|
-
|
|
679
|
-
if (of_source === undefined) {
|
|
680
|
-
of_source = [];
|
|
681
|
-
this.#sets_of_geometry.set(source, of_source);
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
of_source.push(id);
|
|
685
|
-
|
|
686
|
-
if (this.#layout_pages.has(source)) {
|
|
687
|
-
this.#start(id);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
/**
|
|
693
|
-
* `clone` is no longer aliased: card sets acquired for it from here on capture its own layout. Those it has keep
|
|
694
|
-
* capturing its source's until they are given back.
|
|
695
|
-
*
|
|
696
|
-
* @param {number} clone
|
|
697
|
-
*/
|
|
698
|
-
unalias(clone) {
|
|
699
|
-
this.#source_of.delete(clone);
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
/**
|
|
703
|
-
* Pages from the atlas for a card set whose layout is placed, and its first capture queued.
|
|
704
|
-
*
|
|
705
|
-
* @param {number} id
|
|
706
|
-
*/
|
|
707
|
-
#start(id) {
|
|
708
|
-
const pages = this.#layout_pages.get(this.#geometry[id]);
|
|
709
|
-
|
|
710
|
-
this.#ensure_device();
|
|
711
|
-
|
|
712
|
-
const tiles = this.#allocate_tiles(pages);
|
|
713
|
-
|
|
714
|
-
if (tiles === null) {
|
|
715
|
-
// the atlas is at the device's limit; it waits, and is tried again with the next layout
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
this.#tiles[id] = tiles;
|
|
720
|
-
this.#state[id] = SET_CAPTURING;
|
|
721
|
-
this.#next_page[id] = 0;
|
|
722
|
-
|
|
723
|
-
if (pages === 0) {
|
|
724
|
-
// a layout with nothing to see: resident at once, every lookup missing
|
|
725
|
-
this.#write_record(id);
|
|
726
|
-
this.#turn_resident(id);
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
this.#queued[id] = 1;
|
|
731
|
-
this.#queue_new.push(id, this.#ticket[id]);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
#turn_resident(id) {
|
|
735
|
-
this.#state[id] = SET_RESIDENT;
|
|
736
|
-
this.#resident_count++;
|
|
737
|
-
this.#completed.push(id);
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
/**
|
|
741
|
-
* @param {number} pages
|
|
742
|
-
* @returns {Allocation|null}
|
|
743
|
-
*/
|
|
744
|
-
#allocate_tiles(pages) {
|
|
745
|
-
const allocator = this.#tile_allocator;
|
|
746
|
-
const atlas = this.#atlas;
|
|
747
|
-
|
|
748
|
-
// a zero-page card set still takes an offset, freed like any other
|
|
749
|
-
const size = Math.max(1, pages);
|
|
750
|
-
|
|
751
|
-
if (!allocator.can_allocate(size)) {
|
|
752
|
-
const target = allocator.grow_target_for(size);
|
|
753
|
-
|
|
754
|
-
atlas.ensure_capacity(target);
|
|
755
|
-
|
|
756
|
-
if (atlas.capacity < target) {
|
|
757
|
-
warn_limited(`GPUMeshCardSets: the card atlas can't hold ${target} pages`);
|
|
758
|
-
return null;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
allocator.grow(atlas.capacity);
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
const tiles = allocator.allocate(size);
|
|
765
|
-
|
|
766
|
-
assert.notEqual(tiles.offset, ALLOCATOR_NO_SPACE, 'tile allocation after growth');
|
|
767
|
-
|
|
768
|
-
return tiles;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
* @param {number} id
|
|
773
|
-
*/
|
|
774
|
-
#free_tiles(id) {
|
|
775
|
-
const tiles = this.#tiles[id];
|
|
776
|
-
|
|
777
|
-
if (tiles !== null && tiles !== undefined) {
|
|
778
|
-
// only captures write tiles, in submission order: a later owner's capture comes after
|
|
779
|
-
this.#tile_allocator.free(tiles);
|
|
780
|
-
this.#tiles[id] = null;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* @param {number} id
|
|
786
|
-
*/
|
|
787
|
-
#write_record(id) {
|
|
788
|
-
const view = this.#record_scratch;
|
|
789
|
-
const material = this.#material[id];
|
|
790
|
-
|
|
791
|
-
view.setUint32(MESH_CARD_SET_STRUCT.get("geometry").offset, this.#geometry[id], true);
|
|
792
|
-
view.setUint32(MESH_CARD_SET_STRUCT.get("material").offset, material.id, true);
|
|
793
|
-
view.setUint32(MESH_CARD_SET_STRUCT.get("page_base").offset, this.#tiles[id].offset, true);
|
|
794
|
-
view.setFloat32(MESH_CARD_SET_STRUCT.get("emissive_scale").offset, mesh_card_emissive_scale_of(material), true);
|
|
795
|
-
|
|
796
|
-
this.#ensure_records(id + 1);
|
|
797
|
-
|
|
798
|
-
this.#device.queue.writeBuffer(this.#records, id * MESH_CARD_SET_STRUCT.size, view.buffer, 0, MESH_CARD_SET_STRUCT.size);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Take the frame's pages off the queues into runs: at most `budget`, first captures before
|
|
803
|
-
* recaptures.
|
|
804
|
-
*
|
|
805
|
-
* @param {number} budget
|
|
806
|
-
*/
|
|
807
|
-
#take(budget) {
|
|
808
|
-
this.#frame_runs = 0;
|
|
809
|
-
this.#frame_threads = 0;
|
|
810
|
-
this.#frame_left = budget;
|
|
811
|
-
|
|
812
|
-
this.#frame_raster_runs = 0;
|
|
813
|
-
this.#frame_raster_threads = 0;
|
|
814
|
-
this.#shelf_x = 0;
|
|
815
|
-
this.#shelf_y = 0;
|
|
816
|
-
this.#shelf_height = 0;
|
|
817
|
-
this.#frame_scratch_width = 0;
|
|
818
|
-
this.#frame_scratch_height = 0;
|
|
819
|
-
|
|
820
|
-
this.#head_new = this.#compact(this.#queue_new, this.#take_from(this.#queue_new, this.#head_new));
|
|
821
|
-
this.#head_re = this.#compact(this.#queue_re, this.#take_from(this.#queue_re, this.#head_re));
|
|
822
|
-
|
|
823
|
-
this.#pages_captured += budget - this.#frame_left;
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
/**
|
|
827
|
-
* Take pages off one queue from its head into the frame's runs, while the frame's budget lasts.
|
|
828
|
-
*
|
|
829
|
-
* @param {number[]} queue (id, ticket) pairs
|
|
830
|
-
* @param {number} head
|
|
831
|
-
* @returns {number} the queue's head after what was taken
|
|
832
|
-
*/
|
|
833
|
-
#take_from(queue, head) {
|
|
834
|
-
while (this.#frame_left > 0 && head < queue.length) {
|
|
835
|
-
const id = queue[head];
|
|
836
|
-
|
|
837
|
-
if (queue[head + 1] !== this.#ticket[id] || this.#queued[id] === 0) {
|
|
838
|
-
// given back, or its layout went, since it was queued
|
|
839
|
-
head += 2;
|
|
840
|
-
continue;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
const pages = this.#layout_pages.get(this.#geometry[id]);
|
|
844
|
-
|
|
845
|
-
if (this.#capture_mode === MeshCardCaptureMode.Raster) {
|
|
846
|
-
// a context is made with its bind group
|
|
847
|
-
const material = this.#frame_material_contexts.obtain(this.#material[id]);
|
|
848
|
-
|
|
849
|
-
if (material.template.surface !== null) {
|
|
850
|
-
if (!this.#take_raster(id, pages, material)) {
|
|
851
|
-
// the frame's scratch is full: next frame
|
|
852
|
-
return head;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
head += 2;
|
|
856
|
-
continue;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
// a template that cannot be drawn this way is traced
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
// its row as the material stands now, repacked if it has moved since
|
|
863
|
-
this.#frame_materials.obtain_material(this.#material[id]);
|
|
864
|
-
|
|
865
|
-
const first = this.#next_page[id];
|
|
866
|
-
const count = Math.min(pages - first, this.#frame_left);
|
|
867
|
-
|
|
868
|
-
if (first === 0) {
|
|
869
|
-
this.#write_record(id);
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
const runs = this.#frame_runs;
|
|
873
|
-
|
|
874
|
-
this.#run_scratch = grow_typed(this.#run_scratch, 4 * (runs + 1));
|
|
875
|
-
this.#run_scratch[4 * runs] = this.#frame_threads;
|
|
876
|
-
this.#run_scratch[4 * runs + 1] = id;
|
|
877
|
-
this.#run_scratch[4 * runs + 2] = first;
|
|
878
|
-
this.#run_scratch[4 * runs + 3] = 0;
|
|
879
|
-
|
|
880
|
-
this.#frame_runs = runs + 1;
|
|
881
|
-
this.#frame_threads += count * PAGE_THREADS;
|
|
882
|
-
this.#frame_left -= count;
|
|
883
|
-
|
|
884
|
-
this.#next_page[id] = first + count;
|
|
885
|
-
|
|
886
|
-
if (first + count < pages) {
|
|
887
|
-
// the budget ran out inside it: it goes on from here next frame
|
|
888
|
-
return head;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
this.#next_page[id] = 0;
|
|
892
|
-
this.#queued[id] = 0;
|
|
893
|
-
head += 2;
|
|
894
|
-
|
|
895
|
-
if (this.#state[id] === SET_CAPTURING) {
|
|
896
|
-
this.#turn_resident(id);
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
return head;
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
/**
|
|
904
|
-
* Take a whole card set into the frame's raster runs, if its region fits the frame's scratch.
|
|
905
|
-
*
|
|
906
|
-
* @param {number} id
|
|
907
|
-
* @param {number} pages its layout's
|
|
908
|
-
* @param {GPUMaterialContext} material what its draw binds
|
|
909
|
-
* @returns {boolean} whether it was taken
|
|
910
|
-
*/
|
|
911
|
-
#take_raster(id, pages, material) {
|
|
912
|
-
const side = this.#layout_side.get(this.#geometry[id]);
|
|
913
|
-
const corner = this.#place_region(MESH_CARD_RASTER_CELLS_X * side, MESH_CARD_RASTER_CELLS_Y * side);
|
|
914
|
-
|
|
915
|
-
if (corner === -1) {
|
|
916
|
-
return false;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
this.#write_record(id);
|
|
920
|
-
|
|
921
|
-
const runs = this.#frame_raster_runs;
|
|
922
|
-
|
|
923
|
-
this.#raster_run_scratch = grow_typed(this.#raster_run_scratch, 4 * (runs + 1));
|
|
924
|
-
this.#raster_run_scratch[4 * runs] = this.#frame_raster_threads;
|
|
925
|
-
this.#raster_run_scratch[4 * runs + 1] = id;
|
|
926
|
-
this.#raster_run_scratch[4 * runs + 2] = corner;
|
|
927
|
-
this.#raster_run_scratch[4 * runs + 3] = side;
|
|
928
|
-
|
|
929
|
-
this.#frame_raster_materials[runs] = material;
|
|
930
|
-
|
|
931
|
-
this.#frame_raster_runs = runs + 1;
|
|
932
|
-
this.#frame_raster_threads += pages * PAGE_THREADS;
|
|
933
|
-
this.#frame_left -= pages;
|
|
934
|
-
|
|
935
|
-
this.#next_page[id] = 0;
|
|
936
|
-
this.#queued[id] = 0;
|
|
937
|
-
|
|
938
|
-
if (this.#state[id] === SET_CAPTURING) {
|
|
939
|
-
this.#turn_resident(id);
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
return true;
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
/**
|
|
946
|
-
* A corner for a region in the frame's scratch, shelf by shelf.
|
|
947
|
-
*
|
|
948
|
-
* @param {number} width
|
|
949
|
-
* @param {number} height
|
|
950
|
-
* @returns {number} the corner as x | y << 16, or -1 when the region must wait for the next frame
|
|
951
|
-
*/
|
|
952
|
-
#place_region(width, height) {
|
|
953
|
-
if (this.#shelf_x > 0 && this.#shelf_x + width > RASTER_SCRATCH_SIDE) {
|
|
954
|
-
this.#shelf_y += this.#shelf_height;
|
|
955
|
-
this.#shelf_x = 0;
|
|
956
|
-
this.#shelf_height = 0;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
const fits = this.#shelf_x + width <= RASTER_SCRATCH_SIDE && this.#shelf_y + height <= RASTER_SCRATCH_SIDE;
|
|
960
|
-
|
|
961
|
-
if (!fits && this.#frame_raster_runs > 0) {
|
|
962
|
-
return -1;
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
const corner = this.#shelf_x | (this.#shelf_y << 16);
|
|
966
|
-
|
|
967
|
-
this.#shelf_x += width;
|
|
968
|
-
this.#shelf_height = Math.max(this.#shelf_height, height);
|
|
969
|
-
|
|
970
|
-
this.#frame_scratch_width = Math.max(this.#frame_scratch_width, this.#shelf_x);
|
|
971
|
-
this.#frame_scratch_height = Math.max(this.#frame_scratch_height, this.#shelf_y + height);
|
|
972
|
-
|
|
973
|
-
return corner;
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
/**
|
|
977
|
-
* Drop a queue's taken entries once they are most of it.
|
|
978
|
-
*
|
|
979
|
-
* @param {number[]} queue
|
|
980
|
-
* @param {number} head
|
|
981
|
-
* @returns {number} the new head
|
|
982
|
-
*/
|
|
983
|
-
#compact(queue, head) {
|
|
984
|
-
if (head === queue.length) {
|
|
985
|
-
queue.length = 0;
|
|
986
|
-
return 0;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
if (head > 64 && head * 2 > queue.length) {
|
|
990
|
-
queue.copyWithin(0, head);
|
|
991
|
-
queue.length -= head;
|
|
992
|
-
return 0;
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
return head;
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
/**
|
|
999
|
-
* Record the frame's capture: at most `budget` pages. Records nothing when nothing waits. Card
|
|
1000
|
-
* sets whose first capture this completes are resident from here, and {@link onResident} is sent
|
|
1001
|
-
* for each.
|
|
1002
|
-
*
|
|
1003
|
-
* @param {Object} options
|
|
1004
|
-
* @param {FrameGraph} options.graph
|
|
1005
|
-
* @param {number} options.budget pages captured at most, `card_capture_budget`
|
|
1006
|
-
* @param {number} options.arena graph handle of the arena, as the frame's bake left it
|
|
1007
|
-
* @param {GPUBuffer} options.headers
|
|
1008
|
-
* @param {GPUResidentMaterialContext} options.materials what the trace shades with: each traced
|
|
1009
|
-
* material is made resident, and the rows committed, before the trace is recorded
|
|
1010
|
-
* @param {GPUMaterialManager} options.material_contexts what the raster draws with: each
|
|
1011
|
-
* material's template and bind group
|
|
1012
|
-
* @param {Object} options.blas the geometry bindings `ray_query_blas_nearest` reads, whose
|
|
1013
|
-
* geometry and meshlet buffers the raster pulls vertices from
|
|
1014
|
-
*/
|
|
1015
|
-
graph_capture({ graph, budget, arena, headers, materials, material_contexts, blas }) {
|
|
1016
|
-
assert.defined(graph, 'graph');
|
|
1017
|
-
assert.isPositiveInteger(budget, 'budget');
|
|
1018
|
-
assert.lessThanOrEqual(budget, MESH_CARD_CAPTURE_BUDGET_MAX, 'budget');
|
|
1019
|
-
|
|
1020
|
-
if (this.#capture_mode === MeshCardCaptureMode.Raster) {
|
|
1021
|
-
assert.notNull(material_contexts, 'material_contexts');
|
|
1022
|
-
assert.defined(material_contexts, 'material_contexts');
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
this.#frame_material_contexts = material_contexts;
|
|
1026
|
-
this.#frame_materials = materials;
|
|
1027
|
-
|
|
1028
|
-
this.#take(budget);
|
|
1029
|
-
|
|
1030
|
-
this.#frame_material_contexts = null;
|
|
1031
|
-
this.#frame_materials = null;
|
|
1032
|
-
|
|
1033
|
-
const completed = this.#completed;
|
|
1034
|
-
|
|
1035
|
-
if (this.#frame_runs > 0 || this.#frame_raster_runs > 0) {
|
|
1036
|
-
this.#ensure_device();
|
|
1037
|
-
|
|
1038
|
-
let albedo = graph_import_texture(graph, this.#atlas.texture_at(0), "mesh_card_albedo");
|
|
1039
|
-
let emissive = graph_import_texture(graph, this.#atlas.texture_at(1), "mesh_card_emissive");
|
|
1040
|
-
|
|
1041
|
-
if (this.#frame_runs > 0) {
|
|
1042
|
-
// what the runs' materials made resident, written before the trace reads it
|
|
1043
|
-
materials.commit();
|
|
1044
|
-
|
|
1045
|
-
this.#ensure_runs(this.#frame_runs);
|
|
1046
|
-
|
|
1047
|
-
this.#device.queue.writeBuffer(this.#runs, 0, this.#run_scratch, 0, 4 * this.#frame_runs);
|
|
1048
|
-
|
|
1049
|
-
const data = this.#pass_data;
|
|
1050
|
-
const pass = graph.add("Mesh Card Capture", data, this.#execute);
|
|
1051
|
-
|
|
1052
|
-
pass.read(arena);
|
|
1053
|
-
|
|
1054
|
-
data.arena = arena;
|
|
1055
|
-
albedo = data.albedo = pass.write(albedo);
|
|
1056
|
-
emissive = data.emissive = pass.write(emissive);
|
|
1057
|
-
|
|
1058
|
-
pass.make_side_effect();
|
|
1059
|
-
|
|
1060
|
-
const b = this.#bindings;
|
|
1061
|
-
|
|
1062
|
-
b.mesh_sdf_headers = headers;
|
|
1063
|
-
b.materials = materials.buffer_materials;
|
|
1064
|
-
b.textures = materials.textureView;
|
|
1065
|
-
b.blas_lookup = blas.blas_lookup;
|
|
1066
|
-
b.blas_data = blas.blas_data;
|
|
1067
|
-
b.geometries = blas.geometries;
|
|
1068
|
-
b.meshlet_metadata = blas.meshlet_metadata;
|
|
1069
|
-
b.meshlet_data = blas.meshlet_data;
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
if (this.#frame_raster_runs > 0) {
|
|
1073
|
-
const runs = this.#frame_raster_runs;
|
|
1074
|
-
|
|
1075
|
-
this.#ensure_raster_runs(runs);
|
|
1076
|
-
this.#ensure_raster_scratch(this.#frame_scratch_width, this.#frame_scratch_height);
|
|
1077
|
-
|
|
1078
|
-
this.#device.queue.writeBuffer(this.#raster_runs, 0, this.#raster_run_scratch, 0, 4 * runs);
|
|
1079
|
-
|
|
1080
|
-
const data = this.#raster_pass_data;
|
|
1081
|
-
const pass = graph.add("Mesh Card Capture / Raster", data, this.#execute_raster);
|
|
1082
|
-
|
|
1083
|
-
pass.read(arena);
|
|
1084
|
-
|
|
1085
|
-
data.arena = arena;
|
|
1086
|
-
data.albedo = pass.write(albedo);
|
|
1087
|
-
data.emissive = pass.write(emissive);
|
|
1088
|
-
|
|
1089
|
-
pass.make_side_effect();
|
|
1090
|
-
|
|
1091
|
-
const args = this.#raster_args_bindings;
|
|
1092
|
-
|
|
1093
|
-
args.mesh_sdf_headers = headers;
|
|
1094
|
-
args.geometries = blas.geometries;
|
|
1095
|
-
|
|
1096
|
-
const scatter = this.#raster_scatter_bindings;
|
|
1097
|
-
|
|
1098
|
-
scatter.mesh_sdf_headers = headers;
|
|
1099
|
-
scatter.mesh_card_raster_albedo = this.#raster_views[0];
|
|
1100
|
-
scatter.mesh_card_raster_emissive = this.#raster_views[1];
|
|
1101
|
-
|
|
1102
|
-
this.#raster_group_buffers.mesh_sdf_headers = headers;
|
|
1103
|
-
this.#raster_group_buffers.geometries = blas.geometries;
|
|
1104
|
-
this.#raster_group_buffers.meshlet_metadata = blas.meshlet_metadata;
|
|
1105
|
-
this.#raster_group_buffers.meshlet_data = blas.meshlet_data;
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
for (let i = 0; i < completed.length; i++) {
|
|
1110
|
-
this.onResident.send1(completed[i]);
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
completed.length = 0;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
/**
|
|
1117
|
-
* {@link #execute_capture}, bound once.
|
|
1118
|
-
* @type {function(Object, Object, Object): void}
|
|
1119
|
-
*/
|
|
1120
|
-
#execute = (data, resources, context) => this.#execute_capture(data, resources, context);
|
|
1121
|
-
|
|
1122
|
-
#execute_capture(data, resources, context) {
|
|
1123
|
-
const b = this.#bindings;
|
|
1124
|
-
const groups = Math.ceil(this.#frame_threads / MESH_SDF_BAKE_WORKGROUP_SIZE);
|
|
1125
|
-
const groups_x = Math.min(groups, WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION);
|
|
1126
|
-
const settings = this.#settings;
|
|
1127
|
-
|
|
1128
|
-
settings.run_count = this.#frame_runs;
|
|
1129
|
-
settings.thread_count = this.#frame_threads;
|
|
1130
|
-
settings.groups_x = groups_x;
|
|
1131
|
-
|
|
1132
|
-
b.settings = settings;
|
|
1133
|
-
b.mesh_sdf_indirection = resources.get(data.arena);
|
|
1134
|
-
b.mesh_card_sets = this.#records;
|
|
1135
|
-
b.mesh_card_runs = this.#runs;
|
|
1136
|
-
b.mesh_card_albedo = resources.get(data.albedo).obtainView();
|
|
1137
|
-
b.mesh_card_emissive = resources.get(data.emissive).obtainView();
|
|
1138
|
-
|
|
1139
|
-
shader_mesh_cards_capture.dispatch({
|
|
1140
|
-
encoder: context.encoder,
|
|
1141
|
-
group_count_x: groups_x,
|
|
1142
|
-
group_count_y: Math.ceil(groups / groups_x),
|
|
1143
|
-
bindings: b,
|
|
1144
|
-
});
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
/**
|
|
1148
|
-
* {@link #execute_raster_capture}, bound once.
|
|
1149
|
-
* @type {function(Object, Object, Object): void}
|
|
1150
|
-
*/
|
|
1151
|
-
#execute_raster = (data, resources, context) => this.#execute_raster_capture(data, resources, context);
|
|
1152
|
-
|
|
1153
|
-
/**
|
|
1154
|
-
* A draw a run, every run's cards into the scratch, then every run's pages into the atlas.
|
|
1155
|
-
*/
|
|
1156
|
-
#execute_raster_capture(data, resources, context) {
|
|
1157
|
-
const encoder = context.encoder;
|
|
1158
|
-
const graphics = context.graphics;
|
|
1159
|
-
const runs = this.#frame_raster_runs;
|
|
1160
|
-
const arena = resources.get(data.arena);
|
|
1161
|
-
|
|
1162
|
-
const args_settings = this.#raster_args_settings;
|
|
1163
|
-
const args = this.#raster_args_bindings;
|
|
1164
|
-
|
|
1165
|
-
args_settings.run_count = runs;
|
|
1166
|
-
|
|
1167
|
-
args.settings = args_settings;
|
|
1168
|
-
args.mesh_sdf_indirection = arena;
|
|
1169
|
-
args.mesh_card_sets = this.#records;
|
|
1170
|
-
args.mesh_card_raster_runs = this.#raster_runs;
|
|
1171
|
-
args.mesh_card_raster_draws = this.#raster_draws;
|
|
1172
|
-
|
|
1173
|
-
shader_mesh_cards_raster_args.dispatch({
|
|
1174
|
-
encoder,
|
|
1175
|
-
group_count_x: Math.ceil(runs / MESH_CARDS_RASTER_ARGS_WORKGROUP_SIZE),
|
|
1176
|
-
bindings: args,
|
|
1177
|
-
});
|
|
1178
|
-
|
|
1179
|
-
const buffers = this.#raster_group_buffers;
|
|
1180
|
-
|
|
1181
|
-
const group = graphics.bind_groups.obtain(BindGroupDescriptor.from(
|
|
1182
|
-
MESH_CARDS_RASTER_LAYOUT,
|
|
1183
|
-
[
|
|
1184
|
-
{ buffer: buffers.mesh_sdf_headers },
|
|
1185
|
-
{ buffer: arena },
|
|
1186
|
-
{ buffer: this.#records },
|
|
1187
|
-
{ buffer: this.#raster_runs },
|
|
1188
|
-
{ buffer: buffers.geometries },
|
|
1189
|
-
{ buffer: buffers.meshlet_metadata },
|
|
1190
|
-
{ buffer: buffers.meshlet_data },
|
|
1191
|
-
]
|
|
1192
|
-
));
|
|
1193
|
-
|
|
1194
|
-
const immediate = this.#raster_immediate;
|
|
1195
|
-
|
|
1196
|
-
this.#raster_immediate_f32[1] = this.#raster_width;
|
|
1197
|
-
this.#raster_immediate_f32[2] = this.#raster_height;
|
|
1198
|
-
|
|
1199
|
-
const pass = encoder.beginRenderPass(this.#raster_pass_descriptor);
|
|
1200
|
-
|
|
1201
|
-
pass.setBindGroup(1, group);
|
|
1202
|
-
|
|
1203
|
-
let bound_template = null;
|
|
1204
|
-
|
|
1205
|
-
for (let run = 0; run < runs; run++) {
|
|
1206
|
-
const material = this.#frame_raster_materials[run];
|
|
1207
|
-
|
|
1208
|
-
if (!material.is_built) {
|
|
1209
|
-
// let go since it was taken: its texels stay empty, every lookup missing
|
|
1210
|
-
continue;
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
const template = material.template;
|
|
1214
|
-
|
|
1215
|
-
if (template !== bound_template) {
|
|
1216
|
-
pass.setPipeline(mesh_cards_raster_pass_descriptor.obtain_pipeline(graphics.render_pipelines, template, "none"));
|
|
1217
|
-
|
|
1218
|
-
bound_template = template;
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
// the same group 0 the G-buffer pass binds
|
|
1222
|
-
pass.setBindGroup(0, material.material_binding);
|
|
1223
|
-
|
|
1224
|
-
immediate[0] = run;
|
|
1225
|
-
|
|
1226
|
-
pass.setImmediates(0, immediate, 0, immediate.length);
|
|
1227
|
-
pass.drawIndirect(this.#raster_draws, run * STRUCT_UNINDEXED_DRAW_COMMAND.size);
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
pass.end();
|
|
1231
|
-
|
|
1232
|
-
const groups = Math.ceil(this.#frame_raster_threads / MESH_SDF_BAKE_WORKGROUP_SIZE);
|
|
1233
|
-
const groups_x = Math.min(groups, WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION);
|
|
1234
|
-
|
|
1235
|
-
const scatter_settings = this.#raster_scatter_settings;
|
|
1236
|
-
const scatter = this.#raster_scatter_bindings;
|
|
1237
|
-
|
|
1238
|
-
scatter_settings.run_count = runs;
|
|
1239
|
-
scatter_settings.thread_count = this.#frame_raster_threads;
|
|
1240
|
-
scatter_settings.groups_x = groups_x;
|
|
1241
|
-
|
|
1242
|
-
scatter.settings = scatter_settings;
|
|
1243
|
-
scatter.mesh_sdf_indirection = arena;
|
|
1244
|
-
scatter.mesh_card_sets = this.#records;
|
|
1245
|
-
scatter.mesh_card_raster_runs = this.#raster_runs;
|
|
1246
|
-
scatter.mesh_card_albedo = resources.get(data.albedo).obtainView();
|
|
1247
|
-
scatter.mesh_card_emissive = resources.get(data.emissive).obtainView();
|
|
1248
|
-
|
|
1249
|
-
shader_mesh_cards_raster_scatter.dispatch({
|
|
1250
|
-
encoder,
|
|
1251
|
-
group_count_x: groups_x,
|
|
1252
|
-
group_count_y: Math.ceil(groups / groups_x),
|
|
1253
|
-
bindings: scatter,
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
#ensure_id(id) {
|
|
1258
|
-
const length = id + 1;
|
|
1259
|
-
|
|
1260
|
-
this.#state = grow_typed(this.#state, length);
|
|
1261
|
-
this.#geometry = grow_typed(this.#geometry, length);
|
|
1262
|
-
this.#ticket = grow_typed(this.#ticket, length);
|
|
1263
|
-
this.#next_page = grow_typed(this.#next_page, length);
|
|
1264
|
-
this.#queued = grow_typed(this.#queued, length);
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
#ensure_device() {
|
|
1268
|
-
if (this.#atlas !== null) {
|
|
1269
|
-
return;
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
this.#atlas = new GPUTileAtlas2D({
|
|
1273
|
-
device: this.#device,
|
|
1274
|
-
formats: ["rgba8unorm", "rgba8unorm"],
|
|
1275
|
-
tile_size: [MESH_CARD_PAGE_TEXELS, MESH_CARD_PAGE_TEXELS],
|
|
1276
|
-
// stored into by the capture, read by the hits
|
|
1277
|
-
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.STORAGE_BINDING,
|
|
1278
|
-
label: "GPUMeshCardSets/atlas",
|
|
1279
|
-
});
|
|
1280
|
-
|
|
1281
|
-
this.#tile_allocator = new OffsetAllocator(this.#atlas.capacity);
|
|
1282
|
-
|
|
1283
|
-
this.#ensure_records(64);
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
/**
|
|
1287
|
-
* @param {number} count
|
|
1288
|
-
*/
|
|
1289
|
-
#ensure_records(count) {
|
|
1290
|
-
if (count <= this.#record_capacity) {
|
|
1291
|
-
return;
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
let capacity = Math.max(64, this.#record_capacity);
|
|
1295
|
-
|
|
1296
|
-
while (capacity < count) {
|
|
1297
|
-
capacity *= 2;
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
const size = MESH_CARD_SET_STRUCT.size * capacity;
|
|
1301
|
-
const buffer = this.#create_buffer("records", size, GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC);
|
|
1302
|
-
|
|
1303
|
-
if (this.#records !== null) {
|
|
1304
|
-
const encoder = this.#device.createCommandEncoder({ label: "GPUMeshCardSets/records growth" });
|
|
1305
|
-
|
|
1306
|
-
encoder.copyBufferToBuffer(this.#records, 0, buffer, 0, this.#records.size);
|
|
1307
|
-
this.#device.queue.submit([encoder.finish()]);
|
|
1308
|
-
|
|
1309
|
-
this.#records.destroy();
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
this.#records = buffer;
|
|
1313
|
-
this.#record_capacity = capacity;
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
/**
|
|
1317
|
-
* @param {number} runs
|
|
1318
|
-
*/
|
|
1319
|
-
#ensure_runs(runs) {
|
|
1320
|
-
if (runs <= this.#run_capacity) {
|
|
1321
|
-
return;
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
let capacity = Math.max(64, this.#run_capacity);
|
|
1325
|
-
|
|
1326
|
-
while (capacity < runs) {
|
|
1327
|
-
capacity *= 2;
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
this.#runs?.destroy();
|
|
1331
|
-
this.#runs = this.#create_buffer("runs", 16 * capacity, GPUBufferUsage.COPY_DST);
|
|
1332
|
-
this.#run_capacity = capacity;
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
/**
|
|
1336
|
-
* @param {number} runs
|
|
1337
|
-
*/
|
|
1338
|
-
#ensure_raster_runs(runs) {
|
|
1339
|
-
if (runs <= this.#raster_run_capacity) {
|
|
1340
|
-
return;
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
let capacity = Math.max(64, this.#raster_run_capacity);
|
|
1344
|
-
|
|
1345
|
-
while (capacity < runs) {
|
|
1346
|
-
capacity *= 2;
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
this.#raster_runs?.destroy();
|
|
1350
|
-
this.#raster_draws?.destroy();
|
|
1351
|
-
|
|
1352
|
-
this.#raster_runs = this.#create_buffer("raster runs", 16 * capacity, GPUBufferUsage.COPY_DST);
|
|
1353
|
-
this.#raster_draws = this.#create_buffer("raster draws", STRUCT_UNINDEXED_DRAW_COMMAND.size * capacity, GPUBufferUsage.INDIRECT);
|
|
1354
|
-
this.#raster_run_capacity = capacity;
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
/**
|
|
1358
|
-
* The scratch the cards are drawn into, at least `width` × `height`. It only grows.
|
|
1359
|
-
*
|
|
1360
|
-
* @param {number} width
|
|
1361
|
-
* @param {number} height
|
|
1362
|
-
*/
|
|
1363
|
-
#ensure_raster_scratch(width, height) {
|
|
1364
|
-
if (width <= this.#raster_width && height <= this.#raster_height) {
|
|
1365
|
-
return;
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
const step = RASTER_SCRATCH_STEP;
|
|
1369
|
-
|
|
1370
|
-
width = Math.max(this.#raster_width, Math.ceil(width / step) * step);
|
|
1371
|
-
height = Math.max(this.#raster_height, Math.ceil(height / step) * step);
|
|
1372
|
-
|
|
1373
|
-
const formats = [...MESH_CARD_RASTER_TARGET_FORMATS, MESH_CARD_RASTER_DEPTH_FORMAT];
|
|
1374
|
-
|
|
1375
|
-
for (let i = 0; i < formats.length; i++) {
|
|
1376
|
-
// a frame already submitted may still be reading it; destroy waits for that
|
|
1377
|
-
this.#raster_targets[i]?.destroy();
|
|
1378
|
-
|
|
1379
|
-
const color = i < MESH_CARD_RASTER_TARGET_FORMATS.length;
|
|
1380
|
-
|
|
1381
|
-
this.#raster_targets[i] = this.#device.createTexture({
|
|
1382
|
-
label: `GPUMeshCardSets/raster scratch ${i}`,
|
|
1383
|
-
size: [width, height],
|
|
1384
|
-
format: formats[i],
|
|
1385
|
-
usage: color
|
|
1386
|
-
? GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
1387
|
-
: GPUTextureUsage.RENDER_ATTACHMENT,
|
|
1388
|
-
});
|
|
1389
|
-
|
|
1390
|
-
this.#raster_views[i] = this.#raster_targets[i].createView();
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
const descriptor = this.#raster_pass_descriptor;
|
|
1394
|
-
|
|
1395
|
-
for (let i = 0; i < descriptor.colorAttachments.length; i++) {
|
|
1396
|
-
descriptor.colorAttachments[i].view = this.#raster_views[i];
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
descriptor.depthStencilAttachment.view = this.#raster_views[formats.length - 1];
|
|
1400
|
-
|
|
1401
|
-
this.#raster_width = width;
|
|
1402
|
-
this.#raster_height = height;
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
/**
|
|
1406
|
-
* @param {string} name
|
|
1407
|
-
* @param {number} size
|
|
1408
|
-
* @param {GPUBufferUsageFlags} usage beside STORAGE
|
|
1409
|
-
* @returns {GPUBuffer}
|
|
1410
|
-
*/
|
|
1411
|
-
#create_buffer(name, size, usage) {
|
|
1412
|
-
return this.#device.createBuffer(BufferDescriptor.fromJSON({
|
|
1413
|
-
label: `GPUMeshCardSets/${name}`,
|
|
1414
|
-
size,
|
|
1415
|
-
usage: GPUBufferUsage.STORAGE | usage,
|
|
1416
|
-
}));
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
/**
|
|
1420
|
-
* @returns {number} bytes
|
|
1421
|
-
*/
|
|
1422
|
-
get gpu_memory_usage() {
|
|
1423
|
-
let bytes = 0;
|
|
1424
|
-
|
|
1425
|
-
if (this.#records !== null) {
|
|
1426
|
-
bytes += this.#records.size;
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
if (this.#runs !== null) {
|
|
1430
|
-
bytes += this.#runs.size;
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
if (this.#atlas !== null) {
|
|
1434
|
-
bytes += this.#atlas.gpu_memory_usage;
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
if (this.#raster_runs !== null) {
|
|
1438
|
-
bytes += this.#raster_runs.size + this.#raster_draws.size;
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
// two rgba8 targets and a depth32float, 4 bytes a texel each
|
|
1442
|
-
bytes += this.#raster_width * this.#raster_height * 4 * (MESH_CARD_RASTER_TARGET_FORMATS.length + 1);
|
|
1443
|
-
|
|
1444
|
-
return bytes;
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
destroy() {
|
|
1448
|
-
this.#records?.destroy();
|
|
1449
|
-
this.#runs?.destroy();
|
|
1450
|
-
this.#atlas?.destroy();
|
|
1451
|
-
this.#raster_runs?.destroy();
|
|
1452
|
-
this.#raster_draws?.destroy();
|
|
1453
|
-
|
|
1454
|
-
for (let i = 0; i < this.#raster_targets.length; i++) {
|
|
1455
|
-
this.#raster_targets[i].destroy();
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
this.#records = null;
|
|
1459
|
-
this.#runs = null;
|
|
1460
|
-
this.#atlas = null;
|
|
1461
|
-
this.#raster_runs = null;
|
|
1462
|
-
this.#raster_draws = null;
|
|
1463
|
-
this.#raster_targets.length = 0;
|
|
1464
|
-
this.#raster_views.length = 0;
|
|
1465
|
-
this.#raster_width = 0;
|
|
1466
|
-
this.#raster_height = 0;
|
|
1467
|
-
}
|
|
1468
|
-
}
|