From patchwork Sat Feb 10 04:45:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 10210297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0FF4260247 for ; Sat, 10 Feb 2018 04:56:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04FFB2993E for ; Sat, 10 Feb 2018 04:56:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED54F299D8; Sat, 10 Feb 2018 04:56:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2611A2993E for ; Sat, 10 Feb 2018 04:56:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 14FEF6E085; Sat, 10 Feb 2018 04:55:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by gabe.freedesktop.org (Postfix) with ESMTP id ABDD06E07A; Sat, 10 Feb 2018 04:55:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 591473F210F2; Fri, 9 Feb 2018 20:45:19 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id d0CpK3qntvJo; Fri, 9 Feb 2018 20:45:18 -0800 (PST) Received: from keithp.com (unknown [65.158.186.241]) by elaine.keithp.com (Postfix) with ESMTPSA id 895013F2140C; Fri, 9 Feb 2018 20:45:17 -0800 (PST) Received: by keithp.com (Postfix, from userid 1000) id 267D615829ED; Fri, 9 Feb 2018 20:45:17 -0800 (PST) From: Keith Packard To: mesa-dev@lists.freedesktop.org Subject: [PATCH 4/7] vulkan: Add VK_EXT_display_surface_counter [v4] Date: Fri, 9 Feb 2018 20:45:13 -0800 Message-Id: <20180210044516.16944-5-keithp@keithp.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180210044516.16944-1-keithp@keithp.com> References: <20180210044516.16944-1-keithp@keithp.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Packard , dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This extension is required to support EXT_display_control as it offers a way to query whether the vblank counter is supported. v2: Thanks to kisak Fix spelling of VkSurfaceCapabilities2EXT in wsi_common_wayland.c, it was using ext instead of EXT. Fix spelling of VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT v3: Fix wayland WSI, regularize spelling Misspelled 'surface' in get_capabilities2ext Remove extra _ from get_capabilities_2ext in a couple of places v4: Add anv support Signed-off-by: Keith Packard --- src/amd/vulkan/radv_extensions.py | 1 + src/amd/vulkan/radv_wsi.c | 12 ++++++++++++ src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_wsi.c | 12 ++++++++++++ src/vulkan/wsi/wsi_common.c | 11 +++++++++++ src/vulkan/wsi/wsi_common.h | 5 +++++ src/vulkan/wsi/wsi_common_display.c | 27 +++++++++++++++++++++++++++ src/vulkan/wsi/wsi_common_private.h | 2 ++ src/vulkan/wsi/wsi_common_wayland.c | 27 +++++++++++++++++++++++++++ src/vulkan/wsi/wsi_common_x11.c | 27 +++++++++++++++++++++++++++ 10 files changed, 125 insertions(+) diff --git a/src/amd/vulkan/radv_extensions.py b/src/amd/vulkan/radv_extensions.py index 2d804afed35..3f315e074b5 100644 --- a/src/amd/vulkan/radv_extensions.py +++ b/src/amd/vulkan/radv_extensions.py @@ -84,6 +84,7 @@ EXTENSIONS = [ Extension('VK_KHR_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_EXT_acquire_xlib_display', 1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'), + Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_KHX_multiview', 1, '!ANDROID'), Extension('VK_EXT_debug_report', 9, True), Extension('VK_EXT_discard_rectangles', 1, True), diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c index 5ec872a63d0..2d2a30ebbb1 100644 --- a/src/amd/vulkan/radv_wsi.c +++ b/src/amd/vulkan/radv_wsi.c @@ -103,6 +103,18 @@ VkResult radv_GetPhysicalDeviceSurfaceCapabilities2KHR( pSurfaceCapabilities); } +VkResult radv_GetPhysicalDeviceSurfaceCapabilities2EXT( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + VkSurfaceCapabilities2EXT* pSurfaceCapabilities) +{ + RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice); + + return wsi_common_get_surface_capabilities2ext(&device->wsi_device, + surface, + pSurfaceCapabilities); +} + VkResult radv_GetPhysicalDeviceSurfaceFormatsKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py index 32a240acdcb..8265077d894 100644 --- a/src/intel/vulkan/anv_extensions.py +++ b/src/intel/vulkan/anv_extensions.py @@ -89,6 +89,7 @@ EXTENSIONS = [ Extension('VK_KHX_multiview', 1, True), Extension('VK_EXT_debug_report', 8, True), Extension('VK_EXT_external_memory_dma_buf', 1, True), + Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), ] class VkVersion: diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c index f86d83589ea..52362adfb71 100644 --- a/src/intel/vulkan/anv_wsi.c +++ b/src/intel/vulkan/anv_wsi.c @@ -104,6 +104,18 @@ VkResult anv_GetPhysicalDeviceSurfaceCapabilities2KHR( pSurfaceCapabilities); } +VkResult anv_GetPhysicalDeviceSurfaceCapabilities2EXT( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + VkSurfaceCapabilities2EXT* pSurfaceCapabilities) +{ + ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice); + + return wsi_common_get_surface_capabilities2ext(&device->wsi_device, + surface, + pSurfaceCapabilities); +} + VkResult anv_GetPhysicalDeviceSurfaceFormatsKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index c0a285e5814..02abc9ef7fb 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -579,6 +579,17 @@ wsi_common_get_surface_capabilities2(struct wsi_device *wsi_device, pSurfaceCapabilities); } +VkResult +wsi_common_get_surface_capabilities2ext(struct wsi_device *wsi_device, + VkSurfaceKHR _surface, + VkSurfaceCapabilities2EXT *pSurfaceCapabilities) +{ + ICD_FROM_HANDLE(VkIcdSurfaceBase, surface, _surface); + struct wsi_interface *iface = wsi_device->wsi[surface->platform]; + + return iface->get_capabilities2ext(surface, pSurfaceCapabilities); +} + VkResult wsi_common_get_surface_formats(struct wsi_device *wsi_device, VkSurfaceKHR _surface, diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index 1cb6aaebca0..124d096170a 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -155,6 +155,11 @@ wsi_common_get_surface_present_modes(struct wsi_device *wsi_device, uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes); +VkResult +wsi_common_get_surface_capabilities2ext(struct wsi_device *wsi_device, + VkSurfaceKHR surface, + VkSurfaceCapabilities2EXT *pSurfaceCapabilities); + VkResult wsi_common_get_images(VkSwapchainKHR _swapchain, uint32_t *pSwapchainImageCount, diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c index 29d64b21aff..e63700e2e65 100644 --- a/src/vulkan/wsi/wsi_common_display.c +++ b/src/vulkan/wsi/wsi_common_display.c @@ -655,6 +655,32 @@ wsi_display_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface, return wsi_display_surface_get_capabilities(icd_surface, &caps->surfaceCapabilities); } +static VkResult +wsi_display_surface_get_capabilities2ext(VkIcdSurfaceBase *icd_surface, + VkSurfaceCapabilities2EXT *caps) +{ + VkSurfaceCapabilitiesKHR khr_caps; + VkResult ret; + + assert(caps->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT); + ret = wsi_display_surface_get_capabilities(icd_surface, &khr_caps); + if (ret) + return ret; + + caps->minImageCount = khr_caps.minImageCount; + caps->maxImageCount = khr_caps.maxImageCount; + caps->currentExtent = khr_caps.currentExtent; + caps->minImageExtent = khr_caps.minImageExtent; + caps->maxImageExtent = khr_caps.maxImageExtent; + caps->maxImageArrayLayers = khr_caps.maxImageArrayLayers; + caps->supportedTransforms = khr_caps.supportedTransforms; + caps->currentTransform = khr_caps.currentTransform; + caps->supportedCompositeAlpha = khr_caps.supportedCompositeAlpha; + caps->supportedUsageFlags = khr_caps.supportedUsageFlags; + caps->supportedSurfaceCounters = 0; + return ret; +} + static const VkFormat available_surface_formats[] = { VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_B8G8R8A8_UNORM, @@ -1323,6 +1349,7 @@ wsi_display_init_wsi(struct wsi_device *wsi_device, wsi->base.get_support = wsi_display_surface_get_support; wsi->base.get_capabilities = wsi_display_surface_get_capabilities; wsi->base.get_capabilities2 = wsi_display_surface_get_capabilities2; + wsi->base.get_capabilities2ext = wsi_display_surface_get_capabilities2ext; wsi->base.get_formats = wsi_display_surface_get_formats; wsi->base.get_formats2 = wsi_display_surface_get_formats2; wsi->base.get_present_modes = wsi_display_surface_get_present_modes; diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h index d38d2efa116..0d902846238 100644 --- a/src/vulkan/wsi/wsi_common_private.h +++ b/src/vulkan/wsi/wsi_common_private.h @@ -103,6 +103,8 @@ struct wsi_interface { VkResult (*get_capabilities2)(VkIcdSurfaceBase *surface, const void *info_next, VkSurfaceCapabilities2KHR* pSurfaceCapabilities); + VkResult (*get_capabilities2ext)(VkIcdSurfaceBase *surface, + VkSurfaceCapabilities2EXT* pSurfaceCapabilities); VkResult (*get_formats)(VkIcdSurfaceBase *surface, struct wsi_device *wsi_device, uint32_t* pSurfaceFormatCount, diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index be7635bbf84..54b9449ab8c 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -457,6 +457,32 @@ wsi_wl_surface_get_capabilities2(VkIcdSurfaceBase *surface, return wsi_wl_surface_get_capabilities(surface, &caps->surfaceCapabilities); } +static VkResult +wsi_wl_surface_get_capabilities2ext(VkIcdSurfaceBase *surface, + VkSurfaceCapabilities2EXT* caps) +{ + VkSurfaceCapabilitiesKHR khr_caps; + VkResult ret; + + assert(caps->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT); + ret = wsi_wl_surface_get_capabilities(surface, &khr_caps); + if (ret) + return ret; + + caps->minImageCount = khr_caps.minImageCount; + caps->maxImageCount = khr_caps.maxImageCount; + caps->currentExtent = khr_caps.currentExtent; + caps->minImageExtent = khr_caps.minImageExtent; + caps->maxImageExtent = khr_caps.maxImageExtent; + caps->maxImageArrayLayers = khr_caps.maxImageArrayLayers; + caps->supportedTransforms = khr_caps.supportedTransforms; + caps->currentTransform = khr_caps.currentTransform; + caps->supportedCompositeAlpha = khr_caps.supportedCompositeAlpha; + caps->supportedUsageFlags = khr_caps.supportedUsageFlags; + caps->supportedSurfaceCounters = 0; + return ret; +} + static VkResult wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface, struct wsi_device *wsi_device, @@ -891,6 +917,7 @@ wsi_wl_init_wsi(struct wsi_device *wsi_device, wsi->base.get_support = wsi_wl_surface_get_support; wsi->base.get_capabilities = wsi_wl_surface_get_capabilities; wsi->base.get_capabilities2 = wsi_wl_surface_get_capabilities2; + wsi->base.get_capabilities2ext = wsi_wl_surface_get_capabilities2ext; wsi->base.get_formats = wsi_wl_surface_get_formats; wsi->base.get_formats2 = wsi_wl_surface_get_formats2; wsi->base.get_present_modes = wsi_wl_surface_get_present_modes; diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index c29e0a2d30d..714523678d4 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -516,6 +516,32 @@ x11_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface, return x11_surface_get_capabilities(icd_surface, &caps->surfaceCapabilities); } +static VkResult +x11_surface_get_capabilities2ext(VkIcdSurfaceBase *icd_surface, + VkSurfaceCapabilities2EXT *caps) +{ + VkSurfaceCapabilitiesKHR khr_caps; + VkResult ret; + + assert(caps->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT); + ret = x11_surface_get_capabilities(icd_surface, &khr_caps); + if (ret) + return ret; + + caps->minImageCount = khr_caps.minImageCount; + caps->maxImageCount = khr_caps.maxImageCount; + caps->currentExtent = khr_caps.currentExtent; + caps->minImageExtent = khr_caps.minImageExtent; + caps->maxImageExtent = khr_caps.maxImageExtent; + caps->maxImageArrayLayers = khr_caps.maxImageArrayLayers; + caps->supportedTransforms = khr_caps.supportedTransforms; + caps->currentTransform = khr_caps.currentTransform; + caps->supportedCompositeAlpha = khr_caps.supportedCompositeAlpha; + caps->supportedUsageFlags = khr_caps.supportedUsageFlags; + caps->supportedSurfaceCounters = 0; + return ret; +} + static VkResult x11_surface_get_formats(VkIcdSurfaceBase *surface, struct wsi_device *wsi_device, @@ -1207,6 +1233,7 @@ wsi_x11_init_wsi(struct wsi_device *wsi_device, wsi->base.get_support = x11_surface_get_support; wsi->base.get_capabilities = x11_surface_get_capabilities; wsi->base.get_capabilities2 = x11_surface_get_capabilities2; + wsi->base.get_capabilities2ext = x11_surface_get_capabilities2ext; wsi->base.get_formats = x11_surface_get_formats; wsi->base.get_formats2 = x11_surface_get_formats2; wsi->base.get_present_modes = x11_surface_get_present_modes;