Files
DroidDeck/tools/upscale/layer/build-glibc.sh
T
The412Banner 74ece6c854 upscale: port Winlator-NeuralScale r5 (non-root parts)
Layer and bridges updated from Winlator-NeuralScale 71c140d9 (michaelisomer-cyber, GPL-3.0):
- full FSR 4.1 on the NPU (S8 graph, U8 fallback), compiled on the device per HTP arch
- ghosting fix: blank far depth when a game sends none, binding 11 bound with 62
- FSR 4.1.2 Lite S8/U8 zero-copy graphs
- Snapdragon GSR 2 on the GPU (new engine sgsr2_gpu)
- D3D11 DLSS through DXVK's interop (nvngx D3D11 entry points)

Left out on purpose: upstream's root-only performance/thermal manager, GPU clock floor and
bypass charging. Kept from DroidDeck: NPU detection by the app (DROIDDECK_UPSCALE_NPU, any HTP
generation incl. the phone's own QNN libraries) instead of upstream's SoC list, DD env names and
log tags, Intel XeSS 3 (runtime still fetched from a0ab6b0f, upstream dropped it in cb3ae04e).

FSR 4.0 on the NPU is gone upstream; the engine id becomes fsr4_1_full_npu and saved
fsr4_0_npu choices map to it. The full-FSR-4-on-Turnip guard is now opt-in
(DROIDDECK_UPSCALE_FULL_OFF_ON_TURNIP=1), since upstream's binding-11 fix targets that black frame.
Data files re-pinned to 71c140d9 (81 core + 8 NPU, sha256 checked).
2026-12-04 18:52:36 -05:00

53 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Builds VK_LAYER_DROIDDECK_upscale for the arm64 glibc guest (PRoot mode): tools/upscale/layer/build-glibc.sh OUT
# DD_UPSCALE_NO_ANDROID leaves out AHardwareBuffer, FastRPC, QNN and liblog, so NPU backends use their GPU fallbacks.
# OUT gets libVkLayer_droiddeck_upscale.so and VK_LAYER_DROIDDECK_upscale.json (absolute guest library_path).
# -Bsymbolic: the layer exports vkGetInstanceProcAddr; without it a libvulkan already in the global scope
# wins the lookup and the loader gets its own trampoline back ("Failed to find 'vkCreateInstance'").
set -euo pipefail
here=$(cd "$(dirname "$0")" && pwd)
repo=$(cd "$here/../../.." && pwd)
out=${1:?usage: tools/upscale/layer/build-glibc.sh OUT}
case "$out" in /*) ;; *) out="$PWD/$out" ;; esac
guest_lib=${DD_UPSCALE_GUEST_LIB:-/usr/local/lib/droiddeck-upscale-layer/libVkLayer_droiddeck_upscale.so}
cc=${CC:-aarch64-linux-gnu-gcc}
strip=${STRIP:-aarch64-linux-gnu-strip}
vkinc=${VK_INCLUDE:-}
if [ -z "$vkinc" ]; then
ndks=("${NDK:-}" "${ANDROID_NDK_HOME:-}" "${ANDROID_NDK_LATEST_HOME:-}")
sdk_ndks=("${ANDROID_HOME:-$HOME/Library/Android/sdk}"/ndk/*)
for ((i = ${#sdk_ndks[@]} - 1; i >= 0; i--)); do ndks+=("${sdk_ndks[i]}"); done
for ndk in "${ndks[@]}"; do
[ -n "$ndk" ] && [ -d "$ndk" ] || continue
for cand in "$ndk"/toolchains/llvm/prebuilt/*/sysroot/usr/include; do
if [ -f "$cand/vulkan/vulkan_android.h" ]; then vkinc=$cand; break 2; fi
done
done
fi
[ -n "$vkinc" ] && [ -f "$vkinc/vulkan/vulkan_core.h" ] && [ -f "$vkinc/vulkan/vulkan_android.h" ] || {
echo "tools/upscale/layer/build-glibc.sh: no Vulkan headers (set VK_INCLUDE)" >&2; exit 1; }
command -v "$cc" >/dev/null || { echo "tools/upscale/layer/build-glibc.sh: $cc not found (set CC)" >&2; exit 1; }
work="$repo/build/upscale-layer"
rm -rf "$work" && mkdir -p "$work/include" "$work/out"
# Only the Vulkan headers: the NDK sysroot's libc headers must not shadow glibc's.
cp -R "$vkinc/vulkan" "$work/include/"
if [ -d "$vkinc/vk_video" ]; then cp -R "$vkinc/vk_video" "$work/include/"; fi
"$cc" -std=gnu11 -shared -fPIC -O2 -Wall -Wextra -Wno-unused-function -Wno-missing-field-initializers \
-fvisibility=hidden -pthread -Wl,-z,defs -Wl,-Bsymbolic -DDD_UPSCALE_NO_ANDROID -I"$work/include" -I"$here" \
-o "$work/out/libVkLayer_droiddeck_upscale.so" \
"$here/fsr4_layer.c" "$here/fsr4_pipeline.c" "$here/fsr4_builtin.c" "$here/fsr412_lite.c" \
"$here/fsr411_full_gpu.c" "$here/fsr3_gpu.c" "$here/sgsr2_gpu.c" "$here/fsr4_qnn.c" -lm -ldl
"$strip" --strip-unneeded "$work/out/libVkLayer_droiddeck_upscale.so"
sed "s|\"library_path\": \"[^\"]*\"|\"library_path\": \"$guest_lib\"|" \
"$here/VK_LAYER_DROIDDECK_upscale.json" > "$work/out/VK_LAYER_DROIDDECK_upscale.json"
grep -q "\"library_path\": \"$guest_lib\"" "$work/out/VK_LAYER_DROIDDECK_upscale.json"
mkdir -p "$out"
cp "$work/out/libVkLayer_droiddeck_upscale.so" "$work/out/VK_LAYER_DROIDDECK_upscale.json" "$out/"
echo "built $out"