Understanding Vulkan Workflow

Echo Yin
Women in Technology
3 min readAug 15, 2023

[Personal Devlog: August 15, 2023]

There are million ways of coding a game engine, choosing a renderer API is a tough choice when getting started. My personal goal is: in understanding the workflow and taking effort of implementing something that is meaningful, in return I could be a better programmer.

So it should start with knowing how computer graphics work. When we see frames of images on the screen, the calculating devices such our desktops or Cloud Servers has already done the graphic pipeline jobs several mili-seconds prior.

Vulkan Object Notes (TBC)

VkInstance

An base object that is used to access drivers.
It initializes the Vulkan library.
The first handle to be created.
Vulkan does not have global state.
All the information required for Vulkan to run is in this handle.

VKSurfaceKHR

This handle is responsible for presenting the image information calculated and sent to GPU to the surface (i.e. a monitor screen).

VKPhysicalDevice

This is the presentation of hardware device (GPU)
It is possible to have multiple GPUs at the same time, those can be chosen by selecting the VKPhysicalDevince handles.

From An Application to Pre-image

A game engine in essence is a piece of software, and a highly sophisticated one that is!

The the materials of image data such as meshes and textures are converted into GPU readable commands. They are sent to the command buffers ready to be called by physical devices (in this case GPUs). After that the commands are waiting in the Queues to be executed (the word executed is a bit… harsh).

Notes on Vulkan Workflow

Core Structure Initialization

  • Creating a VkInstance
  • Query a list of VkPhysicalDevice (A laptop can have two GPUs, one integrated and one dedicated)
  • Create a VkDevice from selected VkPhysicalDevice instance.
  • Create VkCommandPool (command buffers are here)
  • Get VkQueue handles from VkDevice.
  • Execute commands from VkQueue handles.
  • Initialize VkSwapchainKHR

After Materials Are Loaded

  • Create a set of VkPipeline for providing information to render the materials. (Pipeline creation is expensive)
  • Upload mesh vertex data into VkBuffer resources.
  • Upload textures into VkImage resources.
  • Create VkRenderPass (one for main, one for shadow etc. in concurrent mode).

The preprocessing is done and the image is ready for rendering

  • Ask VkSwapchainKHR for an image to render.
  • Allocate a VkCommandBuffer from VkCommandBufferPool/Re-use one allocated command buffer.
  • Start a VkRenderPass.
  • Create a loop with a VkPipeline in it.
  • Bind VkDescriptorSet.
  • Bind vertex buffer.
  • Execute a draw call.
  • Terminat the VkRenderPass.

When rendering is finished

  • End VkCommandBuffer.
  • Submit the commnad buffer into the queue.
  • Execute commands from the command buffer on the GPU.
  • Display the rendered result to the surface (the screen).

--

--