From f0e6e4c6b7da8956cb618627833b1e99381ea4b0 Mon Sep 17 00:00:00 2001 From: Rua Date: Fri, 12 Aug 2022 12:18:35 +0200 Subject: [PATCH] Fix or allow all Clippy errors, re-enable dead code and unused variable warnings (#1953) --- examples/src/bin/basic-compute-shader.rs | 8 +- examples/src/bin/debug.rs | 18 +- .../deferred/frame/ambient_lighting_system.rs | 2 +- .../frame/directional_lighting_system.rs | 2 +- .../deferred/frame/point_lighting_system.rs | 3 +- examples/src/bin/deferred/main.rs | 4 +- examples/src/bin/dynamic-buffers.rs | 24 +- examples/src/bin/dynamic-local-size.rs | 21 +- examples/src/bin/gl-interop.rs | 5 +- examples/src/bin/image-self-copy-blit/main.rs | 6 +- examples/src/bin/image/main.rs | 6 +- examples/src/bin/immutable-sampler/main.rs | 8 +- examples/src/bin/indirect.rs | 6 +- examples/src/bin/interactive_fractal/app.rs | 7 +- .../fractal_compute_pipeline.rs | 2 +- examples/src/bin/interactive_fractal/main.rs | 2 +- examples/src/bin/msaa-renderpass.rs | 21 +- examples/src/bin/multi-window.rs | 2 +- .../src/bin/multi_window_game_of_life/main.rs | 2 +- examples/src/bin/multiview.rs | 10 +- examples/src/bin/pipeline-caching.rs | 8 +- examples/src/bin/push-constants.rs | 10 +- examples/src/bin/runtime_array/main.rs | 6 +- examples/src/bin/self-copy-buffer.rs | 6 +- examples/src/bin/shader-include/main.rs | 8 +- examples/src/bin/shader-types-sharing.rs | 10 +- examples/src/bin/simple-particles.rs | 8 +- examples/src/bin/specialization-constants.rs | 10 +- examples/src/bin/teapot/main.rs | 6 +- examples/src/bin/texture_array/main.rs | 6 +- examples/src/lib.rs | 6 +- vulkano-shaders/src/codegen.rs | 10 +- vulkano-shaders/src/entry_point.rs | 31 +-- vulkano-shaders/src/lib.rs | 24 +- vulkano-shaders/src/structs.rs | 74 +++--- vulkano-util/src/context.rs | 21 +- vulkano-util/src/lib.rs | 2 + vulkano-util/src/renderer.rs | 2 +- vulkano-util/src/window.rs | 10 +- vulkano-win/src/lib.rs | 1 + vulkano/autogen/extensions.rs | 76 ++---- vulkano/autogen/features.rs | 37 ++- vulkano/autogen/fns.rs | 2 +- vulkano/autogen/formats.rs | 10 +- vulkano/autogen/mod.rs | 36 ++- vulkano/autogen/properties.rs | 28 +-- vulkano/autogen/spirv_parse.rs | 27 +-- vulkano/src/buffer/cpu_access.rs | 20 +- vulkano/src/buffer/cpu_pool.rs | 8 +- vulkano/src/buffer/device_local.rs | 17 +- vulkano/src/buffer/slice.rs | 2 +- vulkano/src/buffer/sys.rs | 2 +- vulkano/src/buffer/view.rs | 44 ++-- vulkano/src/command_buffer/auto.rs | 50 ++-- .../src/command_buffer/commands/bind_push.rs | 9 +- vulkano/src/command_buffer/commands/debug.rs | 4 +- .../command_buffer/commands/dynamic_state.rs | 69 +++--- vulkano/src/command_buffer/commands/image.rs | 20 +- .../src/command_buffer/commands/pipeline.rs | 23 +- vulkano/src/command_buffer/commands/query.rs | 14 +- .../command_buffer/commands/render_pass.rs | 139 +++++------ .../src/command_buffer/commands/secondary.rs | 9 +- .../src/command_buffer/commands/transfer.rs | 66 ++--- vulkano/src/command_buffer/pool/standard.rs | 2 +- vulkano/src/command_buffer/pool/sys.rs | 32 +-- vulkano/src/command_buffer/submit/mod.rs | 5 +- .../src/command_buffer/submit/queue_submit.rs | 10 +- .../command_buffer/submit/semaphores_wait.rs | 12 +- vulkano/src/command_buffer/synced/builder.rs | 14 +- vulkano/src/command_buffer/synced/mod.rs | 16 +- vulkano/src/command_buffer/sys.rs | 2 +- vulkano/src/command_buffer/traits.rs | 4 +- vulkano/src/descriptor_set/collection.rs | 11 +- vulkano/src/descriptor_set/layout.rs | 28 +-- vulkano/src/descriptor_set/mod.rs | 23 +- vulkano/src/descriptor_set/pool/sys.rs | 6 +- .../src/descriptor_set/single_layout_pool.rs | 11 +- vulkano/src/descriptor_set/update.rs | 23 +- vulkano/src/device/extensions.rs | 2 +- vulkano/src/device/mod.rs | 14 +- vulkano/src/device/physical.rs | 19 +- vulkano/src/format.rs | 5 +- vulkano/src/image/attachment.rs | 12 +- vulkano/src/image/immutable.rs | 13 +- vulkano/src/image/mod.rs | 4 +- vulkano/src/image/storage.rs | 20 +- vulkano/src/image/swapchain.rs | 4 +- vulkano/src/image/sys.rs | 51 ++-- vulkano/src/image/view.rs | 19 +- vulkano/src/instance/debug.rs | 8 +- vulkano/src/instance/extensions.rs | 2 +- vulkano/src/instance/layers.rs | 4 +- vulkano/src/instance/mod.rs | 8 +- vulkano/src/lib.rs | 20 +- vulkano/src/library.rs | 6 +- vulkano/src/memory/device_memory.rs | 32 +-- vulkano/src/memory/pool/host_visible.rs | 2 +- vulkano/src/memory/pool/mod.rs | 5 +- vulkano/src/memory/pool/non_host_visible.rs | 2 +- vulkano/src/memory/pool/pool.rs | 18 +- vulkano/src/pipeline/cache.rs | 103 ++++---- vulkano/src/pipeline/compute.rs | 4 +- vulkano/src/pipeline/graphics/builder.rs | 229 +++++++++--------- vulkano/src/pipeline/graphics/mod.rs | 2 +- vulkano/src/pipeline/graphics/render_pass.rs | 7 - .../graphics/vertex_input/collection.rs | 21 +- .../graphics/vertex_input/definition.rs | 2 +- vulkano/src/pipeline/layout.rs | 2 +- vulkano/src/query.rs | 8 +- vulkano/src/range_map.rs | 6 +- vulkano/src/render_pass/create.rs | 46 ++-- vulkano/src/render_pass/framebuffer.rs | 14 +- vulkano/src/render_pass/macros.rs | 2 +- vulkano/src/render_pass/mod.rs | 7 +- vulkano/src/sampler/mod.rs | 40 ++- vulkano/src/sampler/ycbcr.rs | 4 +- vulkano/src/shader/mod.rs | 4 +- vulkano/src/shader/reflect.rs | 73 +++--- vulkano/src/shader/spirv.rs | 6 +- vulkano/src/swapchain/display.rs | 9 +- vulkano/src/swapchain/swapchain.rs | 40 +-- vulkano/src/sync/event.rs | 4 +- vulkano/src/sync/fence.rs | 14 +- vulkano/src/sync/future/fence_signal.rs | 9 +- vulkano/src/sync/future/join.rs | 39 ++- vulkano/src/sync/future/mod.rs | 2 +- vulkano/src/sync/future/now.rs | 18 +- vulkano/src/sync/future/semaphore_signal.rs | 2 +- vulkano/src/sync/mod.rs | 2 +- vulkano/src/sync/pipeline.rs | 6 +- vulkano/src/sync/semaphore.rs | 6 +- 131 files changed, 1051 insertions(+), 1279 deletions(-) diff --git a/examples/src/bin/basic-compute-shader.rs b/examples/src/bin/basic-compute-shader.rs index 5c496241..395fbc72 100644 --- a/examples/src/bin/basic-compute-shader.rs +++ b/examples/src/bin/basic-compute-shader.rs @@ -137,7 +137,7 @@ fn main() { // We start by creating the buffer that will store the data. let data_buffer = { // Iterator that produces the data. - let data_iter = (0..65536u32).map(|n| n); + let data_iter = 0..65536u32; // Builds the buffer and fills it with this iterator. CpuAccessibleBuffer::from_iter( device.clone(), @@ -186,7 +186,7 @@ fn main() { PipelineBindPoint::Compute, pipeline.layout().clone(), 0, - set.clone(), + set, ) .dispatch([1024, 1, 1]) .unwrap(); @@ -195,8 +195,8 @@ fn main() { // Let's execute this command buffer now. // To do so, we TODO: this is a bit clumsy, probably needs a shortcut - let future = sync::now(device.clone()) - .then_execute(queue.clone(), command_buffer) + let future = sync::now(device) + .then_execute(queue, command_buffer) .unwrap() // This line instructs the GPU to signal a *fence* once the command buffer has finished // execution. A fence is a Vulkan object that allows the CPU to know when the GPU has diff --git a/examples/src/bin/debug.rs b/examples/src/bin/debug.rs index a3eea319..62545104 100644 --- a/examples/src/bin/debug.rs +++ b/examples/src/bin/debug.rs @@ -53,8 +53,8 @@ fn main() { // and you should verify that list for safety - Vulkano will return an error if you specify // any layers that are not installed on this system. That code to do could look like this: println!("List of Vulkan debugging layers available to use:"); - let mut layers = library.layer_properties().unwrap(); - while let Some(l) = layers.next() { + let layers = library.layer_properties().unwrap(); + for l in layers { println!("\t{}", l.name()); } @@ -140,13 +140,11 @@ fn main() { }; let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance) .filter(|&p| p.supported_extensions().is_superset_of(&device_extensions)) - .filter_map(|p| { - Some( - p.queue_families() - .next() - .map(|q| (p, q)) - .expect("couldn't find a queue family"), - ) + .map(|p| { + p.queue_families() + .next() + .map(|q| (p, q)) + .expect("couldn't find a queue family") }) .min_by_key(|(p, _)| match p.properties().device_type { PhysicalDeviceType::DiscreteGpu => 0, @@ -181,7 +179,7 @@ fn main() { dimensions, MipmapsCount::One, pixel_format, - queue.clone(), + queue, ) .unwrap(); diff --git a/examples/src/bin/deferred/frame/ambient_lighting_system.rs b/examples/src/bin/deferred/frame/ambient_lighting_system.rs index 27fcc155..7b36810a 100644 --- a/examples/src/bin/deferred/frame/ambient_lighting_system.rs +++ b/examples/src/bin/deferred/frame/ambient_lighting_system.rs @@ -144,7 +144,7 @@ impl AmbientLightingSystem { ) .unwrap(); builder - .set_viewport(0, [viewport.clone()]) + .set_viewport(0, [viewport]) .bind_pipeline_graphics(self.pipeline.clone()) .bind_descriptor_sets( PipelineBindPoint::Graphics, diff --git a/examples/src/bin/deferred/frame/directional_lighting_system.rs b/examples/src/bin/deferred/frame/directional_lighting_system.rs index 7612f61a..1604e75c 100644 --- a/examples/src/bin/deferred/frame/directional_lighting_system.rs +++ b/examples/src/bin/deferred/frame/directional_lighting_system.rs @@ -158,7 +158,7 @@ impl DirectionalLightingSystem { ) .unwrap(); builder - .set_viewport(0, [viewport.clone()]) + .set_viewport(0, [viewport]) .bind_pipeline_graphics(self.pipeline.clone()) .bind_descriptor_sets( PipelineBindPoint::Graphics, diff --git a/examples/src/bin/deferred/frame/point_lighting_system.rs b/examples/src/bin/deferred/frame/point_lighting_system.rs index 0951872f..4887d951 100644 --- a/examples/src/bin/deferred/frame/point_lighting_system.rs +++ b/examples/src/bin/deferred/frame/point_lighting_system.rs @@ -126,6 +126,7 @@ impl PointLightingSystem { /// - `position` is the position of the spot light in world coordinates. /// - `color` is the color of the light. /// + #[allow(clippy::too_many_arguments)] pub fn draw( &self, viewport_dimensions: [u32; 2], @@ -170,7 +171,7 @@ impl PointLightingSystem { ) .unwrap(); builder - .set_viewport(0, [viewport.clone()]) + .set_viewport(0, [viewport]) .bind_pipeline_graphics(self.pipeline.clone()) .bind_descriptor_sets( PipelineBindPoint::Graphics, diff --git a/examples/src/bin/deferred/main.rs b/examples/src/bin/deferred/main.rs index e80cccb1..78558efa 100644 --- a/examples/src/bin/deferred/main.rs +++ b/examples/src/bin/deferred/main.rs @@ -141,7 +141,7 @@ fn main() { .unwrap(); let images = images .into_iter() - .map(|image| ImageView::new_default(image.clone()).unwrap()) + .map(|image| ImageView::new_default(image).unwrap()) .collect::>(); (swapchain, images) }; @@ -186,7 +186,7 @@ fn main() { }; let new_images = new_images .into_iter() - .map(|image| ImageView::new_default(image.clone()).unwrap()) + .map(|image| ImageView::new_default(image).unwrap()) .collect::>(); swapchain = new_swapchain; diff --git a/examples/src/bin/dynamic-buffers.rs b/examples/src/bin/dynamic-buffers.rs index 822499b0..fabe2571 100644 --- a/examples/src/bin/dynamic-buffers.rs +++ b/examples/src/bin/dynamic-buffers.rs @@ -14,7 +14,7 @@ // offset into the buffer to read object data from, without having to // rebind descriptor sets. -use std::mem::size_of; +use std::{iter::repeat, mem::size_of}; use vulkano::{ buffer::{BufferUsage, CpuAccessibleBuffer}, command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage}, @@ -139,16 +139,14 @@ fn main() { let align = (size_of::() + min_dynamic_align - 1) & !(min_dynamic_align - 1); let aligned_data = { let mut aligned_data = Vec::with_capacity(align * data.len()); - for i in 0..data.len() { - let bytes = data[i].to_ne_bytes(); + for elem in data { + let bytes = elem.to_ne_bytes(); // Fill up the buffer with data - for bi in 0..bytes.len() { - aligned_data.push(bytes[bi]); + for b in bytes { + aligned_data.push(b); } // Zero out any padding needed for alignment - for _ in 0..align - bytes.len() { - aligned_data.push(0); - } + aligned_data.extend(repeat(0).take(align - bytes.len())); } aligned_data }; @@ -173,7 +171,7 @@ fn main() { let set = PersistentDescriptorSet::new( layout.clone(), [ - WriteDescriptorSet::buffer(0, input_buffer.clone()), + WriteDescriptorSet::buffer(0, input_buffer), WriteDescriptorSet::buffer(1, output_buffer.clone()), ], ) @@ -186,6 +184,8 @@ fn main() { CommandBufferUsage::OneTimeSubmit, ) .unwrap(); + + #[allow(clippy::erasing_op, clippy::identity_op)] builder .bind_pipeline_compute(pipeline.clone()) .bind_descriptor_sets( @@ -208,14 +208,14 @@ fn main() { PipelineBindPoint::Compute, pipeline.layout().clone(), 0, - set.clone().offsets([2 * align as u32]), + set.offsets([2 * align as u32]), ) .dispatch([12, 1, 1]) .unwrap(); let command_buffer = builder.build().unwrap(); - let future = sync::now(device.clone()) - .then_execute(queue.clone(), command_buffer) + let future = sync::now(device) + .then_execute(queue, command_buffer) .unwrap() .then_signal_fence_and_flush() .unwrap(); diff --git a/examples/src/bin/dynamic-local-size.rs b/examples/src/bin/dynamic-local-size.rs index a17f309f..4eac2e83 100644 --- a/examples/src/bin/dynamic-local-size.rs +++ b/examples/src/bin/dynamic-local-size.rs @@ -201,11 +201,9 @@ fn main() { let view = ImageView::new_default(image.clone()).unwrap(); let layout = pipeline.layout().set_layouts().get(0).unwrap(); - let set = PersistentDescriptorSet::new( - layout.clone(), - [WriteDescriptorSet::image_view(0, view.clone())], - ) - .unwrap(); + let set = + PersistentDescriptorSet::new(layout.clone(), [WriteDescriptorSet::image_view(0, view)]) + .unwrap(); let buf = CpuAccessibleBuffer::from_iter( device.clone(), @@ -227,7 +225,7 @@ fn main() { PipelineBindPoint::Compute, pipeline.layout().clone(), 0, - set.clone(), + set, ) .dispatch([ 1024 / local_size_x, // Note that dispatch dimensions must be @@ -235,15 +233,12 @@ fn main() { 1, ]) .unwrap() - .copy_image_to_buffer(CopyImageToBufferInfo::image_buffer( - image.clone(), - buf.clone(), - )) + .copy_image_to_buffer(CopyImageToBufferInfo::image_buffer(image, buf.clone())) .unwrap(); let command_buffer = builder.build().unwrap(); - let future = sync::now(device.clone()) - .then_execute(queue.clone(), command_buffer) + let future = sync::now(device) + .then_execute(queue, command_buffer) .unwrap() .then_signal_fence_and_flush() .unwrap(); @@ -255,7 +250,7 @@ fn main() { let buffer_content = buf.read().unwrap(); let path = Path::new("mandelbrot.png"); let file = File::create(path).unwrap(); - let ref mut w = BufWriter::new(file); + let w = &mut BufWriter::new(file); let mut encoder = png::Encoder::new(w, 1024, 1024); encoder.set_color(png::ColorType::Rgba); encoder.set_depth(png::BitDepth::Eight); diff --git a/examples/src/bin/gl-interop.rs b/examples/src/bin/gl-interop.rs index 0621f789..7a2b049f 100644 --- a/examples/src/bin/gl-interop.rs +++ b/examples/src/bin/gl-interop.rs @@ -212,9 +212,7 @@ mod linux { let set = PersistentDescriptorSet::new( layout.clone(), [WriteDescriptorSet::image_view_sampler( - 0, - image_view, - sampler.clone(), + 0, image_view, sampler, )], ) .unwrap(); @@ -363,6 +361,7 @@ mod linux { } impl_vertex!(Vertex, position); + #[allow(clippy::type_complexity)] fn vk_setup( display: glium::HeadlessRenderer, ) -> ( diff --git a/examples/src/bin/image-self-copy-blit/main.rs b/examples/src/bin/image-self-copy-blit/main.rs index 96670599..8ab43d25 100644 --- a/examples/src/bin/image-self-copy-blit/main.rs +++ b/examples/src/bin/image-self-copy-blit/main.rs @@ -319,11 +319,7 @@ fn main() { let layout = pipeline.layout().set_layouts().get(0).unwrap(); let set = PersistentDescriptorSet::new( layout.clone(), - [WriteDescriptorSet::image_view_sampler( - 0, - texture.clone(), - sampler.clone(), - )], + [WriteDescriptorSet::image_view_sampler(0, texture, sampler)], ) .unwrap(); diff --git a/examples/src/bin/image/main.rs b/examples/src/bin/image/main.rs index 7d0e8921..98fee6f1 100644 --- a/examples/src/bin/image/main.rs +++ b/examples/src/bin/image/main.rs @@ -239,11 +239,7 @@ fn main() { let layout = pipeline.layout().set_layouts().get(0).unwrap(); let set = PersistentDescriptorSet::new( layout.clone(), - [WriteDescriptorSet::image_view_sampler( - 0, - texture.clone(), - sampler.clone(), - )], + [WriteDescriptorSet::image_view_sampler(0, texture, sampler)], ) .unwrap(); diff --git a/examples/src/bin/immutable-sampler/main.rs b/examples/src/bin/immutable-sampler/main.rs index 3eb6b36f..04547ec2 100644 --- a/examples/src/bin/immutable-sampler/main.rs +++ b/examples/src/bin/immutable-sampler/main.rs @@ -250,11 +250,9 @@ fn main() { let layout = pipeline.layout().set_layouts().get(0).unwrap(); // Use `image_view` instead of `image_view_sampler`, since the sampler is already in the layout. - let set = PersistentDescriptorSet::new( - layout.clone(), - [WriteDescriptorSet::image_view(0, texture.clone())], - ) - .unwrap(); + let set = + PersistentDescriptorSet::new(layout.clone(), [WriteDescriptorSet::image_view(0, texture)]) + .unwrap(); let mut viewport = Viewport { origin: [0.0, 0.0], diff --git a/examples/src/bin/indirect.rs b/examples/src/bin/indirect.rs index 77057dc7..969c78d0 100644 --- a/examples/src/bin/indirect.rs +++ b/examples/src/bin/indirect.rs @@ -385,7 +385,7 @@ fn main() { PipelineBindPoint::Compute, compute_pipeline.layout().clone(), 0, - cs_desciptor_set.clone(), + cs_desciptor_set, ) .dispatch([1, 1, 1]) .unwrap() @@ -401,8 +401,8 @@ fn main() { // contain the arguments when the draw is executed on the GPU .set_viewport(0, [viewport.clone()]) .bind_pipeline_graphics(render_pipeline.clone()) - .bind_vertex_buffers(0, vertices.clone()) - .draw_indirect(indirect_buffer.clone()) + .bind_vertex_buffers(0, vertices) + .draw_indirect(indirect_buffer) .unwrap() .end_render_pass() .unwrap(); diff --git a/examples/src/bin/interactive_fractal/app.rs b/examples/src/bin/interactive_fractal/app.rs index 66947a40..f591381c 100644 --- a/examples/src/bin/interactive_fractal/app.rs +++ b/examples/src/bin/interactive_fractal/app.rs @@ -329,9 +329,8 @@ impl InputState { /// Update toggle julia state (if right mouse is clicked) fn on_mouse_click_event(&mut self, state: ElementState, mouse_btn: winit::event::MouseButton) { - match mouse_btn { - MouseButton::Right => self.toggle_c = state_is_pressed(state), - _ => (), - }; + if mouse_btn == MouseButton::Right { + self.toggle_c = state_is_pressed(state) + } } } diff --git a/examples/src/bin/interactive_fractal/fractal_compute_pipeline.rs b/examples/src/bin/interactive_fractal/fractal_compute_pipeline.rs index ad63e19b..5a27ba08 100644 --- a/examples/src/bin/interactive_fractal/fractal_compute_pipeline.rs +++ b/examples/src/bin/interactive_fractal/fractal_compute_pipeline.rs @@ -105,7 +105,7 @@ impl FractalComputePipeline { let set = PersistentDescriptorSet::new( desc_layout.clone(), [ - WriteDescriptorSet::image_view(0, image.clone()), + WriteDescriptorSet::image_view(0, image), WriteDescriptorSet::buffer(1, self.palette.clone()), ], ) diff --git a/examples/src/bin/interactive_fractal/main.rs b/examples/src/bin/interactive_fractal/main.rs index 9d6e1caf..7ab2a3f3 100644 --- a/examples/src/bin/interactive_fractal/main.rs +++ b/examples/src/bin/interactive_fractal/main.rs @@ -144,7 +144,7 @@ fn compute_then_render( // Start frame let before_pipeline_future = match renderer.acquire() { Err(e) => { - println!("{}", e.to_string()); + println!("{}", e); return; } Ok(future) => future, diff --git a/examples/src/bin/msaa-renderpass.rs b/examples/src/bin/msaa-renderpass.rs index f126bef5..510b8ee3 100644 --- a/examples/src/bin/msaa-renderpass.rs +++ b/examples/src/bin/msaa-renderpass.rs @@ -214,7 +214,7 @@ fn main() { let framebuffer = Framebuffer::new( render_pass.clone(), FramebufferCreateInfo { - attachments: vec![intermediary.clone(), view.clone()], + attachments: vec![intermediary, view], ..Default::default() }, ) @@ -281,7 +281,7 @@ fn main() { CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, vertices) .unwrap(); - let subpass = Subpass::from(render_pass.clone(), 0).unwrap(); + let subpass = Subpass::from(render_pass, 0).unwrap(); let pipeline = GraphicsPipeline::start() .vertex_input_state(BuffersDefinition::new().vertex::()) .vertex_shader(vs.entry_point("main").unwrap(), ()) @@ -310,7 +310,7 @@ fn main() { .unwrap(); let mut builder = AutoCommandBufferBuilder::primary( - device.clone(), + device, queue.family(), CommandBufferUsage::OneTimeSubmit, ) @@ -319,26 +319,23 @@ fn main() { .begin_render_pass( RenderPassBeginInfo { clear_values: vec![Some([0.0, 0.0, 1.0, 1.0].into()), None], - ..RenderPassBeginInfo::framebuffer(framebuffer.clone()) + ..RenderPassBeginInfo::framebuffer(framebuffer) }, SubpassContents::Inline, ) .unwrap() - .set_viewport(0, [viewport.clone()]) - .bind_pipeline_graphics(pipeline.clone()) + .set_viewport(0, [viewport]) + .bind_pipeline_graphics(pipeline) .bind_vertex_buffers(0, vertex_buffer.clone()) .draw(vertex_buffer.len() as u32, 1, 0, 0) .unwrap() .end_render_pass() .unwrap() - .copy_image_to_buffer(CopyImageToBufferInfo::image_buffer( - image.clone(), - buf.clone(), - )) + .copy_image_to_buffer(CopyImageToBufferInfo::image_buffer(image, buf.clone())) .unwrap(); let command_buffer = builder.build().unwrap(); - let finished = command_buffer.execute(queue.clone()).unwrap(); + let finished = command_buffer.execute(queue).unwrap(); finished .then_signal_fence_and_flush() .unwrap() @@ -348,7 +345,7 @@ fn main() { let buffer_content = buf.read().unwrap(); let path = Path::new("triangle.png"); let file = File::create(path).unwrap(); - let ref mut w = BufWriter::new(file); + let w = &mut BufWriter::new(file); let mut encoder = png::Encoder::new(w, 1024, 1024); // Width is 2 pixels and height is 1. encoder.set_color(png::ColorType::Rgba); encoder.set_depth(png::BitDepth::Eight); diff --git a/examples/src/bin/multi-window.rs b/examples/src/bin/multi-window.rs index 86a483a9..671ad62d 100644 --- a/examples/src/bin/multi-window.rs +++ b/examples/src/bin/multi-window.rs @@ -296,7 +296,7 @@ fn main() { .. } => { let surface = WindowBuilder::new() - .build_vk_surface(&event_loop, instance.clone()) + .build_vk_surface(event_loop, instance.clone()) .unwrap(); let window_id = surface.window().id(); let (swapchain, images) = { diff --git a/examples/src/bin/multi_window_game_of_life/main.rs b/examples/src/bin/multi_window_game_of_life/main.rs index 93c691db..8ea2742a 100644 --- a/examples/src/bin/multi_window_game_of_life/main.rs +++ b/examples/src/bin/multi_window_game_of_life/main.rs @@ -198,7 +198,7 @@ fn compute_then_render( // Start frame let before_pipeline_future = match window_renderer.acquire() { Err(e) => { - println!("{}", e.to_string()); + println!("{}", e); return; } Ok(future) => future, diff --git a/examples/src/bin/multiview.rs b/examples/src/bin/multiview.rs index 048a253c..9a3e69ff 100644 --- a/examples/src/bin/multiview.rs +++ b/examples/src/bin/multiview.rs @@ -261,7 +261,7 @@ fn main() { }, ])) .fragment_shader(fs.entry_point("main").unwrap(), ()) - .render_pass(Subpass::from(render_pass.clone(), 0).unwrap()) + .render_pass(Subpass::from(render_pass, 0).unwrap()) .build(device.clone()) .unwrap(); @@ -291,12 +291,12 @@ fn main() { .begin_render_pass( RenderPassBeginInfo { clear_values: vec![Some([0.0, 0.0, 1.0, 1.0].into())], - ..RenderPassBeginInfo::framebuffer(framebuffer.clone()) + ..RenderPassBeginInfo::framebuffer(framebuffer) }, SubpassContents::Inline, ) .unwrap() - .bind_pipeline_graphics(pipeline.clone()) + .bind_pipeline_graphics(pipeline) .bind_vertex_buffers(0, vertex_buffer.clone()) .draw(vertex_buffer.len() as u32, 1, 0, 0) .unwrap() @@ -335,7 +335,7 @@ fn main() { let command_buffer = builder.build().unwrap(); let future = sync::now(device.clone()) - .then_execute(queue.clone(), command_buffer) + .then_execute(queue, command_buffer) .unwrap() .then_signal_fence_and_flush() .unwrap(); @@ -366,7 +366,7 @@ fn write_image_buffer_to_file( let buffer_content = buffer.read().unwrap(); let path = Path::new(path); let file = File::create(path).unwrap(); - let ref mut w = BufWriter::new(file); + let w = &mut BufWriter::new(file); let mut encoder = png::Encoder::new(w, width, height); encoder.set_color(png::ColorType::Rgba); encoder.set_depth(png::BitDepth::Eight); diff --git a/examples/src/bin/pipeline-caching.rs b/examples/src/bin/pipeline-caching.rs index 7be6a1b6..01d65a84 100644 --- a/examples/src/bin/pipeline-caching.rs +++ b/examples/src/bin/pipeline-caching.rs @@ -145,7 +145,7 @@ fn main() { if let Ok(data) = pipeline_cache.get_data() { if let Ok(mut file) = File::create("pipeline_cache.bin.tmp") { - if let Ok(_) = file.write_all(&data) { + if file.write_all(&data).is_ok() { let _ = rename("pipeline_cache.bin.tmp", "pipeline_cache.bin"); } else { let _ = remove_file("pipeline_cache.bin.tmp"); @@ -163,7 +163,7 @@ fn main() { let data = { if let Ok(mut file) = File::open("pipeline_cache.bin") { let mut data = Vec::new(); - if let Ok(_) = file.read_to_end(&mut data) { + if file.read_to_end(&mut data).is_ok() { Some(data) } else { None @@ -175,9 +175,9 @@ fn main() { let second_cache = if let Some(data) = data { // This is unsafe because there is no way to be sure that the file contains valid data. - unsafe { PipelineCache::with_data(device.clone(), &data).unwrap() } + unsafe { PipelineCache::with_data(device, &data).unwrap() } } else { - PipelineCache::empty(device.clone()).unwrap() + PipelineCache::empty(device).unwrap() }; // As the PipelineCache of the Vulkan implementation saves an opaque blob of data, diff --git a/examples/src/bin/push-constants.rs b/examples/src/bin/push-constants.rs index 7a259971..0bccfe85 100644 --- a/examples/src/bin/push-constants.rs +++ b/examples/src/bin/push-constants.rs @@ -115,7 +115,7 @@ fn main() { .unwrap(); let data_buffer = { - let data_iter = (0..65536u32).map(|n| n); + let data_iter = 0..65536u32; CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, data_iter) .unwrap() }; @@ -151,15 +151,15 @@ fn main() { PipelineBindPoint::Compute, pipeline.layout().clone(), 0, - set.clone(), + set, ) .push_constants(pipeline.layout().clone(), 0, push_constants) .dispatch([1024, 1, 1]) .unwrap(); let command_buffer = builder.build().unwrap(); - let future = sync::now(device.clone()) - .then_execute(queue.clone(), command_buffer) + let future = sync::now(device) + .then_execute(queue, command_buffer) .unwrap() .then_signal_fence_and_flush() .unwrap(); @@ -168,7 +168,7 @@ fn main() { let data_buffer_content = data_buffer.read().unwrap(); for n in 0..65536u32 { - assert_eq!(data_buffer_content[n as usize], n * 1 + 1); + assert_eq!(data_buffer_content[n as usize], n + 1); } println!("Success"); } diff --git a/examples/src/bin/runtime_array/main.rs b/examples/src/bin/runtime_array/main.rs index e9458bda..ba559967 100644 --- a/examples/src/bin/runtime_array/main.rs +++ b/examples/src/bin/runtime_array/main.rs @@ -328,7 +328,7 @@ fn main() { let set_layouts = layout_create_infos .into_iter() - .map(|desc| Ok(DescriptorSetLayout::new(device.clone(), desc.clone())?)) + .map(|desc| DescriptorSetLayout::new(device.clone(), desc)) .collect::, DescriptorSetLayoutCreationError>>() .unwrap(); @@ -368,8 +368,8 @@ fn main() { 0, 0, [ - (mascot_texture.clone() as _, sampler.clone()), - (vulkano_texture.clone() as _, sampler.clone()), + (mascot_texture as _, sampler.clone()), + (vulkano_texture as _, sampler), ], )], ) diff --git a/examples/src/bin/self-copy-buffer.rs b/examples/src/bin/self-copy-buffer.rs index a464a51b..0ff72e3c 100644 --- a/examples/src/bin/self-copy-buffer.rs +++ b/examples/src/bin/self-copy-buffer.rs @@ -155,14 +155,14 @@ fn main() { PipelineBindPoint::Compute, pipeline.layout().clone(), 0, - set.clone(), + set, ) .dispatch([1024, 1, 1]) .unwrap(); let command_buffer = builder.build().unwrap(); - let future = sync::now(device.clone()) - .then_execute(queue.clone(), command_buffer) + let future = sync::now(device) + .then_execute(queue, command_buffer) .unwrap() .then_signal_fence_and_flush() .unwrap(); diff --git a/examples/src/bin/shader-include/main.rs b/examples/src/bin/shader-include/main.rs index 3d60f80b..1b114ed3 100644 --- a/examples/src/bin/shader-include/main.rs +++ b/examples/src/bin/shader-include/main.rs @@ -115,7 +115,7 @@ fn main() { }; let data_buffer = { - let data_iter = (0..65536u32).map(|n| n); + let data_iter = 0..65536u32; CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, data_iter) .unwrap() }; @@ -139,13 +139,13 @@ fn main() { PipelineBindPoint::Compute, pipeline.layout().clone(), 0, - set.clone(), + set, ) .dispatch([1024, 1, 1]) .unwrap(); let command_buffer = builder.build().unwrap(); - let future = sync::now(device.clone()) - .then_execute(queue.clone(), command_buffer) + let future = sync::now(device) + .then_execute(queue, command_buffer) .unwrap() .then_signal_fence_and_flush() .unwrap(); diff --git a/examples/src/bin/shader-types-sharing.rs b/examples/src/bin/shader-types-sharing.rs index 995c4c46..ad82d0c7 100644 --- a/examples/src/bin/shader-types-sharing.rs +++ b/examples/src/bin/shader-types-sharing.rs @@ -186,7 +186,7 @@ fn main() { let layout = pipeline.layout().set_layouts().get(0).unwrap(); let set = PersistentDescriptorSet::new( layout.clone(), - [WriteDescriptorSet::buffer(0, data_buffer.clone())], + [WriteDescriptorSet::buffer(0, data_buffer)], ) .unwrap(); @@ -202,7 +202,7 @@ fn main() { PipelineBindPoint::Compute, pipeline.layout().clone(), 0, - set.clone(), + set, ) .push_constants(pipeline.layout().clone(), 0, parameters) .dispatch([1024, 1, 1]) @@ -220,7 +220,7 @@ fn main() { // Preparing test data array `[0, 1, 2, 3....]` let data_buffer = { - let data_iter = (0..65536u32).map(|n| n); + let data_iter = 0..65536u32; CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, data_iter) .unwrap() }; @@ -241,7 +241,7 @@ fn main() { // Loading the second shader, and creating a Pipeline for the shader let add_pipeline = ComputePipeline::new( device.clone(), - shaders::load_add(device.clone()) + shaders::load_add(device) .unwrap() .entry_point("main") .unwrap(), @@ -270,7 +270,7 @@ fn main() { // Then multiply each value by 3 run_shader( mult_pipeline, - queue.clone(), + queue, data_buffer.clone(), shaders::ty::Parameters { value: 3 }, ); diff --git a/examples/src/bin/simple-particles.rs b/examples/src/bin/simple-particles.rs index afb39a5f..283a299f 100644 --- a/examples/src/bin/simple-particles.rs +++ b/examples/src/bin/simple-particles.rs @@ -398,7 +398,7 @@ fn main() { .input_assembly_state(InputAssemblyState::new().topology(PrimitiveTopology::PointList)) // Vertices will be rendered as a list of points. .viewport_state(ViewportState::viewport_fixed_scissor_irrelevant([viewport])) .fragment_shader(fs.entry_point("main").unwrap(), ()) - .render_pass(Subpass::from(render_pass.clone(), 0).unwrap()) + .render_pass(Subpass::from(render_pass, 0).unwrap()) .build(device.clone()) .unwrap(); @@ -406,7 +406,7 @@ fn main() { let mut previous_fence_index = 0; let start_time = SystemTime::now(); - let mut last_frame_time = start_time.clone(); + let mut last_frame_time = start_time; event_loop.run(move |event, _, control_flow| { match event { Event::WindowEvent { @@ -445,8 +445,8 @@ fn main() { }; // Since we disallow resizing, assert the swapchain and surface are optimally configured. - assert_eq!( - suboptimal, false, + assert!( + !suboptimal, "Not handling sub-optimal swapchains in this sample code" ); diff --git a/examples/src/bin/specialization-constants.rs b/examples/src/bin/specialization-constants.rs index a31196cc..6e8efe8a 100644 --- a/examples/src/bin/specialization-constants.rs +++ b/examples/src/bin/specialization-constants.rs @@ -116,7 +116,7 @@ fn main() { .unwrap(); let data_buffer = { - let data_iter = (0..65536u32).map(|n| n); + let data_iter = 0..65536u32; CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, data_iter) .unwrap() }; @@ -140,14 +140,14 @@ fn main() { PipelineBindPoint::Compute, pipeline.layout().clone(), 0, - set.clone(), + set, ) .dispatch([1024, 1, 1]) .unwrap(); let command_buffer = builder.build().unwrap(); - let future = sync::now(device.clone()) - .then_execute(queue.clone(), command_buffer) + let future = sync::now(device) + .then_execute(queue, command_buffer) .unwrap() .then_signal_fence_and_flush() .unwrap(); @@ -156,7 +156,7 @@ fn main() { let data_buffer_content = data_buffer.read().unwrap(); for n in 0..65536u32 { - assert_eq!(data_buffer_content[n as usize], n * 1 + 1); + assert_eq!(data_buffer_content[n as usize], n + 1); } println!("Success"); } diff --git a/examples/src/bin/teapot/main.rs b/examples/src/bin/teapot/main.rs index da838f2b..4877e89d 100644 --- a/examples/src/bin/teapot/main.rs +++ b/examples/src/bin/teapot/main.rs @@ -301,7 +301,7 @@ fn main() { PipelineBindPoint::Graphics, pipeline.layout().clone(), 0, - set.clone(), + set, ) .bind_vertex_buffers(0, (vertex_buffer.clone(), normals_buffer.clone())) .bind_index_buffer(index_buffer.clone()) @@ -390,8 +390,8 @@ fn window_size_dependent_setup( ])) .fragment_shader(fs.entry_point("main").unwrap(), ()) .depth_stencil_state(DepthStencilState::simple_depth_test()) - .render_pass(Subpass::from(render_pass.clone(), 0).unwrap()) - .build(device.clone()) + .render_pass(Subpass::from(render_pass, 0).unwrap()) + .build(device) .unwrap(); (pipeline, framebuffers) diff --git a/examples/src/bin/texture_array/main.rs b/examples/src/bin/texture_array/main.rs index 7a0437f0..224e79f0 100644 --- a/examples/src/bin/texture_array/main.rs +++ b/examples/src/bin/texture_array/main.rs @@ -240,11 +240,7 @@ fn main() { let layout = pipeline.layout().set_layouts().get(0).unwrap(); let set = PersistentDescriptorSet::new( layout.clone(), - [WriteDescriptorSet::image_view_sampler( - 0, - texture.clone(), - sampler.clone(), - )], + [WriteDescriptorSet::image_view_sampler(0, texture, sampler)], ) .unwrap(); diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 42b534c5..2957105e 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -1,6 +1,3 @@ -use bytemuck::{Pod, Zeroable}; -use vulkano::impl_vertex; - // Copyright (c) 2016 The vulkano developers // Licensed under the Apache License, Version 2.0 // &str { ) } +#[allow(clippy::too_many_arguments)] fn include_callback( requested_source_path_raw: &str, directive_type: IncludeType, @@ -143,6 +144,7 @@ fn include_callback( }) } +#[allow(clippy::too_many_arguments)] pub fn compile( path: Option, base_path: &impl AsRef, @@ -197,7 +199,7 @@ pub fn compile( compile_options.set_generate_debug_info(); let content = compiler - .compile_into_spirv(&code, ty, root_source_path, "main", Some(&compile_options)) + .compile_into_spirv(code, ty, root_source_path, "main", Some(&compile_options)) .map_err(|e| e.to_string())?; let includes = includes_tracker.borrow().clone(); @@ -703,7 +705,7 @@ mod tests { // Check first entrypoint let e1_descriptors = descriptors.get(0).expect("Could not find entrypoint1"); let mut e1_bindings = Vec::new(); - for (loc, _reqs) in e1_descriptors { + for loc in e1_descriptors.keys() { e1_bindings.push(*loc); } assert_eq!(e1_bindings.len(), 5); @@ -716,7 +718,7 @@ mod tests { // Check second entrypoint let e2_descriptors = descriptors.get(1).expect("Could not find entrypoint2"); let mut e2_bindings = Vec::new(); - for (loc, _reqs) in e2_descriptors { + for loc in e2_descriptors.keys() { e2_bindings.push(*loc); } assert_eq!(e2_bindings.len(), 3); @@ -767,7 +769,7 @@ mod tests { .unwrap(); let spirv = Spirv::new(comp.as_binary()).unwrap(); - for (_, _, info) in reflect::entry_points(&spirv) { + if let Some((_, _, info)) = reflect::entry_points(&spirv).next() { let mut bindings = Vec::new(); for (loc, _reqs) in info.descriptor_requirements { bindings.push(loc); diff --git a/vulkano-shaders/src/entry_point.rs b/vulkano-shaders/src/entry_point.rs index aee83274..01768ca7 100644 --- a/vulkano-shaders/src/entry_point.rs +++ b/vulkano-shaders/src/entry_point.rs @@ -87,7 +87,7 @@ fn write_shader_execution(execution: &ShaderExecution) -> TokenStream { fn write_descriptor_requirements( descriptor_requirements: &HashMap<(u32, u32), DescriptorRequirements>, ) -> TokenStream { - let descriptor_requirements = descriptor_requirements.into_iter().map(|(loc, reqs)| { + let descriptor_requirements = descriptor_requirements.iter().map(|(loc, reqs)| { let (set_num, binding_num) = loc; let DescriptorRequirements { descriptor_types, @@ -106,7 +106,7 @@ fn write_descriptor_requirements( storage_write, } = reqs; - let descriptor_types = descriptor_types.into_iter().map(|ty| { + let descriptor_types = descriptor_types.iter().map(|ty| { let ident = format_ident!("{}", format!("{:?}", ty)); quote! { ::vulkano::descriptor_set::layout::DescriptorType::#ident } }); @@ -286,19 +286,20 @@ fn write_push_constant_requirements( fn write_specialization_constant_requirements( specialization_constant_requirements: &HashMap, ) -> TokenStream { - let specialization_constant_requirements = specialization_constant_requirements - .into_iter() - .map(|(&constant_id, reqs)| { - let SpecializationConstantRequirements { size } = reqs; - quote! { - ( - #constant_id, - ::vulkano::shader::SpecializationConstantRequirements { - size: #size, - }, - ), - } - }); + let specialization_constant_requirements = + specialization_constant_requirements + .iter() + .map(|(&constant_id, reqs)| { + let SpecializationConstantRequirements { size } = reqs; + quote! { + ( + #constant_id, + ::vulkano::shader::SpecializationConstantRequirements { + size: #size, + }, + ), + } + }); quote! { [ diff --git a/vulkano-shaders/src/lib.rs b/vulkano-shaders/src/lib.rs index 897bdd16..7b279169 100644 --- a/vulkano-shaders/src/lib.rs +++ b/vulkano-shaders/src/lib.rs @@ -217,6 +217,7 @@ #![doc(html_logo_url = "https://raw.githubusercontent.com/vulkano-rs/vulkano/master/logo.png")] #![recursion_limit = "1024"] + #[macro_use] extern crate quote; #[macro_use] @@ -779,7 +780,7 @@ impl Parse for MacroInput { }) .collect(), spirv_version, - types_meta: types_meta.unwrap_or_else(|| TypesMeta::default()), + types_meta: types_meta.unwrap_or_default(), vulkan_version, }) } @@ -796,7 +797,7 @@ pub fn shader(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as MacroInput); let is_single = input.shaders.len() == 1; - let root = env::var("CARGO_MANIFEST_DIR").unwrap_or(".".into()); + let root = env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".into()); let root_path = Path::new(&root); let mut shaders_code = Vec::with_capacity(input.shaders.len()); @@ -808,7 +809,8 @@ pub fn shader(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let full_path = root_path.join(&path); let bytes = if full_path.is_file() { - fs::read(full_path).expect(&format!("Error reading source from {:?}", path)) + fs::read(full_path) + .unwrap_or_else(|_| panic!("Error reading source from {:?}", path)) } else { panic!( "File {:?} was not found; note that the path must be relative to your Cargo.toml", @@ -828,14 +830,13 @@ pub fn shader(input: proc_macro::TokenStream) -> proc_macro::TokenStream { &mut types_registry, ) .unwrap() - .into() } else { let (path, full_path, source_code) = match shader_source { SourceKind::Src(source) => (None, None, source), SourceKind::Path(path) => { let full_path = root_path.join(&path); let source_code = read_file_to_string(&full_path) - .expect(&format!("Error reading source from {:?}", path)); + .unwrap_or_else(|_| panic!("Error reading source from {:?}", path)); if full_path.is_file() { (Some(path.clone()), Some(full_path), source_code) @@ -877,12 +878,10 @@ pub fn shader(input: proc_macro::TokenStream) -> proc_macro::TokenStream { } }; - let input_paths = includes.iter().map(|s| s.as_ref()).chain( - full_path - .as_ref() - .map(|p| p.as_path()) - .map(codegen::path_to_str), - ); + let input_paths = includes + .iter() + .map(|s| s.as_ref()) + .chain(full_path.as_deref().map(codegen::path_to_str)); codegen::reflect( prefix.as_str(), @@ -893,7 +892,6 @@ pub fn shader(input: proc_macro::TokenStream) -> proc_macro::TokenStream { &mut types_registry, ) .unwrap() - .into() }; shaders_code.push(code); @@ -917,7 +915,7 @@ pub fn shader(input: proc_macro::TokenStream) -> proc_macro::TokenStream { }; if input.dump { - println!("{}", result.to_string()); + println!("{}", result); panic!("`shader!` rust codegen dumped") // TODO: use span from dump } diff --git a/vulkano-shaders/src/structs.rs b/vulkano-shaders/src/structs.rs index f9d435b6..8c7597d8 100644 --- a/vulkano-shaders/src/structs.rs +++ b/vulkano-shaders/src/structs.rs @@ -64,7 +64,7 @@ pub(super) fn write_structs<'a>( Some(if is_sized { let derives = write_derives(types_meta); - let impls = write_impls(types_meta, &struct_name, &rust_members); + let impls = write_impls(types_meta, struct_name, &rust_members); quote! { #derives #struct_body @@ -414,12 +414,12 @@ pub(super) fn type_from_id( data: i8, after: u8, } - return ( + ( quote! {i8}, Cow::from("i8"), Some(std::mem::size_of::()), mem::align_of::(), - ); + ) } (8, 0) => { #[repr(C)] @@ -427,12 +427,12 @@ pub(super) fn type_from_id( data: u8, after: u8, } - return ( + ( quote! {u8}, Cow::from("u8"), Some(std::mem::size_of::()), mem::align_of::(), - ); + ) } (16, 1) => { #[repr(C)] @@ -440,12 +440,12 @@ pub(super) fn type_from_id( data: i16, after: u8, } - return ( + ( quote! {i16}, Cow::from("i16"), Some(std::mem::size_of::()), mem::align_of::(), - ); + ) } (16, 0) => { #[repr(C)] @@ -453,12 +453,12 @@ pub(super) fn type_from_id( data: u16, after: u8, } - return ( + ( quote! {u16}, Cow::from("u16"), Some(std::mem::size_of::()), mem::align_of::(), - ); + ) } (32, 1) => { #[repr(C)] @@ -466,12 +466,12 @@ pub(super) fn type_from_id( data: i32, after: u8, } - return ( + ( quote! {i32}, Cow::from("i32"), Some(std::mem::size_of::()), mem::align_of::(), - ); + ) } (32, 0) => { #[repr(C)] @@ -479,12 +479,12 @@ pub(super) fn type_from_id( data: u32, after: u8, } - return ( + ( quote! {u32}, Cow::from("u32"), Some(std::mem::size_of::()), mem::align_of::(), - ); + ) } (64, 1) => { #[repr(C)] @@ -492,12 +492,12 @@ pub(super) fn type_from_id( data: i64, after: u8, } - return ( + ( quote! {i64}, Cow::from("i64"), Some(std::mem::size_of::()), mem::align_of::(), - ); + ) } (64, 0) => { #[repr(C)] @@ -505,12 +505,12 @@ pub(super) fn type_from_id( data: u64, after: u8, } - return ( + ( quote! {u64}, Cow::from("u64"), Some(std::mem::size_of::()), mem::align_of::(), - ); + ) } _ => panic!("No Rust equivalent for an integer of width {}", width), }, @@ -521,12 +521,12 @@ pub(super) fn type_from_id( data: f32, after: u8, } - return ( + ( quote! {f32}, Cow::from("f32"), Some(std::mem::size_of::()), mem::align_of::(), - ); + ) } 64 => { #[repr(C)] @@ -534,12 +534,12 @@ pub(super) fn type_from_id( data: f64, after: u8, } - return ( + ( quote! {f64}, Cow::from("f64"), Some(std::mem::size_of::()), mem::align_of::(), - ); + ) } _ => panic!("No Rust equivalent for a floating-point of width {}", width), }, @@ -552,12 +552,12 @@ pub(super) fn type_from_id( let (ty, item, t_size, t_align) = type_from_id(shader, spirv, component_type); let array_length = component_count as usize; let size = t_size.map(|s| s * component_count as usize); - return ( + ( quote! { [#ty; #array_length] }, Cow::from(format!("[{}; {}]", item, array_length)), size, t_align, - ); + ) } &Instruction::TypeMatrix { column_type, @@ -569,12 +569,12 @@ pub(super) fn type_from_id( let (ty, item, t_size, t_align) = type_from_id(shader, spirv, column_type); let array_length = column_count as usize; let size = t_size.map(|s| s * column_count as usize); - return ( + ( quote! { [#ty; #array_length] }, Cow::from(format!("[{}; {}]", item, array_length)), size, t_align, - ); + ) } &Instruction::TypeArray { element_type, @@ -611,12 +611,12 @@ pub(super) fn type_from_id( (e.g. increase a vec3 to a vec4)") } - return ( + ( quote! { [#element_type; #array_length] }, Cow::from(format!("[{}; {}]", element_type_string, array_length)), Some(element_size * array_length as usize), element_align, - ); + ) } &Instruction::TypeRuntimeArray { element_type, .. } => { debug_assert_eq!(mem::align_of::<[u32; 3]>(), mem::align_of::()); @@ -624,12 +624,12 @@ pub(super) fn type_from_id( let (element_type, element_type_string, _, element_align) = type_from_id(shader, spirv, element_type); - return ( + ( quote! { [#element_type] }, Cow::from(format!("[{}]", element_type_string)), None, element_align, - ); + ) } Instruction::TypeStruct { member_types, .. } => { // TODO: take the Offset member decorate into account? @@ -676,13 +676,13 @@ pub(super) fn type_from_id( Instruction::Name { name, .. } => Some(Cow::from(name.clone())), _ => None, }) - .unwrap_or(Cow::from("__unnamed")); + .unwrap_or_else(|| Cow::from("__unnamed")); let name = { let name = format_ident!("{}", name_string); quote! { #name } }; - return (name, name_string, size, align); + (name, name_string, size, align) } _ => panic!("Type #{} not found", type_id), } @@ -709,18 +709,18 @@ pub(super) fn write_specialization_constants<'a>( let mut spec_consts = Vec::new(); for instruction in spirv.iter_global() { - let (result_type_id, result_id, default_value) = match instruction { - &Instruction::SpecConstantTrue { + let (result_type_id, result_id, default_value) = match *instruction { + Instruction::SpecConstantTrue { result_type_id, result_id, } => (result_type_id, result_id, quote! {1u32}), - &Instruction::SpecConstantFalse { + Instruction::SpecConstantFalse { result_type_id, result_id, } => (result_type_id, result_id, quote! {0u32}), - &Instruction::SpecConstant { + Instruction::SpecConstant { result_type_id, result_id, ref value, @@ -730,7 +730,8 @@ pub(super) fn write_specialization_constants<'a>( }; (result_type_id, result_id, def_val) } - &Instruction::SpecConstantComposite { + + Instruction::SpecConstantComposite { result_type_id, result_id, ref constituents, @@ -741,6 +742,7 @@ pub(super) fn write_specialization_constants<'a>( }; (result_type_id, result_id, def_val) } + _ => continue, }; diff --git a/vulkano-util/src/context.rs b/vulkano-util/src/context.rs index f710396e..bb730770 100644 --- a/vulkano-util/src/context.rs +++ b/vulkano-util/src/context.rs @@ -134,19 +134,18 @@ impl VulkanoContext { .union(&config.instance_create_info.enabled_extensions); // Create instance - let instance = Instance::new(library.clone(), config.instance_create_info) - .expect("Failed to create instance"); + let instance = + Instance::new(library, config.instance_create_info).expect("Failed to create instance"); // Create debug callback - let _debug_utils_messenger = if let Some(dbg_create_info) = config.debug_create_info.take() - { - Some(unsafe { - DebugUtilsMessenger::new(instance.clone(), dbg_create_info) - .expect("Failed to create debug callback") - }) - } else { - None - }; + let _debug_utils_messenger = + config + .debug_create_info + .take() + .map(|dbg_create_info| unsafe { + DebugUtilsMessenger::new(instance.clone(), dbg_create_info) + .expect("Failed to create debug callback") + }); // Get prioritized device let physical_device = PhysicalDevice::enumerate(&instance) diff --git a/vulkano-util/src/lib.rs b/vulkano-util/src/lib.rs index 552fee36..3b37b6d1 100644 --- a/vulkano-util/src/lib.rs +++ b/vulkano-util/src/lib.rs @@ -7,6 +7,8 @@ // notice may not be copied, modified, or distributed except // according to those terms. +#![allow(clippy::missing_safety_doc)] + pub mod context; pub mod renderer; pub mod window; diff --git a/vulkano-util/src/renderer.rs b/vulkano-util/src/renderer.rs index 7c6bc5aa..f3733285 100644 --- a/vulkano-util/src/renderer.rs +++ b/vulkano-util/src/renderer.rs @@ -335,7 +335,7 @@ impl VulkanoWindowRenderer { .collect::>(); for i in resizable_views { let format = self.get_additional_image_view(i).format().unwrap(); - let usage = self.get_additional_image_view(i).usage().clone(); + let usage = *self.get_additional_image_view(i).usage(); self.remove_additional_image_view(i); self.add_additional_image_view(i, format, usage); } diff --git a/vulkano-util/src/window.rs b/vulkano-util/src/window.rs index 19a602c2..421cbd77 100644 --- a/vulkano-util/src/window.rs +++ b/vulkano-util/src/window.rs @@ -202,19 +202,17 @@ impl VulkanoWindows { &mut self, id: winit::window::WindowId, ) -> Option<&mut VulkanoWindowRenderer> { - self.windows.get_mut(&id).and_then(|v| Some(v)) + self.windows.get_mut(&id) } /// Get a reference to the renderer by winit window id pub fn get_renderer(&self, id: winit::window::WindowId) -> Option<&VulkanoWindowRenderer> { - self.windows.get(&id).and_then(|v| Some(v)) + self.windows.get(&id) } /// Get a reference to the winit window by winit window id pub fn get_window(&self, id: winit::window::WindowId) -> Option<&winit::window::Window> { - self.windows - .get(&id) - .and_then(|v_window| Some(v_window.window())) + self.windows.get(&id).map(|v_window| v_window.window()) } /// Return primary window id @@ -294,7 +292,7 @@ fn get_best_videomode(monitor: &winit::monitor::MonitorHandle) -> winit::monitor } /// Defines the way a window is displayed. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum WindowMode { /// Creates a window that uses the given size. Windowed, diff --git a/vulkano-win/src/lib.rs b/vulkano-win/src/lib.rs index 57bb3768..cb5e5879 100644 --- a/vulkano-win/src/lib.rs +++ b/vulkano-win/src/lib.rs @@ -1,4 +1,5 @@ #![doc(html_logo_url = "https://raw.githubusercontent.com/vulkano-rs/vulkano/master/logo.png")] +#![allow(clippy::missing_safety_doc)] /// Create a surface either using winit or a RawWindowHandle /// Its possible to disable either one using features diff --git a/vulkano/autogen/extensions.rs b/vulkano/autogen/extensions.rs index 9f7f3603..28c3b43c 100644 --- a/vulkano/autogen/extensions.rs +++ b/vulkano/autogen/extensions.rs @@ -17,6 +17,7 @@ use vk_parse::Extension; // This is not included in vk.xml, so it's added here manually fn required_if_supported(name: &str) -> bool { + #[allow(clippy::match_like_matches_macro)] match name { "VK_KHR_portability_subset" => true, _ => false, @@ -172,18 +173,6 @@ fn device_extensions_output(members: &[ExtensionsMember]) -> TokenStream { } }); - let required_if_supported_extensions_items = members.iter().map( - |ExtensionsMember { - name, - required_if_supported, - .. - }| { - quote! { - #name: #required_if_supported, - } - }, - ); - quote! { #common @@ -199,13 +188,6 @@ fn device_extensions_output(members: &[ExtensionsMember]) -> TokenStream { #(#check_requirements_items)* Ok(()) } - - pub(crate) fn required_if_supported_extensions() -> Self { - Self { - #(#required_if_supported_extensions_items)* - _ne: crate::NonExhaustive(()), - } - } } } } @@ -354,7 +336,7 @@ fn extensions_common_output(struct_name: Ident, members: &[ExtensionsMember]) -> let from_extensions_for_vec_cstring_items = members.iter().map(|ExtensionsMember { name, raw, .. }| { quote! { - if x.#name { data.push(CString::new(&#raw[..]).unwrap()); } + if x.#name { data.push(CString::new(#raw).unwrap()); } } }); @@ -482,7 +464,7 @@ fn extensions_members(ty: &str, extensions: &IndexMap<&str, &Extension>) -> Vec< ); let extension = extensions[vk_name]; - match extension.ext_type.as_ref().map(|s| s.as_str()) { + match extension.ext_type.as_deref() { Some("device") => &mut dependencies.device_extensions, Some("instance") => &mut dependencies.instance_extensions, _ => unreachable!(), @@ -518,8 +500,7 @@ fn extensions_members(ty: &str, extensions: &IndexMap<&str, &Extension>) -> Vec< .collect(), status: ext .promotedto - .as_ref() - .map(|s| s.as_str()) + .as_deref() .and_then(|pr| { if let Some(version) = pr.strip_prefix("VK_VERSION_") { let (major, minor) = version.split_once('_').unwrap(); @@ -541,35 +522,28 @@ fn extensions_members(ty: &str, extensions: &IndexMap<&str, &Extension>) -> Vec< } }) .or_else(|| { - ext.deprecatedby - .as_ref() - .map(|s| s.as_str()) - .and_then(|depr| { - if depr.is_empty() { - Some(ExtensionStatus::Deprecated(None)) - } else if let Some(version) = depr.strip_prefix("VK_VERSION_") { - let (major, minor) = version.split_once('_').unwrap(); - Some(ExtensionStatus::Deprecated(Some(Replacement::Core(( - major.parse().unwrap(), - minor.parse().unwrap(), - ))))) - } else { - let member = depr.strip_prefix("VK_").unwrap().to_snake_case(); - match extensions[depr].ext_type.as_ref().unwrap().as_str() { - "device" => Some(ExtensionStatus::Deprecated(Some( - Replacement::DeviceExtension(format_ident!( - "{}", member - )), - ))), - "instance" => Some(ExtensionStatus::Deprecated(Some( - Replacement::InstanceExtension(format_ident!( - "{}", member - )), - ))), - _ => unreachable!(), - } + ext.deprecatedby.as_deref().and_then(|depr| { + if depr.is_empty() { + Some(ExtensionStatus::Deprecated(None)) + } else if let Some(version) = depr.strip_prefix("VK_VERSION_") { + let (major, minor) = version.split_once('_').unwrap(); + Some(ExtensionStatus::Deprecated(Some(Replacement::Core(( + major.parse().unwrap(), + minor.parse().unwrap(), + ))))) + } else { + let member = depr.strip_prefix("VK_").unwrap().to_snake_case(); + match extensions[depr].ext_type.as_ref().unwrap().as_str() { + "device" => Some(ExtensionStatus::Deprecated(Some( + Replacement::DeviceExtension(format_ident!("{}", member)), + ))), + "instance" => Some(ExtensionStatus::Deprecated(Some( + Replacement::InstanceExtension(format_ident!("{}", member)), + ))), + _ => unreachable!(), } - }) + } + }) }), }; make_doc(&mut member); diff --git a/vulkano/autogen/features.rs b/vulkano/autogen/features.rs index 65a0c0ec..63f3b141 100644 --- a/vulkano/autogen/features.rs +++ b/vulkano/autogen/features.rs @@ -203,18 +203,22 @@ fn features_output(members: &[FeaturesMember]) -> TokenStream { quote! { self.#ffi_member.as_mut().map(|s| &mut s #ffi_member_field .#ffi_name) } }); quote! { - [ + if let Some(f) = [ #(#ffi_members),* - ].into_iter().flatten().next().map(|f| *f = features.#name as ash::vk::Bool32); + ].into_iter().flatten().next() { + *f = features.#name as ash::vk::Bool32; + } } } else { let ffi_members = ffi_members.iter().map(|(ffi_member, ffi_member_field)| { quote! { &mut self.#ffi_member #ffi_member_field .#ffi_name } }); quote! { - [ + if let Some(f) = [ #(#ffi_members),* - ].into_iter().next().map(|f| *f = features.#name as ash::vk::Bool32); + ].into_iter().next() { + *f = features.#name as ash::vk::Bool32; + } } } }, @@ -378,8 +382,8 @@ fn features_members(types: &HashMap<&str, (&Type, Vec<&str>)>) -> Vec)>) -> Vec TokenStream { &mut self, api_version: Version, device_extensions: &DeviceExtensions, - instance_extensions: &InstanceExtensions, + _instance_extensions: &InstanceExtensions, ) { self.features_vulkan10 = Default::default(); let head = &mut self.features_vulkan10; @@ -646,8 +650,7 @@ fn sorted_structs<'a>( let mut structs: Vec<_> = types .values() .filter(|(ty, _)| { - ty.structextends.as_ref().map(|s| s.as_str()) - == Some("VkPhysicalDeviceFeatures2,VkDeviceCreateInfo") + ty.structextends.as_deref() == Some("VkPhysicalDeviceFeatures2,VkDeviceCreateInfo") }) .collect(); let regex = Regex::new(r"^VkPhysicalDeviceVulkan\d+Features$").unwrap(); @@ -661,17 +664,9 @@ fn sorted_structs<'a>( { let (major, minor) = version.split_once('_').unwrap(); major.parse::().unwrap() << 22 | minor.parse::().unwrap() << 12 - } else if provided_by - .iter() - .find(|s| s.starts_with("VK_KHR_")) - .is_some() - { + } else if provided_by.iter().any(|s| s.starts_with("VK_KHR_")) { i32::MAX - 2 - } else if provided_by - .iter() - .find(|s| s.starts_with("VK_EXT_")) - .is_some() - { + } else if provided_by.iter().any(|s| s.starts_with("VK_EXT_")) { i32::MAX - 1 } else { i32::MAX diff --git a/vulkano/autogen/fns.rs b/vulkano/autogen/fns.rs index 58bc8f11..072319d8 100644 --- a/vulkano/autogen/fns.rs +++ b/vulkano/autogen/fns.rs @@ -90,7 +90,7 @@ fn fns_output(extension_members: &[FnsMember], fns_level: &str, doc: &str) -> To impl std::fmt::Debug for #struct_name { #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { Ok(()) } } diff --git a/vulkano/autogen/formats.rs b/vulkano/autogen/formats.rs index dd3d4ff5..9f5d0ae1 100644 --- a/vulkano/autogen/formats.rs +++ b/vulkano/autogen/formats.rs @@ -475,8 +475,8 @@ fn formats_members(formats: &[&Format]) -> Vec { let name = format_ident!("{}", parts.join("_")); let mut member = FormatMember { - name: name.clone(), - ffi_name: ffi_name.clone(), + name, + ffi_name, aspect_color: false, aspect_depth: false, @@ -489,13 +489,13 @@ fn formats_members(formats: &[&Format]) -> Vec { block_size: None, compatibility: format_ident!( "Class_{}", - format.class.replace("-", "").replace(" ", "_") + format.class.replace('-', "").replace(' ', "_") ), components: [0u8; 4], compression: format .compressed .as_ref() - .map(|c| format_ident!("{}", c.replace(" ", "_"))), + .map(|c| format_ident!("{}", c.replace(' ', "_"))), planes: vec![], rust_type: None, texels_per_block: format.texelsPerBlock, @@ -585,7 +585,7 @@ fn formats_members(formats: &[&Format]) -> Vec { captures.get(3).unwrap().as_str().parse().unwrap(), ]; } else { - match format.chroma.as_ref().map(|s| s.as_str()) { + match format.chroma.as_deref() { Some("420") => member.block_extent = [2, 2, 1], Some("422") => member.block_extent = [2, 1, 1], _ => (), diff --git a/vulkano/autogen/mod.rs b/vulkano/autogen/mod.rs index 3f225cde..c6d63321 100644 --- a/vulkano/autogen/mod.rs +++ b/vulkano/autogen/mod.rs @@ -63,7 +63,7 @@ fn write_file(file: impl AsRef, source: impl AsRef, content: impl Dis // It should not be edited manually. Changes should be made by editing autogen.\n\ \n\n{}", source.as_ref(), - content.to_string(), + content, ) .unwrap(); @@ -98,15 +98,15 @@ pub struct VkRegistryData<'r> { impl<'r> VkRegistryData<'r> { fn new(registry: &'r Registry) -> Self { - let aliases = Self::get_aliases(®istry); - let extensions = Self::get_extensions(®istry); - let features = Self::get_features(®istry); - let formats = Self::get_formats(®istry); + let aliases = Self::get_aliases(registry); + let extensions = Self::get_extensions(registry); + let features = Self::get_features(registry); + let formats = Self::get_formats(registry); let spirv_capabilities = Self::get_spirv_capabilities(registry); let spirv_extensions = Self::get_spirv_extensions(registry); - let errors = Self::get_errors(®istry, &features, &extensions); - let types = Self::get_types(®istry, &aliases, &features, &extensions); - let header_version = Self::get_header_version(®istry); + let errors = Self::get_errors(registry, &features, &extensions); + let types = Self::get_types(registry, &aliases, &features, &extensions); + let header_version = Self::get_header_version(registry); VkRegistryData { header_version, @@ -162,7 +162,7 @@ impl<'r> VkRegistryData<'r> { if let RegistryChild::Types(types) = child { return Some(types.children.iter().filter_map(|ty| { if let TypesChild::Type(ty) = ty { - if let Some(alias) = ty.alias.as_ref().map(|s| s.as_str()) { + if let Some(alias) = ty.alias.as_deref() { return Some((ty.name.as_ref().unwrap().as_str(), alias)); } } @@ -191,7 +191,7 @@ impl<'r> VkRegistryData<'r> { }) if name == "VkResult" => Some(children.iter().filter_map(|en| { if let EnumsChild::Enum(en) = en { if let EnumSpec::Value { value, .. } = &en.spec { - if value.starts_with("-") { + if value.starts_with('-') { return Some(en.name.as_str()); } } @@ -238,13 +238,11 @@ impl<'r> VkRegistryData<'r> { .iter() .filter_map(|child| { if let RegistryChild::Extensions(ext) = child { - return Some(ext.children.iter().filter_map(|ext| { - if ext.supported.as_ref().map(|s| s.as_str()) == Some("vulkan") - && ext.obsoletedby.is_none() - { - return Some(ext); + return Some(ext.children.iter().filter(|ext| { + if ext.supported.as_deref() == Some("vulkan") && ext.obsoletedby.is_none() { + return true; } - None + false })); } None @@ -281,7 +279,7 @@ impl<'r> VkRegistryData<'r> { .collect() } - fn get_formats<'a>(registry: &'a Registry) -> Vec<&'a Format> { + fn get_formats(registry: &Registry) -> Vec<&Format> { registry .0 .iter() @@ -295,7 +293,7 @@ impl<'r> VkRegistryData<'r> { .collect() } - fn get_spirv_capabilities<'a>(registry: &'a Registry) -> Vec<&'a SpirvExtOrCap> { + fn get_spirv_capabilities(registry: &Registry) -> Vec<&SpirvExtOrCap> { registry .0 .iter() @@ -309,7 +307,7 @@ impl<'r> VkRegistryData<'r> { .collect() } - fn get_spirv_extensions<'a>(registry: &'a Registry) -> Vec<&'a SpirvExtOrCap> { + fn get_spirv_extensions(registry: &Registry) -> Vec<&SpirvExtOrCap> { registry .0 .iter() diff --git a/vulkano/autogen/properties.rs b/vulkano/autogen/properties.rs index d9306bd2..2f56deb0 100644 --- a/vulkano/autogen/properties.rs +++ b/vulkano/autogen/properties.rs @@ -92,7 +92,7 @@ fn properties_output(members: &[PropertiesMember]) -> TokenStream { quote! { #name: [ #(#ffi_members),* - ].into_iter().flatten().next().and_then(|x| <#ty>::from_vulkan(x)), + ].into_iter().flatten().next().and_then(<#ty>::from_vulkan), } } else { let ffi_members = ffi_members.iter().map(|(ffi_member, ffi_member_field)| { @@ -102,7 +102,7 @@ fn properties_output(members: &[PropertiesMember]) -> TokenStream { quote! { #name: [ #(#ffi_members),* - ].into_iter().next().and_then(|x| <#ty>::from_vulkan(x)).unwrap(), + ].into_iter().next().and_then(<#ty>::from_vulkan).unwrap(), } } }, @@ -151,11 +151,11 @@ fn properties_members(types: &HashMap<&str, (&Type, Vec<&str>)>) -> Vec TokenStream { #(#make_chain_items)* } - pub(crate) fn head_as_ref(&self) -> &ash::vk::PhysicalDeviceProperties2KHR { - &self.properties_vulkan10 - } - pub(crate) fn head_as_mut(&mut self) -> &mut ash::vk::PhysicalDeviceProperties2KHR { &mut self.properties_vulkan10 } @@ -367,9 +363,7 @@ fn sorted_structs<'a>( ) -> Vec<&'a (&'a Type, Vec<&'a str>)> { let mut structs: Vec<_> = types .values() - .filter(|(ty, _)| { - ty.structextends.as_ref().map(|s| s.as_str()) == Some("VkPhysicalDeviceProperties2") - }) + .filter(|(ty, _)| ty.structextends.as_deref() == Some("VkPhysicalDeviceProperties2")) .collect(); let regex = Regex::new(r"^VkPhysicalDeviceVulkan\d+Properties$").unwrap(); structs.sort_unstable_by_key(|&(ty, provided_by)| { @@ -382,17 +376,9 @@ fn sorted_structs<'a>( { let (major, minor) = version.split_once('_').unwrap(); major.parse::().unwrap() << 22 | minor.parse::().unwrap() << 12 - } else if provided_by - .iter() - .find(|s| s.starts_with("VK_KHR_")) - .is_some() - { + } else if provided_by.iter().any(|s| s.starts_with("VK_KHR_")) { i32::MAX - 2 - } else if provided_by - .iter() - .find(|s| s.starts_with("VK_EXT_")) - .is_some() - { + } else if provided_by.iter().any(|s| s.starts_with("VK_EXT_")) { i32::MAX - 1 } else { i32::MAX diff --git a/vulkano/autogen/spirv_parse.rs b/vulkano/autogen/spirv_parse.rs index 29ca9326..e6eb462d 100644 --- a/vulkano/autogen/spirv_parse.rs +++ b/vulkano/autogen/spirv_parse.rs @@ -221,13 +221,14 @@ fn instruction_output(members: &[InstructionMember], spec_constant: bool) -> Tok }; quote! { - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug, PartialEq, Eq)] #[doc=#doc] pub enum #enum_name { #(#struct_items)* } impl #enum_name { + #[allow(dead_code)] fn parse(reader: &mut InstructionReader) -> Result { let opcode = (reader.next_u32()? & 0xffff) as u16; @@ -264,7 +265,7 @@ fn instruction_members(grammar: &SpirvGrammar) -> Vec { has_result_type_id = true; format_ident!("result_type_id") } else { - to_member_name(&operand.kind, operand.name.as_ref().map(|x| x.as_str())) + to_member_name(&operand.kind, operand.name.as_deref()) }; *operand_names.entry(name.clone()).or_insert(0) += 1; @@ -293,11 +294,7 @@ fn instruction_members(grammar: &SpirvGrammar) -> Vec { _ => parse.clone(), }; - OperandMember { - name, - ty, - parse: parse.clone(), - } + OperandMember { name, ty, parse } }) .collect::>(); @@ -387,13 +384,14 @@ fn bit_enum_output(enums: &[(Ident, Vec)]) -> TokenStream { ); quote! { - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug, PartialEq, Eq)] #[allow(non_camel_case_types)] pub struct #name { #(#members_items)* } impl #name { + #[allow(dead_code)] fn parse(reader: &mut InstructionReader) -> Result<#name, ParseError> { let value = reader.next_u32()?; @@ -453,10 +451,7 @@ fn bit_enum_members(grammar: &SpirvGrammar) -> Vec<(Ident, Vec)> .parameters .iter() .map(|param| { - let name = to_member_name( - ¶m.kind, - param.name.as_ref().map(|x| x.as_str()), - ); + let name = to_member_name(¶m.kind, param.name.as_deref()); let (ty, parse) = parameter_kinds[param.kind.as_str()].clone(); OperandMember { name, ty, parse } @@ -529,7 +524,7 @@ fn value_enum_output(enums: &[(Ident, Vec)]) -> TokenStream { let derives = match name_string.as_str() { "ExecutionModel" => quote! { #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] }, - _ => quote! { #[derive(Clone, Debug, PartialEq)] }, + _ => quote! { #[derive(Clone, Debug, PartialEq, Eq)] }, }; quote! { @@ -540,6 +535,7 @@ fn value_enum_output(enums: &[(Ident, Vec)]) -> TokenStream { } impl #name { + #[allow(dead_code)] fn parse(reader: &mut InstructionReader) -> Result<#name, ParseError> { Ok(match reader.next_u32()? { #(#parse_items)* @@ -586,10 +582,7 @@ fn value_enum_members(grammar: &SpirvGrammar) -> Vec<(Ident, Vec .parameters .iter() .map(|param| { - let name = to_member_name( - ¶m.kind, - param.name.as_ref().map(|x| x.as_str()), - ); + let name = to_member_name(¶m.kind, param.name.as_deref()); let (ty, parse) = parameter_kinds[param.kind.as_str()].clone(); OperandMember { name, ty, parse } diff --git a/vulkano/src/buffer/cpu_access.rs b/vulkano/src/buffer/cpu_access.rs index 7548f609..e3664c7f 100644 --- a/vulkano/src/buffer/cpu_access.rs +++ b/vulkano/src/buffer/cpu_access.rs @@ -41,7 +41,7 @@ use std::{ mem::size_of, ops::{Deref, DerefMut, Range}, ptr, - sync::{atomic::AtomicUsize, Arc}, + sync::Arc, }; /// Buffer whose content is accessible by the CPU. @@ -68,18 +68,6 @@ where marker: PhantomData>, } -#[derive(Debug)] -enum CurrentGpuAccess { - NonExclusive { - // Number of non-exclusive GPU accesses. Can be 0. - num: AtomicUsize, - }, - Exclusive { - // Number of exclusive locks. Cannot be 0. If 0 is reached, we must jump to `NonExclusive`. - num: usize, - }, -} - impl CpuAccessibleBuffer where T: BufferContents, @@ -344,13 +332,12 @@ where mapped_memory .invalidate_range(memory_range.clone()) .unwrap(); - mapped_memory.read(memory_range.clone()).unwrap() + mapped_memory.read(memory_range).unwrap() }; Ok(ReadLock { inner: self, buffer_range, - memory_range, data: T::from_bytes(bytes).unwrap(), }) } @@ -483,7 +470,6 @@ where { inner: &'a CpuAccessibleBuffer, buffer_range: Range, - memory_range: Range, data: &'a T, } @@ -635,7 +621,7 @@ mod tests { #[test] fn create_empty_buffer() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); const EMPTY: [i32; 0] = []; diff --git a/vulkano/src/buffer/cpu_pool.rs b/vulkano/src/buffer/cpu_pool.rs index fd53404e..85a36811 100644 --- a/vulkano/src/buffer/cpu_pool.rs +++ b/vulkano/src/buffer/cpu_pool.rs @@ -202,7 +202,7 @@ where device, pool, current_buffer: Mutex::new(None), - usage: usage.clone(), + usage, marker: PhantomData, } } @@ -345,7 +345,7 @@ where I: IntoIterator, I::IntoIter: ExactSizeIterator, { - self.chunk_impl(data.into_iter()).map(|ok| Arc::new(ok)) + self.chunk_impl(data.into_iter()).map(Arc::new) } fn chunk_impl( @@ -435,7 +435,7 @@ where memory: mem, chunks_in_use: Mutex::new(vec![]), next_index: AtomicU64::new(0), - capacity: capacity, + capacity, })); Ok(()) @@ -612,7 +612,7 @@ where device: self.device.clone(), pool: self.pool.clone(), current_buffer: Mutex::new(buf.clone()), - usage: self.usage.clone(), + usage: self.usage, marker: PhantomData, } } diff --git a/vulkano/src/buffer/device_local.rs b/vulkano/src/buffer/device_local.rs index c8d97909..875fff25 100644 --- a/vulkano/src/buffer/device_local.rs +++ b/vulkano/src/buffer/device_local.rs @@ -140,13 +140,6 @@ where marker: PhantomData>, } -#[derive(Debug, Copy, Clone)] -enum GpuAccess { - None, - NonExclusive { num: u32 }, - Exclusive { num: u32 }, -} - impl DeviceLocalBuffer where T: BufferContents, @@ -408,7 +401,7 @@ where let (buffer, mem_reqs) = Self::build_buffer(&device, size, usage, &queue_families)?; let memory = alloc_dedicated_with_exportable_fd( - device.clone(), + device, &mem_reqs, AllocLayout::Linear, MappingRequirement::DoNotMap, @@ -627,7 +620,7 @@ mod tests { CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), false, 0).unwrap(); let mut cbb = AutoCommandBufferBuilder::primary( - device.clone(), + device, queue.family(), CommandBufferUsage::MultipleSubmit, ) @@ -637,7 +630,7 @@ mod tests { let _ = cbb .build() .unwrap() - .execute(queue.clone()) + .execute(queue) .unwrap() .then_signal_fence_and_flush() .unwrap(); @@ -666,7 +659,7 @@ mod tests { .unwrap(); let mut cbb = AutoCommandBufferBuilder::primary( - device.clone(), + device, queue.family(), CommandBufferUsage::MultipleSubmit, ) @@ -676,7 +669,7 @@ mod tests { let _ = cbb .build() .unwrap() - .execute(queue.clone()) + .execute(queue) .unwrap() .then_signal_fence_and_flush() .unwrap(); diff --git a/vulkano/src/buffer/slice.rs b/vulkano/src/buffer/slice.rs index 28bd62e9..8a5466af 100644 --- a/vulkano/src/buffer/slice.rs +++ b/vulkano/src/buffer/slice.rs @@ -74,7 +74,7 @@ impl BufferSlice { marker: PhantomData, resource: r, offset: 0, - size: size, + size, }) } diff --git a/vulkano/src/buffer/sys.rs b/vulkano/src/buffer/sys.rs index 44c232b5..0dd1b806 100644 --- a/vulkano/src/buffer/sys.rs +++ b/vulkano/src/buffer/sys.rs @@ -502,7 +502,7 @@ impl fmt::Display for BufferCreationError { fmt, "the specified size exceeded the value of the `max_buffer_size` limit" ), - Self::SharingInvalidQueueFamilyId { id } => { + Self::SharingInvalidQueueFamilyId { .. } => { write!(fmt, "the sharing mode was set to `Concurrent`, but one of the specified queue family ids was not valid") } } diff --git a/vulkano/src/buffer/view.rs b/vulkano/src/buffer/view.rs index f23f9495..2bf03797 100644 --- a/vulkano/src/buffer/view.rs +++ b/vulkano/src/buffer/view.rs @@ -475,20 +475,17 @@ mod tests { #[test] fn create_uniform() { // `VK_FORMAT_R8G8B8A8_UNORM` guaranteed to be a supported format - let (device, queue) = gfx_dev_and_queue!(); + let (_device, queue) = gfx_dev_and_queue!(); let usage = BufferUsage { uniform_texel_buffer: true, ..BufferUsage::none() }; - let (buffer, _) = DeviceLocalBuffer::<[[u8; 4]]>::from_iter( - (0..128).map(|_| [0; 4]), - usage, - queue.clone(), - ) - .unwrap(); - let view = BufferView::new( + let (buffer, _) = + DeviceLocalBuffer::<[[u8; 4]]>::from_iter((0..128).map(|_| [0; 4]), usage, queue) + .unwrap(); + BufferView::new( buffer, BufferViewCreateInfo { format: Some(Format::R8G8B8A8_UNORM), @@ -501,19 +498,16 @@ mod tests { #[test] fn create_storage() { // `VK_FORMAT_R8G8B8A8_UNORM` guaranteed to be a supported format - let (device, queue) = gfx_dev_and_queue!(); + let (_device, queue) = gfx_dev_and_queue!(); let usage = BufferUsage { storage_texel_buffer: true, ..BufferUsage::none() }; - let (buffer, _) = DeviceLocalBuffer::<[[u8; 4]]>::from_iter( - (0..128).map(|_| [0; 4]), - usage, - queue.clone(), - ) - .unwrap(); + let (buffer, _) = + DeviceLocalBuffer::<[[u8; 4]]>::from_iter((0..128).map(|_| [0; 4]), usage, queue) + .unwrap(); BufferView::new( buffer, BufferViewCreateInfo { @@ -527,7 +521,7 @@ mod tests { #[test] fn create_storage_atomic() { // `VK_FORMAT_R32_UINT` guaranteed to be a supported format for atomics - let (device, queue) = gfx_dev_and_queue!(); + let (_device, queue) = gfx_dev_and_queue!(); let usage = BufferUsage { storage_texel_buffer: true, @@ -535,8 +529,7 @@ mod tests { }; let (buffer, _) = - DeviceLocalBuffer::<[u32]>::from_iter((0..128).map(|_| 0), usage, queue.clone()) - .unwrap(); + DeviceLocalBuffer::<[u32]>::from_iter((0..128).map(|_| 0), usage, queue).unwrap(); BufferView::new( buffer, BufferViewCreateInfo { @@ -550,12 +543,12 @@ mod tests { #[test] fn wrong_usage() { // `VK_FORMAT_R8G8B8A8_UNORM` guaranteed to be a supported format - let (device, queue) = gfx_dev_and_queue!(); + let (_device, queue) = gfx_dev_and_queue!(); let (buffer, _) = DeviceLocalBuffer::<[[u8; 4]]>::from_iter( (0..128).map(|_| [0; 4]), BufferUsage::none(), - queue.clone(), + queue, ) .unwrap(); @@ -573,7 +566,7 @@ mod tests { #[test] fn unsupported_format() { - let (device, queue) = gfx_dev_and_queue!(); + let (_device, queue) = gfx_dev_and_queue!(); let usage = BufferUsage { uniform_texel_buffer: true, @@ -581,12 +574,9 @@ mod tests { ..BufferUsage::none() }; - let (buffer, _) = DeviceLocalBuffer::<[[f64; 4]]>::from_iter( - (0..128).map(|_| [0.0; 4]), - usage, - queue.clone(), - ) - .unwrap(); + let (buffer, _) = + DeviceLocalBuffer::<[[f64; 4]]>::from_iter((0..128).map(|_| [0.0; 4]), usage, queue) + .unwrap(); // TODO: what if R64G64B64A64_SFLOAT is supported? match BufferView::new( diff --git a/vulkano/src/command_buffer/auto.rs b/vulkano/src/command_buffer/auto.rs index 81dcf374..87f457da 100644 --- a/vulkano/src/command_buffer/auto.rs +++ b/vulkano/src/command_buffer/auto.rs @@ -164,7 +164,7 @@ impl AutoCommandBufferBuilder { unsafe { - Ok(AutoCommandBufferBuilder::begin( + AutoCommandBufferBuilder::begin( device, queue_family, CommandBufferLevel::Secondary, @@ -173,7 +173,7 @@ impl AutoCommandBufferBuilder AutoCommandBufferBuilder { if let Some(inheritance_info) = &inheritance_info { let &CommandBufferInheritanceInfo { ref render_pass, - occlusion_query, - query_statistics_flags, + occlusion_query: _, + query_statistics_flags: _, _ne: _, } = inheritance_info; @@ -257,7 +257,7 @@ impl AutoCommandBufferBuilder { fn validate_begin( device: &Device, - queue_family: &QueueFamily, + _queue_family: &QueueFamily, level: CommandBufferLevel, begin_info: &CommandBufferBeginInfo, ) -> Result<(), CommandBufferBeginError> { @@ -265,7 +265,7 @@ impl AutoCommandBufferBuilder { let properties = physical_device.properties(); let &CommandBufferBeginInfo { - usage, + usage: _, ref inheritance_info, _ne: _, } = &begin_info; @@ -317,7 +317,7 @@ impl AutoCommandBufferBuilder { ref color_attachment_formats, depth_attachment_format, stencil_attachment_format, - rasterization_samples, + rasterization_samples: _, // TODO: ? } = rendering_info; // VUID-VkCommandBufferInheritanceRenderingInfo-multiview-06008 @@ -563,7 +563,7 @@ where Ok(PrimaryAutoCommandBuffer { inner: self.inner.build()?, - pool_alloc: self.pool_builder_alloc.into_alloc(), + _pool_alloc: self.pool_builder_alloc.into_alloc(), submit_state, }) } @@ -592,7 +592,7 @@ where Ok(SecondaryAutoCommandBuffer { inner: self.inner.build()?, - pool_alloc: self.pool_builder_alloc.into_alloc(), + _pool_alloc: self.pool_builder_alloc.into_alloc(), inheritance_info: self.inheritance_info.unwrap(), submit_state, }) @@ -641,13 +641,13 @@ impl AutoCommandBufferBuilder { // Render passes must be compatible. if !pipeline_subpass .render_pass() - .is_compatible_with(&state.subpass.render_pass()) + .is_compatible_with(state.subpass.render_pass()) { return Err(AutoCommandBufferBuilderContextError::IncompatibleRenderPass); } } - RenderPassStateType::BeginRendering(state) => { - let pipeline_rendering_info = match pipeline.render_pass() { + RenderPassStateType::BeginRendering(_state) => { + let _pipeline_rendering_info = match pipeline.render_pass() { PipelineRenderPassType::BeginRenderPass(_) => todo!(), PipelineRenderPassType::BeginRendering(rendering_info) => rendering_info, }; @@ -677,7 +677,7 @@ impl AutoCommandBufferBuilder { // Render passes must be compatible. if !pipeline_subpass .render_pass() - .is_compatible_with(&info.subpass.render_pass()) + .is_compatible_with(info.subpass.render_pass()) { return Err( AutoCommandBufferBuilderContextError::IncompatibleRenderPass, @@ -685,7 +685,7 @@ impl AutoCommandBufferBuilder { } } CommandBufferInheritanceRenderPassType::BeginRendering(_) => { - let pipeline_rendering_info = match pipeline.render_pass() { + let _pipeline_rendering_info = match pipeline.render_pass() { PipelineRenderPassType::BeginRenderPass(_) => todo!(), PipelineRenderPassType::BeginRendering(rendering_info) => { rendering_info @@ -725,7 +725,7 @@ unsafe impl DeviceOwned for AutoCommandBufferBuilder { pub struct PrimaryAutoCommandBuffer

{ inner: SyncCommandBuffer, - pool_alloc: P, // Safety: must be dropped after `inner` + _pool_alloc: P, // Safety: must be dropped after `inner` // Tracks usage of the command buffer on the GPU. submit_state: SubmitState, @@ -839,7 +839,7 @@ where pub struct SecondaryAutoCommandBuffer

{ inner: SyncCommandBuffer, - pool_alloc: P, // Safety: must be dropped after `inner` + _pool_alloc: P, // Safety: must be dropped after `inner` inheritance_info: CommandBufferInheritanceInfo, // Tracks usage of the command buffer on the GPU. @@ -1216,7 +1216,7 @@ mod tests { .unwrap(); let mut cbb = AutoCommandBufferBuilder::primary( - device.clone(), + device, queue.family(), CommandBufferUsage::OneTimeSubmit, ) @@ -1230,14 +1230,14 @@ mod tests { ..Default::default() }] .into(), - ..CopyBufferInfoTyped::buffers(source.clone(), destination.clone()) + ..CopyBufferInfoTyped::buffers(source, destination.clone()) }) .unwrap(); let cb = cbb.build().unwrap(); let future = cb - .execute(queue.clone()) + .execute(queue) .unwrap() .then_signal_fence_and_flush() .unwrap(); @@ -1296,7 +1296,7 @@ mod tests { let cb1 = builder.build().unwrap(); let mut builder = AutoCommandBufferBuilder::primary( - device.clone(), + device, queue.family(), CommandBufferUsage::SimultaneousUse, ) @@ -1316,7 +1316,7 @@ mod tests { std::mem::drop(cb1); // Now that the first cb is dropped, we should be able to record. - builder.execute_commands(secondary.clone()).unwrap(); + builder.execute_commands(secondary).unwrap(); } } @@ -1333,7 +1333,7 @@ mod tests { .unwrap(); let mut builder = AutoCommandBufferBuilder::primary( - device.clone(), + device, queue.family(), CommandBufferUsage::OneTimeSubmit, ) @@ -1355,7 +1355,7 @@ mod tests { let cb = builder.build().unwrap(); let future = cb - .execute(queue.clone()) + .execute(queue) .unwrap() .then_signal_fence_and_flush() .unwrap(); @@ -1379,7 +1379,7 @@ mod tests { .unwrap(); let mut builder = AutoCommandBufferBuilder::primary( - device.clone(), + device, queue.family(), CommandBufferUsage::OneTimeSubmit, ) @@ -1394,7 +1394,7 @@ mod tests { ..Default::default() }] .into(), - ..CopyBufferInfoTyped::buffers(source.clone(), source.clone()) + ..CopyBufferInfoTyped::buffers(source.clone(), source) }), Err(CopyError::OverlappingRegions { src_region_index: 0, diff --git a/vulkano/src/command_buffer/commands/bind_push.rs b/vulkano/src/command_buffer/commands/bind_push.rs index 566b47f7..48683dcb 100644 --- a/vulkano/src/command_buffer/commands/bind_push.rs +++ b/vulkano/src/command_buffer/commands/bind_push.rs @@ -658,7 +658,7 @@ impl SyncCommandBufferBuilder { let set_resources = match state .descriptor_sets .entry(set_num) - .or_insert(SetOrPush::Push(DescriptorSetResources::new(layout, 0))) + .or_insert_with(|| SetOrPush::Push(DescriptorSetResources::new(layout, 0))) { SetOrPush::Push(set_resources) => set_resources, _ => unreachable!(), @@ -720,8 +720,7 @@ impl<'b> SyncCommandBufferBuilderBindDescriptorSets<'b> { let dynamic_offsets = self .descriptor_sets .iter() - .map(|x| x.as_ref().1.iter().copied()) - .flatten(); + .flat_map(|x| x.as_ref().1.iter().copied()); out.bind_descriptor_sets( self.pipeline_bind_point, @@ -775,7 +774,7 @@ impl<'a> SyncCommandBufferBuilderBindVertexBuffer<'a> { struct Cmd { first_set: u32, inner: Mutex>, - buffers: SmallVec<[Arc; 4]>, + _buffers: SmallVec<[Arc; 4]>, } impl Command for Cmd { @@ -798,7 +797,7 @@ impl<'a> SyncCommandBufferBuilderBindVertexBuffer<'a> { self.builder.commands.push(Box::new(Cmd { first_set, inner: Mutex::new(Some(self.inner)), - buffers: self.buffers, + _buffers: self.buffers, })); } } diff --git a/vulkano/src/command_buffer/commands/debug.rs b/vulkano/src/command_buffer/commands/debug.rs index 9c72282c..5eb68501 100644 --- a/vulkano/src/command_buffer/commands/debug.rs +++ b/vulkano/src/command_buffer/commands/debug.rs @@ -41,7 +41,7 @@ impl AutoCommandBufferBuilder { fn validate_begin_debug_utils_label( &self, - label_info: &mut DebugUtilsLabel, + _label_info: &mut DebugUtilsLabel, ) -> Result<(), DebugUtilsError> { if !self .device() @@ -123,7 +123,7 @@ impl AutoCommandBufferBuilder { fn validate_insert_debug_utils_label( &self, - label_info: &mut DebugUtilsLabel, + _label_info: &mut DebugUtilsLabel, ) -> Result<(), DebugUtilsError> { if !self .device() diff --git a/vulkano/src/command_buffer/commands/dynamic_state.rs b/vulkano/src/command_buffer/commands/dynamic_state.rs index 46934d6e..dabf3a70 100644 --- a/vulkano/src/command_buffer/commands/dynamic_state.rs +++ b/vulkano/src/command_buffer/commands/dynamic_state.rs @@ -59,7 +59,7 @@ impl AutoCommandBufferBuilder { fn validate_set_blend_constants( &self, - constants: [f32; 4], + _constants: [f32; 4], ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::BlendConstants) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -162,7 +162,7 @@ impl AutoCommandBufferBuilder { self } - fn validate_set_cull_mode(&self, cull_mode: CullMode) -> Result<(), SetDynamicStateError> { + fn validate_set_cull_mode(&self, _cull_mode: CullMode) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::CullMode) { return Err(SetDynamicStateError::PipelineHasFixedState); } @@ -213,9 +213,9 @@ impl AutoCommandBufferBuilder { fn validate_set_depth_bias( &self, - constant_factor: f32, + _constant_factor: f32, clamp: f32, - slope_factor: f32, + _slope_factor: f32, ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::DepthBias) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -257,7 +257,7 @@ impl AutoCommandBufferBuilder { self } - fn validate_set_depth_bias_enable(&self, enable: bool) -> Result<(), SetDynamicStateError> { + fn validate_set_depth_bias_enable(&self, _enable: bool) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::DepthBiasEnable) { return Err(SetDynamicStateError::PipelineHasFixedState); } @@ -352,7 +352,7 @@ impl AutoCommandBufferBuilder { fn validate_set_depth_bounds_test_enable( &self, - enable: bool, + _enable: bool, ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::DepthBoundsTestEnable) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -398,7 +398,7 @@ impl AutoCommandBufferBuilder { fn validate_set_depth_compare_op( &self, - compare_op: CompareOp, + _compare_op: CompareOp, ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::DepthCompareOp) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -442,7 +442,7 @@ impl AutoCommandBufferBuilder { self } - fn validate_set_depth_test_enable(&self, enable: bool) -> Result<(), SetDynamicStateError> { + fn validate_set_depth_test_enable(&self, _enable: bool) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::DepthTestEnable) { return Err(SetDynamicStateError::PipelineHasFixedState); } @@ -485,7 +485,7 @@ impl AutoCommandBufferBuilder { self } - fn validate_set_depth_write_enable(&self, enable: bool) -> Result<(), SetDynamicStateError> { + fn validate_set_depth_write_enable(&self, _enable: bool) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::DepthWriteEnable) { return Err(SetDynamicStateError::PipelineHasFixedState); } @@ -600,7 +600,7 @@ impl AutoCommandBufferBuilder { self } - fn validate_set_front_face(&self, face: FrontFace) -> Result<(), SetDynamicStateError> { + fn validate_set_front_face(&self, _face: FrontFace) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::FrontFace) { return Err(SetDynamicStateError::PipelineHasFixedState); } @@ -646,7 +646,7 @@ impl AutoCommandBufferBuilder { fn validate_set_line_stipple( &self, factor: u32, - pattern: u16, + _pattern: u16, ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::LineStipple) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -731,7 +731,7 @@ impl AutoCommandBufferBuilder { self } - fn validate_set_logic_op(&self, logic_op: LogicOp) -> Result<(), SetDynamicStateError> { + fn validate_set_logic_op(&self, _logic_op: LogicOp) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::LogicOp) { return Err(SetDynamicStateError::PipelineHasFixedState); } @@ -848,7 +848,7 @@ impl AutoCommandBufferBuilder { fn validate_set_primitive_restart_enable( &self, - enable: bool, + _enable: bool, ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::PrimitiveRestartEnable) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -970,7 +970,7 @@ impl AutoCommandBufferBuilder { fn validate_set_rasterizer_discard_enable( &self, - enable: bool, + _enable: bool, ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::RasterizerDiscardEnable) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -1156,8 +1156,8 @@ impl AutoCommandBufferBuilder { fn validate_set_stencil_compare_mask( &self, - faces: StencilFaces, - compare_mask: u32, + _faces: StencilFaces, + _compare_mask: u32, ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::StencilCompareMask) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -1202,11 +1202,11 @@ impl AutoCommandBufferBuilder { fn validate_set_stencil_op( &self, - faces: StencilFaces, - fail_op: StencilOp, - pass_op: StencilOp, - depth_fail_op: StencilOp, - compare_op: CompareOp, + _faces: StencilFaces, + _fail_op: StencilOp, + _pass_op: StencilOp, + _depth_fail_op: StencilOp, + _compare_op: CompareOp, ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::StencilOp) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -1249,8 +1249,8 @@ impl AutoCommandBufferBuilder { fn validate_set_stencil_reference( &self, - faces: StencilFaces, - reference: u32, + _faces: StencilFaces, + _reference: u32, ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::StencilReference) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -1284,7 +1284,7 @@ impl AutoCommandBufferBuilder { self } - fn validate_set_stencil_test_enable(&self, enable: bool) -> Result<(), SetDynamicStateError> { + fn validate_set_stencil_test_enable(&self, _enable: bool) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::StencilTestEnable) { return Err(SetDynamicStateError::PipelineHasFixedState); } @@ -1326,8 +1326,8 @@ impl AutoCommandBufferBuilder { fn validate_set_stencil_write_mask( &self, - faces: StencilFaces, - write_mask: u32, + _faces: StencilFaces, + _write_mask: u32, ) -> Result<(), SetDynamicStateError> { if self.has_fixed_state(DynamicState::StencilWriteMask) { return Err(SetDynamicStateError::PipelineHasFixedState); @@ -1743,9 +1743,7 @@ impl SyncCommandBufferBuilder { for (num, rectangle) in rectangles.iter().enumerate() { let num = num as u32 + first_rectangle; - self.current_state - .discard_rectangle - .insert(num, rectangle.clone()); + self.current_state.discard_rectangle.insert(num, *rectangle); } self.commands.push(Box::new(Cmd { @@ -2130,7 +2128,7 @@ impl SyncCommandBufferBuilder { for (num, scissor) in scissors.iter().enumerate() { let num = num as u32 + first_scissor; - self.current_state.scissor.insert(num, scissor.clone()); + self.current_state.scissor.insert(num, *scissor); } self.commands.push(Box::new(Cmd { @@ -2379,7 +2377,7 @@ impl UnsafeCommandBufferBuilder { let rectangles = rectangles .into_iter() - .map(|v| v.clone().into()) + .map(|v| v.into()) .collect::>(); if rectangles.is_empty() { return; @@ -2577,7 +2575,7 @@ impl UnsafeCommandBufferBuilder { ) { let scissors = scissors .into_iter() - .map(|v| ash::vk::Rect2D::from(v.clone())) + .map(ash::vk::Rect2D::from) .collect::>(); if scissors.is_empty() { return; @@ -2599,7 +2597,7 @@ impl UnsafeCommandBufferBuilder { pub unsafe fn set_scissor_with_count(&mut self, scissors: impl IntoIterator) { let scissors = scissors .into_iter() - .map(|v| ash::vk::Rect2D::from(v.clone())) + .map(ash::vk::Rect2D::from) .collect::>(); if scissors.is_empty() { return; @@ -2635,7 +2633,7 @@ impl UnsafeCommandBufferBuilder { ) { let viewports = viewports .into_iter() - .map(|v| v.clone().into()) + .map(|v| v.into()) .collect::>(); if viewports.is_empty() { return; @@ -2660,7 +2658,7 @@ impl UnsafeCommandBufferBuilder { ) { let viewports = viewports .into_iter() - .map(|v| v.clone().into()) + .map(|v| v.into()) .collect::>(); if viewports.is_empty() { return; @@ -2687,6 +2685,7 @@ impl UnsafeCommandBufferBuilder { } #[derive(Clone, Debug)] +#[allow(dead_code)] enum SetDynamicStateError { ExtensionNotEnabled { extension: &'static str, diff --git a/vulkano/src/command_buffer/commands/image.rs b/vulkano/src/command_buffer/commands/image.rs index 49e46a5b..2e3fb136 100644 --- a/vulkano/src/command_buffer/commands/image.rs +++ b/vulkano/src/command_buffer/commands/image.rs @@ -599,7 +599,7 @@ impl AutoCommandBufferBuilder { let &mut ClearColorImageInfo { ref image, image_layout, - clear_value, + clear_value: _, ref regions, _ne: _, } = clear_info; @@ -1070,7 +1070,7 @@ impl AutoCommandBufferBuilder { assert!(extent[0] != 0 && extent[1] != 0 && extent[2] != 0); let check_offset_extent = |resource: CopyErrorResource, - image_type: ImageType, + _image_type: ImageType, subresource_extent: [u32; 3], offset: [u32; 3]| -> Result<_, CopyError> { @@ -1153,7 +1153,7 @@ impl SyncCommandBufferBuilder { ref dst_image, dst_image_layout, ref regions, - filter, + filter: _, _ne: _, } = &blit_image_info; @@ -1162,9 +1162,9 @@ impl SyncCommandBufferBuilder { .flat_map(|region| { let &ImageBlit { ref src_subresource, - src_offsets, + src_offsets: _, ref dst_subresource, - dst_offsets, + dst_offsets: _, _ne: _, } = region; @@ -1251,7 +1251,7 @@ impl SyncCommandBufferBuilder { let &ClearColorImageInfo { ref image, image_layout, - clear_value, + clear_value: _, ref regions, _ne: _, } = &clear_info; @@ -1321,7 +1321,7 @@ impl SyncCommandBufferBuilder { let &ClearDepthStencilImageInfo { ref image, image_layout, - clear_value, + clear_value: _, ref regions, _ne: _, } = &clear_info; @@ -1403,10 +1403,10 @@ impl SyncCommandBufferBuilder { .flat_map(|region| { let &ImageResolve { ref src_subresource, - src_offset, + src_offset: _, ref dst_subresource, - dst_offset, - extent, + dst_offset: _, + extent: _, _ne: _, } = region; diff --git a/vulkano/src/command_buffer/commands/pipeline.rs b/vulkano/src/command_buffer/commands/pipeline.rs index d1aa721a..731b0a48 100644 --- a/vulkano/src/command_buffer/commands/pipeline.rs +++ b/vulkano/src/command_buffer/commands/pipeline.rs @@ -391,7 +391,7 @@ fn check_descriptor_sets_validity<'a, P: Pipeline>( let layout_binding = &pipeline.layout().set_layouts()[set_num as usize].bindings()[&binding_num]; - let check_buffer = |index: u32, buffer: &Arc| Ok(()); + let check_buffer = |_index: u32, _buffer: &Arc| Ok(()); let check_buffer_view = |index: u32, buffer_view: &Arc| { if layout_binding.descriptor_type == DescriptorType::StorageTexelBuffer { @@ -804,12 +804,7 @@ impl fmt::Display for InvalidDescriptorResource { Self::Missing => { write!(fmt, "no resource was bound") } - Self::SamplerImageViewIncompatible { - image_view_set_num, - image_view_binding_num, - image_view_index, - .. - } => { + Self::SamplerImageViewIncompatible { .. } => { write!( fmt, "the bound sampler samples an image view that is not compatible with it" @@ -1331,8 +1326,7 @@ fn check_index_buffer( return Err(CheckIndexBufferError::TooManyIndices { index_count, max_index_count, - } - .into()); + }); } } @@ -1432,10 +1426,7 @@ impl fmt::Display for CheckIndirectBufferError { CheckIndirectBufferError::BufferMissingUsage => { "the indirect buffer usage must be enabled on the indirect buffer" } - CheckIndirectBufferError::MaxDrawIndirectCountLimitExceeded { - limit, - requested, - } => { + CheckIndirectBufferError::MaxDrawIndirectCountLimitExceeded { .. } => { "the maximum number of indirect draws has been exceeded" } } @@ -1511,8 +1502,7 @@ fn check_vertex_buffers( return Err(CheckVertexBufferError::TooManyInstances { instance_count, max_instance_count, - } - .into()); + }); } } @@ -1536,8 +1526,7 @@ fn check_vertex_buffers( return Err(CheckVertexBufferError::TooManyInstances { instance_count, max_instance_count: max_instance_index + 1, // TODO: this can overflow - } - .into()); + }); } } } diff --git a/vulkano/src/command_buffer/commands/query.rs b/vulkano/src/command_buffer/commands/query.rs index 8b6c1c19..07f0d168 100644 --- a/vulkano/src/command_buffer/commands/query.rs +++ b/vulkano/src/command_buffer/commands/query.rs @@ -67,7 +67,7 @@ impl AutoCommandBufferBuilder { ) -> Result<(), QueryError> { // VUID-vkCmdBeginQuery-commandBuffer-cmdpool if !(self.queue_family().supports_graphics() || self.queue_family().supports_compute()) { - return Err(QueryError::NotSupportedByQueueFamily.into()); + return Err(QueryError::NotSupportedByQueueFamily); } let device = self.device(); @@ -175,7 +175,7 @@ impl AutoCommandBufferBuilder { fn validate_end_query(&self, query_pool: &QueryPool, query: u32) -> Result<(), QueryError> { // VUID-vkCmdEndQuery-commandBuffer-cmdpool if !(self.queue_family().supports_graphics() || self.queue_family().supports_compute()) { - return Err(QueryError::NotSupportedByQueueFamily.into()); + return Err(QueryError::NotSupportedByQueueFamily); } let device = self.device(); @@ -191,7 +191,7 @@ impl AutoCommandBufferBuilder { state.query_pool == query_pool.internal_object() && state.query == query }) { - return Err(QueryError::QueryNotActive.into()); + return Err(QueryError::QueryNotActive); } // VUID-vkCmdEndQuery-query-00810 @@ -256,7 +256,7 @@ impl AutoCommandBufferBuilder { || self.queue_family().supports_graphics() || self.queue_family().supports_compute()) { - return Err(QueryError::NotSupportedByQueueFamily.into()); + return Err(QueryError::NotSupportedByQueueFamily); } let device = self.device(); @@ -391,7 +391,7 @@ impl AutoCommandBufferBuilder { { // VUID-vkCmdCopyQueryPoolResults-commandBuffer-cmdpool if !(self.queue_family().supports_graphics() || self.queue_family().supports_compute()) { - return Err(QueryError::NotSupportedByQueueFamily.into()); + return Err(QueryError::NotSupportedByQueueFamily); } // VUID-vkCmdCopyQueryPoolResults-renderpass @@ -476,7 +476,7 @@ impl AutoCommandBufferBuilder { // VUID-vkCmdResetQueryPool-commandBuffer-cmdpool if !(self.queue_family().supports_graphics() || self.queue_family().supports_compute()) { - return Err(QueryError::NotSupportedByQueueFamily.into()); + return Err(QueryError::NotSupportedByQueueFamily); } let device = self.device(); @@ -494,7 +494,7 @@ impl AutoCommandBufferBuilder { if self.query_state.values().any(|state| { state.query_pool == query_pool.internal_object() && queries.contains(&state.query) }) { - return Err(QueryError::QueryIsActive.into()); + return Err(QueryError::QueryIsActive); } Ok(()) diff --git a/vulkano/src/command_buffer/commands/render_pass.rs b/vulkano/src/command_buffer/commands/render_pass.rs index 87567311..fb4dd29d 100644 --- a/vulkano/src/command_buffer/commands/render_pass.rs +++ b/vulkano/src/command_buffer/commands/render_pass.rs @@ -84,7 +84,7 @@ where fn validate_begin_render_pass( &self, render_pass_begin_info: &mut RenderPassBeginInfo, - contents: SubpassContents, + _contents: SubpassContents, ) -> Result<(), RenderPassError> { let device = self.device(); @@ -407,12 +407,12 @@ where Ok(self) } - fn validate_next_subpass(&self, contents: SubpassContents) -> Result<(), RenderPassError> { + fn validate_next_subpass(&self, _contents: SubpassContents) -> Result<(), RenderPassError> { // VUID-vkCmdNextSubpass2-renderpass let render_pass_state = self .render_pass_state .as_ref() - .ok_or_else(|| RenderPassError::ForbiddenOutsideRenderPass)?; + .ok_or(RenderPassError::ForbiddenOutsideRenderPass)?; let begin_render_pass_state = match &render_pass_state.render_pass { RenderPassStateType::BeginRenderPass(state) => state, @@ -463,7 +463,7 @@ where let render_pass_state = self .render_pass_state .as_ref() - .ok_or_else(|| RenderPassError::ForbiddenOutsideRenderPass)?; + .ok_or(RenderPassError::ForbiddenOutsideRenderPass)?; let begin_render_pass_state = match &render_pass_state.render_pass { RenderPassStateType::BeginRenderPass(state) => state, @@ -518,7 +518,7 @@ impl AutoCommandBufferBuilder { ref color_attachments, ref depth_attachment, ref stencil_attachment, - contents, + contents: _, _ne: _, } = &mut rendering_info; @@ -597,7 +597,7 @@ impl AutoCommandBufferBuilder { let &RenderingInfo { render_area_offset, render_area_extent, - layer_count, + layer_count: _, view_mask, ref color_attachments, ref depth_attachment, @@ -717,9 +717,9 @@ impl AutoCommandBufferBuilder { ref image_view, image_layout, ref resolve_info, - load_op, - store_op, - clear_value, + load_op: _, + store_op: _, + clear_value: _, _ne: _, } = attachment_info; @@ -742,7 +742,7 @@ impl AutoCommandBufferBuilder { // VUID-VkRenderingInfo-imageView-06070 match samples { Some(samples) if samples == image.samples() => (), - Some(samples) => { + Some(_) => { return Err(RenderPassError::ColorAttachmentSamplesMismatch { attachment_index, }); @@ -851,9 +851,9 @@ impl AutoCommandBufferBuilder { ref image_view, image_layout, ref resolve_info, - load_op, - store_op, - clear_value, + load_op: _, + store_op: _, + clear_value: _, _ne: _, } = attachment_info; @@ -883,7 +883,7 @@ impl AutoCommandBufferBuilder { // VUID-VkRenderingInfo-imageView-06070 match samples { Some(samples) if samples == image.samples() => (), - Some(samples) => { + Some(_) => { return Err(RenderPassError::DepthAttachmentSamplesMismatch); } None => samples = Some(image.samples()), @@ -961,9 +961,9 @@ impl AutoCommandBufferBuilder { ref image_view, image_layout, ref resolve_info, - load_op, - store_op, - clear_value, + load_op: _, + store_op: _, + clear_value: _, _ne: _, } = attachment_info; @@ -993,7 +993,7 @@ impl AutoCommandBufferBuilder { // VUID-VkRenderingInfo-imageView-06070 match samples { Some(samples) if samples == image.samples() => (), - Some(samples) => { + Some(_) => { return Err(RenderPassError::StencilAttachmentSamplesMismatch); } None => (), @@ -1123,13 +1123,11 @@ impl AutoCommandBufferBuilder { } fn validate_end_rendering(&self) -> Result<(), RenderPassError> { - let device = self.device(); - // VUID-vkCmdEndRendering-renderpass let render_pass_state = self .render_pass_state .as_ref() - .ok_or_else(|| RenderPassError::ForbiddenOutsideRenderPass)?; + .ok_or(RenderPassError::ForbiddenOutsideRenderPass)?; // VUID-vkCmdEndRendering-None-06161 // VUID-vkCmdEndRendering-commandBuffer-06162 @@ -1228,12 +1226,12 @@ impl AutoCommandBufferBuilder { let attachment_format = match &render_pass_state.render_pass { RenderPassStateType::BeginRenderPass(state) => { let color_attachments = &state.subpass.subpass_desc().color_attachments; - let atch_ref = color_attachments - .get(color_attachment as usize) - .ok_or_else(|| RenderPassError::ColorAttachmentIndexOutOfRange { + let atch_ref = color_attachments.get(color_attachment as usize).ok_or( + RenderPassError::ColorAttachmentIndexOutOfRange { color_attachment_index: color_attachment, num_color_attachments: color_attachments.len() as u32, - })?; + }, + )?; atch_ref.as_ref().map(|atch_ref| { let image_view = @@ -1251,7 +1249,7 @@ impl AutoCommandBufferBuilder { RenderPassStateType::BeginRendering(state) => state .color_attachments .get(color_attachment as usize) - .ok_or_else(|| RenderPassError::ColorAttachmentIndexOutOfRange { + .ok_or(RenderPassError::ColorAttachmentIndexOutOfRange { color_attachment_index: color_attachment, num_color_attachments: state.color_attachments.len() as u32, })? @@ -1278,7 +1276,7 @@ impl AutoCommandBufferBuilder { &info.subpass.subpass_desc().color_attachments; let atch_ref = color_attachments .get(color_attachment as usize) - .ok_or_else(|| { + .ok_or({ RenderPassError::ColorAttachmentIndexOutOfRange { color_attachment_index: color_attachment, num_color_attachments: color_attachments.len() @@ -1309,7 +1307,7 @@ impl AutoCommandBufferBuilder { *info .color_attachment_formats .get(color_attachment as usize) - .ok_or_else(|| { + .ok_or({ RenderPassError::ColorAttachmentIndexOutOfRange { color_attachment_index: color_attachment, num_color_attachments: info @@ -1533,9 +1531,9 @@ impl SyncCommandBufferBuilder { let &RenderPassBeginInfo { ref render_pass, ref framebuffer, - render_area_offset, - render_area_extent, - ref clear_values, + render_area_offset: _, + render_area_extent: _, + clear_values: _, _ne: _, } = &render_pass_begin_info; @@ -1652,14 +1650,14 @@ impl SyncCommandBufferBuilder { } let &RenderingInfo { - render_area_offset, - render_area_extent, - layer_count, - view_mask, + render_area_offset: _, + render_area_extent: _, + layer_count: _, + view_mask: _, ref color_attachments, ref depth_attachment, ref stencil_attachment, - contents, + contents: _, _ne, } = &rendering_info; @@ -1675,10 +1673,10 @@ impl SyncCommandBufferBuilder { let &RenderingAttachmentInfo { ref image_view, image_layout, - resolve_info: ref resolve, - load_op, - store_op, - clear_value, + ref resolve_info, + load_op: _, + store_op: _, + clear_value: _, _ne: _, } = attachment_info; @@ -1704,9 +1702,9 @@ impl SyncCommandBufferBuilder { end_layout: image_layout, }, )), - attachment_info.resolve_info.as_ref().map(|resolve_info| { + resolve_info.as_ref().map(|resolve_info| { let &RenderingAttachmentResolveInfo { - mode, + mode: _, ref image_view, image_layout, } = resolve_info; @@ -1714,11 +1712,8 @@ impl SyncCommandBufferBuilder { ( format!("color resolve attachment {}", index).into(), Resource::Image { - image: resolve_info.image_view.image(), - subresource_range: resolve_info - .image_view - .subresource_range() - .clone(), + image: image_view.image(), + subresource_range: image_view.subresource_range().clone(), memory: PipelineMemoryAccess { stages: PipelineStages { all_commands: true, @@ -1731,8 +1726,8 @@ impl SyncCommandBufferBuilder { }, // TODO: suboptimal exclusive: true, // TODO: suboptimal }, - start_layout: resolve_info.image_layout, - end_layout: resolve_info.image_layout, + start_layout: image_layout, + end_layout: image_layout, }, ) }), @@ -1744,10 +1739,10 @@ impl SyncCommandBufferBuilder { let &RenderingAttachmentInfo { ref image_view, image_layout, - resolve_info: ref resolve, - load_op, - store_op, - clear_value, + ref resolve_info, + load_op: _, + store_op: _, + clear_value: _, _ne: _, } = attachment_info; @@ -1773,9 +1768,9 @@ impl SyncCommandBufferBuilder { end_layout: image_layout, }, )), - attachment_info.resolve_info.as_ref().map(|resolve_info| { + resolve_info.as_ref().map(|resolve_info| { let &RenderingAttachmentResolveInfo { - mode, + mode: _, ref image_view, image_layout, } = resolve_info; @@ -1783,8 +1778,8 @@ impl SyncCommandBufferBuilder { ( "depth resolve attachment".into(), Resource::Image { - image: resolve_info.image_view.image(), - subresource_range: resolve_info.image_view.subresource_range().clone(), + image: image_view.image(), + subresource_range: image_view.subresource_range().clone(), memory: PipelineMemoryAccess { stages: PipelineStages { all_commands: true, @@ -1797,8 +1792,8 @@ impl SyncCommandBufferBuilder { }, // TODO: suboptimal exclusive: true, // TODO: suboptimal }, - start_layout: resolve_info.image_layout, - end_layout: resolve_info.image_layout, + start_layout: image_layout, + end_layout: image_layout, }, ) }), @@ -1810,10 +1805,10 @@ impl SyncCommandBufferBuilder { let &RenderingAttachmentInfo { ref image_view, image_layout, - resolve_info: ref resolve, - load_op, - store_op, - clear_value, + ref resolve_info, + load_op: _, + store_op: _, + clear_value: _, _ne: _, } = attachment_info; @@ -1839,9 +1834,9 @@ impl SyncCommandBufferBuilder { end_layout: image_layout, }, )), - attachment_info.resolve_info.as_ref().map(|resolve_info| { + resolve_info.as_ref().map(|resolve_info| { let &RenderingAttachmentResolveInfo { - mode, + mode: _, ref image_view, image_layout, } = resolve_info; @@ -1849,8 +1844,8 @@ impl SyncCommandBufferBuilder { ( "stencil resolve attachment".into(), Resource::Image { - image: resolve_info.image_view.image(), - subresource_range: resolve_info.image_view.subresource_range().clone(), + image: image_view.image(), + subresource_range: image_view.subresource_range().clone(), memory: PipelineMemoryAccess { stages: PipelineStages { all_commands: true, @@ -1863,8 +1858,8 @@ impl SyncCommandBufferBuilder { }, // TODO: suboptimal exclusive: true, // TODO: suboptimal }, - start_layout: resolve_info.image_layout, - end_layout: resolve_info.image_layout, + start_layout: image_layout, + end_layout: image_layout, }, ) }), @@ -1957,7 +1952,7 @@ impl UnsafeCommandBufferBuilder { } = render_pass_begin_info; let clear_values_vk: SmallVec<[_; 4]> = clear_values - .into_iter() + .iter() .copied() .map(|clear_value| clear_value.map(Into::into).unwrap_or_default()) .collect(); @@ -2042,7 +2037,7 @@ impl UnsafeCommandBufferBuilder { debug_assert!(subpass_begin_info.p_next.is_null()); debug_assert!(subpass_end_info.p_next.is_null()); - (fns.v1_0.cmd_next_subpass)(self.handle, subpass_begin_info.contents.into()); + (fns.v1_0.cmd_next_subpass)(self.handle, subpass_begin_info.contents); } } @@ -2190,7 +2185,7 @@ impl UnsafeCommandBufferBuilder { /// Does nothing if the list of attachments or the list of rects is empty, as it would be a /// no-op and isn't a valid usage of the command anyway. #[inline] - pub unsafe fn clear_attachments<'a>( + pub unsafe fn clear_attachments( &mut self, attachments: impl IntoIterator, rects: impl IntoIterator, diff --git a/vulkano/src/command_buffer/commands/secondary.rs b/vulkano/src/command_buffer/commands/secondary.rs index d56c2df4..79128000 100644 --- a/vulkano/src/command_buffer/commands/secondary.rs +++ b/vulkano/src/command_buffer/commands/secondary.rs @@ -324,12 +324,11 @@ where match state.ty { QueryType::Occlusion => { // VUID-vkCmdExecuteCommands-commandBuffer-00102 - let inherited_flags = command_buffer - .inheritance_info() - .occlusion_query - .ok_or_else(|| ExecuteCommandsError::OcclusionQueryInheritanceRequired { + let inherited_flags = command_buffer.inheritance_info().occlusion_query.ok_or( + ExecuteCommandsError::OcclusionQueryInheritanceRequired { command_buffer_index, - })?; + }, + )?; let inherited_flags_vk = ash::vk::QueryControlFlags::from(inherited_flags); let state_flags_vk = ash::vk::QueryControlFlags::from(state.flags); diff --git a/vulkano/src/command_buffer/commands/transfer.rs b/vulkano/src/command_buffer/commands/transfer.rs index 3fa64920..76067915 100644 --- a/vulkano/src/command_buffer/commands/transfer.rs +++ b/vulkano/src/command_buffer/commands/transfer.rs @@ -771,7 +771,7 @@ impl AutoCommandBufferBuilder { for (dst_region_index, dst_region) in regions.iter().enumerate() { let &ImageCopy { ref dst_subresource, - dst_offset, + dst_offset: _, .. } = dst_region; @@ -1729,7 +1729,7 @@ impl AutoCommandBufferBuilder { } let &mut FillBufferInfo { - data, + data: _, ref dst_buffer, dst_offset, size, @@ -1895,25 +1895,6 @@ impl AutoCommandBufferBuilder { } } -/// Computes the minimum required len in elements for buffer with image data in specified -/// format of specified size. -fn required_size_for_format(format: Format, extent: [u32; 3], layer_count: u32) -> DeviceSize { - let num_blocks = extent - .into_iter() - .zip(format.block_extent()) - .map(|(extent, block_extent)| { - let extent = extent as DeviceSize; - let block_extent = block_extent as DeviceSize; - (extent + block_extent - 1) / block_extent - }) - .product::() - * layer_count as DeviceSize; - let block_size = format - .block_size() - .expect("this format cannot accept pixels"); - num_blocks * block_size -} - impl SyncCommandBufferBuilder { /// Calls `vkCmdCopyBuffer` on the builder. /// @@ -2046,10 +2027,10 @@ impl SyncCommandBufferBuilder { .flat_map(|region| { let &ImageCopy { ref src_subresource, - src_offset, + src_offset: _, ref dst_subresource, - dst_offset, - extent, + dst_offset: _, + extent: _, _ne: _, } = region; @@ -2147,11 +2128,11 @@ impl SyncCommandBufferBuilder { .flat_map(|region| { let &BufferImageCopy { buffer_offset, - buffer_row_length, - buffer_image_height, + buffer_row_length: _, + buffer_image_height: _, ref image_subresource, - image_offset, - image_extent, + image_offset: _, + image_extent: _, _ne: _, } = region; @@ -2250,11 +2231,11 @@ impl SyncCommandBufferBuilder { .flat_map(|region| { let &BufferImageCopy { buffer_offset, - buffer_row_length, - buffer_image_height, + buffer_row_length: _, + buffer_image_height: _, ref image_subresource, - image_offset, - image_extent, + image_offset: _, + image_extent: _, _ne: _, } = region; @@ -2338,7 +2319,7 @@ impl SyncCommandBufferBuilder { } let &FillBufferInfo { - data, + data: _, ref dst_buffer, dst_offset, size, @@ -3566,6 +3547,25 @@ mod tests { use super::*; use crate::format::Format; + /// Computes the minimum required len in elements for buffer with image data in specified + /// format of specified size. + fn required_size_for_format(format: Format, extent: [u32; 3], layer_count: u32) -> DeviceSize { + let num_blocks = extent + .into_iter() + .zip(format.block_extent()) + .map(|(extent, block_extent)| { + let extent = extent as DeviceSize; + let block_extent = block_extent as DeviceSize; + (extent + block_extent - 1) / block_extent + }) + .product::() + * layer_count as DeviceSize; + let block_size = format + .block_size() + .expect("this format cannot accept pixels"); + num_blocks * block_size + } + #[test] fn test_required_len_for_format() { // issue #1292 diff --git a/vulkano/src/command_buffer/pool/standard.rs b/vulkano/src/command_buffer/pool/standard.rs index 4cdcceb1..f3750edb 100644 --- a/vulkano/src/command_buffer/pool/standard.rs +++ b/vulkano/src/command_buffer/pool/standard.rs @@ -266,7 +266,7 @@ mod tests { let (device, queue) = gfx_dev_and_queue!(); let thread = thread::spawn({ - let (device, queue) = (device.clone(), queue.clone()); + let (device, queue) = (device, queue); move || { device .with_standard_command_pool(queue.family(), |pool| { diff --git a/vulkano/src/command_buffer/pool/sys.rs b/vulkano/src/command_buffer/pool/sys.rs index 19d25604..fa465b09 100644 --- a/vulkano/src/command_buffer/pool/sys.rs +++ b/vulkano/src/command_buffer/pool/sys.rs @@ -39,8 +39,8 @@ pub struct UnsafeCommandPool { dummy_avoid_sync: PhantomData<*const u8>, queue_family_index: u32, - transient: bool, - reset_command_buffer: bool, + _transient: bool, + _reset_command_buffer: bool, } unsafe impl Send for UnsafeCommandPool {} @@ -67,8 +67,8 @@ impl UnsafeCommandPool { dummy_avoid_sync: PhantomData, queue_family_index, - transient, - reset_command_buffer, + _transient: transient, + _reset_command_buffer: reset_command_buffer, }) } @@ -94,8 +94,8 @@ impl UnsafeCommandPool { dummy_avoid_sync: PhantomData, queue_family_index, - transient, - reset_command_buffer, + _transient: transient, + _reset_command_buffer: reset_command_buffer, } } @@ -105,8 +105,8 @@ impl UnsafeCommandPool { ) -> Result<(), UnsafeCommandPoolCreationError> { let &mut UnsafeCommandPoolCreateInfo { queue_family_index, - transient, - reset_command_buffer, + transient: _, + reset_command_buffer: _, _ne: _, } = create_info; @@ -615,14 +615,18 @@ mod tests { .unwrap(); if device.api_version() >= Version::V1_1 { - match pool.trim() { - Err(CommandPoolTrimError::Maintenance1ExtensionNotEnabled) => panic!(), - _ => (), + if matches!( + pool.trim(), + Err(CommandPoolTrimError::Maintenance1ExtensionNotEnabled) + ) { + panic!() } } else { - match pool.trim() { - Err(CommandPoolTrimError::Maintenance1ExtensionNotEnabled) => (), - _ => panic!(), + if !matches!( + pool.trim(), + Err(CommandPoolTrimError::Maintenance1ExtensionNotEnabled) + ) { + panic!() } } } diff --git a/vulkano/src/command_buffer/submit/mod.rs b/vulkano/src/command_buffer/submit/mod.rs index 13d86cc0..86789832 100644 --- a/vulkano/src/command_buffer/submit/mod.rs +++ b/vulkano/src/command_buffer/submit/mod.rs @@ -43,9 +43,6 @@ impl<'a> SubmitAnyBuilder<'a> { /// Returns true if equal to `SubmitAnyBuilder::Empty`. #[inline] pub fn is_empty(&self) -> bool { - match self { - &SubmitAnyBuilder::Empty => true, - _ => false, - } + matches!(self, SubmitAnyBuilder::Empty) } } diff --git a/vulkano/src/command_buffer/submit/queue_submit.rs b/vulkano/src/command_buffer/submit/queue_submit.rs index 7479a36d..468c5a50 100644 --- a/vulkano/src/command_buffer/submit/queue_submit.rs +++ b/vulkano/src/command_buffer/submit/queue_submit.rs @@ -300,7 +300,7 @@ mod tests { #[test] fn empty_submit() { - let (device, queue) = gfx_dev_and_queue!(); + let (_device, queue) = gfx_dev_and_queue!(); let builder = SubmitCommandBufferBuilder::new(); builder.submit(&queue).unwrap(); } @@ -310,7 +310,7 @@ mod tests { unsafe { let (device, queue) = gfx_dev_and_queue!(); - let fence = Fence::new(device.clone(), Default::default()).unwrap(); + let fence = Fence::new(device, Default::default()).unwrap(); assert!(!fence.is_signaled().unwrap()); let mut builder = SubmitCommandBufferBuilder::new(); @@ -325,9 +325,9 @@ mod tests { #[test] fn has_fence() { unsafe { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); - let fence = Fence::new(device.clone(), Default::default()).unwrap(); + let fence = Fence::new(device, Default::default()).unwrap(); let mut builder = SubmitCommandBufferBuilder::new(); assert!(!builder.has_fence()); @@ -342,7 +342,7 @@ mod tests { let (device, _) = gfx_dev_and_queue!(); let fence1 = Fence::new(device.clone(), Default::default()).unwrap(); - let fence2 = Fence::new(device.clone(), Default::default()).unwrap(); + let fence2 = Fence::new(device, Default::default()).unwrap(); let mut builder1 = SubmitCommandBufferBuilder::new(); builder1.set_fence_signal(&fence1); diff --git a/vulkano/src/command_buffer/submit/semaphores_wait.rs b/vulkano/src/command_buffer/submit/semaphores_wait.rs index 425466c8..d45cb591 100644 --- a/vulkano/src/command_buffer/submit/semaphores_wait.rs +++ b/vulkano/src/command_buffer/submit/semaphores_wait.rs @@ -46,12 +46,12 @@ impl<'a> SubmitSemaphoresWaitBuilder<'a> { } } -impl<'a> Into> for SubmitSemaphoresWaitBuilder<'a> { +impl<'a> From> for SubmitCommandBufferBuilder<'a> { #[inline] - fn into(mut self) -> SubmitCommandBufferBuilder<'a> { + fn from(mut val: SubmitSemaphoresWaitBuilder<'a>) -> Self { unsafe { let mut builder = SubmitCommandBufferBuilder::new(); - for sem in self.semaphores.drain(..) { + for sem in val.semaphores.drain(..) { builder.add_wait_semaphore( sem, PipelineStages { @@ -66,12 +66,12 @@ impl<'a> Into> for SubmitSemaphoresWaitBuilder<'a } } -impl<'a> Into> for SubmitSemaphoresWaitBuilder<'a> { +impl<'a> From> for SubmitPresentBuilder<'a> { #[inline] - fn into(mut self) -> SubmitPresentBuilder<'a> { + fn from(mut val: SubmitSemaphoresWaitBuilder<'a>) -> Self { unsafe { let mut builder = SubmitPresentBuilder::new(); - for sem in self.semaphores.drain(..) { + for sem in val.semaphores.drain(..) { builder.add_wait_semaphore(sem); } builder diff --git a/vulkano/src/command_buffer/synced/builder.rs b/vulkano/src/command_buffer/synced/builder.rs index 79610689..b1535ba7 100644 --- a/vulkano/src/command_buffer/synced/builder.rs +++ b/vulkano/src/command_buffer/synced/builder.rs @@ -198,8 +198,8 @@ impl SyncCommandBufferBuilder { ) -> Result<(), SyncCommandBufferBuilderError> { let (resource_name, resource) = resource; - match resource { - &Resource::Buffer { + match *resource { + Resource::Buffer { ref buffer, ref range, ref memory, @@ -217,7 +217,7 @@ impl SyncCommandBufferBuilder { }); } } - &Resource::Image { + Resource::Image { ref image, ref subresource_range, ref memory, @@ -266,7 +266,7 @@ impl SyncCommandBufferBuilder { let range_map = self.buffers2.get(inner.buffer)?; - for (range, state) in range_map + for (_range, state) in range_map .range(&range) .filter(|(_range, state)| !state.resource_uses.is_empty()) { @@ -297,7 +297,7 @@ impl SyncCommandBufferBuilder { mut subresource_range: ImageSubresourceRange, memory: &PipelineMemoryAccess, start_layout: ImageLayout, - end_layout: ImageLayout, + _end_layout: ImageLayout, ) -> Option<&ImageUse> { // Barriers work differently in render passes, so if we're in one, we can only insert a // barrier before the start of the render pass. @@ -313,7 +313,7 @@ impl SyncCommandBufferBuilder { let range_map = self.images2.get(inner.image)?; for range in inner.image.iter_ranges(subresource_range) { - for (range, state) in range_map + for (_range, state) in range_map .range(&range) .filter(|(_range, state)| !state.resource_uses.is_empty()) { @@ -851,7 +851,7 @@ impl SyncCommandBufferBuilder { buffers2, images2, commands: self.commands, - barriers: self.barriers, + _barriers: self.barriers, }) } } diff --git a/vulkano/src/command_buffer/synced/mod.rs b/vulkano/src/command_buffer/synced/mod.rs index b3490e5c..214b4318 100644 --- a/vulkano/src/command_buffer/synced/mod.rs +++ b/vulkano/src/command_buffer/synced/mod.rs @@ -100,7 +100,7 @@ pub struct SyncCommandBuffer { // Locations within commands that pipeline barriers were inserted. For debugging purposes. // TODO: present only in cfg(debug_assertions)? - barriers: Vec, + _barriers: Vec, // State of all the resources used by this command buffer. buffers2: HashMap, RangeMap>, @@ -311,7 +311,7 @@ impl SyncCommandBuffer { buffer: &UnsafeBuffer, range: Range, exclusive: bool, - queue: &Queue, + _queue: &Queue, ) -> Result, AccessCheckError> { let range_map = match self.buffers2.get(buffer) { Some(x) => x, @@ -345,7 +345,7 @@ impl SyncCommandBuffer { range: Range, exclusive: bool, expected_layout: ImageLayout, - queue: &Queue, + _queue: &Queue, ) -> Result, AccessCheckError> { let range_map = match self.images2.get(image) { Some(x) => x, @@ -556,7 +556,7 @@ mod tests { .unwrap(); SyncCommandBufferBuilder::new( - &pool_builder_alloc.inner(), + pool_builder_alloc.inner(), CommandBufferBeginInfo { usage: CommandBufferUsage::MultipleSubmit, ..Default::default() @@ -635,7 +635,7 @@ mod tests { // Ensure that the builder added a barrier between the two writes assert_eq!(&names, &["execute_commands", "execute_commands"]); - assert_eq!(&primary.barriers, &[0, 1]); + assert_eq!(&primary._barriers, &[0, 1]); } { @@ -672,7 +672,7 @@ mod tests { }) .unwrap(); let mut sync = SyncCommandBufferBuilder::new( - &pool_builder_alloc.inner(), + pool_builder_alloc.inner(), CommandBufferBeginInfo { usage: CommandBufferUsage::MultipleSubmit, ..Default::default() @@ -705,7 +705,7 @@ mod tests { }) .unwrap(); let mut sync = SyncCommandBufferBuilder::new( - &pool_builder_alloc.inner(), + pool_builder_alloc.inner(), CommandBufferBeginInfo { usage: CommandBufferUsage::MultipleSubmit, ..Default::default() @@ -794,7 +794,7 @@ mod tests { .unwrap(); let set = PersistentDescriptorSet::new( - set_layout.clone(), + set_layout, [WriteDescriptorSet::sampler( 0, Sampler::new(device, SamplerCreateInfo::simple_repeat_linear()).unwrap(), diff --git a/vulkano/src/command_buffer/sys.rs b/vulkano/src/command_buffer/sys.rs index 69c53486..a8cb9eb2 100644 --- a/vulkano/src/command_buffer/sys.rs +++ b/vulkano/src/command_buffer/sys.rs @@ -101,7 +101,7 @@ impl UnsafeCommandBufferBuilder { ..Default::default() }); - if let Some(flags) = inheritance_info.occlusion_query { + if let Some(flags) = occlusion_query { inheritance_info_vk.occlusion_query_enable = ash::vk::TRUE; if flags.precise { diff --git a/vulkano/src/command_buffer/traits.rs b/vulkano/src/command_buffer/traits.rs index 15cafc8b..7c7affcf 100644 --- a/vulkano/src/command_buffer/traits.rs +++ b/vulkano/src/command_buffer/traits.rs @@ -387,7 +387,7 @@ where return Ok(SubmitAnyBuilder::Empty); } - return self.build_submission_impl(); + self.build_submission_impl() } #[inline] @@ -416,7 +416,7 @@ where #[inline] unsafe fn signal_finished(&self) { - if self.finished.swap(true, Ordering::SeqCst) == false { + if !self.finished.swap(true, Ordering::SeqCst) { self.command_buffer.unlock(); } diff --git a/vulkano/src/descriptor_set/collection.rs b/vulkano/src/descriptor_set/collection.rs index d62c15a8..ef96ce9d 100644 --- a/vulkano/src/descriptor_set/collection.rs +++ b/vulkano/src/descriptor_set/collection.rs @@ -48,17 +48,10 @@ macro_rules! impl_collection { $(, $others: Into)* { #[inline] + #[allow(non_snake_case)] fn into_vec(self) -> Vec { - #![allow(non_snake_case)] - let ($first, $($others,)*) = self; - - let mut list = Vec::new(); - list.push($first.into()); - $( - list.push($others.into()); - )+ - list + vec![$first.into() $(, $others.into())+] } } diff --git a/vulkano/src/descriptor_set/layout.rs b/vulkano/src/descriptor_set/layout.rs index 1811d7cb..2a508690 100644 --- a/vulkano/src/descriptor_set/layout.rs +++ b/vulkano/src/descriptor_set/layout.rs @@ -81,7 +81,7 @@ impl DescriptorSetLayout { } = create_info; let mut descriptor_counts = HashMap::default(); - for (&binding_num, binding) in bindings.iter() { + for binding in bindings.values() { if binding.descriptor_count != 0 { *descriptor_counts .entry(binding.descriptor_type) @@ -699,18 +699,18 @@ impl DescriptorSetLayoutBinding { let DescriptorRequirements { descriptor_types, descriptor_count, - image_format, - image_multisampled, - image_scalar_type, - image_view_type, - sampler_compare, - sampler_no_unnormalized_coordinates, - sampler_no_ycbcr_conversion, - sampler_with_images, + image_format: _, + image_multisampled: _, + image_scalar_type: _, + image_view_type: _, + sampler_compare: _, + sampler_no_unnormalized_coordinates: _, + sampler_no_ycbcr_conversion: _, + sampler_with_images: _, stages, - storage_image_atomic, - storage_read, - storage_write, + storage_image_atomic: _, + storage_read: _, + storage_write: _, } = descriptor_requirements; if !descriptor_types.contains(&self.descriptor_type) { @@ -786,7 +786,7 @@ impl fmt::Display for DescriptorRequirementsNotMet { "the descriptor count ({}) is less than what is required ({})", obtained, required ), - Self::ShaderStages { required, obtained } => write!( + Self::ShaderStages { .. } => write!( fmt, "the descriptor's shader stages do not contain the stages that are required", ), @@ -869,7 +869,7 @@ mod tests { let (device, _) = gfx_dev_and_queue!(); let sl = DescriptorSetLayout::new( - device.clone(), + device, DescriptorSetLayoutCreateInfo { bindings: [( 0, diff --git a/vulkano/src/descriptor_set/mod.rs b/vulkano/src/descriptor_set/mod.rs index 36a18bfd..fde3b48f 100644 --- a/vulkano/src/descriptor_set/mod.rs +++ b/vulkano/src/descriptor_set/mod.rs @@ -148,9 +148,7 @@ impl Hash for dyn DescriptorSet { } pub(crate) struct DescriptorSetInner { - handle: ash::vk::DescriptorSet, layout: Arc, - variable_descriptor_count: u32, resources: DescriptorSetResources, } @@ -225,22 +223,13 @@ impl DescriptorSetInner { ); } - Ok(DescriptorSetInner { - handle, - layout, - variable_descriptor_count, - resources, - }) + Ok(DescriptorSetInner { layout, resources }) } pub(crate) fn layout(&self) -> &Arc { &self.layout } - pub(crate) fn variable_descriptor_count(&self) -> u32 { - self.variable_descriptor_count - } - pub(crate) fn resources(&self) -> &DescriptorSetResources { &self.resources } @@ -317,7 +306,7 @@ impl DescriptorSetResources { /// /// - Panics if the binding number of a write does not exist in the resources. /// - See also [`DescriptorBindingResources::update`]. - pub fn update<'a>(&mut self, write: &WriteDescriptorSet) { + pub fn update(&mut self, write: &WriteDescriptorSet) { self.binding_resources .get_mut(&write.binding()) .expect("descriptor write has invalid binding number") @@ -460,13 +449,13 @@ impl DescriptorSetWithOffsets { } assert!( - !(dynamic_offsets.len() < dynamic_offset_index), + dynamic_offsets.len() >= dynamic_offset_index, "Too few dynamic offsets: got {}, expected {}", dynamic_offsets.len(), dynamic_offset_index ); assert!( - !(dynamic_offsets.len() > dynamic_offset_index), + dynamic_offsets.len() <= dynamic_offset_index, "Too many dynamic offsets: got {}, expected {}", dynamic_offsets.len(), dynamic_offset_index @@ -519,10 +508,10 @@ impl std::fmt::Display for DescriptorSetCreationError { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::DescriptorSetUpdateError(err) => { + Self::DescriptorSetUpdateError(_) => { write!(f, "an error occurred while updating the descriptor set") } - Self::OomError(err) => write!(f, "out of memory"), + Self::OomError(_) => write!(f, "out of memory"), } } } diff --git a/vulkano/src/descriptor_set/pool/sys.rs b/vulkano/src/descriptor_set/pool/sys.rs index 1f8429c8..324bdff0 100644 --- a/vulkano/src/descriptor_set/pool/sys.rs +++ b/vulkano/src/descriptor_set/pool/sys.rs @@ -205,7 +205,7 @@ impl UnsafeDescriptorPool { }) .unzip(); - let output = if layouts.len() == 0 { + let output = if layouts.is_empty() { vec![] } else { let variable_desc_count_alloc_info = if (self.device.api_version() >= Version::V1_2 @@ -265,9 +265,7 @@ impl UnsafeDescriptorPool { output }; - Ok(output - .into_iter() - .map(|handle| UnsafeDescriptorSet::new(handle))) + Ok(output.into_iter().map(UnsafeDescriptorSet::new)) } /// Frees some descriptor sets. diff --git a/vulkano/src/descriptor_set/single_layout_pool.rs b/vulkano/src/descriptor_set/single_layout_pool.rs index 590dda2e..fa8d916b 100644 --- a/vulkano/src/descriptor_set/single_layout_pool.rs +++ b/vulkano/src/descriptor_set/single_layout_pool.rs @@ -117,7 +117,7 @@ impl SingleLayoutDescSetPool { struct SingleLayoutPool { // The actual Vulkan descriptor pool. This field isn't actually used anywhere, but we need to // keep the pool alive in order to keep the descriptor sets valid. - inner: UnsafeDescriptorPool, + _inner: UnsafeDescriptorPool, // List of descriptor sets. When `alloc` is called, a descriptor will be extracted from this // list. When a `SingleLayoutPoolAlloc` is dropped, its descriptor set is put back in this list. reserve: ArrayQueue, @@ -169,7 +169,10 @@ impl SingleLayoutPool { } }; - Ok(Arc::new(Self { inner, reserve })) + Ok(Arc::new(Self { + _inner: inner, + reserve, + })) } } @@ -372,7 +375,7 @@ impl SingleLayoutVariableDescSetPool { Ok(SingleLayoutVariablePoolAlloc { inner, - pool: self.inner.clone(), + _pool: self.inner.clone(), }) } } @@ -430,7 +433,7 @@ pub(crate) struct SingleLayoutVariablePoolAlloc { // The `SingleLayoutVariablePool` where we allocated from. We need to keep a copy of it in each // allocation so that we can put back the pool in the reserve once all allocations have been // dropped. - pool: Arc, + _pool: Arc, } unsafe impl Send for SingleLayoutVariablePoolAlloc {} diff --git a/vulkano/src/descriptor_set/update.rs b/vulkano/src/descriptor_set/update.rs index b4238a8b..3351685d 100644 --- a/vulkano/src/descriptor_set/update.rs +++ b/vulkano/src/descriptor_set/update.rs @@ -372,27 +372,6 @@ pub(crate) enum DescriptorWriteInfo { BufferView(SmallVec<[ash::vk::BufferView; 1]>), } -impl DescriptorWriteInfo { - fn set_info(&self, write: &mut ash::vk::WriteDescriptorSet) { - match self { - DescriptorWriteInfo::Image(info) => { - write.descriptor_count = info.len() as u32; - write.p_image_info = info.as_ptr(); - } - DescriptorWriteInfo::Buffer(info) => { - write.descriptor_count = info.len() as u32; - write.p_buffer_info = info.as_ptr(); - } - DescriptorWriteInfo::BufferView(info) => { - write.descriptor_count = info.len() as u32; - write.p_texel_buffer_view = info.as_ptr(); - } - } - - debug_assert!(write.descriptor_count != 0); - } -} - pub(crate) fn check_descriptor_write<'a>( write: &WriteDescriptorSet, layout: &'a DescriptorSetLayout, @@ -429,7 +408,7 @@ pub(crate) fn check_descriptor_write<'a>( } match elements { - WriteDescriptorSetElements::None(num_elements) => match layout_binding.descriptor_type { + WriteDescriptorSetElements::None(_num_elements) => match layout_binding.descriptor_type { DescriptorType::Sampler if layout.push_descriptor() && !layout_binding.immutable_samplers.is_empty() => {} _ => { diff --git a/vulkano/src/device/extensions.rs b/vulkano/src/device/extensions.rs index 9f84ed43..c01cb801 100644 --- a/vulkano/src/device/extensions.rs +++ b/vulkano/src/device/extensions.rs @@ -25,6 +25,6 @@ mod tests { #[test] fn empty_extensions() { let d: Vec = (&DeviceExtensions::none()).into(); - assert!(d.iter().next().is_none()); + assert!(d.get(0).is_none()); } } diff --git a/vulkano/src/device/mod.rs b/vulkano/src/device/mod.rs index 46ab1660..856a8c23 100644 --- a/vulkano/src/device/mod.rs +++ b/vulkano/src/device/mod.rs @@ -235,7 +235,7 @@ impl Device { // VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383 assert!(queues .iter() - .all(|&priority| priority >= 0.0 && priority <= 1.0)); + .all(|&priority| (0.0..=1.0).contains(&priority))); if queues.len() > family.queues_count() { return Err(DeviceCreationError::TooManyQueuesForFamily); @@ -491,7 +491,7 @@ impl Device { /// > **Note**: Will return `-> impl ExactSizeIterator` in the future. // TODO: ^ #[inline] - pub fn active_queue_families<'a>(&'a self) -> impl ExactSizeIterator> { + pub fn active_queue_families(&self) -> impl ExactSizeIterator { let physical_device = self.physical_device(); self.active_queue_families .iter() @@ -1058,7 +1058,7 @@ impl Queue { fn validate_begin_debug_utils_label( &self, - label_info: &mut DebugUtilsLabel, + _label_info: &mut DebugUtilsLabel, ) -> Result<(), DebugUtilsError> { if !self .device() @@ -1151,7 +1151,7 @@ impl Queue { fn validate_insert_debug_utils_label( &self, - label_info: &mut DebugUtilsLabel, + _label_info: &mut DebugUtilsLabel, ) -> Result<(), DebugUtilsError> { if !self .device() @@ -1246,7 +1246,7 @@ mod tests { }; let family = physical.queue_families().next().unwrap(); - let queues = (0..family.queues_count() + 1).map(|_| (family, 1.0)); + let _queues = (0..family.queues_count() + 1).map(|_| (family, 1.0)); match Device::new( physical, @@ -1258,7 +1258,7 @@ mod tests { ..Default::default() }, ) { - Err(DeviceCreationError::TooManyQueuesForFamily) => return, // Success + Err(DeviceCreationError::TooManyQueuesForFamily) => (), // Success _ => panic!(), }; } @@ -1290,7 +1290,7 @@ mod tests { Err(DeviceCreationError::FeatureRestrictionNotMet(FeatureRestrictionError { restriction: FeatureRestriction::NotSupported, .. - })) => return, // Success + })) => (), // Success _ => panic!(), }; } diff --git a/vulkano/src/device/physical.rs b/vulkano/src/device/physical.rs index 37292252..fc946c12 100644 --- a/vulkano/src/device/physical.rs +++ b/vulkano/src/device/physical.rs @@ -68,10 +68,10 @@ pub(crate) fn init_physical_devices( } }; - Ok(handles + handles .into_iter() .enumerate() - .map(|(index, handle)| -> Result<_, InstanceCreationError> { + .map(|(_index, handle)| -> Result<_, InstanceCreationError> { let api_version = unsafe { let mut output = MaybeUninit::uninit(); (fns.v1_0.get_physical_device_properties)(handle, output.as_mut_ptr()); @@ -138,7 +138,7 @@ pub(crate) fn init_physical_devices( Ok(info) }) - .collect::>()?) + .collect::>() } fn init_info(instance: &Instance, info: &mut PhysicalDeviceInfo) { @@ -391,7 +391,7 @@ impl<'a> PhysicalDevice<'a> { /// ``` #[inline] pub fn instance(&self) -> &'a Arc { - &self.instance + self.instance } /// Returns the index of the physical device in the physical devices list. @@ -1324,11 +1324,8 @@ impl<'a> PhysicalDevice<'a> { } }; - debug_assert!(modes.len() > 0); - debug_assert!(modes - .iter() - .find(|&&m| m == ash::vk::PresentModeKHR::FIFO) - .is_some()); + debug_assert!(!modes.is_empty()); + debug_assert!(modes.iter().any(|&m| m == ash::vk::PresentModeKHR::FIFO)); Ok(modes .into_iter() @@ -1564,7 +1561,7 @@ impl<'a> QueueFamily<'a> { /// of `[width, height, depth]` #[inline] pub fn min_image_transfer_granularity(&self) -> [u32; 3] { - let ref granularity = self.properties.min_image_transfer_granularity; + let granularity = &self.properties.min_image_transfer_granularity; [granularity.width, granularity.height, granularity.depth] } @@ -1809,7 +1806,7 @@ pub struct ShaderCoreProperties {} impl From for ShaderCoreProperties { #[inline] - fn from(val: ash::vk::ShaderCorePropertiesFlagsAMD) -> Self { + fn from(_val: ash::vk::ShaderCorePropertiesFlagsAMD) -> Self { Self {} } } diff --git a/vulkano/src/format.rs b/vulkano/src/format.rs index 9aa27f76..701871f9 100644 --- a/vulkano/src/format.rs +++ b/vulkano/src/format.rs @@ -102,7 +102,10 @@ include!(concat!(env!("OUT_DIR"), "/formats.rs")); impl Format { /// Retrieves the properties of a format when used by a certain device. - #[deprecated(since = "0.28", note = "Use PhysicalDevice::format_properties instead")] + #[deprecated( + since = "0.28.0", + note = "Use PhysicalDevice::format_properties instead" + )] #[inline] pub fn properties(&self, physical_device: PhysicalDevice) -> FormatProperties { physical_device.format_properties(*self) diff --git a/vulkano/src/image/attachment.rs b/vulkano/src/image/attachment.rs index b9f56669..21b1f6b0 100644 --- a/vulkano/src/image/attachment.rs +++ b/vulkano/src/image/attachment.rs @@ -30,7 +30,7 @@ use std::{ fs::File, hash::{Hash, Hasher}, sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, + atomic::{AtomicBool, Ordering}, Arc, }, }; @@ -72,9 +72,6 @@ pub struct AttachmentImage> { image: Arc, dimensions: ImageDimensions, - memory: A, - format: Format, + _memory: A, layout: ImageLayout, } @@ -66,7 +64,7 @@ fn generate_mipmaps( cbb: &mut AutoCommandBufferBuilder, image: Arc, dimensions: ImageDimensions, - layout: ImageLayout, + _layout: ImageLayout, ) { for level in 1..image.mip_levels() { let src_size = dimensions @@ -225,16 +223,13 @@ impl ImmutableImage { let image = Arc::new(ImmutableImage { image, - memory, + _memory: memory, dimensions, - format, layout, }); let init = Arc::new(ImmutableImageInitialization { image: image.clone(), - mip_levels_access: 0..image.mip_levels(), - array_layers_access: 0..image.dimensions().array_layers(), }); Ok((image, init)) @@ -414,8 +409,6 @@ where // Must not implement Clone, as that would lead to multiple `used` values. pub struct ImmutableImageInitialization> { image: Arc>, - mip_levels_access: Range, - array_layers_access: Range, } unsafe impl DeviceOwned for ImmutableImageInitialization { diff --git a/vulkano/src/image/mod.rs b/vulkano/src/image/mod.rs index 77969410..8ed78120 100644 --- a/vulkano/src/image/mod.rs +++ b/vulkano/src/image/mod.rs @@ -946,7 +946,7 @@ mod tests { #[test] fn mipmap_working_immutable_image() { - let (device, queue) = gfx_dev_and_queue!(); + let (_device, queue) = gfx_dev_and_queue!(); let dimensions = ImageDimensions::Dim2d { width: 512, @@ -978,7 +978,7 @@ mod tests { dimensions, MipmapsCount::Log2, Format::R8_UNORM, - queue.clone(), + queue, ) .unwrap(); assert_eq!(image.mip_levels(), 10); diff --git a/vulkano/src/image/storage.rs b/vulkano/src/image/storage.rs index 96aae0f5..73977646 100644 --- a/vulkano/src/image/storage.rs +++ b/vulkano/src/image/storage.rs @@ -48,12 +48,6 @@ where // Dimensions of the image. dimensions: ImageDimensions, - - // Format. - format: Format, - - // Queue families allowed to access this image. - queue_families: SmallVec<[u32; 4]>, } impl StorageImage { @@ -150,8 +144,6 @@ impl StorageImage { image, memory, dimensions, - format, - queue_families, })) } @@ -196,7 +188,7 @@ impl StorageImage { let mem_reqs = image.memory_requirements(); let memory = alloc_dedicated_with_exportable_fd( - device.clone(), + device, &mem_reqs, AllocLayout::Optimal, MappingRequirement::DoNotMap, @@ -218,8 +210,6 @@ impl StorageImage { image, memory, dimensions, - format, - queue_families, })) } @@ -376,7 +366,7 @@ mod tests { #[test] fn create_general_purpose_image_view() { - let (device, queue) = gfx_dev_and_queue!(); + let (_device, queue) = gfx_dev_and_queue!(); let usage = ImageUsage { transfer_src: true, transfer_dst: true, @@ -384,7 +374,7 @@ mod tests { ..ImageUsage::none() }; let img_view = StorageImage::general_purpose_image_view( - queue.clone(), + queue, [32, 32], Format::R8G8B8A8_UNORM, usage, @@ -395,14 +385,14 @@ mod tests { #[test] fn create_general_purpose_image_view_failed() { - let (device, queue) = gfx_dev_and_queue!(); + let (_device, queue) = gfx_dev_and_queue!(); // Not valid for image view... let usage = ImageUsage { transfer_src: true, ..ImageUsage::none() }; let img_result = StorageImage::general_purpose_image_view( - queue.clone(), + queue, [32, 32], Format::R8G8B8A8_UNORM, usage, diff --git a/vulkano/src/image/swapchain.rs b/vulkano/src/image/swapchain.rs index 17daad03..035d3768 100644 --- a/vulkano/src/image/swapchain.rs +++ b/vulkano/src/image/swapchain.rs @@ -45,10 +45,8 @@ impl SwapchainImage { swapchain: Arc>, id: usize, ) -> Result>, OomError> { - let image = swapchain.raw_image(id).unwrap(); - Ok(Arc::new(SwapchainImage { - swapchain: swapchain.clone(), + swapchain, image_offset: id, })) } diff --git a/vulkano/src/image/sys.rs b/vulkano/src/image/sys.rs index f9d0d3c3..03ea8e0c 100644 --- a/vulkano/src/image/sys.rs +++ b/vulkano/src/image/sys.rs @@ -126,9 +126,9 @@ impl UnsafeImage { samples, tiling, usage, - sharing, + sharing: _, initial_layout, - external_memory_handle_types, + external_memory_handle_types: _, mutable_format, cube_compatible, array_2d_compatible, @@ -218,7 +218,7 @@ impl UnsafeImage { color_attachment: false, depth_stencil_attachment: false, input_attachment: false, - ..usage.clone() + ..usage } == ImageUsage::none() ) } @@ -230,7 +230,7 @@ impl UnsafeImage { )); // VUID-VkImageCreateInfo-flags-01573 - assert!(!(block_texel_view_compatible && !mutable_format)); + assert!(!block_texel_view_compatible || mutable_format); // Get format features let format_features = { @@ -340,7 +340,7 @@ impl UnsafeImage { ChromaSampling::Mode444 => (), ChromaSampling::Mode422 => { // VUID-VkImageCreateInfo-format-04712 - if !(extent[0] % 2 == 0) { + if extent[0] % 2 != 0 { return Err(ImageCreationError::YcbcrFormatInvalidDimensions); } } @@ -653,7 +653,7 @@ impl UnsafeImage { && ImageUsage { transfer_src: false, transfer_dst: false, - ..usage.clone() + ..usage } == ImageUsage::none()) } else { false @@ -673,10 +673,7 @@ impl UnsafeImage { if !external_memory_handle_types.is_empty() { // If external memory handles are used, the properties need to be queried // individually for each handle type. - external_memory_handle_types - .iter() - .map(|handle_type| Some(handle_type)) - .collect() + external_memory_handle_types.iter().map(Some).collect() } else { smallvec![None] }; @@ -703,7 +700,7 @@ impl UnsafeImage { max_mip_levels, max_array_layers, sample_counts, - max_resource_size, + max_resource_size: _, .. } = match image_format_properties { Some(x) => x, @@ -894,7 +891,7 @@ impl UnsafeImage { let image = UnsafeImage { handle, - device: device.clone(), + device, dimensions, format: Some(format), @@ -1328,7 +1325,7 @@ impl UnsafeImage { let subresource = ash::vk::ImageSubresource { aspect_mask: ash::vk::ImageAspectFlags::from(aspect), - mip_level: mip_level, + mip_level, array_layer: 0, }; @@ -1685,7 +1682,7 @@ impl fmt::Display for ImageCreationError { Self::FormatNotSupported => { write!(fmt, "the given format was not supported by the device") } - Self::FormatUsageNotSupported { usage } => { + Self::FormatUsageNotSupported { .. } => { write!( fmt, "a requested usage flag was not supported by the given format" @@ -1694,16 +1691,16 @@ impl fmt::Display for ImageCreationError { Self::ImageFormatPropertiesNotSupported => { write!(fmt, "the image configuration as queried through the `image_format_properties` function was not supported by the device") } - Self::MaxArrayLayersExceeded { array_layers, max } => { + Self::MaxArrayLayersExceeded { .. } => { write!(fmt, "the number of array layers exceeds the maximum supported by the device for this image configuration") } - Self::MaxDimensionsExceeded { extent, max } => { + Self::MaxDimensionsExceeded { .. } => { write!(fmt, "the specified dimensions exceed the maximum supported by the device for this image configuration") } - Self::MaxFramebufferDimensionsExceeded { extent, max } => { + Self::MaxFramebufferDimensionsExceeded { .. } => { write!(fmt, "the usage included one of the attachment types, and the specified width and height exceeded the `max_framebuffer_width` or `max_framebuffer_height` limits") } - Self::MaxMipLevelsExceeded { mip_levels, max } => { + Self::MaxMipLevelsExceeded { .. } => { write!( fmt, "the maximum number of mip levels for the given dimensions has been exceeded" @@ -1730,13 +1727,13 @@ impl fmt::Display for ImageCreationError { "multisampling was enabled, but the image type was not 2D" ) } - Self::SampleCountNotSupported { samples, supported } => { + Self::SampleCountNotSupported { .. } => { write!( fmt, "the sample count is not supported by the device for this image configuration" ) } - Self::SharingInvalidQueueFamilyId { id } => { + Self::SharingInvalidQueueFamilyId { .. } => { write!(fmt, "the sharing mode was set to `Concurrent`, but one of the specified queue family ids was not valid") } Self::YcbcrFormatInvalidDimensions => { @@ -1761,7 +1758,7 @@ impl fmt::Display for ImageCreationError { ) } Self::DirectImageViewCreationFailed(e) => { - write!(fmt, "Image view creation failed {}", e.to_string()) + write!(fmt, "Image view creation failed {}", e) } } } @@ -1840,6 +1837,7 @@ impl ImageState { } } + #[allow(dead_code)] pub(crate) fn check_cpu_read(&mut self, range: Range) -> Result<(), ReadLockError> { for (_range, state) in self.ranges.range(&range) { match &state.current_access { @@ -1852,6 +1850,7 @@ impl ImageState { Ok(()) } + #[allow(dead_code)] pub(crate) unsafe fn cpu_read_lock(&mut self, range: Range) { self.ranges.split_at(&range.start); self.ranges.split_at(&range.end); @@ -1866,6 +1865,7 @@ impl ImageState { } } + #[allow(dead_code)] pub(crate) unsafe fn cpu_read_unlock(&mut self, range: Range) { self.ranges.split_at(&range.start); self.ranges.split_at(&range.end); @@ -1878,6 +1878,7 @@ impl ImageState { } } + #[allow(dead_code)] pub(crate) fn check_cpu_write( &mut self, range: Range, @@ -1900,6 +1901,7 @@ impl ImageState { Ok(()) } + #[allow(dead_code)] pub(crate) unsafe fn cpu_write_lock(&mut self, range: Range) { self.ranges.split_at(&range.start); self.ranges.split_at(&range.end); @@ -1909,6 +1911,7 @@ impl ImageState { } } + #[allow(dead_code)] pub(crate) unsafe fn cpu_write_unlock(&mut self, range: Range) { self.ranges.split_at(&range.start); self.ranges.split_at(&range.end); @@ -2285,7 +2288,7 @@ mod tests { array_layers: 1, }, format: Some(Format::R8G8B8A8_UNORM), - mip_levels: u32::MAX.into(), + mip_levels: u32::MAX, usage: ImageUsage { sampled: true, ..ImageUsage::none() @@ -2417,6 +2420,7 @@ mod tests { } #[test] + #[allow(clippy::erasing_op, clippy::identity_op)] fn subresource_range_iterator() { // A fictitious set of aspects that no real image would actually ever have. let image_aspect_list: SmallVec<[ImageAspect; 4]> = ImageAspects { @@ -2453,6 +2457,7 @@ mod tests { mip, image_array_layers, ); + assert_eq!(iter.next(), Some(0 * asp..4 * asp)); assert_eq!(iter.next(), None); @@ -2475,6 +2480,7 @@ mod tests { mip, image_array_layers, ); + assert_eq!(iter.next(), Some(0 * asp..2 * asp)); assert_eq!(iter.next(), Some(3 * asp..4 * asp)); assert_eq!(iter.next(), None); @@ -2521,6 +2527,7 @@ mod tests { mip, image_array_layers, ); + assert_eq!( iter.next(), Some(0 * asp + 0 * mip + 2..0 * asp + 0 * mip + 4) diff --git a/vulkano/src/image/view.rs b/vulkano/src/image/view.rs index 3150c701..ece9782e 100644 --- a/vulkano/src/image/view.rs +++ b/vulkano/src/image/view.rs @@ -508,14 +508,13 @@ where ..Default::default() }; - let mut sampler_ycbcr_conversion_info = if let Some(conversion) = sampler_ycbcr_conversion { - Some(ash::vk::SamplerYcbcrConversionInfo { - conversion: conversion.internal_object(), - ..Default::default() - }) - } else { - None - }; + let mut sampler_ycbcr_conversion_info = + sampler_ycbcr_conversion.as_ref().map(|conversion| { + ash::vk::SamplerYcbcrConversionInfo { + conversion: conversion.internal_object(), + ..Default::default() + } + }); if let Some(sampler_ycbcr_conversion_info) = sampler_ycbcr_conversion_info.as_mut() { sampler_ycbcr_conversion_info.p_next = create_info.p_next; @@ -811,7 +810,7 @@ impl fmt::Display for ImageViewCreationError { #[inline] fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { - Self::OomError(err) => write!( + Self::OomError(_) => write!( fmt, "allocating memory failed", ), @@ -854,7 +853,7 @@ impl fmt::Display for ImageViewCreationError { fmt, "the format requires a sampler YCbCr conversion, but none was provided", ), - Self::FormatUsageNotSupported { usage } => write!( + Self::FormatUsageNotSupported { .. } => write!( fmt, "a requested usage flag was not supported by the given format" ), diff --git a/vulkano/src/instance/debug.rs b/vulkano/src/instance/debug.rs index 39918812..f11e5b37 100644 --- a/vulkano/src/instance/debug.rs +++ b/vulkano/src/instance/debug.rs @@ -63,7 +63,7 @@ pub(super) type UserCallback = Arc, - user_callback: Box, + _user_callback: Box, } impl DebugUtilsMessenger { @@ -86,7 +86,7 @@ impl DebugUtilsMessenger { Ok(DebugUtilsMessenger { handle, instance, - user_callback, + _user_callback: user_callback, }) } @@ -97,7 +97,7 @@ impl DebugUtilsMessenger { let &mut DebugUtilsMessengerCreateInfo { message_type, message_severity, - ref user_callback, + user_callback: _, _ne: _, } = create_info; @@ -185,7 +185,7 @@ impl fmt::Debug for DebugUtilsMessenger { let Self { handle, instance, - user_callback: _, + _user_callback: _, } = self; f.debug_struct("DebugUtilsMessenger") diff --git a/vulkano/src/instance/extensions.rs b/vulkano/src/instance/extensions.rs index efbd38c4..5340127a 100644 --- a/vulkano/src/instance/extensions.rs +++ b/vulkano/src/instance/extensions.rs @@ -27,6 +27,6 @@ mod tests { #[test] fn empty_extensions() { let i: Vec = (&InstanceExtensions::none()).into(); - assert!(i.iter().next().is_none()); + assert!(i.get(0).is_none()); } } diff --git a/vulkano/src/instance/layers.rs b/vulkano/src/instance/layers.rs index c1d2bde7..dd23f06c 100644 --- a/vulkano/src/instance/layers.rs +++ b/vulkano/src/instance/layers.rs @@ -118,11 +118,11 @@ mod tests { Err(_) => return, }; - let mut list = match library.layer_properties() { + let list = match library.layer_properties() { Ok(l) => l, Err(_) => return, }; - while let Some(_) = list.next() {} + for _ in list {} } } diff --git a/vulkano/src/instance/mod.rs b/vulkano/src/instance/mod.rs index bf2a6a03..25457409 100644 --- a/vulkano/src/instance/mod.rs +++ b/vulkano/src/instance/mod.rs @@ -241,7 +241,7 @@ pub struct Instance { enabled_layers: Vec, library: Arc, max_api_version: Version, - user_callbacks: Vec>, + _user_callbacks: Vec>, } // TODO: fix the underlying cause instead @@ -323,7 +323,7 @@ impl Instance { } // Check if the extensions are correct - enabled_extensions.check_requirements(&supported_extensions, api_version)?; + enabled_extensions.check_requirements(supported_extensions, api_version)?; // FIXME: check whether each layer is supported let enabled_layers_cstr: Vec = enabled_layers @@ -453,7 +453,7 @@ impl Instance { enabled_layers, library, max_api_version, - user_callbacks, + _user_callbacks: user_callbacks, }; // Enumerating all physical devices. @@ -550,7 +550,7 @@ impl fmt::Debug for Instance { enabled_layers, library: function_pointers, max_api_version, - user_callbacks: _, + _user_callbacks: _, } = self; f.debug_struct("Instance") diff --git a/vulkano/src/lib.rs b/vulkano/src/lib.rs index 79acbcf3..0420f0c0 100644 --- a/vulkano/src/lib.rs +++ b/vulkano/src/lib.rs @@ -62,8 +62,24 @@ //! //#![warn(missing_docs)] // TODO: activate -#![allow(dead_code)] // TODO: remove -#![allow(unused_variables)] // TODO: remove + +// These lints are a bit too pedantic, so they're disabled here. +#![allow( + clippy::collapsible_else_if, + clippy::collapsible_if, + clippy::large_enum_variant, + clippy::len_without_is_empty, + clippy::missing_safety_doc, // TODO: remove + clippy::module_inception, + clippy::mutable_key_type, + clippy::new_without_default, + clippy::nonminimal_bool, + clippy::op_ref, // Seems to be bugged, the fixed code triggers a compile error + clippy::too_many_arguments, + clippy::type_complexity, + clippy::vec_box, + clippy::wrong_self_convention +)] pub use ash::vk::Handle; pub use half; diff --git a/vulkano/src/library.rs b/vulkano/src/library.rs index 20b43cef..300a0094 100644 --- a/vulkano/src/library.rs +++ b/vulkano/src/library.rs @@ -264,14 +264,14 @@ where impl fmt::Debug for dyn Loader { #[inline] - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { Ok(()) } } /// Implementation of `Loader` that loads Vulkan from a dynamic library. pub struct DynamicLibraryLoader { - vk_lib: Library, + _vk_lib: Library, get_instance_proc_addr: ash::vk::PFN_vkGetInstanceProcAddr, } @@ -294,7 +294,7 @@ impl DynamicLibraryLoader { .map_err(LoadingError::LibraryLoadFailure)?; Ok(DynamicLibraryLoader { - vk_lib, + _vk_lib: vk_lib, get_instance_proc_addr, }) } diff --git a/vulkano/src/memory/device_memory.rs b/vulkano/src/memory/device_memory.rs index 696472c1..f799a762 100644 --- a/vulkano/src/memory/device_memory.rs +++ b/vulkano/src/memory/device_memory.rs @@ -12,7 +12,6 @@ use crate::{ device::{physical::MemoryType, Device, DeviceOwned}, DeviceSize, OomError, Version, VulkanError, VulkanObject, }; -use parking_lot::Mutex; use std::{ error::Error, ffi::c_void, @@ -55,8 +54,6 @@ pub struct DeviceMemory { allocation_size: DeviceSize, memory_type_index: u32, export_handle_types: ExternalMemoryHandleTypes, - - mapped: Mutex, } impl DeviceMemory { @@ -80,7 +77,7 @@ impl DeviceMemory { let MemoryAllocateInfo { allocation_size, memory_type_index, - dedicated_allocation, + dedicated_allocation: _, export_handle_types, _ne: _, } = allocate_info; @@ -92,8 +89,6 @@ impl DeviceMemory { allocation_size, memory_type_index, export_handle_types, - - mapped: Mutex::new(false), }) } @@ -119,7 +114,7 @@ impl DeviceMemory { let MemoryAllocateInfo { allocation_size, memory_type_index, - dedicated_allocation, + dedicated_allocation: _, export_handle_types, _ne: _, } = allocate_info; @@ -131,8 +126,6 @@ impl DeviceMemory { allocation_size, memory_type_index, export_handle_types, - - mapped: Mutex::new(false), }) } @@ -246,7 +239,7 @@ impl DeviceMemory { match import_info { &mut MemoryImportInfo::Fd { handle_type, - ref file, + file: _, } => { if !device.enabled_extensions().khr_external_memory_fd { return Err(DeviceMemoryAllocationError::ExtensionNotEnabled { @@ -319,8 +312,8 @@ impl DeviceMemory { .memory_type_index(memory_type_index); // VUID-VkMemoryDedicatedAllocateInfo-image-01432 - let mut dedicated_allocate_info = if let Some(dedicated_allocation) = dedicated_allocation { - Some(match dedicated_allocation { + let mut dedicated_allocate_info = + dedicated_allocation.map(|dedicated_allocation| match dedicated_allocation { DedicatedAllocation::Buffer(buffer) => ash::vk::MemoryDedicatedAllocateInfo { buffer: buffer.internal_object(), ..Default::default() @@ -329,10 +322,7 @@ impl DeviceMemory { image: image.internal_object(), ..Default::default() }, - }) - } else { - None - }; + }); if let Some(info) = dedicated_allocate_info.as_mut() { allocate_info = allocate_info.push_next(info); @@ -1528,8 +1518,7 @@ mod tests { let memory_type = device .physical_device() .memory_types() - .filter(|m| !m.is_lazily_allocated()) - .next() + .find(|m| !m.is_lazily_allocated()) .unwrap(); match DeviceMemory::allocate( @@ -1552,8 +1541,7 @@ mod tests { let memory_type = device .physical_device() .memory_types() - .filter(|m| !m.is_lazily_allocated()) - .next() + .find(|m| !m.is_lazily_allocated()) .unwrap(); let heap_size = memory_type.heap().size(); @@ -1582,7 +1570,7 @@ mod tests { let (device, _) = gfx_dev_and_queue!(); let memory_type = device.physical_device().memory_types().next().unwrap(); assert_eq!(*device.allocation_count().lock(), 0); - let mem1 = DeviceMemory::allocate( + let _mem1 = DeviceMemory::allocate( device.clone(), MemoryAllocateInfo { allocation_size: 256, @@ -1593,7 +1581,7 @@ mod tests { .unwrap(); assert_eq!(*device.allocation_count().lock(), 1); { - let mem2 = DeviceMemory::allocate( + let _mem2 = DeviceMemory::allocate( device.clone(), MemoryAllocateInfo { allocation_size: 256, diff --git a/vulkano/src/memory/pool/host_visible.rs b/vulkano/src/memory/pool/host_visible.rs index bb7cc91e..5e3fe706 100644 --- a/vulkano/src/memory/pool/host_visible.rs +++ b/vulkano/src/memory/pool/host_visible.rs @@ -52,7 +52,7 @@ impl StandardHostVisibleMemoryTypePool { assert!(memory_type.is_host_visible()); Arc::new(StandardHostVisibleMemoryTypePool { - device: device.clone(), + device, memory_type: memory_type.id(), occupied: Mutex::new(Vec::new()), }) diff --git a/vulkano/src/memory/pool/mod.rs b/vulkano/src/memory/pool/mod.rs index 11108935..fcfc6636 100644 --- a/vulkano/src/memory/pool/mod.rs +++ b/vulkano/src/memory/pool/mod.rs @@ -60,8 +60,7 @@ where first_loop .chain(second_loop) .filter(|&(t, _)| (requirements.memory_type_bits & (1 << t.id())) != 0) - .filter(|&(t, rq)| filter(t) == rq) - .next() + .find(|&(t, rq)| filter(t) == rq) .expect("Couldn't find a memory type to allocate from") .0 }; @@ -73,7 +72,7 @@ where pub(crate) fn alloc_dedicated_with_exportable_fd( device: Arc, requirements: &MemoryRequirements, - layout: AllocLayout, + _layout: AllocLayout, map: MappingRequirement, dedicated_allocation: DedicatedAllocation, filter: F, diff --git a/vulkano/src/memory/pool/non_host_visible.rs b/vulkano/src/memory/pool/non_host_visible.rs index 04d25bff..5db53316 100644 --- a/vulkano/src/memory/pool/non_host_visible.rs +++ b/vulkano/src/memory/pool/non_host_visible.rs @@ -47,7 +47,7 @@ impl StandardNonHostVisibleMemoryTypePool { ); Arc::new(StandardNonHostVisibleMemoryTypePool { - device: device.clone(), + device, memory_type: memory_type.id(), occupied: Mutex::new(Vec::new()), }) diff --git a/vulkano/src/memory/pool/pool.rs b/vulkano/src/memory/pool/pool.rs index 0133e654..a040f3fe 100644 --- a/vulkano/src/memory/pool/pool.rs +++ b/vulkano/src/memory/pool/pool.rs @@ -40,7 +40,7 @@ impl StandardMemoryPool { let cap = device.physical_device().memory_types().len(); Arc::new(StandardMemoryPool { - device: device.clone(), + device, pools: Mutex::new(HashMap::with_capacity(cap)), }) } @@ -60,21 +60,21 @@ fn generic_allocation( assert!(memory_type_host_visible || map == MappingRequirement::DoNotMap); match pools.entry((memory_type.id(), layout, map)) { - Entry::Occupied(entry) => match entry.get() { - &Pool::HostVisible(ref pool) => { + Entry::Occupied(entry) => match *entry.get() { + Pool::HostVisible(ref pool) => { let alloc = pool.alloc(size, alignment)?; let inner = StandardMemoryPoolAllocInner::HostVisible(alloc); Ok(StandardMemoryPoolAlloc { inner, - pool: mem_pool.clone(), + _pool: mem_pool.clone(), }) } - &Pool::NonHostVisible(ref pool) => { + Pool::NonHostVisible(ref pool) => { let alloc = pool.alloc(size, alignment)?; let inner = StandardMemoryPoolAllocInner::NonHostVisible(alloc); Ok(StandardMemoryPoolAlloc { inner, - pool: mem_pool.clone(), + _pool: mem_pool.clone(), }) } }, @@ -88,7 +88,7 @@ fn generic_allocation( let inner = StandardMemoryPoolAllocInner::HostVisible(alloc); Ok(StandardMemoryPoolAlloc { inner, - pool: mem_pool.clone(), + _pool: mem_pool.clone(), }) } else { let pool = @@ -98,7 +98,7 @@ fn generic_allocation( let inner = StandardMemoryPoolAllocInner::NonHostVisible(alloc); Ok(StandardMemoryPoolAlloc { inner, - pool: mem_pool.clone(), + _pool: mem_pool.clone(), }) } } @@ -136,7 +136,7 @@ enum Pool { #[derive(Debug)] pub struct StandardMemoryPoolAlloc { inner: StandardMemoryPoolAllocInner, - pool: Arc, + _pool: Arc, } impl StandardMemoryPoolAlloc { diff --git a/vulkano/src/pipeline/cache.rs b/vulkano/src/pipeline/cache.rs index cc1b54f1..b7baedd2 100644 --- a/vulkano/src/pipeline/cache.rs +++ b/vulkano/src/pipeline/cache.rs @@ -127,7 +127,7 @@ impl PipelineCache { Ok(Arc::new(PipelineCache { device: device.clone(), - cache: cache, + cache, })) } @@ -151,7 +151,7 @@ impl PipelineCache { let pipelines = pipelines .into_iter() .map(|pipeline| { - assert!(&***pipeline as *const _ != &*self as *const _); + assert!(&***pipeline as *const _ != self as *const _); pipeline.cache }) .collect::>(); @@ -264,11 +264,10 @@ mod tests { pipeline::{cache::PipelineCache, ComputePipeline}, shader::ShaderModule, }; - use std::sync::Arc; #[test] fn merge_self_forbidden() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let pipeline = PipelineCache::empty(device).unwrap(); assert_should_panic!({ pipeline.merge(&[&pipeline]).unwrap(); @@ -277,7 +276,7 @@ mod tests { #[test] fn cache_returns_same_data() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let cache = PipelineCache::empty(device.clone()).unwrap(); @@ -300,16 +299,14 @@ mod tests { ShaderModule::from_bytes(device.clone(), &MODULE).unwrap() }; - let pipeline = Arc::new( - ComputePipeline::new( - device.clone(), - module.entry_point("main").unwrap(), - &(), - Some(cache.clone()), - |_| {}, - ) - .unwrap(), - ); + let _pipeline = ComputePipeline::new( + device, + module.entry_point("main").unwrap(), + &(), + Some(cache.clone()), + |_| {}, + ) + .unwrap(); let cache_data = cache.get_data().unwrap(); let second_data = cache.get_data().unwrap(); @@ -319,7 +316,7 @@ mod tests { #[test] fn cache_returns_different_data() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let cache = PipelineCache::empty(device.clone()).unwrap(); @@ -373,29 +370,25 @@ mod tests { ShaderModule::from_bytes(device.clone(), &SECOND_MODULE).unwrap() }; - let pipeline = Arc::new( - ComputePipeline::new( - device.clone(), - first_module.entry_point("main").unwrap(), - &(), - Some(cache.clone()), - |_| {}, - ) - .unwrap(), - ); + let _pipeline = ComputePipeline::new( + device.clone(), + first_module.entry_point("main").unwrap(), + &(), + Some(cache.clone()), + |_| {}, + ) + .unwrap(); let cache_data = cache.get_data().unwrap(); - let second_pipeline = Arc::new( - ComputePipeline::new( - device.clone(), - second_module.entry_point("main").unwrap(), - &(), - Some(cache.clone()), - |_| {}, - ) - .unwrap(), - ); + let _second_pipeline = ComputePipeline::new( + device, + second_module.entry_point("main").unwrap(), + &(), + Some(cache.clone()), + |_| {}, + ) + .unwrap(); let second_data = cache.get_data().unwrap(); @@ -408,7 +401,7 @@ mod tests { #[test] fn cache_data_does_not_change() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let cache = PipelineCache::empty(device.clone()).unwrap(); @@ -431,29 +424,25 @@ mod tests { ShaderModule::from_bytes(device.clone(), &MODULE).unwrap() }; - let pipeline = Arc::new( - ComputePipeline::new( - device.clone(), - module.entry_point("main").unwrap(), - &(), - Some(cache.clone()), - |_| {}, - ) - .unwrap(), - ); + let _pipeline = ComputePipeline::new( + device.clone(), + module.entry_point("main").unwrap(), + &(), + Some(cache.clone()), + |_| {}, + ) + .unwrap(); let cache_data = cache.get_data().unwrap(); - let second_pipeline = Arc::new( - ComputePipeline::new( - device.clone(), - module.entry_point("main").unwrap(), - &(), - Some(cache.clone()), - |_| {}, - ) - .unwrap(), - ); + let _second_pipeline = ComputePipeline::new( + device, + module.entry_point("main").unwrap(), + &(), + Some(cache.clone()), + |_| {}, + ) + .unwrap(); let second_data = cache.get_data().unwrap(); diff --git a/vulkano/src/pipeline/compute.rs b/vulkano/src/pipeline/compute.rs index 1ac90b62..3b6b2b31 100644 --- a/vulkano/src/pipeline/compute.rs +++ b/vulkano/src/pipeline/compute.rs @@ -512,8 +512,8 @@ mod tests { .unwrap(); let cb = cbb.build().unwrap(); - let future = now(device.clone()) - .then_execute(queue.clone(), cb) + let future = now(device) + .then_execute(queue, cb) .unwrap() .then_signal_fence_and_flush() .unwrap(); diff --git a/vulkano/src/pipeline/graphics/builder.rs b/vulkano/src/pipeline/graphics/builder.rs index 4a4abf69..8cdc04cb 100644 --- a/vulkano/src/pipeline/graphics/builder.rs +++ b/vulkano/src/pipeline/graphics/builder.rs @@ -184,8 +184,7 @@ where for (loc, reqs) in stages .iter() - .map(|shader| shader.descriptor_requirements()) - .flatten() + .flat_map(|shader| shader.descriptor_requirements()) { match descriptor_requirements.entry(loc) { Entry::Occupied(entry) => { @@ -292,22 +291,22 @@ where let has = { let &Self { ref render_pass, - ref cache, + cache: _, ref vertex_shader, ref tessellation_shaders, - ref geometry_shader, - ref fragment_shader, + geometry_shader: _, + fragment_shader: _, vertex_input_state: _, - ref input_assembly_state, - ref tessellation_state, - ref viewport_state, - ref discard_rectangle_state, + input_assembly_state: _, + tessellation_state: _, + viewport_state: _, + discard_rectangle_state: _, ref rasterization_state, - ref multisample_state, - ref depth_stencil_state, - ref color_blend_state, + multisample_state: _, + depth_stencil_state: _, + color_blend_state: _, } = &self; let render_pass = render_pass.as_ref().expect("Missing render pass"); @@ -363,11 +362,11 @@ where let Self { mut render_pass, - cache, - vertex_shader, - tessellation_shaders, - geometry_shader, - fragment_shader, + cache: _, + vertex_shader: _, + tessellation_shaders: _, + geometry_shader: _, + fragment_shader: _, vertex_input_state: _, input_assembly_state, tessellation_state, @@ -422,7 +421,7 @@ where let &Self { ref render_pass, - ref cache, + cache: _, ref vertex_shader, ref tessellation_shaders, @@ -747,7 +746,7 @@ where } _ => (), }, - PartialStateMode::Dynamic(topology_class) => { + PartialStateMode::Dynamic(_topology_class) => { // VUID? if !(device.api_version() >= Version::V1_3 || device.enabled_features().extended_dynamic_state) @@ -820,7 +819,7 @@ where shader_stages.push(ShaderStageInfo { entry_point, specialization_map_entries: Vss::descriptors(), - specialization_data: unsafe { + _specialization_data: unsafe { std::slice::from_raw_parts( specialization_data as *const _ as *const u8, size_of_val(specialization_data), @@ -918,7 +917,7 @@ where shader_stages.push(ShaderStageInfo { entry_point, specialization_map_entries: Tcss::descriptors(), - specialization_data: unsafe { + _specialization_data: unsafe { std::slice::from_raw_parts( specialization_data as *const _ as *const u8, size_of_val(specialization_data), @@ -938,7 +937,7 @@ where shader_stages.push(ShaderStageInfo { entry_point, specialization_map_entries: Tess::descriptors(), - specialization_data: unsafe { + _specialization_data: unsafe { std::slice::from_raw_parts( specialization_data as *const _ as *const u8, size_of_val(specialization_data), @@ -985,7 +984,7 @@ where shader_stages.push(ShaderStageInfo { entry_point, specialization_map_entries: Gss::descriptors(), - specialization_data: unsafe { + _specialization_data: unsafe { std::slice::from_raw_parts( specialization_data as *const _ as *const u8, size_of_val(specialization_data), @@ -1249,14 +1248,14 @@ where // Discard rectangle state { let &DiscardRectangleState { - mode, + mode: _, ref rectangles, } = discard_rectangle_state; if device.enabled_extensions().ext_discard_rectangles { - let discard_rectangle_count = match rectangles { - &PartialStateMode::Dynamic(count) => count, - &PartialStateMode::Fixed(ref rectangles) => rectangles.len() as u32, + let discard_rectangle_count = match *rectangles { + PartialStateMode::Dynamic(count) => count, + PartialStateMode::Fixed(ref rectangles) => rectangles.len() as u32, }; // VUID-VkPipelineDiscardRectangleStateCreateInfoEXT-discardRectangleCount-00582 @@ -1269,9 +1268,9 @@ where ); } } else { - let error = match rectangles { - &PartialStateMode::Dynamic(_) => true, - &PartialStateMode::Fixed(ref rectangles) => !rectangles.is_empty(), + let error = match *rectangles { + PartialStateMode::Dynamic(_) => true, + PartialStateMode::Fixed(ref rectangles) => !rectangles.is_empty(), }; if error { @@ -1311,7 +1310,7 @@ where match patch_control_points { StateMode::Fixed(patch_control_points) => { // VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214 - if patch_control_points <= 0 + if patch_control_points == 0 || patch_control_points > properties.max_tessellation_patch_size { return Err(GraphicsPipelineCreationError::InvalidNumPatchControlPoints); @@ -1336,8 +1335,8 @@ where // VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750 // VUID-VkGraphicsPipelineCreateInfo-pViewportState-04892 if has.viewport_state { - let (viewport_count, scissor_count) = match viewport_state { - &ViewportState::Fixed { ref data } => { + let (viewport_count, scissor_count) = match *viewport_state { + ViewportState::Fixed { ref data } => { let count = data.len() as u32; assert!(count != 0); // TODO: return error? @@ -1365,7 +1364,7 @@ where (count, count) } - &ViewportState::FixedViewport { + ViewportState::FixedViewport { ref viewports, scissor_count_dynamic, } => { @@ -1411,7 +1410,7 @@ where (viewport_count, scissor_count) } - &ViewportState::FixedScissor { + ViewportState::FixedScissor { ref scissors, viewport_count_dynamic, } => { @@ -1443,7 +1442,7 @@ where (viewport_count, scissor_count) } - &ViewportState::Dynamic { + ViewportState::Dynamic { count, viewport_count_dynamic, scissor_count_dynamic, @@ -1532,7 +1531,7 @@ where shader_stages.push(ShaderStageInfo { entry_point, specialization_map_entries: Fss::descriptors(), - specialization_data: unsafe { + _specialization_data: unsafe { std::slice::from_raw_parts( specialization_data as *const _ as *const u8, size_of_val(specialization_data), @@ -1779,8 +1778,8 @@ where let &MultisampleState { rasterization_samples, sample_shading, - sample_mask, - alpha_to_coverage_enable, + sample_mask: _, + alpha_to_coverage_enable: _, alpha_to_one_enable, } = multisample_state; @@ -1816,7 +1815,7 @@ where // VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786 // TODO: return error? - assert!(min_sample_shading >= 0.0 && min_sample_shading <= 1.0); + assert!((0.0..=1.0).contains(&min_sample_shading)); } // VUID-VkPipelineMultisampleStateCreateInfo-alphaToOneEnable-00785 @@ -1839,7 +1838,7 @@ where let &ColorBlendState { logic_op, ref attachments, - blend_constants, + blend_constants: _, } = color_blend_state; if let Some(logic_op) = logic_op { @@ -1888,18 +1887,18 @@ where // VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 if !iter.all(|state| state == first) { return Err( - GraphicsPipelineCreationError::FeatureNotEnabled { - feature: "independent_blend", - reason: "The blend and color_write_mask members of all elements of ColorBlendState::attachments were not identical", - }, - ); + GraphicsPipelineCreationError::FeatureNotEnabled { + feature: "independent_blend", + reason: "The blend and color_write_mask members of all elements of ColorBlendState::attachments were not identical", + }, + ); } } for (attachment_index, state) in attachments.iter().enumerate() { let &ColorBlendAttachmentState { blend, - color_write_mask, + color_write_mask: _, color_write_enable, } = state; @@ -2566,13 +2565,13 @@ where ref rectangles, } = discard_rectangle_state; - let discard_rectangle_count = match rectangles { - &PartialStateMode::Fixed(ref rectangles) => { + let discard_rectangle_count = match *rectangles { + PartialStateMode::Fixed(ref rectangles) => { dynamic_state.insert(DynamicState::DiscardRectangle, false); discard_rectangles.extend(rectangles.iter().map(|&rect| rect.into())); discard_rectangles.len() as u32 } - &PartialStateMode::Dynamic(count) => { + PartialStateMode::Dynamic(count) => { dynamic_state.insert(DynamicState::DiscardRectangle, true); count } @@ -2616,20 +2615,20 @@ where // Viewport state if has.viewport_state { - let (viewport_count, scissor_count) = match viewport_state { - &ViewportState::Fixed { ref data } => { + let (viewport_count, scissor_count) = match *viewport_state { + ViewportState::Fixed { ref data } => { let count = data.len() as u32; viewports_vk.extend(data.iter().map(|e| e.0.clone().into())); dynamic_state.insert(DynamicState::Viewport, false); dynamic_state.insert(DynamicState::ViewportWithCount, false); - scissors_vk.extend(data.iter().map(|e| e.1.clone().into())); + scissors_vk.extend(data.iter().map(|e| e.1.into())); dynamic_state.insert(DynamicState::Scissor, false); dynamic_state.insert(DynamicState::ScissorWithCount, false); (count, count) } - &ViewportState::FixedViewport { + ViewportState::FixedViewport { ref viewports, scissor_count_dynamic, } => { @@ -2650,12 +2649,12 @@ where (viewport_count, scissor_count) } - &ViewportState::FixedScissor { + ViewportState::FixedScissor { ref scissors, viewport_count_dynamic, } => { let scissor_count = scissors.len() as u32; - scissors_vk.extend(scissors.iter().map(|e| e.clone().into())); + scissors_vk.extend(scissors.iter().map(|e| (*e).into())); dynamic_state.insert(DynamicState::Scissor, false); dynamic_state.insert(DynamicState::ScissorWithCount, false); @@ -2671,7 +2670,7 @@ where (viewport_count, scissor_count) } - &ViewportState::Dynamic { + ViewportState::Dynamic { count, viewport_count_dynamic, scissor_count_dynamic, @@ -3006,11 +3005,11 @@ where let &ColorBlendAttachmentState { blend, color_write_mask, - color_write_enable, + color_write_enable: _, } = color_blend_attachment_state; let blend = if let Some(blend) = blend { - blend.clone().into() + blend.into() } else { Default::default() }; @@ -3072,8 +3071,8 @@ where color_write_enables_vk.extend(attachments.iter().map( |color_blend_attachment_state| { let &ColorBlendAttachmentState { - blend, - color_write_mask, + blend: _, + color_write_mask: _, color_write_enable, } = color_blend_attachment_state; @@ -3223,7 +3222,7 @@ where struct ShaderStageInfo<'a> { entry_point: &'a EntryPoint<'a>, specialization_map_entries: &'a [SpecializationMapEntry], - specialization_data: &'a [u8], + _specialization_data: &'a [u8], } impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> @@ -3476,7 +3475,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets the tessellation shaders stage as disabled. This is the default. - #[deprecated(since = "0.27")] + #[deprecated(since = "0.27.0")] #[inline] pub fn tessellation_shaders_disabled(mut self) -> Self { self.tessellation_shaders = None; @@ -3484,7 +3483,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets the geometry shader stage as disabled. This is the default. - #[deprecated(since = "0.27")] + #[deprecated(since = "0.27.0")] #[inline] pub fn geometry_shader_disabled(mut self) -> Self { self.geometry_shader = None; @@ -3495,7 +3494,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// You will most likely need to explicitly specify the template parameter to the type of a /// vertex. - #[deprecated(since = "0.27", note = "Use `vertex_input_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `vertex_input_state` instead")] #[inline] pub fn vertex_input_single_buffer( self, @@ -3516,7 +3515,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets whether primitive restart is enabled. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn primitive_restart(mut self, enabled: bool) -> Self { self.input_assembly_state.primitive_restart_enable = StateMode::Fixed(enabled); @@ -3524,7 +3523,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets the topology of the primitives that are expected by the pipeline. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn primitive_topology(mut self, topology: PrimitiveTopology) -> Self { self.input_assembly_state.topology = PartialStateMode::Fixed(topology); @@ -3535,7 +3534,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::PointList)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn point_list(self) -> Self { self.primitive_topology(PrimitiveTopology::PointList) @@ -3545,7 +3544,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::LineList)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn line_list(self) -> Self { self.primitive_topology(PrimitiveTopology::LineList) @@ -3555,7 +3554,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::LineStrip)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn line_strip(self) -> Self { self.primitive_topology(PrimitiveTopology::LineStrip) @@ -3565,7 +3564,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::TriangleList)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn triangle_list(self) -> Self { self.primitive_topology(PrimitiveTopology::TriangleList) @@ -3575,7 +3574,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::TriangleStrip)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn triangle_strip(self) -> Self { self.primitive_topology(PrimitiveTopology::TriangleStrip) @@ -3585,7 +3584,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::TriangleFan)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn triangle_fan(self) -> Self { self.primitive_topology(PrimitiveTopology::TriangleFan) @@ -3595,7 +3594,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::LineListWithAdjacency)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn line_list_with_adjacency(self) -> Self { self.primitive_topology(PrimitiveTopology::LineListWithAdjacency) @@ -3605,7 +3604,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::LineStripWithAdjacency)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn line_strip_with_adjacency(self) -> Self { self.primitive_topology(PrimitiveTopology::LineStripWithAdjacency) @@ -3615,7 +3614,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::TriangleListWithAdjacency)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn triangle_list_with_adjacency(self) -> Self { self.primitive_topology(PrimitiveTopology::TriangleListWithAdjacency) @@ -3625,7 +3624,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::TriangleStripWithAdjacency)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn triangle_strip_with_adjacency(self) -> Self { self.primitive_topology(PrimitiveTopology::TriangleStripWithAdjacency) @@ -3636,7 +3635,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is equivalent to /// > `self.primitive_topology(PrimitiveTopology::PatchList)`. - #[deprecated(since = "0.27", note = "Use `input_assembly_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] pub fn patch_list(self) -> Self { self.primitive_topology(PrimitiveTopology::PatchList) @@ -3644,7 +3643,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Sets the viewports to some value, and the scissor boxes to boxes that always cover the /// whole viewport. - #[deprecated(since = "0.27", note = "Use `viewport_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `viewport_state` instead")] #[inline] pub fn viewports(self, viewports: I) -> Self where @@ -3654,7 +3653,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets the characteristics of viewports and scissor boxes in advance. - #[deprecated(since = "0.27", note = "Use `viewport_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `viewport_state` instead")] #[inline] pub fn viewports_scissors(mut self, viewports: I) -> Self where @@ -3668,7 +3667,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Sets the scissor boxes to some values, and viewports to dynamic. The viewports will /// need to be set before drawing. - #[deprecated(since = "0.27", note = "Use `viewport_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `viewport_state` instead")] #[inline] pub fn viewports_dynamic_scissors_fixed(mut self, scissors: I) -> Self where @@ -3683,7 +3682,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Sets the viewports to dynamic, and the scissor boxes to boxes that always cover the whole /// viewport. The viewports will need to be set before drawing. - #[deprecated(since = "0.27", note = "Use `viewport_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `viewport_state` instead")] #[inline] pub fn viewports_dynamic_scissors_irrelevant(mut self, num: u32) -> Self { self.viewport_state = ViewportState::FixedScissor { @@ -3695,7 +3694,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Sets the viewports to some values, and scissor boxes to dynamic. The scissor boxes will /// need to be set before drawing. - #[deprecated(since = "0.27", note = "Use `viewport_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `viewport_state` instead")] #[inline] pub fn viewports_fixed_scissors_dynamic(mut self, viewports: I) -> Self where @@ -3710,7 +3709,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Sets the viewports and scissor boxes to dynamic. They will both need to be set before /// drawing. - #[deprecated(since = "0.27", note = "Use `viewport_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `viewport_state` instead")] #[inline] pub fn viewports_scissors_dynamic(mut self, count: u32) -> Self { self.viewport_state = ViewportState::Dynamic { @@ -3724,7 +3723,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// If true, then the depth value of the vertices will be clamped to the range `[0.0 ; 1.0]`. /// If false, fragments whose depth is outside of this range will be discarded before the /// fragment shader even runs. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn depth_clamp(mut self, clamp: bool) -> Self { self.rasterization_state.depth_clamp_enable = clamp; @@ -3735,7 +3734,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// Triangles whose vertices are oriented counter-clockwise on the screen will be considered /// as facing their front. Otherwise they will be considered as facing their back. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn front_face_counter_clockwise(mut self) -> Self { self.rasterization_state.front_face = StateMode::Fixed(FrontFace::CounterClockwise); @@ -3746,7 +3745,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// Triangles whose vertices are oriented clockwise on the screen will be considered /// as facing their front. Otherwise they will be considered as facing their back. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn front_face_clockwise(mut self) -> Self { self.rasterization_state.front_face = StateMode::Fixed(FrontFace::Clockwise); @@ -3754,7 +3753,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets backface culling as disabled. This is the default. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn cull_mode_disabled(mut self) -> Self { self.rasterization_state.cull_mode = StateMode::Fixed(CullMode::None); @@ -3763,7 +3762,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Sets backface culling to front faces. The front faces (as chosen with the `front_face_*` /// methods) will be discarded by the GPU when drawing. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn cull_mode_front(mut self) -> Self { self.rasterization_state.cull_mode = StateMode::Fixed(CullMode::Front); @@ -3772,7 +3771,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Sets backface culling to back faces. Faces that are not facing the front (as chosen with /// the `front_face_*` methods) will be discarded by the GPU when drawing. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn cull_mode_back(mut self) -> Self { self.rasterization_state.cull_mode = StateMode::Fixed(CullMode::Back); @@ -3783,7 +3782,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This option exists for the sake of completeness. It has no known practical /// > usage. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn cull_mode_front_and_back(mut self) -> Self { self.rasterization_state.cull_mode = StateMode::Fixed(CullMode::FrontAndBack); @@ -3791,7 +3790,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets the polygon mode to "fill". This is the default. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn polygon_mode_fill(mut self) -> Self { self.rasterization_state.polygon_mode = PolygonMode::Fill; @@ -3799,7 +3798,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets the polygon mode to "line". Triangles will each be turned into three lines. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn polygon_mode_line(mut self) -> Self { self.rasterization_state.polygon_mode = PolygonMode::Line; @@ -3807,7 +3806,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets the polygon mode to "point". Triangles and lines will each be turned into three points. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn polygon_mode_point(mut self) -> Self { self.rasterization_state.polygon_mode = PolygonMode::Point; @@ -3815,7 +3814,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets the width of the lines, if the GPU needs to draw lines. The default is `1.0`. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn line_width(mut self, value: f32) -> Self { self.rasterization_state.line_width = StateMode::Fixed(value); @@ -3824,7 +3823,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Sets the width of the lines as dynamic, which means that you will need to set this value /// when drawing. - #[deprecated(since = "0.27", note = "Use `rasterization_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `rasterization_state` instead")] #[inline] pub fn line_width_dynamic(mut self) -> Self { self.rasterization_state.line_width = StateMode::Dynamic; @@ -3836,7 +3835,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// samples. /// /// Sample shading is disabled by default. - #[deprecated(since = "0.27", note = "Use `multisample_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `multisample_state` instead")] #[inline] pub fn sample_shading_disabled(mut self) -> Self { self.multisample_state.sample_shading = None; @@ -3859,23 +3858,23 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// - Panics if `min_fract` is not between 0.0 and 1.0. /// - #[deprecated(since = "0.27", note = "Use `multisample_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `multisample_state` instead")] #[inline] pub fn sample_shading_enabled(mut self, min_fract: f32) -> Self { - assert!(min_fract >= 0.0 && min_fract <= 1.0); + assert!((0.0..=1.0).contains(&min_fract)); self.multisample_state.sample_shading = Some(min_fract); self } // TODO: doc - #[deprecated(since = "0.27", note = "Use `multisample_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `multisample_state` instead")] pub fn alpha_to_coverage_disabled(mut self) -> Self { self.multisample_state.alpha_to_coverage_enable = false; self } // TODO: doc - #[deprecated(since = "0.27", note = "Use `multisample_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `multisample_state` instead")] pub fn alpha_to_coverage_enabled(mut self) -> Self { self.multisample_state.alpha_to_coverage_enable = true; self @@ -3884,7 +3883,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Disables alpha-to-one. /// /// Alpha-to-one is disabled by default. - #[deprecated(since = "0.27", note = "Use `multisample_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `multisample_state` instead")] #[inline] pub fn alpha_to_one_disabled(mut self) -> Self { self.multisample_state.alpha_to_one_enable = false; @@ -3897,7 +3896,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Enabling alpha-to-one requires the `alpha_to_one` feature to be enabled on the device. /// /// Alpha-to-one is disabled by default. - #[deprecated(since = "0.27", note = "Use `multisample_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `multisample_state` instead")] #[inline] pub fn alpha_to_one_enabled(mut self) -> Self { self.multisample_state.alpha_to_one_enable = true; @@ -3905,7 +3904,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets the depth/stencil state. - #[deprecated(since = "0.27", note = "Use `depth_stencil_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `depth_stencil_state` instead")] #[inline] pub fn depth_stencil(self, depth_stencil_state: DepthStencilState) -> Self { self.depth_stencil_state(depth_stencil_state) @@ -3915,7 +3914,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is a shortcut for all the other `depth_*` and `depth_stencil_*` methods /// > of the builder. - #[deprecated(since = "0.27", note = "Use `depth_stencil_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `depth_stencil_state` instead")] #[inline] pub fn depth_stencil_disabled(mut self) -> Self { self.depth_stencil_state = DepthStencilState::disabled(); @@ -3926,7 +3925,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// /// > **Note**: This is a shortcut for setting the depth test to `Less`, the depth write Into /// > ` true` and disable the stencil test. - #[deprecated(since = "0.27", note = "Use `depth_stencil_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `depth_stencil_state` instead")] #[inline] pub fn depth_stencil_simple_depth(mut self) -> Self { self.depth_stencil_state = DepthStencilState::simple_depth_test(); @@ -3934,7 +3933,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets whether the depth buffer will be written. - #[deprecated(since = "0.27", note = "Use `depth_stencil_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `depth_stencil_state` instead")] #[inline] pub fn depth_write(mut self, write: bool) -> Self { let depth_state = self @@ -3945,7 +3944,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> self } - #[deprecated(since = "0.27", note = "Use `color_blend_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `color_blend_state` instead")] // TODO: When this method is removed, also remove the special casing in `with_pipeline_layout` // for self.color_blend_state.attachments.len() == 1 #[inline] @@ -3958,7 +3957,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> self } - #[deprecated(since = "0.27", note = "Use `color_blend_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `color_blend_state` instead")] #[inline] pub fn blend_individual(mut self, blend: I) -> Self where @@ -3977,7 +3976,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Each fragment shader output will have its value directly written to the framebuffer /// attachment. This is the default. - #[deprecated(since = "0.27", note = "Use `color_blend_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `color_blend_state` instead")] // TODO: When this method is removed, also remove the special casing in `with_pipeline_layout` // for self.color_blend_state.attachments.len() == 1 #[inline] @@ -3990,7 +3989,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> self } - #[deprecated(since = "0.27", note = "Use `color_blend_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `color_blend_state` instead")] // TODO: When this method is removed, also remove the special casing in `with_pipeline_layout` // for self.color_blend_state.attachments.len() == 1 #[inline] @@ -4003,7 +4002,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> self } - #[deprecated(since = "0.27", note = "Use `color_blend_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `color_blend_state` instead")] #[inline] pub fn blend_logic_op(mut self, logic_op: LogicOp) -> Self { self.color_blend_state.logic_op = Some(StateMode::Fixed(logic_op)); @@ -4011,7 +4010,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> } /// Sets the logic operation as disabled. This is the default. - #[deprecated(since = "0.27", note = "Use `color_blend_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `color_blend_state` instead")] #[inline] pub fn blend_logic_op_disabled(mut self) -> Self { self.color_blend_state.logic_op = None; @@ -4021,7 +4020,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Sets the blend constant. The default is `[0.0, 0.0, 0.0, 0.0]`. /// /// The blend constant is used for some blending calculations. It is irrelevant otherwise. - #[deprecated(since = "0.27", note = "Use `color_blend_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `color_blend_state` instead")] #[inline] pub fn blend_constants(mut self, constants: [f32; 4]) -> Self { self.color_blend_state.blend_constants = StateMode::Fixed(constants); @@ -4031,7 +4030,7 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> /// Sets the blend constant value as dynamic. Its value will need to be set before drawing. /// /// The blend constant is used for some blending calculations. It is irrelevant otherwise. - #[deprecated(since = "0.27", note = "Use `color_blend_state` instead")] + #[deprecated(since = "0.27.0", note = "Use `color_blend_state` instead")] #[inline] pub fn blend_constants_dynamic(mut self) -> Self { self.color_blend_state.blend_constants = StateMode::Dynamic; diff --git a/vulkano/src/pipeline/graphics/mod.rs b/vulkano/src/pipeline/graphics/mod.rs index 4cfbb7eb..50b4a26e 100644 --- a/vulkano/src/pipeline/graphics/mod.rs +++ b/vulkano/src/pipeline/graphics/mod.rs @@ -123,7 +123,7 @@ pub struct GraphicsPipeline { impl GraphicsPipeline { /// Starts the building process of a graphics pipeline. Returns a builder object that you can /// fill with the various parameters. - pub fn start<'a>() -> GraphicsPipelineBuilder< + pub fn start() -> GraphicsPipelineBuilder< 'static, 'static, 'static, diff --git a/vulkano/src/pipeline/graphics/render_pass.rs b/vulkano/src/pipeline/graphics/render_pass.rs index c5fdc83d..cd4a524f 100644 --- a/vulkano/src/pipeline/graphics/render_pass.rs +++ b/vulkano/src/pipeline/graphics/render_pass.rs @@ -7,7 +7,6 @@ // notice may not be copied, modified, or distributed except // according to those terms. -use super::GraphicsPipelineCreationError; use crate::{format::Format, render_pass::Subpass}; /// Selects the type of render pass that a graphics pipeline is created for. @@ -80,9 +79,3 @@ impl Default for PipelineRenderingCreateInfo { } } } - -impl PipelineRenderingCreateInfo { - pub(super) fn validate(&self) -> Result<(), GraphicsPipelineCreationError> { - Ok(()) - } -} diff --git a/vulkano/src/pipeline/graphics/vertex_input/collection.rs b/vulkano/src/pipeline/graphics/vertex_input/collection.rs index c03d9c0b..0149172e 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/collection.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/collection.rs @@ -56,18 +56,10 @@ macro_rules! impl_collection { $(, $others: BufferAccessObject)* { #[inline] + #[allow(non_snake_case)] fn into_vec(self) -> Vec> { - #![allow(non_snake_case)] - let ($first, $($others,)*) = self; - let mut list = Vec::new(); - list.push($first.as_buffer_access_object()); - - $( - list.push($others.as_buffer_access_object()); - )+ - - list + vec![$first.as_buffer_access_object() $(, $others.as_buffer_access_object())+] } } @@ -166,12 +158,9 @@ mod tests { takes_collection(vec![dynamic_a.clone(), concrete_b.clone()]); // Arrays are similar to Vecs - takes_collection([concrete_a.clone(), concrete_aa.clone()]); + takes_collection([concrete_a.clone(), concrete_aa]); takes_collection([dynamic_a.clone(), dynamic_b.clone()]); - takes_collection([ - concrete_a.clone() as Arc, - concrete_b.clone(), - ]); - takes_collection([dynamic_a.clone(), concrete_b.clone()]); + takes_collection([concrete_a as Arc, concrete_b.clone()]); + takes_collection([dynamic_a.clone(), concrete_b]); } } diff --git a/vulkano/src/pipeline/graphics/vertex_input/definition.rs b/vulkano/src/pipeline/graphics/vertex_input/definition.rs index 023ee965..2bdfac71 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/definition.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/definition.rs @@ -71,7 +71,7 @@ pub unsafe trait VertexDefinition { unsafe impl VertexDefinition for VertexInputState { fn definition( &self, - interface: &ShaderInterface, + _interface: &ShaderInterface, ) -> Result { Ok(self.clone()) } diff --git a/vulkano/src/pipeline/layout.rs b/vulkano/src/pipeline/layout.rs index 1c59061a..0facc8ac 100644 --- a/vulkano/src/pipeline/layout.rs +++ b/vulkano/src/pipeline/layout.rs @@ -244,7 +244,7 @@ impl PipelineLayout { if set_layout.push_descriptor() { // VUID-VkPipelineLayoutCreateInfo-pSetLayouts-00293 - if let Some(num) = push_descriptor_set { + if push_descriptor_set.is_some() { return Err(PipelineLayoutCreationError::SetLayoutsPushDescriptorMultiple); } else { push_descriptor_set = Some(set_num); diff --git a/vulkano/src/query.rs b/vulkano/src/query.rs index 980e6750..8b110372 100644 --- a/vulkano/src/query.rs +++ b/vulkano/src/query.rs @@ -117,12 +117,12 @@ impl QueryPool { query_count, _ne: _, } = create_info; - return Arc::new(QueryPool { + Arc::new(QueryPool { handle, device, query_type, query_count, - }); + }) } /// Returns the query type of the pool. @@ -306,7 +306,7 @@ impl<'a> Query<'a> { /// Returns a reference to the query pool. #[inline] pub fn pool(&self) -> &'a QueryPool { - &self.pool + self.pool } /// Returns the index of the query represented. @@ -329,7 +329,7 @@ impl<'a> QueriesRange<'a> { /// Returns a reference to the query pool. #[inline] pub fn pool(&self) -> &'a QueryPool { - &self.pool + self.pool } /// Returns the range of queries represented. diff --git a/vulkano/src/range_map.rs b/vulkano/src/range_map.rs index 701bc2da..53d3172d 100644 --- a/vulkano/src/range_map.rs +++ b/vulkano/src/range_map.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use std::{ cmp, cmp::Ordering, @@ -72,13 +74,13 @@ where /// Returns `true` if any part of the provided range overlaps with a range in the map. #[inline] - pub fn contains_any<'a>(&self, range: &'a Range) -> bool { + pub fn contains_any(&self, range: &Range) -> bool { self.range(range).next().is_some() } /// Returns `true` if all of the provided range is covered by ranges in the map. #[inline] - pub fn contains_all<'a>(&self, range: &'a Range) -> bool { + pub fn contains_all(&self, range: &Range) -> bool { self.gaps(range).next().is_none() } diff --git a/vulkano/src/render_pass/create.rs b/vulkano/src/render_pass/create.rs index 50076607..dd5908a2 100644 --- a/vulkano/src/render_pass/create.rs +++ b/vulkano/src/render_pass/create.rs @@ -46,11 +46,11 @@ impl RenderPass { for (atch_num, attachment) in attachments.iter().enumerate() { let &AttachmentDescription { format, - samples, - load_op, - store_op, - stencil_load_op, - stencil_store_op, + samples: _, + load_op: _, + store_op: _, + stencil_load_op: _, + stencil_store_op: _, initial_layout, final_layout, _ne: _, @@ -175,17 +175,17 @@ impl RenderPass { // Common checks for all attachment types let mut check_attachment = |atch_ref: &AttachmentReference| { // VUID-VkRenderPassCreateInfo2-attachment-03051 - let atch = attachments - .get(atch_ref.attachment as usize) - .ok_or_else(|| RenderPassCreationError::SubpassAttachmentOutOfRange { + let atch = attachments.get(atch_ref.attachment as usize).ok_or( + RenderPassCreationError::SubpassAttachmentOutOfRange { subpass: subpass_num, attachment: atch_ref.attachment, - })?; + }, + )?; // VUID-VkSubpassDescription2-layout-02528 match &mut layouts[atch_ref.attachment as usize] { Some(layout) if *layout == atch_ref.layout => (), - Some(layout) => { + Some(_) => { return Err(RenderPassCreationError::SubpassAttachmentLayoutMismatch { subpass: subpass_num, attachment: atch_ref.attachment, @@ -486,7 +486,7 @@ impl RenderPass { } // VUID-VkSubpassDescription2-pResolveAttachments-03065 - let color_atch_ref = color_atch_ref.ok_or_else(|| { + let color_atch_ref = color_atch_ref.ok_or({ RenderPassCreationError::SubpassResolveAttachmentWithoutColorAttachment { subpass: subpass_num, } @@ -732,6 +732,7 @@ impl RenderPass { .. } = *source_stages; + #[allow(clippy::identity_op)] [ draw_indirect as u8 * 1, // index_input as u8 * 2, @@ -772,6 +773,7 @@ impl RenderPass { .. } = *destination_stages; + #[allow(clippy::identity_op)] [ draw_indirect as u8 * 1, // index_input as u8 * 2, @@ -933,17 +935,14 @@ impl RenderPass { let out: SmallVec<[_; 4]> = subpasses .iter() .map(|subpass| { - let input_attachments = - attachment_references_vk.as_ptr().offset(ref_index as isize); + let input_attachments = attachment_references_vk.as_ptr().add(ref_index); ref_index += subpass.input_attachments.len(); - let color_attachments = - attachment_references_vk.as_ptr().offset(ref_index as isize); + let color_attachments = attachment_references_vk.as_ptr().add(ref_index); ref_index += subpass.color_attachments.len(); - let resolve_attachments = - attachment_references_vk.as_ptr().offset(ref_index as isize); + let resolve_attachments = attachment_references_vk.as_ptr().add(ref_index); ref_index += subpass.resolve_attachments.len(); let depth_stencil = if subpass.depth_stencil_attachment.is_some() { - let a = attachment_references_vk.as_ptr().offset(ref_index as isize); + let a = attachment_references_vk.as_ptr().add(ref_index); ref_index += 1; a } else { @@ -1132,17 +1131,14 @@ impl RenderPass { let out: SmallVec<[_; 4]> = subpasses .iter() .map(|subpass| { - let input_attachments = - attachment_references_vk.as_ptr().offset(ref_index as isize); + let input_attachments = attachment_references_vk.as_ptr().add(ref_index); ref_index += subpass.input_attachments.len(); - let color_attachments = - attachment_references_vk.as_ptr().offset(ref_index as isize); + let color_attachments = attachment_references_vk.as_ptr().add(ref_index); ref_index += subpass.color_attachments.len(); - let resolve_attachments = - attachment_references_vk.as_ptr().offset(ref_index as isize); + let resolve_attachments = attachment_references_vk.as_ptr().add(ref_index); ref_index += subpass.resolve_attachments.len(); let depth_stencil = if subpass.depth_stencil_attachment.is_some() { - let a = attachment_references_vk.as_ptr().offset(ref_index as isize); + let a = attachment_references_vk.as_ptr().add(ref_index); ref_index += 1; a } else { diff --git a/vulkano/src/render_pass/framebuffer.rs b/vulkano/src/render_pass/framebuffer.rs index cecf3751..4eaae05c 100644 --- a/vulkano/src/render_pass/framebuffer.rs +++ b/vulkano/src/render_pass/framebuffer.rs @@ -753,7 +753,7 @@ mod tests { .unwrap(); let view = ImageView::new_default( - AttachmentImage::new(device.clone(), [1024, 768], Format::R8G8B8A8_UNORM).unwrap(), + AttachmentImage::new(device, [1024, 768], Format::R8G8B8A8_UNORM).unwrap(), ) .unwrap(); let _ = Framebuffer::new( @@ -820,7 +820,7 @@ mod tests { .unwrap(); let view = ImageView::new_default( - AttachmentImage::new(device.clone(), [1024, 768], Format::R8_UNORM).unwrap(), + AttachmentImage::new(device, [1024, 768], Format::R8_UNORM).unwrap(), ) .unwrap(); @@ -859,7 +859,7 @@ mod tests { .unwrap(); let view = ImageView::new_default( - AttachmentImage::new(device.clone(), [600, 600], Format::R8G8B8A8_UNORM).unwrap(), + AttachmentImage::new(device, [600, 600], Format::R8G8B8A8_UNORM).unwrap(), ) .unwrap(); @@ -896,7 +896,7 @@ mod tests { .unwrap(); let view = ImageView::new_default( - AttachmentImage::new(device.clone(), [512, 700], Format::R8G8B8A8_UNORM).unwrap(), + AttachmentImage::new(device, [512, 700], Format::R8G8B8A8_UNORM).unwrap(), ) .unwrap(); @@ -945,7 +945,7 @@ mod tests { ) .unwrap(); let b = ImageView::new_default( - AttachmentImage::new(device.clone(), [512, 128], Format::R8G8B8A8_UNORM).unwrap(), + AttachmentImage::new(device, [512, 128], Format::R8G8B8A8_UNORM).unwrap(), ) .unwrap(); @@ -991,7 +991,7 @@ mod tests { .unwrap(); let view = ImageView::new_default( - AttachmentImage::new(device.clone(), [256, 512], Format::R8G8B8A8_UNORM).unwrap(), + AttachmentImage::new(device, [256, 512], Format::R8G8B8A8_UNORM).unwrap(), ) .unwrap(); @@ -1037,7 +1037,7 @@ mod tests { ) .unwrap(); let b = ImageView::new_default( - AttachmentImage::new(device.clone(), [256, 512], Format::R8G8B8A8_UNORM).unwrap(), + AttachmentImage::new(device, [256, 512], Format::R8G8B8A8_UNORM).unwrap(), ) .unwrap(); diff --git a/vulkano/src/render_pass/macros.rs b/vulkano/src/render_pass/macros.rs index 4bf82c62..7f839ab4 100644 --- a/vulkano/src/render_pass/macros.rs +++ b/vulkano/src/render_pass/macros.rs @@ -233,7 +233,7 @@ mod tests { #[test] fn single_pass_resolve() { let (device, _) = gfx_dev_and_queue!(); - let _ = single_pass_renderpass!(device.clone(), + let _ = single_pass_renderpass!(device, attachments: { a: { load: Clear, diff --git a/vulkano/src/render_pass/mod.rs b/vulkano/src/render_pass/mod.rs index 0305be84..e2ec5488 100644 --- a/vulkano/src/render_pass/mod.rs +++ b/vulkano/src/render_pass/mod.rs @@ -182,7 +182,6 @@ impl RenderPass { pub unsafe fn from_handle( handle: ash::vk::RenderPass, create_info: RenderPassCreateInfo, - granularity: [u32; 2], device: Arc, ) -> Result, RenderPassCreationError> { let views_used = create_info @@ -495,7 +494,7 @@ impl RenderPass { _ => return false, }; - let attachment_desc = &self.attachments[attachment_id as usize]; + let _attachment_desc = &self.attachments[attachment_id as usize]; // FIXME: compare formats depending on the number of components and data type /*if attachment_desc.format != element.format { @@ -1248,7 +1247,7 @@ mod tests { } let rp = single_pass_renderpass! { - device.clone(), + device, attachments: { a1: { load: Clear, store: DontCare, format: Format::R8G8B8A8_UNORM, samples: 1, }, a2: { load: Clear, store: DontCare, format: Format::R8G8B8A8_UNORM, samples: 1, }, @@ -1278,7 +1277,7 @@ mod tests { let (device, _) = gfx_dev_and_queue!(); let rp = single_pass_renderpass! { - device.clone(), + device, attachments: { a: { load: Clear, store: DontCare, format: Format::R8G8B8A8_UNORM, samples: 1, } }, diff --git a/vulkano/src/sampler/mod.rs b/vulkano/src/sampler/mod.rs index af195a50..b3daedd0 100644 --- a/vulkano/src/sampler/mod.rs +++ b/vulkano/src/sampler/mod.rs @@ -198,8 +198,8 @@ impl Sampler { .any(|filter| filter == Filter::Cubic) { return Err(SamplerCreationError::AnisotropyInvalidFilter { - mag_filter: mag_filter, - min_filter: min_filter, + mag_filter, + min_filter, }); } @@ -235,12 +235,10 @@ impl Sampler { } if lod != (0.0..=0.0) { - return Err(SamplerCreationError::UnnormalizedCoordinatesNonzeroLod { - lod: lod.clone(), - }); + return Err(SamplerCreationError::UnnormalizedCoordinatesNonzeroLod { lod }); } - if address_mode[0..2].into_iter().any(|mode| { + if address_mode[0..2].iter().any(|mode| { !matches!( mode, SamplerAddressMode::ClampToEdge | SamplerAddressMode::ClampToBorder @@ -366,7 +364,7 @@ impl Sampler { address_mode_u: address_mode[0].into(), address_mode_v: address_mode[1].into(), address_mode_w: address_mode[2].into(), - mip_lod_bias: mip_lod_bias, + mip_lod_bias, anisotropy_enable, max_anisotropy, compare_enable, @@ -1491,7 +1489,7 @@ mod tests { #[test] fn create_regular() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let s = Sampler::new( device, @@ -1505,13 +1503,13 @@ mod tests { }, ) .unwrap(); - assert!(!s.compare().is_some()); + assert!(s.compare().is_none()); assert!(!s.unnormalized_coordinates()); } #[test] fn create_compare() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let s = Sampler::new( device, @@ -1532,7 +1530,7 @@ mod tests { #[test] fn create_unnormalized() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let s = Sampler::new( device, @@ -1544,25 +1542,25 @@ mod tests { }, ) .unwrap(); - assert!(!s.compare().is_some()); + assert!(s.compare().is_none()); assert!(s.unnormalized_coordinates()); } #[test] fn simple_repeat_linear() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let _ = Sampler::new(device, SamplerCreateInfo::simple_repeat_linear()); } #[test] fn simple_repeat_linear_no_mipmap() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let _ = Sampler::new(device, SamplerCreateInfo::simple_repeat_linear_no_mipmap()); } #[test] fn min_lod_inferior() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); assert_should_panic!({ let _ = Sampler::new( @@ -1581,7 +1579,7 @@ mod tests { #[test] fn max_anisotropy() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); assert_should_panic!({ let _ = Sampler::new( @@ -1601,7 +1599,7 @@ mod tests { #[test] fn anisotropy_feature() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let r = Sampler::new( device, @@ -1627,7 +1625,7 @@ mod tests { #[test] fn anisotropy_limit() { - let (device, queue) = gfx_dev_and_queue!(sampler_anisotropy); + let (device, _queue) = gfx_dev_and_queue!(sampler_anisotropy); let r = Sampler::new( device, @@ -1650,7 +1648,7 @@ mod tests { #[test] fn mip_lod_bias_limit() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let r = Sampler::new( device, @@ -1672,7 +1670,7 @@ mod tests { #[test] fn sampler_mirror_clamp_to_edge_extension() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let r = Sampler::new( device, @@ -1703,7 +1701,7 @@ mod tests { #[test] fn sampler_filter_minmax_extension() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let r = Sampler::new( device, diff --git a/vulkano/src/sampler/ycbcr.rs b/vulkano/src/sampler/ycbcr.rs index c7ef5cd1..674b24b1 100644 --- a/vulkano/src/sampler/ycbcr.rs +++ b/vulkano/src/sampler/ycbcr.rs @@ -475,7 +475,7 @@ impl Hash for SamplerYcbcrConversion { } /// Error that can happen when creating a `SamplerYcbcrConversion`. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum SamplerYcbcrConversionCreationError { /// Not enough memory. OomError(OomError), @@ -765,7 +765,7 @@ mod tests { #[test] fn feature_not_enabled() { - let (device, queue) = gfx_dev_and_queue!(); + let (device, _queue) = gfx_dev_and_queue!(); let r = SamplerYcbcrConversion::new(device, Default::default()); diff --git a/vulkano/src/shader/mod.rs b/vulkano/src/shader/mod.rs index 9a49f161..2553750e 100644 --- a/vulkano/src/shader/mod.rs +++ b/vulkano/src/shader/mod.rs @@ -164,7 +164,7 @@ impl ShaderModule { let entries = entry_points.into_iter().collect::>(); let entry_points = entries .iter() - .filter_map(|(name, _, _)| Some(name)) + .map(|(name, _, _)| name) .collect::>() .iter() .map(|name| { @@ -607,7 +607,7 @@ impl DescriptorRequirements { .descriptor_types .iter() .copied() - .filter(|ty| other.descriptor_types.contains(&ty)) + .filter(|ty| other.descriptor_types.contains(ty)) .collect(); if descriptor_types.is_empty() { diff --git a/vulkano/src/shader/reflect.rs b/vulkano/src/shader/reflect.rs index b6b6cc77..e8a86aa3 100644 --- a/vulkano/src/shader/reflect.rs +++ b/vulkano/src/shader/reflect.rs @@ -31,7 +31,7 @@ use std::{ }; /// Returns an iterator of the capabilities used by `spirv`. -pub fn spirv_capabilities<'a>(spirv: &'a Spirv) -> impl Iterator { +pub fn spirv_capabilities(spirv: &Spirv) -> impl Iterator { spirv .iter_capability() .filter_map(|instruction| match instruction { @@ -41,7 +41,7 @@ pub fn spirv_capabilities<'a>(spirv: &'a Spirv) -> impl Iterator(spirv: &'a Spirv) -> impl Iterator { +pub fn spirv_extensions(spirv: &Spirv) -> impl Iterator { spirv .iter_extension() .filter_map(|instruction| match instruction { @@ -51,9 +51,9 @@ pub fn spirv_extensions<'a>(spirv: &'a Spirv) -> impl Iterator { } /// Returns an iterator over all entry points in `spirv`, with information about the entry point. -pub fn entry_points<'a>( - spirv: &'a Spirv, -) -> impl Iterator + 'a { +pub fn entry_points( + spirv: &Spirv, +) -> impl Iterator + '_ { let interface_variables = interface_variables(spirv); spirv.iter_entry_point().filter_map(move |instruction| { @@ -68,7 +68,7 @@ pub fn entry_points<'a>( _ => return None, }; - let execution = shader_execution(&spirv, execution_model, function_id); + let execution = shader_execution(spirv, execution_model, function_id); let stage = ShaderStage::from(execution); let mut descriptor_requirements = @@ -78,10 +78,10 @@ pub fn entry_points<'a>( reqs.stages = stage.into(); } - let push_constant_requirements = push_constant_requirements(&spirv, stage); - let specialization_constant_requirements = specialization_constant_requirements(&spirv); + let push_constant_requirements = push_constant_requirements(spirv, stage); + let specialization_constant_requirements = specialization_constant_requirements(spirv); let input_interface = shader_interface( - &spirv, + spirv, interface, StorageClass::Input, matches!( @@ -92,7 +92,7 @@ pub fn entry_points<'a>( ), ); let output_interface = shader_interface( - &spirv, + spirv, interface, StorageClass::Output, matches!(execution_model, ExecutionModel::TessellationControl), @@ -184,13 +184,14 @@ fn interface_variables(spirv: &Spirv) -> InterfaceVariables { let mut variables = InterfaceVariables::default(); for instruction in spirv.iter_global() { - match instruction { - Instruction::Variable { - result_id, - result_type_id, - storage_class, - .. - } => match storage_class { + if let Instruction::Variable { + result_id, + result_type_id: _, + storage_class, + .. + } = instruction + { + match storage_class { StorageClass::StorageBuffer | StorageClass::Uniform | StorageClass::UniformConstant => { @@ -199,8 +200,7 @@ fn interface_variables(spirv: &Spirv) -> InterfaceVariables { .insert(*result_id, descriptor_requirements_of(spirv, *result_id)); } _ => (), - }, - _ => (), + } } } @@ -608,9 +608,7 @@ fn inspect_entry_point( } } - &Instruction::ImageTexelPointer { - result_id, image, .. - } => { + &Instruction::ImageTexelPointer { image, .. } => { instruction_chain(result, global, spirv, [], image); } @@ -682,7 +680,7 @@ fn inspect_entry_point( ); result .into_iter() - .map(|(variable_id, variable)| ((variable.set, variable.binding), variable.reqs)) + .map(|(_, variable)| ((variable.set, variable.binding), variable.reqs)) .collect() } @@ -771,8 +769,8 @@ fn descriptor_requirements_of(spirv: &Spirv, variable_id: Id) -> DescriptorVaria assert!(sampled != 0, "Vulkan requires that variables of type OpTypeImage have a Sampled operand of 1 or 2"); reqs.image_format = image_format.clone().into(); reqs.image_multisampled = ms != 0; - reqs.image_scalar_type = Some(match spirv.id(sampled_type).instruction() { - &Instruction::TypeInt { + reqs.image_scalar_type = Some(match *spirv.id(sampled_type).instruction() { + Instruction::TypeInt { width, signedness, .. } => { assert!(width == 32); // TODO: 64-bit components @@ -782,7 +780,7 @@ fn descriptor_requirements_of(spirv: &Spirv, variable_id: Id) -> DescriptorVaria _ => unreachable!(), } } - &Instruction::TypeFloat { width, .. } => { + Instruction::TypeFloat { width, .. } => { assert!(width == 32); // TODO: 64-bit components ShaderScalarType::Float } @@ -869,7 +867,7 @@ fn descriptor_requirements_of(spirv: &Spirv, variable_id: Id) -> DescriptorVaria Some(element_type) } - &Instruction::TypeAccelerationStructureKHR { result_id } => None, // FIXME temporary workaround + &Instruction::TypeAccelerationStructureKHR { .. } => None, // FIXME temporary workaround _ => { let name = variable_id_info @@ -976,7 +974,7 @@ fn specialization_constant_requirements( } => Some(*specialization_constant_id), _ => None, }) - .and_then(|constant_id| { + .map(|constant_id| { let size = match spirv.id(result_type_id).instruction() { Instruction::TypeBool { .. } => { // Translate bool to Bool32 @@ -985,7 +983,7 @@ fn specialization_constant_requirements( _ => size_of_type(spirv, result_type_id) .expect("Found runtime-sized specialization constant"), }; - Some((constant_id, SpecializationConstantRequirements { size })) + (constant_id, SpecializationConstantRequirements { size }) }), _ => None, } @@ -1184,7 +1182,7 @@ fn offset_of_struct(spirv: &Spirv, id: Id) -> u32 { spirv .id(id) .iter_members() - .map(|member_info| { + .filter_map(|member_info| { member_info .iter_decoration() .find_map(|instruction| match instruction { @@ -1195,7 +1193,6 @@ fn offset_of_struct(spirv: &Spirv, id: Id) -> u32 { _ => None, }) }) - .flatten() .min() .unwrap_or(0) } @@ -1208,8 +1205,8 @@ fn shader_interface_type_of( id: Id, ignore_first_array: bool, ) -> ShaderInterfaceEntryType { - match spirv.id(id).instruction() { - &Instruction::TypeInt { + match *spirv.id(id).instruction() { + Instruction::TypeInt { width, signedness, .. } => { assert!(!ignore_first_array); @@ -1228,7 +1225,7 @@ fn shader_interface_type_of( }, } } - &Instruction::TypeFloat { width, .. } => { + Instruction::TypeFloat { width, .. } => { assert!(!ignore_first_array); ShaderInterfaceEntryType { base_type: ShaderScalarType::Float, @@ -1241,7 +1238,7 @@ fn shader_interface_type_of( }, } } - &Instruction::TypeVector { + Instruction::TypeVector { component_type, component_count, .. @@ -1252,7 +1249,7 @@ fn shader_interface_type_of( ..shader_interface_type_of(spirv, component_type, false) } } - &Instruction::TypeMatrix { + Instruction::TypeMatrix { column_type, column_count, .. @@ -1263,7 +1260,7 @@ fn shader_interface_type_of( ..shader_interface_type_of(spirv, column_type, false) } } - &Instruction::TypeArray { + Instruction::TypeArray { element_type, length, .. @@ -1293,7 +1290,7 @@ fn shader_interface_type_of( ty } } - &Instruction::TypePointer { ty, .. } => { + Instruction::TypePointer { ty, .. } => { shader_interface_type_of(spirv, ty, ignore_first_array) } _ => panic!("Type {} not found or invalid", id), diff --git a/vulkano/src/shader/spirv.rs b/vulkano/src/shader/spirv.rs index f14a6768..cdace1f4 100644 --- a/vulkano/src/shader/spirv.rs +++ b/vulkano/src/shader/spirv.rs @@ -396,7 +396,7 @@ impl Spirv { /// - Panics if `id` is not defined in this module. This can in theory only happpen if you are /// mixing `Id`s from different modules. #[inline] - pub fn id<'a>(&'a self, id: Id) -> IdInfo<'a> { + pub fn id(&self, id: Id) -> IdInfo { IdInfo { data_indices: &self.ids[&id], instructions: &self.instructions, @@ -628,11 +628,13 @@ impl<'a> InstructionReader<'a> { Ok(word) } + /* /// Returns the next two words as a single `u64`. #[inline] fn next_u64(&mut self) -> Result { Ok(self.next_u32()? as u64 | (self.next_u32()? as u64) << 32) } + */ /// Reads a nul-terminated string. fn next_string(&mut self) -> Result { @@ -771,7 +773,7 @@ impl Display for ParseErrors { #[inline] fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { - Self::FromUtf8Error(err) => write!(f, "invalid UTF-8 in string literal"), + Self::FromUtf8Error(_) => write!(f, "invalid UTF-8 in string literal"), Self::LeftoverOperands => write!(f, "unparsed operands remaining"), Self::MissingOperands => write!(f, "the instruction and its operands require more words than are present in the instruction"), Self::UnexpectedEOF => write!(f, "encountered unexpected end of file"), diff --git a/vulkano/src/swapchain/display.rs b/vulkano/src/swapchain/display.rs index b5c814f4..03e8dd94 100644 --- a/vulkano/src/swapchain/display.rs +++ b/vulkano/src/swapchain/display.rs @@ -168,8 +168,7 @@ impl DisplayPlane { self.supported_displays .iter() - .find(|&&d| d == display.internal_object()) - .is_some() + .any(|&d| d == display.internal_object()) } } @@ -259,7 +258,7 @@ impl Display { /// Returns the physical dimensions of the display in millimeters. #[inline] pub fn physical_dimensions(&self) -> [u32; 2] { - let ref r = self.properties.physical_dimensions; + let r = &self.properties.physical_dimensions; [r.width, r.height] } @@ -269,7 +268,7 @@ impl Display { /// > only the "best" resolution. #[inline] pub fn physical_resolution(&self) -> [u32; 2] { - let ref r = self.properties.physical_resolution; + let r = &self.properties.physical_resolution; [r.width, r.height] } @@ -408,7 +407,7 @@ impl DisplayMode { /// Returns the dimensions of the region that is visible on the monitor. #[inline] pub fn visible_region(&self) -> [u32; 2] { - let ref d = self.parameters.visible_region; + let d = &self.parameters.visible_region; [d.width, d.height] } diff --git a/vulkano/src/swapchain/swapchain.rs b/vulkano/src/swapchain/swapchain.rs index c4497219..828c3523 100644 --- a/vulkano/src/swapchain/swapchain.rs +++ b/vulkano/src/swapchain/swapchain.rs @@ -289,7 +289,7 @@ impl Swapchain { pre_transform, composite_alpha, present_mode, - clipped, + clipped: _, full_screen_exclusive, win32_monitor, _ne: _, @@ -322,7 +322,7 @@ impl Swapchain { // VUID-VkSwapchainCreateInfoKHR-surface-01270 *image_format = Some({ let surface_formats = device.physical_device().surface_formats( - &surface, + surface, SurfaceInfo { full_screen_exclusive, win32_monitor, @@ -347,12 +347,12 @@ impl Swapchain { && [Format::R8G8B8A8_UNORM, Format::B8G8R8A8_UNORM].contains(&f)) .then(|| f) }) - .ok_or_else(|| SwapchainCreationError::FormatColorSpaceNotSupported)? + .ok_or(SwapchainCreationError::FormatColorSpaceNotSupported)? } }); let surface_capabilities = device.physical_device().surface_capabilities( - &surface, + surface, SurfaceInfo { full_screen_exclusive, win32_monitor, @@ -463,7 +463,7 @@ impl Swapchain { // VUID-VkSwapchainCreateInfoKHR-presentMode-01281 if !device .physical_device() - .surface_present_modes(&surface)? + .surface_present_modes(surface)? .any(|mode| mode == present_mode) { return Err(SwapchainCreationError::PresentModeNotSupported); @@ -634,7 +634,7 @@ impl Swapchain { image_extent, image_array_layers, image_usage, - ref image_sharing, // TODO: put this in the image too + image_sharing: _, // TODO: put this in the image too .. } = create_info; @@ -844,14 +844,14 @@ impl Swapchain { // See the `ImageAccess::layout_initialized` method documentation for more details. pub(crate) fn image_layout_initialized(&self, image_offset: usize) { let image_entry = self.images.get(image_offset); - if let Some(ref image_entry) = image_entry { + if let Some(image_entry) = image_entry { image_entry.undefined_layout.store(false, Ordering::SeqCst); } } pub(crate) fn is_image_layout_initialized(&self, image_offset: usize) -> bool { let image_entry = self.images.get(image_offset); - if let Some(ref image_entry) = image_entry { + if let Some(image_entry) = image_entry { !image_entry.undefined_layout.load(Ordering::SeqCst) } else { false @@ -1531,7 +1531,7 @@ unsafe impl GpuFuture for SwapchainAcquireFuture { unsafe fn build_submission(&self) -> Result { if let Some(ref semaphore) = self.semaphore { let mut sem = SubmitSemaphoresWaitBuilder::new(); - sem.add_wait_semaphore(&semaphore); + sem.add_wait_semaphore(semaphore); Ok(SubmitAnyBuilder::SemaphoresWait(sem)) } else { Ok(SubmitAnyBuilder::Empty) @@ -1561,10 +1561,10 @@ unsafe impl GpuFuture for SwapchainAcquireFuture { #[inline] fn check_buffer_access( &self, - buffer: &UnsafeBuffer, - range: Range, - exclusive: bool, - queue: &Queue, + _buffer: &UnsafeBuffer, + _range: Range, + _exclusive: bool, + _queue: &Queue, ) -> Result, AccessCheckError> { Err(AccessCheckError::Unknown) } @@ -1573,10 +1573,10 @@ unsafe impl GpuFuture for SwapchainAcquireFuture { fn check_image_access( &self, image: &UnsafeImage, - range: Range, - exclusive: bool, + _range: Range, + _exclusive: bool, expected_layout: ImageLayout, - queue: &Queue, + _queue: &Queue, ) -> Result, AccessCheckError> { let swapchain_image = self.swapchain.raw_image(self.image_id).unwrap(); if swapchain_image.image.internal_object() != image.internal_object() { @@ -1763,7 +1763,7 @@ where return Ok(SubmitAnyBuilder::Empty); } - let queue = self.previous.queue().map(|q| q.clone()); + let _queue = self.previous.queue(); // TODO: if the swapchain image layout is not PRESENT, should add a transition command // buffer @@ -1787,7 +1787,7 @@ where ); SubmitAnyBuilder::QueuePresent(builder) } - SubmitAnyBuilder::CommandBuffer(cb) => { + SubmitAnyBuilder::CommandBuffer(_) => { // submit the command buffer by flushing previous. // Since the implementation should remember being flushed it's safe to call build_submission multiple times self.previous.flush()?; @@ -1800,7 +1800,7 @@ where ); SubmitAnyBuilder::QueuePresent(builder) } - SubmitAnyBuilder::BindSparse(cb) => { + SubmitAnyBuilder::BindSparse(_) => { // submit the command buffer by flushing previous. // Since the implementation should remember being flushed it's safe to call build_submission multiple times self.previous.flush()?; @@ -1813,7 +1813,7 @@ where ); SubmitAnyBuilder::QueuePresent(builder) } - SubmitAnyBuilder::QueuePresent(present) => { + SubmitAnyBuilder::QueuePresent(_present) => { unimplemented!() // TODO: /*present.submit(); let mut builder = SubmitPresentBuilder::new(); diff --git a/vulkano/src/sync/event.rs b/vulkano/src/sync/event.rs index 5cf27afb..d3898b8b 100644 --- a/vulkano/src/sync/event.rs +++ b/vulkano/src/sync/event.rs @@ -33,7 +33,7 @@ pub struct Event { impl Event { /// Creates a new `Event`. - pub fn new(device: Arc, create_info: EventCreateInfo) -> Result { + pub fn new(device: Arc, _create_info: EventCreateInfo) -> Result { let create_info = ash::vk::EventCreateInfo { flags: ash::vk::EventCreateFlags::empty(), ..Default::default() @@ -100,7 +100,7 @@ impl Event { /// the `create_info` must match the info used to create said object pub unsafe fn from_handle( handle: ash::vk::Event, - create_info: EventCreateInfo, + _create_info: EventCreateInfo, device: Arc, ) -> Event { Event { diff --git a/vulkano/src/sync/fence.rs b/vulkano/src/sync/fence.rs index 1b3d9c19..124bfb79 100644 --- a/vulkano/src/sync/fence.rs +++ b/vulkano/src/sync/fence.rs @@ -215,8 +215,7 @@ impl Fence { .filter_map(|fence| { match &mut device { dev @ &mut None => *dev = Some(&*fence.device), - &mut Some(ref dev) - if &**dev as *const Device == &*fence.device as *const Device => {} + &mut Some(dev) if std::ptr::eq(dev, &*fence.device) => {} _ => panic!( "Tried to wait for multiple fences that didn't belong to the \ same device" @@ -294,8 +293,7 @@ impl Fence { .map(|fence| { match &mut device { dev @ &mut None => *dev = Some(&*fence.device), - &mut Some(ref dev) - if &**dev as *const Device == &*fence.device as *const Device => {} + &mut Some(dev) if std::ptr::eq(dev, &*fence.device) => {} _ => panic!( "Tried to reset multiple fences that didn't belong to the same \ device" @@ -454,7 +452,7 @@ mod tests { fn fence_create() { let (device, _) = gfx_dev_and_queue!(); - let fence = Fence::new(device.clone(), Default::default()).unwrap(); + let fence = Fence::new(device, Default::default()).unwrap(); assert!(!fence.is_signaled().unwrap()); } @@ -463,7 +461,7 @@ mod tests { let (device, _) = gfx_dev_and_queue!(); let fence = Fence::new( - device.clone(), + device, FenceCreateInfo { signaled: true, ..Default::default() @@ -478,7 +476,7 @@ mod tests { let (device, _) = gfx_dev_and_queue!(); let fence = Fence::new( - device.clone(), + device, FenceCreateInfo { signaled: true, ..Default::default() @@ -493,7 +491,7 @@ mod tests { let (device, _) = gfx_dev_and_queue!(); let mut fence = Fence::new( - device.clone(), + device, FenceCreateInfo { signaled: true, ..Default::default() diff --git a/vulkano/src/sync/future/fence_signal.rs b/vulkano/src/sync/future/fence_signal.rs index 01cd2a67..12549463 100644 --- a/vulkano/src/sync/future/fence_signal.rs +++ b/vulkano/src/sync/future/fence_signal.rs @@ -43,6 +43,7 @@ pub enum FenceSignalFutureBehavior { /// Continue execution on the same queue. Continue, /// Wait for the fence to be signalled before submitting any further operation. + #[allow(dead_code)] // TODO: why is this never constructed? Block { /// How long to block the current thread. timeout: Option, @@ -219,7 +220,7 @@ where }; // TODO: meh for unwrap - let queue = previous.queue().unwrap().clone(); + let queue = previous.queue().unwrap(); // There are three possible outcomes for the flush operation: success, partial success // in which case `result` will contain `Err(OutcomeErr::Partial)`, or total failure @@ -365,11 +366,7 @@ where match self.behavior { FenceSignalFutureBehavior::Continue => { let state = self.state.lock(); - if state.get_prev().is_some() { - false - } else { - true - } + state.get_prev().is_none() } FenceSignalFutureBehavior::Block { .. } => true, } diff --git a/vulkano/src/sync/future/join.rs b/vulkano/src/sync/future/join.rs index 44d928df..e6c58d02 100644 --- a/vulkano/src/sync/future/join.rs +++ b/vulkano/src/sync/future/join.rs @@ -35,10 +35,7 @@ where assert!(first.queue().unwrap() == second.queue().unwrap()); } - JoinFuture { - first: first, - second: second, - } + JoinFuture { first, second } } /// Two futures joined into one. @@ -99,27 +96,27 @@ where a.merge(b); SubmitAnyBuilder::SemaphoresWait(a) } - (SubmitAnyBuilder::SemaphoresWait(a), SubmitAnyBuilder::CommandBuffer(b)) => { + (SubmitAnyBuilder::SemaphoresWait(a), SubmitAnyBuilder::CommandBuffer(_)) => { self.second.flush()?; SubmitAnyBuilder::SemaphoresWait(a) } - (SubmitAnyBuilder::CommandBuffer(a), SubmitAnyBuilder::SemaphoresWait(b)) => { + (SubmitAnyBuilder::CommandBuffer(_), SubmitAnyBuilder::SemaphoresWait(b)) => { self.first.flush()?; SubmitAnyBuilder::SemaphoresWait(b) } - (SubmitAnyBuilder::SemaphoresWait(a), SubmitAnyBuilder::QueuePresent(b)) => { + (SubmitAnyBuilder::SemaphoresWait(a), SubmitAnyBuilder::QueuePresent(_)) => { self.second.flush()?; SubmitAnyBuilder::SemaphoresWait(a) } - (SubmitAnyBuilder::QueuePresent(a), SubmitAnyBuilder::SemaphoresWait(b)) => { + (SubmitAnyBuilder::QueuePresent(_), SubmitAnyBuilder::SemaphoresWait(b)) => { self.first.flush()?; SubmitAnyBuilder::SemaphoresWait(b) } - (SubmitAnyBuilder::SemaphoresWait(a), SubmitAnyBuilder::BindSparse(b)) => { + (SubmitAnyBuilder::SemaphoresWait(a), SubmitAnyBuilder::BindSparse(_)) => { self.second.flush()?; SubmitAnyBuilder::SemaphoresWait(a) } - (SubmitAnyBuilder::BindSparse(a), SubmitAnyBuilder::SemaphoresWait(b)) => { + (SubmitAnyBuilder::BindSparse(_), SubmitAnyBuilder::SemaphoresWait(b)) => { self.first.flush()?; SubmitAnyBuilder::SemaphoresWait(b) } @@ -128,27 +125,27 @@ where let new = a.merge(b); SubmitAnyBuilder::CommandBuffer(new) } - (SubmitAnyBuilder::QueuePresent(a), SubmitAnyBuilder::QueuePresent(b)) => { + (SubmitAnyBuilder::QueuePresent(_), SubmitAnyBuilder::QueuePresent(_)) => { self.first.flush()?; self.second.flush()?; SubmitAnyBuilder::Empty } - (SubmitAnyBuilder::CommandBuffer(a), SubmitAnyBuilder::QueuePresent(b)) => { + (SubmitAnyBuilder::CommandBuffer(_), SubmitAnyBuilder::QueuePresent(_)) => { unimplemented!() } - (SubmitAnyBuilder::QueuePresent(a), SubmitAnyBuilder::CommandBuffer(b)) => { + (SubmitAnyBuilder::QueuePresent(_), SubmitAnyBuilder::CommandBuffer(_)) => { unimplemented!() } - (SubmitAnyBuilder::BindSparse(a), SubmitAnyBuilder::QueuePresent(b)) => { + (SubmitAnyBuilder::BindSparse(_), SubmitAnyBuilder::QueuePresent(_)) => { unimplemented!() } - (SubmitAnyBuilder::QueuePresent(a), SubmitAnyBuilder::BindSparse(b)) => { + (SubmitAnyBuilder::QueuePresent(_), SubmitAnyBuilder::BindSparse(_)) => { unimplemented!() } - (SubmitAnyBuilder::BindSparse(a), SubmitAnyBuilder::CommandBuffer(b)) => { + (SubmitAnyBuilder::BindSparse(_), SubmitAnyBuilder::CommandBuffer(_)) => { unimplemented!() } - (SubmitAnyBuilder::CommandBuffer(a), SubmitAnyBuilder::BindSparse(b)) => { + (SubmitAnyBuilder::CommandBuffer(_), SubmitAnyBuilder::BindSparse(_)) => { unimplemented!() } (SubmitAnyBuilder::BindSparse(mut a), SubmitAnyBuilder::BindSparse(b)) => { @@ -210,13 +207,13 @@ where .second .check_buffer_access(buffer, range, exclusive, queue); debug_assert!( - !exclusive || !(first.is_ok() && second.is_ok()), + !(exclusive && first.is_ok() && second.is_ok()), "Two futures gave exclusive access to the same resource" ); match (first, second) { (v, Err(AccessCheckError::Unknown)) => v, (Err(AccessCheckError::Unknown), v) => v, - (Err(AccessCheckError::Denied(e1)), Err(AccessCheckError::Denied(e2))) => { + (Err(AccessCheckError::Denied(e1)), Err(AccessCheckError::Denied(_))) => { Err(AccessCheckError::Denied(e1)) } // TODO: which one? (Ok(_), Err(AccessCheckError::Denied(_))) @@ -246,13 +243,13 @@ where self.second .check_image_access(image, range, exclusive, expected_layout, queue); debug_assert!( - !exclusive || !(first.is_ok() && second.is_ok()), + !(exclusive && first.is_ok() && second.is_ok()), "Two futures gave exclusive access to the same resource" ); match (first, second) { (v, Err(AccessCheckError::Unknown)) => v, (Err(AccessCheckError::Unknown), v) => v, - (Err(AccessCheckError::Denied(e1)), Err(AccessCheckError::Denied(e2))) => { + (Err(AccessCheckError::Denied(e1)), Err(AccessCheckError::Denied(_))) => { Err(AccessCheckError::Denied(e1)) } // TODO: which one? (Ok(_), Err(AccessCheckError::Denied(_))) diff --git a/vulkano/src/sync/future/mod.rs b/vulkano/src/sync/future/mod.rs index 6d9bf39a..67a5b4f6 100644 --- a/vulkano/src/sync/future/mod.rs +++ b/vulkano/src/sync/future/mod.rs @@ -178,7 +178,7 @@ pub unsafe trait GpuFuture: DeviceOwned { Self: Sized, Cb: PrimaryCommandBuffer + 'static, { - let queue = self.queue().unwrap().clone(); + let queue = self.queue().unwrap(); command_buffer.execute_after(self, queue) } diff --git a/vulkano/src/sync/future/now.rs b/vulkano/src/sync/future/now.rs index 4e18a167..28d21789 100644 --- a/vulkano/src/sync/future/now.rs +++ b/vulkano/src/sync/future/now.rs @@ -59,10 +59,10 @@ unsafe impl GpuFuture for NowFuture { #[inline] fn check_buffer_access( &self, - buffer: &UnsafeBuffer, - range: Range, - exclusive: bool, - queue: &Queue, + _buffer: &UnsafeBuffer, + _range: Range, + _exclusive: bool, + _queue: &Queue, ) -> Result, AccessCheckError> { Err(AccessCheckError::Unknown) } @@ -70,11 +70,11 @@ unsafe impl GpuFuture for NowFuture { #[inline] fn check_image_access( &self, - image: &UnsafeImage, - range: Range, - exclusive: bool, - expected_layout: ImageLayout, - queue: &Queue, + _image: &UnsafeImage, + _range: Range, + _exclusive: bool, + _expected_layout: ImageLayout, + _queue: &Queue, ) -> Result, AccessCheckError> { Err(AccessCheckError::Unknown) } diff --git a/vulkano/src/sync/future/semaphore_signal.rs b/vulkano/src/sync/future/semaphore_signal.rs index a969ffaf..1e9d5748 100644 --- a/vulkano/src/sync/future/semaphore_signal.rs +++ b/vulkano/src/sync/future/semaphore_signal.rs @@ -88,7 +88,7 @@ where return Ok(()); } - let queue = self.previous.queue().unwrap().clone(); + let queue = self.previous.queue().unwrap(); match self.previous.build_submission()? { SubmitAnyBuilder::Empty => { diff --git a/vulkano/src/sync/mod.rs b/vulkano/src/sync/mod.rs index 630d36ef..e4002fcc 100644 --- a/vulkano/src/sync/mod.rs +++ b/vulkano/src/sync/mod.rs @@ -144,7 +144,7 @@ pub enum SharingMode { impl<'a> From<&'a Arc> for SharingMode { #[inline] - fn from(queue: &'a Arc) -> SharingMode { + fn from(_queue: &'a Arc) -> SharingMode { SharingMode::Exclusive } } diff --git a/vulkano/src/sync/pipeline.rs b/vulkano/src/sync/pipeline.rs index a9b3d690..c7d92fd3 100644 --- a/vulkano/src/sync/pipeline.rs +++ b/vulkano/src/sync/pipeline.rs @@ -116,7 +116,7 @@ impl PipelineStages { } let PipelineStages { - top_of_pipe, + top_of_pipe: _, mut draw_indirect, mut vertex_input, mut vertex_shader, @@ -129,10 +129,10 @@ impl PipelineStages { mut color_attachment_output, compute_shader, transfer, - bottom_of_pipe, + bottom_of_pipe: _, host, all_graphics, - all_commands, + all_commands: _, ray_tracing_shader, } = *self; diff --git a/vulkano/src/sync/semaphore.rs b/vulkano/src/sync/semaphore.rs index 8786ca13..b1fa911c 100644 --- a/vulkano/src/sync/semaphore.rs +++ b/vulkano/src/sync/semaphore.rs @@ -567,7 +567,7 @@ mod tests { #[test] fn semaphore_create() { let (device, _) = gfx_dev_and_queue!(); - let _ = Semaphore::new(device.clone(), Default::default()); + let _ = Semaphore::new(device, Default::default()); } #[test] @@ -629,13 +629,13 @@ mod tests { }; let sem = Semaphore::new( - device.clone(), + device, SemaphoreCreateInfo { export_handle_types: ExternalSemaphoreHandleTypes::posix(), ..Default::default() }, ) .unwrap(); - let fd = unsafe { sem.export_opaque_fd().unwrap() }; + let _fd = unsafe { sem.export_opaque_fd().unwrap() }; } }