Skip to content

perf(fork): reduce BDA shader size and repeated PCIe atomics - #11

Draft
R3Dzf wants to merge 5 commits into
integration/current-main-compatibilityfrom
integration/shader-memory-efficiency
Draft

R3Dzf wants to merge 5 commits into
integration/current-main-compatibilityfrom
integration/shader-memory-efficiency

Conversation

@R3Dzf

@R3Dzf R3Dzf commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

What

Fork integration of two existing shader-recompiler performance changes:

Original commit history and authorship are retained. The integration applies those four source commits to the restored current-main tree; it does not claim new instruction semantics or console hardware measurements.

These changes directly address the oversized BDA-store shaders involved in the two Linux test timeouts. They also reduce repeated atomics against host-visible fault-tracking memory on discrete GPUs. The upstream descriptions include NVIDIA, AMD and Intel measurements for boykopovar#1265, and NVIDIA measurements for boykopovar#1280; those measurements belong to the original contributors and have not been reproduced on physical hardware here.

Adds Linux/Windows validation that builds and runs the affected BDA store/atomic tests with the existing 30-second limit, then builds the full project and guest libraries and runs the full suite. Linux enables SPIRV-Tools validation and requires the Vulkan software driver.

Tested

  • Four focused source commits applied cleanly to the restored integration.
  • Both changed translation units passed local GCC 13.3 syntax compilation against the restored headers.
  • Convention checks passed for the committed delta.
  • The remote tree matches the local tree exactly.

The targeted CI test phase completed successfully on Linux and Windows in run 37991651105. Linux then built the full project and all guest libraries and completed the full 523-test suite successfully, with explicitly reported skips for unavailable facilities. Windows also built the full project and guest libraries. Its full 514-test suite had one failure, patched_libraries: 15 PRX libraries loaded and 101 failed because the old test environment selected the wrong C++ runtime. All other tests passed or were explicitly skipped. This branch does not yet contain the separate CMake runtime-selection fix. Windows runners can explicitly skip tests requiring an unavailable GPU; the full Linux phase requires the Vulkan software driver. Earlier Linux baseline timing was 51.03 seconds for global_vcc_base and 67.98 seconds for flat_store; the earlier integration run failed their 30-second limits. On the cold targeted Linux run, flat_store completed in 26.15 seconds and global_vcc_base in 16.69 seconds. Their subsequent full-suite runs completed in 4.34 and 2.71 seconds, respectively; those later timings can benefit from driver cache and are not claimed as cold results. Limits and test coverage have not been relaxed.

Combined follow-up validation

The combined review branch integration/project-completion at commit 76f71f8 includes #8, #9, #10 and #11 plus the separately developed Windows runtime fixes. Results below apply to that combined commit; the individual PR heads retain the baseline results above.

  • Full build and test run 38033998905: Linux built the full project and all guest libraries, then completed 523 registered tests with zero failures and 27 explicit skips. Windows built the full project and all guest libraries, then completed 514 registered tests with zero failures and 211 explicit skips. The patched_libraries loader test passed in 0.06 seconds.
  • Cold Linux affected-test timings were 25.05 seconds for flat_store and 15.91 seconds for global_vcc_base. The subsequent full-suite timings were 4.20 and 2.89 seconds and can benefit from the driver cache. The 30-second limits remain in effect.
  • The main-based Windows exception topic fixes future-result destruction using the wrong exception-header layout, native primary-exception initialization and make_exception_ptr reference ownership. Native future helpers and RTTI remain exported under their GNU names after NID patching. Failed video initialization owns its startup promise and completes libc shutdown.
  • Standalone source verification 38033956388 reproduced a crash after restoring the old runtime, then passed 20 repeated exception tests and 400 fresh video-initialization processes with the fix. All 400 video runs reported unavailable video/Vulkan facilities with exit 77; this verifies failure cleanup rather than successful rendering. A separate real NID-patch probe retained all eight native future exports and passed another 200 processes, each with 100 cross-thread exception transfers.
  • New-delta convention checks and the standalone exception topic pass. The combined main-based history still has eight inherited integration(...) commit-subject findings, which remain unresolved for review.

Commercial games, a physical discrete GPU, PCIe performance and console execution have not been tested. The scanner's export-body counts do not establish semantic completeness: encrypted SELF conversion, complete Tempest audio, predictive GPU memory management and full Mesh/Ray Tracing support remain outside the implemented changes.

Checklist

Owner-requested fork integration of existing upstream implementations, with original attribution.

popcoder565 and others added 5 commits October 7, 2026 16:18
Every 8- and 16-bit BDA store and the unaligned path of every 32-bit store emitted one get_bda_write_pointer lookup and one note_bda_write per byte at the store site, five write lookups per 32-bit store. They now call write_bda_bytes, which loops over the bytes and does, per byte and in order, the same lookup, the store when it is mapped and the write note, so faults are recorded exactly as before. On an RTX 3060 the agc_driver_flat_store binaries shrink from 496,256 to 138,240 bytes (wave32) and from 928,384 to 225,152 bytes (wave64), and the cold run from 19.7 s to 2.2 s.
note_bda_write unrolled its 8 compare-exchange probes, and drivers inline it at every BDA store and atomic. The probes now run in a loop that tries the same slots in the same order and stops at the same slot, so the recorded pages and the overflow flag are unchanged. With the byte store helper, the agc_driver_flat_store binaries on an RTX 3060 go from 138,240 to 75,648 bytes (wave32) and from 225,152 to 130,560 bytes (wave64), and the cold run from 2.2 s to 1.2 s.
… path

The declaration, the state field and the definition of write_bda_bytes now sit next to EmitBdaStore and the other BDA write functions instead of next to the dword read functions, which boykopovar#1267 extends at the same lines. No change to the emitted code.
note_bda_write ran a device-scope compare-exchange on every probe, also
when the slot already held the page. The table lives in host-visible
memory, so each BDA store paid an atomic across PCIe, and nearly every
store hits a page an earlier store noted. Load the slot first and only
compare-exchange when it does not hold the page. The slots probed, the
pages recorded and the overflow report are unchanged.

DOOM (PPSA99666) presents through a compute kernel that stores about two
million pixels through raw pointers per frame: 248 ms per dispatch
before, 8.1 ms after, on an RTX 5070 Ti.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Integrate upstream boykopovar#1265 by popcoder565 and boykopovar#1280 by Scott Schuster while preserving their original history. Emit shared looping byte-write helpers and written-page probes, and skip compare-exchange when a slot already holds the page. Add focused shader and full integration validation on both hosts.

AI-assisted integration and validation: yes.
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.

3 participants