From patchwork Wed Feb 14 00:31:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 10217833 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 F208760216 for ; Wed, 14 Feb 2018 00:34:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E22B428F08 for ; Wed, 14 Feb 2018 00:34:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D706128F0A; Wed, 14 Feb 2018 00:34:23 +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 7D1E928F08 for ; Wed, 14 Feb 2018 00:34:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB9ED6E32E; Wed, 14 Feb 2018 00:32:12 +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 A16B46E30C; Wed, 14 Feb 2018 00:31:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 7809C3F20ABA; Tue, 13 Feb 2018 16:31:39 -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 TMXve14yCJ4H; Tue, 13 Feb 2018 16:31:39 -0800 (PST) Received: from keithp.com (koto.keithp.com [10.0.0.2]) by elaine.keithp.com (Postfix) with ESMTPSA id 456983F20FD9; Tue, 13 Feb 2018 16:31:35 -0800 (PST) Received: by keithp.com (Postfix, from userid 1000) id 25C1C15829F5; Tue, 13 Feb 2018 16:31:35 -0800 (PST) From: Keith Packard To: mesa-dev@lists.freedesktop.org Subject: [PATCH 08/21] anv: Add EXT_acquire_xlib_display to anv driver Date: Tue, 13 Feb 2018 16:31:21 -0800 Message-Id: <20180214003134.1552-9-keithp@keithp.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180214003134.1552-1-keithp@keithp.com> References: <20180214003134.1552-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 adds the ability to borrow an X RandR output for temporary use directly by a Vulkan application to the anv driver. Signed-off-by: Keith Packard --- src/intel/Makefile.vulkan.am | 7 +++++++ src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_extensions_gen.py | 10 +++++----- src/intel/vulkan/anv_wsi_display.c | 30 ++++++++++++++++++++++++++++++ src/intel/vulkan/meson.build | 7 +++++++ 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/intel/Makefile.vulkan.am b/src/intel/Makefile.vulkan.am index 7c428a799d7..0f0d3815097 100644 --- a/src/intel/Makefile.vulkan.am +++ b/src/intel/Makefile.vulkan.am @@ -194,6 +194,13 @@ VULKAN_CPPFLAGS += \ VULKAN_SOURCES += $(VULKAN_WSI_DISPLAY_FILES) endif +if HAVE_XLIB_LEASE +VULKAN_CPPFLAGS += \ + -DVK_USE_PLATFORM_XLIB_XRANDR_EXT \ + $(XCB_RANDR_CFLAGS) +VULKAN_LIB_DEPS += $(XCB_RANDR_LIBS) +endif + noinst_LTLIBRARIES += vulkan/libvulkan_common.la vulkan_libvulkan_common_la_SOURCES = $(VULKAN_SOURCES) vulkan_libvulkan_common_la_CFLAGS = $(VULKAN_CFLAGS) diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py index 75b6bf0b41f..47993f45d41 100644 --- a/src/intel/vulkan/anv_extensions.py +++ b/src/intel/vulkan/anv_extensions.py @@ -85,6 +85,7 @@ EXTENSIONS = [ Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'), Extension('VK_KHR_display', 23, '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_KHX_multiview', 1, True), Extension('VK_EXT_debug_report', 8, True), Extension('VK_EXT_external_memory_dma_buf', 1, True), diff --git a/src/intel/vulkan/anv_extensions_gen.py b/src/intel/vulkan/anv_extensions_gen.py index 84d07f9767a..025907aff72 100644 --- a/src/intel/vulkan/anv_extensions_gen.py +++ b/src/intel/vulkan/anv_extensions_gen.py @@ -113,12 +113,12 @@ _TEMPLATE_C = Template(COPYRIGHT + """ #include "vk_util.h" /* Convert the VK_USE_PLATFORM_* defines to booleans */ -%for platform in ['ANDROID', 'WAYLAND', 'XCB', 'XLIB', 'DISPLAY']: -#ifdef VK_USE_PLATFORM_${platform}_KHR -# undef VK_USE_PLATFORM_${platform}_KHR -# define VK_USE_PLATFORM_${platform}_KHR true +%for platform in ['ANDROID_KHR', 'WAYLAND_KHR', 'XCB_KHR', 'XLIB_KHR', 'DISPLAY_KHR', 'XLIB_XRANDR_EXT']: +#ifdef VK_USE_PLATFORM_${platform} +# undef VK_USE_PLATFORM_${platform} +# define VK_USE_PLATFORM_${platform} true #else -# define VK_USE_PLATFORM_${platform}_KHR false +# define VK_USE_PLATFORM_${platform} false #endif %endfor diff --git a/src/intel/vulkan/anv_wsi_display.c b/src/intel/vulkan/anv_wsi_display.c index e6f67f7dec9..e87aed49f7d 100644 --- a/src/intel/vulkan/anv_wsi_display.c +++ b/src/intel/vulkan/anv_wsi_display.c @@ -138,3 +138,33 @@ anv_ReleaseDisplayEXT(VkPhysicalDevice physical_device, &pdevice->wsi_device, display); } + +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT +VkResult +anv_AcquireXlibDisplayEXT(VkPhysicalDevice physical_device, + Display *dpy, + VkDisplayKHR display) +{ + ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device); + + return wsi_acquire_xlib_display(physical_device, + &pdevice->wsi_device, + dpy, + display); +} + +VkResult +anv_GetRandROutputDisplayEXT(VkPhysicalDevice physical_device, + Display *dpy, + RROutput output, + VkDisplayKHR *display) +{ + ANV_FROM_HANDLE(anv_physical_device, pdevice, physical_device); + + return wsi_get_randr_output_display(physical_device, + &pdevice->wsi_device, + dpy, + output, + display); +} +#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */ diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index 2e2ab8f7ecd..d3ab5ac8a64 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -178,6 +178,13 @@ if with_platform_display libanv_files += files('anv_wsi_display.c') endif +if with_xlib_lease + anv_deps += dep_xcb_xrandr + anv_flags += [ + '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT', + ] +endif + libanv_common = static_library( 'anv_common', [libanv_files, anv_entrypoints, anv_extensions_c, anv_extensions_h],