[Mesa-dev] [PATCH] anv, radv: Add support for VK_KHR_get_display_properties2
Jason Ekstrand
jason at jlekstrand.net
Sat Jun 16 00:12:56 UTC 2018
Cc: Keith Packard <keithp at keithp.com>
---
src/amd/vulkan/radv_extensions.py | 1 +
src/amd/vulkan/radv_wsi_display.c | 57 +++++++++
src/intel/vulkan/anv_extensions.py | 1 +
src/intel/vulkan/anv_wsi_display.c | 56 ++++++++
src/vulkan/wsi/wsi_common_display.c | 192 ++++++++++++++++++++++++----
src/vulkan/wsi/wsi_common_display.h | 27 ++++
6 files changed, 311 insertions(+), 23 deletions(-)
diff --git a/src/amd/vulkan/radv_extensions.py b/src/amd/vulkan/radv_extensions.py
index 65ce7349016..5eb63a7d5dc 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -66,6 +66,7 @@ EXTENSIONS = [
Extension('VK_KHR_external_semaphore', 1, 'device->rad_info.has_syncobj'),
Extension('VK_KHR_external_semaphore_capabilities', 1, True),
Extension('VK_KHR_external_semaphore_fd', 1, 'device->rad_info.has_syncobj'),
+ Extension('VK_KHR_get_display_properties2', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
Extension('VK_KHR_get_memory_requirements2', 1, True),
Extension('VK_KHR_get_physical_device_properties2', 1, True),
Extension('VK_KHR_get_surface_capabilities2', 1, 'RADV_HAS_SURFACE'),
diff --git a/src/amd/vulkan/radv_wsi_display.c b/src/amd/vulkan/radv_wsi_display.c
index 0f88ce13942..c9915f0100f 100644
--- a/src/amd/vulkan/radv_wsi_display.c
+++ b/src/amd/vulkan/radv_wsi_display.c
@@ -56,6 +56,20 @@ radv_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physical_device,
properties);
}
+VkResult
+radv_GetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physical_device,
+ uint32_t *property_count,
+ VkDisplayProperties2KHR *properties)
+{
+ RADV_FROM_HANDLE(radv_physical_device, pdevice, physical_device);
+
+ return wsi_display_get_physical_device_display_properties2(
+ physical_device,
+ &pdevice->wsi_device,
+ property_count,
+ properties);
+}
+
VkResult
radv_GetPhysicalDeviceDisplayPlanePropertiesKHR(
VkPhysicalDevice physical_device,
@@ -71,6 +85,21 @@ radv_GetPhysicalDeviceDisplayPlanePropertiesKHR(
properties);
}
+VkResult
+radv_GetPhysicalDeviceDisplayPlaneProperties2KHR(
+ VkPhysicalDevice physical_device,
+ uint32_t *property_count,
+ VkDisplayPlaneProperties2KHR *properties)
+{
+ RADV_FROM_HANDLE(radv_physical_device, pdevice, physical_device);
+
+ return wsi_display_get_physical_device_display_plane_properties2(
+ physical_device,
+ &pdevice->wsi_device,
+ property_count,
+ properties);
+}
+
VkResult
radv_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device,
uint32_t plane_index,
@@ -103,6 +132,21 @@ radv_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device,
properties);
}
+VkResult
+radv_GetDisplayModeProperties2KHR(VkPhysicalDevice physical_device,
+ VkDisplayKHR display,
+ uint32_t *property_count,
+ VkDisplayModeProperties2KHR *properties)
+{
+ RADV_FROM_HANDLE(radv_physical_device, pdevice, physical_device);
+
+ return wsi_display_get_display_mode_properties2(physical_device,
+ &pdevice->wsi_device,
+ display,
+ property_count,
+ properties);
+}
+
VkResult
radv_CreateDisplayModeKHR(VkPhysicalDevice physical_device,
VkDisplayKHR display,
@@ -129,6 +173,19 @@ radv_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device,
capabilities);
}
+VkResult
+radv_GetDisplayPlaneCapabilities2KHR(VkPhysicalDevice physical_device,
+ const VkDisplayPlaneInfo2KHR *pDisplayPlaneInfo,
+ VkDisplayPlaneCapabilities2KHR *capabilities)
+{
+ RADV_FROM_HANDLE(radv_physical_device, pdevice, physical_device);
+
+ return wsi_get_display_plane_capabilities2(physical_device,
+ &pdevice->wsi_device,
+ pDisplayPlaneInfo,
+ capabilities);
+}
+
VkResult
radv_CreateDisplayPlaneSurfaceKHR(
VkInstance _instance,
diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py
index 4bffbcb5a2a..e8131335c0c 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -86,6 +86,7 @@ EXTENSIONS = [
Extension('VK_KHR_external_semaphore', 1, True),
Extension('VK_KHR_external_semaphore_capabilities', 1, True),
Extension('VK_KHR_external_semaphore_fd', 1, True),
+ Extension('VK_KHR_get_display_properties2', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
Extension('VK_KHR_get_memory_requirements2', 1, True),
Extension('VK_KHR_get_physical_device_properties2', 1, True),
Extension('VK_KHR_get_surface_capabilities2', 1, 'ANV_HAS_SURFACE'),
diff --git a/src/intel/vulkan/anv_wsi_display.c b/src/intel/vulkan/anv_wsi_display.c
index f749a8d98f7..26e091021dd 100644
--- a/src/intel/vulkan/anv_wsi_display.c
+++ b/src/intel/vulkan/anv_wsi_display.c
@@ -40,6 +40,19 @@ anv_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physical_device,
properties);
}
+VkResult
+anv_GetPhysicalDeviceDisplayProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t* pPropertyCount,
+ VkDisplayProperties2KHR* pProperties)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+
+ return wsi_display_get_physical_device_display_properties2(
+ physicalDevice, &pdevice->wsi_device,
+ pPropertyCount, pProperties);
+}
+
VkResult
anv_GetPhysicalDeviceDisplayPlanePropertiesKHR(
VkPhysicalDevice physical_device,
@@ -53,6 +66,19 @@ anv_GetPhysicalDeviceDisplayPlanePropertiesKHR(
property_count, properties);
}
+VkResult
+anv_GetPhysicalDeviceDisplayPlaneProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t* pPropertyCount,
+ VkDisplayPlaneProperties2KHR* pProperties)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+
+ return wsi_display_get_physical_device_display_plane_properties2(
+ physicalDevice, &pdevice->wsi_device,
+ pPropertyCount, pProperties);
+}
+
VkResult
anv_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physical_device,
uint32_t plane_index,
@@ -84,6 +110,22 @@ anv_GetDisplayModePropertiesKHR(VkPhysicalDevice physical_device,
properties);
}
+VkResult
+anv_GetDisplayModeProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ VkDisplayKHR display,
+ uint32_t* pPropertyCount,
+ VkDisplayModeProperties2KHR* pProperties)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+
+ return wsi_display_get_display_mode_properties2(physicalDevice,
+ &pdevice->wsi_device,
+ display,
+ pPropertyCount,
+ pProperties);
+}
+
VkResult
anv_CreateDisplayModeKHR(VkPhysicalDevice physical_device,
VkDisplayKHR display,
@@ -110,6 +152,20 @@ anv_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physical_device,
capabilities);
}
+VkResult
+anv_GetDisplayPlaneCapabilities2KHR(
+ VkPhysicalDevice physicalDevice,
+ const VkDisplayPlaneInfo2KHR* pDisplayPlaneInfo,
+ VkDisplayPlaneCapabilities2KHR* pCapabilities)
+{
+ ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice);
+
+ return wsi_get_display_plane_capabilities2(physicalDevice,
+ &pdevice->wsi_device,
+ pDisplayPlaneInfo,
+ pCapabilities);
+}
+
VkResult
anv_CreateDisplayPlaneSurfaceKHR(
VkInstance _instance,
diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c
index d1453368dfd..db546929f91 100644
--- a/src/vulkan/wsi/wsi_common_display.c
+++ b/src/vulkan/wsi/wsi_common_display.c
@@ -341,8 +341,11 @@ mode_size(struct wsi_display_mode *mode)
static void
wsi_display_fill_in_display_properties(struct wsi_device *wsi_device,
struct wsi_display_connector *connector,
- VkDisplayPropertiesKHR *properties)
+ VkDisplayProperties2KHR *properties2)
{
+ assert(properties2->sType == VK_STRUCTURE_TYPE_DISPLAY_PROPERTIES_2_KHR);
+ VkDisplayPropertiesKHR *properties = &properties2->displayProperties;
+
properties->display = wsi_display_connector_to_handle(connector);
properties->displayName = connector->name;
@@ -391,12 +394,13 @@ wsi_display_fill_in_display_properties(struct wsi_device *wsi_device,
/*
* Implement vkGetPhysicalDeviceDisplayPropertiesKHR (VK_KHR_display)
*/
-VkResult
-wsi_display_get_physical_device_display_properties(
+static VkResult
+get_physical_device_display_properties(
VkPhysicalDevice physical_device,
struct wsi_device *wsi_device,
uint32_t *property_count,
- VkDisplayPropertiesKHR *properties)
+ VkDisplayPropertiesKHR *properties,
+ VkDisplayProperties2KHR *properties2)
{
struct wsi_display *wsi =
(struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
@@ -409,7 +413,12 @@ wsi_display_get_physical_device_display_properties(
if (!mode_res)
goto bail;
- VK_OUTARRAY_MAKE(conn, properties, property_count);
+ vk_outarray(VkDisplayPropertiesKHR) props_arr;
+ vk_outarray(VkDisplayProperties2KHR) props2_arr;
+ if (properties)
+ vk_outarray_init(&props_arr, properties, property_count);
+ else
+ vk_outarray_init(&props2_arr, properties2, property_count);
/* Get current information */
@@ -423,26 +432,85 @@ wsi_display_get_physical_device_display_properties(
}
if (connector->connected) {
- vk_outarray_append(&conn, prop) {
+ if (properties) {
+ VkDisplayProperties2KHR props2 = {
+ .sType = VK_STRUCTURE_TYPE_DISPLAY_PROPERTIES_2_KHR,
+ };
wsi_display_fill_in_display_properties(wsi_device,
connector,
- prop);
+ &props2);
+ vk_outarray_append(&props_arr, props) {
+ *props = props2.displayProperties;
+ }
+ } else {
+ vk_outarray_append(&props2_arr, props) {
+ wsi_display_fill_in_display_properties(wsi_device,
+ connector,
+ props);
+ }
}
}
}
drmModeFreeResources(mode_res);
- return vk_outarray_status(&conn);
+ if (properties)
+ return vk_outarray_status(&props_arr);
+ else
+ return vk_outarray_status(&props2_arr);
bail:
*property_count = 0;
return VK_SUCCESS;
}
+VkResult
+wsi_display_get_physical_device_display_properties(
+ VkPhysicalDevice physical_device,
+ struct wsi_device *wsi_device,
+ uint32_t *property_count,
+ VkDisplayPropertiesKHR *properties)
+{
+ return get_physical_device_display_properties(physical_device, wsi_device,
+ property_count,
+ properties,
+ NULL);
+}
+
+VkResult
+wsi_display_get_physical_device_display_properties2(
+ VkPhysicalDevice physical_device,
+ struct wsi_device *wsi_device,
+ uint32_t *property_count,
+ VkDisplayProperties2KHR *properties)
+{
+ return get_physical_device_display_properties(physical_device, wsi_device,
+ property_count,
+ NULL,
+ properties);
+}
+
/*
* Implement vkGetPhysicalDeviceDisplayPlanePropertiesKHR (VK_KHR_display
*/
+static void
+wsi_display_fill_in_display_plane_properties(
+ struct wsi_device *wsi_device,
+ struct wsi_display_connector *connector,
+ VkDisplayPlaneProperties2KHR *properties)
+{
+ assert(properties->sType == VK_STRUCTURE_TYPE_DISPLAY_PLANE_PROPERTIES_2_KHR);
+ VkDisplayPlanePropertiesKHR *prop = &properties->displayPlaneProperties;
+
+ if (connector && connector->active) {
+ prop->currentDisplay = wsi_display_connector_to_handle(connector);
+ prop->currentStackIndex = 0;
+ } else {
+ prop->currentDisplay = VK_NULL_HANDLE;
+ prop->currentStackIndex = 0;
+ }
+}
+
VkResult
wsi_display_get_physical_device_display_plane_properties(
VkPhysicalDevice physical_device,
@@ -457,13 +525,33 @@ wsi_display_get_physical_device_display_plane_properties(
wsi_for_each_connector(connector, wsi) {
vk_outarray_append(&conn, prop) {
- if (connector && connector->active) {
- prop->currentDisplay = wsi_display_connector_to_handle(connector);
- prop->currentStackIndex = 0;
- } else {
- prop->currentDisplay = VK_NULL_HANDLE;
- prop->currentStackIndex = 0;
- }
+ VkDisplayPlaneProperties2KHR prop2 = {
+ .sType = VK_STRUCTURE_TYPE_DISPLAY_PLANE_PROPERTIES_2_KHR,
+ };
+ wsi_display_fill_in_display_plane_properties(wsi_device, connector,
+ &prop2);
+ *prop = prop2.displayPlaneProperties;
+ }
+ }
+ return vk_outarray_status(&conn);
+}
+
+VkResult
+wsi_display_get_physical_device_display_plane_properties2(
+ VkPhysicalDevice physical_device,
+ struct wsi_device *wsi_device,
+ uint32_t *property_count,
+ VkDisplayPlaneProperties2KHR *properties)
+{
+ struct wsi_display *wsi =
+ (struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
+
+ VK_OUTARRAY_MAKE(conn, properties, property_count);
+
+ wsi_for_each_connector(connector, wsi) {
+ vk_outarray_append(&conn, prop) {
+ wsi_display_fill_in_display_plane_properties(wsi_device, connector,
+ prop);
}
}
return vk_outarray_status(&conn);
@@ -503,6 +591,22 @@ wsi_display_get_display_plane_supported_displays(
* Implement vkGetDisplayModePropertiesKHR (VK_KHR_display)
*/
+static void
+wsi_display_fill_in_display_mode_properties(
+ struct wsi_device *wsi_device,
+ struct wsi_display_mode *display_mode,
+ VkDisplayModeProperties2KHR *properties)
+{
+ assert(properties->sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_PROPERTIES_2_KHR);
+ VkDisplayModePropertiesKHR *prop = &properties->displayModeProperties;
+
+ prop->displayMode = wsi_display_mode_to_handle(display_mode);
+ prop->parameters.visibleRegion.width = display_mode->hdisplay;
+ prop->parameters.visibleRegion.height = display_mode->vdisplay;
+ prop->parameters.refreshRate =
+ (uint32_t) (wsi_display_mode_refresh(display_mode) * 1000 + 0.5);
+}
+
VkResult
wsi_display_get_display_mode_properties(VkPhysicalDevice physical_device,
struct wsi_device *wsi_device,
@@ -516,14 +620,40 @@ wsi_display_get_display_mode_properties(VkPhysicalDevice physical_device,
VK_OUTARRAY_MAKE(conn, properties, property_count);
wsi_for_each_display_mode(display_mode, connector) {
- if (display_mode->valid) {
- vk_outarray_append(&conn, prop) {
- prop->displayMode = wsi_display_mode_to_handle(display_mode);
- prop->parameters.visibleRegion.width = display_mode->hdisplay;
- prop->parameters.visibleRegion.height = display_mode->vdisplay;
- prop->parameters.refreshRate =
- (uint32_t) (wsi_display_mode_refresh(display_mode) * 1000 + 0.5);
- }
+ if (!display_mode->valid)
+ continue;
+
+ vk_outarray_append(&conn, prop) {
+ VkDisplayModeProperties2KHR prop2 = {
+ .sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_PROPERTIES_2_KHR,
+ };
+ wsi_display_fill_in_display_mode_properties(wsi_device,
+ display_mode, &prop2);
+ *prop = prop2.displayModeProperties;
+ }
+ }
+ return vk_outarray_status(&conn);
+}
+
+VkResult
+wsi_display_get_display_mode_properties2(VkPhysicalDevice physical_device,
+ struct wsi_device *wsi_device,
+ VkDisplayKHR display,
+ uint32_t *property_count,
+ VkDisplayModeProperties2KHR *properties)
+{
+ struct wsi_display_connector *connector =
+ wsi_display_connector_from_handle(display);
+
+ VK_OUTARRAY_MAKE(conn, properties, property_count);
+
+ wsi_for_each_display_mode(display_mode, connector) {
+ if (!display_mode->valid)
+ continue;
+
+ vk_outarray_append(&conn, prop) {
+ wsi_display_fill_in_display_mode_properties(wsi_device,
+ display_mode, prop);
}
}
return vk_outarray_status(&conn);
@@ -562,6 +692,22 @@ wsi_get_display_plane_capabilities(VkPhysicalDevice physical_device,
return VK_SUCCESS;
}
+VkResult
+wsi_get_display_plane_capabilities2(
+ VkPhysicalDevice physical_device,
+ struct wsi_device *wsi_device,
+ const VkDisplayPlaneInfo2KHR *pDisplayPlaneInfo,
+ VkDisplayPlaneCapabilities2KHR *capabilities)
+{
+ assert(capabilities->sType =
+ VK_STRUCTURE_TYPE_DISPLAY_PLANE_CAPABILITIES_2_KHR);
+
+ return wsi_get_display_plane_capabilities(physical_device, wsi_device,
+ pDisplayPlaneInfo->mode,
+ pDisplayPlaneInfo->planeIndex,
+ &capabilities->capabilities);
+}
+
VkResult
wsi_create_display_surface(VkInstance instance,
const VkAllocationCallbacks *allocator,
diff --git a/src/vulkan/wsi/wsi_common_display.h b/src/vulkan/wsi/wsi_common_display.h
index 58447d2c6eb..bbf76402f6a 100644
--- a/src/vulkan/wsi/wsi_common_display.h
+++ b/src/vulkan/wsi/wsi_common_display.h
@@ -39,6 +39,13 @@ wsi_display_get_physical_device_display_properties(
uint32_t *property_count,
VkDisplayPropertiesKHR *properties);
+VkResult
+wsi_display_get_physical_device_display_properties2(
+ VkPhysicalDevice physical_device,
+ struct wsi_device *wsi_device,
+ uint32_t *pPropertyCount,
+ VkDisplayProperties2KHR *pProperties);
+
VkResult
wsi_display_get_physical_device_display_plane_properties(
VkPhysicalDevice physical_device,
@@ -46,6 +53,13 @@ wsi_display_get_physical_device_display_plane_properties(
uint32_t *property_count,
VkDisplayPlanePropertiesKHR *properties);
+VkResult
+wsi_display_get_physical_device_display_plane_properties2(
+ VkPhysicalDevice physical_device,
+ struct wsi_device *wsi_device,
+ uint32_t *property_count,
+ VkDisplayPlaneProperties2KHR *properties);
+
VkResult
wsi_display_get_display_plane_supported_displays(
VkPhysicalDevice physical_device,
@@ -61,6 +75,13 @@ wsi_display_get_display_mode_properties(VkPhysicalDevice physical_device,
uint32_t *property_count,
VkDisplayModePropertiesKHR *properties);
+VkResult
+wsi_display_get_display_mode_properties2(VkPhysicalDevice physical_device,
+ struct wsi_device *wsi_device,
+ VkDisplayKHR display,
+ uint32_t *property_count,
+ VkDisplayModeProperties2KHR *properties);
+
VkResult
wsi_get_display_plane_capabilities(VkPhysicalDevice physical_device,
struct wsi_device *wsi_device,
@@ -68,6 +89,12 @@ wsi_get_display_plane_capabilities(VkPhysicalDevice physical_device,
uint32_t plane_index,
VkDisplayPlaneCapabilitiesKHR *capabilities);
+VkResult
+wsi_get_display_plane_capabilities2(VkPhysicalDevice physical_device,
+ struct wsi_device *wsi_device,
+ const VkDisplayPlaneInfo2KHR *pDisplayPlaneInfo,
+ VkDisplayPlaneCapabilities2KHR *capabilities);
+
VkResult
wsi_create_display_surface(VkInstance instance,
const VkAllocationCallbacks *pAllocator,
--
2.17.1
More information about the mesa-dev
mailing list