Vulkan on Android 6 — VR Stereo Rendering Part 4: Implementation
In this post, we are about to see the rest of the components. And due to the two-stage rendering, render pass, graphics pipeline, command buffers, semaphores, and fences are all paired.
Render Pass
MSAAShaderReadRenderPass
is similar to MSAARenderPass
and it varies in the final layouts of the color and resolved images and the subpass dependencies. The image is going to be used for sampling instead of being presented, so the final layouts are VK_IMAGE_COLOR_ATTACHMENT_OPTIMAL
and VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
for the color and resolved images, respectively. And hence, dstStageMask
and dstAccessMask
are VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
and VK_ACCESS_SHADER_READ_BIT
, respectively.
Additionally, the render pass for multi-view rendering is simply a ColorDestinationRenderPass
which only contains a color attachment without any depth attachments due to no occurrences of occlusions.
Graphics Pipelines
As arguments of graphics pipeline creation, pipeline layouts are created at the end of descriptor set layouts creation due to dependencies.
The two graphics pipeline loads two different shaders which we will talk about later and the rest of them are what we have seen before already. However, BuildMultiviewPipeline
deserves more attention. It disables depth test as we are sure that no occlusions are going to happen. And we specify VkPipelineDynamicStateCreateInfo
for both viewport and scissor areas for the sake of multi-viewport rendering and they are specified in command buffers creation.
Fences and Semaphores
Each set of fences and semaphores has the same number of elements with the number of images the swapchain have as usual. In this application, msaaFences
are extra fences to wait for off-screen rendering to complete before multi-view rendering begins.
Model Loading
The first model we load is from The Hallwyl Museum and is build from camera pictures so it is suitable for our rendering scene.
The second one is a procedurally created square plane used for the multi-view rendering, and the coordinates are in the range -1 to 1 as we want them to be in the clip space. We’ll see how this plane being used in the next post.