vulkan/wsi: Refactors to pull buffer blit decisions into common code
The final patch in this MR is needed by NVK since NVIDIA hardware is incapable of rendering to linear images (at least if a depth/stencil buffer is also used). The ones leading up to it are a general refactor that move decisions about whether or not a blit needs to happen as part of present to the common code which allocates the images.
Annoyingly, there's an order of operations problem here. Before we can allocate command buffers and set them up for blitting (which happens as part of image creation), we need command pools and those get allocated as part of the swapchain. So we really need to know whether or not we're going to blit when the swapchain is first initialized. The solution used here is to have two functions: One which decides if a blit is needed and the other which does the actual image allocation. Both are called from wsi_swapchain_init()
so we can control the order of operations and ensure everything gets set up the way we want. In future, we could potentially move towards a lazy scheme now that we know it's all confined to the wsi_swapchain_init()
function but it's not clear to me that doing so would actually be better.
Lest you think all this churn is just for NVK, there are other folks at Collabora who are going to be looking into enabling PRIME properly for Wayland and fixing Vulkan PRIME to allocate from the display device. This should help with that as it makes Wayland and X11 almost entirely unaware that PRIME is even happening.