1*61046927SAndroid Build Coastguard WorkerRender Passes 2*61046927SAndroid Build Coastguard Worker============= 3*61046927SAndroid Build Coastguard Worker 4*61046927SAndroid Build Coastguard WorkerThe Vulkan runtime code in Mesa provides several helpful utilities to make 5*61046927SAndroid Build Coastguard Workermanaging render passes easier. 6*61046927SAndroid Build Coastguard Worker 7*61046927SAndroid Build Coastguard Worker 8*61046927SAndroid Build Coastguard Worker:ext:`VK_KHR_create_renderpass2` 9*61046927SAndroid Build Coastguard Worker-------------------------------- 10*61046927SAndroid Build Coastguard Worker 11*61046927SAndroid Build Coastguard WorkerIt is strongly recommended that drivers implement 12*61046927SAndroid Build Coastguard Worker:ext:`VK_KHR_create_renderpass2` directly and not bother implementing the 13*61046927SAndroid Build Coastguard Workerold Vulkan 1.0 entrypoints. If a driver does not implement them, the 14*61046927SAndroid Build Coastguard Workerfollowing will be implemented in common code in terms of their 15*61046927SAndroid Build Coastguard Worker:ext:`VK_KHR_create_renderpass2` counterparts: 16*61046927SAndroid Build Coastguard Worker 17*61046927SAndroid Build Coastguard Worker - :c:func:`vkCreateRenderPass` 18*61046927SAndroid Build Coastguard Worker - :c:func:`vkCmdBeginRenderPass` 19*61046927SAndroid Build Coastguard Worker - :c:func:`vkCmdNextSubpass` 20*61046927SAndroid Build Coastguard Worker - :c:func:`vkCmdEndRenderPass` 21*61046927SAndroid Build Coastguard Worker 22*61046927SAndroid Build Coastguard Worker 23*61046927SAndroid Build Coastguard WorkerCommon VkRenderPass implementation 24*61046927SAndroid Build Coastguard Worker---------------------------------- 25*61046927SAndroid Build Coastguard Worker 26*61046927SAndroid Build Coastguard WorkerThe Vulkan runtime code in Mesa provides a common implementation of 27*61046927SAndroid Build Coastguard Worker:c:type:`VkRenderPass` called :c:struct:`vk_render_pass` which drivers 28*61046927SAndroid Build Coastguard Workercan optionally use. Unlike most Vulkan runtime structs, it's not really 29*61046927SAndroid Build Coastguard Workerdesigned to be used as a base for a driver-specific struct. It does, 30*61046927SAndroid Build Coastguard Workerhowever, contain all the information passed to 31*61046927SAndroid Build Coastguard Worker:c:func:`vkCreateRenderPass2` so it can be used in a driver so long as 32*61046927SAndroid Build Coastguard Workerthat driver doesn't need to do any additional compilation at 33*61046927SAndroid Build Coastguard Worker:c:func:`vkCreateRenderPass2` time. If a driver chooses to use 34*61046927SAndroid Build Coastguard Worker:c:struct:`vk_render_pass`, the Vulkan runtime provides implementations 35*61046927SAndroid Build Coastguard Workerof :c:func:`vkCreateRenderPass2` and :c:func:`vkDestroyRenderPass`. 36*61046927SAndroid Build Coastguard Worker 37*61046927SAndroid Build Coastguard Worker 38*61046927SAndroid Build Coastguard Worker:ext:`VK_KHR_dynamic_rendering` 39*61046927SAndroid Build Coastguard Worker------------------------------- 40*61046927SAndroid Build Coastguard Worker 41*61046927SAndroid Build Coastguard WorkerFor drivers which don't need to do subpass combining, it is recommended 42*61046927SAndroid Build Coastguard Workerthat they skip implementing render passes entirely and implement 43*61046927SAndroid Build Coastguard Worker:ext:`VK_KHR_dynamic_rendering` instead. If they choose to do so, the runtime 44*61046927SAndroid Build Coastguard Workerwill provide the following, implemented in terms of 45*61046927SAndroid Build Coastguard Worker:c:func:`vkCmdBeginRendering` and :c:func:`vkCmdEndRendering`: 46*61046927SAndroid Build Coastguard Worker 47*61046927SAndroid Build Coastguard Worker - :c:func:`vkCmdBeginRenderPass2` 48*61046927SAndroid Build Coastguard Worker - :c:func:`vkCmdNextSubpass2` 49*61046927SAndroid Build Coastguard Worker - :c:func:`vkCmdEndRenderPass2` 50*61046927SAndroid Build Coastguard Worker 51*61046927SAndroid Build Coastguard WorkerWe also provide a no-op implementation of 52*61046927SAndroid Build Coastguard Worker:c:func:`vkGetRenderAreaGranularity` which returns a render area 53*61046927SAndroid Build Coastguard Workergranularity of 1x1. 54*61046927SAndroid Build Coastguard Worker 55*61046927SAndroid Build Coastguard WorkerDrivers which wish to use the common render pass implementation in this way 56*61046927SAndroid Build Coastguard Worker**must** also support a Mesa-specific pseudo-extension which optionally 57*61046927SAndroid Build Coastguard Workerprovides an initial image layout for each attachment at 58*61046927SAndroid Build Coastguard Worker:c:func:`vkCmdBeginRendering` time. This is required for us to combine 59*61046927SAndroid Build Coastguard Workerrender pass clears with layout transitions, often from 60*61046927SAndroid Build Coastguard Worker:c:enum:`VK_IMAGE_LAYOUT_UNDEFINED`. On at least Intel and AMD, 61*61046927SAndroid Build Coastguard Workercombining these transitions with clears is important for performance. 62*61046927SAndroid Build Coastguard Worker 63*61046927SAndroid Build Coastguard Worker.. c:autostruct:: VkRenderingAttachmentInitialLayoutInfoMESA 64*61046927SAndroid Build Coastguard Worker :file: src/vulkan/runtime/vk_render_pass.h 65*61046927SAndroid Build Coastguard Worker :members: 66*61046927SAndroid Build Coastguard Worker 67*61046927SAndroid Build Coastguard WorkerBecause render passes and subpass indices are also passed into 68*61046927SAndroid Build Coastguard Worker:c:func:`vkCmdCreateGraphicsPipelines` and 69*61046927SAndroid Build Coastguard Worker:c:func:`vkCmdExecuteCommands` which we can't implement on the driver's 70*61046927SAndroid Build Coastguard Workerbehalf, we provide a couple of helpers for getting the render pass 71*61046927SAndroid Build Coastguard Workerinformation in terms of the relevant :ext:`VK_KHR_dynamic_rendering`: 72*61046927SAndroid Build Coastguard Worker 73*61046927SAndroid Build Coastguard Worker.. c:autofunction:: vk_get_pipeline_rendering_create_info 74*61046927SAndroid Build Coastguard Worker :file: src/vulkan/runtime/vk_render_pass.h 75*61046927SAndroid Build Coastguard Worker 76*61046927SAndroid Build Coastguard Worker.. c:autofunction:: vk_get_command_buffer_inheritance_rendering_info 77*61046927SAndroid Build Coastguard Worker :file: src/vulkan/runtime/vk_render_pass.h 78*61046927SAndroid Build Coastguard Worker 79*61046927SAndroid Build Coastguard WorkerApart from handling layout transitions, the common render pass 80*61046927SAndroid Build Coastguard Workerimplementation mostly ignores input attachments. It is expected that the 81*61046927SAndroid Build Coastguard Workerdriver call :c:func:`nir_lower_input_attachments` to turn them into 82*61046927SAndroid Build Coastguard Workertexturing operations. The driver **must** support texturing from an input 83*61046927SAndroid Build Coastguard Workerattachment at the same time as rendering to it in order to support Vulkan 84*61046927SAndroid Build Coastguard Workersubpass self-dependencies. ``VK_EXT_attachment_feedback_loop_layout`` provides 85*61046927SAndroid Build Coastguard Workerinformation on when these self dependencies are present. 86*61046927SAndroid Build Coastguard Worker 87*61046927SAndroid Build Coastguard Workervk_render_pass reference 88*61046927SAndroid Build Coastguard Worker------------------------ 89*61046927SAndroid Build Coastguard Worker 90*61046927SAndroid Build Coastguard WorkerThe following is a reference for the :c:struct:`vk_render_pass` structure 91*61046927SAndroid Build Coastguard Workerand its substructures. 92*61046927SAndroid Build Coastguard Worker 93*61046927SAndroid Build Coastguard Worker.. c:autostruct:: vk_render_pass 94*61046927SAndroid Build Coastguard Worker :file: src/vulkan/runtime/vk_render_pass.h 95*61046927SAndroid Build Coastguard Worker :members: 96*61046927SAndroid Build Coastguard Worker 97*61046927SAndroid Build Coastguard Worker.. c:autostruct:: vk_render_pass_attachment 98*61046927SAndroid Build Coastguard Worker :file: src/vulkan/runtime/vk_render_pass.h 99*61046927SAndroid Build Coastguard Worker :members: 100*61046927SAndroid Build Coastguard Worker 101*61046927SAndroid Build Coastguard Worker.. c:autostruct:: vk_subpass 102*61046927SAndroid Build Coastguard Worker :file: src/vulkan/runtime/vk_render_pass.h 103*61046927SAndroid Build Coastguard Worker :members: 104*61046927SAndroid Build Coastguard Worker 105*61046927SAndroid Build Coastguard Worker.. c:autostruct:: vk_subpass_attachment 106*61046927SAndroid Build Coastguard Worker :file: src/vulkan/runtime/vk_render_pass.h 107*61046927SAndroid Build Coastguard Worker :members: 108*61046927SAndroid Build Coastguard Worker 109*61046927SAndroid Build Coastguard Worker.. c:autostruct:: vk_subpass_dependency 110*61046927SAndroid Build Coastguard Worker :file: src/vulkan/runtime/vk_render_pass.h 111*61046927SAndroid Build Coastguard Worker :members: 112