Skip to content

Instantly share code, notes, and snippets.

@jmcerrejon
Last active July 14, 2020 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmcerrejon/cfc4deb6507f529e60243125b6ba64e0 to your computer and use it in GitHub Desktop.
Save jmcerrejon/cfc4deb6507f529e60243125b6ba64e0 to your computer and use it in GitHub Desktop.
Install vulkan driver (experimental) no wayland (check comments). Just for testing
#!/bin/bash -ex
#
# Description : Vulkan driver (EXPERIMENTAL)
# Author : Jose Cerrejon Gonzalez (ulysess@gmail_dot._com)
# Version : 1.0.0 (14/Jul/20)
# Compatible : Raspberry Pi 4
#
# Info : Thks to PI Labs
# Help : https://ninja-build.org/manual.html#ref_pool
# : https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=276412&start=25#p1678723
# : https://blogs.igalia.com/apinheiro/2020/06/v3dv-quick-guide-to-build-and-run-some-demos/
#
. ./scripts/helper.sh || . ./helper.sh || wget -q 'https://github.com/jmcerrejon/PiKISS/raw/master/scripts/helper.sh'
clear
check_board || { echo "Missing file helper.sh. I've tried to download it for you. Try to run the script again." && exit 1; }
SOURCE_CODE_URL="https://gitlab.freedesktop.org/apinheiro/mesa.git"
SOURCE_CODE_DEMOS_URL="https://github.com/SaschaWillems/Vulkan.git"
BIN_DEMOS_URL="https://www.dropbox.com/s/d1phg4bss26txg8/demos_vulkan.tar.gz?dl=0"
CORES=$(nproc --all)
install() {
echo -e "\nInstalling,...\n"
cd "$HOME"/mesa
sudo ninja -C build install
echo
glxinfo -B
}
binary_only() {
echo -e "\nInstalling deps...\n"
sudo apt install -y ninja-build
install
}
install_meson() {
echo -e "\nInstalling meson...\n"
sudo apt-get remove -y meson
sudo pip3 install meson --force-reinstall
}
install_full_deps() {
echo -e "\nInstalling deps...\n"
sudo apt-get install -y libxcb-randr0-dev libxrandr-dev \
libxcb-xinerama0-dev libxinerama-dev libxcursor-dev \
libxcb-cursor-dev libxkbcommon-dev xutils-dev \
xutils-dev libpthread-stubs0-dev libpciaccess-dev \
libffi-dev x11proto-xext-dev libxcb1-dev libxcb-*dev \
bison flex libssl-dev libgnutls28-dev x11proto-dri2-dev \
x11proto-dri3-dev libx11-dev libxcb-glx0-dev \
libx11-xcb-dev libxext-dev libxdamage-dev libxfixes-dev \
libva-dev x11proto-randr-dev x11proto-present-dev \
libclc-dev libelf-dev git build-essential mesa-utils \
libvulkan-dev ninja-build libvulkan1 python-mako \
libdrm-dev libxshmfence-dev libxxf86vm-dev \
python3-mako wayland-protocols libwayland-egl-backend-dev \
cmake libassimp-dev
install_meson
}
clone_repo() {
echo -e "\nCloning mesa repo...\n"
cd "$HOME"
git clone --single-branch --branch wip/igalia/v3dv "$SOURCE_CODE_URL" mesa && cd "$_"
}
update_repo() {
cd "$HOME"/mesa
git fetch --all
git reset --hard origin/wip/igalia/v3dv
}
compile() {
if [[ -d "$HOME"/mesa ]]; then
echo -e "\nDirectory exists, downloading the latest changes...\n"
update_repo
else
install_full_deps
clone_repo
fi
if [[ -d "$HOME"/mesa/build ]]; then
rm -rf "$HOME"/mesa/build
fi
meson --prefix /usr -Dplatforms=x11,drm,surfaceless,wayland -Dvulkan-drivers=broadcom -Ddri-drivers= -Dgallium-drivers=v3d,kmsro,vc4,zink -Dbuildtype=release build
echo -e "\nCompiling... Estimated time on Raspberry Pi 4 (Not overclocked): ~12 min. \n"
ninja -C build -j"${CORES}"
install
download_demos
}
download_demos() {
if [[ -d "$HOME"/mesa/demos ]]; then
return 1
fi
echo -e "\nDownloading demos...\n"
wget -4 -qO- -O "$HOME"/mesa/demos_vulkan.tar.gz "$BIN_DEMOS_URL" && tar -xz "$HOME"/mesa/demos_vulkan.tar.gz && rm "$HOME"/mesa/demos_vulkan.tar.gz
}
# TODO Not working yet: make: *** Error [Makefile:84: all] Error 2
compile_demos() {
cd "$HOME"/mesa
if [[ -d "$HOME"/mesa/demos ]]; then
return 1
fi
echo
read -p "Do you want to download & compile Vulkan demos (Y/n)? " response
if [[ $response =~ [Nn] ]]; then
return 1
fi
echo -e "\nCloning Vulkan demos repo...\n"
git clone --recursive "$SOURCE_CODE_DEMOS_URL" demos && cd "$_"
# git submodule init
# git submodule update
python3 download_assets.py
mkdir -p build && cd "$_"
cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_WAYLAND_WSI=ON ..
echo -e "\nCompiling... Estimated time on Raspberry Pi 4 (Not overclocked): ~10-15 min. \n"
make -j"${CORES}"
echo -e "\nDone.\n"
}
compile
exitMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment