Bug 1244: changes to images
[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 update -y
21 apt-get install -y -t buster-backports meson
22
23 Then install the necessary packages by running the following commands as root:
24
25 apt-get update -y
26 apt-get upgrade -y
27 apt-get install -y build-essential \
28 cmake \
29 git \
30 pkg-config \
31 libatomic-ops-dev \
32 libcairo2-dev \
33 libcunit1-dev \
34 libpciaccess-dev \
35 libunwind-dev \
36 llvm-8 \
37 llvm-8-dev \
38 python3.7 \
39 python3.7-dev \
40 python3-setuptools \
41 libzstd-dev \
42 libzstd1 \
43 zlib1g
44
45 Then, still as root, run the following to get the necessary dependencies for building `drm` and `mesa`.
46
47 apt-get build-dep -y libdrm
48 apt-get build-dep -y mesa
49
50 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.
51
52 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.
53
54 mkdir -p ~/opt/lsoc_mesa
55 cd ~/opt
56
57 Now clone `drm` from mesa's gitlab. Change to the `drm` directory. Create a build directory and cd into it.
58
59 git clone https://gitlab.freedesktop.org/mesa/drm.git
60 cd drm
61 mkdir build && cd build
62
63 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.
64
65 meson -Dbuildtype=release -Dprefix=/home/$USER/opt/lsoc_mesa ..
66
67 After configuration has completed, run ninja to build and install the `drm` libraries.
68
69 ninja install
70
71 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`.
72
73 export PKG_CONFIG_PATH=~/opt/lsoc_mesa/lib/x86_64-linux-gnu/pkgconfig/
74
75 These following `vulkan`-specific environment variables are necessary to build our branch of mesa successfully:
76
77 export VK_ICD_FILENAMES=/home/$USER/opt/lsoc_mesa/share/vulkan/icd.d/libresoc_icd.x86_64.json
78 export VK_LOADER_DEBUG=warn
79 export LIBRESOC_TRACE=1
80
81 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.
82
83 cd ~/opt
84 git clone https://git.libre-soc.org/git/mesa.git
85 git pull --rebase origin libresoc_dev
86 git checkout -b libresoc_dev
87 cd mesa
88 mkdir build && cd build
89
90 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.
91
92 meson -Dbuildtype=debug -Dprefix=/home/$USER/opt/lsoc_mesa \
93 -Dvulkan-drivers=libre-soc ..
94
95 After configuration has completed, run ninja to build and install the `mesa` libraries.
96
97 ninja install
98
99 # From here on is solely Vivek's instructions
100
101 To test the code I am sing simple tests built by
102
103 https://github.com/GameTechDev/IntroductionToVulkan
104
105 I am also using debug build for vulkan loader if any one interested in that
106 please look at
107
108 https://github.com/KhronosGroup/Vulkan-Loader/blob/master/BUILD.md
109
110 I have pushed code to the new branch
111 https://gitlab.freedesktop.org/vivekvpandya/mesa/-/tree/libresoc_dev
112 previously it was on master so it will cause me problems working on master
113 branch.
114
115 # Running vulkan intro tutorial
116
117 * <https://github.com/GameTechDev/IntroductionToVulkan/tree/master/Project/Tutorials/01>
118 * <http://lists.libre-soc.org/pipermail/libre-soc-dev/2020-August/000368.html>
119
120 # Demos with lavapipe
121
122 > It can be built with
123 > meson configure -Dvulkan-drivers=swrast -Dgallium-drivers=swrast
124 > set VK_ICD_FILENAMES to the lvp_icd.x86_64.json file and vulkaninfo should
125 > show it.
126 >
127 > I tried running demos from
128 > https://software.intel.com/content/www/us/en/develop/articles/api-without-
129 > secrets-introduction-to-vulkan-part-1.html and all 7 runs fine with lavapipe.
130
131 * <https://bugs.libre-soc.org/show_bug.cgi?id=251#c58>