From d05c0773c6844423777c732d2b9712f5f91e6de1 Mon Sep 17 00:00:00 2001 From: Elias Stepanik <40958815+eliasstepanik@users.noreply.github.com> Date: Sat, 14 Jun 2025 22:10:41 +0200 Subject: [PATCH] Increase GPU worker buffer sizes --- .../environment/systems/voxels/meshing_gpu.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/src/plugins/environment/systems/voxels/meshing_gpu.rs b/client/src/plugins/environment/systems/voxels/meshing_gpu.rs index 13c60c5..9b5462d 100644 --- a/client/src/plugins/environment/systems/voxels/meshing_gpu.rs +++ b/client/src/plugins/environment/systems/voxels/meshing_gpu.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; use bevy_app_compute::prelude::*; -use super::structure::{MeshBufferPool, SparseVoxelOctree}; +use super::structure::{CHUNK_SIZE, MeshBufferPool, SparseVoxelOctree}; #[repr(C)] #[derive(ShaderType, Copy, Clone, Default)] @@ -22,6 +22,11 @@ pub struct VertexGpu { pub uv: Vec2, } +const MAX_VOXELS: usize = (CHUNK_SIZE as usize) * (CHUNK_SIZE as usize) * (CHUNK_SIZE as usize); +const MAX_QUADS: usize = MAX_VOXELS * 6; +const MAX_VERTICES: usize = MAX_QUADS * 4; +const MAX_INDICES: usize = MAX_QUADS * 6; + #[derive(TypePath)] struct GreedyMeshingShader; @@ -38,10 +43,10 @@ pub struct GpuMeshingWorker; impl ComputeWorker for GpuMeshingWorker { fn build(world: &mut World) -> AppComputeWorker { AppComputeWorkerBuilder::new(world) - .add_storage("voxels", &[0u32; 1]) + .add_storage("voxels", &[0u32; MAX_VOXELS]) .add_uniform("params", &Params::default()) - .add_storage("vertices", &[VertexGpu::default(); 1]) - .add_storage("indices", &[0u32; 1]) + .add_storage("vertices", &[VertexGpu::default(); MAX_VERTICES]) + .add_storage("indices", &[0u32; MAX_INDICES]) .add_storage("counts", &[0u32; 2]) .add_pass::( [1, 1, 1],