Mesa (main): vulkan/wsi/sw: add mit-shm support for pixmap allocation
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Aug 29 20:46:05 UTC 2021
Module: Mesa
Branch: main
Commit: a069b4e9b9a138b4d1e7a76ab76c2db29526bebf
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a069b4e9b9a138b4d1e7a76ab76c2db29526bebf
Author: Dave Airlie <airlied at redhat.com>
Date: Mon Aug 23 10:10:37 2021 +1000
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 at vmware.com>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12482>
---
src/vulkan/wsi/wsi_common_x11.c | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 8b5592bf297..bb6adeb0534 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -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;
More information about the mesa-commit
mailing list