feat(shader): translate texture size queries through four descriptor dwords #567
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!567
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-563"
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?
@Sandile-0511 on GitHub · 2026-11-28 05:13 UTC · original
Sandile-0511:shader/size-query-four-dwords→main· +515 −25 · 5 files · 1 commits · openWhat this changes
Refs #411
Main took most of #411 while this was being written: since
5cb68393and3a435b56a sizing load takes its kind and its sizes from the view the program also samples, which covers 708 of the 723 programs thatb998bb65refused for "a view address field the table gives as 0: a buffer's stride or swizzle". This is the rest: size queries of a view the program does not use, which still fall to the view addresses. On main2f4d81e0that is 43 of my 21,608 shaders (41 pixel, 2 vertex): 15 are refused, 28 translate with the size missing.Lower::image_half(crates/victory-shader/src/emit/lower.rs) takes a four-dword load as an image's first half when it is at a whole descriptor (the computed part an index shifted left by 5 as the offset register, or none), every reader keeps only bits the view addresses hold of an image or tests dword 1 against 0, and together they read a size from dword 2 and the view's first level from dword 3. Any other load stays a buffer's and keeps the refusal it has on main.Lower::seen_bitsfollowss_bfe_u32of a constant field, and for an image's dword 1 countss_cmp_eq_i32/s_cmp_lg_i32with 0 as seeing no bit.descriptor_datasets since5cb68393), which no other reader sees, when the entry's dword 3 is not 0 (a texture view's never is). This is the casedocs/native-host.mdnames as "still refused, rightly for now".Things to know before reviewing:
How it was tested
cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victorycargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warningsAlso:
cargo test -p victory-shader -p victory-hle: 424 library tests pass. Four are new (gfx_refusal_tests): the three forms and the eight-dword form translate; one refusal per field class, a join, and tests that are not of dword 1 against 0; a size without the level, the level without a size, the last level for the first; the waterfall loop, with a shift by 4 and an index added into the base refused. All are hand-written programs.cargo test -p victory-gpu --lib(Metal, M5): 450 pass. New:heap_tests::a_compute_shader_sizes_textures_from_the_first_half_of_their_descriptorsreads, per lane, the widths of textures 5 and 1 wide, of a view from level 1 of one 24 wide and of an empty entry: 5, 1, 12, 0. Without the mark the first two read 0.cargo xtask policy: 404 files ok.-j 4, against main2f4d81e0): 14 newly translated (12 pixel, 2 vertex), one of them bound from the first world frame on; 0 regressions; 28 changed; 1 stops at a later refusal ("a lane mask holding lanes elsewhere read as data: a program input"). The 43 lines that differ are exactly the programs in which the rule accepts a load, and nothing is refused for "a buffer's stride or swizzle" any more.write_placeddoes not count as a read, so that edge gets 0 (the shape of #256). Those lanes now keep the size. Checked with a throwaway print on clean main: in all 28 a join edge carrying the refused size gets 0, and that join is the kept old value of a guarded write.bf6031225eee4640; changed and bound in the world,0149c1fd291ed305and15133db0bc1b8b1f.victory-hle'smodules::dsp::tests::dump_captures_the_titles_ir_blocks_and_outputfailed in 4 of 7 runs of the x86_64 suite here, and in 2 of 8 on clean main (it sharesVICTORY_DUMP_DSPwith tests running beside it).host_posix::sync::tests::wait_on_address_handles_sizes_timeouts_and_isolated_wakesfailed twice while other builds were running. The suite passes on re-run.Checklist
VICTORY_*variable and documented (none added)@AnastasisKon on GitHub · 2026-11-28 18:04 UTC · original · approved these changes
Reviewed and verified locally on head
fc52e3bb(worktree /private/tmp/review-563):The reader-based image_half detection is conservative (whole-descriptor offset via s_lshl_b32-by-5, size fields plus first level read, dword-1 null test), the refused-case pins cover dword 0 / format / tiling / 32-bit fields / joins / wrong compares, and the docs record both guesses (null-view semantics, image-or-nothing entry) and the 4k+1-width shortcut explicitly, which is what AGENTS.md asks for. The null-test format-bit trick (bit 20 set when entry dword 3 != 0) is documented in both mod.rs and native-host.md.
Note: the branch is behind upstream/main by two README-only commits (
bf9cdf17,26817285); no code conflict, mergeable as-is. Approving.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.