meson: use a feature option for gallium-vdpau

Which we can use with the require method, and use the feature itself
as the require argument to dependency call. All of this results in less
code

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20409>
This commit is contained in:
Dylan Baker 2022-12-20 14:59:48 -08:00 committed by Marge Bot
parent 8dcc1f8311
commit eac76e433d
2 changed files with 19 additions and 47 deletions

View File

@ -640,53 +640,27 @@ if with_gallium_d3d12 and not _with_gallium_d3d12_video.disabled()
pre_args += '-DHAVE_GALLIUM_D3D12_VIDEO'
endif
_vdpau = get_option('gallium-vdpau')
if _vdpau == 'true'
_vdpau = 'enabled'
warning('gallium-vdpau option "true" deprecated, please use "enabled" instead.')
elif _vdpau == 'false'
_vdpau = 'disabled'
warning('gallium-vdpau option "false" deprecated, please use "disabled" instead.')
endif
if not system_has_kms_drm
if _vdpau == 'enabled'
error('VDPAU state tracker can only be build on unix-like OSes.')
else
_vdpau = 'disabled'
endif
elif not with_platform_x11
if _vdpau == 'enabled'
error('VDPAU state tracker requires X11 support.')
else
_vdpau = 'disabled'
endif
elif not [
with_gallium_d3d12_video,
with_gallium_nouveau,
with_gallium_r300,
with_gallium_r600,
with_gallium_radeonsi,
with_gallium_virgl,
].contains(true)
if _vdpau == 'enabled'
error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video, virgl).')
else
_vdpau = 'disabled'
endif
endif
dep_vdpau = null_dep
with_gallium_vdpau = false
if _vdpau != 'disabled'
dep_vdpau = dependency('vdpau', version : '>= 1.1', required : _vdpau == 'enabled')
if dep_vdpau.found()
dep_vdpau = dep_vdpau.partial_dependency(compile_args : true)
with_gallium_vdpau = true
endif
endif
_vdpau_drivers = [
with_gallium_d3d12_video,
with_gallium_nouveau,
with_gallium_r300,
with_gallium_r600,
with_gallium_radeonsi,
with_gallium_virgl,
]
if with_gallium_vdpau
vdpau = get_option('gallium-vdpau') \
.require(system_has_kms_drm, error_message : 'VDPAU state tracker can only be build on unix-like OSes.') \
.require(with_platform_x11, error_message : 'VDPAU state tracker requires X11 support.') \
.require(_vdpau_drivers.contains(true), error_message : 'VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video, virgl).')
dep_vdpau = dependency('vdpau', version : '>= 1.1', required : vdpau)
if dep_vdpau.found()
dep_vdpau = dep_vdpau.partial_dependency(compile_args : true)
pre_args += '-DHAVE_ST_VDPAU'
endif
with_gallium_vdpau = dep_vdpau.found()
vdpau_drivers_path = get_option('vdpau-libs-path')
if vdpau_drivers_path == ''
vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')

View File

@ -85,9 +85,7 @@ option(
)
option(
'gallium-vdpau',
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false', 'enabled', 'disabled'],
type : 'feature',
description : 'enable gallium vdpau frontend.',
)
option(