@woosh/meep-engine 3.69.0 → 3.70.0
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 +30 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/package.json +1 -1
- package/src/core/bvh8/build/BVH8Converter.d.ts +16 -0
- package/src/core/bvh8/build/BVH8Converter.d.ts.map +1 -1
- package/src/core/bvh8/build/BVH8Converter.js +64 -37
- package/src/core/bvh8/build/bvh8_assign_slots_greedy.d.ts +25 -0
- package/src/core/bvh8/build/bvh8_assign_slots_greedy.d.ts.map +1 -0
- package/src/core/bvh8/build/bvh8_assign_slots_greedy.js +68 -0
- package/src/core/bvh8/build/bvh8_from_proxy.d.ts.map +1 -1
- package/src/core/bvh8/build/bvh8_from_proxy.js +2 -33
- package/src/core/bvh8/build/bvh8_node_fit_slots.d.ts +22 -0
- package/src/core/bvh8/build/bvh8_node_fit_slots.d.ts.map +1 -0
- package/src/core/bvh8/build/bvh8_node_fit_slots.js +115 -0
- package/src/core/bvh8/bvh8_depth.d.ts +8 -0
- package/src/core/bvh8/bvh8_depth.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_depth.js +39 -0
- package/src/core/math/complex/complex_fft_radix2.d.ts +19 -0
- package/src/core/math/complex/complex_fft_radix2.d.ts.map +1 -0
- package/src/core/math/complex/complex_fft_radix2.js +71 -0
- package/src/engine/graphics3/GPUFluidSystem.d.ts +17 -4
- package/src/engine/graphics3/GPUFluidSystem.d.ts.map +1 -1
- package/src/engine/graphics3/GPUFluidSystem.js +113 -16
- package/src/engine/physics/cloth/playground/wind_main.js +7 -6
- package/src/engine/physics/cloth/wind/AbstractClothWind.d.ts +2 -2
- package/src/engine/physics/cloth/wind/AbstractClothWind.js +2 -2
- package/src/engine/physics/cloth/wind/ClothFluidWind.d.ts +3 -3
- package/src/engine/physics/cloth/wind/ClothFluidWind.d.ts.map +1 -1
- package/src/engine/physics/cloth/wind/ClothFluidWind.js +7 -9
- package/src/engine/physics/cloth/wind/ClothGPUFluidWind.d.ts +10 -10
- package/src/engine/physics/cloth/wind/ClothGPUFluidWind.d.ts.map +1 -1
- package/src/engine/physics/cloth/wind/ClothGPUFluidWind.js +14 -22
- package/src/engine/physics/fluid/FluidAtmosphere.d.ts +16 -2
- package/src/engine/physics/fluid/FluidAtmosphere.d.ts.map +1 -1
- package/src/engine/physics/fluid/FluidAtmosphere.js +17 -3
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponentSerializationAdapter.d.ts +1 -2
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponentSerializationAdapter.d.ts.map +1 -1
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponentSerializationAdapter.js +1 -2
- package/src/engine/physics/fluid/ecs/FluidEffectorsSystem.d.ts +8 -5
- package/src/engine/physics/fluid/ecs/FluidEffectorsSystem.d.ts.map +1 -1
- package/src/engine/physics/fluid/ecs/FluidEffectorsSystem.js +60 -17
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +1 -1
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +1 -1
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts +33 -47
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +38 -176
- package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationAdapter.d.ts +8 -11
- package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationAdapter.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationAdapter.js +13 -24
- package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationUpgrader_0_1.d.ts +16 -0
- package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationUpgrader_0_1.d.ts.map +1 -0
- package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationUpgrader_0_1.js +35 -0
- package/src/engine/physics/fluid/fluid_apply_atmosphere.d.ts +1 -1
- package/src/engine/physics/fluid/fluid_apply_atmosphere.js +1 -1
- package/src/engine/physics/fluid/turbulence/FLUID_TURBULENCE_TILE.d.ts +28 -0
- package/src/engine/physics/fluid/turbulence/FLUID_TURBULENCE_TILE.d.ts.map +1 -0
- package/src/engine/physics/fluid/turbulence/FLUID_TURBULENCE_TILE.js +29 -0
- package/src/engine/physics/fluid/turbulence/fluid_atmosphere_velocity_at.d.ts +16 -0
- package/src/engine/physics/fluid/turbulence/fluid_atmosphere_velocity_at.d.ts.map +1 -0
- package/src/engine/physics/fluid/turbulence/fluid_atmosphere_velocity_at.js +49 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_inverse_tile_size.d.ts +11 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_inverse_tile_size.d.ts.map +1 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_inverse_tile_size.js +18 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_data.d.ts +25 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_data.d.ts.map +1 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_data.js +65 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_generate.d.ts +56 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_generate.d.ts.map +1 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_generate.js +313 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_sample.d.ts +16 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_sample.d.ts.map +1 -0
- package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_sample.js +69 -0
- package/src/generation/foliage/mesh/branch_ring_triangulate.d.ts +1 -1
- package/src/generation/foliage/mesh/branch_ring_triangulate.js +1 -1
- package/src/shade/playground/bvh_repro/README.md +8 -6
- package/src/shade/playground/bvh_repro/index.html +125 -124
- package/src/shade/playground/bvh_repro/main.js +259 -254
- package/src/shade/playground/foliage_wind/foliage_world.d.ts.map +1 -1
- package/src/shade/playground/foliage_wind/foliage_world.js +7 -4
- package/src/shade/playground/grass_surfaces/main.js +3 -2
- package/src/shade/playground/particle_ecs/bonfire_wind.d.ts +23 -13
- package/src/shade/playground/particle_ecs/bonfire_wind.d.ts.map +1 -1
- package/src/shade/playground/particle_ecs/bonfire_wind.js +30 -33
- package/src/shade/playground/skinned_blas_refit/README.md +26 -14
- package/src/shade/playground/skinned_blas_refit/shader_blas_audit_leaf_triangles.d.ts +14 -9
- package/src/shade/playground/skinned_blas_refit/shader_blas_audit_leaf_triangles.d.ts.map +1 -1
- package/src/shade/playground/skinned_blas_refit/shader_blas_audit_leaf_triangles.js +126 -127
- package/src/shade/playground/skinned_blas_refit/shader_blas_audit_points.js +95 -95
- package/src/shade/playground/skinned_blas_refit/shader_blas_audit_visibility.d.ts +9 -1
- package/src/shade/playground/skinned_blas_refit/shader_blas_audit_visibility.d.ts.map +1 -1
- package/src/shade/playground/skinned_blas_refit/shader_blas_audit_visibility.js +146 -135
- package/src/shade/playground/skinned_blas_refit/verify_clone_leaves.d.ts +6 -6
- package/src/shade/playground/skinned_blas_refit/verify_clone_leaves.d.ts.map +1 -1
- package/src/shade/playground/skinned_blas_refit/verify_clone_leaves.js +148 -134
- package/src/shade/playground/skinned_blas_refit/verify_leaf_triangles.d.ts +11 -8
- package/src/shade/playground/skinned_blas_refit/verify_leaf_triangles.d.ts.map +1 -1
- package/src/shade/playground/skinned_blas_refit/verify_leaf_triangles.js +342 -202
- package/src/shade/playground/skinned_blas_refit/verify_skinned_blas_refit.d.ts +12 -13
- package/src/shade/playground/skinned_blas_refit/verify_skinned_blas_refit.d.ts.map +1 -1
- package/src/shade/playground/skinned_blas_refit/verify_skinned_blas_refit.js +136 -116
- package/src/shade/playground/skinned_blas_refit/verify_traversal_reachability.d.ts +4 -4
- package/src/shade/playground/skinned_blas_refit/verify_traversal_reachability.d.ts.map +1 -1
- package/src/shade/playground/skinned_blas_refit/verify_traversal_reachability.js +255 -249
- package/src/shade/playground/water_surface/main.js +6 -3
- package/src/shade/renderer/animation/GPUAnimationManager.js +2 -2
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +1 -1
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +7 -8
- package/src/shade/renderer/fluid/FLUID_FAR_FIELD_STRUCT.d.ts +111 -0
- package/src/shade/renderer/fluid/FLUID_FAR_FIELD_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/fluid/FLUID_FAR_FIELD_STRUCT.js +162 -0
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +37 -8
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts.map +1 -1
- package/src/shade/renderer/fluid/GPUFluidCascade.js +149 -47
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +10 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts.map +1 -1
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.js +69 -10
- package/src/shade/renderer/fluid/chunk_fluid_far_field.d.ts +19 -0
- package/src/shade/renderer/fluid/chunk_fluid_far_field.d.ts.map +1 -0
- package/src/shade/renderer/fluid/chunk_fluid_far_field.js +43 -0
- package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_PARENT_STRUCT.d.ts +10 -9
- package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_PARENT_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_PARENT_STRUCT.js +14 -12
- package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_RESTRICT_STRUCT.d.ts +3 -2
- package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_RESTRICT_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_RESTRICT_STRUCT.js +7 -5
- package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_epilogue.d.ts +17 -9
- package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_epilogue.d.ts.map +1 -1
- package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_epilogue.js +58 -18
- package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_parent.d.ts +23 -11
- package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_parent.d.ts.map +1 -1
- package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_parent.js +371 -335
- package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_fill.d.ts.map +1 -1
- package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_fill.js +2 -1
- package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_ghosts.d.ts.map +1 -1
- package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_ghosts.js +109 -108
- package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_restrict.d.ts +5 -3
- package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_restrict.d.ts.map +1 -1
- package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_restrict.js +24 -12
- package/src/shade/renderer/fluid/mac/FLUID_MAC_STEP_STRUCT.d.ts +6 -2
- package/src/shade/renderer/fluid/mac/FLUID_MAC_STEP_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/fluid/mac/FLUID_MAC_STEP_STRUCT.js +10 -5
- package/src/shade/renderer/fluid/mac/FluidMacPasses.d.ts +20 -21
- package/src/shade/renderer/fluid/mac/FluidMacPasses.d.ts.map +1 -1
- package/src/shade/renderer/fluid/mac/FluidMacPasses.js +453 -427
- package/src/shade/renderer/fluid/mac/shader_fluid_mac_advect_correct.d.ts.map +1 -1
- package/src/shade/renderer/fluid/mac/shader_fluid_mac_advect_correct.js +2 -1
- package/src/shade/renderer/fluid/publish/FluidWindPublish.d.ts +13 -5
- package/src/shade/renderer/fluid/publish/FluidWindPublish.d.ts.map +1 -1
- package/src/shade/renderer/fluid/publish/FluidWindPublish.js +20 -10
- package/src/shade/renderer/fluid/publish/chunk_fluid_wind_publish_cell.d.ts +2 -2
- package/src/shade/renderer/fluid/publish/chunk_fluid_wind_publish_cell.js +2 -2
- package/src/shade/renderer/fluid/publish/shader_fluid_wind_publish.d.ts +5 -3
- package/src/shade/renderer/fluid/publish/shader_fluid_wind_publish.d.ts.map +1 -1
- package/src/shade/renderer/fluid/publish/shader_fluid_wind_publish.js +147 -142
- package/src/shade/renderer/fluid/query/GPUFluidQueries.js +2 -2
- package/src/shade/renderer/geometry/GPUGeometryManager.d.ts.map +1 -1
- package/src/shade/renderer/geometry/GPUGeometryManager.js +5 -7
- package/src/shade/renderer/geometry/MeshletGeometry.d.ts +4 -1
- package/src/shade/renderer/geometry/MeshletGeometry.d.ts.map +1 -1
- package/src/shade/renderer/geometry/MeshletGeometry.js +4 -1
- package/src/shade/renderer/geometry/MeshletGeometrySerializationAdapter.d.ts +20 -0
- package/src/shade/renderer/geometry/MeshletGeometrySerializationAdapter.d.ts.map +1 -1
- package/src/shade/renderer/geometry/MeshletGeometrySerializationAdapter.js +35 -3
- package/src/shade/renderer/geometry/blas_from_meshlets.d.ts +9 -3
- package/src/shade/renderer/geometry/blas_from_meshlets.d.ts.map +1 -1
- package/src/shade/renderer/geometry/blas_from_meshlets.js +16 -30
- package/src/shade/renderer/geometry/bvh/BLAS8_REFIT_TARGET_STRUCT.d.ts +14 -0
- package/src/shade/renderer/geometry/bvh/BLAS8_REFIT_TARGET_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/geometry/bvh/BLAS8_REFIT_TARGET_STRUCT.js +33 -0
- package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.d.ts +18 -21
- package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.d.ts.map +1 -1
- package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.js +78 -158
- package/src/shade/renderer/geometry/bvh/GPUGeometryBVHManager.d.ts +18 -39
- package/src/shade/renderer/geometry/bvh/GPUGeometryBVHManager.d.ts.map +1 -1
- package/src/shade/renderer/geometry/bvh/GPUGeometryBVHManager.js +39 -398
- package/src/shade/renderer/geometry/bvh/GPUGeometryMeshletsBVH.d.ts +6 -7
- package/src/shade/renderer/geometry/bvh/GPUGeometryMeshletsBVH.d.ts.map +1 -1
- package/src/shade/renderer/geometry/bvh/GPUGeometryMeshletsBVH.js +5 -7
- package/src/shade/renderer/geometry/bvh/bvh8_build_for_meshlets.d.ts +36 -0
- package/src/shade/renderer/geometry/bvh/bvh8_build_for_meshlets.d.ts.map +1 -0
- package/src/shade/renderer/geometry/bvh/bvh8_build_for_meshlets.js +179 -0
- package/src/shade/renderer/geometry/bvh/meshlet_batch_to_clustered_bvh.d.ts +30 -0
- package/src/shade/renderer/geometry/bvh/meshlet_batch_to_clustered_bvh.d.ts.map +1 -0
- package/src/shade/renderer/geometry/bvh/meshlet_batch_to_clustered_bvh.js +207 -0
- package/src/shade/renderer/geometry/bvh/shader_blas8_refit_batch.d.ts +52 -0
- package/src/shade/renderer/geometry/bvh/shader_blas8_refit_batch.d.ts.map +1 -0
- package/src/shade/renderer/geometry/bvh/shader_blas8_refit_batch.js +464 -0
- package/src/shade/renderer/geometry/meshlet/MeshletBatch.d.ts +12 -0
- package/src/shade/renderer/geometry/meshlet/MeshletBatch.d.ts.map +1 -1
- package/src/shade/renderer/geometry/meshlet/MeshletBatch.js +37 -0
- 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 +4 -4
- 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 +2 -2
- package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.js +2 -2
- package/src/shade/renderer/geometry/sdf/shader_sdf_visualize.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/shader_sdf_visualize.js +4 -4
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_trace.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_trace.js +2 -2
- package/src/shade/renderer/geometry/sr_create_group_RTX.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sr_create_group_RTX.js +4 -4
- package/src/shade/renderer/global_illumination/brick4/gpu/bake/brick4_bake_basic.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/brick4/gpu/bake/brick4_bake_basic.js +1 -0
- package/src/shade/renderer/global_illumination/lpv/bake/GPULightProbeVolumeRenderer.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/lpv/bake/GPULightProbeVolumeRenderer.js +1 -0
- package/src/shade/renderer/global_illumination/lpv/placement/graph_generate_probe_locations.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/lpv/placement/graph_generate_probe_locations.js +372 -376
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.d.ts +9 -10
- 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 +10 -11
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.d.ts +2 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.js +2 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts +12 -8
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.js +109 -60
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_sdf.js +2 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_surfaces.js +2 -2
- package/src/shade/renderer/gpu_primitive/bvh/BVH_BUFFER_LAYOUT.d.ts +2 -2
- package/src/shade/renderer/gpu_primitive/bvh/BVH_BUFFER_LAYOUT.js +70 -70
- package/src/shade/renderer/gpu_primitive/bvh/BVH_BUILD_SETTINGS_STRUCT.d.ts +6 -7
- package/src/shade/renderer/gpu_primitive/bvh/BVH_BUILD_SETTINGS_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/gpu_primitive/bvh/BVH_BUILD_SETTINGS_STRUCT.js +6 -7
- package/src/shade/renderer/gpu_primitive/bvh/graph_bvh_build_lbvh.d.ts +3 -3
- package/src/shade/renderer/gpu_primitive/bvh/graph_bvh_build_lbvh.js +3 -3
- package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_build_single_workgroup.js +1 -1
- package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_emit_hierarchy.d.ts +2 -2
- package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_emit_hierarchy.js +3 -3
- package/src/shade/renderer/gpu_primitive/bvh8/BVH8_TREE_BUFFER_LAYOUT.d.ts +69 -0
- package/src/shade/renderer/gpu_primitive/bvh8/BVH8_TREE_BUFFER_LAYOUT.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/BVH8_TREE_BUFFER_LAYOUT.js +89 -0
- package/src/shade/renderer/gpu_primitive/bvh8/bvh8_encode_from_bvh2.d.ts +41 -0
- package/src/shade/renderer/gpu_primitive/bvh8/bvh8_encode_from_bvh2.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/bvh8_encode_from_bvh2.js +348 -0
- package/src/shade/renderer/gpu_primitive/bvh8/check_bvh8_tree.d.ts +34 -0
- package/src/shade/renderer/gpu_primitive/bvh8/check_bvh8_tree.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/check_bvh8_tree.js +291 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_assign.d.ts +31 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_assign.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_assign.js +175 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_depth.d.ts +27 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_depth.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_depth.js +48 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_gather.d.ts +26 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_gather.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_gather.js +118 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_node.d.ts +22 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_node.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_node.js +143 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_sums.d.ts +36 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_sums.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_sums.js +97 -0
- package/src/shade/renderer/gpu_primitive/bvh8/graph_bvh8_encode_from_bvh2.d.ts +49 -0
- package/src/shade/renderer/gpu_primitive/bvh8/graph_bvh8_encode_from_bvh2.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/graph_bvh8_encode_from_bvh2.js +265 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_assign.d.ts +37 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_assign.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_assign.js +109 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count.d.ts +15 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count.js +85 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count_single_workgroup.d.ts +26 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count_single_workgroup.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count_single_workgroup.js +200 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_parents.d.ts +19 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_parents.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_parents.js +81 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_write.d.ts +14 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_write.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_write.js +101 -0
- package/src/shade/renderer/gpu_primitive/bvh8/verify_gpu_bvh8_encode.d.ts +19 -0
- package/src/shade/renderer/gpu_primitive/bvh8/verify_gpu_bvh8_encode.d.ts.map +1 -0
- package/src/shade/renderer/gpu_primitive/bvh8/verify_gpu_bvh8_encode.js +361 -0
- package/src/shade/renderer/grass/surface/shader_grass_surface_bake.d.ts.map +1 -1
- package/src/shade/renderer/grass/surface/shader_grass_surface_bake.js +5 -6
- package/src/shade/renderer/lightmap/GPULightMap.d.ts.map +1 -1
- package/src/shade/renderer/lightmap/GPULightMap.js +1 -0
- package/src/shade/renderer/path_tracer/accumulating/AccumulatingPathTracer.d.ts.map +1 -1
- package/src/shade/renderer/path_tracer/accumulating/AccumulatingPathTracer.js +1 -0
- package/src/shade/renderer/path_tracer/graph_path_trace_scene.d.ts.map +1 -1
- package/src/shade/renderer/path_tracer/graph_path_trace_scene.js +1 -0
- package/src/shade/renderer/scene/GPUInstancesAccelerationStructure.d.ts +8 -4
- package/src/shade/renderer/scene/GPUInstancesAccelerationStructure.d.ts.map +1 -1
- package/src/shade/renderer/scene/GPUInstancesAccelerationStructure.js +60 -33
- package/src/shade/renderer/scene/verify_gpu_tlas_build.d.ts +6 -6
- package/src/shade/renderer/scene/verify_gpu_tlas_build.d.ts.map +1 -1
- package/src/shade/renderer/scene/verify_gpu_tlas_build.js +23 -53
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_INODE_STRUCT.d.ts +3 -1
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_INODE_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_INODE_STRUCT.js +5 -3
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_MAX_DEPTH.d.ts +28 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_MAX_DEPTH.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_MAX_DEPTH.js +29 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_grid.d.ts +25 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_grid.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_grid.js +97 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_intersect.d.ts +8 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_intersect.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_intersect.js +23 -14
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_slot_distances.d.ts +36 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_slot_distances.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_slot_distances.js +222 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_direction_rcp.d.ts +20 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_direction_rcp.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_direction_rcp.js +30 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_tree_read.d.ts +30 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_tree_read.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_tree_read.js +91 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_waiting_slots.d.ts +23 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_waiting_slots.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_waiting_slots.js +40 -0
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_nearest.d.ts +22 -0
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_nearest.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_nearest.js +121 -70
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_occluded.d.ts +13 -1
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_occluded.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_occluded.js +117 -61
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest.d.ts +21 -0
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest.js +111 -72
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.d.ts +1 -2
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.js +83 -54
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_occluded.d.ts +14 -0
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_occluded.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_occluded.js +92 -60
- package/src/shade/renderer/shader/chunk/sdf/chunk_point_query_blas_nearest.d.ts +22 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_point_query_blas_nearest.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/sdf/chunk_point_query_blas_nearest.js +153 -106
- package/src/shade/renderer/shader/chunk/sdf/chunk_scene_point_query_nearest.d.ts +21 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_scene_point_query_nearest.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/sdf/chunk_scene_point_query_nearest.js +115 -74
- package/src/shade/renderer/shader/chunk/sdf/chunk_scene_sdf_raymarch.d.ts +5 -2
- package/src/shade/renderer/shader/chunk/sdf/chunk_scene_sdf_raymarch.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/sdf/chunk_scene_sdf_raymarch.js +89 -63
- package/src/shade/renderer/shader/chunk/sdf/chunk_sdf_query_distance.d.ts +15 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_sdf_query_distance.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/sdf/chunk_sdf_query_distance.js +108 -63
- package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast.d.ts +14 -0
- package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast.d.ts.map +1 -1
- package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast.js +94 -60
- package/src/shade/renderer/shadow/sdf/graph_draw_sdf_shadows.d.ts.map +1 -1
- package/src/shade/renderer/shadow/sdf/graph_draw_sdf_shadows.js +4 -4
- package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +2 -2
- package/src/shade/renderer/water/query/shader_water_surface_query.d.ts.map +1 -1
- package/src/shade/renderer/water/query/shader_water_surface_query.js +227 -227
- package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts.map +1 -1
- package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.js +7 -4
- package/src/shade/renderer/water/surface/particles/shader_water_particles.js +2 -2
- package/src/shade/renderer/wind/GPUSceneWind.d.ts +36 -4
- package/src/shade/renderer/wind/GPUSceneWind.d.ts.map +1 -1
- package/src/shade/renderer/wind/GPUSceneWind.js +150 -4
- package/src/shade/renderer/wind/WIND_FIELD_STRUCT.d.ts +9 -3
- package/src/shade/renderer/wind/WIND_FIELD_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/wind/WIND_FIELD_STRUCT.js +13 -3
- package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.d.ts +6 -6
- package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.js +6 -6
- package/src/shade/renderer/wind/chunk_fluid_turbulence.d.ts +39 -0
- package/src/shade/renderer/wind/chunk_fluid_turbulence.d.ts.map +1 -0
- package/src/shade/renderer/wind/chunk_fluid_turbulence.js +63 -0
- package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts +10 -7
- package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts.map +1 -1
- package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.js +34 -11
- package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.d.ts +2 -2
- package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.js +2 -2
- package/src/shade/renderer/wind/wind_field_add_resources.d.ts +6 -4
- package/src/shade/renderer/wind/wind_field_add_resources.d.ts.map +1 -1
- package/src/shade/renderer/wind/wind_field_add_resources.js +9 -6
- package/src/shade/renderer/geometry/bvh/BLAS_REFIT_TARGET_STRUCT.d.ts +0 -18
- package/src/shade/renderer/geometry/bvh/BLAS_REFIT_TARGET_STRUCT.d.ts.map +0 -1
- package/src/shade/renderer/geometry/bvh/BLAS_REFIT_TARGET_STRUCT.js +0 -50
- package/src/shade/renderer/geometry/bvh/bvh2_derive_topology.d.ts +0 -23
- package/src/shade/renderer/geometry/bvh/bvh2_derive_topology.d.ts.map +0 -1
- package/src/shade/renderer/geometry/bvh/bvh2_derive_topology.js +0 -87
- package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch.d.ts +0 -42
- package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch.d.ts.map +0 -1
- package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch.js +0 -141
- package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch_seed.d.ts +0 -21
- package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch_seed.d.ts.map +0 -1
- package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch_seed.js +0 -75
- package/src/shade/renderer/geometry/meshlet_batch_to_bvh.d.ts +0 -17
- package/src/shade/renderer/geometry/meshlet_batch_to_bvh.d.ts.map +0 -1
- package/src/shade/renderer/geometry/meshlet_batch_to_bvh.js +0 -247
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_query_blas_occlusion.d.ts +0 -7
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_query_blas_occlusion.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_query_blas_occlusion.js +0 -226
- package/src/shade/renderer/shader/chunk/light/lpv/chunk_lpv_mask_visibility_via_rays.d.ts +0 -8
- package/src/shade/renderer/shader/chunk/light/lpv/chunk_lpv_mask_visibility_via_rays.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/light/lpv/chunk_lpv_mask_visibility_via_rays.js +0 -45
- package/src/shade/renderer/shader/chunk/light/sample/chunk_ray_sample_light.d.ts +0 -3
- package/src/shade/renderer/shader/chunk/light/sample/chunk_ray_sample_light.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/light/sample/chunk_ray_sample_light.js +0 -105
- package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_distance.d.ts +0 -6
- package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_distance.d.ts.map +0 -1
- package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_distance.js +0 -86
- package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast_traversal_count.d.ts +0 -2
- package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast_traversal_count.d.ts.map +0 -1
- package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast_traversal_count.js +0 -136
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { PREFIX_SCAN_CSDLDF_HEADER_WORDS } from "../prefix_sum/v1/shader_prefix_scan_csdldf.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Counts the encode of a binary tree as a BVH8 keeps of each internal node of the binary tree, laid
|
|
6
|
+
* end to end a kind at a time and summed by one scan: its child nodes, its leaves, and whether it is
|
|
7
|
+
* a node of the wide tree at all.
|
|
8
|
+
*
|
|
9
|
+
* @type {number}
|
|
10
|
+
*/
|
|
11
|
+
export const BVH8_ENCODE_COUNTS_PER_NODE = 3;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* What the running sums of {@link shader_bvh8_encode_count}'s counts say:
|
|
15
|
+
*
|
|
16
|
+
* ```wgsl
|
|
17
|
+
* fn bvh8_encode_child_nodes(internal_count: u32) -> u32
|
|
18
|
+
* fn bvh8_encode_child_nodes_before(node: u32) -> u32
|
|
19
|
+
* fn bvh8_encode_leaves_before(node: u32, internal_count: u32) -> u32
|
|
20
|
+
* fn bvh8_encode_wide_node(ordinal: u32, internal_count: u32) -> u32
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* `bvh8_encode_child_nodes` is every child node of the wide tree, which is every node of it but the
|
|
24
|
+
* root. The two `before` are what the internal nodes before one hold between them: with the root's
|
|
25
|
+
* one node, where that node's block of child nodes starts, and where its run of payloads does.
|
|
26
|
+
*
|
|
27
|
+
* `bvh8_encode_wide_node` is the internal node that is the `ordinal`th node of the wide tree, counted
|
|
28
|
+
* in the binary tree's order, for an ordinal below the wide tree's node count. A pass that takes a
|
|
29
|
+
* lane per node of the wide tree finds its node by it, and so has no lane without one.
|
|
30
|
+
*
|
|
31
|
+
* `internal_count` is the binary tree's internal nodes; a tree that is one leaf has none, and nothing
|
|
32
|
+
* of the sums is read for it. The enclosing shader declares `sums`,
|
|
33
|
+
* `array<u32>`: what `graph_prefix_scan_csdldf` makes of the counts, each sum including its own
|
|
34
|
+
* element.
|
|
35
|
+
*
|
|
36
|
+
* @type {CodeChunk}
|
|
37
|
+
*/
|
|
38
|
+
export const chunk_bvh8_encode_sums = CodeChunk.from(
|
|
39
|
+
//language=WGSL
|
|
40
|
+
`
|
|
41
|
+
const BVH8_ENCODE_SUMS = ${PREFIX_SCAN_CSDLDF_HEADER_WORDS}u;
|
|
42
|
+
|
|
43
|
+
fn bvh8_encode_child_nodes(internal_count: u32) -> u32 {
|
|
44
|
+
if (internal_count == 0u) {
|
|
45
|
+
// a tree that is one leaf is one node, with nothing counted for it
|
|
46
|
+
return 0u;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return sums[BVH8_ENCODE_SUMS + internal_count - 1u];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fn bvh8_encode_child_nodes_before(node: u32) -> u32 {
|
|
53
|
+
if (node == 0u) {
|
|
54
|
+
return 0u;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return sums[BVH8_ENCODE_SUMS + node - 1u];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// the leaves' sums follow the child nodes' and carry on from their total
|
|
61
|
+
fn bvh8_encode_leaves_before(node: u32, internal_count: u32) -> u32 {
|
|
62
|
+
if (node == 0u) {
|
|
63
|
+
return 0u;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return sums[BVH8_ENCODE_SUMS + internal_count + node - 1u] - bvh8_encode_child_nodes(internal_count);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fn bvh8_encode_wide_node(ordinal: u32, internal_count: u32) -> u32 {
|
|
70
|
+
if (ordinal == 0u) {
|
|
71
|
+
// the root, whatever the tree
|
|
72
|
+
return 0u;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// the flags' sums follow the leaves' and carry on from theirs
|
|
76
|
+
let flags = BVH8_ENCODE_SUMS + 2u * internal_count;
|
|
77
|
+
|
|
78
|
+
// one more than the wide nodes at or before the one looked for
|
|
79
|
+
let wanted = sums[flags - 1u] + ordinal + 1u;
|
|
80
|
+
|
|
81
|
+
// the first node whose sum reaches it; a step halves what is left of a tree of at most 2^32 nodes
|
|
82
|
+
var low = 0u;
|
|
83
|
+
var high = internal_count - 1u;
|
|
84
|
+
|
|
85
|
+
for (var step = 0u; step < 32u && low < high; step++) {
|
|
86
|
+
let middle = (low + high) / 2u;
|
|
87
|
+
|
|
88
|
+
if (sums[flags + middle] >= wanted) {
|
|
89
|
+
high = middle;
|
|
90
|
+
} else {
|
|
91
|
+
low = middle + 1u;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return low;
|
|
96
|
+
}
|
|
97
|
+
`);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("../../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry} PipelineEnquiry
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Offer the pipelines {@link graph_bvh8_encode_from_bvh2} dispatches — see {@link PipelineEnquiry}.
|
|
6
|
+
*
|
|
7
|
+
* @param {PipelineEnquiry} enquiry
|
|
8
|
+
*/
|
|
9
|
+
export function enquire_bvh8_encode_pipelines(enquiry: PipelineEnquiry): void;
|
|
10
|
+
/**
|
|
11
|
+
* Record the encode of a binary BVH as a BVH8, three binary levels to a node: what
|
|
12
|
+
* {@link bvh8_encode_from_bvh2} does, word for word, on the device.
|
|
13
|
+
*
|
|
14
|
+
* What a node of the wide tree holds, and where it goes, follows from counts of every internal node
|
|
15
|
+
* of the binary tree and their running sums ({@link chunk_bvh8_encode_sums}). Those are made in one
|
|
16
|
+
* of two ways, chosen by `leaf_count` and nothing else. Up to
|
|
17
|
+
* {@link BVH8_ENCODE_SINGLE_WORKGROUP_LEAVES} leaves, by one dispatch of one workgroup,
|
|
18
|
+
* {@link shader_bvh8_encode_count_single_workgroup}. Above, by four dispatches whatever the tree's
|
|
19
|
+
* depth: every internal node's parent ({@link shader_bvh8_encode_parents}), the counts
|
|
20
|
+
* ({@link shader_bvh8_encode_count}), and their sums (`graph_prefix_scan_csdldf`, two dispatches).
|
|
21
|
+
*
|
|
22
|
+
* Two dispatches follow either: the slots of each node's children ({@link shader_bvh8_encode_assign}),
|
|
23
|
+
* and the nodes ({@link shader_bvh8_encode_write}). Both take a lane per node of the wide tree, so
|
|
24
|
+
* that a lane with a node has no lane without one beside it to wait with.
|
|
25
|
+
*
|
|
26
|
+
* The binary tree is in the order `graph_bvh_build_lbvh` writes: `leaf_count - 1` internal nodes
|
|
27
|
+
* first, the root node 0, and it is fitted. It is at most `BVH8_ENCODE_MAX_BINARY_DEPTH` deep, which
|
|
28
|
+
* a tree of that builder is.
|
|
29
|
+
*
|
|
30
|
+
* `leaf_count` must be at least 1. A tree of no leaves is one empty node, which the caller writes
|
|
31
|
+
* host-side.
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} options
|
|
34
|
+
* @param {FrameGraph} options.graph
|
|
35
|
+
* @param {number} options.tree buffer resource ID, the binary tree: `[root][nodes]` in the layout of
|
|
36
|
+
* {@link BVH_BUFFER_LAYOUT}
|
|
37
|
+
* @param {number} options.leaf_count leaves in the binary tree, at least 1
|
|
38
|
+
* @param {number} options.out buffer resource ID to write the BVH8 into, in the layout of
|
|
39
|
+
* {@link BVH8_TREE_BUFFER_LAYOUT}; at least `bvh8_tree_buffer_size(leaf_count)` bytes
|
|
40
|
+
* @returns {number} buffer resource ID of the written BVH8
|
|
41
|
+
*/
|
|
42
|
+
export function graph_bvh8_encode_from_bvh2({ graph, tree, leaf_count, out, }: {
|
|
43
|
+
graph: FrameGraph;
|
|
44
|
+
tree: number;
|
|
45
|
+
leaf_count: number;
|
|
46
|
+
out: number;
|
|
47
|
+
}): number;
|
|
48
|
+
export type PipelineEnquiry = import("../../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry;
|
|
49
|
+
//# sourceMappingURL=graph_bvh8_encode_from_bvh2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph_bvh8_encode_from_bvh2.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/gpu_primitive/bvh8/graph_bvh8_encode_from_bvh2.js"],"names":[],"mappings":"AAqBA;;GAEG;AAEH;;;;GAIG;AACH,uDAFW,eAAe,QASzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH;IAR+B,KAAK;IACT,IAAI,EAApB,MAAM;IAEU,UAAU,EAA1B,MAAM;IACU,GAAG,EAAnB,MAAM;IAEJ,MAAM,CAmMlB;8BAlPY,OAAO,6CAA6C,EAAE,eAAe"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { round_up } from "../../../../core/math/round_up.js";
|
|
3
|
+
import { BufferResourceDescriptor } from "../../../device/graph/BufferResourceDescriptor.js";
|
|
4
|
+
import { graph_create_buffer } from "../../shader/graph/graph_create_buffer.js";
|
|
5
|
+
import { bvh_buffer_size } from "../bvh/BVH_BUFFER_LAYOUT.js";
|
|
6
|
+
import {
|
|
7
|
+
enquire_prefix_scan_csdldf_pipelines,
|
|
8
|
+
graph_prefix_scan_csdldf,
|
|
9
|
+
prefix_scan_csdldf_output_descriptor
|
|
10
|
+
} from "../prefix_sum/v1/graph_prefix_scan_csdldf.js";
|
|
11
|
+
import { bvh8_tree_buffer_size } from "./BVH8_TREE_BUFFER_LAYOUT.js";
|
|
12
|
+
import { BVH8_ENCODE_COUNTS_PER_NODE } from "./chunk_bvh8_encode_sums.js";
|
|
13
|
+
import { BVH8_ENCODE_PLACEMENT_STRIDE_WORDS, shader_bvh8_encode_assign } from "./shader_bvh8_encode_assign.js";
|
|
14
|
+
import { shader_bvh8_encode_count } from "./shader_bvh8_encode_count.js";
|
|
15
|
+
import { shader_bvh8_encode_parents } from "./shader_bvh8_encode_parents.js";
|
|
16
|
+
import {
|
|
17
|
+
BVH8_ENCODE_SINGLE_WORKGROUP_LEAVES,
|
|
18
|
+
shader_bvh8_encode_count_single_workgroup
|
|
19
|
+
} from "./shader_bvh8_encode_count_single_workgroup.js";
|
|
20
|
+
import { shader_bvh8_encode_write } from "./shader_bvh8_encode_write.js";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {import("../../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry} PipelineEnquiry
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Offer the pipelines {@link graph_bvh8_encode_from_bvh2} dispatches — see {@link PipelineEnquiry}.
|
|
28
|
+
*
|
|
29
|
+
* @param {PipelineEnquiry} enquiry
|
|
30
|
+
*/
|
|
31
|
+
export function enquire_bvh8_encode_pipelines(enquiry) {
|
|
32
|
+
enquiry.compute.push(shader_bvh8_encode_count_single_workgroup.pipeline);
|
|
33
|
+
enquiry.compute.push(shader_bvh8_encode_parents.pipeline);
|
|
34
|
+
enquiry.compute.push(shader_bvh8_encode_count.pipeline);
|
|
35
|
+
enquire_prefix_scan_csdldf_pipelines(enquiry);
|
|
36
|
+
enquiry.compute.push(shader_bvh8_encode_assign.pipeline);
|
|
37
|
+
enquiry.compute.push(shader_bvh8_encode_write.pipeline);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Record the encode of a binary BVH as a BVH8, three binary levels to a node: what
|
|
42
|
+
* {@link bvh8_encode_from_bvh2} does, word for word, on the device.
|
|
43
|
+
*
|
|
44
|
+
* What a node of the wide tree holds, and where it goes, follows from counts of every internal node
|
|
45
|
+
* of the binary tree and their running sums ({@link chunk_bvh8_encode_sums}). Those are made in one
|
|
46
|
+
* of two ways, chosen by `leaf_count` and nothing else. Up to
|
|
47
|
+
* {@link BVH8_ENCODE_SINGLE_WORKGROUP_LEAVES} leaves, by one dispatch of one workgroup,
|
|
48
|
+
* {@link shader_bvh8_encode_count_single_workgroup}. Above, by four dispatches whatever the tree's
|
|
49
|
+
* depth: every internal node's parent ({@link shader_bvh8_encode_parents}), the counts
|
|
50
|
+
* ({@link shader_bvh8_encode_count}), and their sums (`graph_prefix_scan_csdldf`, two dispatches).
|
|
51
|
+
*
|
|
52
|
+
* Two dispatches follow either: the slots of each node's children ({@link shader_bvh8_encode_assign}),
|
|
53
|
+
* and the nodes ({@link shader_bvh8_encode_write}). Both take a lane per node of the wide tree, so
|
|
54
|
+
* that a lane with a node has no lane without one beside it to wait with.
|
|
55
|
+
*
|
|
56
|
+
* The binary tree is in the order `graph_bvh_build_lbvh` writes: `leaf_count - 1` internal nodes
|
|
57
|
+
* first, the root node 0, and it is fitted. It is at most `BVH8_ENCODE_MAX_BINARY_DEPTH` deep, which
|
|
58
|
+
* a tree of that builder is.
|
|
59
|
+
*
|
|
60
|
+
* `leaf_count` must be at least 1. A tree of no leaves is one empty node, which the caller writes
|
|
61
|
+
* host-side.
|
|
62
|
+
*
|
|
63
|
+
* @param {Object} options
|
|
64
|
+
* @param {FrameGraph} options.graph
|
|
65
|
+
* @param {number} options.tree buffer resource ID, the binary tree: `[root][nodes]` in the layout of
|
|
66
|
+
* {@link BVH_BUFFER_LAYOUT}
|
|
67
|
+
* @param {number} options.leaf_count leaves in the binary tree, at least 1
|
|
68
|
+
* @param {number} options.out buffer resource ID to write the BVH8 into, in the layout of
|
|
69
|
+
* {@link BVH8_TREE_BUFFER_LAYOUT}; at least `bvh8_tree_buffer_size(leaf_count)` bytes
|
|
70
|
+
* @returns {number} buffer resource ID of the written BVH8
|
|
71
|
+
*/
|
|
72
|
+
export function graph_bvh8_encode_from_bvh2({
|
|
73
|
+
graph,
|
|
74
|
+
tree,
|
|
75
|
+
leaf_count,
|
|
76
|
+
out,
|
|
77
|
+
}) {
|
|
78
|
+
|
|
79
|
+
assert.defined(graph, 'graph');
|
|
80
|
+
assert.isNonNegativeInteger(tree, 'tree');
|
|
81
|
+
assert.isNonNegativeInteger(out, 'out');
|
|
82
|
+
assert.isNonNegativeInteger(leaf_count, 'leaf_count');
|
|
83
|
+
assert.greaterThanOrEqual(leaf_count, 1, 'leaf_count — an empty tree is written host-side');
|
|
84
|
+
|
|
85
|
+
const tree_bytes = bvh_buffer_size(leaf_count);
|
|
86
|
+
const out_bytes = bvh8_tree_buffer_size(leaf_count);
|
|
87
|
+
|
|
88
|
+
const internal_count = leaf_count - 1;
|
|
89
|
+
|
|
90
|
+
// the assign and write passes are dispatched over the internal nodes, or the one leaf of a tree with none
|
|
91
|
+
const wide_lanes = Math.max(1, internal_count);
|
|
92
|
+
|
|
93
|
+
// Written for the nodes of the wide tree alone, which are the only ones it is read for.
|
|
94
|
+
const PLACEMENT_DESCRIPTOR = BufferResourceDescriptor.from(
|
|
95
|
+
round_up(wide_lanes * BVH8_ENCODE_PLACEMENT_STRIDE_WORDS * Uint32Array.BYTES_PER_ELEMENT, 1024),
|
|
96
|
+
GPUBufferUsage.STORAGE
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// the counts of every internal node and their sums, both in the scan's own layout; every word read
|
|
100
|
+
// of either is written
|
|
101
|
+
const element_count = BVH8_ENCODE_COUNTS_PER_NODE * internal_count;
|
|
102
|
+
|
|
103
|
+
const COUNTS_DESCRIPTOR = prefix_scan_csdldf_output_descriptor(element_count);
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param pass_data
|
|
107
|
+
* @param {FramePassResources} resources
|
|
108
|
+
* @param {GraphicsExecutionContext} context
|
|
109
|
+
*/
|
|
110
|
+
function execute_count_single_workgroup(pass_data, resources, context) {
|
|
111
|
+
const source = resources.get(pass_data.tree);
|
|
112
|
+
|
|
113
|
+
assert.greaterThanOrEqual(source.size, tree_bytes, 'binary tree buffer underflow');
|
|
114
|
+
|
|
115
|
+
shader_bvh8_encode_count_single_workgroup.dispatch({
|
|
116
|
+
encoder: context.encoder,
|
|
117
|
+
// one workgroup holds the whole of it
|
|
118
|
+
group_count_x: 1,
|
|
119
|
+
bindings: {
|
|
120
|
+
leaf_count,
|
|
121
|
+
tree: source,
|
|
122
|
+
sums: resources.get(pass_data.sums),
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @param pass_data
|
|
129
|
+
* @param {FramePassResources} resources
|
|
130
|
+
* @param {GraphicsExecutionContext} context
|
|
131
|
+
*/
|
|
132
|
+
function execute_parents(pass_data, resources, context) {
|
|
133
|
+
const source = resources.get(pass_data.tree);
|
|
134
|
+
|
|
135
|
+
assert.greaterThanOrEqual(source.size, tree_bytes, 'binary tree buffer underflow');
|
|
136
|
+
|
|
137
|
+
shader_bvh8_encode_parents.dispatchThreads({
|
|
138
|
+
encoder: context.encoder,
|
|
139
|
+
thread_count_x: internal_count,
|
|
140
|
+
bindings: {
|
|
141
|
+
leaf_count,
|
|
142
|
+
tree: source,
|
|
143
|
+
parents: resources.get(pass_data.parents),
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @param pass_data
|
|
150
|
+
* @param {FramePassResources} resources
|
|
151
|
+
* @param {GraphicsExecutionContext} context
|
|
152
|
+
*/
|
|
153
|
+
function execute_count(pass_data, resources, context) {
|
|
154
|
+
shader_bvh8_encode_count.dispatchThreads({
|
|
155
|
+
encoder: context.encoder,
|
|
156
|
+
thread_count_x: internal_count,
|
|
157
|
+
bindings: {
|
|
158
|
+
leaf_count,
|
|
159
|
+
tree: resources.get(pass_data.tree),
|
|
160
|
+
parents: resources.get(pass_data.parents),
|
|
161
|
+
counts: resources.get(pass_data.counts),
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @param pass_data
|
|
168
|
+
* @param {FramePassResources} resources
|
|
169
|
+
* @param {GraphicsExecutionContext} context
|
|
170
|
+
*/
|
|
171
|
+
function execute_assign(pass_data, resources, context) {
|
|
172
|
+
shader_bvh8_encode_assign.dispatchThreads({
|
|
173
|
+
encoder: context.encoder,
|
|
174
|
+
// the wide tree's nodes are fewer, by a count only the device has; the lanes past it return
|
|
175
|
+
thread_count_x: wide_lanes,
|
|
176
|
+
bindings: {
|
|
177
|
+
leaf_count,
|
|
178
|
+
tree: resources.get(pass_data.tree),
|
|
179
|
+
sums: resources.get(pass_data.sums),
|
|
180
|
+
placement: resources.get(pass_data.placement),
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @param pass_data
|
|
187
|
+
* @param {FramePassResources} resources
|
|
188
|
+
* @param {GraphicsExecutionContext} context
|
|
189
|
+
*/
|
|
190
|
+
function execute_write(pass_data, resources, context) {
|
|
191
|
+
const output = resources.get(pass_data.out);
|
|
192
|
+
|
|
193
|
+
assert.greaterThanOrEqual(output.size, out_bytes, 'BVH8 buffer underflow');
|
|
194
|
+
|
|
195
|
+
shader_bvh8_encode_write.dispatchThreads({
|
|
196
|
+
encoder: context.encoder,
|
|
197
|
+
// as the assign pass is dispatched
|
|
198
|
+
thread_count_x: wide_lanes,
|
|
199
|
+
bindings: {
|
|
200
|
+
leaf_count,
|
|
201
|
+
tree: resources.get(pass_data.tree),
|
|
202
|
+
sums: resources.get(pass_data.sums),
|
|
203
|
+
placement: resources.get(pass_data.placement),
|
|
204
|
+
out: output,
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** @type {number} */
|
|
210
|
+
let sums;
|
|
211
|
+
|
|
212
|
+
if (leaf_count <= BVH8_ENCODE_SINGLE_WORKGROUP_LEAVES) {
|
|
213
|
+
const count_data = {};
|
|
214
|
+
const count_pass = graph.add("bvh8 encode/count, single workgroup", count_data, execute_count_single_workgroup);
|
|
215
|
+
|
|
216
|
+
count_data.tree = count_pass.read(tree);
|
|
217
|
+
count_data.sums = count_pass.create("bvh8 encode/sums", COUNTS_DESCRIPTOR);
|
|
218
|
+
|
|
219
|
+
sums = count_data.sums;
|
|
220
|
+
} else {
|
|
221
|
+
// aligned on a 1k boundary to lower memory fragmentation, as the binary build's transients are
|
|
222
|
+
const PARENTS_DESCRIPTOR = BufferResourceDescriptor.from(
|
|
223
|
+
round_up(internal_count * Uint32Array.BYTES_PER_ELEMENT, 1024),
|
|
224
|
+
GPUBufferUsage.STORAGE
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
const parents_data = {};
|
|
228
|
+
const parents_pass = graph.add("bvh8 encode/parents", parents_data, execute_parents);
|
|
229
|
+
|
|
230
|
+
parents_data.tree = parents_pass.read(tree);
|
|
231
|
+
parents_data.parents = parents_pass.create("bvh8 encode/parents", PARENTS_DESCRIPTOR);
|
|
232
|
+
|
|
233
|
+
const count_data = {};
|
|
234
|
+
const count_pass = graph.add("bvh8 encode/count", count_data, execute_count);
|
|
235
|
+
|
|
236
|
+
count_data.tree = count_pass.read(tree);
|
|
237
|
+
count_data.parents = count_pass.read(parents_data.parents);
|
|
238
|
+
count_data.counts = count_pass.create("bvh8 encode/counts", COUNTS_DESCRIPTOR);
|
|
239
|
+
|
|
240
|
+
// the scan's output is a buffer of its own: it re-reads its input while it writes
|
|
241
|
+
sums = graph_prefix_scan_csdldf({
|
|
242
|
+
graph,
|
|
243
|
+
input: count_data.counts,
|
|
244
|
+
output: graph_create_buffer(graph, "bvh8 encode/sums", COUNTS_DESCRIPTOR),
|
|
245
|
+
element_max_count: element_count,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const assign_data = {};
|
|
250
|
+
const assign_pass = graph.add("bvh8 encode/assign", assign_data, execute_assign);
|
|
251
|
+
|
|
252
|
+
assign_data.tree = assign_pass.read(tree);
|
|
253
|
+
assign_data.sums = assign_pass.read(sums);
|
|
254
|
+
assign_data.placement = assign_pass.create("bvh8 encode/placement", PLACEMENT_DESCRIPTOR);
|
|
255
|
+
|
|
256
|
+
const write_data = {};
|
|
257
|
+
const write_pass = graph.add("bvh8 encode/write", write_data, execute_write);
|
|
258
|
+
|
|
259
|
+
write_data.tree = write_pass.read(tree);
|
|
260
|
+
write_data.sums = write_pass.read(sums);
|
|
261
|
+
write_data.placement = write_pass.read(assign_data.placement);
|
|
262
|
+
write_data.out = write_pass.write(out);
|
|
263
|
+
|
|
264
|
+
return write_data.out;
|
|
265
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Words of `placement` an internal node of the binary tree has.
|
|
3
|
+
* @type {number}
|
|
4
|
+
*/
|
|
5
|
+
export const BVH8_ENCODE_PLACEMENT_STRIDE_WORDS: number;
|
|
6
|
+
/**
|
|
7
|
+
* Of an internal node's `placement`, the word its own lane writes: the slot of each of its children,
|
|
8
|
+
* three bits a child.
|
|
9
|
+
*
|
|
10
|
+
* @type {number}
|
|
11
|
+
*/
|
|
12
|
+
export const BVH8_ENCODE_PLACEMENT_SLOTS_WORD: number;
|
|
13
|
+
/**
|
|
14
|
+
* Of an internal node's `placement`, the word the lane of the wide node it is a child of writes:
|
|
15
|
+
* that node, times eight, and in the low three bits this node's rank among its child nodes.
|
|
16
|
+
*
|
|
17
|
+
* @type {number}
|
|
18
|
+
*/
|
|
19
|
+
export const BVH8_ENCODE_PLACEMENT_PARENT_WORD: number;
|
|
20
|
+
/**
|
|
21
|
+
* The slots of every node of the wide tree's children — the pass of
|
|
22
|
+
* {@link graph_bvh8_encode_from_bvh2} between the scan and the write, over more leaves than one
|
|
23
|
+
* workgroup takes.
|
|
24
|
+
*
|
|
25
|
+
* A lane per node of the wide tree, which finds the node of the binary tree it stands for by its
|
|
26
|
+
* ordinal ({@link chunk_bvh8_encode_sums}): the dispatch covers the binary tree's internal nodes,
|
|
27
|
+
* and the lanes past the wide tree's node count return at once, whole workgroups of them.
|
|
28
|
+
*
|
|
29
|
+
* `placement` is written for the nodes of the wide tree alone: by a node's own lane the slots of its
|
|
30
|
+
* children, and by the lane of the node it is a child of, whose that is and its rank there. Each
|
|
31
|
+
* word has one writer, and the root has no second word.
|
|
32
|
+
*
|
|
33
|
+
* @type {ComputeShader}
|
|
34
|
+
*/
|
|
35
|
+
export const shader_bvh8_encode_assign: ComputeShader;
|
|
36
|
+
import { ComputeShader } from "../../shader/ComputeShader.js";
|
|
37
|
+
//# sourceMappingURL=shader_bvh8_encode_assign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader_bvh8_encode_assign.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_assign.js"],"names":[],"mappings":"AASA;;;GAGG;AACH,iDAFU,MAAM,CAEoC;AAEpD;;;;;GAKG;AACH,+CAFU,MAAM,CAEkC;AAElD;;;;;GAKG;AACH,gDAFU,MAAM,CAEmC;AA4DnD;;;;;;;;;;;;;;GAcG;AACH,wCAFU,aAAa,CAMpB;8BA3G2B,+BAA+B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { ComputeShader } from "../../shader/ComputeShader.js";
|
|
3
|
+
import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
|
|
4
|
+
import { u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
5
|
+
import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
|
|
6
|
+
import { chunk_bvh8_encode_assign } from "./chunk_bvh8_encode_assign.js";
|
|
7
|
+
import { chunk_bvh8_encode_sums } from "./chunk_bvh8_encode_sums.js";
|
|
8
|
+
import { BVH8_ENCODE_WORKGROUP_SIZE } from "./shader_bvh8_encode_parents.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Words of `placement` an internal node of the binary tree has.
|
|
12
|
+
* @type {number}
|
|
13
|
+
*/
|
|
14
|
+
export const BVH8_ENCODE_PLACEMENT_STRIDE_WORDS = 2;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Of an internal node's `placement`, the word its own lane writes: the slot of each of its children,
|
|
18
|
+
* three bits a child.
|
|
19
|
+
*
|
|
20
|
+
* @type {number}
|
|
21
|
+
*/
|
|
22
|
+
export const BVH8_ENCODE_PLACEMENT_SLOTS_WORD = 0;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Of an internal node's `placement`, the word the lane of the wide node it is a child of writes:
|
|
26
|
+
* that node, times eight, and in the low three bits this node's rank among its child nodes.
|
|
27
|
+
*
|
|
28
|
+
* @type {number}
|
|
29
|
+
*/
|
|
30
|
+
export const BVH8_ENCODE_PLACEMENT_PARENT_WORD = 1;
|
|
31
|
+
|
|
32
|
+
const resources = new ShaderResourceSetDescriptor();
|
|
33
|
+
|
|
34
|
+
// leaves in the binary tree
|
|
35
|
+
resources.setImmediate("leaf_count", u32);
|
|
36
|
+
|
|
37
|
+
resources.createGroup()
|
|
38
|
+
// `[root][nodes]`, in the layout of BVH_BUFFER_LAYOUT, fitted
|
|
39
|
+
.addStorageBuffer("tree", WebGPUArray.from(u32), false)
|
|
40
|
+
// the running sums of what shader_bvh8_encode_count wrote, each including its own element
|
|
41
|
+
.addStorageBuffer("sums", WebGPUArray.from(u32), false)
|
|
42
|
+
// two words an internal node: the slots of its children, and its place in its parent
|
|
43
|
+
.addStorageBuffer("placement", WebGPUArray.from(u32), true);
|
|
44
|
+
|
|
45
|
+
const body = CodeChunk.from(
|
|
46
|
+
//language=WGSL
|
|
47
|
+
`
|
|
48
|
+
const PLACEMENT_STRIDE = ${BVH8_ENCODE_PLACEMENT_STRIDE_WORDS}u;
|
|
49
|
+
const PLACEMENT_SLOTS = ${BVH8_ENCODE_PLACEMENT_SLOTS_WORD}u;
|
|
50
|
+
const PLACEMENT_PARENT = ${BVH8_ENCODE_PLACEMENT_PARENT_WORD}u;
|
|
51
|
+
|
|
52
|
+
@compute @workgroup_size(${BVH8_ENCODE_WORKGROUP_SIZE}, 1, 1)
|
|
53
|
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
|
54
|
+
// a lane per node of the wide tree
|
|
55
|
+
let ordinal = gid.x;
|
|
56
|
+
|
|
57
|
+
// the binary tree's internal nodes come first, one fewer than there are leaves
|
|
58
|
+
let internal_count = leaf_count - 1u;
|
|
59
|
+
|
|
60
|
+
// the root, and every child node
|
|
61
|
+
if (ordinal > bvh8_encode_child_nodes(internal_count)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let node = bvh8_encode_wide_node(ordinal, internal_count);
|
|
66
|
+
|
|
67
|
+
let children = bvh8_encode_gather(node, internal_count);
|
|
68
|
+
|
|
69
|
+
let assignment = bvh8_encode_assign(node, children);
|
|
70
|
+
|
|
71
|
+
placement[node * PLACEMENT_STRIDE + PLACEMENT_SLOTS] = assignment.slots;
|
|
72
|
+
|
|
73
|
+
// each child node is told whose it is, and where it stands among that node's child nodes
|
|
74
|
+
for (var c = 0u; c < children.count; c++) {
|
|
75
|
+
if ((children.internal & (1u << c)) == 0u) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let rank = bvh8_encode_rank(assignment.internal, bvh8_encode_slot_of(assignment.slots, c));
|
|
80
|
+
|
|
81
|
+
placement[children.nodes[c] * PLACEMENT_STRIDE + PLACEMENT_PARENT] = node * 8u + rank;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
`, [
|
|
85
|
+
chunk_bvh8_encode_sums,
|
|
86
|
+
chunk_bvh8_encode_assign,
|
|
87
|
+
]
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The slots of every node of the wide tree's children — the pass of
|
|
92
|
+
* {@link graph_bvh8_encode_from_bvh2} between the scan and the write, over more leaves than one
|
|
93
|
+
* workgroup takes.
|
|
94
|
+
*
|
|
95
|
+
* A lane per node of the wide tree, which finds the node of the binary tree it stands for by its
|
|
96
|
+
* ordinal ({@link chunk_bvh8_encode_sums}): the dispatch covers the binary tree's internal nodes,
|
|
97
|
+
* and the lanes past the wide tree's node count return at once, whole workgroups of them.
|
|
98
|
+
*
|
|
99
|
+
* `placement` is written for the nodes of the wide tree alone: by a node's own lane the slots of its
|
|
100
|
+
* children, and by the lane of the node it is a child of, whose that is and its rank there. Each
|
|
101
|
+
* word has one writer, and the root has no second word.
|
|
102
|
+
*
|
|
103
|
+
* @type {ComputeShader}
|
|
104
|
+
*/
|
|
105
|
+
export const shader_bvh8_encode_assign = ComputeShader.from({
|
|
106
|
+
label: "BVH8Encode/Assign",
|
|
107
|
+
resources,
|
|
108
|
+
body,
|
|
109
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which nodes of a binary tree become nodes of the wide one, and how many child nodes and how many
|
|
3
|
+
* leaves each will hold — the second pass of {@link graph_bvh8_encode_from_bvh2} over more leaves
|
|
4
|
+
* than one workgroup takes.
|
|
5
|
+
*
|
|
6
|
+
* A lane per internal node. `counts` is written whole, in the form `graph_prefix_scan_csdldf` takes:
|
|
7
|
+
* the child nodes of every internal node in node order, then the leaves of every one, then a one
|
|
8
|
+
* for every one that is a node of the wide tree; zeroes for a node that is not. What their running
|
|
9
|
+
* sums say is in {@link chunk_bvh8_encode_sums}.
|
|
10
|
+
*
|
|
11
|
+
* @type {ComputeShader}
|
|
12
|
+
*/
|
|
13
|
+
export const shader_bvh8_encode_count: ComputeShader;
|
|
14
|
+
import { ComputeShader } from "../../shader/ComputeShader.js";
|
|
15
|
+
//# sourceMappingURL=shader_bvh8_encode_count.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader_bvh8_encode_count.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count.js"],"names":[],"mappings":"AAoEA;;;;;;;;;;;GAWG;AACH,uCAFU,aAAa,CAMpB;8BAnF2B,+BAA+B"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { ComputeShader } from "../../shader/ComputeShader.js";
|
|
3
|
+
import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
|
|
4
|
+
import { u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
5
|
+
import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
|
|
6
|
+
import { PREFIX_SCAN_CSDLDF_HEADER_WORDS } from "../prefix_sum/v1/shader_prefix_scan_csdldf.js";
|
|
7
|
+
import { chunk_bvh8_encode_depth } from "./chunk_bvh8_encode_depth.js";
|
|
8
|
+
import { chunk_bvh8_encode_gather } from "./chunk_bvh8_encode_gather.js";
|
|
9
|
+
import { BVH8_ENCODE_COUNTS_PER_NODE } from "./chunk_bvh8_encode_sums.js";
|
|
10
|
+
import { BVH8_ENCODE_WORKGROUP_SIZE } from "./shader_bvh8_encode_parents.js";
|
|
11
|
+
|
|
12
|
+
const resources = new ShaderResourceSetDescriptor();
|
|
13
|
+
|
|
14
|
+
// leaves in the binary tree
|
|
15
|
+
resources.setImmediate("leaf_count", u32);
|
|
16
|
+
|
|
17
|
+
resources.createGroup()
|
|
18
|
+
// `[root][nodes]`, in the layout of BVH_BUFFER_LAYOUT; of a node this reads its two child words
|
|
19
|
+
.addStorageBuffer("tree", WebGPUArray.from(u32), false)
|
|
20
|
+
// a word an internal node
|
|
21
|
+
.addStorageBuffer("parents", WebGPUArray.from(u32), false)
|
|
22
|
+
// what the prefix scan takes: how many elements, then the elements
|
|
23
|
+
.addStorageBuffer("counts", WebGPUArray.from(u32), true);
|
|
24
|
+
|
|
25
|
+
const body = CodeChunk.from(
|
|
26
|
+
//language=WGSL
|
|
27
|
+
`
|
|
28
|
+
const COUNTS = ${PREFIX_SCAN_CSDLDF_HEADER_WORDS}u;
|
|
29
|
+
|
|
30
|
+
@compute @workgroup_size(${BVH8_ENCODE_WORKGROUP_SIZE}, 1, 1)
|
|
31
|
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
|
32
|
+
let node = gid.x;
|
|
33
|
+
|
|
34
|
+
// the internal nodes come first, one fewer than there are leaves
|
|
35
|
+
let internal_count = leaf_count - 1u;
|
|
36
|
+
|
|
37
|
+
if (node >= internal_count) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var child_nodes = 0u;
|
|
42
|
+
var leaves = 0u;
|
|
43
|
+
var wide = 0u;
|
|
44
|
+
|
|
45
|
+
if (bvh8_encode_depth(node) % BVH8_ENCODE_LEVELS == 0u) {
|
|
46
|
+
// a node of the wide tree
|
|
47
|
+
let children = bvh8_encode_gather(node, internal_count);
|
|
48
|
+
|
|
49
|
+
child_nodes = countOneBits(children.internal);
|
|
50
|
+
leaves = children.count - child_nodes;
|
|
51
|
+
wide = 1u;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// the counts of every node, a kind at a time end to end: one scan sums them all
|
|
55
|
+
counts[COUNTS + node] = child_nodes;
|
|
56
|
+
counts[COUNTS + internal_count + node] = leaves;
|
|
57
|
+
counts[COUNTS + 2u * internal_count + node] = wide;
|
|
58
|
+
|
|
59
|
+
if (node == 0u) {
|
|
60
|
+
counts[0] = ${BVH8_ENCODE_COUNTS_PER_NODE}u * internal_count;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`, [
|
|
64
|
+
chunk_bvh8_encode_depth,
|
|
65
|
+
chunk_bvh8_encode_gather,
|
|
66
|
+
]
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Which nodes of a binary tree become nodes of the wide one, and how many child nodes and how many
|
|
71
|
+
* leaves each will hold — the second pass of {@link graph_bvh8_encode_from_bvh2} over more leaves
|
|
72
|
+
* than one workgroup takes.
|
|
73
|
+
*
|
|
74
|
+
* A lane per internal node. `counts` is written whole, in the form `graph_prefix_scan_csdldf` takes:
|
|
75
|
+
* the child nodes of every internal node in node order, then the leaves of every one, then a one
|
|
76
|
+
* for every one that is a node of the wide tree; zeroes for a node that is not. What their running
|
|
77
|
+
* sums say is in {@link chunk_bvh8_encode_sums}.
|
|
78
|
+
*
|
|
79
|
+
* @type {ComputeShader}
|
|
80
|
+
*/
|
|
81
|
+
export const shader_bvh8_encode_count = ComputeShader.from({
|
|
82
|
+
label: "BVH8Encode/Count",
|
|
83
|
+
resources,
|
|
84
|
+
body,
|
|
85
|
+
});
|