[pr-fix][rendering] darner-gpu: OMSetRenderTargets takes at most eight render targets #427

Open
qnjk wants to merge 1 commit from qnjk/Darner:list-omset-render-targets-bound into main
First-time contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: the console-side OMSetRenderTargets took the title's count and used it as a length. The one-range form built the handles by hand and, past its inline eight, fell off the fixed array into the heap:

    handles_vec = (0..u64::from(count)).map(|i| first + 128 * i).collect();   // list.rs:3185 before
    

    and the other form took the title's own count elements (items(handles, count)). The count then reached State::set_targets and BoundTargets::restore, which bind one view per handle. D3D12 takes at most D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT (8) render targets, so a count of u32::MAX asked collect() for 32 GB — whose refused allocation is handle_alloc_error, an abort the run's filters do not see — and any count past eight named more views than the host command list accepts. Eight is already the file's own knowledge: thin::targets clamps the same argument (thin.rs:919), and both range_buf and BoundTargets::restore's inline are eight long.

  • This change takes the count as at most RENDER_TARGETS (8, documented as D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT) before any handle is built, in one helper both forms go through, and refuses the excess the way thin::targets does — silently, keeping the first eight. The helper exists because state::targets cannot be reached without a host command list, so the bookkeeping had to be testable on its own.

How it was tested

  • Tested revision: e233b4d (one commit on f3840d7).
  • Commands and results:
    • cargo test --locked -p darner-gpu --lib — 1757 passed, 0 failed, 81 ignored. (One earlier run on this tree failed watch::tests::ask_once_by_res_splits_reservations_without_refusals, one of the two pre-existing parallel-suite flakes; it passes alone and also fails on unmodified f3840d7 in the same worktree.)
    • New test list::tests::render_target_counts_past_eight_take_the_first_eight pins the bookkeeping without a GPU or a title: the eight views that follow the first on the one-range form from a count of nine, the first eight handles of the title's own sixteen-element array, the first eight from a count of u32::MAX (read from the eight-element array it really is), and an empty slice for a null array on both forms.
    • Fail-before, with the bound put back to the old unbounded count:
      list::tests::render_target_counts_past_eight_take_the_first_eight panicked at list.rs:4726:
        assertion `left == right` failed
          left:  [16384, 16512, 16640, 16768, 16896, 17024, 17152, 17280, 17408]
         right: [16384, 16512, 16640, 16768, 16896, 17024, 17152, 17280]
      
      (nine handles from a count of nine — the heap-vector path the fix removes.)
    • cargo clippy --locked -p darner-gpu --all-targets -- -D warnings passes.
  • Changes a default: no. A count of eight or fewer behaves exactly as before.
  • A/B result, for a change of a default (on for everyone) or a speed claim: not applicable — no default changes and no speed claim.
  • Gates run on that revision:
    • Gate 1, cargo clippy --workspace --all-targets --locked -- -D warnings: passes.
    • Gate 2, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.
    • Gate 3, cargo test --workspace --locked: not green on this machine, and not because of this change. Three pre-existing failures, each covered by an open pull request: darner-gpu stands still in parallel on the test deadlock #224 describes, and serially finishes 1772 passed and 1 failed (pipeline::make::tests::a_capped_draw_waits_once_then_drops, which passes on its own) beside the order-dependent flakes of #150; darner-shader fails emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders, whose fixture #227 fixes.
  • Gameplay, when relevant: no gameplay run. The title never legitimately asks for more than eight render targets, so a run cannot show the difference; the test does.
  • Shader wave sizes tested, when relevant: not applicable.
  • Hardware dependence: none.
  • Coverage gaps: the debug-layer refusal and the host list's Close failure that followed are not reproduced (no adapter); the test pins the count that reaches the bookkeeping. The OMSetRenderTargets entry points themselves are not called (they need a host command list).

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
    • Not run in gameplay: no legitimate title asks for more than eight, so the failure cannot be reached in a normal session. The evidence is the test, which fails on main.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md. (cargo xtask policy: 555 files ok.)
  • 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: #15 and #220 change crates/darner-gpu/src/list.rs as well. Neither appears to touch state::targets or the render-target count in its description; they are listed so a reviewer can check for a conflict. No open or closed issue mentions OMSetRenderTargets or a render-target count.
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: the console-side `OMSetRenderTargets` took the title's `count` and used it as a length. The one-range form built the handles by hand and, past its inline eight, fell off the fixed array into the heap: ```rust handles_vec = (0..u64::from(count)).map(|i| first + 128 * i).collect(); // list.rs:3185 before ``` and the other form took the title's own `count` elements (`items(handles, count)`). The count then reached `State::set_targets` and `BoundTargets::restore`, which bind one view per handle. D3D12 takes at most `D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT` (8) render targets, so a count of `u32::MAX` asked `collect()` for 32 GB — whose refused allocation is `handle_alloc_error`, an abort the run's filters do not see — and any count past eight named more views than the host command list accepts. Eight is already the file's own knowledge: `thin::targets` clamps the same argument (`thin.rs:919`), and both `range_buf` and `BoundTargets::restore`'s `inline` are eight long. - This change takes the count as at most `RENDER_TARGETS` (8, documented as `D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT`) before any handle is built, in one helper both forms go through, and refuses the excess the way `thin::targets` does — silently, keeping the first eight. The helper exists because `state::targets` cannot be reached without a host command list, so the bookkeeping had to be testable on its own. ## How it was tested - Tested revision: `e233b4d` (one commit on `f3840d7`). - Commands and results: - `cargo test --locked -p darner-gpu --lib` — 1757 passed, 0 failed, 81 ignored. (One earlier run on this tree failed `watch::tests::ask_once_by_res_splits_reservations_without_refusals`, one of the two pre-existing parallel-suite flakes; it passes alone and also fails on unmodified `f3840d7` in the same worktree.) - New test `list::tests::render_target_counts_past_eight_take_the_first_eight` pins the bookkeeping without a GPU or a title: the eight views that follow the first on the one-range form from a count of nine, the first eight handles of the title's own sixteen-element array, the first eight from a count of `u32::MAX` (read from the eight-element array it really is), and an empty slice for a null array on both forms. - Fail-before, with the bound put back to the old unbounded count: ``` list::tests::render_target_counts_past_eight_take_the_first_eight panicked at list.rs:4726: assertion `left == right` failed left: [16384, 16512, 16640, 16768, 16896, 17024, 17152, 17280, 17408] right: [16384, 16512, 16640, 16768, 16896, 17024, 17152, 17280] ``` (nine handles from a count of nine — the heap-vector path the fix removes.) - `cargo clippy --locked -p darner-gpu --all-targets -- -D warnings` passes. - Changes a default: no. A count of eight or fewer behaves exactly as before. - A/B result, for a change of a default (on for everyone) or a speed claim: not applicable — no default changes and no speed claim. - Gates run on that revision: - Gate 1, `cargo clippy --workspace --all-targets --locked -- -D warnings`: passes. - Gate 2, `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passes. - Gate 3, `cargo test --workspace --locked`: **not green on this machine, and not because of this change.** Three pre-existing failures, each covered by an open pull request: `darner-gpu` stands still in parallel on the test deadlock #224 describes, and serially finishes 1772 passed and 1 failed (`pipeline::make::tests::a_capped_draw_waits_once_then_drops`, which passes on its own) beside the order-dependent flakes of #150; `darner-shader` fails `emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders`, whose fixture #227 fixes. - Gameplay, when relevant: no gameplay run. The title never legitimately asks for more than eight render targets, so a run cannot show the difference; the test does. - Shader wave sizes tested, when relevant: not applicable. - Hardware dependence: none. - Coverage gaps: the debug-layer refusal and the host list's `Close` failure that followed are not reproduced (no adapter); the test pins the count that reaches the bookkeeping. The `OMSetRenderTargets` entry points themselves are not called (they need a host command list). ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - Not run in gameplay: no legitimate title asks for more than eight, so the failure cannot be reached in a normal session. The evidence is the test, which fails on `main`. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. (`cargo xtask policy`: 555 files ok.) - [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: #15 and #220 change `crates/darner-gpu/src/list.rs` as well. Neither appears to touch `state::targets` or the render-target count in its description; they are listed so a reviewer can check for a conflict. No open or closed issue mentions `OMSetRenderTargets` or a render-target count. - Replaces or overlaps: none found
The console-side OMSetRenderTargets took the title's count as a length: the
one-range form sized a heap vector with it (`collect()`, so a count of
u32::MAX asked for 32 GB, and a refused allocation aborts the process rather
than panicking), and on either form the count reached `State::set_targets`,
where `BoundTargets::restore` binds one view per handle. D3D12 takes at most
D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT (8) render targets: the debug layer
refuses a command naming more, the host list then fails its `Close`, and
`Host::close`'s recovery ends the run.

Eight is what this file already knows: `thin::targets` clamps the same
argument with `(count as usize).min(8)`, and `BoundTargets::restore` binds at
most eight. Take the count as at most `RENDER_TARGETS` (8) before the handles
are built, in a helper (`target_handles`) that both forms go through, so
neither can size an allocation past 8 handles or name more than eight views.
The excess is refused as `thin::targets` refuses it, silently, keeping the
first eight.

render_target_counts_past_eight_take_the_first_eight pins the bookkeeping:
the eight views that follow the first on the one-range form from a count of
nine, the first eight of the title's own array, the first eight from a count
of u32::MAX, and nothing for a null array.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'list-omset-render-targets-bound:qnjk-list-omset-render-targets-bound'
git switch 'qnjk-list-omset-render-targets-bound'

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 'qnjk-list-omset-render-targets-bound'
git switch 'qnjk-list-omset-render-targets-bound'
git rebase 'main'
git switch 'main'
git merge --ff-only 'qnjk-list-omset-render-targets-bound'
git switch 'qnjk-list-omset-render-targets-bound'
git rebase 'main'
git switch 'main'
git merge --no-ff 'qnjk-list-omset-render-targets-bound'
git switch 'main'
git merge --squash 'qnjk-list-omset-render-targets-bound'
git switch 'main'
git merge --ff-only 'qnjk-list-omset-render-targets-bound'
git switch 'main'
git merge 'qnjk-list-omset-render-targets-bound'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!427
No description provided.