Skip to content

Release 0.7.0-rc1: SR Fast/Exact (M/K/L), faster bit-exact Model K, RR Preset F, and Frame Generation + OptiScaler - #306

Draft
phantoslayer21 wants to merge 85 commits into
mainfrom
rel/0.7.0-rc1
Draft

phantoslayer21 wants to merge 85 commits into
mainfrom
rel/0.7.0-rc1

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Unified \

…presenter (F6a)

clean/fg/presenter: IFgPresenter and its value types; the target-time scheduler
(interval estimate, target[k] = t_base + round(k * T / (N + 1)) for 2x..6x in
checked 64-bit ticks, bounded playout lead, variable-refresh window guard with
hysteresis, deadline admission, menu / reset / count changes latched per
interval, epochs, plan validation); a deterministic fake presenter (fake clock,
fences and display slots, one owner per chain, late drops with held leases,
suffix cancellation that keeps the real image, resize that waits for old work,
device-loss teardown, refusal without fallback); CPU tests built with
/W4 /WX /permissive- and wired into the CPU CI job. Nothing in the runtime uses
it yet.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…F6b)

Two production IFgPresenter back ends on a shared display-slot engine, and an explicit selector.

- fg_present_engine: the F6a slot rules without a clock, fences or display of its own. The back end
  passes time in, answers producer fences, drains an outbox of presents in order, forwards cancellations
  and reports what the display did. A slot is handed out again only after the display path gave it
  back. Pacing arithmetic: vblank snapping, whole-refresh cadences, timer due times.
- fg_win_comp_presenter: presentation manager with a target time per image (interrupt time) and a
  DirectComposition visual on the game window. Zero-copy slots: D3D12 shared displayable textures
  (simultaneous access) opened on a small D3D11 presentation device and registered with
  AddBufferFromResource. Shared fences both ways: an image is presented only after its producer fence
  completed (CPU check plus a D3D11 GPU wait), and a slot returns only on a terminal statistic plus
  IsAvailable. Fixed refresh snaps targets to the middle of their vblank window and refuses cadences
  that are not whole refreshes. ForceVSyncInterrupt off by default. Refuses without independent flip,
  displayable surfaces or the hardware flip queue.
- fg_dxgi_presenter: the game's flip-discard swap chain, paced by a worker on a high-resolution timer:
  Present(0, ALLOW_TEARING) at each target, or tear-free Present(1, 0) issued half a refresh before
  the target vblank. Producer fence wait on the GPU, copy into the back buffer, frame-latency waits off
  the game thread; resize releases and retakes the buffers.
- fg_presenter_factory: Auto / WindowsCompositionHwfq / DxgiFlipTearing / DxgiFlipVsync, a capability
  probe (D3DKMT flip-queue bits, independent flip, displayable, tearing) and creation that refuses with
  a reason and never tries another back end.
- Stats gain display_skipped and display_collisions.

Tested: MSVC /W4 /WX /permissive-, Release and Debug: test_fg_presenter 661 checks, test_fg_win_presenters
374 checks, 0 failures; headless GPU leg (--gpu, no window: unbound composition surface and a
composition swap chain) 449 checks, 0 failures on an RX 9070 XT.
Not tested: on-screen pacing (needs a live display), tearing presents on a window swap chain, device
removal on hardware, CI.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…and history (F3a, F4a)

CPU groundwork for the 0.7.0 frame generation runtime in clean/fg/runtime, hidden behind
FG-off: nothing advertises a mode until the modes are qualified.

- fg_contract.h: versioned, size-tagged session / frame / result structs, presets A/B/C,
  N = 1..5, the intermediate time, explicit refusal reasons, and a release route check
  with no alternate route.
- fg_grid.h: net1 and net2 grid sizes from the frame size (the create-time size table).
- fg_model.h: checks a local model file against data/fg.v1.map.json (checksum, map hash,
  42 stages in order with names, types, shapes, recomputed stage digests, float16-exact
  values) before anything is prepared from it.
- fg_net1_plan.h: the fused 11-launch net1 plan ported from runner/fg_net1_mma.py with
  its buffers in input / weight / scratch arena regions, an independent plan check, a
  recorder that refuses before recording anything, and the weight fragment packing.
- fg_history.h: title-neutral tag-to-frame assembly and the previous / current history
  banks: exact identity, rotation only on an accepted game frame, never over a bank
  compute still reads, re-prime on startup, reset, menu, gaps, size changes and chain
  replacement.
- fg_worker.h: create-time work on a worker with a bounded wait, named callables only.

Tests: ctest fg_runtime (23 tests) checks the size table rows, every refusal,
constructed model files and their defects, the plan and its recording through a fake
recorder against a table generated from the Python plan, plan and history mutants, and
the worker's failure paths under /permissive-. test_fg_runtime_tables.py keeps the
generated headers current. CI builds and runs the suite in the converter job.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Groundwork for the game-facing side of frame generation (#96), split like the
RR plugin: a platform-free core under clean/fg/proxy that a per-title
transport or a host plugin entry drives. Nothing is wired into a game, the
front end or the launcher, and nothing is advertised.

- fg_adapter_abi.h: host-neutral, size- and version-tagged contract: adapter
  identity, capability, decoded options / tags / constants, present
  descriptor and result, the assembled packet and session (field for field
  the runtime contract's FgFramePacket / FgCreateDesc), the next link of the
  game interface, the host provider entry and the executor hand-off.
- fg_proxy_core: install-off gate (fg=off by default; route facts checked in
  a fixed order, first failure reported; zero takeover while any fails),
  feature-scoped routing (only the FG feature id is answered; SR, RR, the
  latency features and unknown ids pass through; tags and constants always
  forwarded), truthful capability (max generated 0 unless the route holds,
  then min(5, entry ABI max, game UI range)), tag-to-packet assembly with
  exact token / viewport / LUID / epoch matching, a single present owner per
  swap chain, one diagnostic per transition, no throwing lambda captures.
- fg_settings: per-game keys fg, fg_preset, fg_multiplier, fg_presenter with
  strict spellings, defaults, round trip and an apply that leaves every other
  settings key alone.
- fg_contract_bridge.h: conversion to clean/fg/runtime/fg_contract.h with
  compile-time checks of every shared number; the test uses it when that
  contract is in the tree.
- tests/test_fg_proxy.cpp: fake game interface (SR, RR, FG and latency
  features in one session), fake host and executor; plus eight mutant builds
  that must each fail. Wired into CI's converter job.

Refs #96

Tested:
- MSVC /W4 /WX /permissive-, Release and Debug: fg_proxy (653 checks) and
  mutants 1-8 (each caught by assertions)
- Release with the FG runtime contract on the include path: bridge checks
  pass (662 checks)

Not tested:
- any game, transport or GPU (none is wired in this change)

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…xecutor and presenter (F7a)

clean/fg/runtime/fg_session.h/.cpp: one FG pipeline per swap chain. The game
adapter core's executor hand-off (WgFgExecutorV1) feeds FgSession::OnPresent;
history (FgHistory) accepts the game frame, the target scheduler commits the
interval, the presenter reserves its slots, and the new IFgKernelExecutor seam
records the work: RecordSharedGameFrame once per accepted game frame, then
RecordGeneratedIndex for i = 1..N in order (t = float(i) / (float(N) + 1),
checked against the plan and the ingest side, is_last_index, preset graph, the
reserved presenter slot), then the game frame (RecordRealEndpoint), submitted
with one ready fence per slot.

- Preset and N are frozen per game frame; a count change (2x -> 6x -> 3x)
  never resets history.
- Menu latch: a menu decision on frame k makes frames k and k + 1 exact
  game-frame copies (RecordMenuCopy); history keeps rotating. Priming frames
  copy as well, so pacing never changes.
- History reads are fenced and the advance counted on the last index.
- Real-only intervals (priming, variable-refresh window exit, the adapter's
  real-only reasons via FgSessionPresent) show the game frame at its target.
- A stale suffix is cancelled and the game frame kept; resize runs in two
  steps with old work drained; device loss drops everything at once.
- Every failure is an explicit FgSessionError; a refusing executor or a broken
  presenter puts the session into a sticky Refused state with no fallback
  route (the failing interval's game frame is still shown when it can be
  recorded).
- fg_session_win.h/.cpp: the Windows presenter source over the back-end
  factory; the chosen back end is created or refused, never another one.

Integration fix: fg_presenter.h and fg_contract.h both defined wgfg::FgStatus,
wgfg::FgRealOnlyReason and kFgMaxGenerated, so no file could include both. The
runtime contract's enums are now FgFrameStatus / FgFrameRealOnly (values
unchanged) and kFgMaxGenerated lives in clean/fg/fg_limits.h.

Tests (ctest fg_session, CI flags /W4 /WX /permissive-): a fake game drives
the adapter core on a fake game interface into the session, a fake kernel
executor and the fake presenter on a fake clock. 2x..6x with presets A / B / C,
dynamic count, preset switch, menu latch (detected, latched, resumed; the
game's own menu flag), super resolution / ray reconstruction / latency calls
passing through untouched, resize, device loss, variable-refresh exit and
re-entry, late GPU images and a stale CPU suffix, history busy with priming
copies, a frame history refuses, refusing executors and a broken presenter, create
refusals, the Windows source's refusals. Six session mutants
(fg_session_mutant_1..6) are each caught by the suite.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
… D3D12 kernels (#96)

The shared non-network stages and the light candidate blend of preset C:

- clean/fg/reference/stages_common.py: menu detection (both detectors, exact
  thresholds, one-game-frame latch), downsample with UI estimate and colour
  alpha, motion and packed depth, the previous-to-current scatter (signed
  64-bit minimum), unpack, hole rule and pull / push pyramid, hole mask,
  quality image, net1 input packer and output unpacker, intermediate-time
  scatter, blend weights, copies and menu output.
- clean/fg/reference/lite.py: the light blend (simple path, UI overlay,
  refined candidates).
- clean/fg/reference/pipeline.py: the schedule (once per game frame vs once
  per index for 2x..6x, history and swaps on the last index only, resets,
  frozen flags, generation-disabled word) and its CPU executor.
- clean/dx12/kernels/fg_lite_*.hlsl: D3D12 kernels of every stage,
  byte-identical to the CPU reference (shader model 6.6 64-bit atomics).
- clean/fg/runner/fg_lite_d3d12_check.py: the whole chain on the device
  (net1 fused or exact) against the CPU reference, with sentinels, slack,
  half-grid negative controls and two mutants; step-range timing.
- clean/dx12/tests/kernel_replay.cpp: "time <runs> <first> <last> <label>"
  times a range of a chain's steps.
- Tests: every stage against scalar loop versions, detection boundaries,
  packed-depth round trip, hole rule, 2x / 6x schedules, blend paths.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…rom (#96)

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…exact D3D12 kernels (#96)

The Full generated frame outside the two networks:
- reference/stages_full.py: the Full blend (both candidates, hole flag, preset B's UI recomposition) with net2's
  inputs Ib / Ic / Ia averaged over k x k blocks of the padded frame (k = 1, 2, 4, 8, 16); the output pull, middle
  pull, push and push-fine pyramid (candidates resampled along net2's vectors, mixed by net2's weight, holes
  inpainted); the two distortion stages. Single precision with flushed subnormals, hand-written bilinear / nearest
  reads and pairwise block sums, so the kernels can match it bit for bit.
- D3D12 kernels fg_full_blend, fg_out_pull, fg_out_pull_mid, fg_out_push, fg_out_push_fine, fg_dist_down,
  fg_dist_fields (code object name fg_full.co, built only with --only).
- runner/fg_full_stages_d3d12_check.py: every kernel, the chained stages and full-size frames against the reference
  byte for byte (two sentinel fills, slack bytes, half-grid negative controls, preset A / B mutants, a float16 write
  and fused multiply-add probe with two mutants); per-stage timing after a passing check, information only.

Tested: python -m unittest discover -s clean/fg/tests -t . (130 tests, 45 new); clean.dx12.tests.test_kernel_sets;
RX 9070 XT, D3D12: 45 small cases (1,581,567 values), 1920 x 1080 and 2560 x 1440 stages (106.3 M and 189.1 M
values) identical to the reference under both fills, 7 of 7 negative controls and 4 of 4 mutants caught.
Not tested: net2 between the blend and the pull (synthetic net2 output here); HIP (no HIP counterpart).

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
net2 (the 50-blob network) complete on the CPU and on D3D12, bit for bit.

- clean/fg/reference/net2.py: the grid from the frame size, the 28 launches
  as data (input merge, L1..L3 with the 2 x 2 average pool, the residual
  blocks L4..L11 and L16..L23, the L12 / L24 splits, the L13 / L25 heads,
  the weightless upsample, the warp-merge, the 8-channel output with its
  residuals); tap-major float16 chunk accumulation from the bias, leaky
  ReLU with the [-6, 6] clamp and its per-layer exceptions, the 2x
  half-pixel upsample and the warp sample with single-rounding fused
  multiply-adds.
- clean/fg/reference/fp16acc.py: acc_matmul16, the exact chunk accumulation
  for a whole matrix product (same bits as acc_dot16).
- clean/dx12/kernels/fg_net2_{conv,up2,merge,warp}.hlsl and
  clean/dx12/hlsl/fg_net2.hlsli: exact kernels (the convolution uses the
  integer chunk code of fg_exact16.h, with fused pool, activation, clamp
  rule and residual); the network runs as 38 launches.
- clean/fg/runner/fg_net2_d3d12_check.py: every kernel (special values
  too), an adversarial multiply-add probe, the whole network at small grids
  and at 480 x 272 / 640 x 368, against the CPU reference byte for byte with
  two sentinel fills and slack; a half-grid negative control per kernel, a
  half-grid last launch and two clamp mutants; --timing only after a
  passing record.

Tested:
- python -m unittest discover -s clean/fg/tests -t . (120 tests, OK)
- python -m unittest clean.dx12.tests.test_kernel_sets (OK)
- fg_net2_d3d12_check.py --run on an RX 9070 XT (native D3D12): every case
  byte-identical to the CPU reference, every negative control and mutant
  caught

Not tested:
- a converted weight file (synthetic weights only)
- HIP (D3D12 only)

Refs #96

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…rnels and the presenters (F7b)

FgD3d12Executor is the production IFgKernelExecutor on the game's D3D12 device and queue (#96):

- One root signature for every FG kernel (arena root UAVs, 59 root constants, the driver channel and one texture
  view); the kernels' DXIL comes from a folder built by clean/dx12/build_dx12.py --only and every pipeline is built
  once at configuration, together with the arena (every light-path image, net1's three regions, the input capture
  areas, the Full path's images, net2's tensors, the output pyramid and the logistic table), the weights upload, the
  shared producer fence, the command allocators and the menu readback.
- Per game frame: the colour, motion, depth and optional hudless colour / UI alpha are captured from the game's
  textures (new fg_exec_io.hlsl), then the shared stages of the light path's schedule run (clears, menu detection,
  R3 / R4, the previous-to-current scatter, unpack, hole rule, pull / push, hole mask, net1's input, the fused
  11-launch net1 through fg_net1_plan.h and its output); the detection is read back with a bounded wait on its own
  submission so the session gets this frame's decision.
- Per index: the intermediate-time scatters, the blend weights and the light blend (preset C) or the Full blend, net2
  and the output pyramid (presets A / B), the menu output, then the image is written into the presenter slot's
  texture (packed to the slot's format, COMMON -> COPY_DEST -> COMMON) and the shared fence is signalled. Menu /
  priming copies and the game frame's endpoint copy the colour exactly; a real-only interval reserves a real slot.
- fg_exec_plan.h/.cpp (plain C++17): the grid sizes, regions, float16 rounding, the logistic table and the schedule
  of reference/pipeline.py Host split at the session's seam.
- FgExecutorPresenterSource binds the executor to the composition or DXGI back end the session creates;
  FgExecWeightsFromModel takes net1 / net2 weights from a checked model file.
- Every refusal names its reason (missing / invalid kernel files, pipelines, weights, size, inputs, slots, preset,
  distortion field); nothing falls back.

The branch carries the light path (preset C), Full path stage and net2 kernel commits it builds on.

Tested:
- ctest fg_presenter, fg_win_presenters, fg_runtime, fg_session (+6 mutants), fg_d3d12_e2e (CPU: geometry, regions,
  thresholds and the logistic table digest against the CPU reference, float16 rounding, the schedule, every
  refusal), fg_proxy (+8 mutants): Release and Debug, MSVC /W4 /WX /permissive-
- test_fg_d3d12_e2e --gpu on the RX 9070 XT, headless: preset C 2x / 6x and preset A 2x with a menu frame through
  the adapter core, the session, the executor and both back ends (composition on an unbound surface, DXGI on a
  composition swap chain): generated images finite, menu / endpoint copies exact, slot bytes equal to the image in
  the slot's format, fences complete, DXGI slots all returned; D3D12 debug layer clean; broken kernel folders
  refused (Release and Debug)
- test_fg_win_presenters --gpu; python -m unittest discover -s clean/fg/tests

Not tested: a game; an attached window; byte comparison of the executor's sequence against the CPU reference
pipeline (the stage kernels are checked byte for byte by their own runners).

Refs #96

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
net2's fast path, tier B like net1's: the chunk sums run on
v_wmma_f32_16x16x16_f16 and are rounded to float16 after every chunk;
every other operation keeps the CPU reference's bits. The exact kernels
stay the validation mode.

- clean/dx12/kernels/fg_net2_mconv.hlsl: the 3 x 3 convolution, one
  matrix instruction per spec chunk in net2's tap-major order, the float16
  accumulator from the bias as C; exact leaky ReLU, clamp rule, residual
  and 2 x 2 average pool in the epilogue. Variants by output tiles per
  wave, 16-channel blocks per tap and workgroup size; the 2x upsample of
  L12, L13, L24 and L25 is computed exactly into the workgroup's LDS tile,
  and the three heads of L13 / L25 run as one launch.
- clean/dx12/kernels/fg_net2_upwarp.hlsl: the head upsample and the
  warp-merge in one launch, exact.
- clean/dx12/hlsl/fg_net2_fast.hlsli: exact float16 operations on 8
  values at once (single-precision products, two-sum made round-to-odd,
  one driver-channel conversion), the bits of fg_net2.hlsli.
- clean/fg/runner/fg_net2_mma.py: plan (weight swizzle, padded bias,
  variant choice, the 27-launch chain) and the GPU check: byte gates on
  exactly summable values for every kernel variant, adversarial probes of
  every rewritten rounding (staged upsample, pool / leaky / clamp,
  residual multiply-add, upwarp) each with a mutant it catches,
  determinism over two sentinel fills with slack at every grid
  (480 x 272 and 640 x 368 included), a half-grid negative control per
  kernel, three chain mutants, the exact chain alongside, differences from
  the CPU reference reported; --timing only after a passing record (wall
  and GPU time), --profile for per-launch GPU times (diagnostic).
- clean/dx12/tests/kernel_replay.cpp: "time <runs> each" prints every
  run's wall time and its GPU time (device timestamps around the run).
- clean/fg/runner/fg_net2_d3d12_check.py: the case builders take a case
  class (the fast path reuses them); no change to the exact chain.

Tested:
- python -m unittest discover -s clean/fg/tests -t . (125 tests, OK)
- python -m unittest clean.dx12.tests.test_kernel_sets (OK)
- fg_net2_mma.py --run on an RX 9070 XT (native D3D12): 74 cases, all
  gates pass (49 byte-identical to the CPU reference, including every
  probe; every negative control and mutant caught); the exact chain
  byte-identical at 48 x 32, 480 x 272 and 640 x 368

Not tested:
- a converted weight file (synthetic weights only)
- HIP (D3D12 only)

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
The transport half of the FG game adapter, following the RR plugin's hook
mode (clean/rr_f/proxy/HOOK-MODE.md) and reusing its bounded PE view, safe
reads and scan budget (rr_guard) unchanged.

- win32/fg_asi_transport: install-off gate (fg=off reads nothing from the
  process and patches nothing), qualified title binding plus native codec
  required, interface module found (or the game's own file loaded for an
  exe that delay-loads it), version gate, core attached through
  WgFgChainV1, bounded fail-open scan (nothing patched unless the whole
  scan finished inside its budget), by-name import and delay-load slots
  redirected for the FG roles only. Every handler routes through
  FgProxy: frame generation is answered only while taken; super
  resolution, ray reconstruction, the latency features and unknown ids
  reach the genuine export with the game's own arguments and result.
  Exceptions never cross a handler and a call is never forwarded twice.
  restore() puts back every slot that still holds a handler.
- win32/fg_swapchain_hook: COM-identity-preserving IDXGISwapChain4
  wrapper installed at CreateSwapChainForHwnd. One present owner per
  chain (FgProxy::claim_present or the owner registry). Test presents go
  straight through; BeginInterval once per interval, PresentInterval for
  the real presents; DXGI_ERROR_WAS_STILL_DRAWING keeps the interval open
  so a retry never rotates history or submits twice; flags and HRESULTs
  unchanged; re-entrant presents bypass the hook; resize, fullscreen and
  color space reported around the real call; facade seam for GetBuffer,
  the back-buffer index and the latency waitable; a throwing presenter is
  detached and the interval presented once.
- win32/fg_asi_entry: WrongGPU-FG.asi (InitializeASI, WrongGPU_FgShutdown,
  WrongGPU_FgQuery). No title binding is qualified yet, so it patches
  nothing even with fg=on.
- tests: stand-in interface DLL (synthetic names and version), stand-in
  game modules with static and delay-load imports, an exe that
  delay-loads the interface, fake swap-chain and factory objects; the
  shipped plugin per settings file in its own process; eight mutants of
  the transport and seam, each caught. Synthetic values only.

Tested: clean/fg/proxy Release and Debug with MSVC /W4 /WX /permissive-,
static runtime: 23/23 ctest each (fg_proxy 653 checks, fg_proxy mutants
1-8, fg_win32_transport 629 checks, fg_win32_delay_exe 17 checks,
fg_win32_asi off/default/invalid/on, fg_win32 mutants 1-8 each failing).
Not tested: any game, any GPU, a real DXGI factory or swap chain.

Refs #96

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…(F8b)

The first qualified FG title binding: Cyberpunk 2077 on game-interface
build 2.14.1, with the native codec for the interface's FG structures
and the swap-chain hook on the factory the game creates through the
interface module.

- bindings/: cp2077-2.14.1.json (data only: exe name, interface version
  gate, feature 1000, options v5 / 120 B and state v4 / 88 B GUIDs, FG
  input buffer types, optional inputs, UI range, the factory import);
  the export names, the interface file name and the shared structure
  GUIDs come from the RR binding for 2.14, the two FG feature-function
  names from fg-functions.json (each alone on its line). The configure
  step (fg_binding_gen.cmake) writes them into a header in the build
  tree, so the code names nothing of the interface.
- win32/fg_sl214_codec: chain walk by GUID (any order, unknown
  structures skipped, bounded); the options checks in the original's
  order (missing options or viewport 20, count 0 25 even with the mode
  off, count above the reported maximum 38, dynamic mode refused while
  unsupported); options decoded (UI recomposition 1 -> preset B); the
  state written only up to the passed version (minimum size 100,
  maximum at +52, dynamic byte at +80, status bits for a low resolution
  and an unset common constant); tags valid until present and constants
  into the contract's structs; a present-interval frame clock for a tag
  call that carries no frame token.
- win32/fg_asi_transport: the get-state call takes the game's options
  argument; the codec's checks run before decoding while FG is taken;
  the factory-creation import is redirected (genuine result unchanged)
  and the swap-chain creation hook goes on the returned factory; chains
  created while FG is taken are claimed for the swap-chain wrapper and
  every game interval goes to the core (the presented buffer as colour
  input) before the presenter; restore detaches them and removes the
  hook. FgSwapChain::DetachCallback and FgProxy::session_viewport added.
- win32/fg_asi_entry: the binding is selected by the exe's file name;
  any other game still patches nothing.
- tests: test_fg_cp2077_binding (binding data, codec from raw bytes, a
  whole session through the stand-in interface with the binding's own
  GUIDs and names, fg=off, FG not taken), the shipped plugin in a
  process with the game's exe name, eight mutants each caught.
  Synthetic values only.

Tested: clean/fg/proxy Release and Debug with MSVC /W4 /WX /permissive-,
static runtime: 34/34 ctest each (fg_proxy 653 checks, fg_win32_transport
629, fg_win32_delay_exe 17, fg_cp2077_binding 385, fg_cp2077_asi off/on,
fg_proxy / fg_win32 / fg_cp2077 mutants 1-8 each failing).
Not tested: the game, any GPU, a real DXGI factory or swap chain.

Refs #96

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…default (F8c)

Frame generation's per-game settings and its data conversion in the launcher, behind a new CMake
option WRONGGPU_FG (default OFF). With it off nothing changes for any game: the four keys are
refused by name, preset FG's converter map is not embedded and no file is written differently.

With WRONGGPU_FG=ON:
- fg=off|on, fg_preset=A|B|C, fg_multiplier=2|3|4|5|6 and fg_presenter=auto|hwfq|dxgi_tearing|
  dxgi_vsync are profile settings (set only, not on the settings page), validated in exactly the
  spellings of the frame generation proxy's reader (no case folding), defaults off, A, 2, auto.
  profile.ini gets a line only for a value away from its default.
- The launcher's apply writes the four keys into the game's settings.ini in the same write as the
  front end's keys, only once the profile opts in (or the file already holds one, so turning it off
  is written down). fg stays off there while the data on this PC is not ready, with a warning.
  The effective wronggpu.ini never takes an FG key for a runtime option.
- set <game> fg=on needs a frame generation library in the game; when the data is not ready it is
  converted first from the game's own nvngx_dlssg.dll. A library older than 310.1 (for example
  3.7) is refused by its version, with the version named; nothing is saved.
- model status|convert --preset=FG converts with data/fg.v1.map.json (loaded as preset FG) into
  model\FG\model.wgcm; the search looks for nvngx_dlssg.dll and the ignore lists apply.
- get shows the file's FG values and lists invalid ones (fg_issues); status <game> adds an fg
  object.

Tests: fg-choice (new ctest target, profile.cpp built with the choice on, added to both CI launcher
jobs), and new cases in wg-core and launcher-core: the keys and spellings, settings.ini beside the
upscaler and RR keys, the opt-in rule, the library's version on synthetic PE files, preset FG by
name, the build without the choice. Synthetic folders and values only.

Tested: wg-core, launcher-core, coexist-core, convert-ignore, model-choice, model-choice-k,
model-choice-k-only, fg-choice, source-size, wording in Release and Debug, with the CI
configuration (FG off) and with Preset K, Model K/L and FG on; launcher-core in WRONGGPU_TESTING
builds with FG off and on; the launcher's model command on synthetic libraries in both builds.
Not tested: the launcher suite (run_launcher_tests.py), a conversion from a library that has the
frame-generation model, and frame generation in a game.

Refs #96

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…r and the presenters; net2 fast path in the executor (F9 prep)

Integration branch of the FG pieces (F6a/F6b presenters, F3a/F4a runtime, F8a adapter core, F7a session, F4b/F4c
Full and Lite kernels, F3b net2, F7b executor, F3b-fast net2 on the matrix unit, F8b transport and the Cyberpunk 2077
2.14.1 binding, F8c launcher settings) with the wiring that joins them.

- FgDxgiPresenter: Detach and the destructor drain the game's queue (a fence signalled after the last copy and
  present, own event) before the swap chain's buffers are let go, so the chain can be released right after teardown.
- Real-only frames on the Windows presenters: FgSessionPresent hands the game's back buffer to
  FgSession::OnGameFrameOnly (FgRealDispatchDesc::game_colour); the executor reserves a real slot, captures the back
  buffer and copies it exactly when the frame had no shared work (FG off, menu flag, missing inputs, epoch change).
- FgD3d12Executor: net2 on the fast path by default (27 launches: the input merge, fg_net2_mconv variants chosen as
  clean/fg/runner/fg_net2_mma.py chooses them, the staged upsamples and one launch per head layer, fg_net2_upwarp),
  weights swizzled into A fragments at configuration; the exact 38-launch chain stays selectable
  (FgD3d12ExecutorDesc::net2). Only the chosen path's kernels are loaded. Net2SelfTest runs net2 alone on synthetic
  inputs (comparison and timing legs); FgD3d12ExecutorKernelNames lists the DXIL an executor loads.
- WrongGPU-FG.asi: with fg=on and the title binding selected, the session host (win32/fg_asi_session.h) checks the
  local FG model and the kernel folder (wronggpu-setup\fg-dxil next to the plugin) before anything is patched
  (kFgRuntimeMissing otherwise); sets the route facts (model / presenter, the RDNA 4 adapter from the game's factory,
  device and queue from the chain); gives the claimed chain facade buffers through the wrapper's facade seam (the
  colour input is the facade buffer the game presented); creates the session with one executor and the presenter
  fg_presenter names, and routes every present through FgSessionPresent. Anything the session does not take is
  copied into the real chain and presented as the game asked. fg=off still installs and allocates nothing.
- Transport seams: FgAsiConfig::present_route / factory_note; IFgSwapChainSink::ExtraCreateFlags and
  IFgPresentCallback::ExtraSwapChainFlags / Attached (the creation adds the presenter's flags, retried as the game
  asked on failure; resizes keep them).
- kFgModesQualified behind WRONGGPU_FG_DEV_QUALIFIED (CMake option, default OFF; developer test builds only).

Tests: test_fg_d3d12_e2e adds the net2 plan / swizzle checks (CPU), presets A / B, net2's exact path, frames with
generation off (real-only from the back buffer), immediate swap-chain release, and fast-vs-exact net2 on synthetic
inputs with a negative control (GPU); test_fg_asi_session (new) covers the host's precheck and flags (CPU) and drives
the host headless through a wrapped composition swap chain (GPU). fg_cp2077_asi_on now expects kFgRuntimeMissing (no
model in its redirected LOCALAPPDATA).

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…ive; FG call lines; developer frame dumps (F9)

The session host read the adapter only from the game's DXGI factory, so an FG support query the game made before it
created that factory was forwarded as not supported. The transport now calls FgAsiConfig::core_ready once the core is
attached and the scan found slots, before the first slot is written: the host sets the model / presenter facts and
probes the adapter with CreateDXGIFactory1 (adapter list only, no device). The game's own factory still confirms the
adapter, or supplies it when the probe found none.

The transport logs each FG call kind (support query, function lookup per name, set-options, get-state) on its first
call and whenever its result changes, at most 64 lines per install; the codec describes the options (mode, frames,
flags, UI recomposition) and the state (frames max, status) for those lines.

Developer builds only (WRONGGPU_FG_DEV_QUALIFIED) with WRONGGPU_FG_DUMP_DIR naming a folder: the executor copies the
game frame's and each generated frame's slot image of every 30th generating game frame (at most 6) to readback
buffers and writes them as binary PPM files once their fence passed (never waited for on the present path); each file
is logged. Off in every other build.

Tests (synthetic values): core_ready runs before any slot is patched and not for a refused install; the first FG
support query is answered with the route; the call lines appear once per change; the codec's descriptions; the slot
format conversions and the PPM writer.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Found and fixed with the game running frame generation on an RDNA 4 card
(both the Full and the Lite preset):

- Transport: an earlier plugin's import patch on the same slot is chained to
  instead of bypassed (so the FG plugin coexists with another interposer
  plugin); the start-up route probe is retried at the first FG support /
  is-loaded / set-loaded call when the factory could not be created inside
  the loader lock; is-loaded and set-loaded for the FG feature are answered
  here (two new hooked roles).
- Tags valid only during the tag call are admitted by the Cyberpunk binding
  (tag_lifetimes 0 and 1; "until evaluate" stays refused). The session host
  copies such a texture on the tagging command list (FgAsiConfig::tag_retain)
  and fills a zero size / format from the resource. The transport itself never
  dereferences a tag's resource: without the hook a transient tag is not kept,
  so the unit tests' synthetic pointers are never used as COM objects.
- Core: zero output / render rects in the constants default from the colour /
  depth inputs; motion smaller than the output sets the render-resolution
  motion flag.
- Session host: zero option sizes / format come from the swap chain; render
  bounds 100..output when the title gives none; no menu detection stall before
  the first interval; a 4 ms first-image budget; a run-statistics line on
  session destroy.
- Executor: motion vectors with four channels are accepted; a real-only
  present waits up to 100 ms for a free slot; the game colour is passed down
  for real endpoints; developer dumps are armed on a generated index so each
  dump is a matched pair.
- Session: generation needs a bank that holds the frame; a busy presenter is
  waited for up to 100 ms at the start of an interval.
- DXGI presenter: default slot pool of at least 8; a tearing present refused as
  invalid (exclusive fullscreen) is retried without the tearing flag.

Tests: the stand-in interface and game gain the two roles; new cases for slot
chaining, the lazy route probe, is-loaded / set-loaded, the transient-tag hook,
rect defaults and the motion flag, and motion formats with four channels; the
cp2077 binding test now expects tag_lifetimes [0, 1].

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…ms Model L at 1440p Q, byte-identical) and m_mode presets
…on, and tap-pipelined net1/net2 WMMAs (-53.1% Preset C 2x, -49.5% Preset A 2x, 116/116 exact)
…'s packed rows directly, dropping the fg_exec_pack pass (Preset A 2x -45 us, 6x -219 us; Preset C 2x -45 us, 6x -223 us; exact)

The Full path's fg_out_pull / fg_out_push_fine and the light path's fg_lite_blend each get a _pack variant that stores the 8 / 10-bit UNORM slot code (clean/dx12/hlsl/fg_pack.hlsli, the same code fg_exec_pack computes) instead of the float16 image, so the generated frame is neither written at 8 B per pixel, read back, nor given its own dispatch and barrier. The executor picks them when nothing writes the output image after them (no menu output, prefill or copy), outputs are not kept for readback and the slot is an RGBA8 / BGRA8 / RGB10A2 image of the output size; every other case keeps the old kernels. Two Full-path slot-format cases join the input-SRV test (RGBA8 preset A, RGB10A2 preset B, odd widths).
…tself, dropping the merge dispatch (Preset A 2x -10 us; exact)

fg_full_blend_merge stores the ten-channel net2 input element (the two block means, the hole flag and the float16 of t) next to the three mean images it already writes, with the bits fg_net2_merge_pixels builds from them, so the executor skips that dispatch and its barrier in both net2 paths. The Full blend op now carries t. Used only when the kernel is present and outputs are not kept for readback.
…rectComposition entry points load at run time

fg_full_blend / fg_full_blend_merge: the driver's packed float16 conversion does not quiet a NaN the way fg_f2h does,
so a lane holding a NaN now converts through fg_pack_h2 (a rare, branch-guarded path); the Full-path input-SRV cases
(131-wide frames) match the 86105a8 kernels bit for bit again. Preset A 2x costs about +20 us against the unfixed kernel.

Presenter: DCompositionGetFrameId / GetStatistics / GetTargetStatistics / CreateSurfaceHandle (bound by ordinal through
dcomp.lib, which fails to load the module on Windows Server 2022), CreateDevice3 and CreatePresentationFactory are
resolved with GetProcAddress on first use; a missing export is an ordinary failure. dcomp.lib is no longer linked.
…xposure is not 1 (-0.11 ms at pi = 2, byte-identical)

On the staged native D3D12 route with a pre-exposure other than 1, the post_tf kernels (post_tf_f32_p12_diet_vsit,
post_tf4_dl_*, pmo/post_tf_*_mo) now apply the scale_rgb multiply in their own store (native_scale's values, including the
exact repair of a flushed tiny product), so the separate scale_rgb launch is gone. pi = 1, raw / direct / Model L routes and
the interop output copy are untouched. WG_SCALE_FOLD=0 (runtime option scale_fold=0) brings the launch back.

Windows AMD DX12 (RX 9070 XT, 1706x960 -> 2560x1440, 8 interleaved ABBA rounds, medians): pi = 2.0 frame span 2333 -> 2222 us
(-111 us), kernel profile sum 2318 -> 2202 us (scale_rgb 128 -> 0 us, post_tf +10 us); pi = 1.0 unchanged (span -2 us,
profile sum -2.5 us; post_tf keeps 85 VGPRs, 30336 B LDS). Output, history and every named buffer are byte-identical to
the unfolded sequence and to v0.6.5 for pi in 1, 2, 0.7, 1e-3, 1e4, 1e38 and a mixed-pi stream, with +-0, denormal, huge,
Inf and NaN colour pixels, on the post_tf, post_tf4, native-AA and motion-at-output-resolution routes.
…multi-frame batching, hoisted per-index work, split shared queue work (all exact, each with an off switch)

Phase 0: WRONGGPU_FG_KPROF=1 / FgD3d12ExecutorDesc::kernel_profile times every launch (kernel, workgroups,
ordinal), including net1's raw dispatches; TakeTimings also reports the wall-clock span and the busy time of
every queue on one clock. test_fg_d3d12_e2e --bench takes --gen 1..5 (2x..6x, really recorded), --kprof and
--batch / --hoist / --dualq 0|1 for paired runs.

Phase 1: the per-index images live in scratch banks (one per generated index). RecordGeneratedBatch records
layer k of every index back to back, so the barriers sit only between dependent layers (WG_FG_BATCH=0 off;
the session batches consecutive generated indices when the executor asks for it). The per-index MA / MB fills and
intermediate-time scatters of every index run on a second compute queue beside net1 (WG_FG_HOIST=0 off). The
downsample runs beside the motion / p2c chain on the game queue (WG_FG_DUALQ=0 off). The kernels and their
arguments are unchanged; only where and when independent work is recorded differs.
…l, branchless Q8, packed FP16 body, WG_RR_W5=0x1f)

Fast mode only (VG_OUT alternatives); exact and accurate modes compile and
dispatch the exact same 172 wave-4c kernels unchanged (WG_RR_W5 effective
mask is 0 outside MODE_FAST).

- head.fast.rx.f.w64 (RR_HFAST_ALU=1): replaces 13 random LUT gathers with
  bounded FP32 ALU transcendentals (deriving head.k_s2 from head.rho when
  missing in older packed models), removes slow-path Q8 / wave votes, skips
  dead CANDW store & atomic when scratch is present, keeps Cnet history exact.
  RGA gfx1201: inst 4302->3126 (-27.3%), vmem 114->101, 0 spills.
- stagef.{IN0,D0-F,E1,D1-F,D1-R,E2,D2-F,D2-R}.w64 (RR_Q8_FAST=1 + L01_B16R,
  plus RR_FOLD_B32=1 on IN0): branchless clamped Q8 + packed half2 body
  elementwise/attention, keeping matrix chains in FP32.
  RGA gfx1201: inst -39% to -67% across all 8 stages, VGPR -2 to -53 (E2
  180->127, D2-R 173->124), 0 spills across all 9 wave-5 kernels.
- WG_RR_W5 creation env mask (hex, default 0x1f; 0 = wave-4c frame for A/B).
…n comments, prune Wave 3/4 dead variants

Fixes two RADV/vkd3d-proton/ACO bit-exactness divergences in the hybrid Swin blocks (l_swin_block_c32_enc_lin_hyb and siblings) while keeping VMEM/LUT latency hiding intact:
- hyb_block.hlsli (hyb_softmax_pre): restore compiler-proof FP32 hyb_softmax_e8(hyb_round16(s)) instead of FP16 mad(half2) (which splits under vkd3d-proton FMad NoContraction) and FP16 score scaling/clamping, keeping the HybSmaxPre / hyb_softmax_fin split to hide hyb_rcp16 LUT latency behind Wv.
- swin_block.hlsl (norm2 b2 add, plain hybrid and SW_Q7_CHUNK): restore FP32 add + AGS RN16 (hyb_add16 / hyb_rn16x8) instead of fptrunc + fadd half.
- Clean stale Matrix || Vector overlap comments across swin_block.hlsl, fused_swin.hlsl, and l_ops_project.hlsl (RDNA 4 has 0% WMMA+VALU overlap; the gain is VMEM/LUT latency hiding).
- Prune regressive Wave 3 levers (WG_L_W3, _hyb_w3, _hyb_w3p, _hyb_gp, l_ops_project_w64.hlsl, SW_DIRECT_W, HYB_GELU_POLY) and neutral/regressive Wave 4 variants (ENC_W4, LP_W4_MOT, LP_W4_LDS2, LP_W4_H2), making the winning LP_HSEQ=0 burst the default in w64_lc12/l_post_tf_p12[_pf].
…, with the decoder skip); l_mode=hybrid stays the default

l_mode=hybrid|fast (runtime option, or env WG_L_MODE; the option wins; unset = hybrid). Fast, native D3D12 only, runs Model L
on Model M's WMMA / FP8 _nc kernels with Model M's fusions (pm, xe, mb, xo, rv) and Model L's (ll, le, lc), on Model L's own
values (the packers without the hybrid values), the C1/C2 reconstruction and the fused l_post_tf_p12[_pf] as the hybrid
route's. The decoder block takes Model L's skip S = the encoder block's map l_x3:
  l_swin_block_c32_dec_coef12_add_nc / l_swin_block_c32_dec_add_nc (clean/dx12/kernels/l_swin_fast.hlsl: SW_ADD 1, SW_SRC 2,
  WG_LD_A16 on, 96 / 95 VGPRs, no spills; swin_block.hlsl only relaxes its #error for this one combination, so every other
  kernel's preprocessed input is unchanged).
Hybrid is untouched (same kernels, same launches); warm_up leaves each mode's other kernels out (Device::warm_up_skip).
Refusals by name: wrong value, fast off D3D12, fast with WG_L_FORM, a missing kernel, weights that need the clamped block, no
bmegahg bottleneck build. Tests: clean/l/runtime/tests/test_l_runtime_fast_mode.py.
…dy speedup (WG_RR_W5=0x7f)

Fast mode only (all 13 kernels in VG_OUT alternatives); exact and accurate
modes keep 172/172 wave-4c kernels 100% bit-identical (0 removed, 0 changed;
w5_effective() returns 0 outside MODE_FAST).

Root-cause fixes for wave-5 (b416f30) body bugs/regressions:
- Removed broken L01_B16R packed-f16 body path from rr_block_{c32,c64_w64,
  wide_w64}.hlsl, rr_fast.hlsli, and gpu/stage.py (caused 4-12% FP8 RMS error
  and +47/+66 us regressions via RTZ FP16 + disabled RR_B32/RR_WIL).
- Fixed wave-5 E2.merged non-finite bug (~10% entries) in rr_block_wide_w64.hlsl
  and rr_block_c64_w64.hlsl: under RR_Q8_FAST=1 (no Q8 wave vote), LLVM hoisted
  if (cin) (s_and_saveexec_b64) above cross-lane merge v_wmma instructions
  (NAR=48). Added convergent WaveActiveAnyTrue anti-sink guard before if (cin),
  reducing narrow-EXEC WMMAs to NAR=0 on all stagef.* kernels.

Wave-5b fast-only levers (WG_RR_W5 hex mask, default 0x7f; 0 = wave-4c frame):
- Bit 0 (0x01) head.fast.rx.f.w64 (RR_HFAST_ALU=2): per-head Q8 + native f16 +
  single-mul rr_od255 on top of verified wave-5 ALU head (VGPR 91->84, INST
  4302->3121 [-27.5%], VMEM 115->101, 0 spills, NAR=0; exact Cnet history).
- Bit 1 (0x02) output.fast.w5 (OFX_W5_ALU=1 on output.fast.f0 base): native
  f16, FMA bilinear, 16-tap half exp2, 3-cmp max for OF_REPROJ_MAX=1, folded
  Cf/Df, simplified of_code10 (0 ULP), skips output.fallback.f + UAV barrier
  when CPU tile-fit check holds (VGPR 79->74, INST 2155->1640 [-23.9%], 0 spills).
- Bit 2 (0x04) resolve.fast2.w5 / resolve.fast3.w5 (RFX_W5_ALU=1): f32 1-Newton
  uniforms (0 FP64), uint2 half4 taps, branchless bilinear, FP16 3x3 layer clamp
  before U.E (bit-exact), direct rf_gout store, skips resolve.fixup when RF_SPEC
  2/3 & tile-fit preconditions hold (fast2: VGPR 80->70, INST 4635->2562 [-44.7%],
  VMEM 91->68; fast3: VGPR 43->43, INST 2477->1324 [-46.5%], VMEM 62->43).
- Bit 3 (0x08) input.features.w5 (RR_IN_W5_ALU=1, wave64): eliminates all 5120 B
  LDS (5120->0 B, DS 28->10), vectorized tx4/tx3/tx2 fetches, RR_IN_DLANE=1,
  RR_IN_MDD=1, folded history decode & FMA bmix (VGPR 59, SGPR 73->51, INST
  3763->3307 [-12.1%], 0 spills).
- Bits 4..6 (0x10 L2, 0x20 L0, 0x40 L1) stagef.{E2,D2-F,D2-R,IN0,D0-F,E1,D1-F,
  D1-R}.w64: pure f32 RR_B32=1 + branchless clamped RR_Q8_FAST=1 (0% RMS error
  for finite values in [-448, +448], INST -47% to -71%, E2/D2 VGPR 180/169/173 ->
  136/139/136, IN0 VGPR 92->88, 0 spills, NAR=0 across all 8 stages).
…and the encoder block's linears without the hybrid's bit-exactness

l_mode=fast launches a "<kernel>_fast" twin in place of a base kernel when the build has one (same arguments; the base kernels,
the hybrid twins and everything l_mode=hybrid runs are untouched, a build without a twin runs the base kernel):

- w64_lc12/l_post_tf_p12[_pf]_fast (new l_post_tf_fast.hlsl): no driver intrinsic channel and no opaque-zero guards; native FP16
  packs with the round-to-nearest bias folded into the multiplier; the gather weight is one v_exp_f16 and the total weight is
  summed in FP16 from the weights of the nine features; no FP16 code table (1 KB LDS, a barrier, six lookups per texel); Dec as
  exp2(q k) - 1 for every lane; the filter ring in FP16 pairs (LDS 26752 -> 23040 bytes). Options in pitch_bytes: the weaker
  history candidate as a bilinear (bit 0), and not read twice when its motion equals the first's (bit 1).
- l_project_gather_fast / l_dec_project_fast: the K blocks accumulate in FP32 and round once, in the FP8 pack.
- l_swin_block_c32_enc_lin_nc_fast: the linears' results stay FP32 (TT_LINF32).

RGA (gfx1201), VALU instructions: post 2096 -> 1703 (pf 2356 -> 1705), project_gather 537 -> 281, dec_project 675 -> 419,
enc_lin 997 -> 893; no spills, VGPRs within each kernel's bound.

runtime: l_fast_alt maps each base kernel to its twin; warm-up leaves out the twins for l_mode=hybrid and, for l_mode=fast, the
hybrid twins, the replaced base kernels and the twins of levers that are off; a developer build reads WG_L_FAST_MASK (an A/B of
each lever; no such string in a release build, check_no_dev_diagnostics lists it). Tests: CPU accuracy bounds
(clean/l/tests/test_l_fast_numerics.py), the twins' dispatch and the mask (test_l_runtime_fast_mode.py), kernel_sets.json.
…put, SRV-only input)

Adds 6 independent Fast-mode-only Wave 5c levers behind WG_RR_W5 (default 0xfff,
bits 0..11; VG_OUT alternatives only so Exact, Accurate, and WG_RR_W5=0 remain
100% unchanged and all 172 Wave 4c DXILs stay SHA-256 bit-identical):

- Bit 3 (0x008) input.features.w5c: drops Wave 5b input.features.w5 (which had an
  in_nan0(float3) truncation bug and regressed latency) and restores rr_in_math.hlsli
  and rr_input.hlsl cleanly, replacing bit 3 with wave64 input.features.lite +
  RR_IN_SRV_ONLY=1 (CPU-guarded direct SRV reads, bit-identical to input.features.lite,
  57 VGPR, 5120 B LDS, -17.4% INST, -65.1% VLD, -41.4% IMG).
- Bit 7 (0x080) Body L3 stagef.{E3, D3-F, D3-R} & Bit 8 (0x100) Body L4/L5
  stagef.{E4, E5, D4-F, D4-R}: pure-f32 RR_B32=1 + branchless clamped RR_Q8_FAST=1
  wave32 kernels with convergent merge guard in rr_block_wide.hlsl (NAR=0), plus
  RR_B32G4=1 / RR_PRE=14 at L4/L5 eliminating all scratch/LDS spills (D4-F/D4-R
  LDS 65536->26624 B, SCR 160/112->0 B, VGPR 192->153..160, INST -50%..-60%).
- Bit 9 (0x200) pool.main.w5: hardware f32 mad/mul with exact tables (0 FP64,
  0 CVT, -69.3% INST, bit-identical to quarter_pool).
- Bit 10 (0x400) resolve.fast2.w5c / resolve.fast3.w5c: RF_QN=28 / RF_QO=896 with
  wave-uniform s1==3 skip; fast2 adds CPU-guarded RFX_RP=16 (RF_RS=1, 12.8 KB LDS
  -> 5 WGs/CU), RFX_LLDS=1 (layer bilinear taps from LDS, -33.8% VLD), RFX_QLD=1,
  32-bit MV load, and rolled 3x3 clamp (67 VGPR).
- Bit 11 (0x800) output.fast.w5c: OFX_W5_ALU=1 + OFX_W5C=1 (rolled 5-tap of_reproj
  and on-demand oxk/oxxk in 16-tap loop) + OFX_PH1W=1 + OFX_LD3=1, cutting VGPR
  74->55 (+50% occupancy), LDS 10272->7200 B, VLD 41->21, BAR 4->2.

Verified CPU-only on gfx1201 RGA (all 24 Wave 5b/5c kernels SCR=0, VSP=0, SSP=0,
scratch_ops=0, NAR=0), 172/172 Wave 4c DXIL SHA-256 bit-identical, runtime unit
tests, modes_self_check, and CPU numerical equivalence checks.
…centred 3 x 3 post gather, two windows per wave in the width-32 blocks, quick GELU, c64 twins

New fast-mode kernels, each launched in place of a base kernel with the same arguments (runtime kLFastAlts / the "<kernel>_fast"
twins; every existing DXIL is byte-identical, swin_block.hlsl is not touched, l_mode=hybrid launches none of them):

- w64_lc12/l_post_tf_p12[_pf]_fast3 (l_post_tf_fast.hlsl LP_WIN3, lever 256 with lever 1): the gather over the 3 x 3 render
  texels centred on each D pixel (every tap within 1.5 render pixels; each row of a pair with its own centred rows, the row
  n0 + 2 read under a wave-uniform branch) instead of the 4 x 4 window: 18 taps per row pair instead of 32. Staging cap 448
  texels (LDS 23040 -> 21504 bytes); a frame whose step footprint does not fit (l_tf3_supported) runs the 4 x 4 twin.
- l_swin_block_c32_enc_lin_w2[t]_fast (lever 512) and l_swin_block_c32_dec_coef12_add_w2[t]_fast (lever 1024), new
  l_swin_c32_fast.hlsl: two windows per wave in 128-lane workgroups (swin_c64w2.hlsl's launch shape: weight fragments, biases,
  norm vectors and the linears' weights loaded once for both windows, a barrier waits for 4 waves); the softmax without the
  maximum (the soft cap bounds the exponents to +-11); the decoder's coefficient store one pixel per lane in FP32 (the hh = 1
  lanes take the second window's channels by v_permlanex16; no FP16 rounding of y2, tanh as 1 - 2 / (2^(2 t log2 e) + 1)).
  GELU: quick GELU x / (1 + 2^(-2.53 x)) in "_w2_fast" (lever 4096; no table load; max error 0.016, RMS 0.009 against the
  model's GELU), the arena table (the model's GELU bytes) in "_w2t_fast".
- swin_block_c64_nc_fast / swin_block_c64_add_ex_nc_fast (lever 8, new l_swin_c64_fast.hlsl): the same body at C = 64.

RGA (gfx1201), issue slots per window (without s_delay_alu / s_code_end), VGPRs, no spills: decoder block 1568 -> 978 (w2t 1044),
149 / 172 VGPRs; encoder block 1368 (enc_lin_nc_fast) -> 1090 (w2t 1147), 139 / 164 VGPRs; c64 1780 -> 1644, c64_add_ex
2118 -> 1995 (192 VGPRs, the base kernels' tier); the post 2683 -> 2520 static (96 VGPRs, 2 workgroups per CU as before).
Quick GELU trades table loads for the exponential unit: w2 320 trans / 49 buffer loads per wave, w2t 64 / 177.

runtime: WG_L_FAST_MASK default 127 -> 6015 (every lever but 128 and 2048, the latter reserved for a bottleneck twin);
warm-up leaves out the fast kernels the mask does not select (the 3 x 3 post's 4 x 4 twin stays warm); build_dx12.py
fast_base names the kernel each fast-mode kernel replaces (is_model_l, the trace's argument kinds). Tests: quick GELU, the
softmax without the maximum, the fast coefficient store and the 3 x 3 gather by kernel width (test_l_fast_numerics.py: 3 x 3
vs 4 x 4 52.9 dB on texel noise at sigma 0.5 render pixel, 30.6 dB at sigma 1: lever 256 is the first one to A/B on the
GPU), the selection, the warm-up and the footprint fallback (test_l_runtime_fast_mode.py), kernel_sets.json.
…0 opt-in), GPU-verified results

Paired GPU timing on RX 9070 XT (D3D12), 1440p Quality, 6 ABBA rounds against the wave-4c build:
plain 6.369 -> 5.760 ms, layer 6.600 -> 5.963 ms.

- bit 8 (stagef.{E4,E5,D4-F,D4-R}, 0x100) is not byte-identical to wave 4c (34.7..38.5 dB tone-mapped PSNR on
  a small scene, 37 dB on 1440p Q reset frames against accurate): opt-in.
- bit 10 (resolve.fast2/3.w5c, 0x400) is clean but timing-neutral inside the default (+/-2 us paired): opt-in.
- exact, accurate and WG_RR_W5=0 stay byte-identical to wave 4c; the default has 0 NaN / Inf in every output
  and history buffer (also at 1440p DLAA).
- README: per-bit timing, per-stage profile, 5-cell scaling table and quality metrics.
# Conflicts:
#	clean/k/runtime/k_smx_selfcheck.h
…Upscaler card, launcher model/mode UI, RR stability

Registry (clean/wgshared): slots 12-14 sr_m_mode / sr_l_mode / sr_k_mode (fast | exact, default fast, live,
next-frame); rr_mode default fast (values unchanged). Generated outputs regenerated; generator tests updated.
wg_sr_modes.h: the modes' state keys (m_mode / l_mode / k_mode) and runtime options. The shared block gains owned-slot
writes (the card owns the SR mode slots, as the RR panel owns rr_mode) and an open-existing-only mode.
wg_host_menu_abi.h moves to clean/wgshared (the RR plugin's copy includes it).

SR front end: each create appends the model's mode (m_mode=fast|exact, l_mode=fast|hybrid, k_mode=fast|exact) unless
runtime_options / WG_RUNTIME_OPTIONS name it; resolved from the card's live slot > environment > the game's
settings.ini > wronggpu.ini > fast. A live change from the card recreates the upscaler at the next frame as an output
resize does (context kept, old upscaler kept until destroy, switching back reuses it; at most 2 creates per context).
Model K runtime: k_mode=fast takes the k_approx forms the create supports (never a refusal), k_mode=exact the
standard path; a later k_approx decides; neither given stays exact.

WrongGPU.asi: OptiPluginInit registers a "WrongGPU Upscaler" card (Custom tab, tab fallback) with the running model
and Fast / Exact per model; a change writes the owned slot and wronggpu-setup\settings.ini under the state lock.

Launcher: m_mode / k_mode / l_mode profile settings (state folder only, no outside edits), FoldSrFromGame (model
choice record from the game, settings.ini modes) in GameProfile and installs, Model and Mode selectors on the game
page, model + mode naming on the game page and Library, Model K / Model L data rows with conversion in Settings,
HIP row wording.

RR plugin: SEH + C++ exception isolation of the game-interface route with open-bracket cleanup and pass-through after
a fault; atomic route version / host next pointers and a registration window that passes calls straight on; checked
PE reads (PeView / Reader / ModuleRef) for import, delay-import and importer walks; unused frame-token map removed;
2.x interfaces (2.7 or later) accepted by an export probe, slSetTagForFrame deciding frame-scoped tags. Panel
tooltips and fallbacks follow the fast default.

Tests: wgshared generator, fsr front end (modes, live switch, explicit options), test_asi_card, launcher-core
(modes, persistence, fold), RR hook runs for 2.10 / 2.15 / 2.6 / a missing export and fault builds, K option text.
…c GELU in the width-32 and width-64 twins, width-96 twins; 3 x 3 post off by default

RX 9070 XT (2B-3, 8d0e32f): the 3 x 3 post gather (lever 256) failed the HDR gate (38.7 dB / SSIM 0.955 against 53.2 dB /
0.998 with the 4 x 4 gather); quick GELU x / (1 + 2^(-2.53 x)) was 44 / 56 us slower than the table form in the width-32
blocks and 7 / 18 us slower in the c64 twins (its exponential and reciprocal run on the quarter-rate transcendental unit).
Best clean mask there: 1655, 3.266 ms.

- GELU (l_swin_c32_fast.hlsl LF_GELU 1): 2 GELU(x) = x + |x| min(P(|x|), 1), P a cubic fitted (weighted minimax) to the
  model's GELU: |x| by an AND with an opaque mask, three v_fmaak, a v_min, a v_fmac, all of them VOPD-pairable (RGA: the
  driver pairs most of them), no exponential, no table load. The W2 products accumulate onto twice the residual (the
  accumulator doubled with b2 after norm2, halved at the output / coefficient store: exact power-of-two scalings,
  FP8(2 g) = 2 FP8(g) for every normal code), so the halving is no operation per value. Max error 0.0020, RMS 0.0014 against
  the model's GELU (quick GELU: 0.016 / 0.009), 84.8 % of the FP8 codes unchanged. The hidden values' FP8 range without a
  clamp is |h| < 224 (the table form's: 448).
  Kernels: l_swin_block_c32_enc_lin_w2p_fast / l_swin_block_c32_dec_coef12_add_w2p_fast (lever 512 / 1024 with 4096,
  replacing the quick-GELU "_w2_fast" ones; without 4096 the table twins "_w2t_fast"), swin_block_c64_nc_fast /
  swin_block_c64_add_ex_nc_fast (lever 8).
- Width-96 twins (lever 8192, new l_swin_c96_fast.hlsl): the same body in the base kernels' launch shape (256 lanes, one
  window per wave), the clamped-cubic GELU (no groupshared table: LDS 26 624 / 28 672 -> 24 576 bytes) and the softmax
  without the maximum: swin_block_c96_add_ex_nc_fast (dec2, the fused expand) and swin_block_c96_pm_rev_nc_fast (enc2 with
  enc1's patch merge as its prologue: fused_swin.hlsl's SW_PM code, FZ_PMT 1, its aux / aux2 arguments appended to
  swin_block.hlsl's argument block by WG_ARGS_END).
- No bottleneck twin (lever 2048 stays reserved; the persistent bmegahg kernel is generated and measured sensitive to its
  compiled form), no post or encoder change (a packed FP16 feature sum in the post gather compiled to the same ISA: the
  driver scalarizes it).

RGA (gfx1201), per wave, loops expanded (base c96: head loop x4 / x2, MLP loop x2), no spills (scratch 0, VGPR / SGPR
spills 0); slots without s_delay_alu / s_wait / s_nop:
  enc0 c32   w2t 164 VGPRs, 2027 slots, 1514 VALU, 41 trans, 192 buffer loads -> w2p 139, 2080, 1696, 41, 64
  dec0 c32   w2t 172, 1846, 1391, 65, 177 -> w2p 150, 1880, 1554, 65, 49
  enc1 c64   base 191, 3236, 2326, 169, 286 -> fast 192, 3244, 2531, 41, 94
  dec1 c64   base 192, 3858, 2774, 169, 324 -> fast 192, 3916, 3026, 41, 132
  enc2 c96   base 173 / 26 624 B, 4480, 2865, 39, 216, 451 ds -> fast 186 / 24 576 B, 3264, 2126, 39, 160, 300 ds
  dec2 c96   base 192 / 28 672 B, 4524, 2973, 39, 231, 417 ds -> fast 181 / 24 576 B, 3404, 2294, 39, 175, 257 ds
The width-32 / width-64 twins trade the table loads (and in c64 128 transcendentals) for 1 to 3 % more issue slots; which
one is faster is the GPU A/B of lever 4096 (w2p against w2t) and lever 8. The width-96 twins have 25 to 27 % fewer slots.

runtime: WG_L_FAST_MASK default 6015 -> 13951 (every lever but 128, 256 and 2048), kLFastAll 16383; l_fast_bit: c96 ->
8192, bneck -> 2048, the other swin_block_* -> 8. build_dx12.py fast_base / runtime_frame_trace: "_w2p_fast".
Every other DXIL of the build is byte-identical (135 of 139 entries; changed: the two c64 twins; replaced: the two
"_w2_fast"); hyb_isa_scan clean on the 26 hybrid kernels. Tests: PolyGelu (constants, error bounds, shape, the doubled
accumulator, FP8 codes) in test_l_fast_numerics.py, the new default and lever 8192 in test_l_runtime_fast_mode.py,
kernel_sets.json, vgpr_limits.json.
…plicate history/encoder reads skipped, c96 knob set

Four changes to the hybrid (l_mode=hybrid) route, each the same bytes by construction (GPU byte check and ABBA timing
pending):
- l_swin_block_c32_dec_coef12_hyb (SW_COEF_ROWS 1, swin_block.hlsl; fused_swin.hlsl regenerated): the coefficient
  epilogue reads channels 0..15 only, so the W2 chain runs one 16-row tile instead of two. Rows 8..15 of tile 0
  (channels 16..23) are replaced by tile 1's rows 0..7 (channels 8..15) through a per-lane LDS fragment offset (24
  slots for the A lanes t >= 8; no weight repack); the chain start RN16(b2 + z) of channels 8..15 moves to the hh = 1
  lane and the epilogue takes them back from lane ^ 16. Every output element is the same chain of the same products.
  RGA gfx1201: 64 -> 56 WMMAs per block (W2 16 -> 8), 84 / 96 VGPRs, no spills; hyb_isa_scan 0 fused squares,
  0 of 96 FP8 sources not FP16; its scan mutant still fails both rules.
- l_post_core.hlsli (w64_lc12/l_post_tf_p12[_pf]): the second history candidate at the first one's motion bits reads
  the same position; its values are copied instead of a second 12-tap history read. RGA 89 -> 93 and 86 -> 90 VGPRs
  (bound 96, LDS-capped at 2 workgroups per CU either way), no spills.
- encoder.hlsl, q20 forms only (lev/input_encoder_q20[_pf], _direct_q20): near / far at center's position bits reuse
  center's history values; the reads run only when a lane of the wave needs them. RGA: 104 -> 82 VGPRs (q20),
  106 -> 85 (q20_pf). Model M's encoders unchanged.
- swin_block_c96_hyb / swin_block_c96_add_ex_hyb: the knob set their scan mutants and q7c twins already run
  (SW_MLP_PAIRS 1, SW_COMMIT_EARLY 1, SW_NORM2_EARLY 1; scheduling only). RGA 190 -> 191 and 158 -> 158 VGPRs;
  hyb_isa_scan 0 / 0.
…r filter taps, colour taps skipped by halo-only waves (byte-identical by construction, RGA)

k_out_pixel_c (all forms): the interior 5 x 5 p_L window as one 12-byte load per row (buffer_load_b96) instead of
25 16-bit loads, and, when a whole wave has row-major taps on the fast path, each line's three ctapT values from one
8-byte load (buffer_load_b64) instead of three 16-bit loads. The same bytes go into the same values; no arithmetic
changes. RGA gfx1201: VMEM loads in the listing 110 -> 94, hot path 37 -> 9 for these taps, 80 VGPRs, no spills.

k_in_tiled_color (all forms): a wave whose lanes own no render pixel in a pass of the tile loop skips ki_color_tap
(the test is wave-uniform, so the conversions stay outside divergent branches); stored taps unchanged.

GPU byte-identity and timing check still to run.
# Conflicts:
#	clean/dx12/kernel_sets.json
#	clean/runtime/runtime.cpp
#	clean/tests/runtime_frame_trace.cpp
… block's coefficient store, 8 KB width-32 staging; post options 16384 / 32768 (off)

- l_swin_c32_fast.hlsl: the coefficient store reads channels 0..12 only, so the decoder block's W2 runs one output
  tile (LF_W2_ONE: tile 0 remapped to channels 0..15 by a lane exchange of tile 1's rows; the same products and the
  same accumulation order per stored channel): 128 -> 112 WMMAs, _w2t_fast 188 -> 165 VGPRs. The width-32 twins
  stage 2 x 4 KB of MLP weights (SW_HPU=4: 8 KB of LDS instead of 16 KB).
- l_post_tf_fast.hlsl: history / A8 loads with their 8-byte alignment stated; option bit 3 (lever 16384) gathers the
  4 x 4 window without its four corner taps, option bit 4 (lever 32768) blends two history candidates in the encoded
  domain and decodes once. Both off by default: 16384 measured 43.2 dB / SSIM 0.982 HDR 1440p Q and 40.5 dB 640 x 360
  HDR against the hybrid route (below the gate); 32768 showed no gain.
- runtime.cpp: the default selection is 9847 (levers 8 and 4096 off: neutral and +20 us in the A/B); kLFastAll 65535.
- Tests and SPEED.md follow the new default.

RX 9070 XT, 1440p Q, 6-round ABBA (median of rounds): hybrid 4.3805 / 4.4146 / 4.4160 ms, l_mode=fast (release)
3.2456 / 3.2421 / 3.2419 ms at pi 1.0 / 1.25 / 2.0. l_mode unset and l_mode=hybrid: 0 of 232 buffers differ from
8c07199 (1440p Q HDR / LDR, 640 x 360 HDR), no NaN / Inf. l_mode=fast against hybrid: tone-mapped PSNR >= 49.9 dB
steady, SSIM >= 0.9976, no NaN / Inf in the output or the history; the release DLL is bit-identical to the developer
build at mask 9847.
… 1440p Q vs 5c88a67, byte-identical)

At 1440p Quality d1 has 1,025 windows: as 513 two-window workgroups (k_stage2_d1) they fill the 256 slots of four
workgroups per CU for two rounds and one more (a single workgroup). k_stage_d1, the one-window form HIP's k_block.co
already has (K_STAGES), runs the same per-window maths at 1,025 workgroups: 100-105 us instead of 134 us (WG_D3D12_PROFILE).
Measured, the e0 / e1 one-window forms are slower (139 vs 120 us, 81 vs 78 us), so they stay two-window. Applies to every
backend (stage_kernel_base); d0 is unchanged.

- k_stage_d1__rodd: the round-to-odd form of the self-check / mix-probe fallback; isa_checks.json covers both forms
  (64 / 0 mix folds), kernel_sets.json updated.
- softmax self-check: the d1 case is k_stage_d1 (smx_selfcheck_digest.py BASE); k_smx_selfcheck.h regenerated on HIP
  (gen_k_smx_selfcheck.py): the d1 hash is unchanged, only its name.
- 0/6 diffs, 0 non-finite against 5c88a67: 1440p Q HDR pi 1.0 / 1.25 / 2.0, LDR pi 1.0, 645x363 -> 967x545 HDR.
- 6-round ABBA against 5c88a67 (RX 9070 XT): pi 1.0 1.4623 -> 1.4430 ms, pi 1.25 1.4700 -> 1.4505, pi 2.0 1.4795 -> 1.4609.
…m-O tap forms, FP32 bias planes for d1 / e2 / d2 (-140 us at 1440p Q vs 5c88a67, byte-identical)

k_out_pixel_c (every form, __a2 included), 537 -> 448 us at 1440p Q (WG_D3D12_PROFILE, RX 9070 XT):
- HIP's non-plain best-E retry recomputed both pairs' E and ran in most waves (on the test frames 87 % of the waves
  have a sub-sample whose best E is below -12). It is now a per-sub-sample best-E tap tracked in the 12-tap loop: tap n
  replaces the best unless E[n] < best. Same result for every input, NaN included (the argument is in the source):
  without a NaN the sequential best is the last maximum, so best < -12 only when max E < -12; with a NaN the weight sum
  is NaN (the retry ran) and both forms end on tap 11; the two rules differ only at E[n] = -0, best = +0, a best that
  stays >= -0. -70 us on its own.
- The taps' E are formed tap by tap for both sub-sample pairs (each pair's sums in tap order). A wave whose lanes all
  have the same O forms the pair-independent values once (ko_line_E modes 1 / 2: one FP16 value per pair where both
  halves held the same one, du / dv shared by the pairs). A test-only build that ran every lane through the uniform form
  of its own O (both forms on every pixel) gave 0/6 diffs on all five scenarios and 64/64 in the port check.
- The 4.3 bilinear's four taps written out (the [unroll] loop with the q == 0 select stayed a rolled four-iteration
  loop of selects in the ISA, -10 us); kk = Yp / s3 in a branch (it was a select: the division ran on every pixel).
- The 5 x 5 luma window and the 12 taps' T held as FP16 pairs: 84 -> 71 VGPRs (neutral at 1440p Q).
kx/k_in_tiled_color* (k_frame.hlsli kio_encode, near branch): 1 / (Y + 1) as kio_rcp, the v_rcp_f32 + Newton step of
  ki_rcp / ko_rcp_refined for x in [2^-32, 2^32], wg_div elsewhere (= wg_div on every input): 217 -> 214 us.
k_stage_d1 / k_stage_e2 / k_stage_d2 (and their __rodd forms): KB_BIAS32 + KB_BASE_FORM, the runtime uploads their
  FP32 bias planes (narrow_bias32_kernel): d1 99 -> 90 us, e2 / d2 within noise.
Runtime: d3d12_kernels() names k_stage_d1, not k_stage2_d1 (prepared at create, checked against the payload), and the
  bias-plane ports required at create are the launched ones (test_hybrid_refuses_missing_compact_head_port failed at
  3a35b73 on k_stage2_d1; passes, run alone).

- k_smx_selfcheck.h regenerated on HIP (gen_k_smx_selfcheck.py): the 133 reference hashes are unchanged, only
  kSourceDigest. k_port_check.py: the three bias-plane kernels. test_k_alpha.py: the written-out bilinear.
- 0/6 diffs, 0 non-finite against 5c88a67: 1440p Q HDR pi 1.0 / 1.25 / 2.0, LDR pi 1.0, 645x363 -> 967x545 HDR.
- k_port_check.py (HIP against D3D12, special values): narrow 132/132, output 32/32, direct k_out / k_expo 28/28. The
  input family (kx/k_in_tiled) fails 32/32 the same way with 3a35b73's source: a harness issue, not traced here.
- test_k_runtime_d3d12 (D3D12 against HIP, frame by frame): 37/38 in one run, the 38th (the refusal above, which
  reads WG_DX12_KERNELS at library load) passes run alone. Full build: ISA checks pass, kernel sets unchanged.
- 6-round ABBA against 5c88a67 (RX 9070 XT): pi 1.0 1.4681 -> 1.3277 ms, pi 1.25 1.4735 -> 1.3348, pi 2.0
  1.4791 -> 1.3400; against 3a35b73 at pi 1.0: 1.4594 -> 1.3393.
…0.7.0)

Payload: make_payload.py --fg <dir> embeds plugins\WrongGPU-FG.asi and its
kernels as fg-dxil\<name>.dxil (kFgPayload, resource ids 2001+). It takes the
release stage layout (fg-dxil\ at the root, or under wronggpu-setup\ or
plugins\wronggpu-setup\), reads past the kernel build's manifest.json, and
refuses OptiScaler, NVIDIA names, developer runtimes, any other file, one
kernel name twice, a folder without the plugin or without kernels. CMake:
WRONGGPU_FG_DIR; a WRONGGPU_TESTING build without it gets generated stand-ins
(tests/make_mock_fg.py).

Install: a game with a frame generation library (nvngx_dlssg.dll) on the
OptiScaler setup gets WrongGPU-FG.asi beside WrongGPU's plugin and the kernels
in that folder's wronggpu-setup\fg-dxil (where the plugin reads them), each a
record entry: hashed before anything changes, backed up, rolled back, removed
by the uninstall and the restorer. Leftovers know the plugin's hash; a changed
plugin in a newer build counts as an update (PayloadDiffers).

Coexistence: WrongGPU-FG.asi is WrongGPU's own plugin, recorded or not: never
listed by ForeignPlugins, so it never keeps WrongGPU's Ray Reconstruction out
or gets moved aside.

Launcher: fg, fg_preset, fg_multiplier, fg_presenter are Basic settings. The
game page has a Frame Generation section under Ray Reconstruction: Convert
while its data is missing, Set up for an older install, then Use WrongGPU,
Multiplier (2x-6x), Preset (A-C) and Presenter (Auto, DXGI Tearing,
DXGI VSync, HWFQ). Settings > Model and runtime has a Frame generation data
row (Convert, Choose a DLSS file). Values changed in the game's settings.ini
are folded back into the profile (fg=off only when the data is on this PC).
With fg=on, OptiScaler's own [FrameGen] keys set to anything but its defaults
are reported, never changed. status JSON: fg_uses, fg_installed.

Tests: fg-files (ForeignPlugins, install paths, record, library check,
OptiScaler conflict, fold), fg-payload (make_payload.py --fg), fg-install
(install, set, outside edits, page and Settings dump, repair, uninstall,
restorer, RR beside FG, a hand-placed plugin).
…ease gate open

WrongGPU-FG.asi as an OptiScaler plugin:
- OptiPluginInit: the "WrongGPU Frame Generation" card on OptiScaler's Custom tab
  (a tab of its own on a host without cards) with the live status (off / not active /
  waiting / generating Nx, preset, presenter / real frames only, reason) and, with
  fg=on, Preset A/B/C and Multiplier 2x..6x combos. A choice applies from the next
  frame (FgProxy::update_live_settings, lock-free) and is saved to
  wronggpu-setup\settings.ini (wgstate::SetSettings).
- Host routes (menu ABI v3): the transport registers its 11 interface routes with the
  host, which detours the exports themselves, and puts its import patches back, so a
  later plugin's forward to the export (WrongGPU-RR's) still reaches FG.
- fg_presenter=auto under OptiScaler takes the DXGI flip presenter (tearing when the
  chain allows it, else vsync) so OptiScaler's menu and overlay are drawn on every
  presented image; an explicit hwfq is honoured.

Session host fixes found in the live runs (Cyberpunk 2077, RX 9070 XT, 60 Hz panel):
- the real swap chain is created on a high-priority present queue of the host's own,
  so presents never wait behind the game's rendering (facade copies wait on a fence);
- the first-image budget follows the generated images that miss their display time
  (AIMD over 60-frame windows, 4 ms start, 30 ms cap; FgSession::SetFirstImageBudget);
- the display refresh caps the generated cadence (count adapted);
- game frames wait (at most 50 ms) for a presenter slot when the display shows fewer
  images than the game renders, instead of exhausting the slots;
- the start-up probe failure is logged with its HRESULT and retried at the first FG
  call; the session's teardown logs presenter and real-only statistics.

Streamline 2.x: bindings/sl2-generic.json (interface 2.4 and later, options and state
from version 1, the exe's DXGI factory creations as a fallback), taken when no title
binding matches and the game links the interface. The codec reads nothing past the
options version it is passed (UI recomposition from v5). The Cyberpunk 2077 binding is
unchanged (exactly 2.14, options v5).

Release gate: WG_FG_MODES_QUALIFIED is 1 from 0.7.0; WRONGGPU_FG_DEV_QUALIFIED now
only adds the developer diagnostics (frame dumps under WRONGGPU_FG_DUMP_DIR).

Tests: live settings, host routes, version ranges, the generic binding and codec
versions, the menu card through a stand-in host table, the closed gate through the
config; test_fg_win_presenters' default slot count expectation brought up to date.
@j0nsh1n

j0nsh1n commented Nov 26, 2026

Copy link
Copy Markdown
Contributor
Area Before After
README quality modes The per-model Fast/Exact choices are not explained. A short player section explains Exact, Hybrid, Fast and RR Accurate, with defaults and controls.
Meaning of “exact” It can be misread as “identical to DLSS.” Both texts define it against WrongGPU's own reference and distinguish exact speedups from DLSS equivalence.

For #306, these two docs-only texts address that misunderstanding and cover the Fast/Exact choices added per model in 0.7.0.
The detailed guide also covers RR stages, Model K's k_approx forms, FG presets and net2 paths, and launcher/menu settings.

  • The short section below goes into README.md (it ends with a link to the detailed page).
  • The detailed text below goes in as docs/QUALITY-MODES.md.
    No runtime or launcher behavior changes; no builds, game runs or GPU comparisons were performed.
README section (short)

Quality modes: Exact, Hybrid and Fast

In WrongGPU, “exact” never means identical to DLSS. WrongGPU uses its own arithmetic, so its output is close to DLSS's but not the same. Exact follows WrongGPU's own reference—the project's defined result for that model or stage—not NVIDIA's DLSS DLL, and it does not promise identical pixels on every graphics card.
An exact speedup or byte-identical result means that a change made WrongGPU faster without changing WrongGPU's own output by a single bit compared with before that change; it does not mean matching DLSS, another mode, or every GPU.

Mode What you get When to use it
Exact WrongGPU's reference arithmetic; the most precise and slowest choice where offered. When reference accuracy matters more than GPU time.
Hybrid Model L's Exact route: FP32 calculation chains with FP16 rounding at each step, matching WrongGPU's reference bit for bit. Select Model L → Exact; Hybrid is the route, not a separate button.
Fast Faster calculations that are checked for closeness rather than bit-exact agreement with the reference. Everyday play when speed is the priority.
RR Accurate Exact RR input, output and resolve, with faster head and body arithmetic. A middle RR choice: nearly the same picture as Exact, but faster.

Defaults: Fast is the default for Models M, K and L and for Ray Reconstruction. Frame Generation is off by default.
To switch: choose the model and Mode on the game's launcher page, then Apply; RR uses Quality, and OptiScaler's Custom tab has WrongGPU cards for in-game changes.

Detailed modes, per-model behavior and settings.

docs/QUALITY-MODES.md (detailed)

Quality modes: Exact, Hybrid and Fast

In WrongGPU, “exact” never means identical to DLSS. WrongGPU uses its own arithmetic, so its output is close to DLSS's but not the same. Exact follows WrongGPU's own reference—the project's defined result for that model or stage—not NVIDIA's DLSS DLL. It is not a promise that different graphics cards will produce identical pixels.

An exact speedup or byte-identical result in a change or release note means that WrongGPU got faster without changing WrongGPU's own output by a single bit compared with before that change. It does not mean that the output matches DLSS, another quality mode, or every GPU.

Mode What you get When to use it
Exact WrongGPU's reference arithmetic; the most precise and slowest choice where offered. When reference accuracy matters more than GPU time.
Hybrid Model L's Exact route: FP32 calculation chains with FP16 rounding at each step, matching WrongGPU's reference bit for bit. Select Model L → Exact. Hybrid is the route, not a separate button.
Fast Faster calculations checked for closeness rather than bit-exact agreement with the reference. Everyday play when speed is the priority. Fast is the default for Models M, K and L and for Ray Reconstruction.
RR Accurate Exact RR input, output and resolve, with faster head and body arithmetic. A middle RR choice: nearly the same picture as Exact, but faster.

Super-resolution models

Models M, K and L each have Fast and Exact choices in the launcher and in OptiScaler's WrongGPU Upscaler card. Fast is the default for all three.

Model Fast (default) Exact
M The fast M-form route: the quickest choice, with a picture very close to Exact. The reference calculation route, including original post-processing and pre-exposure calculations on HDR (high-dynamic-range) frames.
K Uses the supported k_approx forms for faster input and output arithmetic. Where a form cannot be used, the standard path runs instead and the runtime records a note. The standard path without those approximations.
L Reuses Model M's faster network kernels with Model L's weights while retaining Model L's own reconstruction and temporal-history handling. It is not bit-exact to the Model L reference. The Hybrid route, which matches WrongGPU's Model L reference bit for bit.

Hybrid: Model L's Exact route

Hybrid is not a separate launcher selection or a middle quality setting. It is the implementation of Model L → Exact, passed to the runtime as l_mode=hybrid.

Hybrid mixes two floating-point formats. FP32 means 32-bit floating-point arithmetic and carries the calculation chains. FP16 means 16-bit floating point; Model L rounds to it at each step. That combination reproduces WrongGPU's reference bit for bit. “Bit for bit” here is a comparison with WrongGPU's own reference, not with DLSS or another GPU.

Model L Fast uses a different set of calculations and is not bit-exact to that reference. It runs only on the native Direct3D 12 route.

Model K's k_approx forms

Model K Fast selects whichever supported approximations apply. Exact is the standard path. A later explicit k_approx runtime option can override k_mode; this is an advanced runtime control, not an additional launcher mode.

  • a1 — tiled input stage. It replaces correctly rounded logarithms, exponentials and divisions with faster hardware operations. Frames using the legacy input route keep the exact input stage: this includes a render size above 0.68 times the output size, jitter outside ±0.5, or input_tiled=0.
  • a2 — output stage. It replaces exact divisions with faster reciprocals and corrections. It requires the compact head, which is the default; the full head has no a2 form.

The available 0.6.5 release notes measured Model K at 1440p Quality on an RX 9070 XT in WrongGPU's direct-route test harness: 1.37 ms per frame with k_approx=a1,a2, versus 1.58 ms on the exact path. The output differed slightly and was rated very close to Exact on the two test sets. These are old harness figures, not a general performance promise for 0.7.0 or for every game and resolution.

Ray Reconstruction

Ray Reconstruction has Fast, Accurate and Exact choices. Fast is the default. Exact is exact with respect to WrongGPU's specification and reference, not to DLSS.

Mode Head Input features Body Output stage Resolve
Exact Exact Exact Exact arithmetic Exact Correctly rounded exp2 and reciprocal
Accurate Faster FP32 arithmetic, quality-checked Exact; history samples stay exact Faster, non-exact arithmetic Exact Same correctly rounded resolve as Exact
Fast Faster FP32 arithmetic Lite Faster, non-exact arithmetic Hardware reciprocal and faster reprojection Hardware exp2 and reciprocal

The head is the network's final stage, the body is its main sequence of network stages, and input features are the values prepared from the game's images and history. The output stage prepares the network's outputs and history; resolve combines them into the image returned to the game. Lite input uses a cheaper feature-preparation route. Reprojection reuses earlier-frame information at the corresponding position in the current frame.

In player terms:

  • Exact is the most precise and slowest.
  • Accurate keeps exact input, output and resolve while using faster head and body arithmetic. It is nearly the same picture as Exact, but faster.
  • Fast also changes input, output and resolve arithmetic. It is the quickest choice, with a little less detail.

To offer Exact in the RR quality choices, enable Settings → Model and runtime → Exact mode in the launcher. Without that allowance, an rr_mode=exact request runs Accurate.

Frame Generation

Frame Generation is off by default. Preset A is the default when you enable it. Presets A and B use the Full path and its second network, net2; preset B also enables UI recomposition. Preset C uses the light path and does not run net2.

Preset Path Net2
A (default) Full Yes
B Full, with UI recomposition Yes
C Light No

Net2 has two internal paths:

Net2 path Behavior Availability
Fast (default) A 27-launch matrix-unit path. Only the chunk sums—the additions inside groups of network calculations—differ from WrongGPU's reference; the other operations stay exact. Used by default for presets A and B.
Exact A 38-launch path that matches WrongGPU's reference bit for bit. Validation path. fg_net2=exact is a developer-only switch, not a normal launcher quality choice.

The frame-generation multiplier is 2 by default. Its value counts the total images presented per game frame, so 2 means one generated image between game frames; values 2 through 6 are accepted.

Launcher, menu and settings.ini controls

Per-game choices are stored in <game folder>\wronggpu-setup\settings.ini.

Feature Launcher and OptiScaler controls settings.ini keys
Models M, K and L On the game's page, choose Model and Mode → Fast or Exact, then Apply. In OptiScaler's Custom tab, the WrongGPU Upscaler card offers the same per-model choices and applies a change from the next frame. `m_mode=fast
Ray Reconstruction On the game's page, choose Quality → Fast, Accurate or Exact, then Apply. Exact first requires the launcher's global Exact-mode setting. The RR card in OptiScaler can also change the mode. `rr_mode=fast
Frame Generation On the game's page, enable Use WrongGPU, then choose the preset, multiplier and presenter. The WrongGPU Frame Generation card offers live preset and multiplier changes. `fg=off

The SR menu choice is synchronized back to the launcher. RR menu changes apply from the next frame when live shared settings are available; otherwise they apply from the next start. FG preset and multiplier changes in its card apply live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants