diff --git a/util/spirv-plugins/README.md b/util/spirv-plugins/README.md new file mode 100644 index 000000000..150d8a917 --- /dev/null +++ b/util/spirv-plugins/README.md @@ -0,0 +1,10 @@ +# SPIR-V open source plugins build + +These scripts are used to build the latest versions of glslang, SPIRV-Cross and SPIRV-Tools for distribution as plugins. On windows this is just a regular build really, on linux it will build in the renderdoc docker with static linking, to ensure maximum compatibility. + +**Most users don't need to build this.**. The pre-built latest plugins packages are provided online which are included in every build, that you can download yourself: + +* Windows: https://renderdoc.org/plugins.zip +* Linux: https://renderdoc.org/plugins.tgz + +These scripts are just here so that a RenderDoc developer can update the plugins when needed. diff --git a/util/spirv-plugins/_build.sh b/util/spirv-plugins/_build.sh new file mode 100644 index 000000000..b989e4d7f --- /dev/null +++ b/util/spirv-plugins/_build.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +PLATFORM=$1 +OUT=$2 + +set -ex + +# Freshly clone repositories +rm -rf glslang SPIRV-Cross +git clone https://github.com/KhronosGroup/glslang +git clone https://github.com/KhronosGroup/SPIRV-Cross + +GENERATOR="Unix Makefiles" + +if [ "$PLATFORM" == "win64" ]; then + GENERATOR="Visual Studio 15 2017 Win64"; +elif [ "$PLATFORM" == "win32" ]; then + GENERATOR="Visual Studio 15 2017"; +else + export CC=clang CXX=clang++ CFLAGS="-fPIC -fvisibility=hidden" LDFLAGS="-static-libstdc++" +fi + +##### SPIRV-Cross + +pushd SPIRV-Cross + + mkdir build + pushd build + + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${OUT}" + + if [ "${PLATFORM:0:3}" == "win" ]; then + cmake --build . --config Release --target install + else + make -j$(nproc) install + fi + + popd #build + +popd # SPIRV-Cross + + +##### glslang (and bonus SPIRV-Tools for free) +pushd glslang + + # Update external sources + python update_glslang_sources.py + + # Now build + mkdir build + pushd build + + # Hack for now until there's a cmake option to turn this off. + export CXXFLAGS="-USPIRV_TIMER_ENABLED" + + cmake .. -DSPIRV_SKIP_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${OUT}" + + if [ "${PLATFORM:0:3}" == "win" ]; then + cmake --build . --config Release --target install + else + make -j$(nproc) install + fi + + popd #build + +popd # glslang + + diff --git a/util/spirv-plugins/build_spirv_plugins.sh b/util/spirv-plugins/build_spirv_plugins.sh new file mode 100644 index 000000000..1fc3132b2 --- /dev/null +++ b/util/spirv-plugins/build_spirv_plugins.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +if [ ! -f build_spirv_plugins.sh ]; then + echo "Run this script from its folder like './build_spirv_plugins.sh'"; + exit 1; +fi + +if uname -a | grep -qiE 'win|msys|cygwin|microsoft'; then + # Windows build + + echo "Building for win32"; + ./_build.sh win32 $(pwd)/spirv-plugins-win32 + + echo "Building for win64"; + ./_build.sh win64 $(pwd)/spirv-plugins-win64 +else + # Linux build + + if docker image ls | grep -q renderdoc-build; then + echo "Building for linux"; + + docker run --rm -v $(pwd):/script:ro -v $(pwd)/spirv-plugins-linux64:/out renderdoc-build bash /script/_build.sh linux64 /out + + strip --strip-unneeded spirv-plugins-linux64/bin/* + else + echo "Run normal RenderDoc build first to generate renderdoc-build image"; + exit 1; + fi +fi