mirror of
https://github.com/eliasstepanik/voxel-simulation.git
synced 2026-01-10 05:18:30 +00:00
Avoid stack overflow from large worker buffers
This commit is contained in:
parent
d05c0773c6
commit
6dc12b96da
@ -42,11 +42,16 @@ pub struct GpuMeshingWorker;
|
||||
|
||||
impl ComputeWorker for GpuMeshingWorker {
|
||||
fn build(world: &mut World) -> AppComputeWorker<Self> {
|
||||
// Allocate large temporary arrays on the heap to avoid stack overflows
|
||||
let voxels = Box::new([0u32; MAX_VOXELS]);
|
||||
let vertices = Box::new([VertexGpu::default(); MAX_VERTICES]);
|
||||
let indices = Box::new([0u32; MAX_INDICES]);
|
||||
|
||||
AppComputeWorkerBuilder::new(world)
|
||||
.add_storage("voxels", &[0u32; MAX_VOXELS])
|
||||
.add_storage("voxels", voxels.as_ref())
|
||||
.add_uniform("params", &Params::default())
|
||||
.add_storage("vertices", &[VertexGpu::default(); MAX_VERTICES])
|
||||
.add_storage("indices", &[0u32; MAX_INDICES])
|
||||
.add_storage("vertices", vertices.as_ref())
|
||||
.add_storage("indices", indices.as_ref())
|
||||
.add_storage("counts", &[0u32; 2])
|
||||
.add_pass::<GreedyMeshingShader>(
|
||||
[1, 1, 1],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user