Understanding Swap Chains, Buffering, and Pipeline Layout in Vulkan
0:02 Swap Chains and Frame Buffers: The swap chain is a series of frame buffers used to display images to a window, coordinating with the display to swap front and back buffers near the vertical sync (vsync).
0:28 Double Buffering: Modern systems use at least two buffers (double buffering): the front buffer (displayed) and the back buffer (rendered to).
0:44 VSync and Tearing: VSync synchronizes buffer swaps with the display's refresh rate. Disabling vsync can cause tearing, where multiple frames are shown in a single draw.
1:48 Triple Buffering: Adds a second back buffer, allowing the device to immediately start working on the next frame instead of waiting for the vsync. Requires more memory but avoids frame rate hiccups when rendering can't keep up with the refresh rate.
2:54 Adaptive Sync/G-Sync: Technologies that change the display's behavior to avoid waiting for the entire update period before refreshing.
3:03 Key Takeaways: Multiple frame buffers (likely two or three) will be used. Each frame, the swap chain tells the graphics pipeline which frame buffer to use.
3:33 Swap Chain Class: Handles synchronization and setup for double or triple buffering, and creates frame buffer objects with color and depth attachments. Code for this class is available for download.
4:28 Window Extent: A getter is added to the window class to return the window's extent (width and height).
5:06 Pipeline Config Info Fix: Addresses an issue where the viewport info in the pipeline config was improperly structured, potentially leading to dangling pointers when the config was copied.
6:33 Swap Present Modes: The chooseSwapPresentMode function selects the mailbox present mode (if available) or vsync as a fallback, determining how the swap chain synchronizes with the display.
6:56 FIFO vs. Mailbox: FIFO (vsync) can cause the GPU to idle if rendering is too fast. Mailbox overwrites older back buffers, resulting in fresher images with lower input latency but potentially higher power consumption.
8:24 Immediate Present Mode: Bypasses synchronization, potentially causing tearing but indicating maximum FPS.
8:50 Swap Chain Instantiation: The swap chain is instantiated in the first app class using the device and window extent.
9:28 Pipeline as Unique Pointer: The pipeline object is changed to a unique pointer for automatic memory management.
10:14 Pipeline Layout and Command Buffers: Private member variables for the pipeline layout (a way to pass data to shaders beyond vertex data) and command buffers (instructions for the GPU) are added to the first app class.
11:34 Create Pipeline Layout Function: Creates an empty pipeline layout.
12:10 Pipeline Set Layout, Push Constants: A pipeline set layout is used to pass data other than vertex data to the vertex and fragment shaders, and push constants are a way to send small amounts of data to shader programs.
13:15 Create Pipeline Function: Creates the graphics pipeline.
14:00 Render Pass: Describes the structure and format of frame buffer objects and their attachments.
15:11 Pipeline Creation: The pipeline object is created using the lve pipeline, and the code compiles successfully with the pipeline layout and render pass.