From 9dd656d49fc1c5c6b10f5a8ef8c427b7c43d87ce Mon Sep 17 00:00:00 2001 From: chyyran Date: Tue, 10 Jan 2023 22:22:42 -0500 Subject: [PATCH] vk: fix some bugs in the format --- librashader-runtime-vk/src/filter_pass.rs | 5 ++ librashader-runtime-vk/src/framebuffer.rs | 68 ------------------- .../src/hello_triangle/mod.rs | 1 + librashader-runtime-vk/src/renderpass.rs | 2 +- librashader-runtime-vk/src/texture.rs | 4 +- 5 files changed, 10 insertions(+), 70 deletions(-) diff --git a/librashader-runtime-vk/src/filter_pass.rs b/librashader-runtime-vk/src/filter_pass.rs index a721981..7017a56 100644 --- a/librashader-runtime-vk/src/filter_pass.rs +++ b/librashader-runtime-vk/src/filter_pass.rs @@ -105,6 +105,11 @@ impl FilterPass { let render_pass_info = vk::RenderPassBeginInfo::builder() .framebuffer(output.output.framebuffer) .render_pass(self.graphics_pipeline.render_pass.handle) + .clear_values(&[vk::ClearValue { + color: vk::ClearColorValue { + float32: [0.0, 0.0, 0.0, 0.0] + } + }]) .render_area(vk::Rect2D { offset: Default::default(), extent: output.output.size.into(), diff --git a/librashader-runtime-vk/src/framebuffer.rs b/librashader-runtime-vk/src/framebuffer.rs index 636f985..178ef43 100644 --- a/librashader-runtime-vk/src/framebuffer.rs +++ b/librashader-runtime-vk/src/framebuffer.rs @@ -6,64 +6,6 @@ use ash::vk; use ash::vk::{ImageAspectFlags, ImageViewType}; use librashader_common::Size; -pub struct VulkanFramebuffer { - pub device: ash::Device, - pub framebuffer: vk::Framebuffer, -} - -impl Drop for VulkanFramebuffer { - fn drop(&mut self) { - unsafe { - if self.framebuffer != vk::Framebuffer::null() { - self.device.destroy_framebuffer(self.framebuffer, None); - } - } - } -} -// -// pub struct OwnedFramebuffer { -// pub size: Size, -// pub image: OwnedTexture, -// pub render_pass: VulkanRenderPass, -// pub framebuffer: VulkanFramebuffer, -// pub view: vk::ImageView, -// } -// -// impl OwnedFramebuffer { -// pub fn new( -// vulkan: &Vulkan, -// size: Size, -// render_pass: VulkanRenderPass, -// max_miplevels: u32, -// ) -> error::Result { -// let image = OwnedTexture::new(vulkan, size, render_pass.format, max_miplevels)?; -// let fb_view = image.create_texture_view()?; -// let framebuffer = unsafe { -// vulkan.device.create_framebuffer( -// &vk::FramebufferCreateInfo::builder() -// .render_pass(render_pass.handle) -// .attachments(&[image.image_view]) -// .width(image.image.size.width) -// .height(image.image.size.height) -// .layers(1) -// .build(), -// None, -// )? -// }; -// -// Ok(OwnedFramebuffer { -// size, -// image, -// view: fb_view, -// render_pass, -// framebuffer: VulkanFramebuffer { -// device: vulkan.device.clone(), -// framebuffer, -// }, -// }) -// } -// } - #[derive(Clone)] pub(crate) struct OutputFramebuffer { pub framebuffer: vk::Framebuffer, @@ -73,16 +15,6 @@ pub(crate) struct OutputFramebuffer { image: vk::Image, } -// -// pub struct OutputFramebuffer<'a> { -// device: ash::Device, -// render_pass: &'a VulkanRenderPass, -// pub handle: vk::Framebuffer, -// pub size: Size, -// pub image: vk::Image, -// pub image_view: vk::ImageView, -// } -// impl OutputFramebuffer { pub fn new(vulkan: &Vulkan, render_pass: &VulkanRenderPass, image: vk::Image, size: Size) -> error::Result { let image_subresource = vk::ImageSubresourceRange::builder() diff --git a/librashader-runtime-vk/src/hello_triangle/mod.rs b/librashader-runtime-vk/src/hello_triangle/mod.rs index 435a803..d261654 100644 --- a/librashader-runtime-vk/src/hello_triangle/mod.rs +++ b/librashader-runtime-vk/src/hello_triangle/mod.rs @@ -324,6 +324,7 @@ impl VulkanWindow { .queue_present(vulkan.base.graphics_queue, &present_info) .unwrap(); + vulkan.base.device.device_wait_idle().unwrap(); drop(intermediates) } } diff --git a/librashader-runtime-vk/src/renderpass.rs b/librashader-runtime-vk/src/renderpass.rs index ade1dbb..93d0952 100644 --- a/librashader-runtime-vk/src/renderpass.rs +++ b/librashader-runtime-vk/src/renderpass.rs @@ -24,7 +24,7 @@ impl VulkanRenderPass { .flags(vk::AttachmentDescriptionFlags::empty()) .format(format.into()) .samples(SampleCountFlags::TYPE_1) - .load_op(AttachmentLoadOp::CLEAR) + .load_op(AttachmentLoadOp::DONT_CARE) .store_op(AttachmentStoreOp::STORE) .stencil_load_op(AttachmentLoadOp::DONT_CARE) .stencil_store_op(AttachmentStoreOp::DONT_CARE) diff --git a/librashader-runtime-vk/src/texture.rs b/librashader-runtime-vk/src/texture.rs index 4020338..39d1c2b 100644 --- a/librashader-runtime-vk/src/texture.rs +++ b/librashader-runtime-vk/src/texture.rs @@ -36,6 +36,7 @@ impl OwnedTexture { .array_layers(1) .samples(SampleCountFlags::TYPE_1) .tiling(ImageTiling::OPTIMAL) + .flags(vk::ImageCreateFlags::MUTABLE_FORMAT) .usage( ImageUsageFlags::SAMPLED | ImageUsageFlags::COLOR_ATTACHMENT @@ -129,7 +130,8 @@ impl OwnedTexture { format }, self.max_miplevels)?; - std::mem::swap(self, &mut new) + let old = std::mem::replace(self, new); + drop(old) } Ok(size) }