Overview

Mesa 包含了各种 GPU/CPU 的 OpenGL, OpenCL, Vulkan 实现(Usermode Driver), 也包括 GLX, EGL, GBM 等协议的实现。

  • Vulkan 驱动
codename directories platforms
anv src/intel/vulkan, src/intel/vulkan_hasvk Alder Lake-P
asahi src/asahi/vulkan Apple M1, M2
lpv src/gallium/drivers/llvmpipe CPU
panvk src/panfrost/vulkan RK3399
v3dv src/broadcom/vulkan Raspberry Pi

Build

Build Dependencies (since mesa-25.0.0)

dep apt-get version required yet another install
/usr/bin/glslangValidator glslang-tools https://github.com/KhronosGroup/glslang
/usr/bin/rustc rustc 1.78.0 or newer `curl --proto ‘=https’ --tlsv1.2 -sSf https://sh.rustup.rs
bindgen (rust package) cargo 0.65 or newer cargo install bindgen-cli
libclc-dev libclc-17-dev not required if -Dmesa-clc=auto
+ libdrm libdrm-dev 2.4.121(120 ok2.0) https://gitlab.freedesktop.org/mesa/drm
llvm llvm-17-dev (17.0.6 ok2.0) https://github.com/llvm/llvm-project
libLLVMSPIRVLib.so.17 llvm-spirv-17 (17.0.0 ok2.0) https://github.com/KhronosGroup/SPIRV-LLVM-Translator
+ LLVMSPIRVLib.h llvmspirvlib-17-dev (absent ok2.0) https://github.com/KhronosGroup/SPIRV-LLVM-Translator
clang-cpp libclang-cpp17-dev (17.0.6 ok2.0) not required if -Dmesa-clc=auto
* clang-dev libclang-17-dev Debian package issue
xshmfence libxshmfence-dev (1.3 ok2.0) required if -Dplatforms=x11
xxf86vm libxxf86vm-dev (1.1.4 ok2.0) required since -Dglx-direct=true by default
xrandr libxrandr-dev (1.5.2 ok2.0) required since -Dxlib-lease=true
cbindgen (rust package) cargo 0.28.0 cargo install cbindgen; required if -Dgallium-drivers=nouveau

NOTE:

  • (*) 表示本来不需要的依赖

  • (+) 在 OpenKylin 2.0 的源里没有,需要源码构建

  • Ubuntu 22.04

书到用时方恨少,包要装时不好找

1
2
3
4
5
6
sudo apt install -y cmake ninja-build bison flex g++ git pkg-config python3-setuptools python3-lz4 \
python3-jinja2 libssl-dev libelf-dev libboost-dev libglm-dev libtinyobjloader-dev libstb-dev \
libpng-dev wayland-protocols libwayland-dev libdecor-0-dev freeglut3-dev libglfw3-dev libexpat1-dev libglvnd-dev \
libx11-dev libxext-dev libxshmfence-dev libxrandr-dev libxxf86vm-dev libxfixes-dev libx11-xcb-dev \
libxcb1-dev libxcb-randr0-dev libxcb-glx0-dev libxcb-shm0-dev libxcb-dri3-dev libxcb-dri2-0-dev libxcb-present-dev \
libselinux1-dev libvulkan-dev vulkan-tools mesa-utils
1
meson build -Dprefix=/usr/local -Dlibdir=lib/x86_64-linux-gnu -Dplatforms=x11 -Dgallium-drivers=nouveau
  • -Dprefix=/usr/local 避免覆盖系统原来的 libGL*
  • -Dlibdir=lib/x86_64-linux-gnu 设置库的安装路径为 /etc/ld.so.conf.d/x86_64-linux-gnu.conf 中搜索第一顺位的路径
  • 其他默认就好, 出现的依赖在 OpenKylin 2.0 上 apt-get 基本都能解决
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
Build targets in project: 437
WARNING: Project specifies a minimum meson_version '>= 1.1.0' but uses features which were added in newer versions:
* 1.3.0: {'rust.proc_macro', 'rust_abi arg in static_library'}

mesa 25.0.0-devel

Directories
prefix : /usr/local
libdir : lib/x86_64-linux-gnu
includedir : include

Common C and C++ arguments
c_cpp_args : -mtls-dialect=gnu2

OpenGL
OpenGL : YES
ES1 : YES
ES2 : YES
Shared glapi : YES
GLVND : YES

DRI
Platform : drm
Driver dir : /usr/local/lib/x86_64-linux-gnu/dri

GLX
Enabled : YES
Provider : dri

EGL
Enabled : YES
Drivers : builtin:egl_dri2 builtin:egl_dri3
Platforms : x11 surfaceless drm xcb

GBM
Enabled : YES
Backends path : /usr/local/lib/x86_64-linux-gnu/gbm

Vulkan
Drivers : amd intel intel_hasvk nouveau swrast
Platforms : x11 surfaceless drm xcb
ICD dir : share/vulkan/icd.d
Intel Ray tracing : YES

Video
Codecs : av1dec av1enc vp9dec
APIs : vulkan xa

LLVM
Enabled : YES
Version : 17.0.6

Gallium
Enabled : YES
Drivers : nouveau
Platforms : x11 surfaceless drm xcb
Frontends : mesa xa
Off-screen rendering (OSMesa): NO
HUD lm-sensors : NO

Perfetto
Enabled : NO

Teflon (TensorFlow Lite delegate)
Enabled : NO

Subprojects
paste : YES
proc-macro2 : YES (from syn => quote)
quote : YES (from syn)
syn : YES
unicode-ident : YES (from syn)

User defined options
libdir : lib/x86_64-linux-gnu
prefix : /usr/local
gallium-drivers : nouveau
platforms : x11

Found ninja-1.11.1 at /usr/bin/ninja
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
Read more »