docs(renderer): collapse multi-line comments and note construction leak

This commit is contained in:
Serkyo 2026-05-16 20:30:01 +02:00
parent 7399d554ec
commit 928f0103a4
4 changed files with 7 additions and 13 deletions

View file

@ -37,6 +37,7 @@ impl Renderer {
/// # Panics
///
/// Panics if `MAX_FRAMES_IN_FLIGHT` or vertex data sizes exceed `u32`/`u64` limits.
// TODO: partial-construction leak. Each `?` below early-returns and leaks every Vulkan resource created so far; only a fully successful `new` reaches `Drop for Renderer`. Once the renderer grows more state, wrap each resource in an RAII guard so failure paths tear them down too.
#[allow(clippy::expect_used)]
pub fn new(
display_handle: RawDisplayHandle,

View file

@ -10,7 +10,6 @@ use bytemuck::{Pod, Zeroable};
#[derive(Copy, Clone, Debug, Pod, Zeroable)]
pub struct Vertex {
/// 3D position of the vertex (X, Y, Z).
/// The position coordinates of the vertex [x, y, z].
pub position: [f32; 3],
/// The RGB color of the vertex [r, g, b].
pub color: [f32; 3],
@ -19,8 +18,7 @@ pub struct Vertex {
impl Vertex {
/// Describes how Vulkan should read the vertex data from a buffer.
///
/// This defines the 'stride' (distance between vertices) and specifies that
/// data is read per-vertex rather than per-instance.
/// This defines the 'stride' (distance between vertices) and specifies that data is read per-vertex rather than per-instance.
///
/// # Panics
/// Panics if the size of the vertex structure exceeds the maximum value of a 32-bit unsigned integer.

View file

@ -7,8 +7,7 @@ use std::io::Cursor;
/// Helper to load SPIR-V bytes and create a Vulkan Shader Module.
///
/// Vulkan expects shader code to be 32-bit aligned; `ash::util::read_spv` is
/// used to correctly interpret the raw bytes as a slice of `u32`.
/// Vulkan expects shader code to be 32-bit aligned; `ash::util::read_spv` is used to correctly interpret the raw bytes as a slice of `u32`.
pub fn create_shader_module(
device: &Device,
bytes: &[u8],
@ -25,11 +24,9 @@ pub fn create_shader_module(
/// Defines the 'interface' of the pipeline (what data we can pass to the shaders).
///
/// This layout defines any push constants or descriptor sets (textures/UBOs)
/// accessed by the shaders during execution.
/// This layout defines any push constants or descriptor sets (textures/UBOs) accessed by the shaders during execution.
pub fn create_pipeline_layout(device: &Device) -> Result<vk::PipelineLayout, RendererError> {
// A single push constant range is defined for the Model-View-Projection matrix.
// This allows the matrix to be updated for every draw call with high efficiency.
// A single push constant range is defined for the MVP matrix, allowing it to be updated for every draw call with high efficiency.
#[allow(clippy::expect_used)]
let push_constant_range = vk::PushConstantRange::default()
.stage_flags(vk::ShaderStageFlags::VERTEX)
@ -47,8 +44,7 @@ pub fn create_pipeline_layout(device: &Device) -> Result<vk::PipelineLayout, Ren
/// Creates a Graphics Pipeline for voxel rendering using Vulkan 1.3 Dynamic Rendering.
///
/// The pipeline encapsulates the entire state of the GPU for a specific draw operation,
/// including shader stages, vertex input layout, rasterization settings, and blending.
/// The pipeline encapsulates the entire state of the GPU for a specific draw operation, including shader stages, vertex input layout, rasterization settings, and blending.
pub fn create_graphics_pipeline(
device: &Device,
layout: vk::PipelineLayout,

View file

@ -440,8 +440,7 @@ impl Drop for Renderer {
self.device.destroy_image_view(self.depth_image_view, None);
self.device.destroy_image(self.depth_image, None);
// Drop the allocator before destroying the logical device so it can
// release any remaining memory blocks while the device is still valid.
// Drop the allocator before destroying the logical device so its remaining memory blocks are released while the device is still valid.
drop(self.allocator.take());
self.device.destroy_command_pool(self.command_pool, None);