Re: [Mesa-dev] [PATCH v2] vulkan: Fix compilation on older platforms

2018-07-13 Thread Danylo Piliaiev



On 12.07.18 21:49, Dylan Baker wrote:

Quoting Danylo Piliaiev (2018-07-12 06:09:57)

Make xlease automatically enabled only if xcb-randr >= 1.13,
check its version if manually enabled.

Enable VK_EXT_display_control only when libdrm >= 2.4.89

Check for DRM_EVENT_CONTEXT_VERSION >= 4 to use sequence_handler.

Add support for 'protect' attribute to anv_entrypoints_gen.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107170
   https://bugs.freedesktop.org/show_bug.cgi?id=106972
   https://bugs.freedesktop.org/show_bug.cgi?id=107176

v2: - Add 'protect="VK_USE_DISPLAY_CONTROL"' attribute to
VK_EXT_display_control in vk.xml
 - Add support for 'protect' attribute to anv_entrypoints_gen
(copied from radv_entrypoints_gen)
 - Turn #if into #ifdef
 - Remove unnecessary pkg-config call from meson build (Dylan Baker)

Signed-off-by: Danylo Piliaiev 
---
Other vulkan extensions are gated behind platforms: wayland, xlib, ...
This one depends on library version and I hope I handled it right,
did I took the right approach?

Also what if extension requires both platform and libary version?
Should *_entrypoints_gen be able to support several defines per extension?

  configure.ac| 29 -
  meson.build | 10 -
  src/amd/vulkan/radv_extensions.py   |  9 +++-
  src/amd/vulkan/radv_wsi_display.c   |  5 ++---
  src/intel/vulkan/anv_entrypoints_gen.py |  7 ++
  src/intel/vulkan/anv_extensions.py  |  2 +-
  src/intel/vulkan/anv_extensions_gen.py  |  7 ++
  src/intel/vulkan/anv_wsi_display.c  |  4 ++--
  src/vulkan/registry/vk.xml  |  2 +-
  src/vulkan/wsi/wsi_common_display.c |  8 +--
  src/vulkan/wsi/wsi_common_display.h |  3 ++-
  11 files changed, 59 insertions(+), 27 deletions(-)

diff --git a/configure.ac b/configure.ac
index f135d05736..0b04525014 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,8 @@ LIBDRM_FREEDRENO_REQUIRED=2.4.92
  LIBDRM_ETNAVIV_REQUIRED=2.4.89
  LIBDRM_VC4_REQUIRED=2.4.89
  
+LIBDRM_CRT_SEQUENCE_REQUIRED=2.4.89

+
  dnl Versions for external dependencies
  DRI2PROTO_REQUIRED=2.8
  GLPROTO_REQUIRED=1.4.14
@@ -97,6 +99,7 @@ XCBDRI2_REQUIRED=1.8
  XCBDRI3_MODIFIERS_REQUIRED=1.13
  XCBGLX_REQUIRED=1.8.1
  XCBPRESENT_MODIFIERS_REQUIRED=1.13
+XCBRANDR_XLEASE_REQUIRED=1.13
  XDAMAGE_REQUIRED=1.1
  XSHMFENCE_REQUIRED=1.1
  XVMC_REQUIRED=1.0.6
@@ -1874,20 +1877,6 @@ 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])
-xlib_randr_modules="xrandr"
-PKG_CHECK_MODULES([XLIB_RANDR], [$xlib_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')
@@ -1905,14 +1894,24 @@ xno)
  ;;
  *)
  if echo "$platforms" | grep -q 'x11' && echo "$platforms" | grep -q 
'drm'; then
-enable_xlib_lease=yes
+xlease_modules="x11-xcb xcb-randr >= $XCBRANDR_XLEASE_REQUIRED xrandr"
+PKG_CHECK_EXISTS([$xlease_modules], [enable_xlib_lease=yes], 
[enable_xlib_lease=no])
  else
  enable_xlib_lease=no
  fi
  esac
  
+if test x"$enable_xlib_lease" = xyes; then

+randr_modules="x11-xcb xcb-randr >= $XCBRANDR_XLEASE_REQUIRED"
+PKG_CHECK_MODULES([XCB_RANDR], [$randr_modules])
+xlib_randr_modules="xrandr"
+PKG_CHECK_MODULES([XLIB_RANDR], [$xlib_randr_modules])
+fi
+
  AM_CONDITIONAL(HAVE_XLIB_LEASE, test "x$enable_xlib_lease" = xyes)
  
+PKG_CHECK_EXISTS([libdrm >= $LIBDRM_CRT_SEQUENCE_REQUIRED], [DEFINES="${DEFINES} -DVK_USE_DISPLAY_CONTROL"], [])

+
  dnl
  dnl More DRI setup
  dnl
diff --git a/meson.build b/meson.build
index 7d12af3d51..902074819c 100644
--- a/meson.build
+++ b/meson.build
@@ -1088,6 +1088,8 @@ _drm_freedreno_ver = '2.4.92'
  _drm_intel_ver = '2.4.75'
  _drm_ver = '2.4.75'
  
+_drm_crt_sequence_ver = '2.4.89'

+
  _libdrm_checks = [
['intel', with_dri_i915 or with_gallium_i915],
['amdgpu', with_amd_vk or with_gallium_radeonsi],
@@ -1361,11 +1363,17 @@ if with_platform_x11
  dep_xcb_xfixes = dependency('xcb-xfixes')
endif
if with_xlib_lease
-dep_xcb_xrandr = dependency('xcb-randr', version : '>= 1.12')
+dep_xcb_xrandr = dependency('xcb-randr', version : '>= 1.13')
  dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
endif
  endif
  
+if with_any_vk

+  if dep_libdrm.version().version_compare('>= ' + _drm_crt_sequence_ver)
+pre_args += '-DVK_USE_DISPLAY_CONTROL'
+  endif
+endif
+
  if get_option('gallium-extra-hud')
pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1'
  endif

Re: [Mesa-dev] [PATCH v2] vulkan: Fix compilation on older platforms

2018-07-12 Thread Dylan Baker
Quoting Danylo Piliaiev (2018-07-12 06:09:57)
> Make xlease automatically enabled only if xcb-randr >= 1.13,
> check its version if manually enabled.
> 
> Enable VK_EXT_display_control only when libdrm >= 2.4.89
> 
> Check for DRM_EVENT_CONTEXT_VERSION >= 4 to use sequence_handler.
> 
> Add support for 'protect' attribute to anv_entrypoints_gen.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107170
>   https://bugs.freedesktop.org/show_bug.cgi?id=106972
>   https://bugs.freedesktop.org/show_bug.cgi?id=107176
> 
> v2: - Add 'protect="VK_USE_DISPLAY_CONTROL"' attribute to
>VK_EXT_display_control in vk.xml
> - Add support for 'protect' attribute to anv_entrypoints_gen
>(copied from radv_entrypoints_gen)
> - Turn #if into #ifdef
> - Remove unnecessary pkg-config call from meson build (Dylan Baker)
> 
> Signed-off-by: Danylo Piliaiev 
> ---
> Other vulkan extensions are gated behind platforms: wayland, xlib, ...
> This one depends on library version and I hope I handled it right,
> did I took the right approach?
> 
> Also what if extension requires both platform and libary version?
> Should *_entrypoints_gen be able to support several defines per extension?
> 
>  configure.ac| 29 -
>  meson.build | 10 -
>  src/amd/vulkan/radv_extensions.py   |  9 +++-
>  src/amd/vulkan/radv_wsi_display.c   |  5 ++---
>  src/intel/vulkan/anv_entrypoints_gen.py |  7 ++
>  src/intel/vulkan/anv_extensions.py  |  2 +-
>  src/intel/vulkan/anv_extensions_gen.py  |  7 ++
>  src/intel/vulkan/anv_wsi_display.c  |  4 ++--
>  src/vulkan/registry/vk.xml  |  2 +-
>  src/vulkan/wsi/wsi_common_display.c |  8 +--
>  src/vulkan/wsi/wsi_common_display.h |  3 ++-
>  11 files changed, 59 insertions(+), 27 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index f135d05736..0b04525014 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -82,6 +82,8 @@ LIBDRM_FREEDRENO_REQUIRED=2.4.92
>  LIBDRM_ETNAVIV_REQUIRED=2.4.89
>  LIBDRM_VC4_REQUIRED=2.4.89
>  
> +LIBDRM_CRT_SEQUENCE_REQUIRED=2.4.89
> +
>  dnl Versions for external dependencies
>  DRI2PROTO_REQUIRED=2.8
>  GLPROTO_REQUIRED=1.4.14
> @@ -97,6 +99,7 @@ XCBDRI2_REQUIRED=1.8
>  XCBDRI3_MODIFIERS_REQUIRED=1.13
>  XCBGLX_REQUIRED=1.8.1
>  XCBPRESENT_MODIFIERS_REQUIRED=1.13
> +XCBRANDR_XLEASE_REQUIRED=1.13
>  XDAMAGE_REQUIRED=1.1
>  XSHMFENCE_REQUIRED=1.1
>  XVMC_REQUIRED=1.0.6
> @@ -1874,20 +1877,6 @@ 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])
> -xlib_randr_modules="xrandr"
> -PKG_CHECK_MODULES([XLIB_RANDR], [$xlib_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')
> @@ -1905,14 +1894,24 @@ xno)
>  ;;
>  *)
>  if echo "$platforms" | grep -q 'x11' && echo "$platforms" | grep -q 
> 'drm'; then
> -enable_xlib_lease=yes
> +xlease_modules="x11-xcb xcb-randr >= $XCBRANDR_XLEASE_REQUIRED 
> xrandr"
> +PKG_CHECK_EXISTS([$xlease_modules], [enable_xlib_lease=yes], 
> [enable_xlib_lease=no])
>  else
>  enable_xlib_lease=no
>  fi
>  esac
>  
> +if test x"$enable_xlib_lease" = xyes; then
> +randr_modules="x11-xcb xcb-randr >= $XCBRANDR_XLEASE_REQUIRED"
> +PKG_CHECK_MODULES([XCB_RANDR], [$randr_modules])
> +xlib_randr_modules="xrandr"
> +PKG_CHECK_MODULES([XLIB_RANDR], [$xlib_randr_modules])
> +fi
> +
>  AM_CONDITIONAL(HAVE_XLIB_LEASE, test "x$enable_xlib_lease" = xyes)
>  
> +PKG_CHECK_EXISTS([libdrm >= $LIBDRM_CRT_SEQUENCE_REQUIRED], 
> [DEFINES="${DEFINES} -DVK_USE_DISPLAY_CONTROL"], [])
> +
>  dnl
>  dnl More DRI setup
>  dnl
> diff --git a/meson.build b/meson.build
> index 7d12af3d51..902074819c 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1088,6 +1088,8 @@ _drm_freedreno_ver = '2.4.92'
>  _drm_intel_ver = '2.4.75'
>  _drm_ver = '2.4.75'
>  
> +_drm_crt_sequence_ver = '2.4.89'
> +
>  _libdrm_checks = [
>['intel', with_dri_i915 or with_gallium_i915],
>['amdgpu', with_amd_vk or with_gallium_radeonsi],
> @@ -1361,11 +1363,17 @@ if with_platform_x11
>  dep_xcb_xfixes = dependency('xcb-xfixes')
>endif
>if with_xlib_lease
> -dep_xcb_xrandr = dependency('xcb-randr', version : '>= 1.12')
> +dep_xcb_xrandr = dependency('xcb-randr', version : '>= 1.13')
>  dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
>endif
>  endif
>  
> +if with_any_vk
> +  if dep_libdrm.version().version_compare('>= ' + 

[Mesa-dev] [PATCH v2] vulkan: Fix compilation on older platforms

2018-07-12 Thread Danylo Piliaiev
Make xlease automatically enabled only if xcb-randr >= 1.13,
check its version if manually enabled.

Enable VK_EXT_display_control only when libdrm >= 2.4.89

Check for DRM_EVENT_CONTEXT_VERSION >= 4 to use sequence_handler.

Add support for 'protect' attribute to anv_entrypoints_gen.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107170
  https://bugs.freedesktop.org/show_bug.cgi?id=106972
  https://bugs.freedesktop.org/show_bug.cgi?id=107176

v2: - Add 'protect="VK_USE_DISPLAY_CONTROL"' attribute to
   VK_EXT_display_control in vk.xml
- Add support for 'protect' attribute to anv_entrypoints_gen
   (copied from radv_entrypoints_gen)
- Turn #if into #ifdef
- Remove unnecessary pkg-config call from meson build (Dylan Baker)

Signed-off-by: Danylo Piliaiev 
---
Other vulkan extensions are gated behind platforms: wayland, xlib, ...
This one depends on library version and I hope I handled it right,
did I took the right approach?

Also what if extension requires both platform and libary version?
Should *_entrypoints_gen be able to support several defines per extension?

 configure.ac| 29 -
 meson.build | 10 -
 src/amd/vulkan/radv_extensions.py   |  9 +++-
 src/amd/vulkan/radv_wsi_display.c   |  5 ++---
 src/intel/vulkan/anv_entrypoints_gen.py |  7 ++
 src/intel/vulkan/anv_extensions.py  |  2 +-
 src/intel/vulkan/anv_extensions_gen.py  |  7 ++
 src/intel/vulkan/anv_wsi_display.c  |  4 ++--
 src/vulkan/registry/vk.xml  |  2 +-
 src/vulkan/wsi/wsi_common_display.c |  8 +--
 src/vulkan/wsi/wsi_common_display.h |  3 ++-
 11 files changed, 59 insertions(+), 27 deletions(-)

diff --git a/configure.ac b/configure.ac
index f135d05736..0b04525014 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,8 @@ LIBDRM_FREEDRENO_REQUIRED=2.4.92
 LIBDRM_ETNAVIV_REQUIRED=2.4.89
 LIBDRM_VC4_REQUIRED=2.4.89
 
+LIBDRM_CRT_SEQUENCE_REQUIRED=2.4.89
+
 dnl Versions for external dependencies
 DRI2PROTO_REQUIRED=2.8
 GLPROTO_REQUIRED=1.4.14
@@ -97,6 +99,7 @@ XCBDRI2_REQUIRED=1.8
 XCBDRI3_MODIFIERS_REQUIRED=1.13
 XCBGLX_REQUIRED=1.8.1
 XCBPRESENT_MODIFIERS_REQUIRED=1.13
+XCBRANDR_XLEASE_REQUIRED=1.13
 XDAMAGE_REQUIRED=1.1
 XSHMFENCE_REQUIRED=1.1
 XVMC_REQUIRED=1.0.6
@@ -1874,20 +1877,6 @@ 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])
-xlib_randr_modules="xrandr"
-PKG_CHECK_MODULES([XLIB_RANDR], [$xlib_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')
@@ -1905,14 +1894,24 @@ xno)
 ;;
 *)
 if echo "$platforms" | grep -q 'x11' && echo "$platforms" | grep -q 'drm'; 
then
-enable_xlib_lease=yes
+xlease_modules="x11-xcb xcb-randr >= $XCBRANDR_XLEASE_REQUIRED xrandr"
+PKG_CHECK_EXISTS([$xlease_modules], [enable_xlib_lease=yes], 
[enable_xlib_lease=no])
 else
 enable_xlib_lease=no
 fi
 esac
 
+if test x"$enable_xlib_lease" = xyes; then
+randr_modules="x11-xcb xcb-randr >= $XCBRANDR_XLEASE_REQUIRED"
+PKG_CHECK_MODULES([XCB_RANDR], [$randr_modules])
+xlib_randr_modules="xrandr"
+PKG_CHECK_MODULES([XLIB_RANDR], [$xlib_randr_modules])
+fi
+
 AM_CONDITIONAL(HAVE_XLIB_LEASE, test "x$enable_xlib_lease" = xyes)
 
+PKG_CHECK_EXISTS([libdrm >= $LIBDRM_CRT_SEQUENCE_REQUIRED], 
[DEFINES="${DEFINES} -DVK_USE_DISPLAY_CONTROL"], [])
+
 dnl
 dnl More DRI setup
 dnl
diff --git a/meson.build b/meson.build
index 7d12af3d51..902074819c 100644
--- a/meson.build
+++ b/meson.build
@@ -1088,6 +1088,8 @@ _drm_freedreno_ver = '2.4.92'
 _drm_intel_ver = '2.4.75'
 _drm_ver = '2.4.75'
 
+_drm_crt_sequence_ver = '2.4.89'
+
 _libdrm_checks = [
   ['intel', with_dri_i915 or with_gallium_i915],
   ['amdgpu', with_amd_vk or with_gallium_radeonsi],
@@ -1361,11 +1363,17 @@ if with_platform_x11
 dep_xcb_xfixes = dependency('xcb-xfixes')
   endif
   if with_xlib_lease
-dep_xcb_xrandr = dependency('xcb-randr', version : '>= 1.12')
+dep_xcb_xrandr = dependency('xcb-randr', version : '>= 1.13')
 dep_xlib_xrandr = dependency('xrandr', version : '>= 1.3')
   endif
 endif
 
+if with_any_vk
+  if dep_libdrm.version().version_compare('>= ' + _drm_crt_sequence_ver)
+pre_args += '-DVK_USE_DISPLAY_CONTROL'
+  endif
+endif
+
 if get_option('gallium-extra-hud')
   pre_args += '-DHAVE_GALLIUM_EXTRA_HUD=1'
 endif
diff --git a/src/amd/vulkan/radv_extensions.py 
b/src/amd/vulkan/radv_extensions.py
index 094ed3bce3..35b49243a3 100644
--- a/src/amd/vulkan/radv_extensions.py