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:
1 parent
247fe1092d
commit
a617c818de
62 files changed
+5894
-89
No files matched your search
@@ -0,0 +1,109 @@
|
||||
"""Capture and extract private K weights through the existing synthetic Windows probe.
|
||||
|
||||
Uses the audited ZLUDA layer-capture hook, not a game or DLL patch. Generated
|
||||
weights/captures are private local assets and must never enter release archives.
|
||||
This does not yet capture the reconstruction LUT or build a full K model.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def sha(path):
|
||||
with path.open('rb') as stream:
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
repo = Path(__file__).resolve().parents[2]
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
for name in ('probe', 'shim', 'runtime', 'core', 'dlss', 'native', 'output'):
|
||||
parser.add_argument('--' + name, required=True, type=lambda p: Path(p).resolve())
|
||||
parser.add_argument('--output-resolution', default='512x288', help='NGX output WxH (default 512x288)')
|
||||
parser.add_argument('--input-resolution', default='256x144', help='NGX render WxH (default 256x144)')
|
||||
parser.add_argument('--include-lut', action='store_true', help='requires audited 328-byte output capture support in isolated runtime')
|
||||
args = parser.parse_args()
|
||||
if args.output.exists() or not args.output.is_relative_to((repo / 'build').resolve()):
|
||||
parser.error('use a fresh directory under ignored build/')
|
||||
if sha(args.dlss) != '3975567b8943c53acce397f2b72380092f84f162d00b0d2c7d08a1025c563983':
|
||||
parser.error('requires pinned SR 310.9.1')
|
||||
if sha(args.core) != '66767018c36b3bab46398dade3adf173daa3730fda75965689ea848c9bc4e79b':
|
||||
parser.error('requires pinned NGX core 617.14')
|
||||
args.output.mkdir(parents=True)
|
||||
capture = args.output / 'capture'
|
||||
env = {key: value for key, value in os.environ.items()
|
||||
if not key.startswith('D4R_') and key not in ('ZLUDA_LOG_DIR', 'ZLUDA_CACHE_DIR', 'ZLUDA_CUDA_LIB')}
|
||||
runtime = args.runtime
|
||||
nvapi = runtime / 'nvapi/gfx1101/nvapi64.dll'
|
||||
if not nvapi.is_file():
|
||||
nvapi = runtime / 'nvapi/nvapi64.dll'
|
||||
env.update(HIP_PATH=str(runtime / 'hip'), ZLUDA_CUDA_LIB=str(runtime / 'zluda/nvcuda.dll'),
|
||||
D4R_NVAPI_BACKEND=str(runtime / 'nvapi/backend/nvapi64.dll'),
|
||||
D4R_FORMAT_MODULE=str(runtime / 'pixel_convert_gfx1101.hsaco'),
|
||||
D4R_ZLUDA_NATIVE_DIR=str(args.native), D4R_ZLUDA_WMMA='1',
|
||||
D4R_ZLUDA_WMMA_FP8='1', D4R_ZLUDA_WMMA_F16_REFERENCE='1', D4R_QUIET_API='1',
|
||||
D4R_DIAG_DIR=str(args.output), D4R_NGX_DATA_DIR=str(args.output / 'ngx-data'),
|
||||
D4R_CUDA_REPLAY_DUMP_DIR=str(capture), D4R_CUDA_REPLAY_DUMP_FILTER='dltss_pwin_',
|
||||
D4R_CUDA_REPLAY_DUMP_LIMIT='1')
|
||||
if args.include_lut:
|
||||
env['D4R_CUDA_REPLAY_DUMP_FILTER'] = ''
|
||||
env['PATH'] = str(runtime / 'hip/bin') + os.pathsep + str(runtime / 'zluda') + os.pathsep + env['PATH']
|
||||
command = [str(args.probe), '--module', str(args.shim), '--hip-root', str(runtime / 'hip'),
|
||||
'--cuda-dll', str(runtime / 'zluda/nvcuda.dll'), '--ngx-core', str(args.core),
|
||||
'--dlss-dll', str(args.dlss), '--nvapi-dll', str(nvapi), '--ngx-abi', 'project',
|
||||
'--interop-mode', 'command-list', '--preset', '11', '--ngx-output-resolution', args.output_resolution,
|
||||
'--ngx-input-resolution', args.input_resolution, '--iterations', '1']
|
||||
report = dict(passed=False, privateLocalWeights=True, gameAccessed=False, reconstructionLutCaptured=False,
|
||||
artifacts={str(p):sha(p) for p in (args.probe, args.shim, args.core, args.dlss, runtime / 'zluda/nvcuda.dll')})
|
||||
try:
|
||||
with (args.output / 'probe.stdout.log').open('wb') as out, (args.output / 'probe.stderr.log').open('wb') as err:
|
||||
result = subprocess.run(command, env=env, stdout=out, stderr=err, timeout=180)
|
||||
if result.returncode or 'PASS D3D12_DLSS' not in (args.output / 'probe.stdout.log').read_text(errors='replace'):
|
||||
raise RuntimeError('Synthetic capture probe failed; inspect logs')
|
||||
expected = {'enc0', 'enc1', 'enc2', 'enc3', 'enc4', 'dec5', 'dec4', 'dec3', 'dec2', 'dec1', 'dec0'}
|
||||
captures = list(capture.glob('replay-*-dltss_pwin_*_layer'))
|
||||
found = {p.name.split('-dltss_pwin_')[1].removesuffix('_layer') for p in captures}
|
||||
if found != expected or len(captures) != 11:
|
||||
raise RuntimeError('Missing/duplicate audited K layer captures')
|
||||
weights = args.output / 'weights'
|
||||
weights.mkdir()
|
||||
if args.include_lut:
|
||||
outputs = list(capture.glob('replay-*-hiluma_engine_output_depthreg_mvhi_ldr_max_v2_rel'))
|
||||
if len(outputs) != 1 or (outputs[0] / 'args.bin').stat().st_size != 328:
|
||||
raise RuntimeError('Missing or invalid audited K output capture')
|
||||
fields = [line.split() for line in (outputs[0] / 'manifest.txt').read_text().splitlines()]
|
||||
pointers = [row for row in fields if row[0] == 'pointer' and row[1] == '280']
|
||||
if len(pointers) != 1:
|
||||
raise RuntimeError('Missing/duplicate reconstruction LUT pointer')
|
||||
_, _, identifier, offset = pointers[0]
|
||||
lut = (outputs[0] / ('alloc-' + identifier + '.bin')).read_bytes()
|
||||
if len(lut) != 16 * 32768 or int(offset) % 32768 or not 0 <= int(offset) < len(lut) or not any(lut):
|
||||
raise RuntimeError('Unexpected reconstruction-table allocation; refusing guessed extraction')
|
||||
(weights / 'lut.bin').write_bytes(lut)
|
||||
report.update(reconstructionLutCaptured=True, reconstructionTables=16, capturedLutIndex=int(offset) // 32768)
|
||||
extraction_env = env.copy()
|
||||
extraction_env['PYTHONPATH'] = os.pathsep.join(str(repo / path) for path in ('.tools/python/vendor', 'engine', 'kernels/tools'))
|
||||
with (args.output / 'extract.log').open('wb') as out:
|
||||
subprocess.run([sys.executable, str(repo / 'engine/extract_k.py'), str(capture), str(weights / 'k'),
|
||||
'--unfold-gains'], env=extraction_env, stdout=out, stderr=subprocess.STDOUT, check=True, timeout=120)
|
||||
index = json.loads((weights / 'k.json').read_text())
|
||||
if set(index) != expected or any(layer['fold_gains'] for layer in index.values()):
|
||||
raise RuntimeError('Incomplete/incorrect K weight extraction')
|
||||
report.update(passed=True, layerCaptures=11, extractedLayers=11, numerics='explicit-f16-gains',
|
||||
products={p.name:sha(p) for p in weights.iterdir() if p.is_file()},
|
||||
weightBytes=(weights / 'k.bin').stat().st_size,
|
||||
standaloneModelComplete=False, qualityReference=False, published=False)
|
||||
print(json.dumps(report, indent=2))
|
||||
except Exception as error:
|
||||
report['error'] = str(error)
|
||||
raise
|
||||
finally:
|
||||
(args.output / 'validation.json').write_text(json.dumps(report, indent=2) + '\n')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user