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

Open
Vlosokjia wants to merge 1 commit from upstream-pr/4126 into main
Vlosokjia commented 2026-11-30 16:24:57 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Vlosokjia on 2026-11-30T16:24:57Z.


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.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5569284168 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4126). Originally posted by [Vlosokjia](https://github.com/Vlosokjia) on 2026-11-30T16:24:57Z. --- 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 commented 2026-11-30 18:39:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Vlosokjia on 2026-11-30T18:39:12Z.


@trustno1-coder that fixes issue that is there since 3 versions

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7288166962 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4126#issuecomment-7288166962). Originally posted by [Vlosokjia](https://github.com/Vlosokjia) on 2026-11-30T18:39:12Z. --- @trustno1-coder that fixes issue that is there since 3 versions
shurhundo commented 2026-12-01 02:48:40 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by shurhundo on 2026-12-01T02:48:40Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7299018728 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4126#issuecomment-7299018728). Originally posted by [shurhundo](https://github.com/shurhundo) on 2026-12-01T02:48:40Z. --- `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.
Vlosokjia commented 2026-12-01 05:38:13 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Vlosokjia on 2026-12-01T05:38:13Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7301979035 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4126#issuecomment-7301979035). Originally posted by [Vlosokjia](https://github.com/Vlosokjia) on 2026-12-01T05:38:13Z. --- > `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 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/4126:upstream-pr/4126'
git switch 'upstream-pr/4126'

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