Live toggle msaa
This commit is contained in:
64
src/vulkan/renderpass.rs
Normal file
64
src/vulkan/renderpass.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
use crate::RenderConfig;
|
||||
use std::sync::Arc;
|
||||
use vulkano::framebuffer::RenderPassAbstract;
|
||||
use vulkano::format::Format;
|
||||
use vulkano::device::Device;
|
||||
|
||||
pub fn create_render_pass(device: Arc<Device>, render_config: &RenderConfig, swapchain_format: Format) -> Arc<dyn RenderPassAbstract + Send + Sync> {
|
||||
if render_config.msaa_samples > 0 {
|
||||
Arc::new(vulkano::single_pass_renderpass!(
|
||||
device.clone(),
|
||||
attachments: {
|
||||
color: {
|
||||
load: DontCare,
|
||||
store: Store,
|
||||
format: swapchain_format,
|
||||
samples: 1,
|
||||
},
|
||||
intermediary: {
|
||||
load: Clear,
|
||||
store: DontCare,
|
||||
format: swapchain_format,
|
||||
samples: render_config.msaa_samples,
|
||||
},
|
||||
depth: {
|
||||
load: Clear,
|
||||
store: Store,
|
||||
format: Format::D16Unorm,
|
||||
samples: render_config.msaa_samples,
|
||||
initial_layout: ImageLayout::Undefined,
|
||||
final_layout: ImageLayout::DepthStencilAttachmentOptimal,
|
||||
}
|
||||
},
|
||||
pass: {
|
||||
color: [intermediary],
|
||||
depth_stencil: {depth},
|
||||
resolve: [color]
|
||||
}
|
||||
).unwrap())
|
||||
} else {
|
||||
Arc::new(vulkano::single_pass_renderpass!(
|
||||
device.clone(),
|
||||
attachments: {
|
||||
color: {
|
||||
load: Clear,
|
||||
store: Store,
|
||||
format: swapchain_format,
|
||||
samples: 1,
|
||||
},
|
||||
depth: {
|
||||
load: Clear,
|
||||
store: Store,
|
||||
format: Format::D16Unorm,
|
||||
samples: 1,
|
||||
initial_layout: ImageLayout::Undefined,
|
||||
final_layout: ImageLayout::DepthStencilAttachmentOptimal,
|
||||
}
|
||||
},
|
||||
pass: {
|
||||
color: [color],
|
||||
depth_stencil: {depth}
|
||||
}
|
||||
).unwrap())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user