vulkan/wsi/x11: Split image creation
Store the wsi_image_create_info in the swapchain and call wsi_configure_*_image once per swapchain and then use wsi_create_image for each image. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12031>
This commit is contained in:
parent
579578f10a
commit
d67250d444
|
@ -86,6 +86,8 @@ struct wsi_swapchain {
|
|||
VkFence* fences;
|
||||
VkSemaphore* prime_blit_semaphores;
|
||||
VkPresentModeKHR present_mode;
|
||||
|
||||
struct wsi_image_info image_info;
|
||||
uint32_t image_count;
|
||||
|
||||
bool use_prime_blit;
|
||||
|
|
|
@ -1512,25 +1512,16 @@ static VkResult
|
|||
x11_image_init(VkDevice device_h, struct x11_swapchain *chain,
|
||||
const VkSwapchainCreateInfoKHR *pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
const uint64_t *const *modifiers,
|
||||
const uint32_t *num_modifiers,
|
||||
int num_tranches, struct x11_image *image)
|
||||
struct x11_image *image)
|
||||
{
|
||||
xcb_void_cookie_t cookie;
|
||||
VkResult result;
|
||||
uint32_t bpp = 32;
|
||||
int fence_fd;
|
||||
|
||||
if (chain->base.use_prime_blit) {
|
||||
bool use_modifier = num_tranches > 0;
|
||||
result = wsi_create_prime_image(&chain->base, pCreateInfo, use_modifier, &image->base);
|
||||
} else {
|
||||
result = wsi_create_native_image(&chain->base, pCreateInfo,
|
||||
num_tranches, num_modifiers, modifiers,
|
||||
chain->has_mit_shm ? &alloc_shm : NULL,
|
||||
&image->base);
|
||||
}
|
||||
if (result < 0)
|
||||
result = wsi_create_image(&chain->base, &chain->base.image_info,
|
||||
&image->base);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
if (chain->base.wsi->sw) {
|
||||
|
@ -1758,6 +1749,7 @@ x11_swapchain_destroy(struct wsi_swapchain *anv_chain,
|
|||
|
||||
for (uint32_t i = 0; i < chain->base.image_count; i++)
|
||||
x11_image_finish(chain, pAllocator, &chain->images[i]);
|
||||
wsi_destroy_image_info(&chain->base, &chain->base.image_info);
|
||||
|
||||
xcb_unregister_for_special_event(chain->conn, chain->special_event);
|
||||
cookie = xcb_present_select_input_checked(chain->conn, chain->event_id,
|
||||
|
@ -1965,11 +1957,24 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
|
|||
modifiers, num_modifiers, &num_tranches,
|
||||
pAllocator);
|
||||
|
||||
if (chain->base.use_prime_blit) {
|
||||
bool use_modifier = num_tranches > 0;
|
||||
result = wsi_configure_prime_image(&chain->base, pCreateInfo,
|
||||
use_modifier,
|
||||
&chain->base.image_info);
|
||||
} else {
|
||||
result = wsi_configure_native_image(&chain->base, pCreateInfo,
|
||||
num_tranches, num_modifiers,
|
||||
(const uint64_t *const *)modifiers,
|
||||
chain->has_mit_shm ? &alloc_shm : NULL,
|
||||
&chain->base.image_info);
|
||||
}
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail_modifiers;
|
||||
|
||||
uint32_t image = 0;
|
||||
for (; image < chain->base.image_count; image++) {
|
||||
result = x11_image_init(device, chain, pCreateInfo, pAllocator,
|
||||
(const uint64_t *const *)modifiers,
|
||||
num_modifiers, num_tranches,
|
||||
&chain->images[image]);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail_init_images;
|
||||
|
@ -2047,6 +2052,9 @@ fail_init_images:
|
|||
for (uint32_t j = 0; j < image; j++)
|
||||
x11_image_finish(chain, pAllocator, &chain->images[j]);
|
||||
|
||||
wsi_destroy_image_info(&chain->base, &chain->base.image_info);
|
||||
|
||||
fail_modifiers:
|
||||
for (int i = 0; i < ARRAY_SIZE(modifiers); i++)
|
||||
vk_free(pAllocator, modifiers[i]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue