vulkan: Move allocate to command pool
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1s
This commit is contained in:
parent
a669247406
commit
4b08b7359d
3 changed files with 24 additions and 11 deletions
|
@ -1 +1,7 @@
|
||||||
pub mod vulkan;
|
use ash::vk;
|
||||||
|
|
||||||
|
pub mod vulkan;
|
||||||
|
|
||||||
|
pub trait Renderable {
|
||||||
|
fn render(device: &vulkan::VkDevice, command_buffer: vk::CommandBuffer);
|
||||||
|
}
|
|
@ -27,6 +27,21 @@ impl VkCommandPool {
|
||||||
handle: command_pool,
|
handle: command_pool,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn allocate_command_buffers_for_framebuffers(&self, framebuffers_count: u32) -> VkResult<Vec<vk::CommandBuffer>> {
|
||||||
|
let command_buffer_info = vk::CommandBufferAllocateInfo::default()
|
||||||
|
.command_pool(self.handle)
|
||||||
|
.level(vk::CommandBufferLevel::PRIMARY)
|
||||||
|
.command_buffer_count(framebuffers_count);
|
||||||
|
|
||||||
|
let command_buffers = unsafe {
|
||||||
|
self.device
|
||||||
|
.handle
|
||||||
|
.allocate_command_buffers(&command_buffer_info)?
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(command_buffers)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for VkCommandPool {
|
impl Drop for VkCommandPool {
|
||||||
|
|
|
@ -66,17 +66,9 @@ impl VkRenderContext {
|
||||||
|
|
||||||
let command_pool = VkCommandPool::new(&device)?;
|
let command_pool = VkCommandPool::new(&device)?;
|
||||||
|
|
||||||
let command_buffer_info = vk::CommandBufferAllocateInfo::default()
|
|
||||||
.command_pool(command_pool.handle)
|
|
||||||
.level(vk::CommandBufferLevel::PRIMARY)
|
|
||||||
.command_buffer_count(framebuffers.len() as u32);
|
|
||||||
|
|
||||||
// Destroyed with command pool
|
// Destroyed with command pool
|
||||||
let command_buffers = unsafe {
|
let command_buffers = command_pool
|
||||||
device
|
.allocate_command_buffers_for_framebuffers(framebuffers.len() as u32)?;
|
||||||
.handle
|
|
||||||
.allocate_command_buffers(&command_buffer_info)?
|
|
||||||
};
|
|
||||||
|
|
||||||
let image_available_semaphore = VkSemaphore::new(&device)?;
|
let image_available_semaphore = VkSemaphore::new(&device)?;
|
||||||
let render_finished_semaphore = VkSemaphore::new(&device)?;
|
let render_finished_semaphore = VkSemaphore::new(&device)?;
|
||||||
|
|
Loading…
Reference in a new issue