diff --git a/crates/renderer/src/lib.rs b/crates/renderer/src/lib.rs index 5b32bef..648dbc7 100644 --- a/crates/renderer/src/lib.rs +++ b/crates/renderer/src/lib.rs @@ -95,7 +95,9 @@ impl Renderer { let alloc_info = vk::CommandBufferAllocateInfo::default() .command_pool(command_pool) .level(vk::CommandBufferLevel::PRIMARY) - .command_buffer_count(u32::try_from(MAX_FRAMES_IN_FLIGHT).expect("MAX_FRAMES_IN_FLIGHT exceeds u32")); + .command_buffer_count( + u32::try_from(MAX_FRAMES_IN_FLIGHT).expect("MAX_FRAMES_IN_FLIGHT exceeds u32"), + ); let command_buffers = unsafe { device.allocate_command_buffers(&alloc_info)? }; @@ -112,8 +114,7 @@ impl Renderer { pipeline::create_graphics_pipeline(&device, pipeline_layout, swapchain_format)?; // 13. Vertex Buffer Initialization - let (vertex_buffer, vertex_allocation) = - create_vertex_buffer(&device, &mut allocator)?; + let (vertex_buffer, vertex_allocation) = create_vertex_buffer(&device, &mut allocator)?; Ok(Self { _entry: entry, @@ -193,14 +194,13 @@ fn create_vertex_buffer( let vertex_buffer = unsafe { device.create_buffer(&buffer_info, None)? }; let requirements = unsafe { device.get_buffer_memory_requirements(vertex_buffer) }; - let vertex_allocation = - allocator.allocate(&gpu_allocator::vulkan::AllocationCreateDesc { - name: "Vertex Buffer", - requirements, - location: gpu_allocator::MemoryLocation::CpuToGpu, - linear: true, - allocation_scheme: gpu_allocator::vulkan::AllocationScheme::GpuAllocatorManaged, - })?; + let vertex_allocation = allocator.allocate(&gpu_allocator::vulkan::AllocationCreateDesc { + name: "Vertex Buffer", + requirements, + location: gpu_allocator::MemoryLocation::CpuToGpu, + linear: true, + allocation_scheme: gpu_allocator::vulkan::AllocationScheme::GpuAllocatorManaged, + })?; unsafe { device.bind_buffer_memory( diff --git a/crates/renderer/src/mesh.rs b/crates/renderer/src/mesh.rs index f112cc1..c9d0e11 100644 --- a/crates/renderer/src/mesh.rs +++ b/crates/renderer/src/mesh.rs @@ -24,7 +24,9 @@ impl Vertex { pub fn get_binding_description() -> ash::vk::VertexInputBindingDescription { ash::vk::VertexInputBindingDescription::default() .binding(0) - .stride(u32::try_from(std::mem::size_of::()).expect("Vertex size exceeds u32 range")) + .stride( + u32::try_from(std::mem::size_of::()).expect("Vertex size exceeds u32 range"), + ) .input_rate(ash::vk::VertexInputRate::VERTEX) } @@ -45,7 +47,10 @@ impl Vertex { .binding(0) .location(1) .format(ash::vk::Format::R32G32_SFLOAT) - .offset(u32::try_from(std::mem::size_of::<[f32; 3]>()).expect("Vertex offset exceeds u32 range")), + .offset( + u32::try_from(std::mem::size_of::<[f32; 3]>()) + .expect("Vertex offset exceeds u32 range"), + ), ] } } diff --git a/crates/renderer/src/pipeline.rs b/crates/renderer/src/pipeline.rs index 7be758e..e06277f 100644 --- a/crates/renderer/src/pipeline.rs +++ b/crates/renderer/src/pipeline.rs @@ -34,7 +34,9 @@ pub fn create_pipeline_layout(device: &Device) -> Result()).expect("Mat4 size exceeds u32 range")); + .size( + u32::try_from(std::mem::size_of::()).expect("Mat4 size exceeds u32 range"), + ); let layout_create_info = vk::PipelineLayoutCreateInfo::default() .push_constant_ranges(std::slice::from_ref(&push_constant_range)); @@ -140,7 +142,9 @@ pub fn create_graphics_pipeline( } /// Loads the vertex and fragment shader modules from embedded bytes. -fn load_shader_modules(device: &Device) -> Result<(vk::ShaderModule, vk::ShaderModule), RendererError> { +fn load_shader_modules( + device: &Device, +) -> Result<(vk::ShaderModule, vk::ShaderModule), RendererError> { let vert_bytes = include_bytes!("../../../assets/shaders/cube.vert.spv"); let frag_bytes = include_bytes!("../../../assets/shaders/cube.frag.spv");