Skip to content

fix(kyty): probe code-only programs at the wave size their code uses - #375

Merged
simnJS merged 1 commit into
simnJS:AnyKytyfrom
Raghav314:feat/kyty-rt-survey-wave
Nov 27, 2026
Merged

simnJS merged 1 commit into
simnJS:AnyKytyfrom
Raghav314:feat/kyty-rt-survey-wave

Conversation

@Raghav314

Copy link
Copy Markdown
Contributor

What

kyty_rt_probe --all (the RT survey) compiled every program found only in the code cache at both wave sizes, because the cache records no dispatch inputs for them. Half of those rows described dispatches the game never makes. A wave32 program compiled as wave64 also reads registers that its 64-bit lane-mask writes clobber, so some of those phantom rows looked like ray tracing misses or emitted invalid SPIR-V.

Decoder::ExecWaveSize now reads the wave size from the code:

  • a write to exec_hi means wave64;
  • otherwise scalar writes to exec, s_*_saveexec_* included, decide by their width (_B32 or _B64);
  • code that mixes widths or never writes exec has no known size, and the survey still tries both.

The survey probes a code-only program once at its known size, and its summary line reports code_only_wave_known. tools/rt_survey.py describes code-only rows accordingly.

Tested

Arch Linux (CachyOS), GTA VI (PPSA38500) pipeline cache:

before this PR
Survey rows 124 68
Code-only programs with a known wave size 56 of 56 (43 wave32, 13 wave64)
Manifest programs whose code gives their recorded wave size 12 of 12 (all wave32)
Host-query sites 172 128
Empty sites 30 12
Invalid SPIR-V variants 27 0

No program mixes both widths. The host-query and empty counts drop because each program is now counted once, at the wave size the game uses.

  • CodeWaveSize() in RtOracle.cpp decodes hand-encoded RDNA2 instructions: 32-bit and 64-bit s_mov and s_and_saveexec to exec, SOP2 s_and to exec, exec_hi written with 32-bit moves (wave64), mixed widths and no exec write (unknown). It fails if saveexec is ignored.
  • RtProbeExport.cmake expects the new summary field; its fixture programs never write exec and keep both wave sizes.
  • kyty_shim_rt_* tests pass, tools/tests/test_rt_survey.py passes, and tools/check_conventions.py passes.

No change to the driver or to compiled shaders: only the survey tool and a new decoder query that the survey calls.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 620.73.04, Arch Linux (CachyOS kernel 7.3.6)
  • AI-assisted: yes

The RT survey compiled every program found only in the code cache at
both wave sizes, because the cache records no dispatch inputs for them.
Half of those rows described dispatches the game never makes, and a
wave32 program compiled as wave64 can read clobbered registers, which
made some of them look like misses or emit invalid SPIR-V.

Decoder::ExecWaveSize reads the wave size from the code: a write to
exec_hi means wave64; otherwise scalar writes to exec, saveexec
included, decide by their width. Code that mixes widths or never
writes exec has no known size, and the survey still tries both. The
summary reports how many code-only programs had a known size.
@Raghav314
Raghav314 temporarily deployed to repository-maintenance November 27, 2026 15:53 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown

I checked the whole diff against its base branch and found no blocking defect.

  • ExecWaveSize treats an exec_hi write as wave64. Otherwise it decides by the width of scalar writes to exec and of s_*_saveexec_*. Mixed widths, or no exec write, return 0, which means unknown.
  • The survey probes a code-only program once at its known size. It still tries both sizes when the size is unknown, and it reports the new code_only_wave_known field in the summary.
  • The new CodeWaveSize cases use hand-encoded instruction words. I decoded the SOP1 and SOP2 encodings by hand and they match the cases they claim to cover.
  • The RtProbeExport.cmake expectation of code_only_wave_known=0 is consistent with fixtures that never write exec.
  • There are no code comments, nothing specific to one title, and no driver or shader changes.

I didn't run any tests. The test and survey results come from the PR description.

@github-actions github-actions Bot added the automerge Merge after maintainer approval and CI label Nov 27, 2026
@simnJS
simnJS changed the base branch from Brainrot to AnyKyty November 27, 2026 16:08
@simnJS
simnJS merged commit 0e1a8ec into simnJS:AnyKyty Nov 27, 2026
10 checks passed
@simnJS

simnJS commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Thanks for improving the RT survey. We corrected wave-size inference for scalar instructions whose input and output widths differ and for vector comparisons that write to exec_hi. The probe tests cover single-width selection, the two-width fallback, and manifest precedence.

Merged into AnyKyty in 17da676.

@simnJS simnJS added area: ray-tracing Native and emulated ray tracing, BVH walks area: tools-ci Tests, CI, measurement and analysis tools bug Something isn't working medium A few days of work; needs some knowledge of the code labels Nov 27, 2026

This branch was previously deployed

1 inactive deployment
repository-maintenance — 001c51d4 Deployed Nov 27, 2026 by Raghav314 via review #369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ray-tracing Native and emulated ray tracing, BVH walks area: tools-ci Tests, CI, measurement and analysis tools automerge Merge after maintainer approval and CI bug Something isn't working medium A few days of work; needs some knowledge of the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants