mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-09 20:31:29 +11:00
Merge pull request #25 from ztlpn/fix-mapping-size
Fix read mapping size in the Vulkan adapter
This commit is contained in:
commit
2c0f1d3cdd
|
@ -744,18 +744,18 @@ impl crate::Device for VkDevice {
|
||||||
result: &mut Vec<T>,
|
result: &mut Vec<T>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let device = &self.device.device;
|
let device = &self.device.device;
|
||||||
let size = buffer.size as usize / std::mem::size_of::<T>();
|
|
||||||
let buf = device.map_memory(
|
let buf = device.map_memory(
|
||||||
buffer.buffer_memory,
|
buffer.buffer_memory,
|
||||||
0,
|
0,
|
||||||
size as u64,
|
buffer.size,
|
||||||
vk::MemoryMapFlags::empty(),
|
vk::MemoryMapFlags::empty(),
|
||||||
)?;
|
)?;
|
||||||
if size > result.len() {
|
let len = buffer.size as usize / std::mem::size_of::<T>();
|
||||||
result.reserve(size - result.len());
|
if len > result.len() {
|
||||||
|
result.reserve(len - result.len());
|
||||||
}
|
}
|
||||||
std::ptr::copy_nonoverlapping(buf as *const T, result.as_mut_ptr(), size);
|
std::ptr::copy_nonoverlapping(buf as *const T, result.as_mut_ptr(), len);
|
||||||
result.set_len(size);
|
result.set_len(len);
|
||||||
device.unmap_memory(buffer.buffer_memory);
|
device.unmap_memory(buffer.buffer_memory);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue