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
fenceorsemaphoreto signal. Fencesare mainly designed to sync your app itself with the rendering operation.- Fences can be accessed from your program using calls like
vkWaitForFences.
- Fences can be accessed from your program using calls like
Semaphoresare used to sync operations within or acrosscommand queues.- We want to sync the queue ops of draw commands and presentation, so
semaphoresare the best fit for this tutorial.
- We want to sync the queue ops of draw commands and presentation, so
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 dependenciesspecify memory and execution dependencies betweensubpasses.- At this point in the tutorial, we only have 1
subpass, but the operations right before and after are implicitsubpasses. - There are 2 built-in dependencies that take care of the transition at the start of the
render passand 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
waitStagesfor theimageAvailableSemaphoretoVK_PIPELINE_STAGE_TOP_OF_PIPE_BITto make sure the render passes don't begin until the image is ready. - Make the
render passwait for theVK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BITstage. For this tutorial, we are using this option.
- Modifying the
See ya!
Got distracted with family things, so I wasn't able to finish this page today.