Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mesh creation failing to copy index data. #1473

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,24 @@ where

/// Copies the entire buffer to another buffer and drops it.
pub fn copy_to_buffer(
mut self,
self,
encoder: &mut wgpu::CommandEncoder,
destination: &GpuBuffer,
destination_offset: wgpu::BufferAddress,
) {
let copy_size = (std::mem::size_of::<T>() * self.unwritten_element_range.start) as u64;

// Wgpu does validation as well, but in debug mode we want to panic if the buffer doesn't fit.
debug_assert!(copy_size <= destination_offset + destination.size(),
"Target buffer has a size of {}, can't write {copy_size} bytes with an offset of {destination_offset}!",
destination.size());

encoder.copy_buffer_to_buffer(
&self.chunk_buffer,
self.byte_offset_in_chunk_buffer,
destination,
destination_offset,
self.write_view.deref_mut().len() as u64,
copy_size,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/re_renderer/src/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl GpuMesh {
vertex_buffer_combined
};

let index_buffer_size = std::mem::size_of_val(data.indices.as_slice()) as u64;
let index_buffer_size = (std::mem::size_of::<u32>() * data.indices.len()) as u64;
let index_buffer = {
let index_buffer = pools.buffers.alloc(
device,
Expand Down