Skip to content

Commit c5481e2

Browse files
committed
patch dat meson.build
1 parent b9028ed commit c5481e2

File tree

1 file changed

+90
-60
lines changed

1 file changed

+90
-60
lines changed

meson.build

Lines changed: 90 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ project(
66
['c', 'cpp'],
77
version : files('VERSION'),
88
license : 'MIT',
9-
meson_version : '>= 1.3.0',
9+
meson_version : '>= 1.1.0',
1010
default_options : [
1111
'buildtype=debugoptimized',
1212
'b_ndebug=if-release',
@@ -44,22 +44,6 @@ with_mesa_debug = get_option('buildtype') == 'debug'
4444
# This means the final value of b_ndebug==true
4545
with_mesa_ndebug = get_option('b_ndebug') == 'true' or (get_option('buildtype') == 'release' and get_option('b_ndebug') == 'if-release')
4646

47-
# We need to set -fmacro-prefix-map properly for driver CL reproducability.
48-
relative_dir = fs.relative_to(meson.global_source_root(), meson.global_build_root())
49-
50-
cl_args = [
51-
'-fmacro-prefix-map=@0@/='.format(relative_dir),
52-
53-
# Set the OpenCL standard to CL 2.0, enabling everything at a frontend.
54-
# Drivers may not actually support everything but that's ok.
55-
'-cl-std=cl2.0',
56-
'-D__OPENCL_VERSION__=200'
57-
]
58-
59-
if with_mesa_ndebug
60-
cl_args += ['-DNDEBUG']
61-
endif
62-
6347
# Arguments for the preprocessor, put these in a separate array from the C and
6448
# C++ (cpp in meson terminology) arguments since they need to be added to the
6549
# default arguments for both C and C++.
@@ -80,10 +64,10 @@ with_moltenvk_dir = get_option('moltenvk-dir')
8064
with_vulkan_icd_dir = get_option('vulkan-icd-dir')
8165
with_tests = get_option('build-tests')
8266
with_glcpp_tests = get_option('enable-glcpp-tests')
83-
with_radv_tests = get_option('build-radv-tests')
8467
with_aco_tests = get_option('build-aco-tests')
8568
with_glx_read_only_text = get_option('glx-read-only-text')
8669
with_glx_direct = get_option('glx-direct')
70+
with_osmesa = get_option('osmesa')
8771
with_vulkan_overlay_layer = get_option('vulkan-layers').contains('overlay')
8872
with_vulkan_device_select_layer = get_option('vulkan-layers').contains('device-select')
8973
with_vulkan_screenshot_layer = get_option('vulkan-layers').contains('screenshot')
@@ -120,15 +104,28 @@ if gbm_backends_path == ''
120104
gbm_backends_path = join_paths(get_option('prefix'), get_option('libdir'), 'gbm')
121105
endif
122106

107+
# Default shared glapi disabled for windows, enabled elsewhere.
108+
with_shared_glapi = get_option('shared-glapi') \
109+
.disable_auto_if(host_machine.system() == 'windows') \
110+
.allowed()
111+
123112
with_opengl = get_option('opengl')
124-
with_gles1 = get_option('gles1').allowed()
125-
with_gles2 = get_option('gles2').allowed()
113+
114+
with_gles1 = get_option('gles1') \
115+
.require(with_shared_glapi, error_message : 'OpengGL ES 1.x requires shared-glapi') \
116+
.allowed()
117+
118+
with_gles2 = get_option('gles2') \
119+
.require(with_shared_glapi, error_message : 'OpengGL ES 2.x requires shared-glapi') \
120+
.allowed()
126121

127122
pre_args += '-DHAVE_OPENGL=@0@'.format(with_opengl.to_int())
128123
pre_args += '-DHAVE_OPENGL_ES_1=@0@'.format(with_gles1.to_int())
129124
pre_args += '-DHAVE_OPENGL_ES_2=@0@'.format(with_gles2.to_int())
130125

131126
with_any_opengl = with_opengl or with_gles1 or with_gles2
127+
# Only build shared_glapi if at least one OpenGL API is enabled
128+
with_shared_glapi = with_shared_glapi and with_any_opengl
132129

133130
system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos', 'android', 'managarm'].contains(host_machine.system())
134131

@@ -168,22 +165,30 @@ if gallium_drivers.contains('auto')
168165
host_machine.system()))
169166
endif
170167
elif gallium_drivers.contains('all')
168+
# Build-test everything except for i915, which depends on libdrm-intel which
169+
# is not available on non-Intel distros.
171170
gallium_drivers = [
172-
'r300', 'r600', 'radeonsi', 'crocus', 'v3d', 'vc4', 'freedreno', 'etnaviv', 'i915',
171+
'r300', 'r600', 'radeonsi', 'crocus', 'v3d', 'vc4', 'freedreno', 'etnaviv',
173172
'nouveau', 'svga', 'tegra', 'virgl', 'lima', 'panfrost', 'llvmpipe', 'softpipe', 'iris',
174173
'zink', 'd3d12', 'asahi'
175174
]
176175
endif
177176

177+
# compatibility for meson configurations asking for 'swrast'
178+
with_swrast = gallium_drivers.contains('swrast')
179+
if with_swrast
180+
warning('`gallium-drivers=swrast` is a deprecated alias for `gallium-drivers=softpipe,llvmpipe` and will be removed in version 25.0')
181+
endif
182+
178183
with_amdgpu_virtio = get_option('amdgpu-virtio')
179184

180185
with_gallium_radeonsi = gallium_drivers.contains('radeonsi')
181186
with_gallium_r300 = gallium_drivers.contains('r300')
182187
with_gallium_r600 = gallium_drivers.contains('r600')
183188
with_gallium_nouveau = gallium_drivers.contains('nouveau')
184189
with_gallium_freedreno = gallium_drivers.contains('freedreno')
185-
with_gallium_softpipe = gallium_drivers.contains('softpipe')
186-
with_gallium_llvmpipe = gallium_drivers.contains('llvmpipe')
190+
with_gallium_softpipe = with_swrast or gallium_drivers.contains('softpipe')
191+
with_gallium_llvmpipe = with_swrast or gallium_drivers.contains('llvmpipe')
187192
with_gallium_vc4 = gallium_drivers.contains('vc4')
188193
with_gallium_v3d = gallium_drivers.contains('v3d')
189194
with_gallium_panfrost = gallium_drivers.contains('panfrost')
@@ -225,7 +230,7 @@ if _vulkan_drivers.contains('auto')
225230
if host_machine.cpu_family().startswith('x86')
226231
_vulkan_drivers = ['amd', 'intel', 'intel_hasvk', 'nouveau', 'swrast']
227232
elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
228-
_vulkan_drivers = ['swrast', 'intel', 'panfrost', 'freedreno']
233+
_vulkan_drivers = ['swrast', 'intel', 'panfrost']
229234
elif ['mips', 'mips64', 'ppc', 'ppc64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family())
230235
_vulkan_drivers = ['amd', 'swrast']
231236
elif ['loongarch64'].contains(host_machine.cpu_family())
@@ -344,9 +349,6 @@ endif
344349
if with_aco_tests and not with_amd_vk
345350
error('ACO tests require Radv')
346351
endif
347-
if with_radv_tests and not with_amd_vk
348-
error('RADV tests require RADV')
349-
endif
350352

351353
with_microsoft_clc = get_option('microsoft-clc').enabled()
352354
with_spirv_to_dxil = get_option('spirv-to-dxil')
@@ -382,7 +384,13 @@ all_codecs = patent_codecs + free_codecs
382384
if _codecs.contains('all')
383385
_codecs = all_codecs
384386
elif _codecs.contains('all_free')
385-
_codecs += free_codecs
387+
selected_codecs = _codecs
388+
_codecs = free_codecs
389+
foreach c : patent_codecs
390+
if selected_codecs.contains(c)
391+
_codecs += c
392+
endif
393+
endforeach
386394
endif
387395
foreach c : all_codecs
388396
pre_args += '-DVIDEO_CODEC_@0@=@1@'.format(c.to_upper(), _codecs.contains(c).to_int())
@@ -452,6 +460,7 @@ if not (with_dri or with_gallium or with_glx != 'disabled')
452460
with_gles2 = false
453461
with_opengl = false
454462
with_any_opengl = false
463+
with_shared_glapi = false
455464
endif
456465

457466
with_gbm = get_option('gbm') \
@@ -465,6 +474,7 @@ with_xlib_lease = get_option('xlib-lease') \
465474

466475
with_egl = get_option('egl') \
467476
.require(with_platform_windows or with_platform_haiku or with_dri or with_platform_android, error_message : 'EGL requires DRI, Haiku, Windows or Android') \
477+
.require(with_shared_glapi, error_message : 'EGL requires shared-glapi') \
468478
.require(with_glx != 'xlib', error_message :'EGL requires DRI, but GLX is being built with xlib support') \
469479
.disable_auto_if(with_platform_haiku) \
470480
.allowed()
@@ -554,6 +564,10 @@ if with_glx != 'disabled'
554564
elif with_dri
555565
error('xlib conflicts with any dri driver')
556566
endif
567+
elif with_glx == 'dri'
568+
if not with_shared_glapi
569+
error('dri based GLX requires shared-glapi')
570+
endif
557571
endif
558572
endif
559573

@@ -696,7 +710,6 @@ endif
696710

697711
with_gallium_st_nine = get_option('gallium-nine')
698712
if with_gallium_st_nine
699-
warning('The nine state tracker will be removed in Mesa 25.2')
700713
if not with_gallium_swrast
701714
error('The nine state tracker requires gallium softpipe/llvmpipe.')
702715
elif not [
@@ -721,18 +734,27 @@ if with_gallium_st_d3d10umd
721734
error('The d3d10umd state tracker requires gallium softpipe/llvmpipe.')
722735
endif
723736
endif
724-
725-
if host_machine.cpu_family() == 'ppc64' and host_machine.endian() == 'little'
726-
if cc.compiles('''
727-
#include <altivec.h>
728-
int main() {
729-
vector unsigned char r;
730-
vector unsigned int v = vec_splat_u32 (1);
731-
r = __builtin_vec_vgbbd ((vector unsigned char) v);
732-
return 0;
733-
}''',
734-
name : 'POWER8 intrinsics')
735-
pre_args += ['-D_ARCH_PWR8']
737+
_power8 = get_option('power8')
738+
if _power8.allowed()
739+
if host_machine.cpu_family() == 'ppc64' and host_machine.endian() == 'little'
740+
if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.8')
741+
error('Altivec is not supported with gcc version < 4.8.')
742+
endif
743+
if cc.compiles('''
744+
#include <altivec.h>
745+
int main() {
746+
vector unsigned char r;
747+
vector unsigned int v = vec_splat_u32 (1);
748+
r = __builtin_vec_vgbbd ((vector unsigned char) v);
749+
return 0;
750+
}''',
751+
args : '-mpower8-vector',
752+
name : 'POWER8 intrinsics')
753+
pre_args += ['-D_ARCH_PWR8']
754+
c_cpp_args += '-mpower8-vector'
755+
elif _power8.enabled()
756+
error('POWER8 intrinsic support required but not found.')
757+
endif
736758
endif
737759
endif
738760

@@ -810,22 +832,17 @@ else
810832
with_drivers_clc = false
811833
endif
812834

813-
with_driver_using_cl = [
814-
with_gallium_iris, with_intel_vk,
815-
with_gallium_asahi, with_asahi_vk,
816-
with_gallium_panfrost, with_panfrost_vk,
817-
with_nouveau_vk,
818-
].contains(true)
819-
820835
if get_option('mesa-clc') == 'system'
821836
prog_mesa_clc = find_program('mesa_clc', native : true)
822-
prog_vtn_bindgen2 = find_program('vtn_bindgen2', native : true)
837+
prog_vtn_bindgen = find_program('vtn_bindgen', native : true)
823838
# Even with mesa-clc already built, rusticl still needs clc.
824839
with_clc = with_gallium_rusticl
825840
else
826841
with_clc = get_option('mesa-clc') != 'auto' or \
827-
with_microsoft_clc or with_gallium_rusticl or \
828-
with_drivers_clc or with_driver_using_cl
842+
with_microsoft_clc or with_drivers_clc or \
843+
with_gallium_iris or with_intel_vk or \
844+
with_gallium_asahi or with_asahi_vk or \
845+
with_gallium_rusticl
829846
endif
830847

831848
dep_clc = null_dep
@@ -861,7 +878,7 @@ if with_platform_x11
861878
endif
862879

863880
with_glapi_export_proto_entry_points = false
864-
if not with_glx_indirect_rendering
881+
if with_shared_glapi and not with_glx_indirect_rendering
865882
# Imply !defined(GLX_INDIRECT_RENDERING)
866883
with_glapi_export_proto_entry_points = true
867884
endif
@@ -1085,7 +1102,6 @@ if cc.get_argument_syntax() == 'msvc'
10851102
'/we4024', # Error when passing different type of parameter
10861103
'/we4189', # 'identifier' : local variable is initialized but not referenced
10871104
'/Zc:__cplusplus', #Set __cplusplus macro to match the /std:c++<version> on the command line
1088-
'/Zc:preprocessor', # Use the standards-conforming preprocessor
10891105
]
10901106
c_args += cc.get_supported_arguments(_trial)
10911107
cpp_args += cpp.get_supported_arguments(_trial)
@@ -1546,6 +1562,10 @@ if with_any_intel and ['x86', 'x86_64'].contains(host_machine.cpu_family())
15461562
pre_args += '-DSUPPORT_INTEL_INTEGRATED_GPUS'
15471563
endif
15481564

1565+
if with_gallium_i915 and host_machine.cpu_family().startswith('x86') == false
1566+
error('Intel "i915" Gallium driver requires x86 or x86_64 CPU family')
1567+
endif
1568+
15491569
# Determine whether or not the rt library is needed for time functions
15501570
if host_machine.system() == 'windows' or cc.has_function('clock_gettime')
15511571
dep_clock = null_dep
@@ -1746,9 +1766,7 @@ amd_with_llvm = get_option('amd-use-llvm')
17461766
llvm_has_mcjit = host_machine.cpu_family() in ['aarch64', 'arm', 'ppc', 'ppc64', 's390x', 'x86', 'x86_64']
17471767
llvm_with_orcjit = get_option('llvm-orcjit') or not llvm_has_mcjit
17481768

1749-
if with_amd_vk or with_gallium_radeonsi
1750-
_llvm_version = '>= 18.0.0'
1751-
elif with_clc or llvm_with_orcjit
1769+
if with_amd_vk or with_gallium_radeonsi or with_clc or llvm_with_orcjit
17521770
_llvm_version = '>= 15.0.0'
17531771
elif with_gallium_clover
17541772
_llvm_version = '>= 11.0.0'
@@ -1869,7 +1887,7 @@ endif
18691887
dep_spirv_tools = dependency(
18701888
'SPIRV-Tools',
18711889
required : with_clc,
1872-
version : '>= 2024.1'
1890+
version : '>= 2022.1'
18731891
)
18741892
if dep_spirv_tools.found()
18751893
pre_args += '-DHAVE_SPIRV_TOOLS'
@@ -2019,6 +2037,17 @@ if dep_unwind.found()
20192037
pre_args += '-DHAVE_LIBUNWIND'
20202038
endif
20212039

2040+
if with_osmesa
2041+
# if not with_gallium_swrast
2042+
# error('OSMesa gallium requires gallium softpipe or llvmpipe.')
2043+
# endif
2044+
if host_machine.system() == 'windows'
2045+
osmesa_lib_name = 'osmesa'
2046+
else
2047+
osmesa_lib_name = 'OSMesa'
2048+
endif
2049+
endif
2050+
20222051
# TODO: symbol mangling
20232052

20242053
if with_platform_wayland
@@ -2029,7 +2058,7 @@ if with_platform_wayland
20292058
else
20302059
wl_scanner_arg = 'code'
20312060
endif
2032-
dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.41', default_options: [ 'tests=false' ])
2061+
dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.38', default_options: [ 'tests=false' ])
20332062
dep_wayland_client = dependency('wayland-client', version : '>=1.18')
20342063
dep_wayland_server = dependency('wayland-server', version : '>=1.18')
20352064
if with_egl
@@ -2317,6 +2346,7 @@ summary(
23172346
'OpenGL': with_opengl,
23182347
'ES1': with_gles1,
23192348
'ES2': with_gles2,
2349+
'Shared glapi': with_shared_glapi,
23202350
'GLVND': with_glvnd,
23212351
},
23222352
section: 'OpenGL', bool_yn: true
@@ -2357,7 +2387,7 @@ summary(egl_summary, section: 'EGL', bool_yn: true, list_sep: ' ')
23572387

23582388
gbm_summary = {'Enabled': with_gbm}
23592389
if with_gbm
2360-
gbm_summary += {'External libgbm': get_option('libgbm-external'), 'Backends path': gbm_backends_path}
2390+
gbm_summary += {'Backends path': gbm_backends_path}
23612391
endif
23622392
summary(gbm_summary, section: 'GBM', bool_yn: true, list_sep: ' ')
23632393

@@ -2384,7 +2414,6 @@ if with_any_vk
23842414
video_apis += 'vulkan'
23852415
endif
23862416
if with_gallium_xa
2387-
warning('XA will be removed in Mesa 25.2')
23882417
video_apis += 'xa'
23892418
endif
23902419
video_summary += {'APIs': video_apis.length() != 0 ? video_apis : false}
@@ -2421,6 +2450,7 @@ if with_gallium
24212450
gallium_frontends += 'rusticl'
24222451
endif
24232452
gallium_summary += {'Frontends': gallium_frontends}
2453+
gallium_summary += {'Off-screen rendering (OSMesa)': with_osmesa ? 'lib' + osmesa_lib_name : false}
24242454
gallium_summary += {'HUD lm-sensors': dep_lmsensors.found()}
24252455
endif
24262456
summary(gallium_summary, section: 'Gallium', bool_yn: true, list_sep: ' ')

0 commit comments

Comments
 (0)