mirror of
https://github.com/trustno1-coder/VIctory-NVIDIA.git
synced 2026-12-06 09:08:35 +00:00
test(gpu): add bounded recovery and combined probe acceptance controls
Co-authored-by: OpenAI Codex <noreply@openai.com>
This commit is contained in:
@ -10,6 +10,10 @@ pub(super) struct Combined {
|
||||
pub(super) motion: ID3D12Resource,
|
||||
pub(super) camera: plan::Camera,
|
||||
textures: Textures,
|
||||
colour: ID3D12Resource,
|
||||
moving: bool,
|
||||
edge: u32,
|
||||
staging: Vec<ID3D12Resource>,
|
||||
list: crate::host::HostList,
|
||||
mode: u32,
|
||||
evaluations: u64,
|
||||
@ -149,7 +153,7 @@ impl Combined {
|
||||
drop(uploads);
|
||||
let mut textures: Textures = Default::default();
|
||||
for (i, t, state) in [
|
||||
(COLOUR, colour, SHADER_READ),
|
||||
(COLOUR, colour.clone(), SHADER_READ),
|
||||
(DEPTH, depth.clone(), SHADER_READ),
|
||||
(MOTION, motion.clone(), SHADER_READ),
|
||||
(EXPOSURE, exposure, SHADER_READ),
|
||||
@ -182,6 +186,7 @@ impl Combined {
|
||||
// SAFETY: live device; a plain fence of our own.
|
||||
let fence: ID3D12Fence = unsafe { d.CreateFence(0, D3D12_FENCE_FLAG_NONE) }.map_err(err)?;
|
||||
Ok(Self { out, overlay, depth, motion, camera, textures, list, mode,
|
||||
colour, moving: std::env::var("VICTORY_CHECK_MOTION").as_deref() == Ok("1"), edge: render[0]/2, staging: Vec::new(),
|
||||
evaluations: 0, skip: std::env::var("VICTORY_CHECK_SKIP_EVALUATE").is_ok_and(|v| v == "1"),
|
||||
asynchronous: asynchronous(), fence, fenced: 0 })
|
||||
}
|
||||
@ -214,7 +219,27 @@ impl Combined {
|
||||
self.camera.reset = round == 0;
|
||||
// The list's previous run must be done before its allocator is reset.
|
||||
self.wait();
|
||||
self.staging.clear();
|
||||
self.list.reset();
|
||||
if self.moving {
|
||||
let width = self.camera.render[0];
|
||||
let span = width / 2;
|
||||
let phase = round % (span * 2);
|
||||
let edge = width / 4 + if phase <= span { phase } else { span * 2 - phase };
|
||||
let delta = if round == 0 { 0 } else { self.edge as i32 - edge as i32 };
|
||||
self.edge = edge;
|
||||
self.camera.motion_scale = [1.0; 2];
|
||||
transition(&self.list.list, &self.colour, SHADER_READ, COPY_DEST);
|
||||
self.staging.push(upload(&host.device, &self.list.list, &self.colour, 8, SHADER_READ, |x, _, p| {
|
||||
let values = if x < edge { [0x3000u16,0x3400,0x3800,0x3c00] } else { [0x3a00u16,0x3800,0x3400,0x3c00] };
|
||||
for (dst,value) in p.chunks_exact_mut(2).zip(values) { dst.copy_from_slice(&value.to_le_bytes()); }
|
||||
})?);
|
||||
transition(&self.list.list, &self.motion, SHADER_READ, COPY_DEST);
|
||||
let mv: u16 = if delta < 0 { 0xbc00 } else if delta > 0 { 0x3c00 } else { 0 };
|
||||
self.staging.push(upload(&host.device, &self.list.list, &self.motion, 4, SHADER_READ, |_, _, p| {
|
||||
p[..2].copy_from_slice(&mv.to_le_bytes()); p[2..].fill(0);
|
||||
})?);
|
||||
}
|
||||
transition(&self.list.list, &self.out, SHADER_READ, UNORDERED);
|
||||
let id = token.unwrap_or_else(|| NEXT_ID.fetch_add(1, Relaxed) + 1);
|
||||
let recorded = if self.skip { Ok(()) } else {
|
||||
@ -234,7 +259,7 @@ impl Combined {
|
||||
}
|
||||
recorded?;
|
||||
if !self.skip { self.evaluations += 1; }
|
||||
if round == 0 { self.check(host)?; }
|
||||
if round == 0 || self.moving { self.wait(); self.check(host)?; }
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -242,7 +267,9 @@ impl Combined {
|
||||
let began = Instant::now();
|
||||
tracing::info!(evaluations=self.evaluations, "combined SR readback beginning (outside measured presents)");
|
||||
let pixels = super::io::readback_from(&host.device, host, &self.out, SHADER_READ)?;
|
||||
let stats = inspect(&pixels, self.camera.output)?;
|
||||
let stats = if self.moving {
|
||||
inspect_moving(&pixels, self.camera.output, self.edge * self.camera.output[0] / self.camera.render[0])?
|
||||
} else { inspect(&pixels, self.camera.output)? };
|
||||
tracing::info!(evaluations=self.evaluations, packed_bytes=pixels.len(), readback_check_ms=began.elapsed().as_secs_f64()*1000.0,
|
||||
"combined SR readback complete (including CPU reference inspection)");
|
||||
Ok(format!("Combined SR readback PASS: render={:?} output={:?} evaluations={}; {stats}; blake3={}",
|
||||
@ -271,3 +298,41 @@ pub(super) fn process_memory() -> Option<(usize, usize, usize)> {
|
||||
(unsafe { K32GetProcessMemoryInfo(GetCurrentProcess(), &mut c, c.cb) } != 0)
|
||||
.then_some((c.PagefileUsage, c.PeakPagefileUsage, c.PeakWorkingSetSize))
|
||||
}
|
||||
|
||||
// Reference comparison away from the moving discontinuity; generated FG images are not captured here.
|
||||
fn inspect_moving(bytes: &[u8], size: [u32;2], edge: u32) -> Result<String,String> {
|
||||
if bytes.len() != size[0] as usize * size[1] as usize * 8 { return Err("motion readback size mismatch".into()); }
|
||||
let mut checked = 0u64;
|
||||
let mut bad = 0u64;
|
||||
for (i,p) in bytes.chunks_exact(8).enumerate() {
|
||||
let x = i as u32 % size[0];
|
||||
let expected = if x < edge { [0.125,0.25,0.5] } else { [0.75,0.5,0.25] };
|
||||
for (c,reference) in p[..6].chunks_exact(2).zip(expected) {
|
||||
let v = half(u16::from_le_bytes([c[0],c[1]]));
|
||||
if !v.is_finite() { return Err("nonfinite moving output".into()); }
|
||||
if x.abs_diff(edge) > 8 {
|
||||
checked += 1;
|
||||
if (v-reference).abs() > 0.05 { bad += 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
if checked == 0 || bad * 1000 > checked { return Err(format!("moving reference mismatch: {bad}/{checked}")); }
|
||||
Ok(format!("moving reference edge={edge}, bad={bad}/{checked}, tolerance=0.05, excluded_edge=8px"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod motion_tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn moving_oracle_rejects_stale_and_nonfinite_output() {
|
||||
let pixels: Vec<u8> = (0..128).flat_map(|x| {
|
||||
let values = if x < 40 { [0x3000u16,0x3400,0x3800,0x3c00] } else { [0x3a00u16,0x3800,0x3400,0x3c00] };
|
||||
values.into_iter().flat_map(u16::to_le_bytes)
|
||||
}).collect();
|
||||
assert!(inspect_moving(&pixels, [128,1], 40).is_ok());
|
||||
assert!(inspect_moving(&pixels, [128,1], 80).is_err());
|
||||
let mut poison = pixels;
|
||||
poison[..2].copy_from_slice(&0x7e00u16.to_le_bytes());
|
||||
assert!(inspect_moving(&poison, [128,1], 40).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ fn run(size: [u32; 2], frames: u32, lifecycle: bool, focus_wait: std::time::Dura
|
||||
return Err("unset VICTORY_FRAMEGEN_CYCLE: the probe owns phase transitions".into());
|
||||
}
|
||||
let mut asked = Asked::from_env()?;
|
||||
let degrade = combined && std::env::var("VICTORY_CHECK_DEGRADE").as_deref() == Ok("1");
|
||||
asked.dlss = combined;
|
||||
asked.framegen = true;
|
||||
asked.fsr_framegen = false;
|
||||
@ -48,7 +49,7 @@ fn run(size: [u32; 2], frames: u32, lifecycle: bool, focus_wait: std::time::Dura
|
||||
CHECK_DEVICE.store(true, Relaxed);
|
||||
CHECKING.store(true, Relaxed);
|
||||
if !FG_READY.load(Acquire) { return Err("FG device not ready".into()); }
|
||||
if combined && !DLSS_READY.load(Acquire) { return Err("combined SR device not ready".into()); }
|
||||
if combined && !DLSS_READY.load(Acquire) && !degrade { return Err("combined SR device not ready".into()); }
|
||||
let split = combined && super::combined::split_token();
|
||||
if combined {
|
||||
lines.push("Combined SR -> FP16 HUD-less colour -> RGBA8 composition -> FG; static reference; first/final SR readback, no generated-image oracle".into());
|
||||
@ -62,8 +63,14 @@ fn run(size: [u32; 2], frames: u32, lifecycle: bool, focus_wait: std::time::Dura
|
||||
let code = unsafe { get_state(&abi::ViewportHandle::new(VIEWPORT_FG), &mut caps, std::ptr::null()) };
|
||||
if code != 0 { return Err(format!("FG capabilities query: {code}")); }
|
||||
let max = caps.num_frames_to_generate_max.saturating_add(1);
|
||||
let requested = framegen_wanted();
|
||||
if requested > max { return Err(format!("requested {requested}x exceeds SDK maximum {max}x")); }
|
||||
// Probe-only negative control: restrict the observed capability, never expand it.
|
||||
let max = if std::env::var("VICTORY_CHECK_FG_CAP_2").as_deref() == Ok("1") { max.min(2) } else { max };
|
||||
let mut requested = framegen_wanted();
|
||||
if requested > max {
|
||||
if !degrade { return Err(format!("requested {requested}x exceeds SDK maximum {max}x")); }
|
||||
lines.push(format!("Degraded: FG request {requested}x exceeds maximum {max}x; continuing SR with FG disabled"));
|
||||
requested = 0;
|
||||
}
|
||||
if size.iter().any(|&n| n < caps.min_width_or_height) { return Err(format!("below SDK minimum {}", caps.min_width_or_height)); }
|
||||
lines.push(format!("FG capabilities: maximum={max}x minimum={} requested={requested}x; original scrolling pattern, depth 0.5, pixel motion+1x; SDK counts only", caps.min_width_or_height));
|
||||
let smaller = size.map(|n| (n * 3 / 4).max(caps.min_width_or_height).max(128));
|
||||
@ -81,8 +88,22 @@ fn run(size: [u32; 2], frames: u32, lifecycle: bool, focus_wait: std::time::Dura
|
||||
host.drop_presenter();
|
||||
}
|
||||
set_framegen(mode);
|
||||
let fixture = if combined { None } else { Some(Fixture::new(host, output)?) };
|
||||
let mut sr = if combined { Some(super::combined::Combined::new(host, output, &asked)?) } else { None };
|
||||
let mut sr = if combined {
|
||||
let init = if std::env::var("VICTORY_CHECK_SR_INIT_FAIL").as_deref() == Ok("1") {
|
||||
Err("injected SR initialization failure (probe control)".into())
|
||||
} else if !DLSS_READY.load(Acquire) {
|
||||
Err("SR device unavailable".into())
|
||||
} else { super::combined::Combined::new(host, output, &asked) };
|
||||
match init {
|
||||
Ok(sr) => Some(sr),
|
||||
Err(e) if degrade => {
|
||||
lines.push(format!("Degraded: SR initialization failed ({e}); continuing initialized native-resolution FG fixture"));
|
||||
None
|
||||
}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
} else { None };
|
||||
let fixture = if sr.is_none() { Some(Fixture::new(host, output)?) } else { None };
|
||||
let before = host.video_memory();
|
||||
let mut times = Vec::new();
|
||||
let mut shown = 0u64;
|
||||
@ -342,4 +363,4 @@ mod tests {
|
||||
d[10..21].fill(2); d[50]=3;
|
||||
assert!(accept(2,110,&d,0,None).is_err(), "partial multiplier");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,3 +23,13 @@ Static synthetic output does not establish generated-image quality, per-frame pi
|
||||
SR and FG now share a frame-token index. `VICTORY_CHECK_SR_ASYNC=1` opts into submitting SR without an immediate CPU wait; the default remains synchronous. The fixture waits on its own fence before reusing its command allocator or destroying resources. A Signal failure after submission, a failed fence wait, or device removal uses the existing fatal GPU failure path. These failures are not graceful fallback or recovery: continuing teardown without established completion would be unsafe.
|
||||
|
||||
Slow-interval and process peak-memory diagnostics are included. The earlier 21-case RTX 5090 matrix on the follow-up source covered SR modes, 1080p/1440p/4K, supported FG multipliers, repeated processes, lifecycle, debug layer/GBV, and one 18000-frame run. That evidence supersedes the earlier untested-maximum statement for that revision only. Final integration checks are recorded separately; no temporal-quality or leak-free claim is added.
|
||||
|
||||
## Opt-in acceptance extensions
|
||||
|
||||
`VICTORY_CHECK_DEGRADE=1` permits two initialization-time degradations: an FG request above the observed SDK maximum continues SR with FG off, and an SR fixture initialization error continues the existing native-resolution FG fixture. Default remains strict. Probe controls `VICTORY_CHECK_FG_CAP_2=1` restrict observed FG capability to at most2x, and `VICTORY_CHECK_SR_INIT_FAIL=1` injects an SR initialization error. These are controlled test scenarios, not proof of every driver/runtime failure mode. Runtime SR evaluation failures and unavailable FG runtime initialization still fail strictly.
|
||||
|
||||
`VICTORY_CHECK_MOTION=1` moves a split-colour boundary one render pixel per frame with matching horizontal motion vectors. Every frame's SR output is checked for finite values and reference mismatch away from an8-output-pixel edge band (RGB tolerance0.05, at most0.1% bad checked channels). A unit negative control rejects stale/frozen reference positions and NaN. This is a narrow moving SR correctness check; the ignored edge band, disocclusion quality and generated FG image pixels are not validated. Full readback makes it unsuitable for timing/performance measurements.
|
||||
|
||||
`tools/vn03e-recover.ps1 -Exe <victory.exe>` supervises fresh probe processes, bounded to1..3 attempts and10..300seconds per child. Success requires a zero exit, SR readback, FG PASS and orderly shutdown. Timeout children are terminated and reaped; exhaustion returns1. Configure official runtime and reserve GPU before using it. Optional `-FaultExe`/`-PersistentFault` are test controls for a separately built fault-injection executable; they are not a production device-reset mechanism.
|
||||
|
||||
Final RTX5090 checks: FG-cap strict/degraded, SR-init strict/degraded and60-frame moving-reference cases all met expected verdicts. Recovery fault->healthy passed on attempt2; persistent fault stopped after2 attempts with exhaustion.5focused CPU tests, strict scoped all-target Clippy, build, and asset policy306files passed on the private integration. New GPU results do not include GBV or generated-frame image capture. Process-level recovery was owner-selected; same-process SDK/device reconstruction remains a separate future project.
|
||||
|
||||
45
tools/vn03e-recover.ps1
Normal file
45
tools/vn03e-recover.ps1
Normal file
@ -0,0 +1,45 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$Exe,
|
||||
[ValidateRange(1,3)][int]$MaxAttempts=2,
|
||||
[ValidateRange(10,300)][int]$TimeoutSeconds=120,
|
||||
[string]$FaultExe='',
|
||||
[switch]$PersistentFault,
|
||||
[string]$LogDir='./vn03e-recovery-logs'
|
||||
)
|
||||
$ErrorActionPreference='Stop'
|
||||
$Exe=(Resolve-Path -LiteralPath $Exe).Path
|
||||
if ($FaultExe) { $FaultExe=(Resolve-Path -LiteralPath $FaultExe).Path }
|
||||
New-Item -ItemType Directory -Force -Path $LogDir | Out-Null
|
||||
$faultBefore=$env:VICTORY_TEST_FENCE_FAULT
|
||||
try {
|
||||
for ($attempt=1; $attempt -le $MaxAttempts; $attempt++) {
|
||||
$inject=$FaultExe -and ($attempt -eq 1 -or $PersistentFault)
|
||||
$env:VICTORY_TEST_FENCE_FAULT=if ($inject) {'signal'} else {''}
|
||||
$info=New-Object Diagnostics.ProcessStartInfo
|
||||
$info.FileName=if ($inject) {$FaultExe} else {$Exe}
|
||||
$info.Arguments='upscaler-check --validate-framegen --combined --output 1920x1080 --frames 30 --focus-wait 60'
|
||||
$info.UseShellExecute=$false
|
||||
$info.RedirectStandardOutput=$true
|
||||
$info.RedirectStandardError=$true
|
||||
$child=New-Object Diagnostics.Process
|
||||
$child.StartInfo=$info
|
||||
try {
|
||||
if (!$child.Start()) { throw 'Child launch failed' }
|
||||
$out=$child.StandardOutput.ReadToEndAsync()
|
||||
$err=$child.StandardError.ReadToEndAsync()
|
||||
$finished=$child.WaitForExit($TimeoutSeconds*1000)
|
||||
if (!$finished) { $child.Kill(); $child.WaitForExit() }
|
||||
$text=$out.GetAwaiter().GetResult()+$err.GetAwaiter().GetResult()
|
||||
[IO.File]::WriteAllText((Join-Path (Resolve-Path $LogDir) "attempt-$attempt.log"),$text)
|
||||
$valid=$finished -and $child.ExitCode -eq 0 -and $text.Contains('Combined SR readback PASS:') -and $text.Contains('PASS=true') -and !$text.Contains('PASS=false') -and $text.Contains('Streamline shut down: ok (0)')
|
||||
Write-Output "ATTEMPT=$attempt PID=$($child.Id) EXIT=$($child.ExitCode) VALID=$valid TIMEOUT=$(!$finished)"
|
||||
if ($valid) { Write-Output 'PROCESS_RECOVERY=PASS'; exit 0 }
|
||||
if ($inject -and !$text.Contains('queue Signal')) { throw 'Fault control did not reach the intended Signal path' }
|
||||
} finally {
|
||||
if ($child.Id -and !$child.HasExited) { $child.Kill(); $child.WaitForExit() }
|
||||
$child.Dispose()
|
||||
}
|
||||
}
|
||||
Write-Output 'PROCESS_RECOVERY=EXHAUSTED'
|
||||
exit 1
|
||||
} finally { $env:VICTORY_TEST_FENCE_FAULT=$faultBefore }
|
||||
Reference in New Issue
Block a user