FidelityFX: the console FSR4 upscaler's passes translate and a frame runs on the GPU

AMD's console upscaler (amd_fidelityfx_upscaler_xbox.dll) creates its 29 pipelines with
CreateComputePipelineState on blobs that carry no DXIL: an ACCC part holding FSPX, the console
driver's own container (numthreads, COMPUTE_PGM_RSRC1/2, the RDNA2 code). pso::fspx reads it
and the program goes through the recompiler as a compute shader – all 29 translate and compile.

The packed 8-bit dot products (v_dot4(c)_i32_i8, v_dot4_u32_u8) are SM 6.4's dot4add_i8packed /
dot4add_u8packed instead of shifts and multiplies: FSR4's network passes are thousands of them,
and the biggest went 1.55 -> 1.23 MB of DXIL and 604 -> 74 s in DXC; the AMD driver had refused
it with E_OUTOFMEMORY.

The FSR probe (XCL_CONSOLE_LISTS=1 XCL_PROBE_FSR=1 XCL_PROBE_FSR_DISPATCH=1, new
XCL_PROBE_FSR_EXECUTE=1) uploads inputs (a grey gradient, depth 0.5, no motion), records a
1280x720 -> 1920x1080 frame (20 dispatches, all records recognised), runs it on the GPU and
reads the output back: finite, and the gradient survives (RX 9070, ~11 ms). New ignored test
fspx_containers_translate_and_compile (XCL_SAMPLE_FSPX). Based on PR #33's research, rebuilt
on current main (the FSPX path carries the real thread geometry; #33 guessed it).
This commit is contained in:
ivall
2026-11-23 14:56:58 +01:00
parent f311ca5b96
commit fdeacf0529
6 changed files with 269 additions and 6 deletions
+20
View File
@@ -915,6 +915,26 @@ opens its "Xbox network unavailable" dialog – input arrives), Unicorn Overlord
(DXC's loop passes: unroll ~30 %, jump threading ~18 %, indvars ~12 % on the slowest); the largest program
(29 000 instructions, 6.5 MB HLSL) peaks at ~0.6 GB in DXC. `XCL_DXC_ARGS` passes DXC arguments in the survey.
## FidelityFX (FSR4) runs on the GPU (2026-11-23)
- The console upscaler (`amd_fidelityfx_upscaler_xbox.dll`) creates its passes with CreateComputePipelineState on a
blob with an `ACCC` part holding `FSPX` (the console driver's container, "NewBE"; it tries
DeserializeComputePipelineStateX first, which stays E_NOTIMPL). `pso::fspx` reads it: entry 0 = numthreads (u16 x3
@+0x0C), RSRC1 @+0x14, RSRC2 @+0x18; entry 6 = the RDNA2 code behind a 0x24-byte header (cut at the last
s_endpgm). Compute interface from RSRC2 as for FSSM CS. All 29 FSR4 pipelines translate and compile
(`fspx_containers_translate_and_compile`, `XCL_SAMPLE_FSPX=<folder of dumped *_rootsig.bin>`).
- `v_dot4(c)_i32_i8` / `v_dot4_u32_u8` as SM 6.4 `dot4add_i8packed` / `dot4add_u8packed` (the network passes are
thousands of them): the biggest pass went 1.55 MB → 1.23 MB DXIL, DXC 604 s → 74 s, and the AMD driver now accepts
it (it returned E_OUTOFMEMORY before).
- `fsr4_console_upscaler_creates_a_context_probe` with `XCL_CONSOLE_LISTS=1 XCL_PROBE_FSR=1 XCL_PROBE_FSR_DISPATCH=1
XCL_PROBE_FSR_EXECUTE=1` (`XCL_SAMPLE_DLLS` = the game's DLLs): inputs uploaded (a 0..1 grey gradient, depth 0.5,
no motion), ffxDispatch records 20 dispatches / 24 barriers / 2 clears / 4 copies on a console list, all
recognised, the PC list runs on the RX 9070 (~11 ms with submission), the 1920x1080 RGBA16F output is finite and
keeps the gradient (red mean 0.123 left quarter, 0.872 right). The probe needs `XCL_CONSOLE_LISTS=1` (without it
the pipelines are not console-shaped and the stream has unknown records).
- Based on PR #33 (ElHombreAlex), rebuilt on current `main`: #33 went through DeserializePipelineStateX with a guessed
thread geometry; the FSPX path carries the real one. Its wave64 rendezvous is #67; R9G9B9E5 UAVs were not needed here.
- Not yet: a title using FSR4 (none of the four run here ships it; the dump with it has no executable).
## Opus decoding (session 5, 2026-11-21, PR #3)
- `hle/opus.rs`: Windows' own decoder, the "Microsoft Opus Audio Decoder MFT" (`MSOpusDecoder.dll`, Media Foundation),
loaded with `mfplat.dll` at run time through `DllGetClassObject` (no COM registration, no libopus). RFC 6716 packet
+2 -2
View File
@@ -30,7 +30,7 @@ next steps:
become HLSL; random samples compile to DXIL with 0 errors.
- **The game's own console DLLs run on the PC** – its Bink 2 video codec decodes the game's
movies, its ray-tracing BVH builder builds acceleration structures on a PC GPU, the AMD FSR 4
console upscaler sets up and records its work, the GDK HTTP library initialises.
console upscaler runs a whole frame on a PC GPU, the GDK HTTP library initialises.
- **Console textures decode exactly** – the GFX10 tiling and mip layout reproduce 909 of 912
textures of the game's texture archive byte for byte, its volume textures included.
- **370+ automated tests**, including GPU tests that compare translated shaders against expected
@@ -67,7 +67,7 @@ next steps:
| **D3D12.X graphics** | ✅ | device, resources and heaps (also placed in title memory), pipelines; the title's graphics command lists – draws, indirect draws, graphics root arguments, barriers, copies, clears – and command lists recorded by console code, replayed; `PresentX` and frame pacing into an XCL window | Minecraft Preview plays its worlds (millions of draws, none skipped); Fortnite and XDefiant draw their screens |
| **Textures** | ✅ | GFX10 tiling (all 14 2D swizzle modes, the 6 3D thick modes, linear), mip chains with mip tail, arrays, cubes and 3D textures → PC textures | 909 / 912 retail textures exact (the 3 volume LUTs decode smooth); GPU upload bit exact |
| **Ray tracing** | ✅ | BLAS / TLAS built on the GPU by the game's own XboxBvhBuilder; RDNA2 BVH node format; BVH intersection instructions emulated in shaders | GPU traversal = brute force reference; the game's builder output checked on the GPU |
| **Upscaling** | ✅ | the game's AMD FSR 4 console DLL creates its context and records its dispatches | end-to-end with the real DLL |
| **Upscaling** | ✅ | the game's AMD FSR 4 console DLL (`amd_fidelityfx_upscaler_xbox.dll`): context, the 29 pipelines in the console driver's own container (FSPX) translated, a frame's 20 passes recorded and run on the GPU | end-to-end with the real DLL: a 1280×720 → 1920×1080 frame on an RX 9070, the input's gradient in the output |
### Media and tools
+6 -3
View File
@@ -2566,11 +2566,14 @@ impl Em {
Some(if clamp { format!("asuint(saturate({e}))") } else { format!("asuint({e})") })
}
"v_dot2c_f32_f16" => Some(format!("asuint(mad({}, {}, mad({}, {}, asfloat({cur}))))", fh(0, true), fh(1, true), fh(0, false), fh(1, false))),
"v_dot4c_i32_i8" => Some(format!("dot4_i8({}, {}, {cur})", src(0), src(1))),
// the packed 8-bit dot products as SM 6.4's intrinsics (the GPU's own instruction): FSR4's
// network passes are thousands of them, and the shift-and-multiply form made one pass
// 1.5 MB of DXIL that the AMD driver could not compile (E_OUTOFMEMORY)
"v_dot4c_i32_i8" => Some(format!("(uint)dot4add_i8packed({}, {}, (int){cur})", src(0), src(1))),
"v_dot2_i32_i16" => Some(format!("(uint)({} * {} + {} * {} + (int){})", si(0, false), si(1, false), si(0, true), si(1, true), src(2))),
"v_dot2_u32_u16" => Some(format!("({} * {} + {} * {} + {})", h(0, false), h(1, false), h(0, true), h(1, true), src(2))),
"v_dot4_u32_u8" => Some(format!("dot4_u8({}, {}, {})", src(0), src(1), src(2))),
"v_dot4_i32_i8" => Some(format!("dot4_i8({}, {}, {})", src(0), src(1), src(2))),
"v_dot4_u32_u8" => Some(format!("dot4add_u8packed({}, {}, {})", src(0), src(1), src(2))),
"v_dot4_i32_i8" => Some(format!("(uint)dot4add_i8packed({}, {}, (int){})", src(0), src(1), src(2))),
"v_dot8_u32_u4" => Some(format!("dot8_u4({}, {}, {})", src(0), src(1), src(2))),
"v_dot8_i32_i4" => Some(format!("dot8_i4({}, {}, {})", src(0), src(1), src(2))),
_ => None,
+66 -1
View File
@@ -24,7 +24,53 @@ pub enum Stage {
/// A console (xbox-native) shader container?
pub fn is_console(blob: &[u8]) -> bool {
xbox::is_xbox(blob)
xbox::is_xbox(blob) || fspx(blob).is_some()
}
/// A compute program in the console driver's own container (an `ACCC` part holding `FSPX`),
/// what AMD FidelityFX (FSR4) creates its passes from on the console: no DXIL, the RDNA2
/// code with its thread geometry and COMPUTE_PGM_RSRC2.
pub struct Fspx<'a> {
pub threads: [u32; 3],
pub rsrc1: u32,
pub rsrc2: u32,
/// RDNA2 code, from its first instruction to the last `s_endpgm`
pub code: &'a [u8],
}
/// `FSPX`: 'FSPX', version, entry count, size, then 16-byte entries (type, offset, size, 0)
/// from +0x10, offsets from the start of FSPX. Type 0 (0x1C bytes): numthreads as u16 x3 at
/// +0x0C, RSRC1 at +0x14, RSRC2 at +0x18; type 1: a 0x14-byte hash; type 6: the code behind
/// a 0x24-byte header (the v_nop hash prologue); type 7: resource declarations (32-byte
/// records). Read from FSR4's pipelines (the console upscaler's "NewBE" path).
pub fn fspx(blob: &[u8]) -> Option<Fspx<'_>> {
let parts = crate::gpu::shader::container_parts(blob)?;
let p = parts.iter().find(|p| p.fourcc == "ACCC")?;
let part = blob.get(p.offset..p.offset + p.size)?;
let u32_at = |b: &[u8], o: usize| b.get(o..o + 4).map(|x| u32::from_le_bytes(x.try_into().unwrap()));
if part.get(..4)? != b"FSPX" {
return None;
}
let n = u32_at(part, 8)? as usize;
let entry = |ty: u32| -> Option<&[u8]> {
(0..n.min(32)).find_map(|e| {
let at = 0x10 + 16 * e;
(u32_at(part, at)? == ty).then(|| {
let (o, s) = (u32_at(part, at + 4)? as usize, u32_at(part, at + 8)? as usize);
part.get(o..o.checked_add(s)?)
})?
})
};
let head = entry(0)?;
let u16_at = |o: usize| head.get(o..o + 2).map(|x| u16::from_le_bytes(x.try_into().unwrap()) as u32);
let threads = [u16_at(0x0C)?, u16_at(0x0E)?, u16_at(0x10)?];
if threads.iter().any(|&t| t == 0 || t > 1024) || threads.iter().product::<u32>() > 1024 {
return None;
}
let code = entry(6)?.get(0x24..)?;
// up to the last s_endpgm (the driver pads with s_code_end)
let end = (0..code.len() / 4).rev().find(|&i| u32_at(code, 4 * i) == Some(0xBF81_0000))?;
Some(Fspx { threads, rsrc1: u32_at(head, 0x14)?, rsrc2: u32_at(head, 0x18)?, code: &code[..4 * (end + 1)] })
}
/// Memory windows of the title's unified memory (1 without it).
@@ -275,6 +321,25 @@ fn cache_allowed(stage: Stage, present: impl Fn(&str) -> bool) -> bool {
}
fn console_translation(blob: &[u8], stage: Stage, sampler_base: u32, windows: u32, split_wave64: bool) -> Result<(super::Translation, &'static str), String> {
if let Some(f) = fspx(blob) {
if stage != Stage::Compute {
return Err("an FSPX (driver) container in a graphics slot".into());
}
let r = f.rsrc2;
let cs = super::CsInterface {
threads: f.threads,
user_sgprs: (r >> 1) & 31,
tgid: [(r >> 7) & 1 == 1, (r >> 8) & 1 == 1, (r >> 9) & 1 == 1],
tg_size: (r >> 10) & 1 == 1,
tid_components: ((r >> 11) & 3) + 1,
};
let t = translate(f.code, &Options { mode: Mode::Compute(cs), wave64: super::detect_wave64(f.code), split_wave64, static_sampler_base: sampler_base, mem_windows: windows, ..Default::default() })?;
if !t.complete() {
let missing: Vec<&String> = t.unsupported.keys().collect();
return Err(format!("incomplete translation, missing: {missing:?}"));
}
return Ok((t, "cs_6_6"));
}
let sh = xbox::parse(blob).ok_or("not a console shader container")?;
// the hardware variant for this pipeline slot: VS (not the ES variant used with GS), PS
let want = match stage {
+34
View File
@@ -5940,3 +5940,37 @@ fn gpu_cmp_class_f16_preserves_snan() {
assert_eq!((r.sgpr[10], r.sgpr[11]), all, "wave{lanes} f16 neg(-1.0) matches +normal");
}
}
/// `XCL_SAMPLE_FSPX=<folder>`: every `*.bin` there that is an FSPX (driver) compute container –
/// e.g. the FSR4 pipelines XCL dumps to `<data>\shaders` – translates and compiles.
#[test]
#[ignore]
fn fspx_containers_translate_and_compile() {
use std::sync::atomic::{AtomicUsize, Ordering};
let Some(dir) = std::env::var_os("XCL_SAMPLE_FSPX") else { return };
let files: Vec<std::path::PathBuf> = std::fs::read_dir(dir).unwrap().flatten().map(|e| e.path()).collect();
let next = AtomicUsize::new(0);
let (n, ok) = (AtomicUsize::new(0), AtomicUsize::new(0));
std::thread::scope(|s| {
for _ in 0..super::dxc::compile_threads() {
s.spawn(|| loop {
let Some(path) = files.get(next.fetch_add(1, Ordering::Relaxed)) else { break };
let blob = std::fs::read(path).unwrap();
let Some(f) = super::pso::fspx(&blob) else { continue };
n.fetch_add(1, Ordering::Relaxed);
let t0 = std::time::Instant::now();
let name = path.file_name().unwrap().to_string_lossy();
match super::pso::console_to_dxil(&blob, super::pso::Stage::Compute, 0) {
Ok(c) => {
ok.fetch_add(1, Ordering::Relaxed);
println!("FSPX {name}: threads {:?} rsrc2 {:#x}, {} B code -> {} B DXIL, {:.2} s", f.threads, f.rsrc2, f.code.len(), c.dxil.len(), t0.elapsed().as_secs_f64());
}
Err(err) => println!("FSPX {name}: FAILED {err}"),
}
});
}
});
let (n, ok) = (n.into_inner(), ok.into_inner());
println!("FSPX: {ok} / {n} translated and compiled");
assert_eq!(ok, n);
}
+141
View File
@@ -977,6 +977,88 @@ fn fsr4_console_upscaler_creates_a_context_probe() {
put(&mut d, 400, &[16.6f32.to_bits(), 1f32.to_bits()]); // frameTimeDelta, preExposure
put(&mut d, 408, &[1]); // reset
put(&mut d, 412, &[0.1f32.to_bits(), 1000f32.to_bits(), 1.0f32.to_bits(), 1f32.to_bits()]);
// `XCL_PROBE_FSR_EXECUTE`: the inputs get content first (colour: a horizontal 0..1 grey
// gradient, depth 0.5, no motion) and the recorded frame runs on the GPU below
let execute = std::env::var_os("XCL_PROBE_FSR_EXECUTE").is_some();
let queue: ID3D12CommandQueue = device.CreateCommandQueue(&D3D12_COMMAND_QUEUE_DESC { Type: D3D12_COMMAND_LIST_TYPE_DIRECT, ..Default::default() }).unwrap();
let fence: ID3D12Fence = device.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap();
let mut fence_value = 0u64;
let mut run = |list: &ID3D12GraphicsCommandList| {
queue.ExecuteCommandLists(&[Some(list.cast::<ID3D12CommandList>().unwrap())]);
fence_value += 1;
queue.Signal(&fence, fence_value).unwrap();
let t0 = std::time::Instant::now();
while fence.GetCompletedValue() < fence_value && t0.elapsed().as_secs() < 20 {
std::thread::sleep(std::time::Duration::from_millis(5));
}
let removed = device.GetDeviceRemovedReason();
assert!(removed.is_ok() && fence.GetCompletedValue() != u64::MAX, "device removed: {removed:?}");
assert!(fence.GetCompletedValue() >= fence_value, "GPU work did not finish in 20 s");
};
let buffer = |bytes: u64, heap: D3D12_HEAP_TYPE| -> ID3D12Resource {
let mut r: Option<ID3D12Resource> = None;
device
.CreateCommittedResource(
&D3D12_HEAP_PROPERTIES { Type: heap, ..Default::default() },
D3D12_HEAP_FLAG_NONE,
&D3D12_RESOURCE_DESC {
Dimension: D3D12_RESOURCE_DIMENSION_BUFFER,
Width: bytes,
Height: 1,
DepthOrArraySize: 1,
MipLevels: 1,
SampleDesc: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 },
Layout: D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
..Default::default()
},
if heap == D3D12_HEAP_TYPE_READBACK { D3D12_RESOURCE_STATE_COPY_DEST } else { D3D12_RESOURCE_STATE_GENERIC_READ },
None,
&mut r,
)
.unwrap();
r.unwrap()
};
let footprint = |r: &ID3D12Resource| -> (D3D12_PLACED_SUBRESOURCE_FOOTPRINT, u64) {
let mut fp = D3D12_PLACED_SUBRESOURCE_FOOTPRINT::default();
let mut total = 0u64;
device.GetCopyableFootprints(&r.GetDesc(), 0, 1, 0, Some(&mut fp), None, None, Some(&mut total));
(fp, total)
};
if execute {
let h = |x: f32| -> u16 {
// f32 -> f16 for values in 0..1 (normal or zero)
if x <= 0.0 { 0 } else { let b = x.to_bits(); ((((b >> 23) & 0xFF) as i32 - 127 + 15) as u16) << 10 | ((b >> 13) & 0x3FF) as u16 }
};
let prep_alloc: ID3D12CommandAllocator = device.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).unwrap();
let prep: ID3D12GraphicsCommandList = device.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &prep_alloc, None).unwrap();
let mut uploads = Vec::new();
for (r, texel) in [
(&color, &(|x: u32, _y: u32| { let g = h(x as f32 / 1279.0); [g, g, g, h(1.0)].iter().flat_map(|v| v.to_le_bytes()).collect::<Vec<u8>>() }) as &dyn Fn(u32, u32) -> Vec<u8>),
(&depth, &|_x: u32, _y: u32| 0.5f32.to_le_bytes().to_vec()),
(&motion, &|_x: u32, _y: u32| vec![0u8; 4]),
] {
let (fp, total) = footprint(r);
let up = buffer(total, D3D12_HEAP_TYPE_UPLOAD);
let mut p: *mut std::ffi::c_void = std::ptr::null_mut();
up.Map(0, None, Some(&mut p)).unwrap();
let base = p as *mut u8;
for y in 0..fp.Footprint.Height {
let mut row = Vec::new();
for x in 0..fp.Footprint.Width {
row.extend(texel(x, y));
}
std::ptr::copy_nonoverlapping(row.as_ptr(), base.add(fp.Offset as usize + (y * fp.Footprint.RowPitch) as usize), row.len());
}
up.Unmap(0, None);
let dst = D3D12_TEXTURE_COPY_LOCATION { pResource: std::mem::transmute_copy(r), Type: D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 { SubresourceIndex: 0 } };
let src = D3D12_TEXTURE_COPY_LOCATION { pResource: std::mem::transmute_copy(&up), Type: D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 { PlacedFootprint: fp } };
prep.CopyTextureRegion(&dst, 0, 0, 0, &src, None);
uploads.push(up);
}
prep.Close().unwrap();
run(&prep);
println!("FSR inputs uploaded (colour gradient, depth 0.5, no motion)");
}
let dispatch: extern "C" fn(*mut usize, *const u32) -> u32 = std::mem::transmute(proc(&m, "ffxDispatch"));
let rc = dispatch(&mut ctx, d.as_ptr());
println!("ffxDispatch: code {rc:#x}");
@@ -1025,5 +1107,64 @@ fn fsr4_console_upscaler_creates_a_context_probe() {
println!("console list → PC: {t:?}");
assert!(t.unknown.is_none(), "all FSR records recognised");
assert!(t.clears > 0 && t.copies > 0 && t.skipped == 0, "UAV clears and copies carried over to the PC");
if !execute {
return;
}
assert_eq!(t.skipped_dispatches, 0, "every FSR4 pass translated");
let pc_raw = console_list::pc_list(console).expect("the console list's PC list");
let pc = ID3D12GraphicsCommandList::from_raw_borrowed(&pc_raw).unwrap().clone();
let t0 = std::time::Instant::now();
run(&pc);
println!("FSR4 frame ran on the GPU in {:.1} ms (with submission)", t0.elapsed().as_secs_f64() * 1000.0);
// the output back to the CPU
let (fp, total) = footprint(&output);
let rb = buffer(total, D3D12_HEAP_TYPE_READBACK);
let rb_alloc: ID3D12CommandAllocator = device.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).unwrap();
let rb_list: ID3D12GraphicsCommandList = device.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &rb_alloc, None).unwrap();
let barrier = |before, after| D3D12_RESOURCE_BARRIER {
Type: D3D12_RESOURCE_BARRIER_TYPE_TRANSITION,
Anonymous: D3D12_RESOURCE_BARRIER_0 {
Transition: std::mem::ManuallyDrop::new(D3D12_RESOURCE_TRANSITION_BARRIER { pResource: std::mem::transmute_copy(&output), Subresource: 0, StateBefore: before, StateAfter: after }),
},
..Default::default()
};
rb_list.ResourceBarrier(&[barrier(D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE)]);
let dst = D3D12_TEXTURE_COPY_LOCATION { pResource: std::mem::transmute_copy(&rb), Type: D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 { PlacedFootprint: fp } };
let src = D3D12_TEXTURE_COPY_LOCATION { pResource: std::mem::transmute_copy(&output), Type: D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 { SubresourceIndex: 0 } };
rb_list.CopyTextureRegion(&dst, 0, 0, 0, &src, None);
rb_list.Close().unwrap();
run(&rb_list);
let mut p: *mut std::ffi::c_void = std::ptr::null_mut();
rb.Map(0, None, Some(&mut p)).unwrap();
let half = |v: u16| -> f32 {
let (s, e, m) = ((v >> 15) as u32, ((v >> 10) & 0x1F) as i32, (v & 0x3FF) as f32);
let x = if e == 0 { m / 1024.0 * 2f32.powi(-14) } else if e == 31 { if m == 0.0 { f32::INFINITY } else { f32::NAN } } else { (1.0 + m / 1024.0) * 2f32.powi(e - 15) };
if s == 1 { -x } else { x }
};
let (mut finite, mut nonzero, mut n) = (0u64, 0u64, 0u64);
let (mut left, mut right) = (0f64, 0f64);
for y in (0..1080u32).step_by(8) {
let row = (p as *const u8).add(fp.Offset as usize + (y * fp.Footprint.RowPitch) as usize) as *const u16;
for x in (0..1920u32).step_by(8) {
let r = half(*row.add(4 * x as usize));
n += 1;
if r.is_finite() {
finite += 1;
if r != 0.0 {
nonzero += 1;
}
if x < 480 {
left += r as f64;
} else if x >= 1440 {
right += r as f64;
}
}
}
}
rb.Unmap(0, None);
println!("FSR4 output: {n} samples, {finite} finite, {nonzero} non-zero; red mean left quarter {:.3}, right quarter {:.3}", left / (n as f64 / 4.0), right / (n as f64 / 4.0));
assert_eq!(finite, n, "no NaN / inf in FSR4's output");
assert!(nonzero > n / 2, "FSR4 wrote its output");
assert!(right > left, "the input's left-to-right gradient survives the upscale");
}
}