Fix [fence 18446744073709551615 did not reach 348999] -> CopyTextureRegion subresource indices for partially resident mip chains #4126

Open
github-bot wants to merge 1 commit from github-bot/gh-4126 into main AGit
Owner

@⁠Vlosokjia on GitHub · 2026-11-30 16:24 UTC · original
Vlosokjia:fix/held-mip-region-copy → main · +99 −94 · 1 files · 1 commits · open

On v2026.11.30.01,v2026.11.30.02, v2026.11.30.03.I replayed the mission that had repeatedly failed with 0x80070057 and got past the crash with this patch. The original command-list close failure is recorded in #4047.

Change

If a host texture begins at guest mip 3, guest mip 3 is host mip 0. The direct CopyTextureRegion path still used the guest index, which could select a smaller mip or one outside the allocation. Resolve both endpoints independently through resource::host_target, including the source used to calculate readback footprints. Compare the resolved indices for self-copies. When the primary destination lacks a mip, a placed twin that holds it can still receive the copy.

This extends the placed-twin handling from 523485ba. The related report #3849 shows the same HRESULT with partial mip chains in use, though its release log does not identify the failing command. The cross-format BC copy reported in #2914 is a separate failure.

Verification

  • Built the Windows release executable with locked dependencies and tested the previously crashing mission on an RTX 5070 Ti.
  • The existing a_copy_into_a_held_copy_takes_its_own_level test passed in isolation.
  • The full GPU test target is blocked by two existing card_pass calls in host.rs that omit the sixth argument.
**@⁠Vlosokjia** on GitHub · 2026-11-30 16:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4126) `Vlosokjia:fix/held-mip-region-copy` → `main` · +99 −94 · 1 files · 1 commits · open On v2026.11.30.01,v2026.11.30.02, v2026.11.30.03.I replayed the mission that had repeatedly failed with `0x80070057` and got past the crash with this patch. The original command-list close failure is recorded in #4047. ## Change If a host texture begins at guest mip 3, guest mip 3 is host mip 0. The direct `CopyTextureRegion` path still used the guest index, which could select a smaller mip or one outside the allocation. Resolve both endpoints independently through `resource::host_target`, including the source used to calculate readback footprints. Compare the resolved indices for self-copies. When the primary destination lacks a mip, a placed twin that holds it can still receive the copy. This extends the placed-twin handling from 523485ba. The related report #3849 shows the same HRESULT with partial mip chains in use, though its release log does not identify the failing command. The cross-format BC copy reported in #2914 is a separate failure. ## Verification - Built the Windows release executable with locked dependencies and tested the previously crashing mission on an RTX 5070 Ti. - The existing `a_copy_into_a_held_copy_takes_its_own_level` test passed in isolation. - The full GPU test target is blocked by two existing `card_pass` calls in `host.rs` that omit the sixth argument.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 16:27:28 +00:00
github-bot changed title from Fix CopyTextureRegion subresource indices for partially resident mip chains to Fix [fence 18446744073709551615 did not reach 348999] -> CopyTextureRegion subresource indices for partially resident mip chains 2026-11-30 17:37:20 +00:00
Author
Owner

@⁠shurhundo on GitHub · 2026-12-01 02:48 UTC · original

crate::texture::card_writes(list, dst.resource, to, Some(dst.footprint.offset as u32)) at list.rs:1825 passes the title-absolute subresource offset, not the dst_sub resolved two lines above by host_target() for exactly this case (a host allocation starting at a later title mip). card_writes forwards it straight into TiledLevels::with_level, which expects a level relative to the host texture's own mip count and returns 0 once level >= self.levels — so for a partially-resident mip chain, the on-demand-tile zeroing step silently no-ops for the level actually being written. The fence crash this PR fixes is fixed, but the destination level can now land the title's copy over un-zeroed tile memory instead of the zeroed backing the old (non-partial-residency) path relied on. Suggest Some(dst_sub) in place of Some(dst.footprint.offset as u32) there.

**@⁠shurhundo** on GitHub · 2026-12-01 02:48 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4126#issuecomment-7299018728) `crate::texture::card_writes(list, dst.resource, to, Some(dst.footprint.offset as u32))` at `list.rs:1825` passes the title-absolute subresource offset, not the `dst_sub` resolved two lines above by `host_target()` for exactly this case (a host allocation starting at a later title mip). `card_writes` forwards it straight into `TiledLevels::with_level`, which expects a level relative to the host texture's own mip count and returns 0 once `level >= self.levels` — so for a partially-resident mip chain, the on-demand-tile zeroing step silently no-ops for the level actually being written. The fence crash this PR fixes is fixed, but the destination level can now land the title's copy over un-zeroed tile memory instead of the zeroed backing the old (non-partial-residency) path relied on. Suggest `Some(dst_sub)` in place of `Some(dst.footprint.offset as u32)` there.
Author
Owner

@⁠Vlosokjia on GitHub · 2026-12-01 05:38 UTC · original

crate::texture::card_writes(list, dst.resource, to, Some(dst.footprint.offset as u32)) at list.rs:1825 passes the title-absolute subresource offset, not the dst_sub resolved two lines above by host_target() for exactly this case (a host allocation starting at a later title mip). card_writes forwards it straight into TiledLevels::with_level, which expects a level relative to the host texture's own mip count and returns 0 once level >= self.levels — so for a partially-resident mip chain, the on-demand-tile zeroing step silently no-ops for the level actually being written. The fence crash this PR fixes is fixed, but the destination level can now land the title's copy over un-zeroed tile memory instead of the zeroed backing the old (non-partial-residency) path relied on. Suggest Some(dst_sub) in place of Some(dst.footprint.offset as u32) there.

@⁠shurhundo

Thanks for checking this. You’re right that card_writes gets the original subresource index. It only reaches with_level for on-demand tiled textures, which always start at mip 0 and keep the original index. For a host texture starting at a later mip, card_writes returns before reaching with_level. That’s why I’m keeping the call as is in this PR.

**@⁠Vlosokjia** on GitHub · 2026-12-01 05:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4126#issuecomment-7301979035) > `crate::texture::card_writes(list, dst.resource, to, Some(dst.footprint.offset as u32))` at `list.rs:1825` passes the title-absolute subresource offset, not the `dst_sub` resolved two lines above by `host_target()` for exactly this case (a host allocation starting at a later title mip). `card_writes` forwards it straight into `TiledLevels::with_level`, which expects a level relative to the host texture's own mip count and returns 0 once `level >= self.levels` — so for a partially-resident mip chain, the on-demand-tile zeroing step silently no-ops for the level actually being written. The fence crash this PR fixes is fixed, but the destination level can now land the title's copy over un-zeroed tile memory instead of the zeroed backing the old (non-partial-residency) path relied on. Suggest `Some(dst_sub)` in place of `Some(dst.footprint.offset as u32)` there. @⁠shurhundo Thanks for checking this. You’re right that card_writes gets the original subresource index. It only reaches with_level for on-demand tiled textures, which always start at mip 0 and keep the original index. For a host texture starting at a later mip, card_writes returns before reaching with_level. That’s why I’m keeping the call as is in this PR.
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 origin '+refs/pull/4126/head:github-bot/gh-4126'
git switch 'github-bot/gh-4126'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4126'
git switch 'github-bot/gh-4126'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4126'
git switch 'github-bot/gh-4126'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4126'
git switch 'main'
git merge --squash 'github-bot/gh-4126'
git switch 'main'
git merge --ff-only 'github-bot/gh-4126'
git switch 'main'
git merge 'github-bot/gh-4126'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4126
No description provided.