Re: [PATCH 3/7] vulkan: Add EXT_acquire_xlib_display
Quoting Keith Packard (2018-02-09 20:45:12) > 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. > > Signed-off-by: Keith Packard > --- > configure.ac | 25 ++ > meson.build| 17 ++ > meson_options.txt | 7 + > src/amd/vulkan/Makefile.am | 7 + > src/amd/vulkan/meson.build | 7 + > src/amd/vulkan/radv_extensions.py | 11 +- > src/amd/vulkan/radv_wsi_display.c | 30 +++ > 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 + > src/vulkan/Makefile.am | 5 + > src/vulkan/wsi/meson.build | 7 + > src/vulkan/wsi/wsi_common_display.c| 472 > + > src/vulkan/wsi/wsi_common_display.h| 17 ++ > 16 files changed, 650 insertions(+), 10 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 46318365603..9effd15e8c5 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1547,6 +1547,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], > @@ -1846,6 +1847,11 @@ if test x"$enable_dri3" = xyes; then > PKG_CHECK_MODULES([XCB_DRI3], [$dri3_modules]) > 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') > @@ -1853,6 +1859,25 @@ AM_CONDITIONAL(HAVE_PLATFORM_DISPLAY, 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'; > +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 > diff --git a/meson.build b/meson.build > index aeb7f5e2917..595b0f66cd7 100644 > --- a/meson.build > +++ b/meson.build > @@ -262,6 +262,19 @@ if _platforms != '' >egl_native_platform = _split[0] > endif > > +with_xlib_lease = get_option('xlib-lease') > +if with_xlib_lease == 'auto' > + if with_platform_x11 and with_platform_display > +with_xlib_lease = true > + else > +with_xlib_lease = false > + endif You could simplify this to with_xlib_lease = with_platform_x11 and with_platform_display > +elif with_xlib_lease == 'true' We should probably error here if we don't have the correct platforms. > + with_xlib_lease = true > +else > + with_xlib_lease = false > +endif > + > with_glx = get_option('glx') > if with_glx == 'auto' >if with_dri > @@ -1151,6 +1164,7 @@ dep_xcb_present = [] > dep_xcb_sync = [] > dep_xcb_xfixes = [] > dep_xshmfence = [] > +dep_xcb_xrandr = [] > if with_platform_x11 >if with_glx == 'xlib' or with_glx == 'gallium-xlib' > dep_x11 = dependency('x11') > @@ -1190,6 +1204,9 @@ if with_platform_x11 >if with_egl > 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') > diff --git a/meson_options.txt b/meson_options.txt > index 7fafe2deaac..d38c9aa6149 100644 > --- a/meson_options.txt > +++ b/meson_options.txt > @@ -286,3 +286,10 @@ option( >value : '', >description : 'Comma delimited list of tools to build. choices : > freedreno,glsl,intel,nir,nouveau or all' > ) > +option( > + 'xlib-lease', > + type : 'combo', > + value : 'auto', > + choices : ['auto', 'true', 'false'], > + description : 'Enable VK_EXT_acquire_xlib_display.' > +) > diff --git a/src/amd/vulkan/Makefile.am b/src/amd/vulkan/
[PATCH 3/7] vulkan: Add EXT_acquire_xlib_display
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. Signed-off-by: Keith Packard --- configure.ac | 25 ++ meson.build| 17 ++ meson_options.txt | 7 + src/amd/vulkan/Makefile.am | 7 + src/amd/vulkan/meson.build | 7 + src/amd/vulkan/radv_extensions.py | 11 +- src/amd/vulkan/radv_wsi_display.c | 30 +++ 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 + src/vulkan/Makefile.am | 5 + src/vulkan/wsi/meson.build | 7 + src/vulkan/wsi/wsi_common_display.c| 472 + src/vulkan/wsi/wsi_common_display.h| 17 ++ 16 files changed, 650 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 46318365603..9effd15e8c5 100644 --- a/configure.ac +++ b/configure.ac @@ -1547,6 +1547,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], @@ -1846,6 +1847,11 @@ if test x"$enable_dri3" = xyes; then PKG_CHECK_MODULES([XCB_DRI3], [$dri3_modules]) 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') @@ -1853,6 +1859,25 @@ AM_CONDITIONAL(HAVE_PLATFORM_DISPLAY, 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'; +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 diff --git a/meson.build b/meson.build index aeb7f5e2917..595b0f66cd7 100644 --- a/meson.build +++ b/meson.build @@ -262,6 +262,19 @@ if _platforms != '' egl_native_platform = _split[0] endif +with_xlib_lease = get_option('xlib-lease') +if with_xlib_lease == 'auto' + if with_platform_x11 and with_platform_display +with_xlib_lease = true + else +with_xlib_lease = false + endif +elif with_xlib_lease == 'true' + with_xlib_lease = true +else + with_xlib_lease = false +endif + with_glx = get_option('glx') if with_glx == 'auto' if with_dri @@ -1151,6 +1164,7 @@ dep_xcb_present = [] dep_xcb_sync = [] dep_xcb_xfixes = [] dep_xshmfence = [] +dep_xcb_xrandr = [] if with_platform_x11 if with_glx == 'xlib' or with_glx == 'gallium-xlib' dep_x11 = dependency('x11') @@ -1190,6 +1204,9 @@ if with_platform_x11 if with_egl 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') diff --git a/meson_options.txt b/meson_options.txt index 7fafe2deaac..d38c9aa6149 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -286,3 +286,10 @@ option( value : '', description : 'Comma delimited list of tools to build. choices : freedreno,glsl,intel,nir,nouveau or all' ) +option( + 'xlib-lease', + type : 'combo', + value : 'auto', + choices : ['auto', 'true', 'false'], + description : 'Enable VK_EXT_acquire_xlib_display.' +) diff --git a/src/amd/vulkan/Makefile.am b/src/amd/vulkan/Makefile.am index 061b8144b88..94ece06e99e 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/mes