TL;DR: Add an experimental FSR Ray Regeneration backend on Windows, run the K

network natively on HIP with Vulkan->HIP shared memory, extend K kernels to
gfx11 (RDNA3), and add dependency/packaging/test tooling around them.

Windows: FSR RR backend, native HIP K runner, gfx11 K kernels, tooling

FSR Ray Regeneration (experimental)
- Add fsr_rr_backend.{h,cpp}, fsr_rr_passes.h and the fsr_rr/ prepare and
  compose compute shaders. They run AMD's FidelityFX denoiser
  (amd_fidelityfx_denoiser_dx12.dll, SDK 2.3, not bundled) on a private
  vkd3d-proton device.
- Add the amdxc64 shim (tools/windows/amdxc64_shim) and two vkd3d-proton
  patches for libcxx includes. AMD's amdxc64.dll is never loaded.
- d4r_nvngx_windows: RrFeature now selects between the native DLSS RR
  backend and the FSR backend (D4R_RR_BACKEND=fsr). After the denoiser it
  runs an internal Super Sampling stage (feature 1) to upscale. If SR is
  unavailable and output != render size, the frame fails; it is never
  returned noisy.
- d4r.ini / player_config: new [RayReconstruction] FsrDenoiser,
  FsrStabilityBias (auto or >= 0) and FsrDetail (0-1), with validation, and
  matching D4R_FSR_* environment variables.
- Add the FSR RR fixture, output-check and ngx test scripts, and a shader
  compile script.

Native HIP K runner (Windows)
- CMake: add d4r_engine_k_hip (d4r-k-hip) plus separate volk/engine copies,
  because VK_USE_PLATFORM_WIN32_KHR changes volk's entry points.
- Share Vulkan memory with HIP via Win32 opaque handles on Windows
  (VK_KHR_external_memory_win32) and via fds on Linux. Handle types are now
  intptr_t, and the platform choice is in D4R_EXT_MEMORY_* macros.
- HipNetwork: add debugRepeatHashes and debugNodeMicros, exposed as
  D4R_HIP_REPEAT_CHECK, D4R_HIP_REPEAT_ALL and D4R_HIP_NODE_PROFILE in
  replay.cpp.
- replay.cpp: display-resolution-motion frames (FrameFlagDisplayMotion) no
  longer require near2rnd == out2rnd. Both values must still be in (0, 1].

K kernels on gfx11
- Allow position-token and enc1 tiling on __GFX11__ as well as gfx12.
- Add an opt-in ds_bpermute cross-half exchange
  (D4R_WINDOWS_GFX11_DS_EXCHANGE, enabled for K on Windows gfx11). M keeps
  its LDS path.
- Fix a block-barrier race in the position layer. Without POS_VSHARE a fast
  wave could overwrite its hb rows while a slower wave still read them for a
  later head, giving rare wrong results on gfx1101 (enc0 outputs differing
  between identical launches).

Packaging and install
- install.bat, d4r.ini, WINDOWS_README: FSR option, and
  install_dependencies.py to install pinned NVIDIA dependencies with staged,
  hash-verified replacement and rollback.
- Update the release package, local package refresh and test scripts.
- Add the InteropBatchInputCopies option (default false). Batching is faster
  on some synthetic runs, but player temporal exactness is unresolved.

Tooling and tests
- K model: capture_k_weights, build_k_model, compare_k_outputs,
  benchmark_k_hip, build_capture_runtime, test_k_model and the
  zluda-k-output-capture patch. Captured weights and models are private
  local assets and must not enter release archives.
- Synthetic probes: test_m_ngx, test_sr_dynamic,
  prepare_rr_dynamic_fixture and the d3d12/rr_ngx probe updates.
- Add tests/windows/test_install_dependencies.py.

Docs
- Update the windows-fsr-rr, k-performance, local-package, rr-interop and
  rr-model-cache docs. Add windows-parity-handoff.md and
  windows-parity-continuation-prompt.md.
This commit is contained in:
ayo committed 2026-10-17 01:43:06 -04:00
1 parent 247fe1092d
commit a617c818de
62 files changed
+5894 -89

No files matched your search

+28 -1
View File
@@ -90,15 +90,21 @@ foreach(family k m)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${source}")
file(READ "${source}" kernel_source)
string(REGEX MATCH "// d4r-build-flags: ([^\r\n]+)" flags_line "${kernel_source}")
set(source_flags_text "${CMAKE_MATCH_1}")
set(native_flags)
if(family STREQUAL "k" AND D4R_K_FP16_BASELINE)
list(APPEND native_flags -DD4R_K_FP16_BASELINE)
endif()
if(family STREQUAL "k" AND WIN32 AND D4R_GPU_ARCH MATCHES "^gfx11")
# Bit-preserving cross-half exchange, validated after the position-layer barrier fix.
# Keep M on its separately validated LDS exchange path.
list(APPEND native_flags -DD4R_WINDOWS_GFX11_DS_EXCHANGE)
endif()
if(family STREQUAL "m" AND D4R_M_FP16_BASELINE)
list(APPEND native_flags -DSWIN_EXACT -DSWIN_EXACT_PV)
endif()
if(flags_line)
separate_arguments(source_flags NATIVE_COMMAND "${CMAKE_MATCH_1}")
separate_arguments(source_flags NATIVE_COMMAND "${source_flags_text}")
list(APPEND native_flags ${source_flags})
endif()
add_custom_command(OUTPUT "${native_object}"
@@ -159,6 +165,23 @@ if(D4R_BUILD_NATIVE_ENGINE)
set_target_properties(d4r_engine_${runner} PROPERTIES OUTPUT_NAME "d4r-${runner}")
install(TARGETS d4r_engine_${runner} RUNTIME DESTINATION engine/bin)
endforeach()
# Experimental: K runner with the native HIP network (Win32 opaque memory shared Vulkan -> HIP). Separate
# volk/engine copies because VK_USE_PLATFORM_WIN32_KHR changes volk's loaded entry points.
add_library(d4r_volk_hip STATIC "${D4R_VOLK_ROOT}/volk.c")
target_include_directories(d4r_volk_hip PUBLIC "${D4R_VOLK_ROOT}" "${D4R_VULKAN_HEADERS_ROOT}/include")
target_compile_definitions(d4r_volk_hip PUBLIC VK_NO_PROTOTYPES VK_USE_PLATFORM_WIN32_KHR WIN32_LEAN_AND_MEAN NOMINMAX)
add_library(d4r_engine_hip STATIC engine/runtime.cpp engine/game.cpp engine/game_m.cpp engine/game_rr.cpp)
target_precompile_headers(d4r_engine_hip PRIVATE engine/volk_pch.h)
target_link_libraries(d4r_engine_hip PUBLIC d4r_volk_hip)
add_executable(d4r_engine_k_hip engine/replay.cpp engine/hip_net.cpp)
target_include_directories(d4r_engine_k_hip PRIVATE "${D4R_HIP_ROOT}/include")
target_compile_definitions(d4r_engine_k_hip PRIVATE D4R_ENGINE_VOLK D4R_ENGINE_HIP __HIP_PLATFORM_AMD__)
target_precompile_headers(d4r_engine_k_hip PRIVATE engine/volk_pch.h)
target_link_libraries(d4r_engine_k_hip PRIVATE d4r_engine_hip "${D4R_HIP_ROOT}/lib/amdhip64.lib")
if(MINGW)
target_link_options(d4r_engine_k_hip PRIVATE -static)
endif()
set_target_properties(d4r_engine_k_hip PROPERTIES OUTPUT_NAME "d4r-k-hip")
else()
message(STATUS "Standalone engine skipped: run scripts/windows/setup-native-engine.ps1 for pinned Vulkan-Headers and Volk")
endif()
@@ -203,6 +226,10 @@ target_include_directories(d4r_nvngx_windows PRIVATE "${D4R_HIP_ROOT}/include")
target_link_libraries(d4r_nvngx_windows PRIVATE version dbghelp d3d12 dxguid minhook bcrypt)
if(TARGET d4r_engine)
target_sources(d4r_nvngx_windows PRIVATE tools/windows/rr_native_backend.cpp)
# Experimental FSR Ray Regeneration backend (needs vkd3d-proton, AMD's denoiser DLL and the amdxc64 shim at run time).
target_sources(d4r_nvngx_windows PRIVATE tools/windows/fsr_rr_backend.cpp)
target_compile_definitions(d4r_nvngx_windows PRIVATE D4R_FSR_RR_BACKEND=1)
target_link_libraries(d4r_nvngx_windows PRIVATE dxgi)
target_link_libraries(d4r_nvngx_windows PRIVATE d4r_engine)
target_compile_definitions(d4r_nvngx_windows PRIVATE D4R_NATIVE_RR_BACKEND=1)
endif()