Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Usulyre/bb33f77b225b8d9336c1f9e744114fba to your computer and use it in GitHub Desktop.
Save Usulyre/bb33f77b225b8d9336c1f9e744114fba to your computer and use it in GitHub Desktop.
Compiling/installing the mesa virtio-venus-driver-(below done with new linux container)
For: Chrome OS crostini-default debian container bookworm
Best viewed in "raw" format
In chrome browser type or paste
chrome://flags
type in "search flags" box "crostini" without quotes.
Enable "Crostini GPU Support" and select "Bookworm" for
"Debian version for new Crostini containers"
Restart your chromebook
In chrome os settings, enable "Linux development environment"
Close the "Terminal" program that opens.
In chrome browser press "ctrl+alt+t" to get crosh
Always start with the below command(s) in crosh and add to your existing vmc start cmdline (before starting any linux program that you want to use the vulkan driver!).
--enable-vulkan termina
Example in crosh:
vmc start --enable-vulkan termina
After your cmdline is entered wait until it is finished you should see "(termina) chronos@localhost ~ $"
Make sure to keep that tab/window open.
Open the linux "Terminal" program located in linux apps.
Type or paste the following cmd(s) one at a time in linux terminal program and press "Y" key if prompted:
sudo apt update
sudo apt upgrade
sudo apt-get install nano
sudo nano /etc/apt/sources.list
Add the (type or copy/paste) below lines to the opened text file:
deb-src [arch=amd64,i386] http://deb.debian.org/debian bookworm main
deb http://http.us.debian.org/debian sid main non-free contrib
Press ctrl+x, press the "y" key and press enter to save.
Type or paste the following cmd(s) one at a time in the linux terminal program:
sudo apt update
sudo apt full-upgrade -y
git clone https://gitlab.freedesktop.org/mesa/mesa.git
sudo apt-get build-dep mesa
sudo apt-get install libunwind-dev
sudo apt-get install libudev-dev
sudo apt-get install libxcb-keysyms1-dev
(Press the "y" key if prompted and wait for the process to complete)
cd mesa
If you want to update the mesa git repository use the cmd below in mesa folder
git pull origin
64 bit mesa driver:
Paste the below in the linux terminal program and press enter (the part in quotes, but don't paste the quotes, note that this a sample one can edit it for their system):
"meson setup build64 --libdir /usr/lib/x86_64-linux-gnu -Ddri3=enabled \
-Dprefix=/usr \
-Dglx=dri \
-Degl=enabled \
-Dgbm=enabled \
-Dgallium-vdpau=disabled \
-Dvalgrind=disabled \
-Dgallium-drivers=virgl \
-Dvulkan-drivers=virtio \
-Dvulkan-layers=device-select"
Type or paste the following cmd in the linux terminal program (the compiling/installation process may take some time):
sudo ninja -C build64 install
If you need to rebuild the 64 bit mesa driver, just delete the build64 folder which is inside the mesa folder and repaste the build/install cmdlines.
Example: sudo rm -rf build64
32 bit mesa driver:
Type or paste the following cmd(s) one at a time in the linux terminal program:
mkdir -p ~/.local/share/meson/cross
sudo nano ~/.local/share/meson/cross/gcc-i686
Paste the below into the opened text file:
# gcc-i686
[binaries]
c = '/usr/bin/gcc'
cpp = '/usr/bin/g++'
ar = '/usr/bin/gcc-ar'
strip = '/usr/bin/strip'
pkg-config = '/usr/bin/i686-linux-gnu-pkg-config'
llvm-config = '/usr/bin/llvm-config'
[built-in options]
c_args = ['-m32']
c_link_args = ['-m32']
cpp_args = ['-m32']
cpp_link_args = ['-m32']
[host_machine]
system = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'
Press ctrl+x, press the "y" key and press enter to save.
Note: At this time, llvm doesn't build/install for 32 bit. Don't actually know if it is necessary at all.
Type or paste the following cmd(s) one at a time in the linux terminal program and Press the "y" key if prompted at any time.
(The reason why one has to enter so many commands is because I don't know if mesa has a 32 bit build dependency package for debian, welcome to find out if they do which would greatly simplify the process)
sudo apt-get install gcc-multilib
sudo apt-get install g++-multilib
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install pkg-config:i386
sudo apt-get -t sid install libdrm-dev:i386
sudo apt-get install libwayland-dev:i386
sudo apt-get install libwayland-egl-backend-dev:i386
sudo apt-get install libxext-dev:i386
sudo apt-get install libxfixes-dev:i386
sudo apt-get install x11proto-dev:i386
sudo apt-get install libxcb-glx0-dev:i386
sudo apt-get install libxcb-shm0-dev:i386
sudo apt-get install libx11-xcb-dev:i386
sudo apt-get install libxcb-dri2-0-dev:i386
sudo apt-get install libxcb-dri3-dev:i386
sudo apt-get install libxcb-present-dev:i386
sudo apt-get install libxshmfence-dev:i386
sudo apt-get install libxxf86vm-dev:i386
sudo apt-get install libxrandr-dev:i386
sudo apt-get install libunwind-dev:i386
sudo apt-get install libudev-dev:i386
sudo apt-get install libelf-dev:i386
sudo apt-get install libzstd-dev:i386
sudo apt-get install libbsd-dev:i386
sudo apt-get install libsensors-dev:i386
sudo apt-get install libxcb-keysyms1-dev:i386
Paste the below in the linux terminal program and press enter (the part in quotes, but don't paste the quotes, note that this a sample one can edit it for their system):
"meson setup build32 --cross-file gcc-i686 --libdir /usr/lib/i386-linux-gnu -Ddri3=enabled \
-Dprefix=/usr \
-Dglx=dri \
-Degl=enabled \
-Dgbm=enabled \
-Dgallium-vdpau=disabled \
-Dvalgrind=disabled \
-Dgallium-drivers=virgl \
-Dvulkan-drivers=virtio \
-Dvulkan-layers=device-select"
Type or paste the following cmd in the linux terminal program (the compiling/installation process may take some time):
sudo ninja -C build32 install
If you need to rebuild the 32 bit mesa driver, just delete the build32 folder which is inside the mesa folder and repaste the build/install cmdlines.
Example: sudo rm -rf build32
Type or paste the following cmd(s) into the linux terminal program:
sudo apt-get install vulkan-tools
You can then list your installed vulkan drivers with the cmd below:
ls /usr/share/vulkan/icd.d/
You should see "virtio_icd.x86_64.json"and
"virtio_icd.i686.json"
To test drivers:
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/virtio_icd.i686.json:/usr/share/vulkan/icd.d/virtio_icd.x86_64.json vkcube
For permanent 32/64 bit driver(no need to enter the above command with every program you want to use vulkan driver).
Type/paste the following cmd:
sudo nano /etc/environment
In the text file paste the below:
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/virtio_icd.i686.json:/usr/share/vulkan/icd.d/virtio_icd.x86_64.json
Press ctrl+x, press the "y" key and press enter to save.
Try typing "vulkaninfo" without quotes to get vulkan driver information.
The command "vulkaninfo | grep driverName" should return something like this:
driverName = venus
driverName = venus
If you enter the below "vkcube" without quotes in the linux terminal program, you should see something like below, and also a spinning cube:
usulyre@penguin:~$ vkcube
Selected GPU 0: Virtio-GPU Venus (AMD RADV STONEY), type: 1
On an intel based chromebook:
usulyre@penguin:~$ vkcube
Selected GPU 0: Virtio-GPU Venus (Intel(R) UHD Graphics 600 (GLK 2)), type: 1
If vkcube doesn't work, either restart the chromebook and go to crosh enter your vmc start cmdline and try vkcube again in terminal or go to crosh and type "exit" and then after that in crosh type "vmc stop termina" then you enter your vmc start cmdline and try vkcube again in termina.
Useful/optional flags in "chrome://flags:"
chrome://flags/#exo-ordinal-motion
Some notes:
There may be bugs, errors, etc. You can update the driver by deleting the mesa folder and use git clone to redownload the latest version of the driver,then go to the mesa folder and build/install the driver. Or go to the mesa folder and type without quotes "git pull origin" which will pull the newest updates to mesa to your system. You can then run the install cmds which should incorporate the newest updates. No need to redownload the dependencies, etc.
For an FPS counter vulkan apps only: add to /etc/environment this "VK_INSTANCE_LAYERS=VK_LAYER_MESA_overlay" without quotes.
For Lutris:
After installing Lutris you need to go to the mesa folder and run the install cmds again:
cd mesa
sudo ninja -C build64 install
sudo ninja -C build32 install
@livexia
Copy link

livexia commented Jan 20, 2024

How did you get llvm:i386 and llvm-dev:i386 to install? For me it removes python3-mako, etc. and I can't get past the configuration part.

I think my soultion for my problem is wrong, but beacuse I din't have python3 install from the apt source so the problem is not occur on my machine, but you are right the conflict is true. I didn't create a new crostini container, maybe this is the reason why it's different for me.

I had been skipping llvm 32 bit and the driver does compile/install, but I don't know if not compiling/installing has any effect.

Yeah, I agree with you, after fail to compile the 32bit driver, I run the vkcube and vulkaninfo, they show the expect output. I think my tested game is also able to run with the vulkan 64bit driver. So I don't think I need the 32bit driver, maybe some old 32bit game will need 32 bit driver.

@livexia
Copy link

livexia commented Mar 18, 2024

Here's the corrected version of your text:

"Last time, due to dependency conflicts, I removed the llvm:i386 and llvm-dev:i386 packages. Afterward, I assumed everything would work as normal. However, today when I attempted to launch Steam, it displayed an error stating it was unable to locate the DRI driver. I then tried updating the Mesa repository and meson from the sid source, and recompiled the 64-bit driver, but Steam still wouldn't launch. Subsequently, I attempted to compile the 32-bit driver, only to encounter the same problem: /usr/bin/ld: cannot find -lLLVM-14: No such file or directory.

To address this properly, I decided to change llvm-config to llvm-config-15 in the file ~/.local/share/meson/cross/gcc-i686. The version of llvm-config should match the LLVM version used when compiling the 64-bit driver. This resolved the compilation issue for the 32-bit driver. After installing the 32-bit driver, Steam ran perfectly.

It seems the complication arises from having two versions of LLVM on my system. While the default version is llvm-14, the 64-bit driver compilation seems to be using llvm-15, though I'm unsure why. Perhaps examining the meson.build file under the Mesa folder could shed some light on this issue.

Additionally, with meson version 1.4.0, it specifies that 'pkgconfig' should be 'pkg-config' in the file '~/.local/share/meson/cross/gcc-i686'."

Hope this will help others, have a nice day.

@Usulyre
Copy link
Author

Usulyre commented Mar 20, 2024

Here's the corrected version of your text:

"Last time, due to dependency conflicts, I removed the llvm:i386 and llvm-dev:i386 packages. Afterward, I assumed everything would work as normal. However, today when I attempted to launch Steam, it displayed an error stating it was unable to locate the DRI driver. I then tried updating the Mesa repository and meson from the sid source, and recompiled the 64-bit driver, but Steam still wouldn't launch. Subsequently, I attempted to compile the 32-bit driver, only to encounter the same problem: /usr/bin/ld: cannot find -lLLVM-14: No such file or directory.

To address this properly, I decided to change llvm-config to llvm-config-15 in the file ~/.local/share/meson/cross/gcc-i686. The version of llvm-config should match the LLVM version used when compiling the 64-bit driver. This resolved the compilation issue for the 32-bit driver. After installing the 32-bit driver, Steam ran perfectly.

It seems the complication arises from having two versions of LLVM on my system. While the default version is llvm-14, the 64-bit driver compilation seems to be using llvm-15, though I'm unsure why. Perhaps examining the meson.build file under the Mesa folder could shed some light on this issue.

Additionally, with meson version 1.4.0, it specifies that 'pkgconfig' should be 'pkg-config' in the file '~/.local/share/meson/cross/gcc-i686'."

Hope this will help others, have a nice day.

Hi, regarding llvm-config, I'm not able to install llvm-16:i386 if llvm-16 is installed, it keeps saying that it wants to remove llvm-16 and some python packages.

I tried to use llvm-config-16 in crossfile but compiling error happens when almost finished. I believe this has something to do with not having llvm-16:i386 installed.

For pkgconfig changed to pkg-config, I can change that.

@livexia
Copy link

livexia commented Mar 21, 2024

The default llvm version is llvm-14 in my system. The 64 bit driver compiles perfectly but I notice ninja using llvm-15 instead of using default llvm-14 when compile the 64 bit driver.In the cross compile file the llvm-config is llvm-config-14. If I use llvm-config(llvm-config-14), compile 32 bit driver will failed when almost finished.

First time I installed the llvm-14:i386 but as you said, it introduced package conflicts.So I think solve the 32 bit drive compile fail by installing the llvm:i386 pakckage is wrong. I think compile the 32 bit driver does not need llvm:i386.

So this time I change llvm-config to llvm-config-15, make sure using the same llvm version when complie 64 bit driver and 32 bit driver. After that, both compiles success.Due to my limited understanding of cross compile, I am not sure this solution is right, maybe this solution works only in my system.

pkgconfig change see: https://mesonbuild.com/Release-notes-for-1-3-0.html#machine-files-pkgconfig-field-deprecated-and-replaced-by-pkgconfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment