-
Notifications
You must be signed in to change notification settings - Fork 47
/
11_render_passes.rs.diff
67 lines (59 loc) · 1.87 KB
/
11_render_passes.rs.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- a/10_fixed_functions.rs
+++ b/11_render_passes.rs
@@ -1,3 +1,4 @@
+#[macro_use]
extern crate vulkano;
extern crate vulkano_win;
extern crate winit;
@@ -35,6 +36,9 @@ use vulkano::pipeline::{
vertex::BufferlessDefinition,
viewport::Viewport,
};
+use vulkano::framebuffer::{
+ RenderPassAbstract,
+};
const WIDTH: u32 = 800;
const HEIGHT: u32 = 600;
@@ -86,6 +90,8 @@ struct HelloTriangleApplication {
swap_chain: Arc<Swapchain<Window>>,
swap_chain_images: Vec<Arc<SwapchainImage<Window>>>,
+
+ render_pass: Arc<RenderPassAbstract + Send + Sync>,
}
impl HelloTriangleApplication {
@@ -101,6 +107,7 @@ impl HelloTriangleApplication {
let (swap_chain, swap_chain_images) = Self::create_swap_chain(&instance, &surface, physical_device_index,
&device, &graphics_queue, &present_queue);
+ let render_pass = Self::create_render_pass(&device, swap_chain.format());
Self::create_graphics_pipeline(&device, swap_chain.dimensions());
Self {
@@ -118,6 +125,8 @@ impl HelloTriangleApplication {
swap_chain,
swap_chain_images,
+
+ render_pass,
}
}
@@ -295,6 +304,23 @@ impl HelloTriangleApplication {
(swap_chain, images)
}
+ fn create_render_pass(device: &Arc<Device>, color_format: Format) -> Arc<RenderPassAbstract + Send + Sync> {
+ Arc::new(single_pass_renderpass!(device.clone(),
+ attachments: {
+ color: {
+ load: Clear,
+ store: Store,
+ format: color_format,
+ samples: 1,
+ }
+ },
+ pass: {
+ color: [color],
+ depth_stencil: {}
+ }
+ ).unwrap())
+ }
+
fn create_graphics_pipeline(
device: &Arc<Device>,
swap_chain_extent: [u32; 2],