diff --git a/librashader-runtime-vk/src/draw_quad.rs b/librashader-runtime-vk/src/draw_quad.rs index 1a51730..7b78d20 100644 --- a/librashader-runtime-vk/src/draw_quad.rs +++ b/librashader-runtime-vk/src/draw_quad.rs @@ -2,15 +2,6 @@ use crate::error; use crate::vulkan_primitives::VulkanBuffer; use ash::vk; -#[rustfmt::skip] -pub(crate) static VBO_OFFSCREEN: &[f32; 16] = &[ - // Offscreen - -1.0, -1.0, 0.0, 0.0, - -1.0, 1.0, 0.0, 1.0, - 1.0, -1.0, 1.0, 0.0, - 1.0, 1.0, 1.0, 1.0, -]; - #[rustfmt::skip] pub(crate) static VBO_DEFAULT_FINAL: &[f32; 16] = &[ // Final @@ -39,17 +30,13 @@ impl DrawQuad { device, mem_props, vk::BufferUsageFlags::VERTEX_BUFFER, - 2 * std::mem::size_of::<[f32; 16]>(), + std::mem::size_of::<[f32; 16]>(), )?; { let mut map = buffer.map()?; unsafe { - map.copy_from(0, bytemuck::cast_slice(VBO_OFFSCREEN)); - map.copy_from( - std::mem::size_of::<[f32; 16]>(), - bytemuck::cast_slice(VBO_DEFAULT_FINAL), - ); + map.copy_from(0, bytemuck::cast_slice(VBO_DEFAULT_FINAL)); } } Ok(DrawQuad { @@ -59,17 +46,12 @@ impl DrawQuad { } pub fn bind_vbo(&self, cmd: vk::CommandBuffer, vbo: VboType) { - let offset = match vbo { - VboType::Offscreen => 0, - VboType::Final => std::mem::size_of::<[f32; 16]>(), - }; - unsafe { self.device.cmd_bind_vertex_buffers( cmd, 0, &[self.buffer.handle], - &[offset as vk::DeviceSize], + &[0], ) } } diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index 5cef471..17ea60f 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -22,7 +22,7 @@ use librashader_runtime::uniforms::UniformStorage; use rustc_hash::FxHashMap; use std::error::Error; use std::path::Path; -use crate::draw_quad::{DrawQuad, VBO_DEFAULT_FINAL, VBO_OFFSCREEN}; +use crate::draw_quad::DrawQuad; use crate::framebuffer::OutputFramebuffer; use crate::render_target::{DEFAULT_MVP, RenderTarget}; use crate::viewport::Viewport; @@ -362,22 +362,11 @@ impl FilterChainVulkan { uniform_bindings.insert(UniformBinding::TextureSize(*semantics), param.offset); } - // default to something sane - if source.format == ImageFormat::Unknown { - source.format = ImageFormat::R8G8B8A8Unorm - } - - // preset overrides shader - if let Some(format) = config.get_format_override() { - source.format = format; - } - let graphics_pipeline = VulkanGraphicsPipeline::new( &vulkan.device, &vulkan.pipeline_cache, &spirv_words, &reflection, - source.format, images, )?; @@ -535,7 +524,8 @@ impl FilterChainVulkan { target.image.clone())?, }; - pass.draw(cmd, index, &self.common, count as u32, 0, viewport, &original, &source, &out)?; + pass.draw(cmd, index, &self.common, count as u32, 0, + viewport, &original, &source, &out)?; // for second to last pass, we want to transition to copy instead. out.output.end_pass(cmd); @@ -560,7 +550,6 @@ impl FilterChainVulkan { y: viewport.y, mvp: viewport.mvp.unwrap_or(DEFAULT_MVP), output: OutputFramebuffer::new(&self.vulkan, - /*&pass.graphics_pipeline.render_pass,*/ viewport.output.clone())?, }; diff --git a/librashader-runtime-vk/src/filter_pass.rs b/librashader-runtime-vk/src/filter_pass.rs index e0b05a6..1ecbd71 100644 --- a/librashader-runtime-vk/src/filter_pass.rs +++ b/librashader-runtime-vk/src/filter_pass.rs @@ -104,23 +104,6 @@ impl FilterPass { output.output.begin_pass(cmd); - // 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] - // } - // }]) - // // always render into the full output, regardless of viewport settings. - // .render_area(vk::Rect2D { - // offset: vk::Offset2D { - // x: 0, - // y: 0, - // }, - // extent: output.output.size.into(), - // }).build(); - let attachments = [vk::RenderingAttachmentInfo::builder() .load_op(vk::AttachmentLoadOp::DONT_CARE) .store_op(vk::AttachmentStoreOp::STORE) @@ -173,7 +156,6 @@ impl FilterPass { parent.device.cmd_set_viewport(cmd, 0, &[output.output.size.into()]); parent.device.cmd_draw(cmd, 4, 1, 0, 0); - // parent.device.cmd_end_render_pass(cmd); parent.device.cmd_end_rendering(cmd); } Ok(()) diff --git a/librashader-runtime-vk/src/framebuffer.rs b/librashader-runtime-vk/src/framebuffer.rs index 1e1033e..1b6b334 100644 --- a/librashader-runtime-vk/src/framebuffer.rs +++ b/librashader-runtime-vk/src/framebuffer.rs @@ -1,7 +1,6 @@ use crate::{error, util}; use crate::filter_chain::Vulkan; -use crate::renderpass::VulkanRenderPass; -use crate::texture::{OwnedTexture, VulkanImage}; +use crate::texture::{VulkanImage}; use ash::vk; use ash::vk::{ImageAspectFlags, ImageViewType}; use librashader_common::Size; @@ -81,30 +80,4 @@ impl OutputFramebuffer { vk::QUEUE_FAMILY_IGNORED) } } - - // pub fn get_renderpass_begin_info(&self, area: vk::Rect2D, clear: Option<&[vk::ClearValue]>) -> vk::RenderPassBeginInfo { - // let mut builder = vk::RenderPassBeginInfo::builder() - // .render_pass(self.render_pass.handle) - // .framebuffer(self.handle) - // .render_area(area); - // - // if let Some(clear) = clear { - // builder = builder.clear_values(clear) - // } - // - // builder.build() - // } } - -impl Drop for OutputFramebuffer { - fn drop(&mut self) { - unsafe { - // if self.framebuffer != vk::Framebuffer::null() { - // self.device.destroy_framebuffer(self.framebuffer, None); - // } - // if self.image_view != vk::ImageView::null() { - // self.device.destroy_image_view(self.image_view, None); - // } - } - } -} \ No newline at end of file diff --git a/librashader-runtime-vk/src/lib.rs b/librashader-runtime-vk/src/lib.rs index 69dddff..1e9b8d2 100644 --- a/librashader-runtime-vk/src/lib.rs +++ b/librashader-runtime-vk/src/lib.rs @@ -9,7 +9,6 @@ mod filter_pass; mod framebuffer; mod hello_triangle; mod luts; -mod renderpass; mod render_target; mod samplers; mod texture; diff --git a/librashader-runtime-vk/src/renderpass.rs b/librashader-runtime-vk/src/renderpass.rs deleted file mode 100644 index 93d0952..0000000 --- a/librashader-runtime-vk/src/renderpass.rs +++ /dev/null @@ -1,56 +0,0 @@ -use crate::error; -use ash::vk; -use ash::vk::{ - AttachmentLoadOp, AttachmentStoreOp, ImageLayout, PipelineBindPoint, SampleCountFlags, -}; -use librashader_common::ImageFormat; - -pub struct VulkanRenderPass { - pub handle: vk::RenderPass, - pub format: ImageFormat, -} - -impl VulkanRenderPass { - pub fn create_render_pass( - device: &ash::Device, - mut format: ImageFormat, - ) -> error::Result { - // default to reasonable choice if unknown - if format == ImageFormat::Unknown { - format = ImageFormat::R8G8B8A8Unorm; - } - - let attachment = vk::AttachmentDescription::builder() - .flags(vk::AttachmentDescriptionFlags::empty()) - .format(format.into()) - .samples(SampleCountFlags::TYPE_1) - .load_op(AttachmentLoadOp::DONT_CARE) - .store_op(AttachmentStoreOp::STORE) - .stencil_load_op(AttachmentLoadOp::DONT_CARE) - .stencil_store_op(AttachmentStoreOp::DONT_CARE) - .initial_layout(ImageLayout::COLOR_ATTACHMENT_OPTIMAL) - .final_layout(ImageLayout::COLOR_ATTACHMENT_OPTIMAL) - .build(); - - let attachment_ref = vk::AttachmentReference::builder() - .attachment(0) - .layout(ImageLayout::COLOR_ATTACHMENT_OPTIMAL) - .build(); - - let subpass = vk::SubpassDescription::builder() - .pipeline_bind_point(PipelineBindPoint::GRAPHICS) - .color_attachments(&[attachment_ref]) - .build(); - - let renderpass_info = vk::RenderPassCreateInfo::builder() - .flags(vk::RenderPassCreateFlags::empty()) - .attachments(&[attachment]) - .subpasses(&[subpass]) - .build(); - - unsafe { - let rp = device.create_render_pass(&renderpass_info, None)?; - Ok(Self { handle: rp, format }) - } - } -} diff --git a/librashader-runtime-vk/src/vulkan_state.rs b/librashader-runtime-vk/src/vulkan_state.rs index 01f8da7..45a050d 100644 --- a/librashader-runtime-vk/src/vulkan_state.rs +++ b/librashader-runtime-vk/src/vulkan_state.rs @@ -1,4 +1,3 @@ -use crate::renderpass::VulkanRenderPass; use crate::{error, util}; use ash::vk; use librashader_common::ImageFormat; @@ -24,7 +23,7 @@ impl PipelineDescriptors { pub fn add_ubo_binding(&mut self, ubo_meta: Option<&UboReflection>) { if let Some(ubo_meta) = ubo_meta && !ubo_meta.stage_mask.is_empty() { - let mut ubo_mask = util::binding_stage_to_vulkan_stage(ubo_meta.stage_mask); + let ubo_mask = util::binding_stage_to_vulkan_stage(ubo_meta.stage_mask); self.layout_bindings.push(vk::DescriptorSetLayoutBinding { binding: ubo_meta.binding, @@ -42,7 +41,7 @@ impl PipelineDescriptors { } pub fn add_texture_bindings<'a>(&mut self, textures: impl Iterator) { - let mut texture_mask = vk::ShaderStageFlags::FRAGMENT; + let texture_mask = vk::ShaderStageFlags::FRAGMENT; for texture in textures { self.layout_bindings.push(vk::DescriptorSetLayoutBinding { binding: texture.binding, @@ -102,11 +101,11 @@ impl PipelineLayoutObjects { let mut descriptor_set_layout = [descriptors.create_descriptor_set_layout(device)?]; - let mut pipeline_create_info = + let pipeline_create_info = vk::PipelineLayoutCreateInfo::builder().set_layouts(&descriptor_set_layout); let pipeline_create_info = if let Some(push_constant) = &reflection.push_constant { - let mut stage_mask = util::binding_stage_to_vulkan_stage(push_constant.stage_mask); + let stage_mask = util::binding_stage_to_vulkan_stage(push_constant.stage_mask); let push_constant_range = [vk::PushConstantRange::builder() .stage_flags(stage_mask) .size(push_constant.size) @@ -186,14 +185,8 @@ impl VulkanGraphicsPipeline { cache: &vk::PipelineCache, shader_assembly: &ShaderCompilerOutput>, reflection: &ShaderReflection, - mut format: ImageFormat, replicas: u32, ) -> error::Result { - // default to something sane - if format == ImageFormat::Unknown { - format = ImageFormat::R8G8B8A8Unorm - } - // shader_vulkan 1927 (init_pipeline_layout) let pipeline_layout = PipelineLayoutObjects::new(&reflection, replicas, device)?; @@ -299,7 +292,6 @@ impl VulkanGraphicsPipeline { .viewport_state(&viewport_state) .depth_stencil_state(&depth_stencil_state) .dynamic_state(&dynamic_state) - // .render_pass(render_pass.handle.clone()) .layout(pipeline_layout.layout) .build(); @@ -313,7 +305,6 @@ impl VulkanGraphicsPipeline { Ok(VulkanGraphicsPipeline { layout: pipeline_layout, - // render_pass, pipeline, }) }