Shaders: lower's tests in their own file, under the policy's size limit #3095

Open
neonbyte1 wants to merge 1 commit from upstream-pr/3097 into main
neonbyte1 commented 2026-11-26 07:46:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-26T07:46:37Z.


emit/lower.rs is 520,563 bytes on main, 3,725 under the asset policy's 512 KiB per-file limit. Two open PRs grow it: #2968 by 601 bytes and #2977 by 3,097, which together leave about 27 bytes. The maintainer triage on #2977 suggested moving the tests out, so this does it on its own.

The mod tests block moves to emit/lower_tests.rs, still a child module of lower through #[path], so it keeps access to the private items it tests. Its contents are unchanged except for rustfmt's layout after losing one indentation level. lower.rs drops to 468,320 bytes.

Checks:

  • Tests: emit::lower::tests, 33 before and 33 after, all pass. Run under cargo xtask wine-test (#1218) on Linux: GE-Proton11-14 Wine, RTX 5090. These tests don't touch the GPU's results except through the optional DXIL validator.
  • Lint: cargo clippy --workspace --all-targets, with and without diagnostics, is clean, and cargo xtask policy passes.

No behaviour change.

AI-assisted (Claude); measured on my machine, no game data shared.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5506047916 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3097). Originally posted by [neonbyte1](https://github.com/neonbyte1) on 2026-11-26T07:46:37Z. --- `emit/lower.rs` is 520,563 bytes on `main`, 3,725 under the asset policy's 512 KiB per-file limit. Two open PRs grow it: #2968 by 601 bytes and #2977 by 3,097, which together leave about 27 bytes. The maintainer triage on #2977 suggested moving the tests out, so this does it on its own. The `mod tests` block moves to `emit/lower_tests.rs`, still a child module of `lower` through `#[path]`, so it keeps access to the private items it tests. Its contents are unchanged except for rustfmt's layout after losing one indentation level. `lower.rs` drops to 468,320 bytes. **Checks:** - **Tests:** `emit::lower::tests`, 33 before and 33 after, all pass. Run under `cargo xtask wine-test` (#1218) on Linux: GE-Proton11-14 Wine, RTX 5090. These tests don't touch the GPU's results except through the optional DXIL validator. - **Lint:** `cargo clippy --workspace --all-targets`, with and without `diagnostics`, is clean, and `cargo xtask policy` passes. No behaviour change. _AI-assisted (Claude); measured on my machine, no game data shared._
fuzeofficlal commented 2026-11-26 08:56:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T08:56:01Z.

Review: APPROVED


Verified 9bca0871 locally on Windows 11 x64:

  • cargo clippy --all-targets --locked -- -D warnings and cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: clean (3.36s / 4.11s).
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.33s).
  • cargo test -p victory-shader --lib --locked emit::lower::tests: 33 passed, 0 failed (0.02s).
  • rustfmt --edition 2024 --check crates/victory-shader/src/emit/lower_tests.rs: clean.

The production prefix of emit/lower.rs (468,320 bytes total) is byte-for-byte identical to main, #[cfg(test)] #[path = "lower_tests.rs"] mod tests; keeps lower::tests module visibility intact, and all 33 tests and helpers in emit/lower_tests.rs (47,450 bytes) match the original inline block aside from de-indentation and formatting. Both files sit comfortably under the 524,288-byte asset-policy limit.

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6071052403 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3097#pullrequestreview-6071052403). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T08:56:01Z. **Review:** APPROVED --- Verified `9bca0871` locally on Windows 11 x64: - `cargo clippy --all-targets --locked -- -D warnings` and `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings`: clean (`3.36s` / `4.11s`). - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.33s`). - `cargo test -p victory-shader --lib --locked emit::lower::tests`: 33 passed, 0 failed (`0.02s`). - `rustfmt --edition 2024 --check crates/victory-shader/src/emit/lower_tests.rs`: clean. The production prefix of `emit/lower.rs` (468,320 bytes total) is byte-for-byte identical to `main`, `#[cfg(test)] #[path = "lower_tests.rs"] mod tests;` keeps `lower::tests` module visibility intact, and all 33 tests and helpers in `emit/lower_tests.rs` (47,450 bytes) match the original inline block aside from de-indentation and formatting. Both files sit comfortably under the 524,288-byte asset-policy limit. LGTM.
Marvisak commented 2026-11-26 09:06:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T08:20:12Z.


Automated triage for the maintainers.

Merge candidate. The mod tests block of crates/victory-shader/src/emit/lower.rs moves to emit/lower_tests.rs, still a child of lower through #[path] under #[cfg(test)]. I compared the moved text with main's block, and it is identical apart from indentation and rustfmt's commas. This brings lower.rs to 468,320 bytes, well under xtask/src/policy.rs's MAX_FILE_SIZE (512 KiB), and it follows the *_tests.rs layout emit/mod.rs already uses. Open PRs that edit lower.rs's tests (#2968, #2977) will need a rebase after this lands.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7186470618 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3097#issuecomment-7186470618). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T08:20:12Z. --- <!-- victory-triage v1 head=9bca08710e6956fd65f9dfcb5d188f12a3f0e2e9 verdict=merge-candidate at=2026-11-26T08:17:31Z --> Automated triage for the maintainers. **Merge candidate.** The `mod tests` block of `crates/victory-shader/src/emit/lower.rs` moves to `emit/lower_tests.rs`, still a child of `lower` through `#[path]` under `#[cfg(test)]`. I compared the moved text with `main`'s block, and it is identical apart from indentation and rustfmt's commas. This brings `lower.rs` to 468,320 bytes, well under `xtask/src/policy.rs`'s `MAX_FILE_SIZE` (512 KiB), and it follows the `*_tests.rs` layout `emit/mod.rs` already uses. Open PRs that edit `lower.rs`'s tests (#2968, #2977) will need a rebase after this lands. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
potatoe0100 commented 2026-11-26 15:02:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by potatoe0100 on 2026-11-26T14:21:31Z.


Some numbers on why this should go in early in a batch. I counted across all 582 open merge candidates against main (63bcca4): 122 of them grow emit/lower.rs, by about 150 KB between them. Five go over the 512 KiB limit on their own once merged onto main: #166, #200, #1395, #2097 and #2723. Merging the 301 candidates that go in together cleanly, in PR order, leaves lower.rs at 555,490 bytes, so repository_passes_policy fails. With this PR first, lower.rs starts at 468,320.

One snag: GitHub isn't serving refs/pull/3097/head at the moment. git ls-remote lists the refs around it but not this one, so tooling that fetches PR heads by pull ref will skip this PR. The branch itself is fine (neonbyte1/VIctory pr/lower-tests at 9bca087).

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7194696297 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3097#issuecomment-7194696297). Originally posted by [potatoe0100](https://github.com/potatoe0100) on 2026-11-26T14:21:31Z. --- Some numbers on why this should go in early in a batch. I counted across all 582 open merge candidates against `main` (`63bcca4`): 122 of them grow `emit/lower.rs`, by about 150 KB between them. Five go over the 512 KiB limit on their own once merged onto `main`: #166, #200, #1395, #2097 and #2723. Merging the 301 candidates that go in together cleanly, in PR order, leaves `lower.rs` at 555,490 bytes, so `repository_passes_policy` fails. With this PR first, `lower.rs` starts at 468,320. One snag: GitHub isn't serving `refs/pull/3097/head` at the moment. `git ls-remote` lists the refs around it but not this one, so tooling that fetches PR heads by pull ref will skip this PR. The branch itself is fine (`neonbyte1/VIctory` `pr/lower-tests` at `9bca087`). AI-assisted (Claude).
futurepro62 commented 2026-11-26 15:02:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T14:41:33Z.


NVIDIA full-suite run, to go with the reports above by fuzeofficlal, since none of them names a GPU run. Tested exact head 9bca087 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 866 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: the_code_table_starts_after_the_instructions, vop3_conversion_modifiers_affect_the_lowering, the_24_bit_multiplies_lower_both_halves, sums_of_absolute_differences_lower, buffer_cache_invalidations_lower_as_no_ops, a_scalar_carry_chain_reaches_the_select, v_cndmask_accepts_uniform_and_constant_masks, perm_constant_selector_needs_no_int64, perm_dynamic_selector_needs_no_int64, a_descriptor_selected_by_scc_picks_its_heap_index, a_descriptor_loaded_only_for_its_size_takes_the_kind_of_its_reload, a_waterfall_loop_that_only_sizes_takes_the_kind_of_the_sampled_one, compute_spills_beside_a_descriptor_word_read_back, waterfall_loops_over_per_lane_descriptors_sample_with_each_lanes_own, waterfall_loops_over_descriptors_joined_per_lane_sample_with_each_lanes_own, an_address_half_set_where_only_lanes_that_never_run_skip_is_known, a_descriptor_skipped_only_by_lanes_that_never_run_needs_no_source, descriptors_joined_by_nested_control_flow_lower_to_one_uniform_handle, descriptors_reloaded_from_a_root_table_share_one_handle, scalar_bit_tests_lower, a_missing_value_stays_missing_through_two_live_joins, a_value_no_lane_from_its_edge_reads_needs_no_form, a_mask_joined_with_data_needs_a_uniform_join, a_scalar_result_needs_no_exec, guarded_or_modified_v_mov_b32_is_not_folded_as_constant, a_missing_value_on_a_path_no_lane_takes_is_dead, a_guarded_scalar_write_kills_a_stale_sgpr, buffer_formats_by_number, packed_buffer_formats_by_number, small_floats_widen_as_halves, packed_halves_fill_parameters_first_fit, ds_bpermute_wave64_preserves_32_lane_half, ds_bpermute_refuses_gds.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7195184014 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3097#issuecomment-7195184014). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T14:41:33Z. --- NVIDIA full-suite run, to go with the reports above by fuzeofficlal, since none of them names a GPU run. Tested exact head `9bca087` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **866 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `the_code_table_starts_after_the_instructions`, `vop3_conversion_modifiers_affect_the_lowering`, `the_24_bit_multiplies_lower_both_halves`, `sums_of_absolute_differences_lower`, `buffer_cache_invalidations_lower_as_no_ops`, `a_scalar_carry_chain_reaches_the_select`, `v_cndmask_accepts_uniform_and_constant_masks`, `perm_constant_selector_needs_no_int64`, `perm_dynamic_selector_needs_no_int64`, `a_descriptor_selected_by_scc_picks_its_heap_index`, `a_descriptor_loaded_only_for_its_size_takes_the_kind_of_its_reload`, `a_waterfall_loop_that_only_sizes_takes_the_kind_of_the_sampled_one`, `compute_spills_beside_a_descriptor_word_read_back`, `waterfall_loops_over_per_lane_descriptors_sample_with_each_lanes_own`, `waterfall_loops_over_descriptors_joined_per_lane_sample_with_each_lanes_own`, `an_address_half_set_where_only_lanes_that_never_run_skip_is_known`, `a_descriptor_skipped_only_by_lanes_that_never_run_needs_no_source`, `descriptors_joined_by_nested_control_flow_lower_to_one_uniform_handle`, `descriptors_reloaded_from_a_root_table_share_one_handle`, `scalar_bit_tests_lower`, `a_missing_value_stays_missing_through_two_live_joins`, `a_value_no_lane_from_its_edge_reads_needs_no_form`, `a_mask_joined_with_data_needs_a_uniform_join`, `a_scalar_result_needs_no_exec`, `guarded_or_modified_v_mov_b32_is_not_folded_as_constant`, `a_missing_value_on_a_path_no_lane_takes_is_dead`, `a_guarded_scalar_write_kills_a_stale_sgpr`, `buffer_formats_by_number`, `packed_buffer_formats_by_number`, `small_floats_widen_as_halves`, `packed_halves_fill_parameters_first_fit`, `ds_bpermute_wave64_preserves_32_lane_half`, `ds_bpermute_refuses_gds`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
neonbyte1 commented 2026-11-26 15:02:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-26T15:00:20Z.


@potatoe0100 thanks for the heads-up: GitHub had lost refs/pull/3097/head (only the merge ref existed). I re-pushed the same tree as 9e83d97 and the head ref is back. No content changed.

AI-assisted (Claude); no game data shared.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7195643293 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3097#issuecomment-7195643293). Originally posted by [neonbyte1](https://github.com/neonbyte1) on 2026-11-26T15:00:20Z. --- @potatoe0100 thanks for the heads-up: GitHub had lost `refs/pull/3097/head` (only the merge ref existed). I re-pushed the same tree as `9e83d97` and the head ref is back. No content changed. _AI-assisted (Claude); no game data shared._
Dukestar69 commented 2026-11-26 23:28:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T23:28:34Z.

Review: APPROVED


LGTM — verified on Windows against origin/main (63bcca4).

  • Moving emit::lower::tests into emit/lower_tests.rs cleanly brings lower.rs well under the 512 KiB asset-policy limit without altering any lowering logic or test coverage.
  • cargo test -p victory-shader --lib emit::lower::tests:: -- --test-threads=1: all passed.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081460214 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3097#pullrequestreview-6081460214). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T23:28:34Z. **Review:** APPROVED --- LGTM — verified on Windows against `origin/main` (`63bcca4`). - Moving `emit::lower::tests` into `emit/lower_tests.rs` cleanly brings `lower.rs` well under the 512 KiB asset-policy limit without altering any lowering logic or test coverage. - `cargo test -p victory-shader --lib emit::lower::tests:: -- --test-threads=1`: all passed. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
kilolimaVI commented 2026-11-29 11:07:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-29T11:07:46Z.


This one unblocks several others, so a merge-order data point. On main 63bcca4, lower.rs is 520,563 bytes, and #1315 (via kilolimaVI/VIctory shader/1315-on-main), #3716, #3617 and #3717 each push it toward or over the 524,288 limit once more than one lands. With this PR first, all five merge without conflicts in this order:

merged lower.rs
this PR 9e83d97 468,320
+ #1315 67fdc55 468,870
+ #3716 cd3cf73 470,483
+ #3617 8bfad4c 471,018
+ #3717 32a02eb 473,315

On that tree (d34cd37), on AMD Radeon 780M (RDNA3, driver 32.0.13022.3006): whole victory-shader lib 318 passed / 0 failed / 3 ignored, clippy --workspace --all-targets -D warnings and repository_passes_policy pass. Per fiestorra's census on #201, #1315 alone takes translation refusals from 220 to 25 of 26,084 programs.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7254899240 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3097#issuecomment-7254899240). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-29T11:07:46Z. --- This one unblocks several others, so a merge-order data point. On main `63bcca4`, `lower.rs` is 520,563 bytes, and #1315 (via `kilolimaVI/VIctory` `shader/1315-on-main`), #3716, #3617 and #3717 each push it toward or over the 524,288 limit once more than one lands. With this PR first, all five merge without conflicts in this order: | merged | `lower.rs` | |---|---| | this PR `9e83d97` | 468,320 | | + #1315 `67fdc55` | 468,870 | | + #3716 `cd3cf73` | 470,483 | | + #3617 `8bfad4c` | 471,018 | | + #3717 `32a02eb` | 473,315 | On that tree (`d34cd37`), on AMD Radeon 780M (RDNA3, driver 32.0.13022.3006): whole `victory-shader` lib 318 passed / 0 failed / 3 ignored, `clippy --workspace --all-targets -D warnings` and `repository_passes_policy` pass. Per fiestorra's census on #201, #1315 alone takes translation refusals from 220 to 25 of 26,084 programs. AI-assisted (Claude).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3097:upstream-pr/3097'
git switch 'upstream-pr/3097'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/3097'
git switch 'upstream-pr/3097'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3097'
git switch 'upstream-pr/3097'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3097'
git switch 'main'
git merge --squash 'upstream-pr/3097'
git switch 'main'
git merge --ff-only 'upstream-pr/3097'
git switch 'main'
git merge 'upstream-pr/3097'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3095
No description provided.