From 4c1226f658d1d0b80fef2b146306b660c859a4f3 Mon Sep 17 00:00:00 2001 From: Pasha Bibko <156938226+PashaBibko@users.noreply.github.com> Date: Sun, 16 Nov 2025 18:15:55 +0000 Subject: [PATCH] Added comments about Vulkan init --- src/managers/VulkanManager.h | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/managers/VulkanManager.h b/src/managers/VulkanManager.h index bbb27ba..c38cbb1 100644 --- a/src/managers/VulkanManager.h +++ b/src/managers/VulkanManager.h @@ -33,21 +33,81 @@ namespace PB::Renderer VulkanManager() = delete; ~VulkanManager() = delete; + /* Shorthand for calling all the initialisation functions, returns false if any fail */ static bool Init(GLFWwindow* window); + + /* Frees ALL allocated Vulkan resources */ static bool Cleanup(); + /* + Creates the global Vulkan instance, which connects the application to Vulkan. + Defines the application info and imports the needed (GLFW) extensions. + */ static bool CreateInstance(); + + /* + Ties a surface to the window to present images. Abstracts platform specific code. + Required for creating a swap chain. + */ static bool CreateSurface(GLFWwindow* window); + + /* + Scans for all available GPUs and picks the first one that supports the necessary capabilities. + Only looks for discrete (non-integrated) GPUs and uses that for all rendering. + */ static bool PickPhysicalDevice(); + + /* + Creates a logical device which handles the commands from Vulkan to hardware instructions. + Also requests the queues needed. + */ static bool CreateLogicalDevice(); + + /* + Creates a swap chain with suitable image formats, present modes and image dimensions. + The swap chain is the series of images that are displayed to the screen. + */ static bool CreateSwapChain(GLFWwindow* window); + + /* + Each swap chain image requires a view, which describes how shaders and + the pipeline interact with the image data. + */ static bool CreateImageViews(); + + /* + Defines the attachments (such as color and depth) and defines how they are rendered. + Also defines the subpasses and dependencies between them. + */ static bool CreateRenderPass(); + + /* + Creates a framebuffer for each swap chain image, pairing the render pass with the relevant image. + Each framebuffer is a specific set of attachments used drawing a render pass instance. + */ static bool CreateFramebuffer(); + + /* + Assembles shaders, fixed function state and creates the render pipeline. + Also checks that the render pass is compatiable. + */ static bool CreateGraphicsPipeline(); + + /* + Allocates a command pool and command buffers. + The buffers represent the exact instructions the GPU will execute. + */ static bool CreateCommandBuffers(); + + /* + Creates sync between coordinate operations between different parts of the rendering. + Required to stop race conditions between frames. + */ static bool CreateSemaphores(); + /* + Draws a frame to the screen using the command buffers and sync objects. + */ static bool RenderPass(); private: