forked from bwasty/vulkan-tutorial-rs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
12_graphics_pipeline_complete.rs.diff
82 lines (72 loc) · 2.89 KB
/
12_graphics_pipeline_complete.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--- a/11_render_passes.rs
+++ b/12_graphics_pipeline_complete.rs
@@ -41,7 +41,9 @@ use vulkano::pipeline::{
};
use vulkano::framebuffer::{
RenderPassAbstract,
+ Subpass,
};
+use vulkano::descriptor::PipelineLayoutAbstract;
const WIDTH: u32 = 800;
const HEIGHT: u32 = 600;
@@ -77,6 +79,8 @@ impl QueueFamilyIndices {
}
}
+type ConcreteGraphicsPipeline = GraphicsPipeline<BufferlessDefinition, Box<PipelineLayoutAbstract + Send + Sync + 'static>, Arc<RenderPassAbstract + Send + Sync + 'static>>;
+
#[allow(unused)]
struct HelloTriangleApplication {
instance: Arc<Instance>,
@@ -95,6 +99,11 @@ struct HelloTriangleApplication {
swap_chain_images: Vec<Arc<SwapchainImage<Window>>>,
render_pass: Arc<RenderPassAbstract + Send + Sync>,
+ // NOTE: We need to the full type of
+ // self.graphics_pipeline, because `BufferlessVertices` only
+ // works when the concrete type of the graphics pipeline is visible
+ // to the command buffer.
+ graphics_pipeline: Arc<ConcreteGraphicsPipeline>,
}
impl HelloTriangleApplication {
@@ -111,7 +120,7 @@ impl HelloTriangleApplication {
&device, &graphics_queue, &present_queue);
let render_pass = Self::create_render_pass(&device, swap_chain.format());
- Self::create_graphics_pipeline(&device, swap_chain.dimensions(), &render_pass);
+ let graphics_pipeline = Self::create_graphics_pipeline(&device, swap_chain.dimensions(), &render_pass);
Self {
instance,
@@ -130,6 +139,7 @@ impl HelloTriangleApplication {
swap_chain_images,
render_pass,
+ graphics_pipeline,
}
}
@@ -327,8 +337,8 @@ impl HelloTriangleApplication {
fn create_graphics_pipeline(
device: &Arc<Device>,
swap_chain_extent: [u32; 2],
- _render_pass: &Arc<RenderPassAbstract + Send + Sync>,
- ) {
+ render_pass: &Arc<RenderPassAbstract + Send + Sync>,
+ ) -> Arc<ConcreteGraphicsPipeline> {
#[allow(unused)]
mod vertex_shader {
#[derive(VulkanoShader)]
@@ -357,7 +367,7 @@ impl HelloTriangleApplication {
depth_range: 0.0 .. 1.0,
};
- let _pipeline_builder = Arc::new(GraphicsPipeline::start()
+ Arc::new(GraphicsPipeline::start()
.vertex_input(BufferlessDefinition {})
.vertex_shader(vert_shader_module.main_entry_point(), ())
.triangle_list()
@@ -372,7 +382,10 @@ impl HelloTriangleApplication {
.front_face_clockwise()
// NOTE: no depth_bias here, but on pipeline::raster::Rasterization
.blend_pass_through() // = default
- );
+ .render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
+ .build(device.clone())
+ .unwrap()
+ )
}
fn find_queue_families(surface: &Arc<Surface<Window>>, device: &PhysicalDevice) -> QueueFamilyIndices {