Join adjacent D3D12 barrier calls #1890

Open
Gauss999 wants to merge 1 commit from upstream-pr/1890 into main
Gauss999 commented 2026-11-29 01:46:27 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Gauss999 on 2026-11-29T01:46:27Z.


What it changes

  • Add VICTORY_JOIN_BARRIERS=1 as an opt-in. The default remains immediate ResourceBarrier, without batching allocation or resource retention; diagnostics builds can also use VICTORY_AB.
  • Wrap the host graphics list in Rec: adjacent barriers are held, then emitted in their original order before the next command, direct barrier, Close, Reset, or other Deref use.
  • Route five list paths and two texture paths through the wrapper, including the current clear_rtv and texture alias transitions that were not present in the original port.
  • Flush before a later call names an already-pending resource. Conflict identity covers transition, both aliasing sides (pResourceBefore and pResourceAfter), and UAV.
  • Acquire strong references for incoming resources before any flush, retain them through the deferred D3D12 call, and release them only after it.
  • Add a small/large resource-name index and per-frame asked/made call counters. This joins API calls only; it does not fold A→B→C into A→C or cancel transitions.

Sources: original replay implementation d3a6c2c, isolated port 195dd84, and conflict-index test 72b0a47. The unrelated VICTORY_UP_QUEUE copy-queue work is deliberately excluded.

The original source reports 2,490 barrier calls joined (1,619 upload-transition/next-aliasing pairs), saving 2.4 ms of 79.5 ms in replay5. That is a third-party replay result, with no in-game measurement or guaranteed gain here.

How it was tested

  • GPU and profile: not run locally; prepared through the GitHub editor.
  • Before/after: no local timing claimed. The replay figure above belongs to the source author.
  • Added seven tests: a 4,096-step conflict-index comparison, mock-sink grouping/order, repeated-resource flush, immediate-off and A/B-switch behavior, null-resource identity, opt-in parsing, and an available-device list/Close smoke test.
  • cargo test: not run in this environment. No build, clippy, fmt, WARP, Debug Layer, PIX, or game run is claimed.
  • Two independent static review passes found no remaining obvious static blocker in the final revision; this is not a compilation claim. Remaining coverage gap: production non-null COM identity/AddRef acquisition and automatic Deref/Close flushing still need runtime regressions.

Required before leaving Draft: run fmt, clippy and victory-gpu tests on Windows; add/run non-null resource retention and Deref/Close tests; exercise repeated A→B→C, aliasing-before/after and UAV cases under D3D12 Debug Layer; inspect PIX/event order; then A/B the same replay and an actual game with GPU/CPU timestamps and the asked/made counters.

Checked for overlap

  • Searched the current repository for VICTORY_JOIN_BARRIERS and inspected the source/downstream ports. Related downstream Draft: Dathinel/victory-4gb#49.
  • Kept this separate from transition folding such as Marvisak/VIctory#1382; this PR preserves every transition and its order.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5546546985 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1890). Originally posted by [Gauss999](https://github.com/Gauss999) on 2026-11-29T01:46:27Z. --- ## What it changes - Add `VICTORY_JOIN_BARRIERS=1` as an opt-in. The default remains immediate `ResourceBarrier`, without batching allocation or resource retention; diagnostics builds can also use `VICTORY_AB`. - Wrap the host graphics list in `Rec`: adjacent barriers are held, then emitted in their original order before the next command, direct barrier, `Close`, `Reset`, or other `Deref` use. - Route five list paths and two texture paths through the wrapper, including the current `clear_rtv` and texture alias transitions that were not present in the original port. - Flush before a later call names an already-pending resource. Conflict identity covers transition, both aliasing sides (`pResourceBefore` and `pResourceAfter`), and UAV. - Acquire strong references for incoming resources **before any flush**, retain them through the deferred D3D12 call, and release them only after it. - Add a small/large resource-name index and per-frame asked/made call counters. This joins API calls only; it does not fold A→B→C into A→C or cancel transitions. Sources: original replay implementation [d3a6c2c](https://github.com/dankxylese/leotux/commit/d3a6c2c3da8016da3063bd3cbc25c0c6498b687b), isolated port [195dd84](https://github.com/yaak192/Victory-Lap-NVIDIA/commit/195dd84357e9c7c67d98fde65fec0a9519ce921b), and conflict-index test [72b0a47](https://github.com/Dathinel/victory-4gb/commit/72b0a47e919f555282084c16e52088c3e5fa0a2d). The unrelated `VICTORY_UP_QUEUE` copy-queue work is deliberately excluded. The original source reports 2,490 barrier calls joined (1,619 upload-transition/next-aliasing pairs), saving **2.4 ms of 79.5 ms in replay5**. That is a third-party replay result, with no in-game measurement or guaranteed gain here. ## How it was tested - GPU and profile: **not run locally**; prepared through the GitHub editor. - Before/after: **no local timing claimed**. The replay figure above belongs to the source author. - Added seven tests: a 4,096-step conflict-index comparison, mock-sink grouping/order, repeated-resource flush, immediate-off and A/B-switch behavior, null-resource identity, opt-in parsing, and an available-device list/Close smoke test. - `cargo test`: **not run in this environment**. No build, clippy, fmt, WARP, Debug Layer, PIX, or game run is claimed. - Two independent static review passes found no remaining obvious static blocker in the final revision; this is not a compilation claim. Remaining coverage gap: production non-null COM identity/AddRef acquisition and automatic `Deref`/`Close` flushing still need runtime regressions. Required before leaving Draft: run fmt, clippy and `victory-gpu` tests on Windows; add/run non-null resource retention and `Deref`/`Close` tests; exercise repeated A→B→C, aliasing-before/after and UAV cases under D3D12 Debug Layer; inspect PIX/event order; then A/B the same replay and an actual game with GPU/CPU timestamps and the asked/made counters. ## Checked for overlap - [x] Searched the current repository for `VICTORY_JOIN_BARRIERS` and inspected the source/downstream ports. Related downstream Draft: [Dathinel/victory-4gb#49](https://github.com/Dathinel/victory-4gb/pull/49). - [x] Kept this separate from transition folding such as [Marvisak/VIctory#1382](https://github.com/Marvisak/VIctory/pull/1382); this PR preserves every transition and its order.
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/1890:upstream-pr/1890'
git switch 'upstream-pr/1890'

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/1890'
git switch 'upstream-pr/1890'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1890'
git switch 'upstream-pr/1890'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1890'
git switch 'main'
git merge --squash 'upstream-pr/1890'
git switch 'main'
git merge --ff-only 'upstream-pr/1890'
git switch 'main'
git merge 'upstream-pr/1890'
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
trustno1-coder/VIctory-NVIDIA!1890
No description provided.