Skip to content

Commit 7e41b63

Browse files
author
Matthew Russo
committed
fixes clippy warnings
1 parent 8a78019 commit 7e41b63

2 files changed

Lines changed: 60 additions & 21 deletions

File tree

src/bin/23_images.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ use vulkano::buffer::{
6565
};
6666
use vulkano::descriptor::descriptor_set::{
6767
FixedSizeDescriptorSetsPool,
68-
FixedSizeDescriptorSet
68+
FixedSizeDescriptorSet,
69+
PersistentDescriptorSetBuf
6970
};
7071

7172
use image::GenericImageView;
@@ -77,7 +78,7 @@ const VALIDATION_LAYERS: &[&str] = &[
7778
"VK_LAYER_LUNARG_standard_validation"
7879
];
7980

80-
const TEXTURE_PATH: &'static str = "src/bin/23_statue.jpg";
81+
const TEXTURE_PATH: &str = "src/bin/23_statue.jpg";
8182

8283
/// Required device extensions
8384
fn device_extensions() -> DeviceExtensions {
@@ -118,6 +119,7 @@ impl Vertex {
118119
}
119120
impl_vertex!(Vertex, pos, color);
120121

122+
#[allow(dead_code)]
121123
#[derive(Copy, Clone)]
122124
struct UniformBufferObject {
123125
model: glm::Mat4,
@@ -138,6 +140,8 @@ fn indices() -> [u16; 6] {
138140
[0, 1, 2, 2, 3, 0]
139141
}
140142

143+
type DescriptorSetResources = ((), PersistentDescriptorSetBuf<Arc<CpuAccessibleBuffer<UniformBufferObject>>>);
144+
141145
struct HelloTriangleApplication {
142146
instance: Arc<Instance>,
143147
#[allow(unused)]
@@ -160,13 +164,14 @@ struct HelloTriangleApplication {
160164

161165
swap_chain_framebuffers: Vec<Arc<FramebufferAbstract + Send + Sync>>,
162166

167+
#[allow(dead_code)]
163168
texture_image: Arc<ImmutableImage<Format>>,
164169

165170
vertex_buffer: Arc<BufferAccess + Send + Sync>,
166171
index_buffer: Arc<TypedBufferAccess<Content=[u16]> + Send + Sync>,
167172
uniform_buffers: Vec<Arc<CpuAccessibleBuffer<UniformBufferObject>>>,
168173

169-
descriptor_sets: Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>,
174+
descriptor_sets: Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, DescriptorSetResources>>>,
170175

171176
command_buffers: Vec<Arc<AutoCommandBuffer>>,
172177

@@ -268,7 +273,7 @@ impl HelloTriangleApplication {
268273
let required_extensions = Self::get_required_extensions();
269274

270275
if ENABLE_VALIDATION_LAYERS && Self::check_validation_layer_support() {
271-
Instance::new(Some(&app_info), &required_extensions, VALIDATION_LAYERS.iter().map(|s| *s))
276+
Instance::new(Some(&app_info), &required_extensions, VALIDATION_LAYERS.iter().cloned())
272277
.expect("failed to create Vulkan instance")
273278
} else {
274279
Instance::new(Some(&app_info), &required_extensions, None)
@@ -494,7 +499,7 @@ impl HelloTriangleApplication {
494499
}
495500

496501
fn create_framebuffers(
497-
swap_chain_images: &Vec<Arc<SwapchainImage<Window>>>,
502+
swap_chain_images: &[Arc<SwapchainImage<Window>>],
498503
render_pass: &Arc<RenderPassAbstract + Send + Sync>
499504
) -> Vec<Arc<FramebufferAbstract + Send + Sync>> {
500505
swap_chain_images.iter()
@@ -524,7 +529,7 @@ impl HelloTriangleApplication {
524529

525530
future.flush().unwrap();
526531

527-
return image_view;
532+
image_view
528533
}
529534

530535
fn create_vertex_buffer(graphics_queue: &Arc<Queue>) -> Arc<BufferAccess + Send + Sync> {
@@ -580,10 +585,11 @@ impl HelloTriangleApplication {
580585
)
581586
}
582587

588+
583589
fn create_descriptor_sets(
584590
pool: &Arc<Mutex<FixedSizeDescriptorSetsPool<Arc<GraphicsPipelineAbstract + Send + Sync>>>>,
585-
uniform_buffers: &Vec<Arc<CpuAccessibleBuffer<UniformBufferObject>>>,
586-
) -> Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>
591+
uniform_buffers: &[Arc<CpuAccessibleBuffer<UniformBufferObject>>],
592+
) -> Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, DescriptorSetResources>>>
587593
{
588594
uniform_buffers
589595
.iter()
@@ -705,9 +711,8 @@ impl HelloTriangleApplication {
705711

706712
let mut done = false;
707713
self.events_loop.poll_events(|ev| {
708-
match ev {
709-
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => done = true,
710-
_ => ()
714+
if let Event::WindowEvent { event: WindowEvent::CloseRequested, .. } = ev {
715+
done = true
711716
}
712717
});
713718
if done {
@@ -761,7 +766,7 @@ impl HelloTriangleApplication {
761766

762767
fn update_uniform_buffer(start_time: Instant, dimensions: [f32; 2]) -> UniformBufferObject {
763768
let duration = Instant::now().duration_since(start_time);
764-
let elapsed = (duration.as_secs() * 1000) + duration.subsec_millis() as u64;
769+
let elapsed = (duration.as_secs() * 1000) + u64::from(duration.subsec_millis());
765770

766771
let identity_matrix = glm::mat4(
767772
1.0, 0.0, 0.0, 0.0,

src/bin/23_images.rs.diff

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,55 @@
2222
use vulkano::sync::{self, SharingMode, GpuFuture};
2323
use vulkano::pipeline::{
2424
GraphicsPipeline,
25-
@@ -62,6 +68,8 @@ use vulkano::descriptor::descriptor_set::{
26-
FixedSizeDescriptorSet
25+
@@ -59,9 +65,12 @@ use vulkano::buffer::{
26+
};
27+
use vulkano::descriptor::descriptor_set::{
28+
FixedSizeDescriptorSetsPool,
29+
- FixedSizeDescriptorSet
30+
+ FixedSizeDescriptorSet,
31+
+ PersistentDescriptorSetBuf
2732
};
2833

2934
+use image::GenericImageView;
3035
+
3136
const WIDTH: u32 = 800;
3237
const HEIGHT: u32 = 600;
3338

34-
@@ -69,6 +77,8 @@ const VALIDATION_LAYERS: &[&str] = &[
39+
@@ -69,6 +78,8 @@ const VALIDATION_LAYERS: &[&str] = &[
3540
"VK_LAYER_LUNARG_standard_validation"
3641
];
3742

38-
+const TEXTURE_PATH: &'static str = "src/bin/23_statue.jpg";
43+
+const TEXTURE_PATH: &str = "src/bin/23_statue.jpg";
3944
+
4045
/// Required device extensions
4146
fn device_extensions() -> DeviceExtensions {
4247
DeviceExtensions {
43-
@@ -150,6 +160,8 @@ struct HelloTriangleApplication {
48+
@@ -129,6 +140,8 @@ fn indices() -> [u16; 6] {
49+
[0, 1, 2, 2, 3, 0]
50+
}
51+
52+
+type DescriptorSetResources = ((), PersistentDescriptorSetBuf<Arc<CpuAccessibleBuffer<UniformBufferObject>>>);
53+
+
54+
struct HelloTriangleApplication {
55+
instance: Arc<Instance>,
56+
#[allow(unused)]
57+
@@ -151,11 +164,14 @@ struct HelloTriangleApplication {
4458

4559
swap_chain_framebuffers: Vec<Arc<FramebufferAbstract + Send + Sync>>,
4660

61+
+ #[allow(dead_code)]
4762
+ texture_image: Arc<ImmutableImage<Format>>,
4863
+
4964
vertex_buffer: Arc<BufferAccess + Send + Sync>,
5065
index_buffer: Arc<TypedBufferAccess<Content=[u16]> + Send + Sync>,
5166
uniform_buffers: Vec<Arc<CpuAccessibleBuffer<UniformBufferObject>>>,
52-
@@ -185,6 +197,8 @@ impl HelloTriangleApplication {
67+
68+
- descriptor_sets: Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>,
69+
+ descriptor_sets: Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, DescriptorSetResources>>>,
70+
71+
command_buffers: Vec<Arc<AutoCommandBuffer>>,
72+
73+
@@ -186,6 +202,8 @@ impl HelloTriangleApplication {
5374

5475
let start_time = Instant::now();
5576

@@ -58,7 +79,7 @@
5879
let vertex_buffer = Self::create_vertex_buffer(&graphics_queue);
5980
let index_buffer = Self::create_index_buffer(&graphics_queue);
6081
let uniform_buffers = Self::create_uniform_buffers(&device, swap_chain_images.len(), start_time, swap_chain.dimensions());
61-
@@ -215,6 +229,8 @@ impl HelloTriangleApplication {
82+
@@ -216,6 +234,8 @@ impl HelloTriangleApplication {
6283

6384
swap_chain_framebuffers,
6485

@@ -67,7 +88,7 @@
6788
vertex_buffer,
6889
index_buffer,
6990
uniform_buffers,
70-
@@ -491,6 +507,26 @@ impl HelloTriangleApplication {
91+
@@ -492,6 +512,26 @@ impl HelloTriangleApplication {
7192
).collect::<Vec<_>>()
7293
}
7394

@@ -88,9 +109,22 @@
88109
+
89110
+ future.flush().unwrap();
90111
+
91-
+ return image_view;
112+
+ image_view
92113
+ }
93114
+
94115
fn create_vertex_buffer(graphics_queue: &Arc<Queue>) -> Arc<BufferAccess + Send + Sync> {
95116
let (buffer, future) = ImmutableBuffer::from_iter(
96117
vertices().iter().cloned(), BufferUsage::vertex_buffer(),
118+
@@ -545,10 +585,11 @@ impl HelloTriangleApplication {
119+
)
120+
}
121+
122+
+
123+
fn create_descriptor_sets(
124+
pool: &Arc<Mutex<FixedSizeDescriptorSetsPool<Arc<GraphicsPipelineAbstract + Send + Sync>>>>,
125+
uniform_buffers: &[Arc<CpuAccessibleBuffer<UniformBufferObject>>],
126+
- ) -> Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>
127+
+ ) -> Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, DescriptorSetResources>>>
128+
{
129+
uniform_buffers
130+
.iter()

0 commit comments

Comments
 (0)