Mesa (main): wsi/x11: Fix a misunderstanding about how xcb_get_geometry works
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Oct 4 15:52:38 UTC 2021
Module: Mesa
Branch: main
Commit: aa30e5860032658963896e7fb9d4075ef9f09779
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa30e5860032658963896e7fb9d4075ef9f09779
Author: Adam Jackson <ajax at redhat.com>
Date: Wed Sep 29 11:44:42 2021 -0400
wsi/x11: Fix a misunderstanding about how xcb_get_geometry works
The code here is well-intentioned, but the only way a GetGeometry
request can fail is if you name an invalid drawable. And if we did that,
either our internal state got corrupted, or - more likely - the user
destroyed the window. In either case there's nothing more we can do with
the surface, so report that it's been lost.
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13104>
---
src/vulkan/wsi/wsi_common_x11.c | 27 +++++++--------------------
1 file changed, 7 insertions(+), 20 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index e05ed58acc2..278d9ace085 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -605,20 +605,11 @@ x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface,
caps->currentExtent = extent;
caps->minImageExtent = extent;
caps->maxImageExtent = extent;
- } else {
- /* This can happen if the client didn't wait for the configure event
- * to come back from the compositor. In that case, we don't know the
- * size of the window so we just return valid "I don't know" stuff.
- */
- caps->currentExtent = (VkExtent2D) { UINT32_MAX, UINT32_MAX };
- caps->minImageExtent = (VkExtent2D) { 1, 1 };
- caps->maxImageExtent = (VkExtent2D) {
- wsi_device->maxImageDimension2D,
- wsi_device->maxImageDimension2D,
- };
}
free(err);
free(geom);
+ if (!geom)
+ return VK_ERROR_SURFACE_LOST_KHR;
if (visual_has_alpha(visual, visual_depth)) {
caps->supportedCompositeAlpha = VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR |
@@ -657,6 +648,9 @@ x11_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,
x11_surface_get_capabilities(icd_surface, wsi_device,
&caps->surfaceCapabilities);
+ if (result != VK_SUCCESS)
+ return result;
+
vk_foreach_struct(ext, caps->pNext) {
switch (ext->sType) {
case VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR: {
@@ -772,17 +766,10 @@ x11_surface_get_present_rectangles(VkIcdSurfaceBase *icd_surface,
.offset = { 0, 0 },
.extent = { geom->width, geom->height },
};
- } else {
- /* This can happen if the client didn't wait for the configure event
- * to come back from the compositor. In that case, we don't know the
- * size of the window so we just return valid "I don't know" stuff.
- */
- *rect = (VkRect2D) {
- .offset = { 0, 0 },
- .extent = { UINT32_MAX, UINT32_MAX },
- };
}
free(geom);
+ if (!geom)
+ return VK_ERROR_SURFACE_LOST_KHR;
}
return vk_outarray_status(&out);
More information about the mesa-commit
mailing list