vulkan/wsi/sw: add mit-shm support for pixmap allocation

This allocate the mit-shm pixmap instead of dri3 pixmaps and
uses the present paths when mit-shm is enabled

Acked-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12482>
This commit is contained in:
Dave Airlie 2021-08-23 10:10:37 +10:00 committed by Marge Bot
parent 1f55f9a97a
commit a069b4e9b9
1 changed files with 26 additions and 5 deletions

View File

@ -1214,7 +1214,7 @@ static VkResult
x11_present_to_x11(struct x11_swapchain *chain, uint32_t image_index,
uint64_t target_msc)
{
if (chain->base.wsi->sw)
if (chain->base.wsi->sw && !chain->has_mit_shm)
return x11_present_to_x11_sw(chain, image_index, target_msc);
return x11_present_to_x11_dri3(chain, image_index, target_msc);
}
@ -1231,7 +1231,7 @@ x11_acquire_next_image(struct wsi_swapchain *anv_chain,
if (chain->status < 0)
return chain->status;
if (chain->base.wsi->sw) {
if (chain->base.wsi->sw && !chain->has_mit_shm) {
*image_index = 0;
return VK_SUCCESS;
}
@ -1375,6 +1375,7 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain,
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;
@ -1389,8 +1390,27 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain,
return result;
if (chain->base.wsi->sw) {
image->busy = false;
return VK_SUCCESS;
if (!chain->has_mit_shm) {
image->busy = false;
return VK_SUCCESS;
}
image->shmseg = xcb_generate_id(chain->conn);
xcb_shm_attach(chain->conn,
image->shmseg,
image->shmid,
0);
image->pixmap = xcb_generate_id(chain->conn);
cookie = xcb_shm_create_pixmap_checked(chain->conn,
image->pixmap,
chain->window,
image->base.row_pitches[0] / 4,
pCreateInfo->imageExtent.height,
chain->depth,
image->shmseg, 0);
xcb_discard_reply(chain->conn, cookie.sequence);
goto out_fence;
}
image->pixmap = xcb_generate_id(chain->conn);
@ -1441,7 +1461,8 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain,
for (int i = 0; i < image->base.num_planes; i++)
image->base.fds[i] = -1;
int fence_fd = xshmfence_alloc_shm();
out_fence:
fence_fd = xshmfence_alloc_shm();
if (fence_fd < 0)
goto fail_pixmap;