Skip to content

Instantly share code, notes, and snippets.

@baryluk
Last active October 29, 2023 18:20
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 baryluk/492aa2c90343cb6eac1384c082e5005b to your computer and use it in GitHub Desktop.
Save baryluk/492aa2c90343cb6eac1384c082e5005b to your computer and use it in GitHub Desktop.
amdvlk portable non-root
#!/bin/bash
set -e
set -x
# TODO(baryluk): Standard depencies required: cmake, ninja, repo, git, gcc/g++, wayland-client, libxcb, libxml2, python3, perl, llvm
# Optional: valgrind, go, ocaml.
# I think the llvm actually doesn't need to be installed, because it is a part of downloaded and patched repo.
cd "${HOME}"
mkdir -p "${HOME}/amdvlk"
cd "${HOME}/amdvlk"
repo init --partial-clone --depth=1 -u "https://github.com/GPUOpen-Drivers/AMDVLK.git" -b master
# TODO(baryluk): repo init still asks interactively for email and name during init, if these are not set in global git config.
repo sync --no-clone-bundle --no-tags -j$(nproc)
cmake -GNinja -Sdrivers/xgl/ -Bdrivers/xgl/builds/Release64
ninja -C drivers/xgl/builds/Release64
cmake -GNinja -Sdrivers/xgl/ -Bdrivers/xgl/builds/Release32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32
ninja -C drivers/xgl/builds/Release32
cmake -GNinja -Sdrivers/xgl/ -Bdrivers/xgl/builds/Debug64 -DCMAKE_BUILD_TYPE=Debug -DLLVM_PARALLEL_LINK_JOBS=4
ninja -C drivers/xgl/builds/Debug64
cmake -GNinja -Sdrivers/xgl/ -Bdrivers/xgl/builds/Debug32 -DCMAKE_BUILD_TYPE=Debug -DLLVM_PARALLEL_LINK_JOBS=4 -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32
ninja -C drivers/xgl/builds/Debug32
sed -e 's,/usr/lib/i386-linux-gnu/,,' "${HOME}/amdvlk/drivers/AMDVLK/json/Ubuntu/amd_icd32.json" > "${HOME}/amd_icd32.json"
sed -e 's,/usr/lib/x86_64-linux-gnu/,,' "${HOME}/amdvlk/drivers/AMDVLK/json/Ubuntu/amd_icd64.json" > "${HOME}/amd_icd64.json"
cat > "${HOME}/amdvlk-opt" <<EOF
#!/bin/sh
export LD_LIBRARY_PATH="${HOME}/amdvlk/drivers/xgl/builds/Release64/icd/:${HOME}/amdvlk/drivers/xgl/builds/Release32/icd/:\${LD_LIBRARY_PATH}"
#export VK_ICD_FILENAMES="${HOME}/amd_icd64.json:${HOME}/amd_icd32.json:\${VK_ICD_FILENAMES}"
export VK_ICD_FILENAMES="${HOME}/amd_icd64.json:${HOME}/amd_icd32.json"
exec "\$@"
EOF
chmod +x "${HOME}/amdvlk-opt"
cat > "${HOME}/amdvlk-dbg" <<EOF
#!/bin/sh
export LD_LIBRARY_PATH="${HOME}/amdvlk/drivers/xgl/builds/Debug64/icd/:${HOME}/amdvlk/drivers/xgl/builds/Debug32/icd/:\${LD_LIBRARY_PATH}"
#export VK_ICD_FILENAMES="${HOME}/amd_icd64.json:${HOME}/amd_icd32.json:\${VK_ICD_FILENAMES}"
export VK_ICD_FILENAMES="${HOME}/amd_icd64.json:${HOME}/amd_icd32.json"
exec "\$@"
EOF
chmod +x "${HOME}/amdvlk-dbg"
echo "Done"
exit 0
@baryluk
Copy link
Author

baryluk commented Oct 29, 2023

Note: This script is a bit outdated. You will need to compile DirectXShaderCompiler first (64-bit is enough, we only need dxc tool during compilation to convert some ray tracing shaders).

Make sure to use version of DXC that is supported (check amdvlk README which version is supported, as newer versions might not work, or throw errors with amdvlk current rt pipelines code - this will be fixed eventually). If you use newer compiler like gcc 13.x, you might need to do a bit of patching (modifying Version.h to have #include <cstdint>), and pass few extra options to cmake to gcc to not emit errors/warnings in few places. Then it builds on modern gcc.

After that, install dxc, or make it available in your PATH. amdvlk should then build without issues. You might adjust the sed slightly, as some paths to json icd files changed.

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