Shaders: reconstruct image descriptor dword 0 as a heap-slot proxy #1845
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1847"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by AdamRchd on 2026-11-24T23:19:42Z.
Summary
Reconstructs image descriptor dword 0 (the GPU base address) using
heap_index(site, first, false)indescriptor_data()so bound image base addresses do not remainVal::Missingwhen compared or propagated through vector instructions (such asv_cmpx_gt_u32feeding branch conditions).Changes
crates/victory-shader/src/emit/lower.rs: reconstruct image dword 0 viaheap_indexindescriptor_data().crates/victory-shader/src/emit/diff_tests.rs: addimage_descriptor_address_read_as_data_translatesregression test.Verification
cargo test -p victory-shadercargo clippy/cargo xtask policy11eeb27c2d15980dtranslates and validates cleanly, and confirmeda descriptor's address or format read as datano longer appears in a 120s game run.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:52:21Z.
Review: CHANGES_REQUESTED
Does not compile after merging into current main (
70564ae):cargo test -p victory-shader --locked→ error[E0308] at crates/victory-shader/src/emit/lower.rs:4037 — one match arm returns a 2-tuple(({integer}, u32), Option<_>)where the others return the 3-tuple(({integer}, u32), Option<{integer}>, u32). The new heap-slot-proxy arm in theui.fieldsmatch is missing the third element (the stride/known_stride value the other arms produce). One-line fix: add the matching third element to that arm. Reproduced locally; happy to re-test after the fix.Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T23:23:03Z.
At
a0553ee(onmain70564ae)victory-shaderdoesn't compile:The
Fields::Smemarm, which reads a buffer through scalar loads, still returns a pair; theImageandBufferarms now return(props, image, known_stride). By analogy with theBufferarm it would be(props, None, used.stride), unless the proxy should not apply to scalar-loaded buffers. I didn't run the tests because of this.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by CaravelaLabs on 2026-11-24T23:38:34Z.
@AdamRchd, @upipibi already has the compile break: the scalar-load arm still returns a pair, so
victory-shaderdoes not build. Same error here, heada0553eemerged onto main70564ae(Linux, rustc 1.98.1). The tests did not start.The image change behind that error is a separate problem, and fixing the pair would not touch it. Dword 0 is filled with the heap-slot index of the load: the table pointer plus the byte offset, shifted right by 5. That is which slot was loaded, not the texture's base address. A null descriptor and a live one in the same slot become the same value, and on a bound heap that value is not zero, so
dword 0 > 0takes the non-null side either way. The new test only checks that lowering returns Ok. It sits in the Windows-only diff tests, so it did not run here.AI-assisted; checked on this machine.
Imported from Marvisak/VIctory. Originally posted by AdamRchd on 2026-11-25T00:09:47Z.
Thanks for catching both issues — I've pushed an update addressing them on top of
70564ae:Fields::Smemcompile break (E0308): updated theFields::Smemarm incrates/victory-shader/src/emit/lower.rsto return the 3-tuple(props, None, used.stride)matching the updateddescriptor_data()destructuring.heap_index— a null descriptor and a live one in the same slot share the same slot index. Switched image dword 0 tofield(self, 0)(width fromgetDimensions()), which is0for null/unbound SRVs and>= 1for live descriptors sodword_0 > 0null checks behave accurately.image_descriptor_dword0_width_proxy_null_check_lowersincrates/victory-shader/src/emit/lower.rs's#[cfg(test)]module (not gated onwindows), checking lowering success,DXBC/DXILcontainer structure, andnonuniform_handles == 0, and updated the comments indiff_tests.rs.Checked
cargo xtask policy(clean); thestride_testsandgathers_at_a_levelfailures were already present onmainat70564ae.Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T00:25:30Z.
Re-checked
485a943on the RTX 3070 (driver 616.56, Windows 11, debug).cargo test -p victory-shader --lockedgives 209 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA failures onmain(the twostride_testsheap-buffer reads andgathers_at_a_level_match_the_hardware). It builds again, andimage_descriptor_dword0_width_proxy_null_check_lowerspasses.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T07:25:34Z.
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main(conflict incrates/victory-shader/src/emit/lower.rs). It will be reviewed again once it is rebased.From the earlier needs-work note, still open: show the title only null-tests descriptor dword 0 and limit the lowering to that pattern (keep the refusal elsewhere), justify or drop the
stride << 16dword 1, drop the re-braced arms, and make the description match the code.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T12:11:27Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
485a9439ontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.