chore(workspace): run cargo fmt

This commit is contained in:
Serkyo 2026-05-12 18:53:56 +02:00
parent 34f1a9d989
commit d30834e14f
3 changed files with 24 additions and 15 deletions

View file

@ -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,8 +194,7 @@ 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 {
let vertex_allocation = allocator.allocate(&gpu_allocator::vulkan::AllocationCreateDesc {
name: "Vertex Buffer",
requirements,
location: gpu_allocator::MemoryLocation::CpuToGpu,

View file

@ -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::<Self>()).expect("Vertex size exceeds u32 range"))
.stride(
u32::try_from(std::mem::size_of::<Self>()).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"),
),
]
}
}

View file

@ -34,7 +34,9 @@ pub fn create_pipeline_layout(device: &Device) -> Result<vk::PipelineLayout, Ren
let push_constant_range = vk::PushConstantRange::default()
.stage_flags(vk::ShaderStageFlags::VERTEX)
.offset(0)
.size(u32::try_from(std::mem::size_of::<glam::Mat4>()).expect("Mat4 size exceeds u32 range"));
.size(
u32::try_from(std::mem::size_of::<glam::Mat4>()).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");