vk: remove unneeded device arcs
This commit is contained in:
parent
4ef4b8762b
commit
f61bed3a22
|
@ -49,7 +49,6 @@ static VBO_DATA: &[VertexInput; 8] = &concat_arrays!(OFFSCREEN_VBO_DATA, FINAL_V
|
||||||
|
|
||||||
pub struct DrawQuad {
|
pub struct DrawQuad {
|
||||||
buffer: VulkanBuffer,
|
buffer: VulkanBuffer,
|
||||||
device: Arc<ash::Device>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DrawQuad {
|
impl DrawQuad {
|
||||||
|
@ -69,31 +68,23 @@ impl DrawQuad {
|
||||||
slice.copy_from_slice(bytemuck::cast_slice(VBO_DATA));
|
slice.copy_from_slice(bytemuck::cast_slice(VBO_DATA));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(DrawQuad {
|
Ok(DrawQuad { buffer })
|
||||||
buffer,
|
|
||||||
device: device.clone(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind_vbo_for_frame(&self, cmd: vk::CommandBuffer) {
|
pub fn bind_vbo_for_frame(&self, device: &ash::Device, cmd: vk::CommandBuffer) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.device.cmd_bind_vertex_buffers(
|
device.cmd_bind_vertex_buffers(cmd, 0, &[self.buffer.handle], &[0 as vk::DeviceSize])
|
||||||
cmd,
|
|
||||||
0,
|
|
||||||
&[self.buffer.handle],
|
|
||||||
&[0 as vk::DeviceSize],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_quad(&self, cmd: vk::CommandBuffer, vbo: QuadType) {
|
pub fn draw_quad(&self, device: &ash::Device, cmd: vk::CommandBuffer, vbo: QuadType) {
|
||||||
let offset = match vbo {
|
let offset = match vbo {
|
||||||
QuadType::Offscreen => 0,
|
QuadType::Offscreen => 0,
|
||||||
QuadType::Final => 4,
|
QuadType::Final => 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
self.device.cmd_draw(cmd, 4, 1, offset, 0);
|
device.cmd_draw(cmd, 4, 1, offset, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,7 +459,6 @@ impl FilterChainVulkan {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(FilterPass {
|
Ok(FilterPass {
|
||||||
device: vulkan.device.clone(),
|
|
||||||
reflection,
|
reflection,
|
||||||
// compiled: spirv_words,
|
// compiled: spirv_words,
|
||||||
uniform_storage,
|
uniform_storage,
|
||||||
|
@ -670,14 +669,16 @@ impl FilterChainVulkan {
|
||||||
|
|
||||||
let options = options.unwrap_or(&self.default_options);
|
let options = options.unwrap_or(&self.default_options);
|
||||||
|
|
||||||
self.common.draw_quad.bind_vbo_for_frame(cmd);
|
self.common
|
||||||
|
.draw_quad
|
||||||
|
.bind_vbo_for_frame(&self.vulkan.device, cmd);
|
||||||
for (index, pass) in pass.iter_mut().enumerate() {
|
for (index, pass) in pass.iter_mut().enumerate() {
|
||||||
let target = &self.output_framebuffers[index];
|
let target = &self.output_framebuffers[index];
|
||||||
source.filter_mode = pass.config.filter;
|
source.filter_mode = pass.config.filter;
|
||||||
source.wrap_mode = pass.config.wrap_mode;
|
source.wrap_mode = pass.config.wrap_mode;
|
||||||
source.mip_filter = pass.config.filter;
|
source.mip_filter = pass.config.filter;
|
||||||
|
|
||||||
let output_image = OutputImage::new(&self.vulkan, target.image.clone())?;
|
let output_image = OutputImage::new(&self.vulkan.device, target.image.clone())?;
|
||||||
let out = RenderTarget::identity(&output_image);
|
let out = RenderTarget::identity(&output_image);
|
||||||
|
|
||||||
let residual_fb = pass.draw(
|
let residual_fb = pass.draw(
|
||||||
|
@ -696,7 +697,7 @@ impl FilterChainVulkan {
|
||||||
if target.max_miplevels > 1 && !self.disable_mipmaps {
|
if target.max_miplevels > 1 && !self.disable_mipmaps {
|
||||||
target.generate_mipmaps_and_end_pass(cmd);
|
target.generate_mipmaps_and_end_pass(cmd);
|
||||||
} else {
|
} else {
|
||||||
out.output.end_pass(cmd);
|
out.output.end_pass(&self.vulkan.device, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
source = self.common.output_textures[index].clone().unwrap();
|
source = self.common.output_textures[index].clone().unwrap();
|
||||||
|
@ -722,7 +723,7 @@ impl FilterChainVulkan {
|
||||||
source.wrap_mode = pass.config.wrap_mode;
|
source.wrap_mode = pass.config.wrap_mode;
|
||||||
source.mip_filter = pass.config.filter;
|
source.mip_filter = pass.config.filter;
|
||||||
|
|
||||||
let output_image = OutputImage::new(&self.vulkan, viewport.output.clone())?;
|
let output_image = OutputImage::new(&self.vulkan.device, viewport.output.clone())?;
|
||||||
let out = RenderTarget::viewport_with_output(&output_image, viewport);
|
let out = RenderTarget::viewport_with_output(&output_image, viewport);
|
||||||
|
|
||||||
let residual_fb = pass.draw(
|
let residual_fb = pass.draw(
|
||||||
|
|
|
@ -23,15 +23,12 @@ use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage, UniformStor
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct FilterPass {
|
pub struct FilterPass {
|
||||||
pub device: Arc<ash::Device>,
|
|
||||||
pub reflection: ShaderReflection,
|
pub reflection: ShaderReflection,
|
||||||
// pub(crate) compiled: ShaderCompilerOutput<Vec<u32>>,
|
|
||||||
pub(crate) uniform_storage: UniformStorage<NoUniformBinder, Option<()>, RawVulkanBuffer>,
|
pub(crate) uniform_storage: UniformStorage<NoUniformBinder, Option<()>, RawVulkanBuffer>,
|
||||||
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
|
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
|
||||||
pub source: ShaderSource,
|
pub source: ShaderSource,
|
||||||
pub config: ShaderPassConfig,
|
pub config: ShaderPassConfig,
|
||||||
pub graphics_pipeline: VulkanGraphicsPipeline,
|
pub graphics_pipeline: VulkanGraphicsPipeline,
|
||||||
// pub ubo_ring: VkUboRing,
|
|
||||||
pub frames_in_flight: u32,
|
pub frames_in_flight: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +120,7 @@ impl FilterPass {
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.output.begin_pass(cmd);
|
output.output.begin_pass(&parent.device, cmd);
|
||||||
|
|
||||||
let residual = self.graphics_pipeline.begin_rendering(output, cmd)?;
|
let residual = self.graphics_pipeline.begin_rendering(output, cmd)?;
|
||||||
|
|
||||||
|
@ -176,7 +173,7 @@ impl FilterPass {
|
||||||
parent
|
parent
|
||||||
.device
|
.device
|
||||||
.cmd_set_viewport(cmd, 0, &[output.output.size.into()]);
|
.cmd_set_viewport(cmd, 0, &[output.output.size.into()]);
|
||||||
parent.draw_quad.draw_quad(cmd, vbo_type);
|
parent.draw_quad.draw_quad(&parent.device, cmd, vbo_type);
|
||||||
self.graphics_pipeline.end_rendering(cmd);
|
self.graphics_pipeline.end_rendering(cmd);
|
||||||
}
|
}
|
||||||
Ok(residual)
|
Ok(residual)
|
||||||
|
@ -196,7 +193,7 @@ impl FilterPass {
|
||||||
source: &InputImage,
|
source: &InputImage,
|
||||||
) {
|
) {
|
||||||
Self::bind_semantics(
|
Self::bind_semantics(
|
||||||
&self.device,
|
&parent.device,
|
||||||
&parent.samplers,
|
&parent.samplers,
|
||||||
&mut self.uniform_storage,
|
&mut self.uniform_storage,
|
||||||
descriptor_set,
|
descriptor_set,
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
use crate::filter_chain::VulkanObjects;
|
|
||||||
use crate::texture::VulkanImage;
|
use crate::texture::VulkanImage;
|
||||||
use crate::{error, util};
|
use crate::{error, util};
|
||||||
use ash::vk;
|
use ash::vk;
|
||||||
use librashader_common::Size;
|
use librashader_common::Size;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct OutputImage {
|
pub(crate) struct OutputImage {
|
||||||
pub size: Size<u32>,
|
pub size: Size<u32>,
|
||||||
pub image_view: vk::ImageView,
|
pub image_view: vk::ImageView,
|
||||||
device: Arc<ash::Device>,
|
|
||||||
image: vk::Image,
|
image: vk::Image,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutputImage {
|
impl OutputImage {
|
||||||
pub fn new(vulkan: &VulkanObjects, image: VulkanImage) -> error::Result<OutputImage> {
|
pub fn new(device: &ash::Device, image: VulkanImage) -> error::Result<OutputImage> {
|
||||||
let image_subresource = vk::ImageSubresourceRange::builder()
|
let image_subresource = vk::ImageSubresourceRange::builder()
|
||||||
.base_mip_level(0)
|
.base_mip_level(0)
|
||||||
.base_array_layer(0)
|
.base_array_layer(0)
|
||||||
|
@ -35,20 +32,19 @@ impl OutputImage {
|
||||||
.subresource_range(*image_subresource)
|
.subresource_range(*image_subresource)
|
||||||
.components(*swizzle_components);
|
.components(*swizzle_components);
|
||||||
|
|
||||||
let image_view = unsafe { vulkan.device.create_image_view(&view_info, None)? };
|
let image_view = unsafe { device.create_image_view(&view_info, None)? };
|
||||||
|
|
||||||
Ok(OutputImage {
|
Ok(OutputImage {
|
||||||
device: vulkan.device.clone(),
|
|
||||||
size: image.size,
|
size: image.size,
|
||||||
image: image.image,
|
image: image.image,
|
||||||
image_view,
|
image_view,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn begin_pass(&self, cmd: vk::CommandBuffer) {
|
pub fn begin_pass(&self, device: &ash::Device, cmd: vk::CommandBuffer) {
|
||||||
unsafe {
|
unsafe {
|
||||||
util::vulkan_image_layout_transition_levels(
|
util::vulkan_image_layout_transition_levels(
|
||||||
&self.device,
|
device,
|
||||||
cmd,
|
cmd,
|
||||||
self.image,
|
self.image,
|
||||||
1,
|
1,
|
||||||
|
@ -64,10 +60,10 @@ impl OutputImage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn end_pass(&self, cmd: vk::CommandBuffer) {
|
pub fn end_pass(&self, device: &ash::Device, cmd: vk::CommandBuffer) {
|
||||||
unsafe {
|
unsafe {
|
||||||
util::vulkan_image_layout_transition_levels(
|
util::vulkan_image_layout_transition_levels(
|
||||||
&self.device,
|
&device,
|
||||||
cmd,
|
cmd,
|
||||||
self.image,
|
self.image,
|
||||||
vk::REMAINING_MIP_LEVELS,
|
vk::REMAINING_MIP_LEVELS,
|
||||||
|
|
Loading…
Reference in a new issue