diff --git a/examples/src/bin/buffer-allocator.rs b/examples/src/bin/buffer-allocator.rs index 04fda6fed2..317b018ebc 100644 --- a/examples/src/bin/buffer-allocator.rs +++ b/examples/src/bin/buffer-allocator.rs @@ -33,7 +33,7 @@ use vulkano::{ pipeline::{ graphics::{ input_assembly::InputAssemblyState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -225,7 +225,7 @@ fn main() { .unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -277,7 +277,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -296,7 +296,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -385,7 +385,7 @@ fn main() { previous_frame_end = Some(Box::new(sync::now(device.clone())) as Box<_>); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(Box::new(sync::now(device.clone())) as Box<_>); } } diff --git a/examples/src/bin/clear_attachments.rs b/examples/src/bin/clear_attachments.rs index 7373c3ae10..3f3ca6fc98 100644 --- a/examples/src/bin/clear_attachments.rs +++ b/examples/src/bin/clear_attachments.rs @@ -192,7 +192,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -209,7 +209,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -289,7 +289,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/deferred/frame/ambient_lighting_system.rs b/examples/src/bin/deferred/frame/ambient_lighting_system.rs index a295e74b54..91bbd46bd0 100644 --- a/examples/src/bin/deferred/frame/ambient_lighting_system.rs +++ b/examples/src/bin/deferred/frame/ambient_lighting_system.rs @@ -24,7 +24,7 @@ use vulkano::{ graphics::{ color_blend::{AttachmentBlend, BlendFactor, BlendOp, ColorBlendState}, input_assembly::InputAssemblyState, - vertex_input::BuffersDefinition, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -81,7 +81,7 @@ impl AmbientLightingSystem { let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module"); GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(LightingVertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) diff --git a/examples/src/bin/deferred/frame/directional_lighting_system.rs b/examples/src/bin/deferred/frame/directional_lighting_system.rs index be99351a0f..ab290d18b7 100644 --- a/examples/src/bin/deferred/frame/directional_lighting_system.rs +++ b/examples/src/bin/deferred/frame/directional_lighting_system.rs @@ -25,7 +25,7 @@ use vulkano::{ graphics::{ color_blend::{AttachmentBlend, BlendFactor, BlendOp, ColorBlendState}, input_assembly::InputAssemblyState, - vertex_input::BuffersDefinition, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -82,7 +82,7 @@ impl DirectionalLightingSystem { let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module"); GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(LightingVertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) diff --git a/examples/src/bin/deferred/frame/point_lighting_system.rs b/examples/src/bin/deferred/frame/point_lighting_system.rs index 1a81fdd1c9..76b5091772 100644 --- a/examples/src/bin/deferred/frame/point_lighting_system.rs +++ b/examples/src/bin/deferred/frame/point_lighting_system.rs @@ -25,7 +25,7 @@ use vulkano::{ graphics::{ color_blend::{AttachmentBlend, BlendFactor, BlendOp, ColorBlendState}, input_assembly::InputAssemblyState, - vertex_input::BuffersDefinition, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -81,7 +81,7 @@ impl PointLightingSystem { let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module"); GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(LightingVertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) diff --git a/examples/src/bin/deferred/main.rs b/examples/src/bin/deferred/main.rs index db856be529..60ba0dfedd 100644 --- a/examples/src/bin/deferred/main.rs +++ b/examples/src/bin/deferred/main.rs @@ -216,7 +216,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; let new_images = new_images .into_iter() @@ -235,7 +235,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -285,7 +285,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/deferred/triangle_draw_system.rs b/examples/src/bin/deferred/triangle_draw_system.rs index 070311a475..aff65ecb7f 100644 --- a/examples/src/bin/deferred/triangle_draw_system.rs +++ b/examples/src/bin/deferred/triangle_draw_system.rs @@ -21,7 +21,7 @@ use vulkano::{ graphics::{ depth_stencil::DepthStencilState, input_assembly::InputAssemblyState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -71,7 +71,7 @@ impl TriangleDrawSystem { let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module"); GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(TriangleVertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) diff --git a/examples/src/bin/dynamic-buffers.rs b/examples/src/bin/dynamic-buffers.rs index cf34eb5c5b..de93efb25c 100644 --- a/examples/src/bin/dynamic-buffers.rs +++ b/examples/src/bin/dynamic-buffers.rs @@ -146,11 +146,8 @@ fn main() { .physical_device() .properties() .min_uniform_buffer_offset_alignment as usize; - println!( - "Minimum uniform buffer offset alignment: {}", - min_dynamic_align - ); - println!("Input: {:?}", data); + println!("Minimum uniform buffer offset alignment: {min_dynamic_align}"); + println!("Input: {data:?}"); // Round size up to the next multiple of align. let align = (size_of::() + min_dynamic_align - 1) & !(min_dynamic_align - 1); let aligned_data = { diff --git a/examples/src/bin/dynamic-local-size.rs b/examples/src/bin/dynamic-local-size.rs index 103edf0b86..b040637ab5 100644 --- a/examples/src/bin/dynamic-local-size.rs +++ b/examples/src/bin/dynamic-local-size.rs @@ -166,7 +166,7 @@ fn main() { // local size can lead to significant performance penalty. let (local_size_x, local_size_y) = match device.physical_device().properties().subgroup_size { Some(subgroup_size) => { - println!("Subgroup size is {}", subgroup_size); + println!("Subgroup size is {subgroup_size}"); // Most of the subgroup values are divisors of 8 (8, subgroup_size / 8) @@ -179,10 +179,7 @@ fn main() { } }; - println!( - "Local size will be set to: ({}, {}, 1)", - local_size_x, local_size_y - ); + println!("Local size will be set to: ({local_size_x}, {local_size_y}, 1)"); let spec_consts = cs::SpecializationConstants { red: 0.2, diff --git a/examples/src/bin/gl-interop.rs b/examples/src/bin/gl-interop.rs index 53fd70e5e5..d72ad2aa35 100644 --- a/examples/src/bin/gl-interop.rs +++ b/examples/src/bin/gl-interop.rs @@ -39,7 +39,7 @@ mod linux { graphics::{ color_blend::ColorBlendState, input_assembly::{InputAssemblyState, PrimitiveTopology}, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Scissor, Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -293,7 +293,7 @@ mod linux { Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => { return } - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -312,7 +312,7 @@ mod linux { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -375,7 +375,7 @@ mod linux { previous_frame_end = Some(vulkano::sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(vulkano::sync::now(device.clone()).boxed()); } }; @@ -608,7 +608,7 @@ mod linux { let subpass = Subpass::from(render_pass.clone(), 0).unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(MyVertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state( InputAssemblyState::new().topology(PrimitiveTopology::TriangleStrip), diff --git a/examples/src/bin/image-self-copy-blit/main.rs b/examples/src/bin/image-self-copy-blit/main.rs index 0174a2d36a..9a9146c5e5 100644 --- a/examples/src/bin/image-self-copy-blit/main.rs +++ b/examples/src/bin/image-self-copy-blit/main.rs @@ -35,7 +35,7 @@ use vulkano::{ graphics::{ color_blend::ColorBlendState, input_assembly::{InputAssemblyState, PrimitiveTopology}, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -326,7 +326,7 @@ fn main() { let subpass = Subpass::from(render_pass.clone(), 0).unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new().topology(PrimitiveTopology::TriangleStrip)) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -390,7 +390,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -406,7 +406,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -466,7 +466,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/image/main.rs b/examples/src/bin/image/main.rs index c7331bd1a1..5625a955fe 100644 --- a/examples/src/bin/image/main.rs +++ b/examples/src/bin/image/main.rs @@ -33,7 +33,7 @@ use vulkano::{ graphics::{ color_blend::ColorBlendState, input_assembly::{InputAssemblyState, PrimitiveTopology}, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -257,7 +257,7 @@ fn main() { let subpass = Subpass::from(render_pass.clone(), 0).unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new().topology(PrimitiveTopology::TriangleStrip)) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -321,7 +321,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -337,7 +337,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -397,7 +397,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/immutable-sampler/main.rs b/examples/src/bin/immutable-sampler/main.rs index f1973bef7a..321cd13e6e 100644 --- a/examples/src/bin/immutable-sampler/main.rs +++ b/examples/src/bin/immutable-sampler/main.rs @@ -42,7 +42,7 @@ use vulkano::{ graphics::{ color_blend::ColorBlendState, input_assembly::{InputAssemblyState, PrimitiveTopology}, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -263,7 +263,7 @@ fn main() { let subpass = Subpass::from(render_pass.clone(), 0).unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new().topology(PrimitiveTopology::TriangleStrip)) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -334,7 +334,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -350,7 +350,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -410,7 +410,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/indirect.rs b/examples/src/bin/indirect.rs index b5ec6143de..661c534595 100644 --- a/examples/src/bin/indirect.rs +++ b/examples/src/bin/indirect.rs @@ -48,7 +48,7 @@ use vulkano::{ pipeline::{ graphics::{ input_assembly::InputAssemblyState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, ComputePipeline, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -302,7 +302,7 @@ fn main() { } let render_pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -355,7 +355,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -374,7 +374,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -470,7 +470,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/instancing.rs b/examples/src/bin/instancing.rs index c807a30b10..5662d2042c 100644 --- a/examples/src/bin/instancing.rs +++ b/examples/src/bin/instancing.rs @@ -30,7 +30,7 @@ use vulkano::{ pipeline::{ graphics::{ input_assembly::InputAssemblyState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -290,11 +290,7 @@ fn main() { let pipeline = GraphicsPipeline::start() // Use the `BuffersDefinition` to describe to vulkano how the two vertex types // are expected to be used. - .vertex_input_state( - BuffersDefinition::new() - .vertex::() - .instance::(), - ) + .vertex_input_state([TriangleVertex::per_vertex(), InstanceData::per_instance()]) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -346,7 +342,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -365,7 +361,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -425,7 +421,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/interactive_fractal/main.rs b/examples/src/bin/interactive_fractal/main.rs index aed18ef997..f04230f5f3 100644 --- a/examples/src/bin/interactive_fractal/main.rs +++ b/examples/src/bin/interactive_fractal/main.rs @@ -138,7 +138,7 @@ fn compute_then_render( // Start frame let before_pipeline_future = match renderer.acquire() { Err(e) => { - println!("{}", e); + println!("{e}"); return; } Ok(future) => future, diff --git a/examples/src/bin/interactive_fractal/pixels_draw_pipeline.rs b/examples/src/bin/interactive_fractal/pixels_draw_pipeline.rs index b7352f6d01..06d378d31a 100644 --- a/examples/src/bin/interactive_fractal/pixels_draw_pipeline.rs +++ b/examples/src/bin/interactive_fractal/pixels_draw_pipeline.rs @@ -24,7 +24,7 @@ use vulkano::{ pipeline::{ graphics::{ input_assembly::InputAssemblyState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -106,7 +106,7 @@ impl PixelsDrawPipeline { let vs = vs::load(gfx_queue.device().clone()).expect("failed to create shader module"); let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module"); GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(TexturedVertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .fragment_shader(fs.entry_point("main").unwrap(), ()) diff --git a/examples/src/bin/msaa-renderpass.rs b/examples/src/bin/msaa-renderpass.rs index 83efec9e7d..361075bb41 100644 --- a/examples/src/bin/msaa-renderpass.rs +++ b/examples/src/bin/msaa-renderpass.rs @@ -83,7 +83,7 @@ use vulkano::{ pipeline::{ graphics::{ multisample::MultisampleState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -296,7 +296,7 @@ fn main() { let subpass = Subpass::from(render_pass, 0).unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) .fragment_shader(fs.entry_point("main").unwrap(), ()) diff --git a/examples/src/bin/multi-window.rs b/examples/src/bin/multi-window.rs index 2673053fee..1c48839394 100644 --- a/examples/src/bin/multi-window.rs +++ b/examples/src/bin/multi-window.rs @@ -34,7 +34,7 @@ use vulkano::{ pipeline::{ graphics::{ input_assembly::InputAssemblyState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -257,7 +257,7 @@ fn main() { .unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -399,7 +399,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; *swapchain = new_swapchain; @@ -415,7 +415,7 @@ fn main() { *recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -470,7 +470,7 @@ fn main() { *previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); *previous_frame_end = Some(sync::now(device.clone()).boxed()); } } 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 ab58e71e22..03b9987f05 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); + println!("{e}"); return; } Ok(future) => future, diff --git a/examples/src/bin/multi_window_game_of_life/pixels_draw.rs b/examples/src/bin/multi_window_game_of_life/pixels_draw.rs index 8adac4b40e..235885ca6b 100644 --- a/examples/src/bin/multi_window_game_of_life/pixels_draw.rs +++ b/examples/src/bin/multi_window_game_of_life/pixels_draw.rs @@ -24,7 +24,7 @@ use vulkano::{ pipeline::{ graphics::{ input_assembly::InputAssemblyState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -106,7 +106,7 @@ impl PixelsDrawPipeline { let vs = vs::load(gfx_queue.device().clone()).expect("failed to create shader module"); let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module"); GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(TexturedVertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .fragment_shader(fs.entry_point("main").unwrap(), ()) diff --git a/examples/src/bin/multiview.rs b/examples/src/bin/multiview.rs index bd3114bced..df8d79b355 100644 --- a/examples/src/bin/multiview.rs +++ b/examples/src/bin/multiview.rs @@ -35,7 +35,7 @@ use vulkano::{ pipeline::{ graphics::{ input_assembly::InputAssemblyState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -254,7 +254,7 @@ fn main() { .unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_fixed_scissor_irrelevant([ diff --git a/examples/src/bin/occlusion-query.rs b/examples/src/bin/occlusion-query.rs index 9b964928b5..27d82314a6 100644 --- a/examples/src/bin/occlusion-query.rs +++ b/examples/src/bin/occlusion-query.rs @@ -31,7 +31,7 @@ use vulkano::{ graphics::{ depth_stencil::DepthStencilState, input_assembly::InputAssemblyState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -302,7 +302,7 @@ fn main() { .unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -363,7 +363,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -383,7 +383,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -475,7 +475,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/push-descriptors/main.rs b/examples/src/bin/push-descriptors/main.rs index 3abba99ae8..16a7ddb987 100644 --- a/examples/src/bin/push-descriptors/main.rs +++ b/examples/src/bin/push-descriptors/main.rs @@ -31,7 +31,7 @@ use vulkano::{ graphics::{ color_blend::ColorBlendState, input_assembly::{InputAssemblyState, PrimitiveTopology}, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -252,7 +252,7 @@ fn main() { let subpass = Subpass::from(render_pass.clone(), 0).unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new().topology(PrimitiveTopology::TriangleStrip)) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -313,7 +313,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -329,7 +329,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -389,7 +389,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/runtime-shader/main.rs b/examples/src/bin/runtime-shader/main.rs index f94a71e3ae..0bba1c970f 100644 --- a/examples/src/bin/runtime-shader/main.rs +++ b/examples/src/bin/runtime-shader/main.rs @@ -38,7 +38,7 @@ use vulkano::{ graphics::{ input_assembly::InputAssemblyState, rasterization::{CullMode, FrontFace, RasterizationState}, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -195,7 +195,7 @@ fn main() { }; let graphics_pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -288,7 +288,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -304,7 +304,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -358,7 +358,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/runtime_array/main.rs b/examples/src/bin/runtime_array/main.rs index a877b2e1ad..cf9495868c 100644 --- a/examples/src/bin/runtime_array/main.rs +++ b/examples/src/bin/runtime_array/main.rs @@ -36,7 +36,7 @@ use vulkano::{ pipeline::{ graphics::{ color_blend::ColorBlendState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, layout::PipelineLayoutCreateInfo, @@ -384,7 +384,7 @@ fn main() { let subpass = Subpass::from(render_pass.clone(), 0).unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) .fragment_shader(fs.entry_point("main").unwrap(), ()) @@ -455,7 +455,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -471,7 +471,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -531,7 +531,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/shader-types-derive.rs b/examples/src/bin/shader-types-derive.rs index 9b53123dcf..fcbff59c70 100644 --- a/examples/src/bin/shader-types-derive.rs +++ b/examples/src/bin/shader-types-derive.rs @@ -131,7 +131,7 @@ fn main() { let serialized = to_string_pretty(&bar, PrettyConfig::default()).unwrap(); - println!("Serialized Bar: {}", serialized); + println!("Serialized Bar: {serialized}"); let deserialized = from_str::(&serialized).unwrap(); diff --git a/examples/src/bin/simple-particles.rs b/examples/src/bin/simple-particles.rs index 8e0cb869f4..4eb9c0f942 100644 --- a/examples/src/bin/simple-particles.rs +++ b/examples/src/bin/simple-particles.rs @@ -34,7 +34,7 @@ use vulkano::{ pipeline::{ graphics::{ input_assembly::{InputAssemblyState, PrimitiveTopology}, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, PipelineBindPoint, @@ -415,7 +415,7 @@ fn main() { // Create a basic graphics pipeline for rendering particles. let graphics_pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .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])) @@ -464,7 +464,7 @@ fn main() { None, /*timeout*/ ) { Ok(tuple) => tuple, - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; // Since we disallow resizing, assert the swapchain and surface are optimally configured. @@ -542,7 +542,7 @@ fn main() { Ok(future) => Some(Arc::new(future)), // Unknown failure. - Err(e) => panic!("Failed to flush future: {:?}", e), + Err(e) => panic!("Failed to flush future: {e:?}"), }; previous_fence_index = image_index; } diff --git a/examples/src/bin/teapot/main.rs b/examples/src/bin/teapot/main.rs index 0ec16d4747..7ae3b42895 100644 --- a/examples/src/bin/teapot/main.rs +++ b/examples/src/bin/teapot/main.rs @@ -34,7 +34,7 @@ use vulkano::{ graphics::{ depth_stencil::DepthStencilState, input_assembly::InputAssemblyState, - vertex_input::BuffersDefinition, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -258,7 +258,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -321,7 +321,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -384,7 +384,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } @@ -429,11 +429,7 @@ fn window_size_dependent_setup( // This allows the driver to optimize things, at the cost of slower window resizes. // https://computergraphics.stackexchange.com/questions/5742/vulkan-best-way-of-updating-pipeline-viewport let pipeline = GraphicsPipeline::start() - .vertex_input_state( - BuffersDefinition::new() - .vertex::() - .vertex::(), - ) + .vertex_input_state([Position::per_vertex(), Normal::per_vertex()]) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new()) .viewport_state(ViewportState::viewport_fixed_scissor_irrelevant([ diff --git a/examples/src/bin/tessellation.rs b/examples/src/bin/tessellation.rs index 90778e9291..6847bf64c1 100644 --- a/examples/src/bin/tessellation.rs +++ b/examples/src/bin/tessellation.rs @@ -38,7 +38,7 @@ use vulkano::{ input_assembly::{InputAssemblyState, PrimitiveTopology}, rasterization::{PolygonMode, RasterizationState}, tessellation::TessellationState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -329,7 +329,7 @@ fn main() { .unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) // Actually use the tessellation shaders. .tessellation_shaders( @@ -394,7 +394,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -410,7 +410,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -464,7 +464,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/texture_array/main.rs b/examples/src/bin/texture_array/main.rs index d488f27a5b..7cbd7f1715 100644 --- a/examples/src/bin/texture_array/main.rs +++ b/examples/src/bin/texture_array/main.rs @@ -33,7 +33,7 @@ use vulkano::{ graphics::{ color_blend::ColorBlendState, input_assembly::{InputAssemblyState, PrimitiveTopology}, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, Pipeline, PipelineBindPoint, @@ -258,7 +258,7 @@ fn main() { let subpass = Subpass::from(render_pass.clone(), 0).unwrap(); let pipeline = GraphicsPipeline::start() - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) .vertex_shader(vs.entry_point("main").unwrap(), ()) .input_assembly_state(InputAssemblyState::new().topology(PrimitiveTopology::TriangleStrip)) .viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant()) @@ -322,7 +322,7 @@ fn main() { }) { Ok(r) => r, Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -338,7 +338,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; if suboptimal { @@ -398,7 +398,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/triangle-v1_3.rs b/examples/src/bin/triangle-v1_3.rs index 3a2efd507c..75a719fb4d 100644 --- a/examples/src/bin/triangle-v1_3.rs +++ b/examples/src/bin/triangle-v1_3.rs @@ -40,7 +40,7 @@ use vulkano::{ graphics::{ input_assembly::InputAssemblyState, render_pass::PipelineRenderingCreateInfo, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -375,7 +375,7 @@ fn main() { ..Default::default() }) // We need to indicate the layout of the vertices. - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) // The content of the vertex buffer describes a list of triangles. .input_assembly_state(InputAssemblyState::new()) // A Vulkan shader can in theory contain multiple entry points, so we have to specify @@ -467,7 +467,7 @@ fn main() { // This error tends to happen when the user is manually resizing the window. // Simply restarting the loop is the easiest way to fix this issue. Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -492,7 +492,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; // acquire_next_image can be successful, but suboptimal. This means that the swapchain image @@ -590,7 +590,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - println!("Failed to flush future: {:?}", e); + println!("Failed to flush future: {e:?}"); previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index abec143196..3a7d8ac0fa 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -34,7 +34,7 @@ use vulkano::{ pipeline::{ graphics::{ input_assembly::InputAssemblyState, - vertex_input::{BuffersDefinition, Vertex}, + vertex_input::Vertex, viewport::{Viewport, ViewportState}, }, GraphicsPipeline, @@ -383,7 +383,7 @@ fn main() { // in. The pipeline will only be usable from this particular subpass. .render_pass(Subpass::from(render_pass.clone(), 0).unwrap()) // We need to indicate the layout of the vertices. - .vertex_input_state(BuffersDefinition::new().vertex::()) + .vertex_input_state(Vertex::per_vertex()) // The content of the vertex buffer describes a list of triangles. .input_assembly_state(InputAssemblyState::new()) // A Vulkan shader can in theory contain multiple entry points, so we have to specify @@ -482,7 +482,7 @@ fn main() { // This error tends to happen when the user is manually resizing the window. // Simply restarting the loop is the easiest way to fix this issue. Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return, - Err(e) => panic!("Failed to recreate swapchain: {:?}", e), + Err(e) => panic!("Failed to recreate swapchain: {e:?}"), }; swapchain = new_swapchain; @@ -510,7 +510,7 @@ fn main() { recreate_swapchain = true; return; } - Err(e) => panic!("Failed to acquire next image: {:?}", e), + Err(e) => panic!("Failed to acquire next image: {e:?}"), }; // acquire_next_image can be successful, but suboptimal. This means that the swapchain image @@ -601,7 +601,7 @@ fn main() { previous_frame_end = Some(sync::now(device.clone()).boxed()); } Err(e) => { - panic!("Failed to flush future: {:?}", e); + panic!("Failed to flush future: {e:?}"); // previous_frame_end = Some(sync::now(device.clone()).boxed()); } } diff --git a/vulkano/macros/src/derive_vertex.rs b/vulkano/macros/src/derive_vertex.rs index 288eefc631..da9d7c6126 100644 --- a/vulkano/macros/src/derive_vertex.rs +++ b/vulkano/macros/src/derive_vertex.rs @@ -41,14 +41,16 @@ pub fn derive_vertex(ast: syn::DeriveInput) -> Result { FoundCrate::Name(name) => Ident::new(&name, Span::call_site()), }; - let mut member_cases = quote! { + let mut members = quote! { let mut offset = 0; + let mut members = HashMap::default(); }; for field in fields.iter() { let field_name = field.ident.to_owned().unwrap(); + let field_name_lit = LitStr::new(&field_name.to_string(), Span::call_site()); let field_ty = &field.ty; - let mut names = vec![LitStr::new(&field_name.to_string(), Span::call_site())]; + let mut names = vec![field_name_lit.clone()]; let mut format = quote! {}; for attr in &field.attrs { let attr_ident = if let Some(ident) = attr.path.get_ident() { @@ -73,42 +75,61 @@ pub fn derive_vertex(ast: syn::DeriveInput) -> Result { )); } for name in &names { - member_cases = quote! { - #member_cases + members = quote! { + #members let field_size = std::mem::size_of::<#field_ty>() as u32; - if name == #name { + { #format let format_size = format.block_size().expect("no block size for format") as u32; let num_elements = field_size / format_size; let remainder = field_size % format_size; - assert!(remainder == 0, "struct field `{}` size does not fit multiple of format size", name); - return Some(VertexMemberInfo { - offset, - format, - num_elements, - }); + assert!(remainder == 0, "struct field `{}` size does not fit multiple of format size", #field_name_lit); + members.insert( + #name.to_string(), + VertexMemberInfo { + offset, + format, + num_elements, + }, + ); } offset += field_size as usize; }; } } - Ok(TokenStream::from(quote! { - #[allow(unsafe_code)] - unsafe impl #crate_ident::pipeline::graphics::vertex_input::Vertex for #struct_name { - #[inline(always)] - fn member(name: &str) -> Option<#crate_ident::pipeline::graphics::vertex_input::VertexMemberInfo> { - #[allow(unused_imports)] - use #crate_ident::format::Format; - use #crate_ident::pipeline::graphics::vertex_input::VertexMemberInfo; - use #crate_ident::pipeline::graphics::vertex_input::VertexMember; + let function_body = quote! { + #[allow(unused_imports)] + use std::collections::HashMap; + use #crate_ident::format::Format; + use #crate_ident::pipeline::graphics::vertex_input::{VertexInputRate, VertexMemberInfo}; - #member_cases + #members - None - } + #crate_ident::pipeline::graphics::vertex_input::VertexBufferDescription { + members, + stride: std::mem::size_of::<#struct_name>() as u32, + input_rate: VertexInputRate::Vertex, } + }; + + Ok(TokenStream::from(quote! { + #[allow(unsafe_code)] + unsafe impl #crate_ident::pipeline::graphics::vertex_input::Vertex for #struct_name { + #[inline(always)] + fn per_vertex() -> #crate_ident::pipeline::graphics::vertex_input::VertexBufferDescription { + #function_body + } + #[inline(always)] + fn per_instance() -> #crate_ident::pipeline::graphics::vertex_input::VertexBufferDescription { + #function_body.per_instance() + } + #[inline(always)] + fn per_instance_with_divisor(divisor: u32) -> #crate_ident::pipeline::graphics::vertex_input::VertexBufferDescription { + #function_body.per_instance_with_divisor(divisor) + } + } })) } diff --git a/vulkano/src/command_buffer/mod.rs b/vulkano/src/command_buffer/mod.rs index 19cde0630d..e12d6da60b 100644 --- a/vulkano/src/command_buffer/mod.rs +++ b/vulkano/src/command_buffer/mod.rs @@ -71,14 +71,19 @@ //! use vulkano::command_buffer::PrimaryCommandBufferAbstract; //! use vulkano::command_buffer::SubpassContents; //! +//! # use vulkano::pipeline::graphics::vertex_input::Vertex; +//! # use bytemuck::{Pod, Zeroable}; +//! //! # #[repr(C)] -//! # #[derive(Clone, Copy, Debug, Default, bytemuck::Zeroable, bytemuck::Pod)] -//! # struct Vertex { position: [f32; 3] }; -//! # vulkano::impl_vertex!(Vertex, position); +//! # #[derive(Clone, Copy, Debug, Default, Zeroable, Pod, Vertex)] +//! # struct PosVertex { +//! # #[format(R32G32B32_SFLOAT)] +//! # position: [f32; 3] +//! # }; //! # use vulkano::buffer::TypedBufferAccess; //! # let device: std::sync::Arc = return; //! # let queue: std::sync::Arc = return; -//! # let vertex_buffer: std::sync::Arc> = return; +//! # let vertex_buffer: std::sync::Arc> = return; //! # let render_pass_begin_info: vulkano::command_buffer::RenderPassBeginInfo = return; //! # let graphics_pipeline: std::sync::Arc = return; //! # let command_buffer_allocator: vulkano::command_buffer::allocator::StandardCommandBufferAllocator = return; diff --git a/vulkano/src/pipeline/graphics/builder.rs b/vulkano/src/pipeline/graphics/builder.rs index 05663c0721..3ef98da3ef 100644 --- a/vulkano/src/pipeline/graphics/builder.rs +++ b/vulkano/src/pipeline/graphics/builder.rs @@ -25,8 +25,8 @@ use super::{ render_pass::{PipelineRenderPassType, PipelineRenderingCreateInfo}, tessellation::TessellationState, vertex_input::{ - BuffersDefinition, Vertex, VertexDefinition, VertexInputAttributeDescription, - VertexInputBindingDescription, VertexInputState, + VertexDefinition, VertexInputAttributeDescription, VertexInputBindingDescription, + VertexInputState, }, viewport::{Scissor, Viewport, ViewportState}, GraphicsPipeline, GraphicsPipelineCreationError, @@ -3997,29 +3997,6 @@ impl<'vs, 'tcs, 'tes, 'gs, 'fs, Vdef, Vss, Tcss, Tess, Gss, Fss> self } - /// Sets the vertex input to a single vertex buffer. - /// - /// You will most likely need to explicitly specify the template parameter to the type of a - /// vertex. - #[deprecated(since = "0.27.0", note = "Use `vertex_input_state` instead")] - pub fn vertex_input_single_buffer( - self, - ) -> GraphicsPipelineBuilder< - 'vs, - 'tcs, - 'tes, - 'gs, - 'fs, - BuffersDefinition, - Vss, - Tcss, - Tess, - Gss, - Fss, - > { - self.vertex_input_state(BuffersDefinition::new().vertex::()) - } - /// Sets whether primitive restart is enabled. #[deprecated(since = "0.27.0", note = "Use `input_assembly_state` instead")] #[inline] diff --git a/vulkano/src/pipeline/graphics/vertex_input/buffers.rs b/vulkano/src/pipeline/graphics/vertex_input/buffers.rs index 424d749350..b7637e6cdd 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/buffers.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/buffers.rs @@ -7,50 +7,23 @@ // notice may not be copied, modified, or distributed except // according to those terms. -use super::VertexMemberInfo; +use super::VertexBufferDescription; use crate::{ pipeline::graphics::vertex_input::{ - IncompatibleVertexDefinitionError, Vertex, VertexDefinition, - VertexInputAttributeDescription, VertexInputBindingDescription, VertexInputRate, - VertexInputState, + IncompatibleVertexDefinitionError, Vertex, VertexDefinition, VertexInputState, }, shader::ShaderInterface, - DeviceSize, -}; -use std::{ - fmt::{Debug, Error as FmtError, Formatter}, - mem, }; /// A vertex definition for any number of vertex and instance buffers. +#[deprecated( + since = "0.33.0", + note = "Use `VertexBufferDescription` directly instead as returned by `Vertex::per_vertex` or `Vertex::per_instance`" +)] #[derive(Clone, Debug, Default)] -pub struct BuffersDefinition(Vec); - -#[derive(Clone, Copy)] -struct VertexBuffer { - info_fn: fn(&str) -> Option, - stride: u32, - input_rate: VertexInputRate, -} - -impl Debug for VertexBuffer { - fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { - f.debug_struct("VertexBuffer") - .field("stride", &self.stride) - .field("input_rate", &self.input_rate) - .finish() - } -} - -impl From for VertexInputBindingDescription { - fn from(val: VertexBuffer) -> Self { - Self { - stride: val.stride, - input_rate: val.input_rate, - } - } -} +pub struct BuffersDefinition(Vec); +#[allow(deprecated)] impl BuffersDefinition { /// Constructs a new definition. #[inline] @@ -60,23 +33,13 @@ impl BuffersDefinition { /// Adds a new vertex buffer containing elements of type `V` to the definition. pub fn vertex(mut self) -> Self { - self.0.push(VertexBuffer { - info_fn: V::member, - stride: mem::size_of::() as u32, - input_rate: VertexInputRate::Vertex, - }); - + self.0.push(V::per_vertex()); self } /// Adds a new instance buffer containing elements of type `V` to the definition. pub fn instance(mut self) -> Self { - self.0.push(VertexBuffer { - info_fn: V::member, - stride: mem::size_of::() as u32, - input_rate: VertexInputRate::Instance { divisor: 1 }, - }); - + self.0.push(V::per_instance()); self } @@ -92,83 +55,18 @@ impl BuffersDefinition { /// [`vertex_attribute_instance_rate_divisor`]: crate::device::Features::vertex_attribute_instance_rate_divisor /// [`vertex_attribute_instance_rate_zero_divisor`]: crate::device::Features::vertex_attribute_instance_rate_zero_divisor pub fn instance_with_divisor(mut self, divisor: u32) -> Self { - self.0.push(VertexBuffer { - info_fn: V::member, - stride: mem::size_of::() as u32, - input_rate: VertexInputRate::Instance { divisor }, - }); - + self.0.push(V::per_instance_with_divisor(divisor)); self } } +#[allow(deprecated)] unsafe impl VertexDefinition for BuffersDefinition { #[inline] fn definition( &self, interface: &ShaderInterface, ) -> Result { - let bindings = self - .0 - .iter() - .enumerate() - .map(|(binding, &buffer)| (binding as u32, buffer.into())); - let mut attributes: Vec<(u32, VertexInputAttributeDescription)> = Vec::new(); - - for element in interface.elements() { - let name = element.name.as_ref().unwrap(); - - let (infos, binding) = self - .0 - .iter() - .enumerate() - .find_map(|(binding, buffer)| { - (buffer.info_fn)(name).map(|infos| (infos, binding as u32)) - }) - .ok_or_else(|| - // TODO: move this check to GraphicsPipelineBuilder - IncompatibleVertexDefinitionError::MissingAttribute { - attribute: name.clone().into_owned(), - })?; - - // TODO: ShaderInterfaceEntryType does not properly support 64bit. - // Once it does the below logic around num_elements and num_locations - // might have to be updated. - if infos.num_components() != element.ty.num_components - || infos.num_elements != element.ty.num_locations() - { - return Err(IncompatibleVertexDefinitionError::FormatMismatch { - attribute: name.clone().into_owned(), - shader: element.ty, - definition: infos, - }); - } - - let mut offset = infos.offset as DeviceSize; - let block_size = infos.format.block_size().unwrap(); - // Double precision formats can exceed a single location. - // R64B64G64A64_SFLOAT requires two locations, so we need to adapt how we bind - let location_range = if block_size > 16 { - (element.location..element.location + 2 * element.ty.num_locations()).step_by(2) - } else { - (element.location..element.location + element.ty.num_locations()).step_by(1) - }; - - for location in location_range { - attributes.push(( - location, - VertexInputAttributeDescription { - binding, - format: infos.format, - offset: offset as u32, - }, - )); - offset += block_size; - } - } - - Ok(VertexInputState::new() - .bindings(bindings) - .attributes(attributes)) + self.0.definition(interface) } } diff --git a/vulkano/src/pipeline/graphics/vertex_input/definition.rs b/vulkano/src/pipeline/graphics/vertex_input/definition.rs index c121c24deb..2372670d49 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/definition.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/definition.rs @@ -50,9 +50,13 @@ //! # } //! ``` +use super::{ + VertexBufferDescription, VertexInputAttributeDescription, VertexInputBindingDescription, +}; use crate::{ pipeline::graphics::vertex_input::{VertexInputState, VertexMemberInfo}, shader::{ShaderInterface, ShaderInterfaceEntryType}, + DeviceSize, }; use std::{ error::Error, @@ -113,3 +117,110 @@ impl Display for IncompatibleVertexDefinitionError { } } } + +unsafe impl VertexDefinition for &[VertexBufferDescription] { + #[inline] + fn definition( + &self, + interface: &ShaderInterface, + ) -> Result { + let bindings = self.iter().enumerate().map(|(binding, buffer)| { + ( + binding as u32, + VertexInputBindingDescription { + stride: buffer.stride, + input_rate: buffer.input_rate, + }, + ) + }); + let mut attributes: Vec<(u32, VertexInputAttributeDescription)> = Vec::new(); + + for element in interface.elements() { + let name = element.name.as_ref().unwrap().clone().into_owned(); + + let (infos, binding) = self + .iter() + .enumerate() + .find_map(|(binding, buffer)| { + buffer + .members + .get(&name) + .map(|infos| (infos.clone(), binding as u32)) + }) + .ok_or_else(|| + // TODO: move this check to GraphicsPipelineBuilder + IncompatibleVertexDefinitionError::MissingAttribute { + attribute: name.clone(), + })?; + + // TODO: ShaderInterfaceEntryType does not properly support 64bit. + // Once it does the below logic around num_elements and num_locations + // might have to be updated. + if infos.num_components() != element.ty.num_components + || infos.num_elements != element.ty.num_locations() + { + return Err(IncompatibleVertexDefinitionError::FormatMismatch { + attribute: name, + shader: element.ty, + definition: infos, + }); + } + + let mut offset = infos.offset as DeviceSize; + let block_size = infos.format.block_size().unwrap(); + // Double precision formats can exceed a single location. + // R64B64G64A64_SFLOAT requires two locations, so we need to adapt how we bind + let location_range = if block_size > 16 { + (element.location..element.location + 2 * element.ty.num_locations()).step_by(2) + } else { + (element.location..element.location + element.ty.num_locations()).step_by(1) + }; + + for location in location_range { + attributes.push(( + location, + VertexInputAttributeDescription { + binding, + format: infos.format, + offset: offset as u32, + }, + )); + offset += block_size; + } + } + + Ok(VertexInputState::new() + .bindings(bindings) + .attributes(attributes)) + } +} + +unsafe impl VertexDefinition for [VertexBufferDescription; N] { + #[inline] + fn definition( + &self, + interface: &ShaderInterface, + ) -> Result { + self.as_slice().definition(interface) + } +} + +unsafe impl VertexDefinition for Vec { + #[inline] + fn definition( + &self, + interface: &ShaderInterface, + ) -> Result { + self.as_slice().definition(interface) + } +} + +unsafe impl VertexDefinition for VertexBufferDescription { + #[inline] + fn definition( + &self, + interface: &ShaderInterface, + ) -> Result { + std::slice::from_ref(self).definition(interface) + } +} diff --git a/vulkano/src/pipeline/graphics/vertex_input/impl_vertex.rs b/vulkano/src/pipeline/graphics/vertex_input/impl_vertex.rs index 5f893c69b3..a38f14c650 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/impl_vertex.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/impl_vertex.rs @@ -35,14 +35,16 @@ macro_rules! impl_vertex { unsafe impl $crate::pipeline::graphics::vertex_input::Vertex for $out { #[inline(always)] #[allow(deprecated)] - fn member(name: &str) -> Option<$crate::pipeline::graphics::vertex_input::VertexMemberInfo> { + fn per_vertex() -> $crate::pipeline::graphics::vertex_input::VertexBufferDescription { #[allow(unused_imports)] + use std::collections::HashMap; use $crate::format::Format; - use $crate::pipeline::graphics::vertex_input::VertexMemberInfo; use $crate::pipeline::graphics::vertex_input::VertexMember; + use $crate::pipeline::graphics::vertex_input::{VertexInputRate, VertexMemberInfo}; + let mut members = HashMap::default(); $( - if name == stringify!($member) { + { let dummy = <$out>::default(); #[inline] fn f(_: &T) -> Format { T::format() } let format = f(&dummy.$member); @@ -58,12 +60,12 @@ macro_rules! impl_vertex { let format_size = format.block_size().expect("no block size for format") as u32; let num_elements = field_size / format_size; let remainder = field_size % format_size; - assert!(remainder == 0, "struct field `{}` size does not fit multiple of format size", name); + assert!(remainder == 0, "struct field `{}` size does not fit multiple of format size", stringify!($member)); let dummy_ptr = (&dummy) as *const _; let member_ptr = (&dummy.$member) as *const _; - return Some(VertexMemberInfo { + members.insert(stringify!($member).to_string(), VertexMemberInfo { offset: member_ptr as usize - dummy_ptr as usize, format, num_elements, @@ -71,8 +73,23 @@ macro_rules! impl_vertex { } )* - None + $crate::pipeline::graphics::vertex_input::VertexBufferDescription { + members, + stride: std::mem::size_of::<$out>() as u32, + input_rate: VertexInputRate::Vertex, + } } + #[inline(always)] + #[allow(deprecated)] + fn per_instance() -> $crate::pipeline::graphics::vertex_input::VertexBufferDescription { + <$out as $crate::pipeline::graphics::vertex_input::Vertex>::per_vertex().per_instance() + } + #[inline(always)] + #[allow(deprecated)] + fn per_instance_with_divisor(divisor: u32) -> $crate::pipeline::graphics::vertex_input::VertexBufferDescription { + <$out as $crate::pipeline::graphics::vertex_input::Vertex>::per_vertex().per_instance_with_divisor(divisor) + } + } ) } @@ -223,9 +240,10 @@ mod tests { } impl_vertex!(TestVertex, scalar, vector, matrix); - let matrix = TestVertex::member("matrix").unwrap(); - let vector = TestVertex::member("vector").unwrap(); - let scalar = TestVertex::member("scalar").unwrap(); + let info = TestVertex::per_vertex(); + let matrix = info.members.get("matrix").unwrap(); + let vector = info.members.get("vector").unwrap(); + let scalar = info.members.get("scalar").unwrap(); assert_eq!(matrix.format, Format::R32G32B32A32_SFLOAT); assert_eq!(matrix.offset, 0); assert_eq!(matrix.num_elements, 4); diff --git a/vulkano/src/pipeline/graphics/vertex_input/mod.rs b/vulkano/src/pipeline/graphics/vertex_input/mod.rs index 38e3455bcd..2ccc73d97c 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/mod.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/mod.rs @@ -104,7 +104,7 @@ pub use self::{ collection::VertexBuffersCollection, definition::{IncompatibleVertexDefinitionError, VertexDefinition}, impl_vertex::VertexMember, - vertex::{Vertex, VertexMemberInfo}, + vertex::{Vertex, VertexBufferDescription, VertexMemberInfo}, }; use crate::format::Format; use ahash::HashMap; diff --git a/vulkano/src/pipeline/graphics/vertex_input/vertex.rs b/vulkano/src/pipeline/graphics/vertex_input/vertex.rs index fe81caef52..d72ffee153 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/vertex.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/vertex.rs @@ -7,8 +7,10 @@ // notice may not be copied, modified, or distributed except // according to those terms. +use super::VertexInputRate; use crate::format::Format; use bytemuck::Pod; +use std::collections::HashMap; pub use vulkano_macros::Vertex; /// Describes an individual `Vertex`. In other words a collection of attributes that can be read @@ -37,14 +39,51 @@ pub use vulkano_macros::Vertex; /// } /// ``` pub unsafe trait Vertex: Pod + Send + Sync + 'static { - /// Returns the characteristics of a vertex member by its name. - fn member(name: &str) -> Option; + /// Returns the information about this Vertex type. + fn per_vertex() -> VertexBufferDescription; + fn per_instance() -> VertexBufferDescription; + fn per_instance_with_divisor(divisor: u32) -> VertexBufferDescription; } -unsafe impl Vertex for () { +/// Describes the contents of a VertexBuffer. +#[derive(Clone, Debug)] +pub struct VertexBufferDescription { + /// List of member names with their detailed information. + pub members: HashMap, + /// Stride of the vertex type in a buffer. + pub stride: u32, + /// How the vertex buffer is unrolled in the shader. + pub input_rate: VertexInputRate, +} + +impl VertexBufferDescription { + #[inline] + pub fn per_vertex(self) -> VertexBufferDescription { + let VertexBufferDescription { + members, stride, .. + } = self; + VertexBufferDescription { + members, + stride, + input_rate: VertexInputRate::Vertex, + } + } + #[inline] - fn member(_: &str) -> Option { - None + pub fn per_instance(self) -> VertexBufferDescription { + self.per_instance_with_divisor(1) + } + + #[inline] + pub fn per_instance_with_divisor(self, divisor: u32) -> VertexBufferDescription { + let VertexBufferDescription { + members, stride, .. + } = self; + VertexBufferDescription { + members, + stride, + input_rate: VertexInputRate::Instance { divisor }, + } } } @@ -87,8 +126,9 @@ mod tests { a: [f32; 16], } - let b = TestVertex::member("b").unwrap(); - let c = TestVertex::member("c").unwrap(); + let info = TestVertex::per_vertex(); + let b = info.members.get("b").unwrap(); + let c = info.members.get("c").unwrap(); assert_eq!(b.format, Format::R32G32B32A32_SFLOAT); assert_eq!(c.format, Format::R32G32B32A32_SFLOAT); assert_eq!(b.num_elements, 4); @@ -104,7 +144,8 @@ mod tests { unorm: u8, } - let unorm = TestVertex::member("unorm").unwrap(); + let info = TestVertex::per_instance(); + let unorm = info.members.get("unorm").unwrap(); assert_eq!(unorm.format, Format::R8_UNORM); assert_eq!(unorm.num_elements, 1); }