(no commit message)
[libreriscv.git] / 3d_gpu / mesa.mdwn
1 # MESA Driver sponsored by NLNet
2
3 todo http://lists.libre-soc.org/pipermail/libre-soc-dev/2020-August/000246.html
4
5 # Build Instructions (by Cole from Vivek's comments on the mailing list)
6
7 This tutorial assumes, like the rest of the info on the wiki, that you are running Debian 10.4 either natively or in a virtualized setup.
8
9 The following is available as scripts in the libre-soc dev-env-setup repo, and can be easily used by running `sudo ./install-mesa-apt-reqs && ./lsoc-mesa-dev-env-setup`.
10
11 First, we need to install the necessary apt dependencies for building `drm` and `mesa`.
12
13 In order to install a `meson` version recent enough to configure `mesa`, add buster-backports to /etc/apt/sources.list by running the following as root:
14
15 echo "deb http://deb.debian.org/debian buster-backports main" | tee \
16 -a /etc/apt/sources.list
17
18 Install `meson` (version 52.0 or later):
19
20 apt-get install -y -t buster-backports meson
21
22 Then install the necessary packages by running the following commands as root:
23
24 apt-get update -y
25 apt-get upgrade -y
26 apt-get install -y build-essential \
27 cmake \
28 git \
29 pkg-config \
30 libatomic-ops-dev \
31 libcairo2-dev \
32 libcunit1-dev \
33 libpciaccess-dev \
34 libunwind-dev \
35 llvm-8 \
36 llvm-8-dev \
37 python3.7 \
38 python3.7-dev \
39 python3-setuptools \
40 libzstd-dev \
41 libzstd1 \
42 zlib1g
43
44 Then, still as root, run the following to get the necessary dependencies for building `drm` and `mesa`.
45
46 apt-get build-dep -y libdrm
47 apt-get build-dep -y mesa
48
49 Now we are going to build and install `drm` from source as the debian apt versions are not recent enough to build mesa. Run all of these command as a regular user, **DO NOT RUN AS ROOT** it is not necessary.
50
51 First, create our working directory `opt` in our user directory. In order to not mess with system `drm` and `mesa` libraries, also create a sub-directory `lsoc_mesa` to hold our header files and libraries. After creating the `opt` directory, cd into it to make it our active, current working directory.
52
53 mkdir -p ~/opt/lsoc_mesa
54 cd ~/opt
55
56 Now clone `drm` from mesa's gitlab. Change to the `drm` directory. Create a build directory and cd into it.
57
58 git clone https://gitlab.freedesktop.org/mesa/drm.git
59 cd drm
60 mkdir build && cd build
61
62 In order to configure `drm` for building and installation run the following command. It is very important to specify `prefix=/home/$USER/opt/lsoc_mesa` because as mentioned above we need these files for development purposes, but we do not want to corrupt or interfere with our *system* `drm` libraries.
63
64 meson -Dbuildtype=release -Dprefix=/home/$USER/opt/lsoc_mesa ..
65
66 After configuration has completed, run ninja to build and install the `drm` libraries.
67
68 ninja install
69
70 In order for meson to be able to find the up-to-date `drm` files we have just built, we need to specify their location with the environment variable `PKG_CONFIG_PATH`.
71
72 export PKG_CONFIG_PATH=~/opt/lsoc_mesa/lib/x86_64-linux-gnu/pkgconfig/
73
74 Now change back to the base `~/opt` directory and clone the `mesa` git repo from the `mesa` gitlab instance. Change to the `mesa` directory. Create a build directory and cd into it.
75
76 cd ~/opt
77 git clone https://gitlab.freedesktop.org/mesa/mesa.git
78 cd mesa
79 mkdir build && cd build
80
81 In order to configure `mesa` for building and installation run the following command. Again, it is *very* important to specify `prefix=/home/$USER/opt/lsoc_mesa` because as mentioned above we need these files for development purposes, but we do not want to corrupt or interfere with our *system* `mesa` libraries.
82
83 meson -Dbuildtype=debug -Dprefix=/home/$USER/opt/lsoc_mesa
84
85 After configuration has completed, run ninja to build and install the `mesa` libraries.
86
87 ninja install
88
89 # From here on is solely Vivek's instructions
90
91 I also have script to set few environment variables like
92
93 export VK_ICD_FILENAMES=/home/vivek/install/share/vulkan/icd.d/libresoc_icd.x86_64.json
94 export VK_LOADER_DEBUG=warn
95 export LIBRESOC_TRACE=1
96
97 To test the code I am sing simple tests built by
98 https://github.com/GameTechDev/IntroductionToVulkan
99
100 I am also using debug build for vulkan loader if any one interested in that
101 please look at
102
103 https://github.com/KhronosGroup/Vulkan-Loader/blob/master/BUILD.md
104
105 I have pushed code to the new branch
106 https://gitlab.freedesktop.org/vivekvpandya/mesa/-/tree/libresoc_dev
107 previously it was on master so it will cause me problems working on master
108 branch.
109
110 Also note slight change in meson configure command
111 meson -Dbuildtype=debug -Dprefix=/home/vivek/install
112 -Dvulkan-drivers=libre-soc ..
113
114 instead of libresoc it is libre-soc for vulkan-drivers option.