summaryrefslogtreecommitdiffstats
path: root/src/vulkan
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2016-11-04 15:42:48 -0700
committerEmil Velikov <emil.l.velikov@gmail.com>2016-11-23 18:49:50 +0000
commitcf8b11fc6ce5618117bb48aca108ea448438a926 (patch)
treeb40515a4896b113e9859691d0de1bc3c6477c3fe /src/vulkan
parent6520a64c4dadf03e2991a997c2399e3cc181b5c2 (diff)
downloadexternal_mesa3d-cf8b11fc6ce5618117bb48aca108ea448438a926.zip
external_mesa3d-cf8b11fc6ce5618117bb48aca108ea448438a926.tar.gz
external_mesa3d-cf8b11fc6ce5618117bb48aca108ea448438a926.tar.bz2
vulkan/wsi: Report the correct min/maxImageCount
From the Vulkan spec 1.0.32 section 29.6 docs for vkAcquireNextImageKHR: "Let n be the total number of images in the swapchain, m be the value of VkSurfaceCapabilitiesKHR::minImageCount, and a be the number of presentable images that the application has currently acquired (i.e. images acquired with vkAcquireNextImageKHR, but not yet presented with vkQueuePresentKHR). vkAcquireNextImageKHR can always succeed if a ≤ n - m at the time vkAcquireNextImageKHR is called. vkAcquireNextImageKHR should not be called if a > n - m with a timeout of UINT64_MAX; in such a case, vkAcquireNextImageKHR may block indefinitely." With minImageCount == 2 (as it was previously, the client is allowed to acquire all but one image withoutblocking. If we really need 4 images for mailbox mode + pageflipping, then we need to request a minimum of 4 images up-front. This is a bit unfortunate because it means we will always consume 4 images. In the future, we may be able to optimize this a bit by waiting until the server starts to flip and returning OUT_OF_DATE to get the client to re-allocate with more images or something like that. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Cc: "13.0" <mesa-stable@lists.freedesktop.org> (cherry picked from commit 4fa0ca80eeeac813affcbb0129ed61f1534d8df0)
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/wsi/wsi_common_wayland.c25
-rw-r--r--src/vulkan/wsi/wsi_common_x11.c21
2 files changed, 20 insertions, 26 deletions
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index a61b74d..d28c430 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -42,8 +42,6 @@
memcpy((dest), (src), (count) * sizeof(*(src))); \
})
-#define MIN_NUM_IMAGES 2
-
struct wsi_wayland;
struct wsi_wl_display {
@@ -369,8 +367,16 @@ static VkResult
wsi_wl_surface_get_capabilities(VkIcdSurfaceBase *surface,
VkSurfaceCapabilitiesKHR* caps)
{
- caps->minImageCount = MIN_NUM_IMAGES;
- caps->maxImageCount = 4;
+ /* For true mailbox mode, we need at least 4 images:
+ * 1) One to scan out from
+ * 2) One to have queued for scan-out
+ * 3) One to be currently held by the Wayland compositor
+ * 4) One to render to
+ */
+ caps->minImageCount = 4;
+ /* There is no real maximum */
+ caps->maxImageCount = 0;
+
caps->currentExtent = (VkExtent2D) { -1, -1 };
caps->minImageExtent = (VkExtent2D) { 1, 1 };
caps->maxImageExtent = (VkExtent2D) { INT16_MAX, INT16_MAX };
@@ -690,17 +696,6 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
int num_images = pCreateInfo->minImageCount;
- assert(num_images >= MIN_NUM_IMAGES);
-
- /* For true mailbox mode, we need at least 4 images:
- * 1) One to scan out from
- * 2) One to have queued for scan-out
- * 3) One to be currently held by the Wayland compositor
- * 4) One to render to
- */
- if (pCreateInfo->presentMode == VK_PRESENT_MODE_MAILBOX_KHR)
- num_images = MAX2(num_images, 4);
-
size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]);
chain = vk_alloc(pAllocator, size, 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 2280651..de71b19 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -371,8 +371,16 @@ x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface,
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
}
+ /* For true mailbox mode, we need at least 4 images:
+ * 1) One to scan out from
+ * 2) One to have queued for scan-out
+ * 3) One to be currently held by the X server
+ * 4) One to render to
+ */
caps->minImageCount = 2;
- caps->maxImageCount = 4;
+ /* There is no real maximum */
+ caps->maxImageCount = 0;
+
caps->supportedTransforms = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
caps->currentTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
caps->maxImageArrayLayers = 1;
@@ -737,16 +745,7 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR);
- int num_images = pCreateInfo->minImageCount;
-
- /* For true mailbox mode, we need at least 4 images:
- * 1) One to scan out from
- * 2) One to have queued for scan-out
- * 3) One to be currently held by the Wayland compositor
- * 4) One to render to
- */
- if (pCreateInfo->presentMode == VK_PRESENT_MODE_MAILBOX_KHR)
- num_images = MAX2(num_images, 4);
+ const unsigned num_images = pCreateInfo->minImageCount;
size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]);
chain = vk_alloc(pAllocator, size, 8,