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

Eric Engestrom eric.engestrom at intel.com
Tue Jul 24 15:43:36 UTC 2018


On Friday, 2018-07-13 16:57:34 +0300, Danylo Piliaiev wrote:
> 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.

You're changing 3 unrelated things here; please send 3 patches :)

> 
> 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)
> 
> v3: by Dylan Baker
>     - Remove previously added changes to vk.xml and entrypoints
>        generation because vk.xml is meant to be pulled from the external
>        source.
> 
> Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
> ---
>  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_extensions.py     |  2 +-
>  src/intel/vulkan/anv_extensions_gen.py |  7 +++++++
>  src/intel/vulkan/anv_wsi_display.c     |  4 ++--
>  src/vulkan/wsi/wsi_common_display.c    |  8 +++++--
>  src/vulkan/wsi/wsi_common_display.h    |  3 ++-
>  9 files changed, 51 insertions(+), 26 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

I agree with everyone else here: just bump the libdrm version required
for vulkan :)

libdrm is absolutely trivial to update; any system that can update its
mesa can also update its libdrm.

> +
>  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
> +++ b/src/amd/vulkan/radv_extensions.py
> @@ -92,7 +92,7 @@ EXTENSIONS = [
>      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_display_surface_counter',           1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
> -    Extension('VK_EXT_display_control',                   1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
> +    Extension('VK_EXT_display_control',                   1, 'VK_USE_DISPLAY_CONTROL'),
>      Extension('VK_EXT_debug_report',                      9, True),
>      Extension('VK_EXT_depth_range_unrestricted',          1, True),
>      Extension('VK_EXT_descriptor_indexing',               2, True),
> @@ -239,6 +239,13 @@ _TEMPLATE_C = Template(COPYRIGHT + """
>  #   define ANDROID false
>  #endif
>  
> +#ifdef VK_USE_DISPLAY_CONTROL
> +#   undef VK_USE_DISPLAY_CONTROL
> +#   define VK_USE_DISPLAY_CONTROL true
> +#else
> +#   define VK_USE_DISPLAY_CONTROL false
> +#endif

Don't do that, you're breaking all your own #ifdef checks :)

> +
>  #define RADV_HAS_SURFACE (VK_USE_PLATFORM_WAYLAND_KHR || \\
>                           VK_USE_PLATFORM_XCB_KHR || \\
>                           VK_USE_PLATFORM_XLIB_KHR || \\
> diff --git a/src/amd/vulkan/radv_wsi_display.c b/src/amd/vulkan/radv_wsi_display.c
> index d8743a06e3..a932e05ce8 100644
> --- a/src/amd/vulkan/radv_wsi_display.c
> +++ b/src/amd/vulkan/radv_wsi_display.c
> @@ -252,8 +252,7 @@ radv_GetRandROutputDisplayEXT(VkPhysicalDevice  physical_device,
>  }
>  #endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
>  
> -/* VK_EXT_display_control */
> -
> +#ifdef VK_USE_DISPLAY_CONTROL
>  VkResult
>  radv_DisplayPowerControlEXT(VkDevice                    _device,
>  			    VkDisplayKHR                display,
> @@ -351,4 +350,4 @@ radv_GetSwapchainCounterEXT(VkDevice                    _device,
>  					 flag_bits,
>  					 value);
>  }
> -
> +#endif /* VK_USE_DISPLAY_CONTROL */
> diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py
> index adc1d75898..defd153095 100644
> --- a/src/intel/vulkan/anv_extensions.py
> +++ b/src/intel/vulkan/anv_extensions.py
> @@ -116,7 +116,7 @@ EXTENSIONS = [
>      Extension('VK_EXT_acquire_xlib_display',              1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'),
>      Extension('VK_EXT_debug_report',                      8, True),
>      Extension('VK_EXT_direct_mode_display',               1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
> -    Extension('VK_EXT_display_control',                   1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
> +    Extension('VK_EXT_display_control',                   1, 'VK_USE_DISPLAY_CONTROL'),
>      Extension('VK_EXT_display_surface_counter',           1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
>      Extension('VK_EXT_external_memory_dma_buf',           1, True),
>      Extension('VK_EXT_global_priority',                   1,
> diff --git a/src/intel/vulkan/anv_extensions_gen.py b/src/intel/vulkan/anv_extensions_gen.py
> index a140c26745..914db7bd0e 100644
> --- a/src/intel/vulkan/anv_extensions_gen.py
> +++ b/src/intel/vulkan/anv_extensions_gen.py
> @@ -120,6 +120,13 @@ _TEMPLATE_C = Template(COPYRIGHT + """
>  #   define ANDROID false
>  #endif
>  
> +#ifdef VK_USE_DISPLAY_CONTROL
> +#   undef VK_USE_DISPLAY_CONTROL
> +#   define VK_USE_DISPLAY_CONTROL true
> +#else
> +#   define VK_USE_DISPLAY_CONTROL false
> +#endif
> +
>  #define ANV_HAS_SURFACE (VK_USE_PLATFORM_WAYLAND_KHR || \\
>                           VK_USE_PLATFORM_XCB_KHR || \\
>                           VK_USE_PLATFORM_XLIB_KHR || \\
> diff --git a/src/intel/vulkan/anv_wsi_display.c b/src/intel/vulkan/anv_wsi_display.c
> index 3212c235ba..a915e1e9f7 100644
> --- a/src/intel/vulkan/anv_wsi_display.c
> +++ b/src/intel/vulkan/anv_wsi_display.c
> @@ -231,8 +231,7 @@ anv_GetRandROutputDisplayEXT(VkPhysicalDevice  physical_device,
>  }
>  #endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
>  
> -/* VK_EXT_display_control */
> -
> +#ifdef VK_USE_DISPLAY_CONTROL
>  VkResult
>  anv_DisplayPowerControlEXT(VkDevice                    _device,
>                              VkDisplayKHR                display,
> @@ -315,3 +314,4 @@ anv_GetSwapchainCounterEXT(VkDevice _device,
>        _device, &device->instance->physicalDevice.wsi_device,
>        swapchain, flag_bits, value);
>  }
> +#endif /* VK_USE_DISPLAY_CONTROL */
> diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c
> index ac932d4368..91ce8706b5 100644
> --- a/src/vulkan/wsi/wsi_common_display.c
> +++ b/src/vulkan/wsi/wsi_common_display.c
> @@ -1131,7 +1131,9 @@ static drmEventContext event_context = {
>     .page_flip_handler2 = wsi_display_page_flip_handler2,
>  #endif
>     .vblank_handler = wsi_display_vblank_handler,
> +#if DRM_EVENT_CONTEXT_VERSION >= 4
>     .sequence_handler = wsi_display_sequence_handler,
> +#endif
>  };
>  
>  static void *
> @@ -1459,6 +1461,7 @@ static void wsi_display_fence_event_handler(struct wsi_display_fence *fence)
>     wsi_display_fence_check_free(fence);
>  }
>  
> +#ifdef VK_USE_DISPLAY_CONTROL
>  static void
>  wsi_display_fence_destroy(struct wsi_fence *fence_wsi)
>  {
> @@ -1551,6 +1554,7 @@ wsi_register_vblank_event(struct wsi_display_fence *fence,
>        }
>     }
>  }
> +#endif /* VK_USE_DISPLAY_CONTROL */
>  
>  /*
>   * Check to see if the kernel has no flip queued and if there's an image
> @@ -2348,7 +2352,7 @@ wsi_get_randr_output_display(VkPhysicalDevice physical_device,
>  
>  #endif
>  
> -/* VK_EXT_display_control */
> +#ifdef VK_USE_DISPLAY_CONTROL
>  VkResult
>  wsi_display_power_control(VkDevice device,
>                            struct wsi_device *wsi_device,
> @@ -2459,4 +2463,4 @@ wsi_get_swapchain_counter(VkDevice device,
>  
>     return VK_SUCCESS;
>  }
> -
> +#endif /* VK_USE_DISPLAY_CONTROL */
> diff --git a/src/vulkan/wsi/wsi_common_display.h b/src/vulkan/wsi/wsi_common_display.h
> index 50d7f836a7..1b2d6c5d76 100644
> --- a/src/vulkan/wsi/wsi_common_display.h
> +++ b/src/vulkan/wsi/wsi_common_display.h
> @@ -131,7 +131,7 @@ wsi_get_randr_output_display(VkPhysicalDevice   physical_device,
>  
>  #endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
>  
> -/* VK_EXT_display_control */
> +#ifdef VK_USE_DISPLAY_CONTROL
>  VkResult
>  wsi_display_power_control(VkDevice                      device,
>                            struct wsi_device             *wsi_device,
> @@ -159,5 +159,6 @@ wsi_get_swapchain_counter(VkDevice                      device,
>                            VkSwapchainKHR                swapchain,
>                            VkSurfaceCounterFlagBitsEXT   flag_bits,
>                            uint64_t                      *value);
> +#endif /* VK_USE_DISPLAY_CONTROL */
>  
>  #endif
> -- 
> 2.17.1
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list