meson: rework mesa-clc=system handling

In theory you can build a driver using OpenCL kernels with a
-Dmesa-clc=system. That shouldn't require any LLVM/Clang/etc...

But the checks to find the pre-compiled mesa_clc & vtn_bindgen
binaries are in meson files or conditions only triggered if you build
with LLVM (:

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Tested-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Dylan Baker <None>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33014>
This commit is contained in:
Lionel Landwerlin
2025-01-14 16:20:08 +02:00
committed by Marge Bot
parent db11165c07
commit 5adac011b8
4 changed files with 66 additions and 50 deletions

View File

@@ -306,24 +306,26 @@ with_any_broadcom = [
with_broadcom_vk,
].contains(true)
if get_option('intel-clc') != 'system' and get_option('precomp-compiler') != 'system'
with_intel_vk_rt = get_option('intel-rt') \
.disable_auto_if(not with_intel_vk) \
.disable_if(get_option('intel-bvh-grl') and \
host_machine.cpu_family() != 'x86_64', \
error_message : 'Intel Ray Tracing is only supported on x86_64') \
.allowed()
with_intel_bvh_grl = get_option('intel-bvh-grl')
if get_option('intel-clc') != 'system' and \
get_option('precomp-compiler') != 'system' and \
with_intel_bvh_grl
# Require intel-clc with Anv & Iris (for internal shaders)
with_intel_clc = get_option('intel-clc') == 'enabled' or \
get_option('precomp-compiler') == 'enabled' or \
with_intel_vk or with_gallium_iris
with_intel_bvh_grl
else
with_intel_clc = false
endif
with_intel_vk_rt = get_option('intel-rt') \
.disable_auto_if(not with_intel_vk) \
.disable_if(host_machine.cpu_family() != 'x86_64', error_message : 'Intel Ray Tracing is only supported on x86_64') \
.allowed()
if with_intel_vk_rt
with_intel_bvh_grl = get_option('intel-bvh-grl')
endif
with_any_intel = [
with_gallium_crocus,
with_gallium_i915,
@@ -825,7 +827,18 @@ else
with_drivers_clc = false
endif
with_clc = get_option('mesa-clc') != 'auto' or with_microsoft_clc or with_intel_vk or with_gallium_iris or with_drivers_clc or with_gallium_asahi or with_asahi_vk or with_gallium_rusticl
if get_option('mesa-clc') == 'system'
prog_mesa_clc = find_program('mesa_clc', native : true)
prog_vtn_bindgen = find_program('vtn_bindgen', native : true)
# Even with mesa-clc already built, rusticl still needs clc.
with_clc = with_gallium_rusticl
else
with_clc = get_option('mesa-clc') != 'auto' or \
with_microsoft_clc or with_drivers_clc or \
with_gallium_iris or with_intel_vk or \
with_gallium_asahi or with_asahi_vk or \
with_gallium_rusticl
endif
dep_clc = null_dep
if with_gallium_clover or with_clc

View File

@@ -117,9 +117,11 @@ idep_mesaclc = declare_dependency(
link_args : _idep_mesaclc_link_args,
)
if get_option('mesa-clc') == 'system'
prog_mesa_clc = find_program('mesa_clc', native : true)
else
if get_option('mesa-clc') != 'system' and (with_gallium_asahi or \
with_asahi_vk or \
with_intel_vk or \
with_gallium_iris or \
get_option('install-mesa-clc'))
prog_mesa_clc = executable(
'mesa_clc',
['mesa_clc.c'],

View File

@@ -77,14 +77,11 @@ spirv2nir = executable(
install : with_tools.contains('nir'),
)
if get_option('mesa-clc') == 'system'
prog_vtn_bindgen = find_program('vtn_bindgen', native : true)
# Due to the cross build issues in current meson, we only build vtn_bindgen when
# building drivers that need it or mesa-clc is explictly required.
#
# XXX: Build by default once https://github.com/mesonbuild/meson/pull/12022
# ships.
elif get_option('mesa-clc') != 'auto' or with_gallium_asahi or with_asahi_vk or with_intel_vk or with_gallium_iris
if get_option('mesa-clc') != 'system' and (with_gallium_asahi or \
with_asahi_vk or \
with_intel_vk or \
with_gallium_iris or \
get_option('install-mesa-clc'))
prog_vtn_bindgen = executable(
'vtn_bindgen',
['vtn_bindgen.c'],

View File

@@ -167,34 +167,38 @@ idep_intel_compiler_brw = declare_dependency(
)
# For now this tool is only going to be used by Anv
if get_option('intel-clc') == 'system' or get_option('precomp-compiler') == 'system'
prog_intel_clc = find_program('intel_clc', native : true)
dep_prog_intel_clc = []
elif with_intel_clc
prog_intel_clc = executable(
'intel_clc',
[
'intel_clc.c',
'brw_kernel.c',
if with_intel_bvh_grl
if get_option('intel-clc') == 'system' or get_option('precomp-compiler') == 'system'
prog_intel_clc = find_program('intel_clc', native : true)
dep_prog_intel_clc = []
elif with_intel_clc
prog_intel_clc = executable(
'intel_clc',
[
'intel_clc.c',
'brw_kernel.c',
# Use just the nir_options part of ELK instead of fully linking.
'elk/elk_nir_options.h',
'elk/elk_nir_options.c',
'elk/elk_spirv.c',
],
link_with : [libisl],
include_directories : [inc_include, inc_src, inc_intel],
c_args : [pre_args, no_override_init_args],
link_args : [ld_args_build_id],
dependencies : [idep_nir, idep_mesaclc, idep_mesautil, idep_intel_dev,
idep_intel_compiler_brw],
# If we can run host binaries directly, just build intel_clc for the host.
# Most commonly this happens when doing a cross compile from an x86_64 build
# machine to an x86 host
native : not meson.can_run_host_binaries(),
install : get_option('install-intel-clc') or get_option('install-precomp-compiler'),
)
dep_prog_intel_clc = [prog_intel_clc]
# Use just the nir_options part of ELK instead of fully linking.
'elk/elk_nir_options.h',
'elk/elk_nir_options.c',
'elk/elk_spirv.c',
],
link_with : [libisl],
include_directories : [inc_include, inc_src, inc_intel],
c_args : [pre_args, no_override_init_args],
link_args : [ld_args_build_id],
dependencies : [idep_nir, idep_mesaclc, idep_mesautil, idep_intel_dev,
idep_intel_compiler_brw],
# If we can run host binaries directly, just build intel_clc for the host.
# Most commonly this happens when doing a cross compile from an x86_64 build
# machine to an x86 host
native : not meson.can_run_host_binaries(),
install : get_option('install-intel-clc') or get_option('install-precomp-compiler'),
)
dep_prog_intel_clc = [prog_intel_clc]
endif
else
dep_prog_intel_clc = []
endif
if with_tests