Repository navigation
Shaders: handle s_buffer_load SMEM uses in descriptor_data (#798) - #953
MartinIndra02 wants to merge 1 commit into
Conversation
|
On On |
A descriptor whose only use is an s_buffer_load is a raw buffer to the host; descriptor_data fell through to "a scalar memory read as data". Upstream reports 771 -> 0 such failures and +231 programs translated. From upstream PR Marvisak#953 (c42cbb0), hand-ported. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Offline measurement (fork github.com/Machad3x/VIctory branch claude/gta6-shader-translation-crashes-705550, tip 9018be9) over 78 console shader containers dumped from an RTX 3080 Ti world run (victory translate --list --validate): MESH programs emitted 0 of 21 on the branch without these changes; 4 of 21 after cherry-picking MartinIndra02's c42cbb0 (PR #953: a descriptor whose only use is s_buffer_load is a raw buffer; 'a scalar memory read as data' 25 -> 0); 19 of 21 (18 validated) after one more change: when the console reuses a dead descriptor's SGPRs for loaded data, a join of that descriptor's address/format dword with a data edge no longer refuses the program (the join reads undefined on that edge, like the lane-mask join already does; commit 9018be9, assumption: the value is only read on paths from the data edge). One of the newly emitted mesh programs (mesh f841ad74ec6e7367) fails DXIL validation: "Container part 'Program Output Signature' does not match expected for module". Remaining mesh failures: structured buffer of unknown stride (2), descriptor read from the first lane of computed VGPRs (4 by group count), descriptor partly joined by control flow (1). In the game (4-minute runs, wave64 mesh allowed by a diagnostics switch) the world still shows only the background plus the loading artwork; one run ended with a title fault writing to a reserved never-committed address. |
…, Marvisak#956, Marvisak#587 and this branch's own changes
|
Reviewed The design reads right, and one detail in it deserves a sentence in the code, because it is what keeps the change honest: with One question about dword 2 when the descriptor is structured. Why it matters: that count is usually a loop bound, and translation success proves the program lowered, not that its loop ends where the console's does. A GPU test in the style of Two smaller things:
|
|
Offline count with this PR on top of the #439 stack (RTX 5070 Ti host, 32-lane waves) Tree: Input: the 6,633 mesh programs the title created in one run, from my own copy. Command:
With this PR applied, Not tested in a title run. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Independent verification at
AI-assisted verification on local RTX 5070 Ti + WARP; no game data. |
`smem` reads an `s_buffer_load` through a raw view of the descriptor when the tracked use is an SRV, and through a constant buffer for every other kind. The arm added for Marvisak#953 annotated the size query as a raw view for any use but a CBV, so a descriptor used as a UAV, or one loaded from a resource heap (neither of which `used_kind` reports), asked for the dimensions of a view its load never reads. Found by the Codex review of the change. No program in the title's 26,148 is affected: the offline A/B is unchanged (862 -> 571 refusals, 291 emitted, 0 newly refused). 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
A descriptor dword read only as data no longer stops the program: when no instruction uses it, the table's range names its kind (eight dwords is an image, else a structured or raw buffer), and an SMEM buffer load of a descriptor reads it as a raw buffer view. A constant buffer's descriptor read as data stays refused. Pixel inputs of packed 16-bit values now pair each packed row with its unlisted partner row, as the console's input table does, instead of refusing a packed input half no element holds. Ported from Marvisak/VIctory Marvisak#1067, Marvisak#953 and Marvisak#176. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…sak#704 + Marvisak#1511 Conflicts in crates/victory-shader/src/emit/lower.rs, resolved by hand: 1. descriptor_data: the bundle (Marvisak#953 s_buffer_load uses, Marvisak#1067 "read only as data" from the table's range) and Marvisak#180 (twin loads of the same dwords) both rewrote how the view's kind is found. Kept Marvisak#180's lookup (own uses, else a twin load's) and the bundle's handling of the use and of the unused case, plus the one case Marvisak#180 accepted that the bundle did not: an 8-dword load outside a table/heap range, taken as a 2D image (Marvisak#180's "image the program only measures"). Where both accepted a descriptor they built the same view. 2. phi joins: the bundle's arm (Marvisak#1073, a mask dword joined by ballot) and Marvisak#180's arm (a descriptor dword at a data join is undef) were inserted at the same place. Both kept, bundle first; the first needs a tracked lane mask, which a descriptor dword is not, so they do not overlap. 3. No textual conflict, did not compile: the bundle (Marvisak#306) gave `addr_val` a start position (`addr_val(l, start, k)`); Marvisak#180's compute image_sample_b arm read the bias with the old form at dword 0 through `as_float`. It now reads it as the bundle's sampleBias does: after the offset word when there is one, an f16 with a16 (`to_float`). This is the bias half of the Marvisak#160/Marvisak#180 interaction described in Marvisak#160 (comment) , which the bundle's offset forms already expose.
|
Automated triage for the maintainers. Closing because this change is already in descriptor_data handles s_buffer_load uses in main (Fields::Smem arm: structured by the used entry's stride, else raw; 75677cb). 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. |
Addresses #798
Summary
In
crates/victory-shader/src/emit/lower.rs,descriptor_datapreviously matched onlyFields::ImageandFields::Bufferon the using instructionui, causings_buffer_load*(Fields::Smem) buffer descriptor uses to fall through toa scalar memory read as data.Handling
Fields::Smem { .. } if un.starts_with("s_buffer_load")as a raw buffer ((11 | u, 0), still refusingResourceType::Cbv) eliminates 100% ofa scalar memory read as data(771 -> 0) and immediately translates +231 shaders on build 1.0.2.1 (+166mesh,+57vertex/pixel,+8compute), while routing the remaining subset that readsdword 0/1(address/format) accurately toa descriptor's address or format read as data.Full-corpus A/B (
victory translateon retail 1.0.2.1, 26,084 programs)main(ffe310e)c42cbb0)12,231 / 14,02712,288 / 14,027+571,441 / 2,5821,449 / 2,582+88,214 / 8,7138,380 / 8,713+16621,88622,117+231a scalar memory read as data7710-771Verification (Windows 11, RTX 3080
621.24, Rust1.98.1)emit::lower::tests::s_buffer_load_descriptor_size_reads_as_data(covers bothResourceType::Srvlowering andResourceType::Cbvrefusal).@fuzeofficlalin Shaders: a descriptor dword needed as another s_load's address stops translation (879 programs on 1.0.2.1) #798 (32-byte view returned[86, 32], 48-byte view returned[86, 48]).cargo test -p victory-shader --lib -- --test-threads=1: 121 passed, 0 failed, 1 ignoredcargo clippy -p victory-shader --all-targets -- -D warnings(default +--features diagnostics): 0 warningscargo xtask policy: 154 files okAggregate counts only; no game data used. AI-assisted; all builds and tests executed on my machine.