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
fences
and semaphores
.
1. There are two ways of synchronizing swap chain events: - They're both objects that can be used for coordinating ops by having one operation signal and another op wait for a
fence
orsemaphore
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
.
- Fences can be accessed from your program using calls like
Semaphores
are used to sync operations within or acrosscommand queues
.- We want to sync the queue ops of draw commands and presentation, so
semaphores
are 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.
Subpasses
in a render pass
automatically take care of image layout transitions, and these transitions are controlled by subpass dependencies
.
3. subpass dependencies
specify 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 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 theimageAvailableSemaphore
toVK_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 theVK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
stage. 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.