[Mesa-dev] [PATCH mesa] vulkan/wsi: get the ICD's max dimensions instead of hard-coding them
Eric Engestrom
eric.engestrom at intel.com
Sun Nov 25 16:44:32 UTC 2018
anv and radv both happened to already return 2^14 for these, but
querying the ICD is better and will help if vdreno (or whatever it's
called) doesn't have the same max.
Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
---
src/vulkan/wsi/wsi_common.c | 7 ++++---
src/vulkan/wsi/wsi_common.h | 1 +
src/vulkan/wsi/wsi_common_display.c | 15 +++++++++++++--
src/vulkan/wsi/wsi_common_private.h | 1 +
src/vulkan/wsi/wsi_common_wayland.c | 17 ++++++++++++++---
src/vulkan/wsi/wsi_common_x11.c | 15 ++++++++++++---
6 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 1cd5f8d62c5e6cc07ec0..29c17a15ebf5e62ce76a 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -86,6 +86,7 @@ wsi_device_init(struct wsi_device *wsi,
WSI_GET_CB(GetMemoryFdKHR);
WSI_GET_CB(GetPhysicalDeviceFormatProperties);
WSI_GET_CB(GetPhysicalDeviceFormatProperties2KHR);
+ WSI_GET_CB(GetPhysicalDeviceProperties2);
WSI_GET_CB(ResetFences);
WSI_GET_CB(QueueSubmit);
WSI_GET_CB(WaitForFences);
@@ -734,7 +735,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 +751,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 +778,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 f6ca013c2a88246e89c1..9035764403865c2f7a9e 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -126,6 +126,7 @@ struct wsi_device {
WSI_CB(GetMemoryFdKHR);
WSI_CB(GetPhysicalDeviceFormatProperties);
WSI_CB(GetPhysicalDeviceFormatProperties2KHR);
+ WSI_CB(GetPhysicalDeviceProperties2);
WSI_CB(ResetFences);
WSI_CB(QueueSubmit);
WSI_CB(WaitForFences);
diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c
index edfb166fa69b22449ff6..cfafaec39f513d96ddbb 100644
--- a/src/vulkan/wsi/wsi_common_display.c
+++ b/src/vulkan/wsi/wsi_common_display.c
@@ -811,16 +811,25 @@ 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;
wsi_display_mode *mode = wsi_display_mode_from_handle(surface->displayMode);
+ VkPhysicalDeviceProperties2 props = {
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2
+ };
+ wsi_device->GetPhysicalDeviceProperties2(wsi_device->pdevice, &props);
+
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) {
+ props.properties.limits.maxViewportDimensions[0],
+ props.properties.limits.maxViewportDimensions[1],
+ };
caps->supportedCompositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
@@ -851,6 +860,7 @@ 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)
{
@@ -858,6 +868,7 @@ wsi_display_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,
VkResult result;
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 50a78acacb0c26a03d9e..a6f49fc31246f83c7d99 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 c0132566eadc11ee5933..1abb211fa70e6cff29bb 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -480,8 +480,14 @@ static const VkPresentModeKHR present_modes[] = {
static VkResult
wsi_wl_surface_get_capabilities(VkIcdSurfaceBase *surface,
+ struct wsi_device *wsi_device,
VkSurfaceCapabilitiesKHR* caps)
{
+ VkPhysicalDeviceProperties2 props = {
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2
+ };
+ wsi_device->GetPhysicalDeviceProperties2(wsi_device->pdevice, &props);
+
/* For true mailbox mode, we need at least 4 images:
* 1) One to scan out from
* 2) One to have queued for scan-out
@@ -494,8 +500,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) {
+ props.properties.limits.maxViewportDimensions[0],
+ props.properties.limits.maxViewportDimensions[1],
+ };
+
caps->supportedTransforms = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
caps->currentTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
caps->maxImageArrayLayers = 1;
@@ -516,12 +525,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 6146c8f3da85d3e85f69..3409b65b8fb2a7be4dea 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);
@@ -482,10 +483,17 @@ x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface,
* 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.
*/
+ VkPhysicalDeviceProperties2 props = {
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2
+ };
+ wsi_device->GetPhysicalDeviceProperties2(wsi_device->pdevice, &props);
+
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) {
+ props.properties.limits.maxViewportDimensions[0],
+ props.properties.limits.maxViewportDimensions[1],
+ };
}
free(err);
free(geom);
@@ -523,12 +531,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
--
Cheers,
Eric
More information about the mesa-dev
mailing list