Improve GPU compatibility, RDNA2 kernels and startup diagnostics
- Match render/compute adapters and gate RR models by GPU capabilities - Add RDNA2 native texture kernels and fix FP16 rounding - Harden model builds, cache validation and packaging - Add startup tracing, timeouts, documentation and regression tests
This commit is contained in:
1 parent
ca93d0fbf7
commit
2558fcbd39
32 files changed
+1131
-81
No files matched your search
@@ -6,6 +6,7 @@ set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
MINGW_CXX="${MINGW_CXX:-x86_64-w64-mingw32-g++}"
|
||||
CLANG_CL="${CLANG_CL:-clang-cl}"
|
||||
BUILD_ID="$(bash "$ROOT/scripts/runtime_build_id.sh")"
|
||||
|
||||
VULKAN_INCLUDE="${VULKAN_INCLUDE:-/usr/include}"
|
||||
|
||||
@@ -22,7 +23,7 @@ PARAM_OBJECT="$ROOT/build/d4r_ngx_param_msvc.obj"
|
||||
"$CLANG_CL" --target=x86_64-pc-windows-msvc /nologo /std:c++20 /O2 /c /GS- /GR- /EHs-c- /Zl \
|
||||
"/Fo$PARAM_OBJECT" -- "$ROOT/tools/d4r_ngx_param_msvc.cpp"
|
||||
# The engine (D4R_ENGINE) reaches Vulkan through a function table: MinGW has no Vulkan import library.
|
||||
"$MINGW_CXX" -std=c++20 -O2 -Wall -Wextra -Wno-missing-field-initializers -DD4R_ENGINE_VK_TABLE -I"$ROOT/build/vulkan-include" -I"$ROOT/build/vulkan-staging" -shared -static -static-libgcc -static-libstdc++ \
|
||||
"$MINGW_CXX" -std=c++20 -O2 -Wall -Wextra -Wno-missing-field-initializers -DD4R_ENGINE_VK_TABLE "-DD4R_RUNTIME_BUILD_ID=\"$BUILD_ID\"" -I"$ROOT/build/vulkan-include" -I"$ROOT/build/vulkan-staging" -shared -static -static-libgcc -static-libstdc++ \
|
||||
"$ROOT/tools/d4r_nvngx_shim.cpp" "$ROOT/tools/d4r_ngx_param_host.cpp" "$PARAM_OBJECT" \
|
||||
"$ROOT/engine/runtime.cpp" "$ROOT/engine/game.cpp" "$ROOT/engine/game_m.cpp" "$ROOT/engine/game_rr.cpp" "$ROOT/engine/vk_dispatch.cpp" \
|
||||
-ldxgi -lbcrypt -Wl,--entry,d4r_dll_entry -o "$ROOT/build/d4r_nvngx.dll"
|
||||
|
||||
@@ -76,8 +76,14 @@ export D4R_DLSS_PTX_DIR="$BUILD/ptx"
|
||||
python3 "$ROOT/kernels/tools/extract_dlss_ptx.py" "$D4R_BUNDLE_DLSS" "$D4R_DLSS_PTX_DIR" > "$BUILD/logs/extract.log"
|
||||
build_textures() {
|
||||
local arch="$1" folder fp8 accuracy out
|
||||
# RDNA2 has no texture tails (they need WMMA); package_release.sh builds its K layers
|
||||
[[ "$arch" == gfx103* ]] && return 0
|
||||
# RDNA2: only K's natively translated hiluma output/input kernels (no WMMA), fast set only (the accuracy
|
||||
# set keeps ZLUDA's compile of them); package_release.sh builds the K layers and copies these
|
||||
if [[ "$arch" == gfx103* ]]; then
|
||||
D4R_PREFER_ACCURACY=0 D4R_GPU_ARCH="$arch" D4R_DLSS_DLL="$D4R_BUNDLE_DLSS" \
|
||||
"$ROOT/kernels/build.sh" tex "$D4R_BUNDLE_TEX/$arch" > "$BUILD/logs/tex-$arch-0.log" 2>&1
|
||||
echo "Texture kernels rebuilt: $arch (native hiluma output/input only)"
|
||||
return 0
|
||||
fi
|
||||
folders=("$arch")
|
||||
[[ "$arch" == gfx12* ]] && folders+=("$arch-fp8")
|
||||
for folder in "${folders[@]}"; do
|
||||
|
||||
@@ -5,6 +5,7 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
WINEGCC="${WINEGCC:-winegcc}"
|
||||
WINEBUILD="${WINEBUILD:-winebuild}"
|
||||
BRIDGE_ROOT="$ROOT/build/wine-nvcuda"
|
||||
BUILD_ID="$(bash "$ROOT/scripts/runtime_build_id.sh")"
|
||||
|
||||
mkdir -p "$BRIDGE_ROOT/x86_64-unix" "$BRIDGE_ROOT/x86_64-windows"
|
||||
MOTION_FLAGS=()
|
||||
@@ -13,6 +14,7 @@ if [[ -x "${D4R_ROCM_DIR:-/opt/rocm}/lib/llvm/bin/clang++" ]]; then
|
||||
MOTION_FLAGS=(-DD4R_MOTION_KERNELS -I"$BRIDGE_ROOT/generated")
|
||||
fi
|
||||
"$WINEGCC" -m64 -shared -o "$BRIDGE_ROOT/x86_64-unix/nvcuda.dll" \
|
||||
"-DD4R_RUNTIME_BUILD_ID=\"$BUILD_ID\"" \
|
||||
"${MOTION_FLAGS[@]}" \
|
||||
"$ROOT/tools/wine_nvcuda_bridge.c" \
|
||||
-Wb,--export="$ROOT/tools/wine_nvcuda_bridge.spec" -ldl -lpthread
|
||||
|
||||
@@ -206,6 +206,12 @@ def main(argv):
|
||||
env["D4R_SHIM_MARKER_POLL_US"] = value
|
||||
|
||||
value = flag("Engine", "Enabled")
|
||||
if value is None:
|
||||
models = Path(os.environ.get("D4R_RUNTIME_DIR", path.parent)) / "engine"
|
||||
value = any((models / model).is_dir() for model in
|
||||
("k", "k-ldr", "m", "m-ldr", "l", "l-ldr", "rr-d", "rr-e", "rr-f",
|
||||
"rr-d-gfx11", "rr-e-gfx11"))
|
||||
env["D4R_ENGINE_K"] = "0"
|
||||
env["D4R_ENGINE"] = "1" if value else "0"
|
||||
if path_value("Engine", "ModelDir"):
|
||||
env["D4R_ENGINE_MODEL_DIR"] = path_value("Engine", "ModelDir")
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
# D4R_ROCM_RUNTIME ROCm runtime bundled as d4r/rocm (scripts/fetch_rocm_runtime.sh)
|
||||
# default ~/.cache/d4r-rocm-runtime
|
||||
# D4R_MAX_GLIBC highest GLIBC ABI the Linux libraries may require default 2.41
|
||||
# D4R_GPU_ARCHS GPU targets to build kernels for default gfx1030-gfx1036 (K only), gfx1100-gfx1103, gfx1200, gfx1201
|
||||
# D4R_GPU_ARCHS GPU targets to build kernels for default gfx1030-gfx1036 (K and its hiluma kernels only),
|
||||
# gfx1100-gfx1103, gfx1200, gfx1201
|
||||
# (RDNA4 targets also get a <target>-fp8 folder: the kernels for d4r.ini NativeFp8 = on)
|
||||
# D4R_OPTISCALER_LICENSE OptiScaler's LICENSE (GPL-3.0) text; default: system SPDX or common-licenses copy
|
||||
# D4R_VKD3D_SRC vkd3d-proton source checkout, for its license files default ~/.cache/d4r-vkd3d-proton
|
||||
@@ -216,15 +217,30 @@ ensure_rr_textures() {
|
||||
fi
|
||||
}
|
||||
build_target() {
|
||||
local folder="$1" arch fp8 tex_dir accurate accurate_tex f
|
||||
local folder="$1" arch fp8 tex_dir tmp_tex accurate accurate_tex f
|
||||
arch="${folder%-fp8}"
|
||||
fp8=0
|
||||
[[ "$folder" == *-fp8 ]] && fp8=1
|
||||
# RDNA2 (gfx103x): only DLSS 4's layers (preset K) have native kernels there, built with software matrix
|
||||
# products (kernels/common/wmma_layout.h); M, L, the texture tails and Ray Reconstruction stay translated by ZLUDA
|
||||
# RDNA2 (gfx103x): DLSS 4's layers (preset K), built with software matrix products
|
||||
# (kernels/common/wmma_layout.h), and K's hiluma output/input kernels translated from the PTX
|
||||
# (kernels/native, no WMMA; wave32, byte-identical to ZLUDA's compile). M, L, the texture tails and Ray
|
||||
# Reconstruction call WMMA and stay translated by ZLUDA. The accuracy set keeps ZLUDA's compile of hiluma.
|
||||
if [[ "$arch" == gfx103* ]]; then
|
||||
D4R_PREFER_ACCURACY=0 D4R_ROCM_DIR="$ROCM" D4R_GPU_ARCH="$arch" "$ROOT/kernels/build.sh" k "$STAGE/d4r/kernels/$folder" >/dev/null
|
||||
D4R_PREFER_ACCURACY=1 D4R_ROCM_DIR="$ROCM" D4R_GPU_ARCH="$arch" "$ROOT/kernels/build.sh" k "$STAGE/d4r/kernels/accuracy/$folder" >/dev/null
|
||||
if [[ "$VARIANT" != clean ]]; then
|
||||
tex_dir="$D4R_BUNDLE_TEX/$folder" tmp_tex=""
|
||||
if [[ ! -d "$tex_dir" ]]; then
|
||||
tex_dir="$(mktemp -d)" tmp_tex="$tex_dir"
|
||||
D4R_PREFER_ACCURACY=0 D4R_ROCM_DIR="$ROCM" D4R_GPU_ARCH="$arch" D4R_DLSS_DLL="$D4R_BUNDLE_DLSS" \
|
||||
"$ROOT/kernels/build.sh" tex "$tex_dir" >/dev/null
|
||||
fi
|
||||
# only the kernels validated for RDNA2, whatever else an older bundle folder holds
|
||||
for f in "$tex_dir"/hiluma_engine_output_*_hdr_max_v2_rel.hsaco "$tex_dir"/hiluma_engine_input_*_v2_rel.hsaco; do
|
||||
[[ -f "$f" ]] && cp "$f" "$STAGE/d4r/kernels/$folder/"
|
||||
done
|
||||
[[ -z "$tmp_tex" ]] || rm -rf "$tmp_tex"
|
||||
fi
|
||||
rm -f "$STAGE/d4r/kernels/$folder"/*.resolution.txt "$STAGE/d4r/kernels/accuracy/$folder"/*.resolution.txt
|
||||
python3 "$ROOT/kernels/tools/kernel_manifest.py" "$STAGE/d4r/kernels/$folder" "${DLLS[@]}" "${RR_DLLS[@]}"
|
||||
python3 "$ROOT/kernels/tools/kernel_manifest.py" "$STAGE/d4r/kernels/accuracy/$folder" "${DLLS[@]}" "${RR_DLLS[@]}"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
|
||||
revision=$(git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||
sources=$(sha256sum tools/*.h tools/d4r_nvngx_shim.cpp tools/d4r_vulkan_frontend.inl tools/wine_nvcuda_bridge.c \
|
||||
engine/*.h engine/*.cpp engine/*.inc | sha256sum | cut -c1-16)
|
||||
printf '%s-%s\n' "$revision" "$sources"
|
||||
@@ -47,5 +47,6 @@ cp "$GL/bin/glslangValidator" "$KIT/bin/glslangValidator"
|
||||
chmod +x "$KIT/bin/glslangValidator"
|
||||
cp "$D4R_GLSLANG_LICENSE" "$D4R/licenses/glslang-LICENSE.txt"
|
||||
cp "$ROOT/packaging/build_engine_models.sh" "$D4R/tools/build-engine-models.sh"
|
||||
cp "$ROOT/packaging/model_tools.py" "$KIT/model_tools.py"
|
||||
chmod +x "$D4R/tools/build-engine-models.sh"
|
||||
printf 'Staged the engine-model builder in %s (%s)\n' "$D4R/tools" "$(du -sh "$D4R/tools" | cut -f1)"
|
||||
Reference in new issue
Block a user