Skip to content

perf(video): reuse texture register decodes across draws - #762

Draft
tekulvw wants to merge 2 commits into
sp00nznet:masterfrom
tekulvw:codex/upstream-draw-preparation-20261109
Draft

tekulvw wants to merge 2 commits into
sp00nznet:masterfrom
tekulvw:codex/upstream-draw-preparation-20261109

Conversation

@tekulvw

@tekulvw tekulvw commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Successive draws repeatedly decode the fragment texture register file. Keep each unit’s pure register-derived descriptor until one of its eight texture words or SIZE1 word changes. Invalidate the affected unit before a changed write; identical writes preserve reuse. Initialization and shutdown clear the derived state.

Guest texture contents, surface aliases, uploads, program state, resource lifetime and backend bindings continue through their existing checks. The normal build adds no diagnostic switch or timing instrumentation.

Demonstrated workload benefit

The isolated downstream adaptation improved request throughput in all three Linux Local Training pairs. The paired median improvement is 1.87%, with a range of 1.54–5.63%. The mean of run rates improves 3.00%; the larger second-pair gain contributes to that mean. CPU cost per request falls in all three pairs.

Linux pair Baseline requests/s Descriptor reuse requests/s Request-rate change CPU ms/request, baseline → reuse
1 33.4644 34.0915 +1.874% 134.596 → 133.378
2 32.4700 34.2982 +5.631% 136.837 → 132.012
3 32.4280 32.9277 +1.541% 137.731 → 135.051

Linux mean CPU cost is 136.388 → 133.480 ms/request (−2.13%). The pooled draw wall phase is 14.214 → 13.216 ms per recorded FIFO update. Drain and drawable wall time rise, so this is not a claim that every phase saves CPU time. The phase subset uses its own update denominator, separate from process CPU/request.

Windows also completes three source-matched pairs, with request-rate changes +1.894%, −1.056%, +1.056%. Its mean rate changes +0.63%, and CPU/request changes +0.39%. These mixed results establish no reliable Windows throughput benefit. A subsequent harness audit found that the preserved Training exports do not contain a positive foreground-window witness for the measured common interval; the Training launcher did not enable its focus-required mode. Actual focus loss is not proven, but these Windows results must not be described as verified focused measurements. Draw wall time falls in each Windows pair (mean 12.907 → 12.345 ms/update), while the end-to-end result remains noisy.

These are bounded guest-request measurements in Local Training. They do not measure independent physical presentation FPS or establish sustained real-match 60 FPS. No release or installer-default adoption is implied.

Source and controls

The measured adaptation changes only libs/video/rsx_draw_engine.c relative to the existing fork’s within-draw memo:

  • Baseline SDK 40fe4f3a.
  • Isolated descriptor-reuse adaptation 37db493f, exact source comparison.
  • Same public downstream client source e259407, optimized Release settings, generated PPU optimization level 1, native EdgeGeom and coherence versions enabled, and retained generated-input/dependency receipts. Linux Ryzen 7800X3D/RX7900XTX; Windows Ryzen 9950X3D/RTX5090.
  • Same frame trace, approximately 1 Hz counter observer and runtime configuration in each pair. Linux uses the fresh owned PID/window focus protocol. Historical Windows Training exports lack positive common-window foreground evidence; the new diagnostic protocol adds a focus-required input guard and 1 Hz owned-window foreground records. No FIFO batching is present in either measured arm. Encode thread, native rendering frontend, adapter and native owner are disabled. Observers do not suspend threads or capture stacks.
  • Common intervals are roughly 24 seconds inside the settled trace of 25 seconds. Request counts and CPU intervals share those boundaries; Linux focus evidence also covers them. Windows historical common-window foreground focus is unverified as described above. All twelve runs exit normally, with zero dropped trace spans and no known fatal diagnostics. One malformed interleaved Windows FIFO report inside the common window is excluded from its phase subset; the request/CPU evidence remains intact. Raw private game evidence stays private.

A downstream-only native publication API also writes these registers directly. A separate correctness fix invalidates before those accepted writes. That path is disabled in the measured configuration, and does not exist in this upstream engine. Later downstream adoption must include that correction. The measured binaries remain frozen at 37db493f.

Correctness and reproducible CPU controls

  • python3 tools/test_rsx_texture_decode.py: actual engine with a recording backend, 267 PASS records with the test-only uncached oracle and 237 in the normal build. Covers all dependency bits across all 16 units, normalized methods/subchannels, equal writes, unit independence, reset, and guest texture/shader/vertex/render-state/surface behavior.
  • RED controls: unchanged-draw decode-work assertion fails before caching; omitting SIZE1 invalidation fails unit 0, word 8, bit 0.
  • The actual adapted fork engine passes 198 checks with Linux Clang 21 ASan+UBSan. The macOS sanitizer executable stalled before main and was stopped; no macOS sanitizer pass is claimed.
  • python3 tools/test_rsx_texture_decode.py --benchmark --draws 400000: nine repeats, Apple M4 Pro, Clang 17, -O2, nice 15. Authored repeated-state actual-engine median elapsed time 408.201 → 368.260ms (−9.78%). A within-draw-only memo control is 390.555 ms, so persistent reuse saves 5.71% beyond it. Repeated work falls from 6.4 million decodes to zero after warmup; every case issues 400,001 recording-backend draws. This CPU fixture is not a game benchmark.
  • Independent existing-fork control: 294.631 → 269.035 ms (−8.69%) repeated state; changing all 16 units is neutral at 332.028 → 331.921 ms (−0.03%).

The CPU regression runner is wired into existing Linux and macOS CI. Future packet-ingestion changes must invalidate the same dependencies before direct register writes; the dependent FIFO experiment remains closed because its workload benefit is unproven.

@tekulvw

tekulvw commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing this draft while source-matched Linux/Windows before/after measurements complete. The branch and authored correctness evidence are preserved. Any future proposal will document a demonstrated, repeatable workload benefit and its limits before publication.

@tekulvw tekulvw closed this Nov 10, 2026
@tekulvw tekulvw reopened this Nov 10, 2026
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.

1 participant