Skip to content

R-7: read the ordered-pixel (POPS) collision SGPR in pixel shaders - #54

Open
sanchaton wants to merge 2 commits into
ProjectLeonidaL:mainfrom
sanchaton:pr/r7-pops
Open

sanchaton wants to merge 2 commits into
ProjectLeonidaL:mainfrom
sanchaton:pr/r7-pops

Conversation

@sanchaton

Copy link
Copy Markdown
Contributor

What changed

R-7 (partial): the 10 PS_PedTexturedCutOutTint_Zero pixel shaders that failed with "emit: a hardware SGPR input" now translate. They wait for earlier waves of overlapping pixels (POPS) and read the SGPR after the primitive mask and src_pops_exiting_wave_id; both now read as "no overlap" (marked shortcut:, the host orders nothing), so the wait is skipped. The R-7 row and the fork notes record the 2026-11-26 recount: the 195 GS_VoxelizeGeneric failures drop no draws, and the 5 CS_TraceShadowRays_* need view addresses by heap slot from leonida-gpu.

How it was tested

  • Not run in game: tests and a full shader census only. The draws these shaders bring back have not been measured in game yet; no frame-rate change is claimed.

Checks run on this branch:

  • cargo test --workspace --locked: 656 passed, 0 failed, 18 ignored (run with -j 2 -- --test-threads=4)
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo xtask policy

New unit test: io::tests::ordered_pixels_read_the_collision_sgpr (the SGPR is an input only when the shader reads src_pops_exiting_wave_id).

Full leonida translate --list --validate --jobs 2 with a release build, compared program by program with the census of the base tree (together with the lane-mask fix sent as a separate PR):

Cause Before After
emit: a hardware SGPR input 10 0
emit: a lane mask holding lanes elsewhere read as data (other PR) 2 0
emit: an opaque lane mask (other PR) 1 0
All translation failures 282 269

No program that translated before fails now, and none changed its cause. The 216 DXIL validator failures are the same 216 programs, with the same messages, on the base commit; none of the 10 fixed shaders is among them.

AI

  • AI-assisted: investigation, fix, unit test, census comparison and review.

…l shaders

Pixel shaders that wait for overlapping earlier waves read the SGPR after the primitive mask and src_pops_exiting_wave_id. Both now have a value (no overlap, nothing exited: the host orders nothing), so the wait is skipped. 10 PS_PedTexturedCutOutTint_Zero programs translate and validate.
Census of 2026-11-26: the 195 GS_VoxelizeGeneric failures drop no draws; the 10 POPS pixel shaders are fixed; the 5 CS_TraceShadowRays_* need view addresses by heap slot from leonida-gpu.
@ShinniUwU

Copy link
Copy Markdown
Contributor

Looks good to me. One question: the collision SGPR is found as the largest user_data + sgprs in native.layout, plus one. If a shader has user SGPRs that are not in the root layout, that lands on the wrong register. Is there a user SGPR count in the program header you could use instead?

@sanchaton

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I looked for one: the native program record does not carry a user SGPR count for pixel shaders.

  • The record's +0x50 word counts all SGPRs the program uses (bits 20-27), not the user ones.
  • The PS stage data we decode holds the inputs, SPI_PS_INPUT_ADDR, DB_SHADER_CONTROL and the export patches; no SPI_SHADER_PGM_RSRC2_PS (whose USER_SGPR field would be the answer) is stored there, unlike compute, where COMPUTE_PGM_RSRC2 is and ComputeIo::user_sgprs reads it.

The root layout is the user-data map the console compiler emits: every user SGPR is filled from a root parameter, so a user SGPR outside the layout would have nothing to hold. That is why the end of the layout is taken as the end of the user SGPRs. If we find where the PS RSRC2 is stored, switching to it is a one-line change, and I will make it.

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