From ff3b24fe7319ecc9541f90d62fd6682a96e2fe38 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 28 Sep 2023 18:44:18 -0700 Subject: [PATCH] count properly --- src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 65193a6..86084fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -207,16 +207,18 @@ impl GraphicsData { }); } //drain the modeldata vec so entities can be /moved/ to models.entities + let mut model_count=0; let mut instance_count=0; let uniform_buffer_binding_size=::required_limits().max_uniform_buffer_binding_size as usize; let chunk_size=uniform_buffer_binding_size/MODEL_BUFFER_SIZE_BYTES; self.models.reserve(models.len()); for model in models.drain(..) { + instance_count+=model.instances.len(); for instances_chunk in model.instances.rchunks(chunk_size){ - instance_count+=1; + model_count+=1; let model_uniforms = get_instances_buffer_data(instances_chunk); let model_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: Some(format!("Model{} Buf",instance_count).as_str()), + label: Some(format!("Model{} Buf",model_count).as_str()), contents: bytemuck::cast_slice(&model_uniforms), usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST, }); @@ -245,7 +247,7 @@ impl GraphicsData { resource: wgpu::BindingResource::Sampler(&self.samplers.repeat), }, ], - label: Some(format!("Model{} Bind Group",instance_count).as_str()), + label: Some(format!("Model{} Bind Group",model_count).as_str()), }); let vertex_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: Some("Vertex"),