- engine/compile_rr2.py, runtime_rr2.inc, engine/rr/rr2_m.comp, exposure_f.comp, gen_rr2_enc0.py, rr2_pack.py, rr2_ref.py: the rr2_* model (nvngx_dlssd.dll 310.9's third network) as d4r's own shaders - exposure, enc0 gather/block split, enc1-5 and dec4-0 through one matrix shader, translated output passes; weights packed from the DLL, argument blocks from the capture - ptx2rr: match the driver's fused roundings - opaque-zero OR around cvt.rn.f16.f32 against v_fma_mix, half-away-from-zero formatted stores, UNORM 10:10:10:2 as RGBA32F of q/1023, OCML tanhF with the AMDGPU exp lowering, binary16 fma and fetch roundings; --probe for register bisection against ZLUDA - dec0_m/swin_m/enc0_*: RR_MIX build option (D4R_RR_MIX=1), one v_fma_mix rounding per 32-deep step, ~5% faster, not bit-exact; default build stays exact - runtime_rr.inc: RModel/REngine dispatch to the D4RR0002 model; replay_rr: RGBA32F and A2B10G10R1010 texel sizes, roughnessPacked bit, larger debug staging - shim: engine\rr-f model slot, 310.9 version probe so preset F is only claimed when the CUDA path has it; d4r.ini / d4r_config.py Model = F; run_rr_engine_compare.sh D4R_RR_DLL - kernels/rr/swin_native.h + rr_swin_native_test.cpp: HIP port of encoder 1 for the FP8-product and rounding cost measurements - engine/rr/README: preset F's block, options, capture-by-capture results, timings and the open camera-matrix difference
72 lines
3.1 KiB
Python
72 lines
3.1 KiB
Python
"""Preset isolation, invalid-setting rejection, and environment precedence."""
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
CONFIG = ROOT / "scripts" / "d4r_config.py"
|
|
RR_VARIABLES = ("D4R_RR_ENABLE", "D4R_RR_PRESET")
|
|
|
|
|
|
def run_config(text, **overrides):
|
|
"""Runs d4r_config.py over `text`; returns (exit code, exports of interest).
|
|
|
|
d4r_config.py also emits its own defaults for unrelated variables, so the result is
|
|
filtered to the Ray Reconstruction and Super Sampling preset variables - the ones whose
|
|
independence from each other is under test here.
|
|
"""
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
ini = Path(directory) / "d4r.ini"
|
|
ini.write_text(text)
|
|
env = dict(os.environ)
|
|
for name in RR_VARIABLES + ("D4R_DLSS_PRESET",):
|
|
env.pop(name, None)
|
|
env.update(overrides)
|
|
result = subprocess.run(["python3", str(CONFIG), "--config", str(ini)], env=env,
|
|
capture_output=True, text=True)
|
|
interesting = set(RR_VARIABLES) | {"D4R_DLSS_PRESET"}
|
|
decided = {}
|
|
for line in result.stdout.splitlines():
|
|
if line.startswith("export "):
|
|
key, _, value = line[len("export "):].partition("=")
|
|
if key in interesting:
|
|
decided[key] = value
|
|
return result.returncode, decided
|
|
|
|
|
|
class RayReconstructionConfigTests(unittest.TestCase):
|
|
def test_rr_and_super_sampling_presets_do_not_collide(self):
|
|
code, decided = run_config("[RayReconstruction]\nEnable = true\nModel = E\n[DLSS]\nModel = K\n")
|
|
self.assertEqual(code, 0)
|
|
self.assertEqual(decided["D4R_RR_ENABLE"], "1")
|
|
self.assertEqual(decided["D4R_RR_PRESET"], "5") # Ray Reconstruction preset E
|
|
self.assertEqual(decided["D4R_DLSS_PRESET"], "11") # Super Sampling preset K
|
|
|
|
def test_dlss_45_ray_reconstruction_is_model_f(self):
|
|
code, decided = run_config("[RayReconstruction]\nEnable = true\nModel = F\n")
|
|
self.assertEqual(code, 0)
|
|
self.assertEqual(decided["D4R_RR_PRESET"], "6") # preset F: nvngx_dlssd.dll 310.9 or later
|
|
|
|
def test_invalid_rr_settings_are_rejected_rather_than_guessed(self):
|
|
for text in ("[RayReconstruction]\nModel = G\n",
|
|
"[RayReconstruction]\nModel = K\n",
|
|
"[RayReconstruction]\nEnable = maybe\n"):
|
|
with self.subTest(ini=text):
|
|
code, decided = run_config(text)
|
|
self.assertNotEqual(code, 0, f"accepted {text!r} as {decided}")
|
|
for name in RR_VARIABLES:
|
|
self.assertNotIn(name, decided)
|
|
|
|
def test_environment_wins_over_the_ini(self):
|
|
# An explicitly exported variable is the user's decision and must survive.
|
|
code, decided = run_config("[RayReconstruction]\nEnable = true\nModel = E\n",
|
|
D4R_RR_ENABLE="0", D4R_RR_PRESET="4")
|
|
self.assertEqual(code, 0)
|
|
self.assertNotIn("D4R_RR_ENABLE", decided)
|
|
self.assertNotIn("D4R_RR_PRESET", decided)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main() |