This commit is contained in:
parent
c0367144a6
commit
dd8a5a97ea
9 changed files with 83 additions and 13 deletions
|
@ -62,7 +62,7 @@ impl VkRenderContext {
|
|||
.create_framebuffers(&render_pass)
|
||||
.ok_or_else(|| anyhow::anyhow!("Failed to get framebuffers"))?;
|
||||
|
||||
let pipeline = Arc::new(VkGraphicsPipeline::new(&device, &swapchain, &render_pass)?);
|
||||
let pipeline = Arc::new(VkGraphicsPipeline::new(&device, &render_pass)?);
|
||||
|
||||
let command_pool = VkCommandPool::new(&device)?;
|
||||
|
||||
|
@ -109,6 +109,10 @@ impl VkRenderContext {
|
|||
.swapchain
|
||||
.acquire_next_image(&self.image_available_semaphore)?;
|
||||
|
||||
// if self.swapchain.is_dirty() {
|
||||
// self.update_swapchain()?
|
||||
// }
|
||||
|
||||
let command_buffer = self.command_buffers[index as usize];
|
||||
unsafe { self.device.handle.reset_command_buffer(command_buffer, vk::CommandBufferResetFlags::default())? };
|
||||
|
||||
|
@ -152,7 +156,7 @@ impl VkRenderContext {
|
|||
|
||||
unsafe { self.device.handle.cmd_set_viewport(command_buffer, 0, &[viewport]) }
|
||||
|
||||
let scissor = vk::Rect2D::default().extent(self.swapchain.surface_resolution);
|
||||
let scissor = self.swapchain.surface_resolution.into();
|
||||
|
||||
unsafe { self.device.handle.cmd_set_scissor(command_buffer, 0, &[scissor]) }
|
||||
|
||||
|
@ -196,8 +200,9 @@ impl VkRenderContext {
|
|||
}
|
||||
|
||||
pub fn update_resolution(&mut self, width: u32, height: u32) -> anyhow::Result<()> {
|
||||
if let Some(swapchain) = Arc::get_mut(&mut self.swapchain) {
|
||||
swapchain.update_resolution(width, height)?;
|
||||
match Arc::get_mut(&mut self.swapchain) {
|
||||
Some(swapchain) => swapchain.update_resolution(width, height)?,
|
||||
None => log::warn!("Impossible to get mutable swapchain"),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -206,4 +211,19 @@ impl VkRenderContext {
|
|||
pub fn exit(&self) {
|
||||
unsafe { self.device.handle.device_wait_idle().unwrap() }
|
||||
}
|
||||
|
||||
fn update_swapchain(&mut self) -> anyhow::Result<()> {
|
||||
match Arc::get_mut(&mut self.swapchain) {
|
||||
Some(swapchain) => {
|
||||
swapchain.create_swapchain()?;
|
||||
|
||||
self.framebuffers = self.swapchain
|
||||
.create_framebuffers(&self.render_pass)
|
||||
.ok_or_else(|| anyhow::anyhow!("Failed to get framebuffers"))?;
|
||||
}
|
||||
None => log::warn!("Impossible to get mutable swapchain"),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue