From e8e544436cbe1fc6139334a2314896b42f88882e Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Sun, 25 Nov 2018 11:23:26 +0000 Subject: [PATCH] wsi: query the ICD's max dimensions instead of hard-coding them anv and radv both happened to already return 2^14 for these, but querying the ICD is safer and will help if vdreno (or whatever it's called) doesn't have the same max. Signed-off-by: Eric Engestrom Reviewed-by: Jason Ekstrand --- src/vulkan/wsi/wsi_common.c | 8 +++++--- src/vulkan/wsi/wsi_common.h | 2 ++ src/vulkan/wsi/wsi_common_display.c | 11 ++++++++--- src/vulkan/wsi/wsi_common_private.h | 1 + src/vulkan/wsi/wsi_common_wayland.c | 12 +++++++++--- src/vulkan/wsi/wsi_common_x11.c | 10 +++++++--- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 6e0bc7be6c0..e5dc1bb4c74 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -58,6 +58,8 @@ wsi_device_init(struct wsi_device *wsi, }; GetPhysicalDeviceProperties2(pdevice, &pdp2); + wsi->maxImageDimension2D = pdp2.properties.limits.maxImageDimension2D; + GetPhysicalDeviceMemoryProperties(pdevice, &wsi->memory_props); GetPhysicalDeviceQueueFamilyProperties(pdevice, &wsi->queue_family_count, NULL); @@ -734,7 +736,7 @@ wsi_common_get_surface_capabilities(struct wsi_device *wsi_device, .sType = VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR, }; - VkResult result = iface->get_capabilities2(surface, NULL, &caps2); + VkResult result = iface->get_capabilities2(surface, wsi_device, NULL, &caps2); if (result == VK_SUCCESS) *pSurfaceCapabilities = caps2.surfaceCapabilities; @@ -750,7 +752,7 @@ wsi_common_get_surface_capabilities2(struct wsi_device *wsi_device, ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, pSurfaceInfo->surface); struct wsi_interface *iface = wsi_device->wsi[surface->platform]; - return iface->get_capabilities2(surface, pSurfaceInfo->pNext, + return iface->get_capabilities2(surface, wsi_device, pSurfaceInfo->pNext, pSurfaceCapabilities); } @@ -777,7 +779,7 @@ wsi_common_get_surface_capabilities2ext( .pNext = &counters, }; - VkResult result = iface->get_capabilities2(surface, NULL, &caps2); + VkResult result = iface->get_capabilities2(surface, wsi_device, NULL, &caps2); if (result == VK_SUCCESS) { VkSurfaceCapabilities2EXT *ext_caps = pSurfaceCapabilities; diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index f6ca013c2a8..8851855fa28 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -100,6 +100,8 @@ struct wsi_device { VkPhysicalDevicePCIBusInfoPropertiesEXT pci_bus_info; bool supports_modifiers; + uint32_t maxImageDimension2D; + uint64_t (*image_get_modifier)(VkImage image); #define WSI_CB(cb) PFN_vk##cb cb diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c index f99360e8416..08e9e5fe3fc 100644 --- a/src/vulkan/wsi/wsi_common_display.c +++ b/src/vulkan/wsi/wsi_common_display.c @@ -811,6 +811,7 @@ wsi_display_surface_get_support(VkIcdSurfaceBase *surface, static VkResult wsi_display_surface_get_capabilities(VkIcdSurfaceBase *surface_base, + struct wsi_device *wsi_device, VkSurfaceCapabilitiesKHR* caps) { VkIcdSurfaceDisplay *surface = (VkIcdSurfaceDisplay *) surface_base; @@ -819,8 +820,11 @@ wsi_display_surface_get_capabilities(VkIcdSurfaceBase *surface_base, caps->currentExtent.width = mode->hdisplay; caps->currentExtent.height = mode->vdisplay; - /* XXX Figure out extents based on driver capabilities */ - caps->maxImageExtent = caps->minImageExtent = caps->currentExtent; + caps->minImageExtent = (VkExtent2D) { 1, 1 }; + caps->maxImageExtent = (VkExtent2D) { + wsi_device->maxImageDimension2D, + wsi_device->maxImageDimension2D, + }; caps->supportedCompositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; @@ -851,13 +855,14 @@ wsi_display_surface_get_surface_counters( static VkResult wsi_display_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface, + struct wsi_device *wsi_device, const void *info_next, VkSurfaceCapabilities2KHR *caps) { assert(caps->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR); VkResult result; - result = wsi_display_surface_get_capabilities(icd_surface, + result = wsi_display_surface_get_capabilities(icd_surface, wsi_device, &caps->surfaceCapabilities); if (result != VK_SUCCESS) return result; diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h index 50a78acacb0..a6f49fc3124 100644 --- a/src/vulkan/wsi/wsi_common_private.h +++ b/src/vulkan/wsi/wsi_common_private.h @@ -106,6 +106,7 @@ struct wsi_interface { uint32_t queueFamilyIndex, VkBool32* pSupported); VkResult (*get_capabilities2)(VkIcdSurfaceBase *surface, + struct wsi_device *wsi_device, const void *info_next, VkSurfaceCapabilities2KHR* pSurfaceCapabilities); VkResult (*get_formats)(VkIcdSurfaceBase *surface, diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index c0132566ead..1bdae7307ac 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -480,6 +480,7 @@ static const VkPresentModeKHR present_modes[] = { static VkResult wsi_wl_surface_get_capabilities(VkIcdSurfaceBase *surface, + struct wsi_device *wsi_device, VkSurfaceCapabilitiesKHR* caps) { /* For true mailbox mode, we need at least 4 images: @@ -494,8 +495,11 @@ wsi_wl_surface_get_capabilities(VkIcdSurfaceBase *surface, caps->currentExtent = (VkExtent2D) { -1, -1 }; caps->minImageExtent = (VkExtent2D) { 1, 1 }; - /* This is the maximum supported size on Intel */ - caps->maxImageExtent = (VkExtent2D) { 1 << 14, 1 << 14 }; + caps->maxImageExtent = (VkExtent2D) { + wsi_device->maxImageDimension2D, + wsi_device->maxImageDimension2D, + }; + caps->supportedTransforms = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; caps->currentTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; caps->maxImageArrayLayers = 1; @@ -516,12 +520,14 @@ wsi_wl_surface_get_capabilities(VkIcdSurfaceBase *surface, static VkResult wsi_wl_surface_get_capabilities2(VkIcdSurfaceBase *surface, + struct wsi_device *wsi_device, const void *info_next, VkSurfaceCapabilities2KHR* caps) { assert(caps->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR); - return wsi_wl_surface_get_capabilities(surface, &caps->surfaceCapabilities); + return wsi_wl_surface_get_capabilities(surface, wsi_device, + &caps->surfaceCapabilities); } static VkResult diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 6146c8f3da8..3604fe46786 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -451,6 +451,7 @@ x11_surface_get_support(VkIcdSurfaceBase *icd_surface, static VkResult x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface, + struct wsi_device *wsi_device, VkSurfaceCapabilitiesKHR *caps) { xcb_connection_t *conn = x11_surface_get_connection(icd_surface); @@ -484,8 +485,10 @@ x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface, */ caps->currentExtent = (VkExtent2D) { -1, -1 }; caps->minImageExtent = (VkExtent2D) { 1, 1 }; - /* This is the maximum supported size on Intel */ - caps->maxImageExtent = (VkExtent2D) { 1 << 14, 1 << 14 }; + caps->maxImageExtent = (VkExtent2D) { + wsi_device->maxImageDimension2D, + wsi_device->maxImageDimension2D, + }; } free(err); free(geom); @@ -523,12 +526,13 @@ x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface, static VkResult x11_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface, + struct wsi_device *wsi_device, const void *info_next, VkSurfaceCapabilities2KHR *caps) { assert(caps->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR); - return x11_surface_get_capabilities(icd_surface, &caps->surfaceCapabilities); + return x11_surface_get_capabilities(icd_surface, wsi_device, &caps->surfaceCapabilities); } static VkResult -- 2.30.2