[Mesa-dev] [PATCH mesa 09/21] radv: Add EXT_acquire_xlib_display to radv driver [v2]
Keith Packard
keithp at keithp.com
Thu Mar 8 07:25:07 UTC 2018
This extension adds the ability to borrow an X RandR output for
temporary use directly by a Vulkan application to the radv driver.
v2:
Simplify addition of VK_USE_PLATFORM_XLIB_XRANDR_KHR to
vulkan_wsi_args
Suggested-by: Eric Engestrom <eric.engestrom at imgtec.com>
Signed-off-by: Keith Packard <keithp at keithp.com>
---
src/amd/vulkan/Makefile.am | 7 +++++++
src/amd/vulkan/meson.build | 5 +++++
src/amd/vulkan/radv_entrypoints_gen.py | 5 ++++-
src/amd/vulkan/radv_extensions.py | 11 ++++++-----
src/amd/vulkan/radv_wsi_display.c | 30 ++++++++++++++++++++++++++++++
5 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/src/amd/vulkan/Makefile.am b/src/amd/vulkan/Makefile.am
index f793dc2fa46..8328f9f0bd1 100644
--- a/src/amd/vulkan/Makefile.am
+++ b/src/amd/vulkan/Makefile.am
@@ -81,7 +81,14 @@ AM_CPPFLAGS += \
-DVK_USE_PLATFORM_DISPLAY_KHR
VULKAN_SOURCES += $(VULKAN_WSI_DISPLAY_FILES)
+endif
+
+if HAVE_XLIB_LEASE
+AM_CPPFLAGS += \
+ -DVK_USE_PLATFORM_XLIB_XRANDR_EXT \
+ $(XCB_RANDR_CFLAGS)
+VULKAN_LIB_DEPS += $(XCB_RANDR_LIBS)
endif
if HAVE_PLATFORM_X11
diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build
index 7db2d9f6c21..afd1a5dad31 100644
--- a/src/amd/vulkan/meson.build
+++ b/src/amd/vulkan/meson.build
@@ -118,6 +118,11 @@ if with_platform_display
libradv_files += files('radv_wsi_display.c')
endif
+if with_xlib_lease
+ radv_deps += dep_xcb_xrandr
+ radv_flags += '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT'
+endif
+
libvulkan_radeon = shared_library(
'vulkan_radeon',
[libradv_files, radv_entrypoints, radv_extensions_c, vk_format_table_c],
diff --git a/src/amd/vulkan/radv_entrypoints_gen.py b/src/amd/vulkan/radv_entrypoints_gen.py
index 8eb18e64b64..efef0592a61 100644
--- a/src/amd/vulkan/radv_entrypoints_gen.py
+++ b/src/amd/vulkan/radv_entrypoints_gen.py
@@ -449,7 +449,10 @@ def get_entrypoints_defines(doc):
for extension in doc.findall('./extensions/extension[@platform]'):
platform = extension.attrib['platform']
- define = 'VK_USE_PLATFORM_' + platform.upper() + '_KHR'
+ ext = '_KHR'
+ if platform.upper() == 'XLIB_XRANDR':
+ ext = '_EXT'
+ define = 'VK_USE_PLATFORM_' + platform.upper() + ext
for entrypoint in extension.findall('./require/command'):
fullname = entrypoint.attrib['name']
diff --git a/src/amd/vulkan/radv_extensions.py b/src/amd/vulkan/radv_extensions.py
index d4783d33ee9..b4ad760c55d 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -87,6 +87,7 @@ EXTENSIONS = [
Extension('VK_KHR_multiview', 1, True),
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_EXT_debug_report', 9, True),
Extension('VK_EXT_discard_rectangles', 1, True),
Extension('VK_EXT_external_memory_dma_buf', 1, True),
@@ -218,12 +219,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/amd/vulkan/radv_wsi_display.c b/src/amd/vulkan/radv_wsi_display.c
index deaf61ce0df..d7a5956ad97 100644
--- a/src/amd/vulkan/radv_wsi_display.c
+++ b/src/amd/vulkan/radv_wsi_display.c
@@ -152,3 +152,33 @@ radv_ReleaseDisplayEXT(VkPhysicalDevice physical_device,
&pdevice->wsi_device,
display);
}
+
+#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
+VkResult
+radv_AcquireXlibDisplayEXT(VkPhysicalDevice physical_device,
+ Display *dpy,
+ VkDisplayKHR display)
+{
+ RADV_FROM_HANDLE(radv_physical_device, pdevice, physical_device);
+
+ return wsi_acquire_xlib_display(physical_device,
+ &pdevice->wsi_device,
+ dpy,
+ display);
+}
+
+VkResult
+radv_GetRandROutputDisplayEXT(VkPhysicalDevice physical_device,
+ Display *dpy,
+ RROutput output,
+ VkDisplayKHR *display)
+{
+ RADV_FROM_HANDLE(radv_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 */
--
2.16.2
More information about the mesa-dev
mailing list