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
/// ///
/// Panics if `MAX_FRAMES_IN_FLIGHT` or vertex data sizes exceed `u32`/`u64` limits. /// 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)] #[allow(clippy::expect_used)]
pub fn new( pub fn new(
display_handle: RawDisplayHandle, display_handle: RawDisplayHandle,

View file

@ -10,7 +10,6 @@ use bytemuck::{Pod, Zeroable};
#[derive(Copy, Clone, Debug, Pod, Zeroable)] #[derive(Copy, Clone, Debug, Pod, Zeroable)]
pub struct Vertex { pub struct Vertex {
/// 3D position of the vertex (X, Y, Z). /// 3D position of the vertex (X, Y, Z).
/// The position coordinates of the vertex [x, y, z].
pub position: [f32; 3], pub position: [f32; 3],
/// The RGB color of the vertex [r, g, b]. /// The RGB color of the vertex [r, g, b].
pub color: [f32; 3], pub color: [f32; 3],
@ -19,8 +18,7 @@ pub struct Vertex {
impl Vertex { impl Vertex {
/// Describes how Vulkan should read the vertex data from a buffer. /// Describes how Vulkan should read the vertex data from a buffer.
/// ///
/// This defines the 'stride' (distance between vertices) and specifies that /// This defines the 'stride' (distance between vertices) and specifies that data is read per-vertex rather than per-instance.
/// data is read per-vertex rather than per-instance.
/// ///
/// # Panics /// # Panics
/// Panics if the size of the vertex structure exceeds the maximum value of a 32-bit unsigned integer. /// 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. /// 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 /// 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`.
/// used to correctly interpret the raw bytes as a slice of `u32`.
pub fn create_shader_module( pub fn create_shader_module(
device: &Device, device: &Device,
bytes: &[u8], 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). /// 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) /// This layout defines any push constants or descriptor sets (textures/UBOs) accessed by the shaders during execution.
/// accessed by the shaders during execution.
pub fn create_pipeline_layout(device: &Device) -> Result<vk::PipelineLayout, RendererError> { pub fn create_pipeline_layout(device: &Device) -> Result<vk::PipelineLayout, RendererError> {
// A single push constant range is defined for the Model-View-Projection matrix. // A single push constant range is defined for the MVP matrix, allowing it to be updated for every draw call with high efficiency.
// This allows the matrix to be updated for every draw call with high efficiency.
#[allow(clippy::expect_used)] #[allow(clippy::expect_used)]
let push_constant_range = vk::PushConstantRange::default() let push_constant_range = vk::PushConstantRange::default()
.stage_flags(vk::ShaderStageFlags::VERTEX) .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. /// 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, /// The pipeline encapsulates the entire state of the GPU for a specific draw operation, including shader stages, vertex input layout, rasterization settings, and blending.
/// including shader stages, vertex input layout, rasterization settings, and blending.
pub fn create_graphics_pipeline( pub fn create_graphics_pipeline(
device: &Device, device: &Device,
layout: vk::PipelineLayout, 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_view(self.depth_image_view, None);
self.device.destroy_image(self.depth_image, None); self.device.destroy_image(self.depth_image, None);
// Drop the allocator before destroying the logical device so it can // Drop the allocator before destroying the logical device so its remaining memory blocks are released while the device is still valid.
// release any remaining memory blocks while the device is still valid.
drop(self.allocator.take()); drop(self.allocator.take());
self.device.destroy_command_pool(self.command_pool, None); self.device.destroy_command_pool(self.command_pool, None);