Coding Session 2025 by Malfunction, Scotch and Belial
- Release:
cmake -DCMAKE_BUILD_TYPE=Release .. - Debug:
cmake -DCMAKE_BUILD_TYPE=Debug ..
In case you are not familiar with the vulkan API, the following sections describe the most important components.
- Entry point into the Vulkan API.
- The Vulkan loader uses the instance to find the appropriate drivers and available extensions.
- Represents the window (e.g., from GLFW) that will be drawn to.
- Vulkan uses the surface to pass rendered images to the window system.
- The actual GPU in the system.
- Provides information about the hardware’s capabilities (e.g., supported formats and queues).
- Software interface to the selected GPU.
- Enables creation of resources and sending commands to the GPU.
- A queue where command buffers are submitted for execution.
- Your
graphicsQueueprocesses draw commands and presentation commands.
- A set of images displayed on the screen (double/triple buffering).
- The GPU renders into these images, which are then presented.
- Raw memory object from the swapchain.
- Contains the actual color image for the current frame.
- Provides access to a
VkImage, e.g., as a color attachment in the render pass. - Specifies how the image should be interpreted.
- Describes how the framebuffer images are used (clear, load, store).
- Defines layout transitions and subpasses.
- Combines one or more
VkImageViews with aVkRenderPass. - Represents the concrete target image for the current frame.
- Compiled shader code in SPIR-V format.
- Used in the pipeline to define the vertex and fragment stages.
- Container for resources like descriptor sets or push constants.
- Empty in our example, but still required.
- Comprehensive description of all drawing parameters:
- Shader stages
- Vertex input
- Rasterizer
- Color processing
- Render target type
- Must be compatible with the
VkRenderPass.
- Memory management for
VkCommandBuffer. - Must be associated with a specific queue family.
- List of GPU commands such as
vkCmdDraw,vkCmdBindPipeline, etc. - Recorded once before rendering.
- GPU synchronization objects:
imageAvailableSemaphore: signals that an image is available.renderFinishedSemaphore: signals that rendering is complete and the image can be presented.
-
Acquire Image (
vkAcquireNextImageKHR)- Gets the next available swapchain image.
- Waits on the
imageAvailableSemaphore.
-
Submit Command Buffer (
vkQueueSubmit)- Executes the recorded draw commands.
- Waits on the
imageAvailableSemaphore. - Signals the
renderFinishedSemaphore.
-
Present (
vkQueuePresentKHR)- Displays the finished image in the window.
- Waits on the
renderFinishedSemaphore.