Commit 7ab1fffc authored by Keith Packard's avatar Keith Packard

vulkan: Add EXT_acquire_xlib_display [v5]

This extension adds the ability to borrow an X RandR output for
temporary use directly by a Vulkan application. For DRM, we use the
Linux resource leasing mechanism.

v2:
	Clean up xlib_lease detection

	* Use separate temporary '_xlib_lease' variable to hold the
	  option value to avoid changin the type of a variable.

	* Use boolean expressions instead of additional if statements
	  to compute resulting with_xlib_lease value.

	* Simplify addition of VK_USE_PLATFORM_XLIB_XRANDR_KHR to
          vulkan_wsi_args
Suggested-by: default avatarEric Engestrom <eric.engestrom@imgtec.com>

	Move mode list from wsi_display to wsi_display_connector

	Fix scope for wsi_display_mode and wsi_display_connector allocs
Suggested-by: default avatarJason Ekstrand <jason@jlekstrand.net>

v3:
	Adopt Jason Ekstrand's coding conventions

	Declare variables at first use, eliminate extra whitespace
	between types and names. Wrap lines to 80 columns.

	Explicitly forbid multiple DRM leases. Making the code support
	this looks tricky and will require additional thought.

	Use xcb_randr_output_t throughout the internals of the
	implementation. Convert at the public API
	(wsi_get_randr_output_display).

	Clean up check for usable active_crtc (possible when only the
	desired output is connected to the crtc).
Suggested-by: default avatarJason Ekstrand <jason.ekstrand@intel.com>

v4:
	Move output resource fetching closer to use in
	wsi_display_get_output. This simplifies the error returns in
	earlier parts of the code a bit.

	Return VK_ERROR_INITIALIZATION_FAILED from
	wsi_acquire_xlib_display. Jason says this is the right error
	message.
Suggested-by: default avatarJason Ekstrand <jason.ekstrand@intel.com>

v5:
	randr doesn't pass vscan over the wire, so we set vscan to 0
	for randr-acquired modes, and test wsi modes for vscan <= 1
	when comparing against randr modes.
Suggested-by: default avatarJason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: default avatarKeith Packard <keithp@keithp.com>
Reviewed-by: default avatarJason Ekstrand <jason@jlekstrand.net>
parent 5a2efefb
......@@ -1564,6 +1564,7 @@ AM_CONDITIONAL(HAVE_APPLEDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = x
AM_CONDITIONAL(HAVE_LMSENSORS, test "x$enable_lmsensors" = xyes )
AM_CONDITIONAL(HAVE_GALLIUM_EXTRA_HUD, test "x$enable_gallium_extra_hud" = xyes )
AM_CONDITIONAL(HAVE_WINDOWSDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = xwindows )
AM_CONDITIONAL(HAVE_XLEASE, test "x$have_xlease" = xyes )
AC_ARG_ENABLE([shared-glapi],
[AS_HELP_STRING([--enable-shared-glapi],
......@@ -1866,12 +1867,43 @@ if test x"$enable_dri3" = xyes; then
fi
fi
if echo "$platforms" | grep -q 'x11' && echo "$platforms" | grep -q 'drm'; then
have_xlease=yes
else
have_xlease=no
fi
if test x"$have_xlease" = xyes; then
randr_modules="x11-xcb xcb-randr"
PKG_CHECK_MODULES([XCB_RANDR], [$randr_modules])
fi
AM_CONDITIONAL(HAVE_PLATFORM_X11, echo "$platforms" | grep -q 'x11')
AM_CONDITIONAL(HAVE_PLATFORM_WAYLAND, echo "$platforms" | grep -q 'wayland')
AM_CONDITIONAL(HAVE_PLATFORM_DRM, echo "$platforms" | grep -q 'drm')
AM_CONDITIONAL(HAVE_PLATFORM_SURFACELESS, echo "$platforms" | grep -q 'surfaceless')
AM_CONDITIONAL(HAVE_PLATFORM_ANDROID, echo "$platforms" | grep -q 'android')
AC_ARG_ENABLE(xlib-lease,
[AS_HELP_STRING([--enable-xlib-lease]
[enable VK_acquire_xlib_display using X leases])],
[enable_xlib_lease=$enableval], [enable_xlib_lease=auto])
case "x$enable_xlib_lease" in
xyes)
;;
xno)
;;
*)
if echo "$platforms" | grep -q 'x11' && echo "$platforms" | grep -q 'drm'; then
enable_xlib_lease=yes
else
enable_xlib_lease=no
fi
esac
AM_CONDITIONAL(HAVE_XLIB_LEASE, test "x$enable_xlib_lease" = xyes)
dnl
dnl More DRI setup
dnl
......
......@@ -247,6 +247,13 @@ if _platforms.length() != 0 and _platforms != ['']
egl_native_platform = _platforms[0]
endif
_xlib_lease = get_option('xlib-lease')
if _xlib_lease == 'auto'
with_xlib_lease = with_platform_x11 and with_platform_drm
else
with_xlib_lease = _xlib_lease == 'true'
endif
with_glx = get_option('glx')
if with_glx == 'auto'
if with_dri
......@@ -1293,6 +1300,7 @@ dep_xcb_present = null_dep
dep_xcb_sync = null_dep
dep_xcb_xfixes = null_dep
dep_xshmfence = null_dep
dep_xcb_xrandr = null_dep
if with_platform_x11
if with_glx == 'xlib' or with_glx == 'gallium-xlib'
dep_x11 = dependency('x11')
......@@ -1339,6 +1347,9 @@ if with_platform_x11
with_gallium_omx != 'disabled'))
dep_xcb_xfixes = dependency('xcb-xfixes')
endif
if with_xlib_lease
dep_xcb_xrandr = dependency('xcb-randr', version : '>= 1.12')
endif
endif
if get_option('gallium-extra-hud')
......
......@@ -305,3 +305,10 @@ option(
choices : ['auto', 'true', 'false'],
description : 'Enable power8 optimizations.',
)
option(
'xlib-lease',
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false'],
description : 'Enable VK_EXT_acquire_xlib_display.'
)
......@@ -61,6 +61,11 @@ AM_CPPFLAGS += \
VULKAN_WSI_SOURCES += $(VULKAN_WSI_DISPLAY_FILES)
endif
if HAVE_XLIB_LEASE
AM_CPPFLAGS += \
-DVK_USE_PLATFORM_XLIB_XRANDR_EXT
endif
CLEANFILES = \
$(VULKAN_UTIL_GENERATED_FILES) \
$(VULKAN_WSI_WAYLAND_GENERATED_FILES)
......
......@@ -67,6 +67,11 @@ if with_platform_drm
)
endif
if with_xlib_lease
vulkan_wsi_deps += dep_xcb_xrandr
vulkan_wsi_args += '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT'
endif
libvulkan_wsi = static_library(
'vulkan_wsi',
files_vulkan_wsi,
......
This diff is collapsed.
......@@ -87,4 +87,21 @@ wsi_release_display(VkPhysicalDevice physical_device,
struct wsi_device *wsi_device,
VkDisplayKHR display);
#if VK_USE_PLATFORM_XLIB_XRANDR_EXT
VkResult
wsi_acquire_xlib_display(VkPhysicalDevice physical_device,
struct wsi_device *wsi_device,
Display *dpy,
VkDisplayKHR display);
VkResult
wsi_get_randr_output_display(VkPhysicalDevice physical_device,
struct wsi_device *wsi_device,
Display *dpy,
RROutput output,
VkDisplayKHR *display);
#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment