Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
7fc1924
Frame generation: presenter boundary, target-time scheduler and fake …
phantoslayer21 Nov 21, 2026
7d49906
Frame generation: Windows presenter back ends and back-end selector (…
phantoslayer21 Nov 21, 2026
99c8eeb
Frame generation: runtime contract, net1 recorder plan, frame ingest …
phantoslayer21 Nov 21, 2026
c493660
Frame generation: game adapter core and per-game FG settings (F8a)
phantoslayer21 Nov 21, 2026
d4a332e
Frame generation: FG session orchestrator joining adapter, history, e…
phantoslayer21 Nov 21, 2026
b9a9812
Frame generation: light path (preset C) end to end, CPU reference and…
phantoslayer21 Nov 21, 2026
1950787
Frame generation: note where the light path's 2^y coefficients come f…
phantoslayer21 Nov 21, 2026
fcfe8f9
Frame generation: Full path stages (presets A / B) CPU reference and …
phantoslayer21 Nov 21, 2026
673f163
Frame generation: net2 CPU reference and exact D3D12 kernels (#96)
phantoslayer21 Nov 21, 2026
9cf2b70
Frame generation: the D3D12 executor joining the session to the FG ke…
phantoslayer21 Nov 21, 2026
3e01343
Frame generation: net2 fast path on the matrix unit, D3D12 tier B (#96)
phantoslayer21 Nov 21, 2026
66ed5c3
Frame generation: Win32 hook transport and swap-chain hook seam (F8b)
phantoslayer21 Nov 21, 2026
e4ecf53
Frame generation: Cyberpunk 2077 title binding and 2.14 native codec …
phantoslayer21 Nov 22, 2026
84b1b7b
Launcher: frame generation settings and preset FG conversion, off by …
phantoslayer21 Nov 21, 2026
8bc452e
Frame generation: WrongGPU-FG.asi runs the session, the D3D12 executo…
phantoslayer21 Nov 22, 2026
dc481af
Frame generation: probe the RDNA 4 adapter before the first slot is l…
phantoslayer21 Nov 22, 2026
86105a8
Frame generation: live-game fixes for the Cyberpunk 2077 route (F9)
phantoslayer21 Nov 22, 2026
51267ad
Model M (D3D12): hoist 8-byte base alignment masks in post_tf (-41.3 …
phantoslayer21 Nov 24, 2026
933ca08
Model L & M (D3D12): hybrid Swin/bneck/post/project speedups (-0.320 …
phantoslayer21 Nov 24, 2026
19bfc54
Model K (D3D12): coalesced 128-bit loads and exact I/O speedups (-0.1…
phantoslayer21 Nov 24, 2026
bcedb06
Frame generation (D3D12): tiled/fused pre-net2, batched FP16 conversi…
phantoslayer21 Nov 24, 2026
a8150db
FG proxy tests: use static_assert for constant gate checks (fixes MSV…
phantoslayer21 Nov 24, 2026
4cf4086
FG swapchain hook: silence MSVC /W4 /WX C4127 on mutant 6
phantoslayer21 Nov 24, 2026
d58a6fa
Fix runtime.cpp without WG_MODEL_L and test_l_runtime_frame hyb_twins…
phantoslayer21 Nov 24, 2026
7c4fecc
RR Preset F: enable bit-exact OFX_FUSE+OF_UNIF on output.* and OFX_FU…
phantoslayer21 Nov 24, 2026
bcf27ef
Frame generation (D3D12): the output kernels write the presenter slot…
phantoslayer21 Nov 24, 2026
426a434
Frame generation (D3D12): the Full blend writes net2's merged input i…
phantoslayer21 Nov 24, 2026
ff06d00
Frame generation (D3D12): Full blend converts NaN lanes as before; Di…
phantoslayer21 Nov 24, 2026
b28679f
Model M (D3D12): fold scale_rgb into the post_tf store when the pre-e…
phantoslayer21 Nov 24, 2026
d894510
Frame generation (D3D12): per-launch profile and multi-queue timing, …
phantoslayer21 Nov 24, 2026
0fc85e0
RR Preset F: exact step-E body (E1, D1-F, D1-R) takes the 2x MLP chun…
phantoslayer21 Nov 24, 2026
153d351
Frame generation (D3D12): fused and retiled kernels (fine pass + hole…
phantoslayer21 Nov 24, 2026
92c5c2f
Frame generation (D3D12): the benchmark takes --fuse 0|1 beside the o…
phantoslayer21 Nov 24, 2026
55923d5
Frame generation (D3D12): Wave 1B fusions (net1 cells in LDS, net2 re…
phantoslayer21 Nov 24, 2026
1b7deb7
Frame generation (D3D12): one arena alias and one driver-channel buff…
phantoslayer21 Nov 24, 2026
182cc43
Model K (D3D12): exact FMA barriers, d1 at 191 VGPRs and output colou…
phantoslayer21 Nov 24, 2026
fc16c9d
RR Preset F: plain resolve specialisation resolve.fast3 (RF_SPEC 3, 4…
phantoslayer21 Nov 24, 2026
7b0f6a5
Model M (D3D12): Wave 1 bit-exact perf levers (T1.1/T1.2/T1.3/T1.5/T1.8)
phantoslayer21 Nov 25, 2026
9188c88
Frame generation (D3D12): Wave 1B defaults to the two levers that win…
phantoslayer21 Nov 25, 2026
133e87e
Frame generation (D3D12): Wave 2 levers A15-A18, all bit-exact and sw…
phantoslayer21 Nov 25, 2026
5ceffd9
Model M (D3D12): Wave 1.5 - fix the post_tf VGPR cliff, drop the f16l…
phantoslayer21 Nov 25, 2026
8e1833f
Model K (D3D12): one-fma exact products in the input stage and scalar…
phantoslayer21 Nov 25, 2026
2be02a0
Frame generation (D3D12): the default fuse2 mask is 593 (17 + A15 fil…
phantoslayer21 Nov 25, 2026
4bef024
Frame generation (D3D12): CI follow-up - Wave 2 test file in LF, K so…
phantoslayer21 Nov 25, 2026
484342c
RR Preset F: wave-4 bit-exact levers (head.fast.rx 99 -> 95 VGPRs + w…
phantoslayer21 Nov 25, 2026
482b616
Model L (D3D12): fused hybrid decoder expands, wave64 reconstruction …
phantoslayer21 Nov 25, 2026
018b8f1
RR Preset F: WG_RR_W4 defaults to 2 (body LDS overlay only); the head…
phantoslayer21 Nov 25, 2026
41bd27c
Model L (D3D12): fused l_post_tf post (recon + filter + scale_rgb), p…
phantoslayer21 Nov 25, 2026
6da9362
RR Preset F: wave64 forms of head.fast.rx and the level-1 body (D1-R,…
phantoslayer21 Nov 25, 2026
13423ef
Model L (D3D12): l_post_tf kernel-set bookkeeping (overridable lazy-f…
phantoslayer21 Nov 25, 2026
306506f
Model L (D3D12): wave 3 bit-exact levers: direct-weight hybrid Swin b…
phantoslayer21 Nov 25, 2026
13a53c9
RR Preset F: wave-4c levers (wide stages in wave64, IN0 / D0-F deferr…
phantoslayer21 Nov 25, 2026
a248628
Model L (D3D12): wave 4 bit-exact levers: l_post_tf history burst, q2…
phantoslayer21 Nov 25, 2026
830279a
Model L (D3D12): default wave 3 / wave 4 masks pruned to the measured…
phantoslayer21 Nov 25, 2026
d2dee9f
Model M (D3D12): restore WG_LD_A16 on the two Swin kernels, make the …
phantoslayer21 Nov 25, 2026
5c88a67
Model K (D3D12): whole-address 16-byte load masks again in the stage …
phantoslayer21 Nov 25, 2026
b416f30
RR Preset F (fast mode): wave-5 quality-relaxed kernels (ALU head tai…
phantoslayer21 Nov 25, 2026
8c07199
Model L (D3D12): fix RADV bit-exactness in hybrid softmax/norm2, clea…
phantoslayer21 Nov 25, 2026
3d83c13
Model L (D3D12): opt-in l_mode=fast (M-form route on Model L's values…
phantoslayer21 Nov 25, 2026
6d3e8bf
RR Preset F (fast mode): wave-5b bugfix + full ALU tail/input/head/bo…
phantoslayer21 Nov 25, 2026
565415b
Model L (D3D12): l_mode=fast levers: the fused post, the projections …
phantoslayer21 Nov 25, 2026
2492d02
rr_f: Wave 5c Fast-mode optimizations (L3-L5 body, pool, resolve, out…
phantoslayer21 Nov 25, 2026
8d0e32f
Model L (D3D12): l_mode=fast levers 256 / 512 / 1024 / 4096 / 8: the …
phantoslayer21 Nov 25, 2026
454987d
RR Preset F (fast mode): wave-5c default WG_RR_W5=0xaff (bits 8 and 1…
phantoslayer21 Nov 25, 2026
cd5ac56
Merge commit 'd2dee9f' into rel/0.7.0-rc1
phantoslayer21 Nov 25, 2026
98ab172
Merge commit '5c88a67' into rel/0.7.0-rc1
phantoslayer21 Nov 25, 2026
1645578
Merge commit '454987d' into rel/0.7.0-rc1
phantoslayer21 Nov 25, 2026
6d16ef3
0.7.0-rc1 phase 2C: SR Fast/Exact modes end to end, in-game WrongGPU …
phantoslayer21 Nov 25, 2026
23a8b59
Model L (D3D12): l_mode=fast levers 4096 / 8 / 8192: the clamped-cubi…
phantoslayer21 Nov 25, 2026
ffe95ba
Model L (D3D12): exact-mode bit-exact levers: dec0 W2 at one tile, du…
phantoslayer21 Nov 26, 2026
b7d033b
Model K (D3D12): row loads for the 5 x 5 luma window and the row-majo…
phantoslayer21 Nov 26, 2026
318e3e8
Merge commit 'b7d033b' into rel/0.7.0-rc1
phantoslayer21 Nov 26, 2026
3ca3160
Merge commit 'ffe95ba' into rel/0.7.0-rc1
phantoslayer21 Nov 26, 2026
3fb797b
Model L (D3D12): l_mode=fast default 9847, one W2 tile in the decoder…
phantoslayer21 Nov 26, 2026
a27c2af
Merge commit '3fb797b' into rel/0.7.0-rc1
phantoslayer21 Nov 26, 2026
124b81f
0.7.0-rc1: isolate WG_Z_GRID to FG and SW_COEF_ROWS to l_swin_dec_coe…
phantoslayer21 Nov 26, 2026
67b2bff
0.7.0-rc1: regenerate k_smx_selfcheck.h digest for unified wg_platfor…
phantoslayer21 Nov 26, 2026
3a35b73
Model K (D3D12): d1 one window per workgroup (k_stage_d1; -19.4 us at…
phantoslayer21 Nov 26, 2026
c22762d
Model K (D3D12): best-E retry folded into the output tap loop, unifor…
phantoslayer21 Nov 26, 2026
3639bdc
Merge commit 'c22762d' into rel/0.7.0-rc1
phantoslayer21 Nov 26, 2026
cd86ce0
Model K (D3D12): add fused colour-tap __a1 kernels so k_mode=fast kee…
phantoslayer21 Nov 26, 2026
8debca9
Launcher: frame generation files and game-page section (WRONGGPU_FG, …
phantoslayer21 Nov 26, 2026
a3df7c9
Merge commit '8debca9' into rel/0.7.0-rc1
phantoslayer21 Nov 26, 2026
68c165f
FG 0.7.0: OptiScaler integration, generic Streamline 2.x binding, rel…
phantoslayer21 Nov 26, 2026
79ca3bb
Merge commit '68c165f' into rel/0.7.0-rc1
phantoslayer21 Nov 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 22 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,30 @@ jobs:
cmake -S clean/converter -B out/converter -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake --build out/converter
ctest --test-dir out/converter --output-on-failure
- name: Frame generation game adapter, Win32 transport and title bindings
run: |
$PSNativeCommandUseErrorActionPreference = $true
cmake -S clean/fg/proxy -B out/fg-proxy -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake --build out/fg-proxy
ctest --test-dir out/fg-proxy --output-on-failure
- name: Shared settings
run: |
$PSNativeCommandUseErrorActionPreference = $true
cmake -S clean/wgshared -B out/wgshared -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake --build out/wgshared
ctest --test-dir out/wgshared --output-on-failure
- name: Frame generation presenter, scheduler and Windows back ends (CPU tests)
run: |
$PSNativeCommandUseErrorActionPreference = $true
cmake -S clean/fg/presenter -B out/fg-presenter -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake --build out/fg-presenter
ctest --test-dir out/fg-presenter --output-on-failure
- name: Frame generation runtime and session
run: |
$PSNativeCommandUseErrorActionPreference = $true
cmake -S clean/fg/runtime -B out/fg-runtime -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake --build out/fg-runtime
ctest --test-dir out/fg-runtime --output-on-failure

frontend:
name: "CPU: FSR front end"
Expand Down Expand Up @@ -117,8 +135,8 @@ jobs:
run: |
$PSNativeCommandUseErrorActionPreference = $true
cmake -S clean/installer -B out/launcher-tests -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DWRONGGPU_PAYLOAD_DIR="$PWD/out/no-payload" -DWRONGGPU_TESTING=OFF -DWRONGGPU_PRESET_K=OFF -DWRONGGPU_DIRECT_ROUTE=OFF
cmake --build out/launcher-tests --target wg-core-tests launcher-core-tests coexist-core-tests convert-ignore-tests model-choice-tests model-choice-k-tests model-choice-k-only-tests
ctest --test-dir out/launcher-tests --output-on-failure -R "^(wg-core|launcher-core|coexist-core|convert-ignore|model-choice|model-choice-k|model-choice-k-only|source-size|wording)$"
cmake --build out/launcher-tests --target wg-core-tests launcher-core-tests coexist-core-tests convert-ignore-tests model-choice-tests model-choice-k-tests model-choice-k-only-tests fg-choice-tests
ctest --test-dir out/launcher-tests --output-on-failure -R "^(wg-core|launcher-core|coexist-core|convert-ignore|model-choice|model-choice-k|model-choice-k-only|fg-choice|source-size|wording)$"
- name: Test launcher from the test suite's stand-in payload (and a release build refusing it)
run: |
$PSNativeCommandUseErrorActionPreference = $true
Expand Down Expand Up @@ -177,8 +195,8 @@ jobs:
run: |
$PSNativeCommandUseErrorActionPreference = $true
cmake -S clean/installer -B out/launcher-models -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DWRONGGPU_PAYLOAD_DIR="$PWD/out/no-payload" -DWRONGGPU_TESTING=OFF -DWRONGGPU_PRESET_K=ON -DWRONGGPU_MODEL_K=ON -DWRONGGPU_MODEL_L=ON -DWRONGGPU_DIRECT_ROUTE=OFF
cmake --build out/launcher-models --target wg-core-tests launcher-core-tests coexist-core-tests convert-ignore-tests model-choice-tests model-choice-k-tests model-choice-k-only-tests
ctest --test-dir out/launcher-models --output-on-failure -R "^(wg-core|launcher-core|coexist-core|convert-ignore|model-choice|model-choice-k|model-choice-k-only|source-size|wording)$"
cmake --build out/launcher-models --target wg-core-tests launcher-core-tests coexist-core-tests convert-ignore-tests model-choice-tests model-choice-k-tests model-choice-k-only-tests fg-choice-tests
ctest --test-dir out/launcher-models --output-on-failure -R "^(wg-core|launcher-core|coexist-core|convert-ignore|model-choice|model-choice-k|model-choice-k-only|fg-choice|source-size|wording)$"
- name: Payload packager and package check refuse a developer runtime (R1)
# The packager (clean/installer/tools/make_payload.py) runs clean/tests/check_no_dev_diagnostics.py on every runtime
# library it embeds and refuses the payload for dev-diagnostics=1 or a missing marker; tools/release runs the same
Expand Down
1 change: 1 addition & 0 deletions clean/FORMATS.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ frame.
| post (fused) | `post_kernel` | `WG_POST_KERNEL` | — | `post_fused*`, `post_fused3*`: reconstruction + filter in one launch (no display image; history 6 or 4 bytes, `_o16` RGBA16F output — refused for an external output unless `FrameIo.out_rgba16f`, and with pre-exposure ≠ 1) |
| filter | `filter_kernel` | `WG_FILTER_KERNEL` | `post_filter_c1_s4_band` (with the banded default; else `post_filter_c1_s4`) | `post_filter[_c1][_s4\|_s16]` |
| post (true fusion) | runtime options `post_tf`, `post_tf_cpairs` | `WG_POST_TF=0` (or `WG_RUNTIME_OPTIONS=post_tf=0`) | on: frames of the default banded pack12 path (post kernels in wave64, default filter) that `tf_supported` takes run one `post_tf_p12` / `post_tf_dl_p12` launch (interop output copy: RGBA16F rows, π folded in) or `post_tf_f32_p12` / `post_tf_dl_f32_p12` (3 × f32, then `scale_rgb` when π ≠ 1); C = 68 output row pairs per workgroup, 36 for the last dispatch round | `post_tf=0`: the banded sequence; `post_tf_cpairs=<even C>`; reported as `post_tf=<C>` and `post_last` |
| scale_rgb fold (native D3D12) | runtime option `scale_fold` | `WG_SCALE_FOLD=0` (or `WG_RUNTIME_OPTIONS=scale_fold=0`) | on: staged buffers (not raw / direct / Model L / interop output copy) on the `post_tf_f32_p12_diet_vsit` / `post_tf4_dl_*` / `pmo/post_tf_*_mo` route with π ≠ 1: `scale_rgb` is done by the post kernel's store (its π argument; `native_scale`'s values), one launch fewer, the same bytes | `scale_fold=0`: `scale_rgb` after the post |

Both spec 06 kernels take an extra last argument `expo`: a pointer to the exposure pair. When it is not null (the
runtime), they derive e, e_prev, e/e_prev and 0.01/e from it on the GPU (0 → 1, the quotients via binary64 then
Expand Down
16 changes: 11 additions & 5 deletions clean/PERF.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ written).

The clean team has no GPU, but clang 18 here compiles the kernels for gfx1201, so the instruction mix of every build
can be counted (static count per lane; the kernels are fully unrolled, so this is close to the dynamic count).
Cost model from the spec team's measurements (perf-targets, "Vector unit and overlap"): a stage takes its matrix time
plus its vector time; one vector instruction per wave per cycle, a transcendental (`v_exp_f32`, `v_log_f32`) about
4 times an FMA. Below, **cost = VALU instructions + 4 × transcendentals per lane** (a lane of enc0 or dec0 handles 2
pixels). The same compile-time switches that remove one part of the work (ablations) are built for the GPU, so the
spec team can measure what each part really costs (`perf_variants.py`).
Cost model note (verified 2026-11-23 on RX 9070 XT `gfx1201`): pure WMMA and VALU (both FMA and TRANS `v_exp_f32`)
**serialize per SIMD** — both within a single wave (cycle counter: 8× FP8 WMMA = 64 cyc, 8×32 FMA = 286 cyc,
interleaved = 354 cyc; 8×8 `v_exp_f32` = 283 cyc, interleaved = 349 cyc) and across split waves on the same SIMD.
What **does** overlap with WMMA on `gfx1201` is **SALU** (`~0.9`), **VMEM** global loads / LUT gathers (`~0.37`), and
**LDS** latency (`~0.085`), plus higher wave occupancy (e.g. cutting LDS from 32 KiB → 16 KiB to go from 2 → 3 WGs/CU)
which hides VMEM/LDS/barrier stalls across resident waves. (Note: running `overlap_probe.py` in fixed un-interleaved
order without warmup allows GPU boost clocks to ramp ~40% mid-run and produces false positive overlap; interleaving
launch order shows `ov_mma + ov_valu32 ≈ ov_mix32` within every round.) For `enc0`/`dec0` estimation below,
**cost = VALU instructions + 4 × transcendentals per lane** (a lane of enc0 or dec0 handles 2 pixels). The same
compile-time switches that remove one part of the work (ablations) are built for the GPU, so the spec team can measure
what each part really costs (`perf_variants.py`).

Version 1 (as measured: 0.331 ms) at that cost model: 3739 per lane, i.e. about 0.28 ms of vector issue at full
occupancy plus about 0.02 ms of WMMA (6.8 GFLOP at 372 TFLOPS); the kernel was vector-bound. Where it went:
Expand Down
9 changes: 8 additions & 1 deletion clean/dx12/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ as its HIP kernel (`clean/dx12/compare.py` proves it per kernel on synthetic fra
| `dxil_asm.cpp` | tool used by the build (assembles the rewritten DXIL listing) |
| `compare.py` | HIP vs hybrid D3D12, every stage output / state buffer byte for byte |
| `kernels/exposure.hlsl` | the reference port (`exposure_auto_diet`): copy its structure |
| `kernels/fg_*.hlsl` | frame generation's ports (#96, `co=fg_*.co`): groundwork, built only when `--only` names them, never by a full build (`is_frame_gen`), so the Model M / Model L sets stay as they are; checks: `clean/fg/runner/fg_d3d12_check.py` (each kernel), `clean/fg/runner/fg_net1_gpu.py` (net1's 32 steps as a `kernel_replay` chain), `clean/fg/runner/fg_net1_mma.py` (net1's fast path on the matrix instructions, fused / unfused / exact) |
| `kernels/fg_*.hlsl` | frame generation's ports (#96, `co=fg_*.co`): groundwork, built only when `--only` names them, never by a full build (`is_frame_gen`), so the Model M / Model L sets stay as they are; checks: `clean/fg/runner/fg_d3d12_check.py` (each kernel), `clean/fg/runner/fg_net1_gpu.py` (net1's 32 steps as a `kernel_replay` chain), `clean/fg/runner/fg_net1_mma.py` (net1's fast path on the matrix instructions, fused / unfused / exact), `clean/fg/runner/fg_full_stages_d3d12_check.py` (the Full path's stage kernels `fg_full_blend`, `fg_out_*`, `fg_dist_*` against the CPU reference, each kernel, the chained stages and full-size frames), `clean/fg/runner/fg_net2_d3d12_check.py` (net2's exact kernels `fg_net2_*` against the CPU reference, each kernel and the whole network) |
| `tests/kernel_replay.cpp` | replays launches from a case file on the native D3D12 device; `chain` blocks run several launches on buffers that persist between them (a whole network, optionally timed) |

## Arithmetic mode (why build_dx12.py and nothing else)
Expand Down Expand Up @@ -128,6 +128,13 @@ WG_KERNEL(exposure_auto_diet) { WG_SETUP(); ... } // entry name = HIP kernel n
* `args` = the HIP kernel's arguments in order: `p` pointer (DWORD: arena byte offset), `u` any 32-bit scalar,
`b<N>` struct by value (N bytes = N/4 DWORDs, copied verbatim). At most 57 DWORDs. The `WG_ARGS_BEGIN` block must
declare exactly these DWORDs in order, **32-bit scalars only** (no vectors / arrays / structs: cbuffer packing).
* A kernel named `<kernel>_fast` is Model L's `l_mode=fast` twin of `<kernel>` (clean/l/SPEED.md "Fast mode"): the runtime
launches it in place of the base kernel with the same arguments when the build has it, so it declares the same `args`; it
is built with `--model-l` only (`is_model_l`), has no HIP twin (`co=-`), keeps the base kernel's DXIL untouched, and the
hybrid route never launches it. Its arithmetic is not bit-exact to the reference by design (the hybrid route is).
`<kernel>_fast3` (the 3 x 3 post) and `<stem>_w2p_fast` / `<stem>_w2t_fast` (two windows per wave, in place of
`<stem>_nc`; `group=128 gscale=1`, the device's launch of the same grid) are fast-mode kernels too (`build_dx12.py
fast_base` names the kernel each one replaces).
* Output: `<build>/dx12/<tag>__<kernel>.dxil` (`<kernel>.dxil` without a tag) and a `manifest.json` line
`{"name", "file", "co", "entry", "block", "wave", "args", "arg_dwords", "source", "sha256"}`. Build all kernels at
once (no `--only`) for a release: `--only` rewrites the shared manifest read-modify-write.
Expand Down
27 changes: 21 additions & 6 deletions clean/dx12/build_dx12.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
and rcp() (fdiv 1.0, x) is the hardware v_rcp_f32; it is reassembled (dxil_asm.cpp, DXC's IDxcAssembler) and signed by
dxv. Any other float division ('/', which would be an IEEE division) or float remainder is refused: use wg_div.

VGPR check: every Swin / bottleneck kernel built (a name with a swin_ or l_swin_ part) is run through RGA (gfx1201) and its
VGPR check: every Swin / bottleneck kernel built (a name with a swin_ or l_swin_ part, and Model L's fused post
w64_lc12/l_post_tf_p12[_pf][_fast|_fast3]) is run through RGA (gfx1201) and its
USED_VGPRs compared with its bound in clean/dx12/vgpr_limits.json (the count that keeps its present workgroups per CU);
over the bound, or no bound listed, fails the build. WG_DX12_VGPR_CHECK=0 skips it.
ISA rules of the hybrid kernels: every hybrid kernel built (a name with a _hyb part) is checked in the same RGA run by
Expand Down Expand Up @@ -226,12 +227,24 @@ def kernel_decls(path):
MODEL_L_ONLY = {"swin_block_c64_add_ex_nc", "lev/input_encoder_q20", "lev/input_encoder_direct_q20"}


def fast_base(name):
"""The kernel a fast-mode kernel of Model L's l_mode=fast is launched in place of (same grid, block and arguments), or
None: "<kernel>_fast" and "<kernel>_fast3" (the 3 x 3 post) replace <kernel>; "<stem>_w2p_fast" / "<stem>_w2t_fast" (the
two-windows-per-wave Swin blocks, l_swin_c32_fast.hlsl) replace "<stem>_nc"."""
m = re.fullmatch(r"(.+)_w2[pt]_fast", name)
if m:
return m.group(1) + "_nc"
m = re.fullmatch(r"(.+)_fast3?", name)
return m.group(1) if m else None


def is_model_l(decl):
"""A port of one of Model L's code objects (#89: l_swin.co, l_ops.co, l_post.co, l_enc_values.co), a Model L kernel
of the direct route with no code object (co "-", named l_*), a kernel only Model L launches (MODEL_L_ONLY), or a
kernel of the hybrid form (named *_hyb: WG_L_FORM = hybrid, Model L's route only so far)."""
of the direct route with no code object (co "-", named l_*), a kernel only Model L launches (MODEL_L_ONLY), a kernel
of the hybrid form (named *_hyb: WG_L_FORM = hybrid, Model L's route only so far), or a fast-mode kernel (fast_base:
Model L's l_mode=fast, launched in place of the kernel it names)."""
return (decl["co"].startswith("l_") or decl["name"].startswith("l_") or decl["name"] in MODEL_L_ONLY
or decl["name"].endswith("_hyb"))
or decl["name"].endswith("_hyb") or fast_base(decl["name"]) is not None)


def is_frame_gen(decl):
Expand Down Expand Up @@ -330,7 +343,8 @@ def rga_isa(dxil, isa_dir, stem):


def vgpr_checked(name):
return re.search(r"(^|/|l_)swin_", name) is not None # l_swin_*: Model L's blocks (#89)
# l_swin_*: Model L's blocks (#89); l_post_tf_p12[_pf][_fast|_fast3]: Model L's fused post (bound = 96-register tier)
return re.search(r"(^|/|l_)swin_|/l_post_tf_p12(_pf)?(_fast3?)?$", name) is not None


def rga_vgprs(dxil, isa=False):
Expand Down Expand Up @@ -358,7 +372,8 @@ def hyb_scanned(name):


# Model hybrid kernels with no norm tree (no square to fuse): their mutants must fail rule 2 only.
HYB_NO_NORM = {"patch_merge_c64_hyb", "patch_merge_c96_hyb", "expand_c96_hyb", "expand_c128_hyb"}
HYB_NO_NORM = {"patch_merge_c64_hyb", "patch_merge_c96_hyb", "expand_c96_hyb", "expand_c128_hyb",
"patch_merge_c64_q7c_hyb", "patch_merge_c96_q7c_hyb", "expand_c96_q7c_hyb", "expand_c128_q7c_hyb"}


def scan_mutant(name):
Expand Down
14 changes: 14 additions & 0 deletions clean/dx12/hlsl/fg_fp16.hlsli
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
#pragma once

static uint fg_fp16_zero;
#define FG_FP16_SETUP() (WG_SETUP(), fg_fp16_zero = wg_grid_ >> 31)

// Driver-channel FP32 to FP16 RNE. The opaque zero keeps the driver from folding the producing
// FP32 operation into a mixed-precision instruction and losing its separate FP32 rounding.
uint fg_f2h(float value)
{
return wg_ags_call(0x1cu, 0u, 1u, asuint(value) ^ fg_fp16_zero, 0u) & 0xffffu;
}

uint fg_pack_h2(float x, float y) { return fg_f2h(x) | (fg_f2h(y) << 16); }
Loading
Loading