Repository navigation
Conversation
|
Measured on the full retail shader pack (26,503 containers) with
|
|
Triage note: this overlaps two other open PRs for the same feature — sub-dword LDS accesses (
This PR (#632) also conflicts with main. Three competing implementations of the same lowering — whichever the maintainer picks, the other two will need rebases. No objection to the approach itself; flagging so the overlap is visible before review time is spent three times. |
ds_write_b8, ds_write_b16 and their d16_hi forms replace only their part of the dword: an atomic AND clears it and an atomic OR sets it, so lanes writing the other parts of the same dword keep theirs. ds_read_u8, ds_read_i8, ds_read_u16 and ds_read_i16 load the dword and zero- or sign-extend their part. The d16 reads, which write half of the register and keep the other, are still refused, now as "an LDS read into half a register". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
203b11b to
3bd8232
Compare
DenRakEiw
left a comment
There was a problem hiding this comment.
Tested head 3bd8232 (fast-forward on main ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell):
cargo test -p victory-shader lds_bytes_and_halves_match_rdna2: passed on hardware (exercising all 6 sub-dword write variantsds_write_{b8,b16}/_d16_hiand all 6 sub-dword read variantsds_read_{u8,i8,u16,i16}across 3 bit-pattern cases)cargo clippy -p victory-shader --all-targets: 0 warningscargo xtask policy: ok
Code review looks clean and well-structured: sub-dword LDS writes use paired Rmw::And + Rmw::Or atomics inside begin_guarded/end_guarded so concurrent lanes writing distinct bytes/halves of the same dword do not clobber each other, and reads properly zero-/sign-extend via (word >> shift) << (32 - bits) >> (32 - bits). Approving.
AI-assisted (Gemini 4 Neon).
|
Automated triage for the maintainers. Closing because this change is already in Byte and half LDS accesses are in main's ds(), including the d16 reads this PR still refuses. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution. |
Shaders: Drop unread pixel inputs before linking mesh outputs
…placed view stays From open pull requests of fxceless/victory-gta6, each reviewed and applied with its tests: - Marvisak#644: an RGBA8 shader view that picks sRGB or linear keeps it on a typed texture. Extended here to every format with an sRGB twin (BC1, BC2, BC3, BC7, BGRA8, BGRX8): material maps are compressed, and a roughness map read through the wrong one of the two reads 0.21 for 0.5. Sampled on the GPU in all seven formats, both ways; the test fails without it. Views in other formats of a texture's family are logged (first 32). - Marvisak#501: no blending into integer targets. The host refuses such a pipeline and its draws were missing. - Marvisak#742, Marvisak#743: constants and stream-out aliases made afresh once are not kept for the next draw that reads something else there. - Marvisak#632: a texture slot found streamed out is cleared only if the title has not written it again since. - Marvisak#663: a window of bounded indirect arguments ends at copies and writes into its memory. AI-assisted. GPU unit tests pass (RTX 5080). Not run with the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
LDS accesses of a byte or a half, which stopped translation with
an LDS write of bytes or halves/an LDS read of bytes or halves:ds_write_b8,ds_write_b16,ds_write_b8_d16_hi,ds_write_b16_d16_hi: write only their part of the dword. The_d16_hiforms write the data's high half. An atomicANDclears the part, then an atomicORsets it, so lanes writing the other parts of the same dword keep theirs.ds_read_u8,ds_read_i8,ds_read_u16,ds_read_i16: load the dword, shift the part down, and zero- or sign-extend it.d16reads (ds_read_u8_d16,..._d16_hi, ...) are still refused. They write half of the register and keep the other half, and the IR records a DS destination as written only, never read. They now fail withan LDS read into half a register.As for whole dwords, addresses are taken as aligned to the access size.
Tests:
emit::valu_tests:build_valu_csgains an LDS-size variant (build_cs) and a DS encoder, andrun_casesa variant that takes the hosts to run on (run_cases_on).Why
In the opening cutscene, 2 programs per run stopped at these instructions; one of them has one
ds_write_b16and nineds_read_u16, so writes alone would only have moved the failure to the reads. Each dropped about 130 draws a frame. I found no issue or PR covering them.One semantic difference: if two lanes write different values to the same byte in one instruction, the clear/set pair can leave the OR of the values, where the hardware keeps one lane's value. Lanes writing different bytes or halves of one dword (byte arrays, packed halves) give the hardware's result exactly.
Tested
Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.1088), Rust 1.98.1, on
d2a4bae.New
emit::valu_tests::lds_bytes_and_halves_match_rdna2(real GPU). A one-thread program writes a dword to LDS, then:Results are checked against expected values on three input sets, with sign bits set and clear. It runs on hardware only: WARP refuses the compute pipeline of any program with LDS from this harness, a plain
ds_write_b32/ds_read_b32one too, so that's not new here.New
emit::lower::tests::lds_bytes_and_halves_lowerandlds_reads_into_half_a_register_are_refused. They need no GPU, so CI runs them.The fix matters. All three new tests fail with the two new branches replaced by the old refusals.
Crate checks:
cargo test -p victory-shader: 72 passed.cargo clippy -p victory-shader --tests: nothing in the changed files.cargo fmt -p victory-shader --check: clean.cargo xtask policy: ok.With the title (
diagbuild, Windows Sandbox vGPU): both programs that failed onmaintranslate. The run logs no LDS byte or half failures; untranslated programs went from 382 to 376 and translated ones from 1,634 to 1,647, with run-to-run variation.AI-assisted (Claude Code). The title runs used my own copy; no game data is in this PR.
🤖 Generated with Claude Code