mirror of
https://github.com/italicsjenga/portability.git
synced 2025-02-17 06:37:43 +11:00
Fix stack corruption caused by command buffers
Command buffer size needs to match between exposed type in Rust and vulkan declaration. Therefore, cmd buffers get wrapped in handles
This commit is contained in:
parent
7d45552cbc
commit
ca1ff277fa
1 changed files with 6 additions and 3 deletions
|
@ -466,7 +466,7 @@ pub type VkInstance = Handle<back::Instance>;
|
|||
pub type VkPhysicalDevice = Handle<hal::Adapter<B>>;
|
||||
pub type VkDevice = Handle<hal::Gpu<B>>;
|
||||
pub type VkCommandPool = Handle<<B as hal::Backend>::CommandPool>;
|
||||
pub type VkCommandBuffer = <B as hal::Backend>::CommandBuffer;
|
||||
pub type VkCommandBuffer = Handle<<B as hal::Backend>::CommandBuffer>;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
@ -4915,7 +4915,7 @@ pub extern fn vkAllocateCommandBuffers(
|
|||
slice::from_raw_parts_mut(pCommandBuffers, count)
|
||||
};
|
||||
for (out, cmd_buf) in output.iter_mut().zip(cmd_bufs) {
|
||||
*out = cmd_buf;
|
||||
*out = Handle::new(cmd_buf);
|
||||
}
|
||||
|
||||
VkResult::VK_SUCCESS
|
||||
|
@ -4931,7 +4931,10 @@ pub extern fn vkFreeCommandBuffers(
|
|||
let buffer_slice = unsafe {
|
||||
slice::from_raw_parts(pCommandBuffers, commandBufferCount as _)
|
||||
};
|
||||
let buffers = buffer_slice.to_vec();
|
||||
let buffers = buffer_slice
|
||||
.iter()
|
||||
.map(|buffer| *buffer.unwrap())
|
||||
.collect();
|
||||
|
||||
unsafe { commandPool.free(buffers) };
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue