Skip to content

Commit

Permalink
fixes clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Russo committed Feb 10, 2019
1 parent 272864c commit 127e6fd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/bin/22_descriptor_pools_and_sets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl Vertex {
}
impl_vertex!(Vertex, pos, color);

#[allow(dead_code)]
#[derive(Copy, Clone)]
struct UniformBufferObject {
model: glm::Mat4,
Expand Down Expand Up @@ -252,7 +253,7 @@ impl HelloTriangleApplication {
let required_extensions = Self::get_required_extensions();

if ENABLE_VALIDATION_LAYERS && Self::check_validation_layer_support() {
Instance::new(Some(&app_info), &required_extensions, VALIDATION_LAYERS.iter().map(|s| *s))
Instance::new(Some(&app_info), &required_extensions, VALIDATION_LAYERS.iter().cloned())
.expect("failed to create Vulkan instance")
} else {
Instance::new(Some(&app_info), &required_extensions, None)
Expand Down Expand Up @@ -478,7 +479,7 @@ impl HelloTriangleApplication {
}

fn create_framebuffers(
swap_chain_images: &Vec<Arc<SwapchainImage<Window>>>,
swap_chain_images: &[Arc<SwapchainImage<Window>>],
render_pass: &Arc<RenderPassAbstract + Send + Sync>
) -> Vec<Arc<FramebufferAbstract + Send + Sync>> {
swap_chain_images.iter()
Expand Down Expand Up @@ -546,7 +547,7 @@ impl HelloTriangleApplication {

fn create_descriptor_sets(
pool: &Arc<Mutex<FixedSizeDescriptorSetsPool<Arc<GraphicsPipelineAbstract + Send + Sync>>>>,
uniform_buffers: &Vec<Arc<CpuAccessibleBuffer<UniformBufferObject>>>,
uniform_buffers: &[Arc<CpuAccessibleBuffer<UniformBufferObject>>],
) -> Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>
{
uniform_buffers
Expand Down Expand Up @@ -669,9 +670,8 @@ impl HelloTriangleApplication {

let mut done = false;
self.events_loop.poll_events(|ev| {
match ev {
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => done = true,
_ => ()
if let Event::WindowEvent { event: WindowEvent::CloseRequested, .. } = ev {
done = true
}
});
if done {
Expand Down Expand Up @@ -725,7 +725,7 @@ impl HelloTriangleApplication {

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

let identity_matrix = glm::mat4(
1.0, 0.0, 0.0, 0.0,
Expand Down
35 changes: 27 additions & 8 deletions src/bin/22_descriptor_pools_and_sets.rs.diff
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,35 @@
};

const WIDTH: u32 = 800;
@@ -150,6 +154,8 @@ struct HelloTriangleApplication {
@@ -102,8 +106,6 @@ impl Vertex {
Self { pos, color }
}
}
-
-#[allow(clippy:ref_in_deref)]
impl_vertex!(Vertex, pos, color);

#[allow(dead_code)]
@@ -151,16 +153,15 @@ struct HelloTriangleApplication {

vertex_buffer: Arc<BufferAccess + Send + Sync>,
index_buffer: Arc<TypedBufferAccess<Content=[u16]> + Send + Sync>,
-
- #[allow(dead_code)]
uniform_buffers: Vec<Arc<CpuAccessibleBuffer<UniformBufferObject>>>,

+ descriptor_sets: Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>,
+
command_buffers: Vec<Arc<AutoCommandBuffer>>,

previous_frame_end: Option<Box<GpuFuture>>,
@@ -183,6 +189,9 @@ impl HelloTriangleApplication {
recreate_swap_chain: bool,

- #[allow(dead_code)]
start_time: Instant,
}

@@ -189,6 +190,9 @@ impl HelloTriangleApplication {
let index_buffer = Self::create_index_buffer(&graphics_queue);
let uniform_buffers = Self::create_uniform_buffers(&device, swap_chain_images.len(), start_time, swap_chain.dimensions());

Expand All @@ -41,7 +60,7 @@
let previous_frame_end = Some(Self::create_sync_objects(&device));

let mut app = Self {
@@ -210,6 +219,8 @@ impl HelloTriangleApplication {
@@ -216,6 +220,8 @@ impl HelloTriangleApplication {
index_buffer,
uniform_buffers,

Expand All @@ -50,7 +69,7 @@
command_buffers: vec![],

previous_frame_end,
@@ -457,7 +468,7 @@ impl HelloTriangleApplication {
@@ -463,7 +469,7 @@ impl HelloTriangleApplication {
.polygon_mode_fill() // = default
.line_width(1.0) // = default
.cull_mode_back()
Expand All @@ -59,7 +78,7 @@
// NOTE: no depth_bias here, but on pipeline::raster::Rasterization
.blend_pass_through() // = default
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
@@ -523,12 +534,50 @@ impl HelloTriangleApplication {
@@ -529,12 +535,50 @@ impl HelloTriangleApplication {
buffers
}

Expand All @@ -75,7 +94,7 @@
+
+ fn create_descriptor_sets(
+ pool: &Arc<Mutex<FixedSizeDescriptorSetsPool<Arc<GraphicsPipelineAbstract + Send + Sync>>>>,
+ uniform_buffers: &Vec<Arc<CpuAccessibleBuffer<UniformBufferObject>>>,
+ uniform_buffers: &[Arc<CpuAccessibleBuffer<UniformBufferObject>>],
+ ) -> Vec<Arc<FixedSizeDescriptorSet<Arc<GraphicsPipelineAbstract + Send + Sync>, ((), vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::CpuAccessibleBuffer<UniformBufferObject>>>)>>>
+ {
+ uniform_buffers
Expand Down Expand Up @@ -112,7 +131,7 @@
.begin_render_pass(framebuffer.clone(), false, vec![[0.0, 0.0, 0.0, 1.0].into()])
.unwrap()
.draw_indexed(
@@ -536,7 +585,7 @@ impl HelloTriangleApplication {
@@ -542,7 +586,7 @@ impl HelloTriangleApplication {
&DynamicState::none(),
vec![self.vertex_buffer.clone()],
self.index_buffer.clone(),
Expand All @@ -121,7 +140,7 @@
())
.unwrap()
.end_render_pass()
@@ -615,6 +664,7 @@ impl HelloTriangleApplication {
@@ -621,6 +665,7 @@ impl HelloTriangleApplication {
#[allow(unused)]
fn main_loop(&mut self) {
loop {
Expand Down

0 comments on commit 127e6fd

Please sign in to comment.