[pr-tests][shaders] Test the isolated LDS add lowering with its switch set for the test #186

Closed
Remorce wants to merge 1 commit from Remorce/Darner:pr-lds-isolated-add-test into main
Contributor

Why: main's darner-shader tests fail on every run on a GPU, because this test still expects a lowering that is now off by default. Anyone running the gates in AGENTS.md gets a failure that has nothing to do with their change, and the lowering has no test that actually runs. This change makes the test set the switch itself and check both sides. The suite gets one failure closer to clean, and the lowering stays covered while it's off.

Contributor role (optional)

  • Fluxer ID: Remorce#4039

What it changes

emit::wave64_tests::lds_shared_atomic_add_producer_executes_wave32_on_hardware came with the isolated LDS add lowering (merge 10c532c1) and expects the program to lower to WaveSize(32). Commit 68cb7c85 then put that lowering behind DARNER_LDS_ISOLATED_ADD=1, off by default. The test never sets the switch, so it now gets WaveSize(64) and fails on every run:

assertion `left == right` failed: lds_shared_atomic_add_producer: expected recovered WaveSize(32)
  left: Some(64)
 right: Some(32)

The switch is read once per process through a OnceLock, and a test cannot safely set the process environment while other tests run. So lds_isolated_add() (in emit/lower.rs) now checks a thread-local test setting first. with_test_lds_isolated_add(enabled, f) sets it for the length of f. This is the pattern lds::with_test_write_only_ok already uses for DARNER_LDS_WRITE_ONLY_OK. Both the setting and the helper are #[cfg(test)].

The test now checks both sides of the switch:

  1. Off: the program stays at WaveSize(64) on a 32-lane host.
  2. On: it lowers to 32 lanes and sums correctly on hardware, for 0, 1, 31, 32, 33, 63 and 64 active lanes. These are the original test's checks.

Outside tests nothing changes: the switch is still read from the environment once, off unless it is exactly 1, and the list of switches in the shader cache key is unchanged. As with any change under crates/darner-shader/src, the translator source hash changes too, so cached translations are rebuilt once even though none of them comes out different.

Threading the setting through lower::Parts instead would touch about 60 places that build one, for a switch that only tests need to set. So this follows the existing test-override pattern.

How it was tested

  • Tested revision: bf21435b on 57dea7f2. The pull request's commit 751d9105 has the same tree; only the commit message changed.
  • Commands and results:
    • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.
    • cargo xtask policy: "asset policy: 553 files ok".
    • cargo test --locked -p darner-shader --lib lds_shared_atomic_add_producer_executes_wave32_on_hardware: 1 passed. On 57dea7f2 it fails as quoted above.
    • cargo test --workspace --locked --no-fail-fast: 3309 passed, 1 failed, 120 ignored. The darner-shader lib tests: 555 passed, 1 failed, 15 ignored. On 57dea7f2 they had 554 passed and 2 failed: this test, and the one below.
    • The remaining failure, emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders ("DXIL validation failed: Not all elements of output SV_Depth were written"), fails the same way on 57dea7f2 alone, and this change does not touch it.
  • Gameplay: not relevant. The change is test-only, and the game runs as before.
  • Shader wave sizes tested: 32 (the lowered program on a 32-lane host) and 64 (the default, checked without running).
  • Coverage gaps: none known.

Checklist

  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none found that touch this test or the switch. Several open pull requests change emit/lower.rs or emit/wave64_tests.rs, and none of their diffs mentions the test, lds_isolated_add or DARNER_LDS_ISOLATED_ADD.
**Why:** main's `darner-shader` tests fail on every run on a GPU, because this test still expects a lowering that is now off by default. Anyone running the gates in AGENTS.md gets a failure that has nothing to do with their change, and the lowering has no test that actually runs. This change makes the test set the switch itself and check both sides. The suite gets one failure closer to clean, and the lowering stays covered while it's off. ## Contributor role (optional) - Fluxer ID: Remorce#4039 ## What it changes `emit::wave64_tests::lds_shared_atomic_add_producer_executes_wave32_on_hardware` came with the isolated LDS add lowering (merge 10c532c1) and expects the program to lower to `WaveSize(32)`. Commit 68cb7c85 then put that lowering behind `DARNER_LDS_ISOLATED_ADD=1`, off by default. The test never sets the switch, so it now gets `WaveSize(64)` and fails on every run: ``` assertion `left == right` failed: lds_shared_atomic_add_producer: expected recovered WaveSize(32) left: Some(64) right: Some(32) ``` The switch is read once per process through a `OnceLock`, and a test cannot safely set the process environment while other tests run. So `lds_isolated_add()` (in `emit/lower.rs`) now checks a thread-local test setting first. `with_test_lds_isolated_add(enabled, f)` sets it for the length of `f`. This is the pattern `lds::with_test_write_only_ok` already uses for `DARNER_LDS_WRITE_ONLY_OK`. Both the setting and the helper are `#[cfg(test)]`. The test now checks both sides of the switch: 1. Off: the program stays at `WaveSize(64)` on a 32-lane host. 2. On: it lowers to 32 lanes and sums correctly on hardware, for 0, 1, 31, 32, 33, 63 and 64 active lanes. These are the original test's checks. Outside tests nothing changes: the switch is still read from the environment once, off unless it is exactly `1`, and the list of switches in the shader cache key is unchanged. As with any change under `crates/darner-shader/src`, the translator source hash changes too, so cached translations are rebuilt once even though none of them comes out different. Threading the setting through `lower::Parts` instead would touch about 60 places that build one, for a switch that only tests need to set. So this follows the existing test-override pattern. ## How it was tested - Tested revision: `bf21435b` on `57dea7f2`. The pull request's commit `751d9105` has the same tree; only the commit message changed. - Commands and results: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean. - `cargo xtask policy`: "asset policy: 553 files ok". - `cargo test --locked -p darner-shader --lib lds_shared_atomic_add_producer_executes_wave32_on_hardware`: 1 passed. On `57dea7f2` it fails as quoted above. - `cargo test --workspace --locked --no-fail-fast`: 3309 passed, 1 failed, 120 ignored. The `darner-shader` lib tests: 555 passed, 1 failed, 15 ignored. On `57dea7f2` they had 554 passed and 2 failed: this test, and the one below. - The remaining failure, `emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders` ("DXIL validation failed: Not all elements of output SV_Depth were written"), fails the same way on `57dea7f2` alone, and this change does not touch it. - Gameplay: not relevant. The change is test-only, and the game runs as before. - Shader wave sizes tested: 32 (the lowered program on a 32-lane host) and 64 (the default, checked without running). - Coverage gaps: none known. ## Checklist - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none found that touch this test or the switch. Several open pull requests change `emit/lower.rs` or `emit/wave64_tests.rs`, and none of their diffs mentions the test, `lds_isolated_add` or `DARNER_LDS_ISOLATED_ADD`.
lds_shared_atomic_add_producer_executes_wave32_on_hardware came with the
isolated LDS add lowering (merge 10c532c1) and expects WaveSize(32). Since
68cb7c85 put that lowering behind DARNER_LDS_ISOLATED_ADD=1, off by
default, the test gets WaveSize(64) and fails on every run.

lds_isolated_add() now takes a test's setting for its thread first
(with_test_lds_isolated_add, as lds::with_test_write_only_ok does for
DARNER_LDS_WRITE_ONLY_OK). The test checks both sides: off, the program
stays at WaveSize(64); on, it lowers to 32 lanes and sums correctly on
hardware. Outside tests nothing changes: the switch is read from the
environment once, off unless it is 1.
Owner

Main already has this fix: f622896d (pushed today) gives the test a per-thread TEST_LDS_ISOLATED_ADD override and turns the switch on for it, so lds_shared_atomic_add_producer_executes_wave32_on_hardware passes on current main. That's why this branch now conflicts in lower.rs and wave64_tests.rs.

What this PR adds beyond that is the check that the program stays WaveSize(64) with the switch off. If you want that in, rebase on main and keep only that part, using main's existing TEST_LDS_ISOLATED_ADD guard (wave64_tests.rs around line 4260) instead of a second one.

Main already has this fix: f622896d (pushed today) gives the test a per-thread `TEST_LDS_ISOLATED_ADD` override and turns the switch on for it, so `lds_shared_atomic_add_producer_executes_wave32_on_hardware` passes on current main. That's why this branch now conflicts in lower.rs and wave64_tests.rs. What this PR adds beyond that is the check that the program stays `WaveSize(64)` with the switch off. If you want that in, rebase on main and keep only that part, using main's existing `TEST_LDS_ISOLATED_ADD` guard (wave64_tests.rs around line 4260) instead of a second one.
Author
Contributor

Closing: main fixed this test in f622896d (f622896d1a), so this one is no longer needed.

Closing: main fixed this test in f622896d (https://git.gtahub.st/TrustNo1/Darner/commit/f622896d1a8a7e15b600865fa68648430cf4d6da), so this one is no longer needed.
Remorce closed this pull request 2026-12-04 02:48:56 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!186
No description provided.