Skip to content

Commit 29ff121

Browse files
author
Matthew Russo
committed
updates diffs from clippy fixes
1 parent 6f5d40a commit 29ff121

8 files changed

+49
-63
lines changed

src/bin/01_instance_creation.rs.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
fn main_loop(&mut self) {
7070
loop {
7171
let mut done = false;
72-
@@ -46,6 +77,6 @@ impl HelloTriangleApplication {
72+
@@ -45,6 +76,6 @@ impl HelloTriangleApplication {
7373
}
7474

7575
fn main() {

src/bin/02_validation_layers.rs.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
+ let required_extensions = Self::get_required_extensions();
6464
+
6565
+ if ENABLE_VALIDATION_LAYERS && Self::check_validation_layer_support() {
66-
+ Instance::new(Some(&app_info), &required_extensions, VALIDATION_LAYERS.iter().map(|s| *s))
66+
+ Instance::new(Some(&app_info), &required_extensions, VALIDATION_LAYERS.iter().cloned())
6767
+ .expect("failed to create Vulkan instance")
6868
+ } else {
6969
+ Instance::new(Some(&app_info), &required_extensions, None)

src/bin/09_shader_modules.rs.diff

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/bin/10_fixed_functions.rs.diff

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--- a/./09_shader_modules.rs
1+
--- a/08_graphics_pipeline.rs
22
+++ b/10_fixed_functions.rs
33
@@ -30,6 +30,11 @@ use vulkano::swapchain::{
44
use vulkano::format::Format;
@@ -21,32 +21,41 @@
2121

2222
Self {
2323
instance,
24-
@@ -292,6 +297,7 @@ impl HelloTriangleApplication {
24+
@@ -290,8 +295,52 @@ impl HelloTriangleApplication {
25+
(swap_chain, images)
26+
}
2527

26-
fn create_graphics_pipeline(
27-
device: &Arc<Device>,
28+
- fn create_graphics_pipeline(_device: &Arc<Device>) {
29+
+ fn create_graphics_pipeline(
30+
+ device: &Arc<Device>,
2831
+ swap_chain_extent: [u32; 2],
29-
) {
30-
mod vertex_shader {
31-
vulkano_shaders::shader! {
32-
@@ -307,10 +313,34 @@ impl HelloTriangleApplication {
33-
}
34-
}
35-
36-
- let _vert_shader_module = vertex_shader::Shader::load(device.clone())
32+
+ ) {
33+
+ mod vertex_shader {
34+
+ vulkano_shaders::shader! {
35+
+ ty: "vertex",
36+
+ path: "src/bin/09_shader_base.vert"
37+
+ }
38+
+ }
39+
+
40+
+ mod fragment_shader {
41+
+ vulkano_shaders::shader! {
42+
+ ty: "fragment",
43+
+ path: "src/bin/09_shader_base.frag"
44+
+ }
45+
+ }
46+
+
3747
+ let vert_shader_module = vertex_shader::Shader::load(device.clone())
38-
.expect("failed to create vertex shader module!");
39-
- let _frag_shader_module = fragment_shader::Shader::load(device.clone())
48+
+ .expect("failed to create vertex shader module!");
4049
+ let frag_shader_module = fragment_shader::Shader::load(device.clone())
41-
.expect("failed to create fragment shader module!");
50+
+ .expect("failed to create fragment shader module!");
4251
+
4352
+ let dimensions = [swap_chain_extent[0] as f32, swap_chain_extent[1] as f32];
4453
+ let viewport = Viewport {
4554
+ origin: [0.0, 0.0],
4655
+ dimensions,
4756
+ depth_range: 0.0 .. 1.0,
4857
+ };
49-
+
58+
5059
+ let _pipeline_builder = Arc::new(GraphicsPipeline::start()
5160
+ .vertex_input(BufferlessDefinition {})
5261
+ .vertex_shader(vert_shader_module.main_entry_point(), ())

src/bin/13_framebuffers.rs.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
}
4242

4343
+ fn create_framebuffers(
44-
+ swap_chain_images: &Vec<Arc<SwapchainImage<Window>>>,
44+
+ swap_chain_images: &[Arc<SwapchainImage<Window>>],
4545
+ render_pass: &Arc<RenderPassAbstract + Send + Sync>
4646
+ ) -> Vec<Arc<FramebufferAbstract + Send + Sync>> {
4747
+ swap_chain_images.iter()

src/bin/15_hello_triangle.rs.diff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
+
2222
let mut done = false;
2323
self.events_loop.poll_events(|ev| {
24-
match ev {
25-
@@ -514,9 +517,24 @@ impl HelloTriangleApplication {
24+
if let Event::WindowEvent { event: WindowEvent::CloseRequested, .. } = ev {
25+
@@ -513,9 +516,24 @@ impl HelloTriangleApplication {
2626
}
2727
}
2828
}

src/bin/16_swap_chain_recreation.rs.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
fn find_queue_families(surface: &Arc<Surface<Window>>, device: &PhysicalDevice) -> QueueFamilyIndices {
9090
let mut indices = QueueFamilyIndices::new();
9191
// TODO: replace index with id to simplify?
92-
@@ -519,18 +533,59 @@ impl HelloTriangleApplication {
92+
@@ -518,18 +532,59 @@ impl HelloTriangleApplication {
9393
}
9494

9595
fn draw_frame(&mut self) {

src/bin/21_descriptor_layout_and_buffer.rs.diff

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
};
1717

1818
const WIDTH: u32 = 800;
19-
@@ -102,6 +104,13 @@ impl Vertex {
19+
@@ -100,8 +102,18 @@ impl Vertex {
20+
Self { pos, color }
21+
}
2022
}
23+
+
24+
+#[allow(clippy:ref_in_deref)]
2125
impl_vertex!(Vertex, pos, color);
2226

27+
+#[allow(dead_code)]
2328
+#[derive(Copy, Clone)]
2429
+struct UniformBufferObject {
2530
+ model: glm::Mat4,
@@ -30,22 +35,25 @@
3035
fn vertices() -> [Vertex; 4] {
3136
[
3237
Vertex::new([-0.5, -0.5], [1.0, 0.0, 0.0]),
33-
@@ -139,10 +148,14 @@ struct HelloTriangleApplication {
38+
@@ -139,10 +151,17 @@ struct HelloTriangleApplication {
3439

3540
vertex_buffer: Arc<BufferAccess + Send + Sync>,
3641
index_buffer: Arc<TypedBufferAccess<Content=[u16]> + Send + Sync>,
42+
+
43+
+ #[allow(dead_code)]
3744
+ uniform_buffers: Vec<Arc<CpuAccessibleBuffer<UniformBufferObject>>>,
3845
+
3946
command_buffers: Vec<Arc<AutoCommandBuffer>>,
4047

4148
previous_frame_end: Option<Box<GpuFuture>>,
4249
recreate_swap_chain: bool,
4350
+
51+
+ #[allow(dead_code)]
4452
+ start_time: Instant,
4553
}
4654

4755
impl HelloTriangleApplication {
48-
@@ -159,12 +172,16 @@ impl HelloTriangleApplication {
56+
@@ -159,12 +178,16 @@ impl HelloTriangleApplication {
4957
&device, &graphics_queue, &present_queue, None);
5058

5159
let render_pass = Self::create_render_pass(&device, swap_chain.format());
@@ -62,7 +70,7 @@
6270

6371
let previous_frame_end = Some(Self::create_sync_objects(&device));
6472

65-
@@ -191,10 +208,14 @@ impl HelloTriangleApplication {
73+
@@ -191,10 +214,14 @@ impl HelloTriangleApplication {
6674

6775
vertex_buffer,
6876
index_buffer,
@@ -77,7 +85,7 @@
7785
};
7886

7987
app.create_command_buffers();
80-
@@ -401,14 +422,14 @@ impl HelloTriangleApplication {
88+
@@ -401,14 +428,14 @@ impl HelloTriangleApplication {
8189
mod vertex_shader {
8290
vulkano_shaders::shader! {
8391
ty: "vertex",
@@ -94,7 +102,7 @@
94102
}
95103
}
96104

97-
@@ -477,6 +498,31 @@ impl HelloTriangleApplication {
105+
@@ -477,6 +504,31 @@ impl HelloTriangleApplication {
98106
buffer
99107
}
100108

@@ -126,7 +134,7 @@
126134
fn create_command_buffers(&mut self) {
127135
let queue_family = self.graphics_queue.family();
128136
self.command_buffers = self.swap_chain_framebuffers.iter()
129-
@@ -485,9 +531,13 @@ impl HelloTriangleApplication {
137+
@@ -485,9 +537,13 @@ impl HelloTriangleApplication {
130138
.unwrap()
131139
.begin_render_pass(framebuffer.clone(), false, vec![[0.0, 0.0, 0.0, 1.0].into()])
132140
.unwrap()
@@ -142,13 +150,13 @@
142150
.unwrap()
143151
.end_render_pass()
144152
.unwrap()
145-
@@ -623,6 +673,36 @@ impl HelloTriangleApplication {
153+
@@ -622,6 +678,36 @@ impl HelloTriangleApplication {
146154
}
147155
}
148156

149157
+ fn update_uniform_buffer(start_time: Instant, dimensions: [f32; 2]) -> UniformBufferObject {
150158
+ let duration = Instant::now().duration_since(start_time);
151-
+ let elapsed = (duration.as_secs() * 1000) + duration.subsec_millis() as u64;
159+
+ let elapsed = (duration.as_secs() * 1000) + u64::from(duration.subsec_millis());
152160
+
153161
+ let identity_matrix = glm::mat4(
154162
+ 1.0, 0.0, 0.0, 0.0,
@@ -179,7 +187,7 @@
179187
fn recreate_swap_chain(&mut self) {
180188
let (swap_chain, images) = Self::create_swap_chain(&self.instance, &self.surface, self.physical_device_index,
181189
&self.device, &self.graphics_queue, &self.present_queue, Some(self.swap_chain.clone()));
182-
@@ -640,4 +720,4 @@ impl HelloTriangleApplication {
190+
@@ -639,4 +725,4 @@ impl HelloTriangleApplication {
183191
fn main() {
184192
let mut app = HelloTriangleApplication::initialize();
185193
app.main_loop();

0 commit comments

Comments
 (0)