[Mesa-dev] [RFC v4 23/23] vulkan/wsi: Return VK_SUBOPTIMAL_KHR for X11
Louis-Francis Ratté-Boulianne
lfrb at collabora.com
Mon Oct 16 07:04:33 UTC 2017
When it is detected that a window could have been flipped
but has been copied because of suboptimal format/modifier.
The Vulkan client should then re-create the swapchain.
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
---
src/vulkan/wsi/wsi_common_x11.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 39172ef019..30380ab71f 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -173,7 +173,7 @@ wsi_x11_connection_create(const VkAllocationCallbacks *alloc,
ver_cookie = xcb_dri3_query_version(conn, 1, 1);
ver_reply = xcb_dri3_query_version_reply(conn, ver_cookie, NULL);
- wsi_conn->has_dri3_v1_1 =
+ wsi_conn->has_dri3_modifiers =
(ver_reply->major_version > 1 || ver_reply->minor_version >= 1);
free(ver_reply);
}
@@ -656,6 +656,7 @@ struct x11_swapchain {
bool threaded;
VkResult status;
+ bool suboptimal;
struct wsi_queue present_queue;
struct wsi_queue acquire_queue;
pthread_t queue_manager;
@@ -732,6 +733,10 @@ x11_handle_dri3_present_event(struct x11_swapchain *chain,
xcb_present_complete_notify_event_t *complete = (void *) event;
if (complete->kind == XCB_PRESENT_COMPLETE_KIND_PIXMAP)
chain->last_present_msc = complete->msc;
+#if XCB_PRESENT_MAJOR_VERSION > 1 || XCB_PRESENT_MINOR_VERSION >= 1
+ if (complete->mode == XCB_PRESENT_COMPLETE_MODE_SUBOPTIMAL_COPY)
+ chain->suboptimal = true;
+#endif
break;
}
@@ -895,11 +900,18 @@ x11_acquire_next_image(struct wsi_swapchain *anv_chain,
uint32_t *image_index)
{
struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
+ VkResult result;
if (chain->threaded) {
- return x11_acquire_next_image_from_queue(chain, image_index, timeout);
+ result = x11_acquire_next_image_from_queue(chain, image_index, timeout);
+ } else {
+ result = x11_acquire_next_image_poll_x11(chain, image_index, timeout);
+ }
+
+ if (result != VK_SUCCESS) {
+ return result;
} else {
- return x11_acquire_next_image_poll_x11(chain, image_index, timeout);
+ return chain->suboptimal ? VK_SUBOPTIMAL_KHR : VK_SUCCESS;
}
}
@@ -909,12 +921,19 @@ x11_queue_present(struct wsi_swapchain *anv_chain,
const VkPresentRegionKHR *damage)
{
struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
+ VkResult result;
if (chain->threaded) {
wsi_queue_push(&chain->present_queue, image_index);
- return chain->status;
+ result = chain->status;
+ } else {
+ result = x11_present_to_x11(chain, image_index, 0);
+ }
+
+ if (result != VK_SUCCESS) {
+ return result;
} else {
- return x11_present_to_x11(chain, image_index, 0);
+ return chain->suboptimal ? VK_SUBOPTIMAL_KHR : VK_SUCCESS;
}
}
@@ -1247,6 +1266,7 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
chain->last_present_msc = 0;
chain->threaded = false;
chain->status = VK_SUCCESS;
+ chain->suboptimal = false;
free(geometry);
--
2.13.0
More information about the mesa-dev
mailing list