Day 10 (Dec 30, 2020) ~~~ Getting Close to Drawing a Triangle! - kwilson33/learning-vulkan GitHub Wiki

Progress Today

In the middle of:

Here are some major takeaways

1. There are two ways of synchronizing swap chain events: fences and semaphores.

  • They're both objects that can be used for coordinating ops by having one operation signal and another op wait for a fence or semaphore to signal.
  • Fences are mainly designed to sync your app itself with the rendering operation.
    • Fences can be accessed from your program using calls like vkWaitForFences.
  • Semaphores are used to sync operations within or across command queues.
    • We want to sync the queue ops of draw commands and presentation, so semaphores are the best fit for this tutorial.

2. To draw a frame, the function in the tutorial will do 3 things:

  • Acquire an image from the swap chain.
  • Execute the command buffer with that image as the attachment in the framebuffer.
  • Return the image to the swap chain for presentation.

3. Subpasses in a render pass automatically take care of image layout transitions, and these transitions are controlled by subpass dependencies.

  • subpass dependencies specify memory and execution dependencies between subpasses.
  • At this point in the tutorial, we only have 1 subpass, but the operations right before and after are implicit subpasses.
  • There are 2 built-in dependencies that take care of the transition at the start of the render pass and at the end, but the transition at the start doesn't happen at the right time.
    • It assumes the transition occurs at the start of the pipeline, but we haven't gotten the image yet at this point.
    • SO! We have to deal with this either by:
      • Modifying the waitStages for the imageAvailableSemaphore to VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT to make sure the render passes don't begin until the image is ready.
      • Make the render pass wait for the VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT stage. For this tutorial, we are using this option.

See ya!

Got distracted with family things, so I wasn't able to finish this page today.