d4r: official NVIDIA DLSS on AMD GPUs under Linux and Proton
This commit is contained in:
commit
118173ecd7
128 files changed
+31333
No files matched your search
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CXX="${CXX:-g++}"
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$CXX" -std=c++20 -O2 -Wall -Wextra \
|
||||
"$ROOT/tools/bench_dlss_kernel.cpp" -ldl \
|
||||
-o "$ROOT/build/bench_dlss_kernel"
|
||||
printf 'Built %s\n' "$ROOT/build/bench_dlss_kernel"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
MINGW_CXX="${MINGW_CXX:-x86_64-w64-mingw32-g++}"
|
||||
|
||||
"$ROOT/scripts/build_d4r_nvngx_shim.sh"
|
||||
"$MINGW_CXX" -std=c++20 -O2 -Wall -Wextra -static -static-libgcc -static-libstdc++ \
|
||||
"$ROOT/tools/d3d12_dlss_harness.cpp" "$ROOT/tools/d4r_ngx_param_host.cpp" "$ROOT/build/d4r_ngx_param_msvc.obj" \
|
||||
-o "$ROOT/build/d3d12_dlss_harness.exe"
|
||||
printf 'Built %s\n' "$ROOT/build/d3d12_dlss_harness.exe"
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
MINGW_CXX="${MINGW_CXX:-x86_64-w64-mingw32-g++}"
|
||||
|
||||
VULKAN_INCLUDE="${VULKAN_INCLUDE:-/usr/include}"
|
||||
|
||||
# Only the Vulkan headers from the host include tree, not its libc headers.
|
||||
mkdir -p "$ROOT/build/vulkan-include"
|
||||
ln -sfn "$VULKAN_INCLUDE/vulkan" "$ROOT/build/vulkan-include/vulkan"
|
||||
ln -sfn "$VULKAN_INCLUDE/vk_video" "$ROOT/build/vulkan-include/vk_video"
|
||||
"$MINGW_CXX" -I"$ROOT/build/vulkan-include" -std=c++20 -O2 -Wall -Wextra -Wno-missing-field-initializers -static -static-libgcc -static-libstdc++ \
|
||||
"$ROOT/tools/d3d12_hip_interop_probe.cpp" -ld3d12 -o "$ROOT/build/d3d12_hip_interop_probe.exe"
|
||||
printf 'Built %s\n' "$ROOT/build/d3d12_hip_interop_probe.exe"
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CC="${MINGW_CC:-x86_64-w64-mingw32-gcc}"
|
||||
mkdir -p "$ROOT/build"
|
||||
"$CC" -std=c11 -O2 -Wall -Wextra -shared -static-libgcc \
|
||||
"$ROOT/tools/d4r_nvapi_identity.c" -o "$ROOT/build/nvapi64.dll"
|
||||
printf 'Built %s\n' "$ROOT/build/nvapi64.dll"
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Builds build/d4r_nvngx.dll, the D3D12-to-CUDA NGX core shim loaded by
|
||||
# OptiScaler through its NvngxPath setting.
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
MINGW_CXX="${MINGW_CXX:-x86_64-w64-mingw32-g++}"
|
||||
CLANG_CL="${CLANG_CL:-clang-cl}"
|
||||
|
||||
VULKAN_INCLUDE="${VULKAN_INCLUDE:-/usr/include}"
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
# Only the Vulkan headers from the host include tree, not its libc headers.
|
||||
mkdir -p "$ROOT/build/vulkan-include"
|
||||
ln -sfn "$VULKAN_INCLUDE/vulkan" "$ROOT/build/vulkan-include/vulkan"
|
||||
ln -sfn "$VULKAN_INCLUDE/vk_video" "$ROOT/build/vulkan-include/vk_video"
|
||||
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"
|
||||
"$MINGW_CXX" -std=c++20 -O2 -Wall -Wextra -Wno-missing-field-initializers -I"$ROOT/build/vulkan-include" -shared -static -static-libgcc -static-libstdc++ \
|
||||
"$ROOT/tools/d4r_nvngx_shim.cpp" "$ROOT/tools/d4r_ngx_param_host.cpp" "$PARAM_OBJECT" \
|
||||
-o "$ROOT/build/d4r_nvngx.dll"
|
||||
printf 'Built %s\n' "$ROOT/build/d4r_nvngx.dll"
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CXX="${CXX:-g++}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-/opt/rocm}"
|
||||
|
||||
if [[ ! -f "$ROCM_ROOT/include/hip/hip_runtime_api.h" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ROCM_ROOT to a ROCm installation containing HIP headers and libamdhip64.so\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$CXX" -std=c++20 -O2 -Wall -Wextra -D__HIP_PLATFORM_AMD__=1 \
|
||||
-I"$ROCM_ROOT/include" \
|
||||
"$ROOT/tools/hip_vk_interop_probe.cpp" \
|
||||
-L"$ROCM_ROOT/lib" -lamdhip64 -lvulkan \
|
||||
-Wl,-rpath,"$ROCM_ROOT/lib" \
|
||||
-o "$ROOT/build/hip_vk_interop_probe"
|
||||
printf 'Built %s\n' "$ROOT/build/hip_vk_interop_probe"
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
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}"
|
||||
|
||||
if [[ -z "${NVSDK_NGX_INCLUDE:-}" || ! -f "$NVSDK_NGX_INCLUDE/nvsdk_ngx.h" ]]; then
|
||||
printf '%s\n' "Set NVSDK_NGX_INCLUDE to a directory containing NVIDIA's nvsdk_ngx.h and nvsdk_ngx_defs.h" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
ABI_OBJECT="$ROOT/build/ngx_param_abi_probe_msvc.obj"
|
||||
"$CLANG_CL" --target=x86_64-pc-windows-msvc /nologo /std:c++20 /O2 /c /GS- /GR- /EHs-c- /Zl \
|
||||
"/Fo$ABI_OBJECT" "$ROOT/tools/ngx_param_abi_probe_msvc.cpp"
|
||||
"$MINGW_CXX" -std=c++20 -O2 -Wall -Wextra -static -static-libgcc -static-libstdc++ \
|
||||
-I"$NVSDK_NGX_INCLUDE" \
|
||||
"$ROOT/tools/ngx_cuda_probe.cpp" "$ABI_OBJECT" \
|
||||
-o "$ROOT/build/ngx_cuda_probe.exe"
|
||||
printf 'Built %s\n' "$ROOT/build/ngx_cuda_probe.exe"
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
MINGW_CXX="${MINGW_CXX:-x86_64-w64-mingw32-g++}"
|
||||
|
||||
if [[ -z "${NVSDK_NGX_INCLUDE:-}" || ! -f "$NVSDK_NGX_INCLUDE/nvsdk_ngx.h" ]]; then
|
||||
printf '%s\n' "Set NVSDK_NGX_INCLUDE to a directory containing NVIDIA's nvsdk_ngx.h and nvsdk_ngx_defs.h" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$MINGW_CXX" -std=c++20 -O2 -Wall -Wextra -static -static-libgcc -static-libstdc++ \
|
||||
-I"$NVSDK_NGX_INCLUDE" \
|
||||
"$ROOT/tools/ngx_d3d12_probe.cpp" \
|
||||
-o "$ROOT/build/ngx_d3d12_probe.exe"
|
||||
printf 'Built %s\n' "$ROOT/build/ngx_d3d12_probe.exe"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
MINGW_CXX="${MINGW_CXX:-x86_64-w64-mingw32-g++}"
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$MINGW_CXX" -std=c++20 -O2 -Wall -Wextra -Werror \
|
||||
"$ROOT/tools/ngx_load_probe.cpp" \
|
||||
-o "$ROOT/build/ngx_load_probe.exe"
|
||||
printf 'Built %s\n' "$ROOT/build/ngx_load_probe.exe"
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
MINGW_CXX="${MINGW_CXX:-x86_64-w64-mingw32-g++}"
|
||||
|
||||
if [[ -z "${NVSDK_NGX_INCLUDE:-}" || ! -f "$NVSDK_NGX_INCLUDE/nvsdk_ngx_vk.h" ]]; then
|
||||
printf '%s\n' "Set NVSDK_NGX_INCLUDE to a directory containing NVIDIA's nvsdk_ngx_vk.h and nvsdk_ngx_defs.h" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
VULKAN_INCLUDE="${VULKAN_INCLUDE:-$(dirname "$NVSDK_NGX_INCLUDE")/vulkan/include}"
|
||||
if [[ ! -f "$VULKAN_INCLUDE/vulkan/vulkan.h" ]]; then
|
||||
printf '%s\n' "Set VULKAN_INCLUDE to a Windows-target Vulkan-Headers include root" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$MINGW_CXX" -std=c++20 -O2 -Wall -Wextra -static -static-libgcc -static-libstdc++ \
|
||||
-I"$NVSDK_NGX_INCLUDE" -I"$VULKAN_INCLUDE" \
|
||||
"$ROOT/tools/ngx_vulkan_probe.cpp" \
|
||||
-o "$ROOT/build/ngx_vulkan_probe.exe"
|
||||
printf 'Built %s\n' "$ROOT/build/ngx_vulkan_probe.exe"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CXX="${CXX:-g++}"
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$CXX" -std=c++20 -O2 -Wall -Wextra \
|
||||
"$ROOT/tools/replay_dlss_fp8_ops.cpp" -ldl \
|
||||
-o "$ROOT/build/replay_dlss_fp8_ops"
|
||||
printf 'Built %s\n' "$ROOT/build/replay_dlss_fp8_ops"
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CXX="${CXX:-g++}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-/opt/rocm}"
|
||||
if [[ ! -f "$ROCM_ROOT/include/hip/hip_runtime_api.h" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ROCM_ROOT to a ROCm installation containing HIP headers and libamdhip64.so\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$CXX" -std=c++20 -O2 -Wall -Wextra -D__HIP_PLATFORM_AMD__=1 \
|
||||
-I"$ROCM_ROOT/include" \
|
||||
"$ROOT/tools/replay_dlss_histogram.cpp" -L"$ROCM_ROOT/lib" -lamdhip64 -ldl \
|
||||
-Wl,-rpath,"$ROCM_ROOT/lib" \
|
||||
-o "$ROOT/build/replay_dlss_histogram"
|
||||
printf 'Built %s\n' "$ROOT/build/replay_dlss_histogram"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CXX="${CXX:-g++}"
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$CXX" -std=c++20 -O2 -Wall -Wextra \
|
||||
"$ROOT/tools/replay_dlss_kernel.cpp" -ldl \
|
||||
-o "$ROOT/build/replay_dlss_kernel"
|
||||
printf 'Built %s\n' "$ROOT/build/replay_dlss_kernel"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CXX="${CXX:-g++}"
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$CXX" -std=c++20 -O2 -Wall -Wextra \
|
||||
"$ROOT/tools/replay_dlss_layer.cpp" -ldl \
|
||||
-o "$ROOT/build/replay_dlss_layer"
|
||||
printf 'Built %s\n' "$ROOT/build/replay_dlss_layer"
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CXX="${CXX:-g++}"
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$CXX" -std=c++20 -O2 -Wall -Wextra \
|
||||
"$ROOT/tools/replay_dlss_surface_half_store.cpp" -ldl \
|
||||
-o "$ROOT/build/replay_dlss_surface_half_store"
|
||||
printf 'Built %s\n' "$ROOT/build/replay_dlss_surface_half_store"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CXX="${CXX:-g++}"
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$CXX" -std=c++20 -O2 -Wall -Wextra \
|
||||
"$ROOT/tools/replay_dlss_surface_store.cpp" -ldl \
|
||||
-o "$ROOT/build/replay_dlss_surface_store"
|
||||
printf 'Built %s\n' "$ROOT/build/replay_dlss_surface_store"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CXX="${CXX:-g++}"
|
||||
|
||||
mkdir -p "$ROOT/build"
|
||||
"$CXX" -std=c++20 -O2 -Wall -Wextra \
|
||||
"$ROOT/tools/replay_dlss_texture_sample.cpp" -ldl \
|
||||
-o "$ROOT/build/replay_dlss_texture_sample"
|
||||
printf 'Built %s\n' "$ROOT/build/replay_dlss_texture_sample"
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Builds vkd3d-proton with patches/vkd3d-proton/ applied (split command lists
|
||||
# for the shim's same-frame DLSS, D4R_SHIM_SPLIT_FRAME) into OUT_DIR, which
|
||||
# the game launcher takes as D4R_VKD3D_DIR.
|
||||
# usage: build_vkd3d_proton_d4r.sh OUT_DIR
|
||||
# Env: VKD3D_PROTON_SRC (clone, default ~/.cache/d4r-vkd3d-proton),
|
||||
# VKD3D_PROTON_COMMIT (default 3dfc6f07, the base GE-Proton11-3 ships).
|
||||
if [[ $# -ne 1 ]]; then
|
||||
printf 'usage: %s OUT_DIR\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
OUT="$(realpath -m "$1")"
|
||||
SRC="${VKD3D_PROTON_SRC:-$HOME/.cache/d4r-vkd3d-proton}"
|
||||
COMMIT="${VKD3D_PROTON_COMMIT:-3dfc6f07}"
|
||||
BUILD="$SRC-build"
|
||||
|
||||
[[ -d "$SRC/.git" ]] || git clone https://github.com/HansKristian-Work/vkd3d-proton.git "$SRC"
|
||||
# -f: the clone is a build cache; the patch is reapplied below.
|
||||
git -C "$SRC" checkout -q -f -B d4r-split "$COMMIT"
|
||||
git -C "$SRC" submodule update --init --recursive -q
|
||||
git -C "$SRC" apply "$ROOT"/patches/vkd3d-proton/*.patch
|
||||
[[ -d "$BUILD" ]] || meson setup --cross-file "$SRC/build-win64.txt" --buildtype release -Denable_tests=false "$BUILD" "$SRC"
|
||||
ninja -C "$BUILD"
|
||||
mkdir -p "$OUT"
|
||||
x86_64-w64-mingw32-strip -o "$OUT/d3d12.dll" "$BUILD/libs/d3d12/d3d12.dll"
|
||||
x86_64-w64-mingw32-strip -o "$OUT/d3d12core.dll" "$BUILD/libs/d3d12core/d3d12core.dll"
|
||||
printf 'Built %s/d3d12.dll and d3d12core.dll\n' "$OUT"
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
WINEGCC="${WINEGCC:-winegcc}"
|
||||
WINEBUILD="${WINEBUILD:-winebuild}"
|
||||
BRIDGE_ROOT="$ROOT/build/wine-nvcuda"
|
||||
|
||||
mkdir -p "$BRIDGE_ROOT/x86_64-unix" "$BRIDGE_ROOT/x86_64-windows"
|
||||
"$WINEGCC" -m64 -shared -o "$BRIDGE_ROOT/x86_64-unix/nvcuda.dll" \
|
||||
"$ROOT/tools/wine_nvcuda_bridge.c" \
|
||||
-Wb,--export="$ROOT/tools/wine_nvcuda_bridge.spec" -ldl -lpthread
|
||||
"$WINEBUILD" --dll --fake-module -E "$ROOT/tools/wine_nvcuda_bridge.spec" \
|
||||
-F nvcuda.dll -b x86_64-windows -o "$BRIDGE_ROOT/x86_64-windows/nvcuda.dll"
|
||||
printf 'Built Wine nvcuda bridge in %s\n' "$BRIDGE_ROOT"
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ZLUDA_SOURCE_ROOT="${ZLUDA_SOURCE_ROOT:-}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-/opt/rocm}"
|
||||
HIPCC="${HIPCC:-$ROCM_ROOT/bin/hipcc}"
|
||||
LLVM_DIS="${LLVM_DIS:-$ROCM_ROOT/lib/llvm/bin/llvm-dis}"
|
||||
LLVM_AS="${LLVM_AS:-$ROCM_ROOT/lib/llvm/bin/llvm-as}"
|
||||
OCML="${OCML:-$ROCM_ROOT/amdgcn/bitcode/ocml.bc}"
|
||||
WORK_ROOT="${D4R_ZLUDA_PTX_HELPER_WORK:-${TMPDIR:-/tmp}/d4r-zluda-ptx-helpers}"
|
||||
|
||||
if [[ -z "$ZLUDA_SOURCE_ROOT" || ! -f "$ZLUDA_SOURCE_ROOT/ptx/lib/zluda_ptx_impl.cpp" ]]; then
|
||||
printf 'Set ZLUDA_SOURCE_ROOT to a ZLUDA source checkout\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
for dependency in "$HIPCC" "$LLVM_DIS" "$LLVM_AS" "$OCML"; do
|
||||
if [[ ! -e "$dependency" ]]; then
|
||||
printf 'Required ROCm/LLVM helper is missing: %s\n' "$dependency" >&2
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p "$WORK_ROOT"
|
||||
SOURCE="$ZLUDA_SOURCE_ROOT/ptx/lib/zluda_ptx_impl.cpp"
|
||||
PTX_LIB="$ZLUDA_SOURCE_ROOT/ptx/lib"
|
||||
COMMON_FLAGS=(-DHIP_ENABLE_WARP_SYNC_BUILTINS -std=c++20 -Xclang -fdenormal-fp-math=dynamic
|
||||
-Wall -Wextra -Wsign-compare -Wconversion -x hip "$SOURCE" -nogpulib -O3
|
||||
-mno-wavefrontsize64 --offload-device-only --offload-arch=gfx1030 -emit-llvm -c
|
||||
-Xclang -mlink-bitcode-file -Xclang "$OCML")
|
||||
|
||||
build_one() {
|
||||
local suffix="$1"
|
||||
shift
|
||||
local raw="$WORK_ROOT/zluda_ptx_impl${suffix}.raw.bc"
|
||||
local clean="$WORK_ROOT/zluda_ptx_impl${suffix}.clean.bc"
|
||||
local ll="$WORK_ROOT/zluda_ptx_impl${suffix}.ll"
|
||||
local output="$PTX_LIB/zluda_ptx_impl${suffix}.bc"
|
||||
|
||||
"$HIPCC" "${COMMON_FLAGS[@]}" "$@" -o "$raw"
|
||||
"$LLVM_DIS" "$raw" -o "$ll"
|
||||
sed -E \
|
||||
-e '/@llvm.used/d' \
|
||||
-e '/wchar_size/d' \
|
||||
-e '/llvm.module.flags/d' \
|
||||
-e '/__hip_cuid/d' \
|
||||
-e 's/optnone//g' \
|
||||
-e 's/define hidden/define linkonce_odr/g' \
|
||||
-e 's/"target-cpu"="gfx1030"//g' \
|
||||
-e 's/"target-features"="[^"]+"//g' "$ll" |
|
||||
"$LLVM_AS" -o "$clean" -
|
||||
mv "$clean" "$output"
|
||||
printf 'Wrote %s (%s bytes)\n' "$output" "$(stat -c '%s' "$output")"
|
||||
}
|
||||
|
||||
build_one ""
|
||||
build_one "_constrained" -ffp-model=strict -ffp-exception-behavior=ignore
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
section() {
|
||||
printf '\n## %s\n' "$1"
|
||||
}
|
||||
|
||||
show_if_available() {
|
||||
local tool="$1"
|
||||
shift
|
||||
if command -v "$tool" >/dev/null 2>&1; then
|
||||
"$tool" "$@" 2>&1 || true
|
||||
else
|
||||
printf '%s: not found\n' "$tool"
|
||||
fi
|
||||
}
|
||||
|
||||
section 'Operating system'
|
||||
uname -a
|
||||
|
||||
section 'Display adapters and kernel drivers'
|
||||
show_if_available lspci -nnk | rg -A4 -i 'vga|3d|display' || true
|
||||
|
||||
section 'ROCm / HIP'
|
||||
show_if_available rocminfo | head -80 || true
|
||||
show_if_available hipcc --version | head -20 || true
|
||||
if command -v rocm-smi >/dev/null 2>&1; then
|
||||
rocm-smi --showproductname --showdriverversion 2>&1 | head -50 || true
|
||||
elif [[ -x /opt/rocm/bin/rocm-smi ]]; then
|
||||
/opt/rocm/bin/rocm-smi --showproductname --showdriverversion 2>&1 | head -50 || true
|
||||
fi
|
||||
|
||||
section 'Vulkan'
|
||||
if command -v vulkaninfo >/dev/null 2>&1; then
|
||||
vulkaninfo --summary 2>&1 | rg -i 'VULKANINFO|Instance Version|GPU[0-9]|apiVersion|driverVersion|vendorID|deviceID|deviceName|driverID|driverName|driverInfo' || true
|
||||
else
|
||||
printf 'vulkaninfo: not found\n'
|
||||
fi
|
||||
|
||||
section 'Wine / Proton'
|
||||
show_if_available wine --version
|
||||
show_if_available protontricks --version
|
||||
find "$HOME/.local/share/Steam/compatibilitytools.d" -maxdepth 3 -type f -name proton -print 2>/dev/null | head -20 || true
|
||||
|
||||
section 'Build and PE inspection tools'
|
||||
for tool in x86_64-w64-mingw32-g++ cmake ninja llvm-objdump llvm-readobj objdump strings; do
|
||||
if command -v "$tool" >/dev/null 2>&1; then
|
||||
printf '%-28s %s\n' "$tool" "$(command -v "$tool")"
|
||||
else
|
||||
printf '%-28s %s\n' "$tool" 'not found'
|
||||
fi
|
||||
done
|
||||
|
||||
section 'Installed relevant Arch packages'
|
||||
if command -v pacman >/dev/null 2>&1; then
|
||||
pacman -Q 2>/dev/null | rg -i '(^| )(rocm|hip|vulkan|wine|mingw|clang|mesa)(-| )' || true
|
||||
else
|
||||
printf 'pacman: not found\n'
|
||||
fi
|
||||
Executable
+200
@@ -0,0 +1,200 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Translate d4r.ini (see config/d4r.ini.default) into shell exports for the game launcher.
|
||||
|
||||
usage: d4r_config.py [--config PATH] [--print | --launch]
|
||||
Prints "export VAR=value" lines for every setting the INI decides, skipping variables that are
|
||||
already set in the environment (explicit environment always wins). --print lists the resulting
|
||||
settings for humans instead. Without --config: $D4R_CONFIG, else ~/.config/d4r/d4r.ini, which is
|
||||
created from config/d4r.ini.default on first use.
|
||||
"""
|
||||
import configparser
|
||||
import os
|
||||
import shlex
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
DEFAULT_TEMPLATE = ROOT / "config" / "d4r.ini.default"
|
||||
PRESETS = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7, "J": 10, "K": 11, "L": 12, "M": 13}
|
||||
# friendly names for [DLSS] Model
|
||||
MODEL_ALIASES = {"CNN": "E", "DLSS3": "E", "DLSS4": "K", "DLSS4.5": "M", "TRANSFORMER": "K"}
|
||||
|
||||
|
||||
def fail(message):
|
||||
print(f"d4r config: {message}", file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
def config_path(argv):
|
||||
if "--config" in argv:
|
||||
return Path(argv[argv.index("--config") + 1]).expanduser()
|
||||
if os.environ.get("D4R_CONFIG"):
|
||||
return Path(os.environ["D4R_CONFIG"]).expanduser()
|
||||
path = Path.home() / ".config" / "d4r" / "d4r.ini"
|
||||
if not path.exists() and DEFAULT_TEMPLATE.exists():
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(DEFAULT_TEMPLATE, path)
|
||||
print(f"d4r config: created {path} from the default template; edit it to change settings",
|
||||
file=sys.stderr)
|
||||
return path
|
||||
|
||||
|
||||
def main(argv):
|
||||
path = config_path(argv)
|
||||
ini = configparser.ConfigParser(inline_comment_prefixes=(";", "#"), interpolation=None)
|
||||
ini.optionxform = str # keep [Env] variable names as written
|
||||
if path.exists():
|
||||
ini.read(path)
|
||||
|
||||
def get(section, key):
|
||||
value = ini.get(section, key, fallback="").strip()
|
||||
return None if value == "" or value.lower() == "auto" else value
|
||||
|
||||
def flag(section, key):
|
||||
value = get(section, key)
|
||||
if value is None:
|
||||
return None
|
||||
if value.lower() in ("1", "true", "yes", "on"):
|
||||
return True
|
||||
if value.lower() in ("0", "false", "no", "off"):
|
||||
return False
|
||||
fail(f"[{section}] {key} must be true or false, not {value!r}")
|
||||
|
||||
def path_value(section, key):
|
||||
value = get(section, key)
|
||||
return os.path.expanduser(value) if value else None
|
||||
|
||||
if "--launch" in argv:
|
||||
# PROTON_DIR, COMPAT_DATA_DIR and GAME_EXE for scripts/d4r_play.sh, one per line
|
||||
values = [path_value("Launch", key) for key in ("ProtonDir", "CompatDataDir", "GameExe")]
|
||||
missing = [key for key, value in zip(("ProtonDir", "CompatDataDir", "GameExe"), values) if not value]
|
||||
if missing:
|
||||
fail(f"set [Launch] {', '.join(missing)} in {path}")
|
||||
print("\n".join(values))
|
||||
return
|
||||
|
||||
env = {}
|
||||
|
||||
model = get("DLSS", "Model")
|
||||
if model is not None:
|
||||
if model.isdigit():
|
||||
env["D4R_DLSS_PRESET"] = model
|
||||
elif model.upper() in PRESETS or model.upper() in MODEL_ALIASES:
|
||||
env["D4R_DLSS_PRESET"] = str(PRESETS[MODEL_ALIASES.get(model.upper(), model.upper())])
|
||||
else:
|
||||
fail(f"[DLSS] Model {model!r}: use one of {', '.join(list(PRESETS) + list(MODEL_ALIASES))} or a preset number")
|
||||
|
||||
age = get("Latency", "FrameAge")
|
||||
if age is not None:
|
||||
if age not in ("0", "1", "2", "3"):
|
||||
fail(f"[Latency] FrameAge must be 0-3, not {age!r}")
|
||||
if age == "0":
|
||||
# same-frame results: the game's command list is split around DLSS (patched vkd3d-proton)
|
||||
env["D4R_SHIM_SPLIT_FRAME"] = "1"
|
||||
else:
|
||||
env["D4R_SHIM_SPLIT_FRAME"] = "0"
|
||||
env["D4R_SHIM_MAX_IN_FLIGHT"] = age
|
||||
|
||||
for key, var in (("RuntimeDir", "D4R_RUNTIME_DIR"), ("ZludaDir", "D4R_ZLUDA_DIR"), ("RocmDir", "D4R_ROCM_DIR"),
|
||||
("VkD3DDir", "D4R_VKD3D_DIR")):
|
||||
value = path_value("Paths", key)
|
||||
if value:
|
||||
env[var] = value
|
||||
# JIT caches (ZLUDA's compiled kernels among them): a directory, or per-zluda for the one the test
|
||||
# runs warm for each ZLUDA build (~/.cache/d4r-perf-game-jit-<ZludaDir name>)
|
||||
jit = get("Paths", "JitCacheDir")
|
||||
if jit is not None:
|
||||
if jit.lower() == "per-zluda":
|
||||
zluda = env.get("D4R_ZLUDA_DIR") or os.environ.get("D4R_ZLUDA_DIR")
|
||||
if not zluda:
|
||||
fail("[Paths] JitCacheDir = per-zluda needs [Paths] ZludaDir")
|
||||
jit = f"~/.cache/d4r-perf-game-jit-{Path(zluda).name}"
|
||||
env["XDG_CACHE_HOME"] = os.path.expanduser(jit)
|
||||
if age == "0" and "D4R_VKD3D_DIR" not in env and not os.environ.get("D4R_VKD3D_DIR"):
|
||||
print("d4r config: FrameAge = 0 needs [Paths] VkD3DDir (the d4r-patched vkd3d-proton); without it the "
|
||||
"shim falls back to older frames", file=sys.stderr)
|
||||
|
||||
mode = (get("Kernels", "NativeKernels") or "off").lower()
|
||||
if mode not in ("fast", "exact", "off"):
|
||||
fail(f"[Kernels] NativeKernels must be fast, exact or off, not {mode!r}")
|
||||
if mode != "off":
|
||||
directory = path_value("Paths", "NativeKernelDirFast" if mode == "fast" else "NativeKernelDirExact")
|
||||
if not directory:
|
||||
fail(f"[Kernels] NativeKernels = {mode} needs [Paths] NativeKernelDir{mode.capitalize()}")
|
||||
if not Path(directory).is_dir():
|
||||
fail(f"native kernel directory {directory} does not exist")
|
||||
env["D4R_ZLUDA_NATIVE_DIR"] = directory
|
||||
for key, var in (("Fp8Wmma", "D4R_ZLUDA_WMMA_FP8"), ("IgnoreDenormals", "D4R_ZLUDA_IGNORE_DENORMAL")):
|
||||
value = flag("Kernels", key)
|
||||
if value is not None:
|
||||
env[var] = "1" if value else "0"
|
||||
value = get("Kernels", "ImplicitMaxBlock")
|
||||
if value:
|
||||
env["D4R_ZLUDA_IMPLICIT_MAX_BLOCK"] = value
|
||||
|
||||
for key, var in (("VramInterop", "D4R_SHIM_VRAM_INTEROP"), ("InputSync", "D4R_SHIM_INPUT_SYNC"),
|
||||
("GpuWait", "D4R_SHIM_GPU_WAIT"), ("LinearInputs", "D4R_SHIM_LINEAR_INPUTS"),
|
||||
("DirectOutput", "D4R_SHIM_OUTPUT_DIRECT"), ("ElideNgxSync", "D4R_ELIDE_NGX_SYNC"),
|
||||
("EvalSync", "D4R_SHIM_EVAL_SYNC")):
|
||||
value = flag("Interop", key)
|
||||
if value is not None:
|
||||
env[var] = "1" if value else "0"
|
||||
value = get("Interop", "MarkerPollUs")
|
||||
if value:
|
||||
if not value.isdigit():
|
||||
fail(f"[Interop] MarkerPollUs must be a number of microseconds, not {value!r}")
|
||||
env["D4R_SHIM_MARKER_POLL_US"] = value
|
||||
|
||||
engine = path_value("Game", "EngineIni")
|
||||
cvars = get("Game", "Cvars")
|
||||
if engine and cvars:
|
||||
env["D4R_UE_ENGINE_INI"] = engine
|
||||
env["D4R_UE_CVARS"] = cvars
|
||||
|
||||
value = flag("OptiScaler", "FpsOverlay")
|
||||
if value is False:
|
||||
env["D4R_OPTISCALER_FPS_OVERLAY_TYPE"] = "0"
|
||||
env["D4R_OPTISCALER_SHOW_FPS"] = "false"
|
||||
elif get("OptiScaler", "FpsOverlayType"):
|
||||
env["D4R_OPTISCALER_FPS_OVERLAY_TYPE"] = get("OptiScaler", "FpsOverlayType")
|
||||
if get("OptiScaler", "LogLevel"):
|
||||
env["D4R_OPTISCALER_LOG_LEVEL"] = get("OptiScaler", "LogLevel")
|
||||
extra = []
|
||||
ratios = [(mode_name, get("OptiScaler", f"QualityRatio{mode_name}"))
|
||||
for mode_name in ("Quality", "Balanced", "Performance", "UltraPerformance")]
|
||||
if any(ratio for _, ratio in ratios):
|
||||
extra.append("QualityOverrides.QualityRatioOverrideEnabled=true")
|
||||
extra += [f"QualityOverrides.QualityRatio{name}={ratio}" for name, ratio in ratios if ratio]
|
||||
if get("OptiScaler", "Extra"):
|
||||
extra.append(get("OptiScaler", "Extra"))
|
||||
if extra:
|
||||
env["D4R_EXTRA_OPTISCALER_CONFIG"] = ";".join(extra)
|
||||
|
||||
if flag("Overlay", "MangoHud"):
|
||||
env["MANGOHUD"] = "1"
|
||||
if get("Overlay", "MangoHudConfig"):
|
||||
env["MANGOHUD_CONFIG"] = get("Overlay", "MangoHudConfig")
|
||||
|
||||
if flag("Debug", "Profile"):
|
||||
env["D4R_PROFILE"] = "1"
|
||||
if path_value("Debug", "LogDir"):
|
||||
env["D4R_GAME_LOG_DIR"] = path_value("Debug", "LogDir")
|
||||
|
||||
if ini.has_section("Env"):
|
||||
for key, value in ini.items("Env"):
|
||||
env[key] = value.strip()
|
||||
|
||||
final = {key: value for key, value in env.items() if key not in os.environ}
|
||||
if "--print" in argv:
|
||||
print(f"d4r config: {path}{'' if path.exists() else ' (missing: built-in defaults)'}")
|
||||
for key in sorted(env):
|
||||
note = "" if key in final else f" (environment wins: {os.environ[key]})"
|
||||
print(f" {key}={env[key]}{note}")
|
||||
return
|
||||
for key, value in sorted(final.items()):
|
||||
print(f"export {key}={shlex.quote(value)}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# One-command launch: runs the game configured in d4r.ini's [Launch] section with all d4r settings
|
||||
# from the same file (see config/d4r.ini.default). Extra arguments go to the game.
|
||||
# D4R_CONFIG=/path/to/other.ini scripts/d4r_play.sh
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
mapfile -t LAUNCH < <(python3 "$ROOT/scripts/d4r_config.py" --launch) || exit 2
|
||||
[[ ${#LAUNCH[@]} -eq 3 ]] || exit 2
|
||||
exec "$ROOT/scripts/run_game_d4r_optiscaler_proton.sh" "${LAUNCH[0]}" "${LAUNCH[1]}" "${LAUNCH[2]}" "$@"
|
||||
@@ -0,0 +1,40 @@
|
||||
# Source this to export the environment a Proton process needs to run
|
||||
# official DLSS on AMD through d4r (ZLUDA + Wine CUDA bridge + NGX shim).
|
||||
# Paths can be overridden before sourcing.
|
||||
D4R_RUNTIME_DIR="${D4R_RUNTIME_DIR:-$HOME/.local/share/d4r-dlss}"
|
||||
D4R_ZLUDA_DIR="${D4R_ZLUDA_DIR:-$HOME/.cache/d4r-zluda-current}"
|
||||
# ROCm user-space runtime: a private copy under ~/.cache if present, otherwise the system /opt/rocm
|
||||
if [[ -z "${D4R_ROCM_DIR:-}" ]]; then
|
||||
D4R_ROCM_DIR="$HOME/.cache/d4r-rocm-deps/root/opt/rocm"
|
||||
[[ -d "$D4R_ROCM_DIR" ]] || D4R_ROCM_DIR=/opt/rocm
|
||||
fi
|
||||
d4r_winpath() { printf 'Z:%s' "$(printf '%s' "$1" | tr '/' '\\')"; }
|
||||
|
||||
# dxvk-nvapi on a non-NVIDIA driver, reporting Ada so NGX uploads the FP8
|
||||
# network weights that match the sm_89 PTX ZLUDA compiles.
|
||||
export PROTON_ENABLE_NVAPI=1
|
||||
export DXVK_NVAPI_ALLOW_OTHER_DRIVERS=1
|
||||
export DXVK_NVAPI_GPU_ARCH=AD100
|
||||
# ZLUDA and the ROCm user-cache runtime.
|
||||
export LD_LIBRARY_PATH="$D4R_ZLUDA_DIR:$D4R_ROCM_DIR/lib:$D4R_ROCM_DIR/lib/llvm/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
export D4R_ZLUDA_LIBCUDA="$D4R_ZLUDA_DIR/libcuda.so"
|
||||
# Kernels without PTX launch bounds (DLSS's convolutions) are compiled for at
|
||||
# most 256-thread blocks, as CUDA itself allows 255 registers for them; the
|
||||
# default 1024 bound caps gfx11 waves at 96 VGPRs and makes them spill.
|
||||
export D4R_ZLUDA_IMPLICIT_MAX_BLOCK="${D4R_ZLUDA_IMPLICIT_MAX_BLOCK:-256}"
|
||||
# f16 tensor-core MMAs (DLSS's convolutions) run on gfx11 WMMA instead of a
|
||||
# dot-product fallback (patches/zluda/0003); 0 selects the fallback.
|
||||
export D4R_ZLUDA_WMMA="${D4R_ZLUDA_WMMA:-1}"
|
||||
# DLSS frames in flight. The presented upscaled image is this many game frames
|
||||
# old at most: 3 = highest frame rate (Townfall ~86 fps, age 2-3), 2 = age 2
|
||||
# (~75 fps), 1 = age 1, the lowest possible with the CPU staging path (~53 fps).
|
||||
export D4R_SHIM_MAX_IN_FLIGHT="${D4R_SHIM_MAX_IN_FLIGHT:-3}"
|
||||
# 1 keeps DLSS inputs and output in VRAM (vkd3d-proton Vulkan interop, no CPU
|
||||
# staging): Townfall ~141 fps at age 2-3 with 3 in flight, ~113 fps at age 1
|
||||
# with D4R_SHIM_MAX_IN_FLIGHT=1. Needs vkd3d-proton; falls back automatically.
|
||||
export D4R_SHIM_VRAM_INTEROP="${D4R_SHIM_VRAM_INTEROP:-0}"
|
||||
# Shim configuration (Windows paths inside the prefix).
|
||||
export D4R_NVCUDA_BRIDGE="$(d4r_winpath "$D4R_RUNTIME_DIR/bin/nvcuda.dll")"
|
||||
export D4R_NGX_CORE="${D4R_NGX_CORE:-$(d4r_winpath "$D4R_RUNTIME_DIR/ngx/_nvngx.dll")}"
|
||||
export D4R_NGX_FEATURE_DIR="$(d4r_winpath "$D4R_RUNTIME_DIR/dlss")"
|
||||
export D4R_SHIM_LOG="${D4R_SHIM_LOG:-$(d4r_winpath "$D4R_RUNTIME_DIR/d4r_nvngx.log")}"
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Stages the pieces a Proton game needs under D4R_RUNTIME_DIR
|
||||
# (default ~/.local/share/d4r-dlss):
|
||||
# bin/nvcuda.dll Wine CUDA bridge (ELF builtin, preloaded by path by the shim)
|
||||
# bin/d4r_nvngx.dll D3D12-to-CUDA NGX core shim (OptiScaler NvngxPath target)
|
||||
# ngx/_nvngx.dll official NGX core
|
||||
# dlss/nvngx_dlss.dll official DLSS SR feature DLL (also copied into bin/)
|
||||
# usage: install_d4r_runtime.sh PATH_TO_NGX_CORE_DLL PATH_TO_NVNGX_DLSS_DLL
|
||||
if [[ $# -ne 2 ]]; then
|
||||
printf 'usage: %s PATH_TO_NGX_CORE_DLL PATH_TO_NVNGX_DLSS_DLL\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
RUNTIME="${D4R_RUNTIME_DIR:-$HOME/.local/share/d4r-dlss}"
|
||||
"$ROOT/scripts/build_d4r_nvngx_shim.sh"
|
||||
"$ROOT/scripts/build_wine_nvcuda_bridge.sh"
|
||||
mkdir -p "$RUNTIME/bin" "$RUNTIME/ngx" "$RUNTIME/dlss"
|
||||
cp -f "$ROOT/build/wine-nvcuda/x86_64-unix/nvcuda.dll.so" "$RUNTIME/bin/nvcuda.dll"
|
||||
cp -f "$ROOT/build/d4r_nvngx.dll" "$RUNTIME/bin/d4r_nvngx.dll"
|
||||
copy_unless_same() { [[ "$(realpath "$1")" == "$(realpath -m "$2")" ]] || cp -f "$1" "$2"; }
|
||||
copy_unless_same "$1" "$RUNTIME/ngx/_nvngx.dll"
|
||||
copy_unless_same "$2" "$RUNTIME/dlss/nvngx_dlss.dll"
|
||||
# The NGX core's CUDA init ignores the feature search paths it is given and
|
||||
# scans the directory of the module that calls it, i.e. the shim's.
|
||||
cp -f "$RUNTIME/dlss/nvngx_dlss.dll" "$RUNTIME/bin/nvngx_dlss.dll"
|
||||
sha256sum "$RUNTIME"/ngx/_nvngx.dll "$RUNTIME"/dlss/nvngx_dlss.dll
|
||||
printf 'Installed d4r runtime in %s\n' "$RUNTIME"
|
||||
Executable
+151
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds the drag-in release: a zip whose contents are extracted into the folder that holds a game's
|
||||
# main .exe, like an OptiScaler release. packaging/D4R_README.txt describes the result.
|
||||
#
|
||||
# usage: scripts/package_release.sh [OUT_DIR] (default: dist/)
|
||||
#
|
||||
# Inputs (environment):
|
||||
# D4R_OPTISCALER OptiScaler release archive (.7z or .zip) or extracted folder (required; 0.9.4 tested)
|
||||
# D4R_DLSS_DLLS colon-separated nvngx_dlss.dll files whose kernel code the native kernels accept
|
||||
# (required; only hashes of their PTX go into the release)
|
||||
# D4R_ZLUDA_DIR ZLUDA build with patches/zluda applied (libnvcuda.so) default ~/.cache/d4r-zluda-current
|
||||
# D4R_VKD3D_DIR d4r-patched vkd3d-proton (d3d12.dll, d3d12core.dll) default ~/.cache/d4r-vkd3d-d4r
|
||||
# D4R_ROCM_DIR ROCm with clang, for the kernels default /opt/rocm
|
||||
# D4R_GPU_ARCHS GPU targets to build kernels for default gfx1101
|
||||
# D4R_OPTISCALER_LICENSE OptiScaler's LICENSE (GPL-3.0) text; default: the system's SPDX copy
|
||||
# D4R_VKD3D_SRC vkd3d-proton source checkout, for its license files default ~/.cache/d4r-vkd3d-proton
|
||||
# D4R_ZLUDA_SRC ZLUDA source checkout, for its license files default: D4R_ZLUDA_DIR's ../d4r-zluda-upstream
|
||||
# SOURCE_DATE_EPOCH timestamp given to every packaged file default: the last commit's
|
||||
# The zip also contains NVIDIA's files and the texture kernels built from NVIDIA's PTX; redistributing
|
||||
# those is up to whoever publishes it (they are not covered by d4r's license):
|
||||
# D4R_BUNDLE_DLSS nvngx_dlss.dll to include D4R_BUNDLE_NGX _nvngx.dll to include
|
||||
# D4R_BUNDLE_TEX directory with the texture-kernel code objects (kernels/build.sh tex), for gfx1101
|
||||
# D4R_BUNDLE_NVIDIA=0 leaves them out (d4r-VERSION-nonvidia.zip; users then add the two DLLs themselves).
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
OUT="$(realpath -m "${1:-$ROOT/dist}")"
|
||||
VERSION="$(cat "$ROOT/packaging/VERSION")"
|
||||
VARIANT=full
|
||||
[[ "${D4R_BUNDLE_NVIDIA:-1}" == 0 ]] && VARIANT=clean
|
||||
NAME="d4r-$VERSION"
|
||||
[[ "$VARIANT" == clean ]] && NAME="$NAME-nonvidia"
|
||||
STAGE="$OUT/$NAME"
|
||||
ZLUDA="${D4R_ZLUDA_DIR:-$HOME/.cache/d4r-zluda-current}"
|
||||
VKD3D="${D4R_VKD3D_DIR:-$HOME/.cache/d4r-vkd3d-d4r}"
|
||||
ROCM="${D4R_ROCM_DIR:-/opt/rocm}"
|
||||
ARCHS="${D4R_GPU_ARCHS:-gfx1101}"
|
||||
: "${D4R_OPTISCALER:?set D4R_OPTISCALER to the OptiScaler release archive or folder}"
|
||||
: "${D4R_DLSS_DLLS:?set D4R_DLSS_DLLS to the nvngx_dlss.dll files the kernel manifest accepts}"
|
||||
for f in "$ZLUDA/libnvcuda.so" "$VKD3D/d3d12.dll" "$VKD3D/d3d12core.dll"; do
|
||||
[[ -f "$f" ]] || { echo "missing $f" >&2; exit 2; }
|
||||
done
|
||||
|
||||
# D4R_SKIP_BUILD=1 packages the shim and bridge already in build/ (e.g. the binaries that were tested)
|
||||
if [[ "${D4R_SKIP_BUILD:-0}" != 1 ]]; then
|
||||
"$ROOT/scripts/build_d4r_nvngx_shim.sh" >/dev/null
|
||||
"$ROOT/scripts/build_wine_nvcuda_bridge.sh" >/dev/null
|
||||
fi
|
||||
|
||||
rm -rf "$STAGE"
|
||||
mkdir -p "$STAGE/d4r/zluda" "$STAGE/d4r/ngx" "$STAGE/d4r/kernels" "$STAGE/d4r/licenses" "$STAGE/d4r/source"
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
# OptiScaler, as dxgi.dll with its INI preconfigured for d4r
|
||||
if [[ -d "$D4R_OPTISCALER" ]]; then
|
||||
OPTI="$D4R_OPTISCALER"
|
||||
else
|
||||
OPTI="$TMP/optiscaler"
|
||||
mkdir -p "$OPTI"
|
||||
case "$D4R_OPTISCALER" in
|
||||
*.7z) 7z x -y -o"$OPTI" "$D4R_OPTISCALER" >/dev/null ;;
|
||||
*.zip) unzip -q -o "$D4R_OPTISCALER" -d "$OPTI" ;;
|
||||
*) echo "D4R_OPTISCALER must be a .7z, a .zip or a folder" >&2; exit 2 ;;
|
||||
esac
|
||||
fi
|
||||
cp "$OPTI/OptiScaler.dll" "$STAGE/dxgi.dll"
|
||||
python3 - "$OPTI/OptiScaler.ini" "$ROOT/packaging/optiscaler.settings" "$STAGE/OptiScaler.ini" <<'PY'
|
||||
import re, sys
|
||||
lines = open(sys.argv[1], encoding="utf-8", newline="").read().split("\n") # keeps the file's line endings
|
||||
for setting in open(sys.argv[2], encoding="utf-8"):
|
||||
setting = setting.strip()
|
||||
if not setting or setting.startswith("#"):
|
||||
continue
|
||||
path, value = setting.split("=", 1)
|
||||
section, key = path.split(".", 1)
|
||||
start = next((i for i, l in enumerate(lines) if l.strip() == f"[{section}]"), None)
|
||||
if start is None:
|
||||
sys.exit(f"OptiScaler.ini has no [{section}]")
|
||||
end = next((i for i in range(start + 1, len(lines)) if lines[i].startswith("[")), len(lines))
|
||||
for i in range(start + 1, end):
|
||||
if re.match(rf"{re.escape(key)}\s*=", lines[i]):
|
||||
lines[i] = f"{key}={value}" + ("\r" if lines[i].endswith("\r") else "")
|
||||
break
|
||||
else:
|
||||
sys.exit(f"OptiScaler.ini has no {key} in [{section}]")
|
||||
open(sys.argv[3], "w", encoding="utf-8", newline="").write("\n".join(lines))
|
||||
PY
|
||||
|
||||
# d4r-patched vkd3d-proton: same-frame DLSS results
|
||||
cp "$VKD3D/d3d12.dll" "$VKD3D/d3d12core.dll" "$STAGE/"
|
||||
|
||||
# d4r itself
|
||||
cp "$ROOT/build/d4r_nvngx.dll" "$STAGE/d4r/nvngx.dll"
|
||||
cp "$ROOT/build/wine-nvcuda/x86_64-unix/nvcuda.dll.so" "$STAGE/d4r/nvcuda.dll"
|
||||
cp "$ZLUDA/libnvcuda.so" "$STAGE/d4r/zluda/libcuda.so"
|
||||
cp "$ROOT/packaging/d4r.ini" "$STAGE/d4r/d4r.ini"
|
||||
cp "$ROOT/packaging/d4r-check.sh" "$STAGE/d4r/d4r-check.sh"
|
||||
if [[ "$VARIANT" == full ]]; then
|
||||
: "${D4R_BUNDLE_DLSS:?set D4R_BUNDLE_DLSS}" "${D4R_BUNDLE_NGX:?set D4R_BUNDLE_NGX}" "${D4R_BUNDLE_TEX:?set D4R_BUNDLE_TEX}"
|
||||
cp "$D4R_BUNDLE_DLSS" "$STAGE/d4r/nvngx_dlss.dll"
|
||||
cp "$D4R_BUNDLE_NGX" "$STAGE/d4r/ngx/_nvngx.dll"
|
||||
else
|
||||
printf 'Put NVIDIA'"'"'s NGX runtime, _nvngx.dll, in this folder (see D4R_README.txt).\r\n' > "$STAGE/d4r/ngx/README.txt"
|
||||
fi
|
||||
IFS=: read -r -a DLLS <<< "$D4R_DLSS_DLLS"
|
||||
for arch in $ARCHS; do
|
||||
D4R_ROCM_DIR="$ROCM" D4R_GPU_ARCH="$arch" "$ROOT/kernels/build.sh" k "$STAGE/d4r/kernels/$arch" >/dev/null
|
||||
D4R_ROCM_DIR="$ROCM" D4R_GPU_ARCH="$arch" "$ROOT/kernels/build.sh" m "$STAGE/d4r/kernels/$arch" >/dev/null
|
||||
rm -f "$STAGE/d4r/kernels/$arch"/*.resolution.txt # empty LTO notes from clang's -save-temps
|
||||
if [[ "$VARIANT" == full && "$arch" == gfx1101 ]]; then
|
||||
for f in "$D4R_BUNDLE_TEX"/*.hsaco; do # texture kernels only; the layers above are built from source
|
||||
[[ -e "$STAGE/d4r/kernels/$arch/$(basename "$f")" ]] || cp "$f" "$STAGE/d4r/kernels/$arch/"
|
||||
done
|
||||
fi
|
||||
python3 "$ROOT/kernels/tools/kernel_manifest.py" "$STAGE/d4r/kernels/$arch" "${DLLS[@]}"
|
||||
done
|
||||
|
||||
# licenses and sources
|
||||
ZLUDA_SRC="${D4R_ZLUDA_SRC:-$(dirname "$ZLUDA")/d4r-zluda-upstream}"
|
||||
VKD3D_SRC="${D4R_VKD3D_SRC:-$HOME/.cache/d4r-vkd3d-proton}"
|
||||
L="$STAGE/d4r/licenses"
|
||||
cp "$ROOT/LICENSE" "$L/d4r-LICENSE.txt"
|
||||
cp "$ROOT/NOTICE" "$L/d4r-NOTICE.txt"
|
||||
cp "$ZLUDA_SRC/LICENSE-APACHE" "$L/ZLUDA-LICENSE-APACHE.txt"
|
||||
cp "$ZLUDA_SRC/LICENSE-MIT" "$L/ZLUDA-LICENSE-MIT.txt"
|
||||
cp "$ZLUDA_SRC/ext/llvm-project/llvm/LICENSE.TXT" "$L/LLVM-LICENSE.txt"
|
||||
cp "$VKD3D_SRC/LICENSE" "$L/vkd3d-proton-LICENSE.txt"
|
||||
cp "$VKD3D_SRC/COPYING" "$L/vkd3d-proton-COPYING.txt"
|
||||
cp "${D4R_OPTISCALER_LICENSE:-/usr/share/licenses/spdx/GPL-3.0-only.txt}" "$L/OptiScaler-LICENSE-GPL-3.0.txt"
|
||||
mkdir -p "$STAGE/d4r/source/patches"
|
||||
cp -r "$ROOT/patches/zluda" "$ROOT/patches/vkd3d-proton" "$STAGE/d4r/source/patches/"
|
||||
ZLUDA_COMMIT="$(git -C "$ZLUDA_SRC" rev-parse HEAD 2>/dev/null || echo unknown)"
|
||||
VKD3D_COMMIT="$(git -C "$VKD3D_SRC" rev-parse HEAD 2>/dev/null || echo unknown)"
|
||||
# "@clean " / "@full " lines belong to one variant only
|
||||
variant() { sed -n -e "s/^@$VARIANT //" -e '/^@[a-z]* /d' -e p; }
|
||||
file_version() { [[ -f "$1" ]] && strings -el "$1" | grep -A1 '^FileVersion$' | sed -n 2p | tr ',' '.' | tr -d ' '; }
|
||||
sed -e "s/@VERSION@/$VERSION/g" -e "s/@ZLUDA_COMMIT@/$ZLUDA_COMMIT/g" -e "s/@VKD3D_COMMIT@/$VKD3D_COMMIT/g" \
|
||||
-e "s/@DLSS_VERSION@/$(file_version "$STAGE/d4r/nvngx_dlss.dll")/g" -e "s/@NGX_VERSION@/$(file_version "$STAGE/d4r/ngx/_nvngx.dll")/g" \
|
||||
"$ROOT/packaging/SOURCES.txt" | variant > "$STAGE/d4r/source/SOURCES.txt"
|
||||
sed -e "s/@VERSION@/$VERSION/g" "$ROOT/packaging/D4R_README.txt" | variant | sed 's/$/\r/' > "$STAGE/D4R_README.txt"
|
||||
|
||||
# One timestamp for every file (SOURCE_DATE_EPOCH, default the last commit): ZLUDA's kernel cache is keyed on
|
||||
# its library's size and mtime, so every extraction of the zip shares one cache.
|
||||
EPOCH="${SOURCE_DATE_EPOCH:-$(git -C "$ROOT" log -1 --format=%ct)}"
|
||||
find "$STAGE" -exec touch -h -d "@$EPOCH" {} +
|
||||
# The zip holds the folder's contents, so it can be extracted straight into the game folder.
|
||||
rm -f "$OUT/$NAME.zip"
|
||||
(cd "$STAGE" && find . -type f | LC_ALL=C sort | sed 's|^\./||' | zip -q -X -9 "$OUT/$NAME.zip" -@)
|
||||
(cd "$OUT" && sha256sum "$NAME.zip" > "$NAME.zip.sha256")
|
||||
printf 'Built %s (%s)\n' "$OUT/$NAME.zip" "$(du -h "$OUT/$NAME.zip" | cut -f1)"
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# usage: run_bench_dlss_kernel.sh FATBIN REPLAY_DIR [ITERATIONS [OUTPUT_PREFIX]]
|
||||
# Replays a launch captured with D4R_CUDA_REPLAY_DUMP_DIR (wine_nvcuda_bridge.c).
|
||||
if [[ $# -lt 2 ]]; then
|
||||
printf 'usage: %s FATBIN REPLAY_DIR [ITERATIONS [OUTPUT_PREFIX]]\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ZLUDA_ROOT="${ZLUDA_ROOT:-}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-}"
|
||||
if [[ -z "$ZLUDA_ROOT" || -z "$ROCM_ROOT" || ! -f "$ZLUDA_ROOT/libcuda.so" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ZLUDA_ROOT and ROCM_ROOT to the ZLUDA and HIP runtimes\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
[[ -x "$ROOT/build/bench_dlss_kernel" && "$ROOT/build/bench_dlss_kernel" -nt "$ROOT/tools/bench_dlss_kernel.cpp" ]] ||
|
||||
"$ROOT/scripts/build_bench_dlss_kernel.sh" >/dev/null
|
||||
LD_LIBRARY_PATH="$ZLUDA_ROOT:$ROCM_ROOT/lib:$ROCM_ROOT/lib/llvm/lib:${LD_LIBRARY_PATH:-}" \
|
||||
"$ROOT/build/bench_dlss_kernel" "$@"
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Runs the D3D12 harness against d4r_nvngx.dll in an isolated Wine prefix.
|
||||
# usage: run_d3d12_dlss_harness.sh PATH_TO_NGX_CORE_DLL PATH_TO_NVNGX_DLSS_DLL OUTPUT_RAW [FRAMES [IN_W IN_H OUT_W OUT_H]]
|
||||
if [[ $# -lt 3 ]]; then
|
||||
printf 'usage: %s PATH_TO_NGX_CORE_DLL PATH_TO_NVNGX_DLSS_DLL OUTPUT_RAW [FRAMES]\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CORE_PATH="$(realpath "$1")"
|
||||
FEATURE_DLL_PATH="$(realpath "$2")"
|
||||
OUTPUT_PATH="$(realpath -m "$3")"
|
||||
FRAMES="${4:-6}"
|
||||
SIZES=("${@:5}")
|
||||
WINE_BIN="${WINE:-wine}"
|
||||
WINEPREFIX="${D4R_WINEPREFIX:-${TMPDIR:-/tmp}/d4r-wineprefix}"
|
||||
APP_DIR="${D4R_HARNESS_APPDIR:-${TMPDIR:-/tmp}/d4r-d3d12-harness-app}"
|
||||
ZLUDA_ROOT="${ZLUDA_ROOT:-}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-}"
|
||||
if [[ ! -f "$ZLUDA_ROOT/libcuda.so" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ZLUDA_ROOT and ROCM_ROOT to the ZLUDA and HIP runtimes\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$APP_DIR" "$WINEPREFIX/drive_c/windows/system32"
|
||||
"$ROOT/scripts/build_d3d12_dlss_harness.sh"
|
||||
"$ROOT/scripts/build_wine_nvcuda_bridge.sh"
|
||||
cp -f "$ROOT/build/wine-nvcuda/x86_64-windows/nvcuda.dll" "$WINEPREFIX/drive_c/windows/system32/nvcuda.dll"
|
||||
cp -f "$ROOT/build/d3d12_dlss_harness.exe" "$ROOT/build/d4r_nvngx.dll" "$APP_DIR/"
|
||||
cp -f "$FEATURE_DLL_PATH" "$APP_DIR/nvngx_dlss.dll"
|
||||
winpath() { WINEPREFIX="$WINEPREFIX" winepath -w "$1"; }
|
||||
WINE_OVERRIDES="${WINEDLLOVERRIDES:-}"
|
||||
for override in 'dxgi=n,b' 'd3d12=n,b' 'd3d12core=n,b' 'nvcuda=b'; do
|
||||
dll_name="${override%%=*}"
|
||||
if [[ ";$WINE_OVERRIDES;" != *";$dll_name="* ]]; then
|
||||
WINE_OVERRIDES="${WINE_OVERRIDES:+$WINE_OVERRIDES;}$override"
|
||||
fi
|
||||
done
|
||||
LD_LIBRARY_PATH="$ZLUDA_ROOT:$ROCM_ROOT/lib:$ROCM_ROOT/lib/llvm/lib:${LD_LIBRARY_PATH:-}" \
|
||||
WINEDLLPATH="$ROOT/build/wine-nvcuda/x86_64-windows:$ROOT/build/wine-nvcuda/x86_64-unix${WINEDLLPATH:+:$WINEDLLPATH}" \
|
||||
WINEDLLOVERRIDES="$WINE_OVERRIDES" WINEPREFIX="$WINEPREFIX" WINEDEBUG="${D4R_WINEDEBUG:--all}" \
|
||||
D4R_NGX_CORE="$(winpath "$CORE_PATH")" D4R_NGX_FEATURE_DIR="$(winpath "$APP_DIR")" \
|
||||
D4R_SHIM_LOG="$(winpath "$APP_DIR/d4r_nvngx.log")" \
|
||||
"$WINE_BIN" "$(winpath "$APP_DIR/d3d12_dlss_harness.exe")" "$(winpath "$APP_DIR/d4r_nvngx.dll")" \
|
||||
"$(winpath "$OUTPUT_PATH")" "$FRAMES" "${SIZES[@]}"
|
||||
printf '\nShim log (%s):\n' "$APP_DIR/d4r_nvngx.log"
|
||||
cat "$APP_DIR/d4r_nvngx.log"
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
|
||||
# Runs the synthetic D3D12 harness through a locally supplied OptiScaler
|
||||
# dxgi.dll and the d4r shim. All proxy files and the NVAPI identity bridge are
|
||||
# staged in disposable /tmp paths; the Proton installation is not modified.
|
||||
# usage: run_d3d12_dlss_harness_optiscaler_proton.sh PROTON_DIR OPTISCALER_DLL OUTPUT_RAW [FRAMES [IN_W IN_H OUT_W OUT_H]]
|
||||
if [[ $# -lt 3 ]]; then
|
||||
printf 'usage: %s PROTON_DIR OPTISCALER_DLL OUTPUT_RAW [FRAMES [IN_W IN_H OUT_W OUT_H]]\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
PROTON_DIR="$(realpath "$1")"
|
||||
OPTISCALER_DLL="$(realpath "$2")"
|
||||
OUTPUT_PATH="$(realpath -m "$3")"
|
||||
shift 3
|
||||
source "$ROOT/scripts/d4r_proton_env.sh"
|
||||
|
||||
for path in "$D4R_RUNTIME_DIR/bin/d4r_nvngx.dll" "$D4R_RUNTIME_DIR/bin/nvcuda.dll" \
|
||||
"$D4R_RUNTIME_DIR/bin/nvngx_dlss.dll" "$D4R_RUNTIME_DIR/ngx/_nvngx.dll"; do
|
||||
if [[ ! -f "$path" ]]; then
|
||||
printf 'Missing staged d4r runtime file: %s\n' "$path" >&2
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
|
||||
# DLSS Enabler has been found installed under the name OptiScaler.dll on this
|
||||
# machine. Reject it here: its proxy rejects dxgi/NGX harness naming and can
|
||||
# open a modal error dialog during LoadLibrary.
|
||||
EXPORT_HEADER="$(x86_64-w64-mingw32-objdump -p "$OPTISCALER_DLL" | sed -n '/The Export Tables/,+6p')"
|
||||
if [[ "$EXPORT_HEADER" != *OptiScaler.dll* ]]; then
|
||||
printf 'Expected a real OptiScaler DLL (PE export name OptiScaler.dll): %s\n' "$OPTISCALER_DLL" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
"$ROOT/scripts/build_d4r_nvapi_identity.sh" >/dev/null
|
||||
APP_DIR="${D4R_OPTISCALER_APP_DIR:-${TMPDIR:-/tmp}/d4r-optiscaler-harness-${UID}-$(date +%s%N)}"
|
||||
mkdir -p "$APP_DIR"
|
||||
LAUNCHER_DIR="$(mktemp -d "${TMPDIR:-/tmp}/d4r-optiscaler-proton.XXXXXXXX")"
|
||||
COMPAT_DIR="${D4R_OPTISCALER_COMPAT_DIR:-${TMPDIR:-/tmp}/d4r-optiscaler-compat-$UID}"
|
||||
mkdir -p "$COMPAT_DIR"
|
||||
|
||||
cp -f "$OPTISCALER_DLL" "$APP_DIR/dxgi.dll"
|
||||
INPUT_HOOK="${D4R_OPTISCALER_ENABLE_DLSS_INPUTS:-false}"
|
||||
ORIGINAL_HOOK="${D4R_OPTISCALER_HOOK_ORIGINAL_NVNGX_ONLY:-$INPUT_HOOK}"
|
||||
if [[ "$INPUT_HOOK" != true && "$INPUT_HOOK" != false ]] ||
|
||||
[[ "$ORIGINAL_HOOK" != true && "$ORIGINAL_HOOK" != false ]]; then
|
||||
printf 'OptiScaler hook settings must be true or false\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
# D4R_OPTISCALER_STAGE_CORE=0 keeps the official core in the runtime directory,
|
||||
# as in a game install; the shim then loads it below OptiScaler's hooks.
|
||||
STAGE_CORE="${D4R_OPTISCALER_STAGE_CORE:-1}"
|
||||
if [[ "$INPUT_HOOK" == true && "$STAGE_CORE" == 1 ]]; then
|
||||
if [[ "$ORIGINAL_HOOK" != true || "$APP_DIR" != "${APP_DIR,,}" ]]; then
|
||||
printf 'The DLSS input hook requires HookOriginalNvngxOnly=true and a lowercase app path\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
# OptiScaler hooks game-side nvngx loads. Keep the official core's required
|
||||
# filename inside the harness EXE directory and pass a lowercase z: path;
|
||||
# its hook then leaves this internal core load alone.
|
||||
cp -f "$D4R_RUNTIME_DIR/ngx/_nvngx.dll" "$APP_DIR/_nvngx.dll"
|
||||
cp -f "$D4R_RUNTIME_DIR/dlss/nvngx_dlss.dll" "$APP_DIR/nvngx_dlss.dll"
|
||||
core_windows_path="$(d4r_winpath "$APP_DIR/_nvngx.dll")"
|
||||
export D4R_NGX_CORE="z:${core_windows_path#Z:}"
|
||||
fi
|
||||
cat > "$APP_DIR/OptiScaler.ini" <<EOF
|
||||
[Upscalers]
|
||||
Dx12Upscaler=dlss
|
||||
[FrameGen]
|
||||
Enabled=false
|
||||
FGInput=nofg
|
||||
FGOutput=nofg
|
||||
[DLSS]
|
||||
Enabled=true
|
||||
[Inputs]
|
||||
EnableDlssInputs=$INPUT_HOOK
|
||||
[Hooks]
|
||||
HookOriginalNvngxOnly=$ORIGINAL_HOOK
|
||||
[FSR]
|
||||
FsrAgilitySDKUpgrade=false
|
||||
[Libraries]
|
||||
NvngxPath=$(d4r_winpath "$D4R_RUNTIME_DIR/bin/d4r_nvngx.dll")
|
||||
NvngxDlssPath=$(d4r_winpath "$D4R_RUNTIME_DIR/bin")
|
||||
[NvApi]
|
||||
OverrideNvapiDll=false
|
||||
[Spoofing]
|
||||
Dxgi=false
|
||||
[Plugins]
|
||||
LoadAsiPlugins=false
|
||||
[Log]
|
||||
LogToFile=true
|
||||
LogLevel=1
|
||||
EOF
|
||||
|
||||
# Proton refreshes nvapi64.dll in the prefix on every run. Make a temporary
|
||||
# launcher that copies our identity bridge instead. Its other files are links
|
||||
# to the unmodified Proton installation.
|
||||
cp -f "$PROTON_DIR/proton" "$PROTON_DIR/filelock.py" "$PROTON_DIR/version" "$LAUNCHER_DIR/"
|
||||
ln -s "$PROTON_DIR/files" "$LAUNCHER_DIR/files"
|
||||
ln -s "$PROTON_DIR/protonfixes" "$LAUNCHER_DIR/protonfixes"
|
||||
LAUNCHER="$LAUNCHER_DIR/proton" python3 - <<'PY'
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
path = Path(os.environ["LAUNCHER"])
|
||||
source = path.read_text()
|
||||
old = 'try_copy(g_proton.arch_pe_dir("wine/nvapi", False) + "nvapi64.dll", "drive_c/windows/system32",'
|
||||
new = 'try_copy(os.environ.get("D4R_NVAPI_IDENTITY_DLL", g_proton.arch_pe_dir("wine/nvapi", False) + "nvapi64.dll"), "drive_c/windows/system32",'
|
||||
if source.count(old) != 1:
|
||||
raise SystemExit("Proton NVAPI copy point changed; cannot stage identity bridge")
|
||||
path.write_text(source.replace(old, new))
|
||||
PY
|
||||
chmod +x "$LAUNCHER_DIR/proton"
|
||||
|
||||
export STEAM_COMPAT_CLIENT_INSTALL_PATH="${STEAM_COMPAT_CLIENT_INSTALL_PATH:-$HOME/.local/share/Steam}"
|
||||
export STEAM_COMPAT_DATA_PATH="$COMPAT_DIR"
|
||||
PROTON_ENABLE_NVAPI=1 WINEDEBUG=-all "$PROTON_DIR/proton" run cmd /c exit 0 >/dev/null
|
||||
NVAPI_REAL="$PROTON_DIR/files/lib/wine/nvapi/x86_64-windows/nvapi64.dll"
|
||||
if [[ ! -f "$NVAPI_REAL" ]]; then
|
||||
printf 'Cannot find Proton DXVK-NVAPI at %s\n' "$NVAPI_REAL" >&2
|
||||
exit 2
|
||||
fi
|
||||
cp -f "$NVAPI_REAL" "$COMPAT_DIR/pfx/drive_c/windows/system32/d4r_nvapi64_real.dll"
|
||||
|
||||
export D4R_NVAPI_IDENTITY_DLL="$ROOT/build/nvapi64.dll"
|
||||
export D4R_HARNESS_APP_DIR="$APP_DIR"
|
||||
export D4R_HARNESS_NGX_DLL="$APP_DIR/dxgi.dll"
|
||||
export D4R_HARNESS_LOAD_NGX_EARLY=1
|
||||
export D4R_HARNESS_TRACE="$(d4r_winpath "$APP_DIR/harness.trace")"
|
||||
export D4R_SHIM_LOG="$(d4r_winpath "$APP_DIR/d4r_nvngx.log")"
|
||||
export D4R_PROTON_COMPAT_DATA="$COMPAT_DIR"
|
||||
export DXVK_CONFIG="${DXVK_CONFIG:-dxgi.customVendorId = 10de}"
|
||||
|
||||
"$ROOT/scripts/run_d3d12_dlss_harness_proton.sh" "$LAUNCHER_DIR" "$OUTPUT_PATH" "$@"
|
||||
|
||||
if [[ ! -s "$OUTPUT_PATH" || ! -f "$APP_DIR/OptiScaler.log" || ! -f "$APP_DIR/d4r_nvngx.log" ]] ||
|
||||
! rg -q 'DLSSFeatureDx12::Init _CreateFeature result: NVSDK_NGX_Result_Success' "$APP_DIR/OptiScaler.log" ||
|
||||
! rg -q 'NVSDK_NGX_CUDA_CreateFeature -> 0x00000001' "$APP_DIR/d4r_nvngx.log" ||
|
||||
! rg -q 'frame [0-9]+ done:' "$APP_DIR/d4r_nvngx.log"; then
|
||||
printf 'OptiScaler did not complete the official DLSS path; inspect %s\n' "$APP_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf 'OptiScaler DLSS harness output: %s\n' "$OUTPUT_PATH"
|
||||
printf 'OptiScaler, shim, and stage logs: %s\n' "$APP_DIR"
|
||||
sha256sum "$OUTPUT_PATH"
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Runs the D3D12 harness through a Proton build's own launcher script, so the
|
||||
# prefix, DXVK/vkd3d-proton/dxvk-nvapi and DLL overrides match a Steam game.
|
||||
# usage: run_d3d12_dlss_harness_proton.sh PROTON_DIR OUTPUT_RAW [FRAMES [IN_W IN_H OUT_W OUT_H]]
|
||||
if [[ $# -lt 2 ]]; then
|
||||
printf 'usage: %s PROTON_DIR OUTPUT_RAW [FRAMES [IN_W IN_H OUT_W OUT_H]]\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
PROTON_DIR="$(realpath "$1")"
|
||||
OUTPUT_PATH="$(realpath -m "$2")"
|
||||
shift 2
|
||||
source "$ROOT/scripts/d4r_proton_env.sh"
|
||||
if [[ "${D4R_HARNESS_SKIP_BUILD:-0}" != 1 ]]; then
|
||||
"$ROOT/scripts/build_d3d12_dlss_harness.sh" >/dev/null
|
||||
fi
|
||||
HARNESS_APP_DIR="${D4R_HARNESS_APP_DIR:-$ROOT/build}"
|
||||
mkdir -p "$HARNESS_APP_DIR"
|
||||
HARNESS_EXE="$HARNESS_APP_DIR/d3d12_dlss_harness.exe"
|
||||
if [[ "$(realpath -m "$HARNESS_EXE")" != "$(realpath -m "$ROOT/build/d3d12_dlss_harness.exe")" ]]; then
|
||||
cp -f "$ROOT/build/d3d12_dlss_harness.exe" "$HARNESS_EXE"
|
||||
fi
|
||||
export STEAM_COMPAT_CLIENT_INSTALL_PATH="${STEAM_COMPAT_CLIENT_INSTALL_PATH:-$HOME/.local/share/Steam}"
|
||||
export STEAM_COMPAT_DATA_PATH="${D4R_PROTON_COMPAT_DATA:-${TMPDIR:-/tmp}/d4r-proton-harness-compat}"
|
||||
mkdir -p "$STEAM_COMPAT_DATA_PATH"
|
||||
# D4R_HARNESS_NGX_DLL selects the NGX DLL the harness drives (default: the
|
||||
# shim; point it at OptiScaler installed as nvngx.dll to test OptiScaler).
|
||||
NGX_DLL="${D4R_HARNESS_NGX_DLL:-$D4R_RUNTIME_DIR/bin/d4r_nvngx.dll}"
|
||||
"$PROTON_DIR/proton" run "$HARNESS_EXE" "$(d4r_winpath "$NGX_DLL")" \
|
||||
"$(d4r_winpath "$OUTPUT_PATH")" "$@"
|
||||
printf '\nShim log:\n'
|
||||
if [[ -f "$D4R_RUNTIME_DIR/d4r_nvngx.log" ]]; then
|
||||
tail -n 20 "$D4R_RUNTIME_DIR/d4r_nvngx.log"
|
||||
fi
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Zero-copy D3D12 <-> HIP sharing probe under Proton (see the .cpp).
|
||||
# usage: run_d3d12_hip_interop_probe.sh PROTON_DIR REPORT_FILE [WIDTH HEIGHT]
|
||||
if [[ $# -lt 2 ]]; then
|
||||
printf 'usage: %s PROTON_DIR REPORT_FILE [WIDTH HEIGHT]\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
PROTON_DIR="$(realpath "$1")"
|
||||
REPORT="$(realpath -m "$2")"
|
||||
shift 2
|
||||
source "$ROOT/scripts/d4r_proton_env.sh"
|
||||
"$ROOT/scripts/build_d3d12_hip_interop_probe.sh" >/dev/null
|
||||
export STEAM_COMPAT_CLIENT_INSTALL_PATH="${STEAM_COMPAT_CLIENT_INSTALL_PATH:-$HOME/.local/share/Steam}"
|
||||
export STEAM_COMPAT_DATA_PATH="${D4R_PROTON_COMPAT_DATA:-${TMPDIR:-/tmp}/d4r-proton-harness-compat}"
|
||||
mkdir -p "$STEAM_COMPAT_DATA_PATH"
|
||||
"$PROTON_DIR/proton" run "$ROOT/build/d3d12_hip_interop_probe.exe" \
|
||||
"$(d4r_winpath "$D4R_RUNTIME_DIR/bin/nvcuda.dll")" "$(d4r_winpath "$REPORT")" "$@" || status=$?
|
||||
cat "$REPORT"
|
||||
exit "${status:-0}"
|
||||
Executable
+170
@@ -0,0 +1,170 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Launches a Windows game through a GE-Proton build's integrated OptiScaler
|
||||
# (PROTON_USE_OPTISCALER) with OptiScaler's DLSS backend routed into the d4r
|
||||
# shim, i.e. official NVIDIA DLSS executed through the Wine CUDA bridge and
|
||||
# ZLUDA on the AMD GPU.
|
||||
#
|
||||
# usage: run_game_d4r_optiscaler_proton.sh PROTON_DIR COMPAT_DATA_DIR GAME_EXE [ARGS...]
|
||||
#
|
||||
# The Proton installation and game directory are not modified. The prefix's
|
||||
# system32/umu/OptiScaler.ini (rewritten by GE-Proton from
|
||||
# PROTON_OPTISCALER_CONFIG) is restored when the game exits, and the real
|
||||
# DXVK-NVAPI is placed next to the identity bridge as d4r_nvapi64_real.dll.
|
||||
# With D4R_VKD3D_DIR (a directory holding d3d12.dll and d3d12core.dll, e.g. the
|
||||
# d4r-patched vkd3d-proton), those replace Proton's vkd3d-proton in the prefix
|
||||
# for this launch; the prefix's previous copies are backed up to the log
|
||||
# directory and restored when the game exits.
|
||||
# With D4R_UE_ENGINE_INI (the game's Saved/Config/Windows/Engine.ini) and
|
||||
# D4R_UE_CVARS ("r.A=0;r.B=1"), those console variables are added to its
|
||||
# [SystemSettings] for this launch only: an existing file is backed up to the
|
||||
# log directory and restored on exit, a new one is removed again. Unreal games
|
||||
# apply tonemapper sharpening and chromatic fringe after the upscaler; e.g.
|
||||
# Townfall's r.Tonemapper.Sharpen and r.SceneColorFringeQuality turn DLSS's
|
||||
# clean thin lines into haloed, stippled and beaded ones.
|
||||
# Logs go to D4R_GAME_LOG_DIR (default: a timestamped capture directory).
|
||||
if [[ $# -lt 3 ]]; then
|
||||
printf 'usage: %s PROTON_DIR COMPAT_DATA_DIR GAME_EXE [ARGS...]\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
PROTON_DIR="$(realpath "$1")"
|
||||
COMPAT_DIR="$(realpath "$2")"
|
||||
GAME_EXE="$(realpath "$3")"
|
||||
shift 3
|
||||
# User settings from d4r.ini (config/d4r.ini.default documents them); explicit environment wins.
|
||||
# D4R_NO_CONFIG=1 ignores the file (automated tests); D4R_CONFIG picks another file.
|
||||
if [[ "${D4R_NO_CONFIG:-0}" != 1 ]]; then
|
||||
python3 "$ROOT/scripts/d4r_config.py" --print >&2 || true
|
||||
D4R_CONFIG_EXPORTS="$(python3 "$ROOT/scripts/d4r_config.py")" || exit 2
|
||||
eval "$D4R_CONFIG_EXPORTS"
|
||||
fi
|
||||
source "$ROOT/scripts/d4r_proton_env.sh"
|
||||
|
||||
PREFIX="$COMPAT_DIR/pfx"
|
||||
UMU="$PREFIX/drive_c/windows/system32/umu"
|
||||
LOG_DIR="${D4R_GAME_LOG_DIR:-$HOME/.cache/d4r-dlss-captures/game-$(basename "$GAME_EXE" .exe)-$(date +%Y%m%d-%H%M%S)}"
|
||||
mkdir -p "$LOG_DIR"
|
||||
[[ -d "$PREFIX" ]] || { printf 'No Proton prefix at %s\n' "$PREFIX" >&2; exit 2; }
|
||||
# A second launch would join the running wineserver, and whichever run exits
|
||||
# first would restore its OptiScaler.ini backup underneath the other.
|
||||
SERVER_DIR="/tmp/.wine-$(id -u)/server-$(stat -c '%D' "$PREFIX" | sed 's/^0*//')-$(printf '%x' "$(stat -c '%i' "$PREFIX")")"
|
||||
if [[ -S "$SERVER_DIR/socket" ]] && fuser "$SERVER_DIR/socket" >/dev/null 2>&1; then
|
||||
printf 'A wineserver is already running for %s; close that game first\n' "$PREFIX" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
"$ROOT/scripts/build_d4r_nvapi_identity.sh" >/dev/null
|
||||
NVAPI_REAL="$PROTON_DIR/files/lib/wine/nvapi/x86_64-windows/nvapi64.dll"
|
||||
[[ -f "$NVAPI_REAL" ]] || { printf 'Cannot find DXVK-NVAPI at %s\n' "$NVAPI_REAL" >&2; exit 2; }
|
||||
cp -f "$NVAPI_REAL" "$PREFIX/drive_c/windows/system32/d4r_nvapi64_real.dll"
|
||||
|
||||
# Temporary launcher: identical to the Proton build except that the NVAPI copy
|
||||
# installs the identity bridge (so OptiScaler enables its DLSS backend).
|
||||
LAUNCHER_DIR="$(mktemp -d "${TMPDIR:-/tmp}/d4r-game-proton.XXXXXXXX")"
|
||||
for entry in "$PROTON_DIR"/*; do
|
||||
[[ "$(basename "$entry")" == proton ]] || ln -s "$entry" "$LAUNCHER_DIR/$(basename "$entry")"
|
||||
done
|
||||
cp -f "$PROTON_DIR/proton" "$LAUNCHER_DIR/proton"
|
||||
LAUNCHER="$LAUNCHER_DIR/proton" python3 - <<'PY'
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
path = Path(os.environ["LAUNCHER"])
|
||||
source = path.read_text()
|
||||
variants = [
|
||||
'g_proton.arch_pe_dir("wine/nvapi", False) + "nvapi64.dll"',
|
||||
'g_proton.arch_pe_dir("wine/" + nvapi_path, False) + "nvapi64.dll"',
|
||||
]
|
||||
for old in variants:
|
||||
target = f'try_copy({old}, "drive_c/windows/system32",'
|
||||
if source.count(target) == 1:
|
||||
new = f'try_copy(os.environ.get("D4R_NVAPI_IDENTITY_DLL", {old}), "drive_c/windows/system32",'
|
||||
path.write_text(source.replace(target, new))
|
||||
break
|
||||
else:
|
||||
raise SystemExit("Proton NVAPI copy point not found; cannot stage identity bridge")
|
||||
if os.environ.get("D4R_VKD3D_DIR"):
|
||||
source = path.read_text()
|
||||
old = 'try_copy(g_proton.arch_pe_dir("wine/vkd3d-proton", False) + f + ".dll", "drive_c/windows/system32",'
|
||||
new = ('try_copy(os.path.join(os.environ["D4R_VKD3D_DIR"], f + ".dll"), "drive_c/windows/system32",')
|
||||
if source.count(old) != 1:
|
||||
raise SystemExit("Proton vkd3d-proton copy point not found; cannot stage D4R_VKD3D_DIR")
|
||||
path.write_text(source.replace(old, new))
|
||||
PY
|
||||
|
||||
# GE-Proton rewrites OptiScaler.ini from PROTON_OPTISCALER_CONFIG; keep the
|
||||
# user's configuration and put it back afterwards.
|
||||
INI="$UMU/OptiScaler.ini"
|
||||
[[ -f "$INI" ]] && cp -f "$INI" "$LOG_DIR/OptiScaler.ini.before"
|
||||
VKD3D_BACKUP="$LOG_DIR/vkd3d-prefix-backup"
|
||||
if [[ -n "${D4R_VKD3D_DIR:-}" ]]; then
|
||||
export D4R_VKD3D_DIR="$(realpath "$D4R_VKD3D_DIR")"
|
||||
for dll in d3d12.dll d3d12core.dll; do
|
||||
[[ -f "$D4R_VKD3D_DIR/$dll" ]] || { printf 'D4R_VKD3D_DIR lacks %s\n' "$dll" >&2; exit 2; }
|
||||
done
|
||||
mkdir -p "$VKD3D_BACKUP"
|
||||
for dll in d3d12.dll d3d12core.dll; do
|
||||
[[ -f "$PREFIX/drive_c/windows/system32/$dll" ]] && cp -f "$PREFIX/drive_c/windows/system32/$dll" "$VKD3D_BACKUP/$dll"
|
||||
done
|
||||
fi
|
||||
ENGINE_INI="${D4R_UE_ENGINE_INI:-}"
|
||||
ENGINE_INI_STATE=""
|
||||
restore_prefix() {
|
||||
[[ -f "$LOG_DIR/OptiScaler.ini.before" ]] && cp -f "$LOG_DIR/OptiScaler.ini.before" "$INI"
|
||||
case "$ENGINE_INI_STATE" in
|
||||
restore) cp -f "$LOG_DIR/Engine.ini.before" "$ENGINE_INI" ;;
|
||||
remove) rm -f "$ENGINE_INI" ;;
|
||||
esac
|
||||
if [[ -n "${D4R_VKD3D_DIR:-}" ]]; then
|
||||
for dll in d3d12.dll d3d12core.dll; do
|
||||
[[ -f "$VKD3D_BACKUP/$dll" ]] && cp -f "$VKD3D_BACKUP/$dll" "$PREFIX/drive_c/windows/system32/$dll"
|
||||
done
|
||||
fi
|
||||
rm -rf "$LAUNCHER_DIR"
|
||||
}
|
||||
trap restore_prefix EXIT
|
||||
if [[ -n "$ENGINE_INI" && -n "${D4R_UE_CVARS:-}" ]]; then
|
||||
if [[ -f "$ENGINE_INI" ]]; then
|
||||
cp -f "$ENGINE_INI" "$LOG_DIR/Engine.ini.before"
|
||||
ENGINE_INI_STATE=restore
|
||||
else
|
||||
mkdir -p "$(dirname "$ENGINE_INI")"
|
||||
ENGINE_INI_STATE=remove
|
||||
fi
|
||||
{ printf '\n[SystemSettings]\n'; tr ';' '\n' <<<"$D4R_UE_CVARS"; printf '\n'; } >> "$ENGINE_INI"
|
||||
fi
|
||||
|
||||
OPTI_CONFIG="Upscalers.Dx12Upscaler=dlss;DLSS.Enabled=true"
|
||||
OPTI_CONFIG+=";Libraries.NvngxPath=$(d4r_winpath "$D4R_RUNTIME_DIR/bin/d4r_nvngx.dll")"
|
||||
OPTI_CONFIG+=";Libraries.NvngxDlssPath=$(d4r_winpath "$D4R_RUNTIME_DIR/bin")"
|
||||
# Game-side DLSS inputs stay hooked; only NGX loads outside the game directory
|
||||
# are redirected, which lets the shim request the official core by an
|
||||
# exe-relative path.
|
||||
OPTI_CONFIG+=";Inputs.EnableDlssInputs=true;Hooks.HookOriginalNvngxOnly=true"
|
||||
OPTI_CONFIG+=";NvApi.OverrideNvapiDll=false;FrameGen.Enabled=false;FrameGen.FGInput=nofg;FrameGen.FGOutput=nofg"
|
||||
OPTI_CONFIG+=";Log.LogToFile=true;Log.LogLevel=${D4R_OPTISCALER_LOG_LEVEL:-2}"
|
||||
# Detailed FPS overlay with frame-time graph (the user's own INI default too).
|
||||
OPTI_CONFIG+=";Menu.ShowFps=${D4R_OPTISCALER_SHOW_FPS:-true};Menu.FpsOverlayType=${D4R_OPTISCALER_FPS_OVERLAY_TYPE:-3}"
|
||||
OPTI_CONFIG+="${D4R_EXTRA_OPTISCALER_CONFIG:+;$D4R_EXTRA_OPTISCALER_CONFIG}"
|
||||
|
||||
export PROTON_USE_OPTISCALER=1
|
||||
export PROTON_OPTISCALER_CONFIG="$OPTI_CONFIG"
|
||||
export D4R_NVAPI_IDENTITY_DLL="$ROOT/build/nvapi64.dll"
|
||||
export DXVK_CONFIG="${DXVK_CONFIG:-dxgi.customVendorId = 10de}"
|
||||
export D4R_SHIM_LOG="$(d4r_winpath "$LOG_DIR/d4r_nvngx.log")"
|
||||
export STEAM_COMPAT_CLIENT_INSTALL_PATH="${STEAM_COMPAT_CLIENT_INSTALL_PATH:-$HOME/.local/share/Steam}"
|
||||
export STEAM_COMPAT_DATA_PATH="$COMPAT_DIR"
|
||||
export PROTON_LOG=1 PROTON_LOG_DIR="$LOG_DIR"
|
||||
export WINEDEBUG="${WINEDEBUG:--all}"
|
||||
# Games load dozens of modules per launch; do not capture them unless asked.
|
||||
export D4R_CUDA_CAPTURE="${D4R_CUDA_CAPTURE:-0}"
|
||||
|
||||
printf 'd4r game launch: %s\nlogs: %s\n' "$GAME_EXE" "$LOG_DIR"
|
||||
status=0
|
||||
(cd "$(dirname "$GAME_EXE")" && "$LAUNCHER_DIR/proton" waitforexitandrun "$GAME_EXE" "$@") \
|
||||
>"$LOG_DIR/launcher.log" 2>&1 || status=$?
|
||||
cp -f "$UMU/OptiScaler.log" "$LOG_DIR/OptiScaler.log" 2>/dev/null || true
|
||||
printf 'game exited with status %s\n' "$status"
|
||||
exit "$status"
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ROCM_ROOT="${ROCM_ROOT:-/opt/rocm}"
|
||||
|
||||
"$ROOT/scripts/build_hip_vk_interop_probe.sh"
|
||||
LD_LIBRARY_PATH="$ROCM_ROOT/lib:$ROCM_ROOT/lib/llvm/lib:${LD_LIBRARY_PATH:-}" \
|
||||
"$ROOT/build/hip_vk_interop_probe"
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 3 ]]; then
|
||||
printf 'usage: %s PATH_TO_NGX_CORE_DLL PATH_TO_NVNGX_DLSS_DLL WRITABLE_APPDATA_DIRECTORY\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CORE_PATH="$(realpath "$1")"
|
||||
FEATURE_DLL_PATH="$(realpath "$2")"
|
||||
DATA_PATH="$(realpath -m "$3")"
|
||||
WINE_BIN="${WINE:-wine}"
|
||||
WINEPREFIX="${D4R_WINEPREFIX:-${TMPDIR:-/tmp}/d4r-wineprefix}"
|
||||
APP_DIR="${D4R_NGX_CUDA_APPDIR:-${TMPDIR:-/tmp}/d4r-ngxcuda-app}"
|
||||
CAPTURE_DIR="${D4R_CUDA_CAPTURE_DIR:-${TMPDIR:-/tmp}/d4r-dlss-cuda-modules}"
|
||||
ZLUDA_ROOT="${ZLUDA_ROOT:-}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-}"
|
||||
|
||||
TMP_ROOT="$(realpath -m "${TMPDIR:-/tmp}")"
|
||||
WINEPREFIX="$(realpath -m "$WINEPREFIX")"
|
||||
APP_DIR="$(realpath -m "$APP_DIR")"
|
||||
DATA_PATH="$(realpath -m "$DATA_PATH")"
|
||||
CAPTURE_DIR="$(realpath -m "$CAPTURE_DIR")"
|
||||
case "$WINEPREFIX/" in
|
||||
"$TMP_ROOT/"*) ;;
|
||||
*)
|
||||
printf 'D4R_WINEPREFIX must be an isolated prefix under %s; refusing to modify a non-temporary prefix\n' "$TMP_ROOT" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
for isolated_path in "$APP_DIR" "$DATA_PATH" "$CAPTURE_DIR"; do
|
||||
case "$isolated_path/" in
|
||||
"$TMP_ROOT/"*) ;;
|
||||
*)
|
||||
printf 'App directory, appdata, and CUDA captures must stay under %s; refusing to write outside temporary storage\n' "$TMP_ROOT" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ! -f "$ZLUDA_ROOT/libcuda.so" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ZLUDA_ROOT and ROCM_ROOT to the temporary or installed ZLUDA/HIP runtimes\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$WINEPREFIX/drive_c/windows/system32" "$DATA_PATH" "$APP_DIR" "$CAPTURE_DIR"
|
||||
"$ROOT/scripts/build_ngx_cuda_probe.sh"
|
||||
"$ROOT/scripts/build_wine_nvcuda_bridge.sh"
|
||||
cp -f "$ROOT/build/wine-nvcuda/x86_64-windows/nvcuda.dll" "$WINEPREFIX/drive_c/windows/system32/nvcuda.dll"
|
||||
APP_EXE_PATH="$APP_DIR/ngx_cuda_probe.exe"
|
||||
APP_FEATURE_DLL_PATH="$APP_DIR/nvngx_dlss.dll"
|
||||
cp -f "$ROOT/build/ngx_cuda_probe.exe" "$APP_EXE_PATH"
|
||||
cp -f "$FEATURE_DLL_PATH" "$APP_FEATURE_DLL_PATH"
|
||||
CORE_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$CORE_PATH")"
|
||||
FEATURE_DLL_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$APP_FEATURE_DLL_PATH")"
|
||||
DATA_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$DATA_PATH")"
|
||||
APP_EXE_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$APP_EXE_PATH")"
|
||||
WINE_OVERRIDES="${WINEDLLOVERRIDES:-}"
|
||||
for override in 'dxgi=n,b' 'd3d12=n,b' 'd3d12core=n,b' 'nvcuda=b'; do
|
||||
dll_name="${override%%=*}"
|
||||
if [[ ";$WINE_OVERRIDES;" != *";$dll_name="* ]]; then
|
||||
WINE_OVERRIDES="${WINE_OVERRIDES:+$WINE_OVERRIDES;}$override"
|
||||
fi
|
||||
done
|
||||
LD_LIBRARY_PATH="$ZLUDA_ROOT:$ROCM_ROOT/lib:$ROCM_ROOT/lib/llvm/lib:${LD_LIBRARY_PATH:-}" \
|
||||
WINEDLLPATH="$ROOT/build/wine-nvcuda/x86_64-windows:$ROOT/build/wine-nvcuda/x86_64-unix${WINEDLLPATH:+:$WINEDLLPATH}" \
|
||||
WINEDLLOVERRIDES="$WINE_OVERRIDES" WINEPREFIX="$WINEPREFIX" \
|
||||
WINEDEBUG="${D4R_WINEDEBUG:--all}" \
|
||||
D4R_CUDA_CAPTURE_DIR="$CAPTURE_DIR" \
|
||||
"$WINE_BIN" "$APP_EXE_WIN_PATH" "$CORE_WIN_PATH" "$FEATURE_DLL_WIN_PATH" "$DATA_WIN_PATH"
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 3 ]]; then
|
||||
printf 'usage: %s PATH_TO_NGX_CORE_DLL PATH_TO_NVNGX_DLSS_DLL WRITABLE_APPDATA_DIRECTORY\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CORE_PATH="$(realpath "$1")"
|
||||
FEATURE_DLL_PATH="$(realpath "$2")"
|
||||
DATA_PATH="$(realpath -m "$3")"
|
||||
WINE_BIN="${WINE:-wine}"
|
||||
WINEPREFIX="${D4R_WINEPREFIX:-${TMPDIR:-/tmp}/d4r-wineprefix}"
|
||||
|
||||
mkdir -p "$WINEPREFIX" "$DATA_PATH"
|
||||
"$ROOT/scripts/build_ngx_d3d12_probe.sh"
|
||||
CORE_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$CORE_PATH")"
|
||||
FEATURE_DLL_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$FEATURE_DLL_PATH")"
|
||||
DATA_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$DATA_PATH")"
|
||||
WINEPREFIX="$WINEPREFIX" WINEDEBUG="${D4R_WINEDEBUG:--all}" \
|
||||
"$WINE_BIN" "$ROOT/build/ngx_d3d12_probe.exe" "$CORE_WIN_PATH" "$FEATURE_DLL_WIN_PATH" "$DATA_WIN_PATH"
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
printf 'usage: %s PATH_TO_NVNGX_DLSS_DLL\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
DLL_PATH="$(realpath "$1")"
|
||||
WINE_BIN="${WINE:-wine}"
|
||||
WINEPREFIX="${D4R_WINEPREFIX:-${TMPDIR:-/tmp}/d4r-wineprefix}"
|
||||
|
||||
"$ROOT/scripts/build_ngx_load_probe.sh"
|
||||
mkdir -p "$WINEPREFIX"
|
||||
DLL_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$DLL_PATH")"
|
||||
WINEPREFIX="$WINEPREFIX" WINEDEBUG="${D4R_WINEDEBUG:--all}" \
|
||||
"$WINE_BIN" "$ROOT/build/ngx_load_probe.exe" "$DLL_WIN_PATH"
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 3 ]]; then
|
||||
printf 'usage: %s PATH_TO_NGX_CORE_DLL PATH_TO_NVNGX_DLSS_DLL WRITABLE_APPDATA_DIRECTORY\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CORE_PATH="$(realpath "$1")"
|
||||
FEATURE_DLL_PATH="$(realpath "$2")"
|
||||
DATA_PATH="$(realpath -m "$3")"
|
||||
WINE_BIN="${WINE:-wine}"
|
||||
WINEPREFIX="${D4R_WINEPREFIX:-${TMPDIR:-/tmp}/d4r-wineprefix}"
|
||||
|
||||
mkdir -p "$WINEPREFIX" "$DATA_PATH"
|
||||
"$ROOT/scripts/build_ngx_vulkan_probe.sh"
|
||||
CORE_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$CORE_PATH")"
|
||||
FEATURE_DLL_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$FEATURE_DLL_PATH")"
|
||||
DATA_WIN_PATH="$(WINEPREFIX="$WINEPREFIX" winepath -w "$DATA_PATH")"
|
||||
WINEPREFIX="$WINEPREFIX" WINEDEBUG="${D4R_WINEDEBUG:--all}" \
|
||||
"$WINE_BIN" "$ROOT/build/ngx_vulkan_probe.exe" "$CORE_WIN_PATH" "$FEATURE_DLL_WIN_PATH" "$DATA_WIN_PATH"
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ZLUDA_ROOT="${ZLUDA_ROOT:-}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-}"
|
||||
if [[ -z "$ZLUDA_ROOT" || -z "$ROCM_ROOT" || ! -f "$ZLUDA_ROOT/libcuda.so" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ZLUDA_ROOT and ROCM_ROOT to the ZLUDA and HIP runtimes\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
"$ROOT/scripts/build_replay_dlss_fp8_ops.sh"
|
||||
LD_LIBRARY_PATH="$ZLUDA_ROOT:$ROCM_ROOT/lib:$ROCM_ROOT/lib/llvm/lib:${LD_LIBRARY_PATH:-}" \
|
||||
"$ROOT/build/replay_dlss_fp8_ops"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
printf 'usage: %s PATH_TO_LOCALLY_CAPTURED_DLSS_HISTOGRAM_FATBIN\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ZLUDA_ROOT="${ZLUDA_ROOT:-}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-}"
|
||||
if [[ -z "$ZLUDA_ROOT" || -z "$ROCM_ROOT" || ! -f "$ZLUDA_ROOT/libcuda.so" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ZLUDA_ROOT and ROCM_ROOT to the ZLUDA and HIP runtimes\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
"$ROOT/scripts/build_replay_dlss_histogram.sh"
|
||||
LD_LIBRARY_PATH="$ZLUDA_ROOT:$ROCM_ROOT/lib:$ROCM_ROOT/lib/llvm/lib:${LD_LIBRARY_PATH:-}" \
|
||||
"$ROOT/build/replay_dlss_histogram" "$1"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -lt 1 || $# -gt 2 ]]; then
|
||||
printf 'usage: %s PATH_TO_LOCALLY_CAPTURED_DLSS_FATBIN [KERNEL_NAME]\n' "$0" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ZLUDA_ROOT="${ZLUDA_ROOT:-}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-}"
|
||||
if [[ -z "$ZLUDA_ROOT" || -z "$ROCM_ROOT" || ! -f "$ZLUDA_ROOT/libcuda.so" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ZLUDA_ROOT and ROCM_ROOT to the ZLUDA and HIP runtimes\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
"$ROOT/scripts/build_replay_dlss_kernel.sh"
|
||||
LD_LIBRARY_PATH="$ZLUDA_ROOT:$ROCM_ROOT/lib:$ROCM_ROOT/lib/llvm/lib:${LD_LIBRARY_PATH:-}" \
|
||||
"$ROOT/build/replay_dlss_kernel" "$@"
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ZLUDA_ROOT="${ZLUDA_ROOT:-}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-}"
|
||||
if [[ -z "$ZLUDA_ROOT" || -z "$ROCM_ROOT" || ! -f "$ZLUDA_ROOT/libcuda.so" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ZLUDA_ROOT and ROCM_ROOT to the ZLUDA and HIP runtimes\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
"$ROOT/scripts/build_replay_dlss_surface_half_store.sh"
|
||||
LD_LIBRARY_PATH="$ZLUDA_ROOT:$ROCM_ROOT/lib:$ROCM_ROOT/lib/llvm/lib:${LD_LIBRARY_PATH:-}" \
|
||||
"$ROOT/build/replay_dlss_surface_half_store"
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ZLUDA_ROOT="${ZLUDA_ROOT:-}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-}"
|
||||
if [[ -z "$ZLUDA_ROOT" || -z "$ROCM_ROOT" || ! -f "$ZLUDA_ROOT/libcuda.so" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ZLUDA_ROOT and ROCM_ROOT to the ZLUDA and HIP runtimes\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
"$ROOT/scripts/build_replay_dlss_surface_store.sh"
|
||||
LD_LIBRARY_PATH="$ZLUDA_ROOT:$ROCM_ROOT/lib:$ROCM_ROOT/lib/llvm/lib:${LD_LIBRARY_PATH:-}" \
|
||||
"$ROOT/build/replay_dlss_surface_store"
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ZLUDA_ROOT="${ZLUDA_ROOT:-}"
|
||||
ROCM_ROOT="${ROCM_ROOT:-}"
|
||||
if [[ -z "$ZLUDA_ROOT" || -z "$ROCM_ROOT" || ! -f "$ZLUDA_ROOT/libcuda.so" || ! -f "$ROCM_ROOT/lib/libamdhip64.so" ]]; then
|
||||
printf 'Set ZLUDA_ROOT and ROCM_ROOT to the ZLUDA and HIP runtimes\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
"$ROOT/scripts/build_replay_dlss_texture_sample.sh"
|
||||
LD_LIBRARY_PATH="$ZLUDA_ROOT:$ROCM_ROOT/lib:$ROCM_ROOT/lib/llvm/lib:${LD_LIBRARY_PATH:-}" \
|
||||
"$ROOT/build/replay_dlss_texture_sample"
|
||||
Reference in new issue
Block a user