Organizing Vulkan frame rendering code
As we learned from the previous chapter, the Vulkan API is pretty verbose. We need something to conceal the API's verbosity and organize our frame rendering code in a manageable way. Let's assume that each frame is composed of multiple layers, just like an image in a graphics editor. The first, and rather formal, layer is the solid background color. The next layer might be a 3D scene with models and lights. On top of a beautifully rendered 3D scene, we could optionally add some wireframe meshes to draw useful debugging information. These wireframe objects belong in another layer. Next, we add a 2D user interface, for example, using the ImGui library. There might be some additional layers, such as fullscreen charts with performance statistics or frames-per-second (FPS) counters. Finally, the finishing layer transitions the swapchain image to the VK_LAYOUT_PRESENT_SRC_KHR
layout.
In this recipe, we define an interface to render a single...