GPU: require texture copy footprints to fit a complete row #3034

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

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 04:12 UTC · original
andrewpozdnakov7-jpg:codex2/footprint-row-pitch → main · +52 −4 · 1 files · 1 commits · open

CopyTextureRegion uses PlacedFootprint to size upload staging and to read back the requested rows. Each calculation now checks that the full unpadded row fits within RowPitch. For block compression, the row size is the number of horizontal blocks times the bytes per block.

The same synthetic footprint test on 63bcca4 accepts an undersized pitch for both RGBA8 and BC1 through both calculations. This revision rejects both, including a small region within the incomplete footprint. Exact-fit and padded pitches still return the expected row offsets and final byte count. The regression tests the layout calculations directly.

Valid guest upload and readback tests and the full Agility WARP GPU suite passed (247 passed, one ignored). The diff applies cleanly beside either #3006 or #3022. Strict GPU Clippy with and without diagnostics and the repository asset policy passed. This follows the optional row-width notes in #3006 and #3022. D3D12_SUBRESOURCE_FOOTPRINT Coordination claim

AI-assisted with Codex. Synthetic inputs.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 04:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/3034) `andrewpozdnakov7-jpg:codex2/footprint-row-pitch` → `main` · +52 −4 · 1 files · 1 commits · open `CopyTextureRegion` uses `PlacedFootprint` to size upload staging and to read back the requested rows. Each calculation now checks that the full unpadded row fits within `RowPitch`. For block compression, the row size is the number of horizontal blocks times the bytes per block. The same synthetic footprint test on `63bcca4` accepts an undersized pitch for both RGBA8 and BC1 through both calculations. This revision rejects both, including a small region within the incomplete footprint. Exact-fit and padded pitches still return the expected row offsets and final byte count. The regression tests the layout calculations directly. Valid guest upload and readback tests and the full Agility WARP GPU suite passed (247 passed, one ignored). The diff applies cleanly beside either #3006 or #3022. Strict GPU Clippy with and without diagnostics and the repository asset policy passed. This follows the optional row-width notes in #3006 and #3022. [D3D12_SUBRESOURCE_FOOTPRINT](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_subresource_footprint) [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) AI-assisted with Codex. Synthetic inputs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:27:03 +00:00
Author
Owner

@⁠pawrenity on GitHub · 2026-11-26 05:04 UTC · original

VERIFY-3034: verified 374aade on NVIDIA GeForce RTX 4070, Windows 11 (MSVC). No defects found.

  • Regression: the new a_placed_footprint_pitch_covers_a_complete_row, with only the test hunk applied to origin/main 63bcca4, fails with accepted short row pitches: [(28, true, true), (71, true, true)] (both RGBA8 and BC1 accepted through bytes() and rows()). It passes at head.
  • cargo test -p victory-gpu --lib at head: 230 passed, 1 ignored, 2 failed. The two failures are dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, which also fail on main on this card (capped view heap). The existing footprint, upload and readback tests in resource::tests all pass.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings is clean, with and without --features diagnostics.
  • Trial merge onto origin/main 63bcca4 is clean.

Review (reading only): the row size ceil(width / block) * element matches D3D12_SUBRESOURCE_FOOTPRINT (RowPitch must hold at least one full row; BC rows are counted in 4x4 blocks). The test values check out: 65 RGBA8 texels are 260 bytes, 129 BC1 texels are 33 blocks of 8 = 264 bytes, and one texel fewer gives exactly 256. Buffer footprints (format 0) and the internally generated copyable_footprints layouts never fall below the row size, so they are unaffected. When a pitch is too short, the upload path (list.rs ~726) returns without recording, as it already does for an unsized format. The readback path (list.rs ~853) reports it as refused!("a region outside its footprint"), so the log reason is slightly loose for this case but the behaviour is correct.

AI-assisted (Claude Code).

**@⁠pawrenity** on GitHub · 2026-11-26 05:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/3034#issuecomment-7183151581) VERIFY-3034: verified `374aade` on NVIDIA GeForce RTX 4070, Windows 11 (MSVC). No defects found. - Regression: the new `a_placed_footprint_pitch_covers_a_complete_row`, with only the test hunk applied to origin/main `63bcca4`, fails with `accepted short row pitches: [(28, true, true), (71, true, true)]` (both RGBA8 and BC1 accepted through `bytes()` and `rows()`). It passes at head. - `cargo test -p victory-gpu --lib` at head: 230 passed, 1 ignored, 2 failed. The two failures are `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`, which also fail on main on this card (capped view heap). The existing footprint, upload and readback tests in `resource::tests` all pass. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` is clean, with and without `--features diagnostics`. - Trial merge onto origin/main `63bcca4` is clean. Review (reading only): the row size `ceil(width / block) * element` matches D3D12_SUBRESOURCE_FOOTPRINT (RowPitch must hold at least one full row; BC rows are counted in 4x4 blocks). The test values check out: 65 RGBA8 texels are 260 bytes, 129 BC1 texels are 33 blocks of 8 = 264 bytes, and one texel fewer gives exactly 256. Buffer footprints (format 0) and the internally generated `copyable_footprints` layouts never fall below the row size, so they are unaffected. When a pitch is too short, the upload path (`list.rs` ~726) returns without recording, as it already does for an unsized format. The readback path (`list.rs` ~853) reports it as `refused!("a region outside its footprint")`, so the log reason is slightly loose for this case but the behaviour is correct. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 06:18 UTC · original

Automated triage for the maintainers.

PlacedFootprint::bytes and rows (crates/victory-gpu/src/resource.rs) now return None when RowPitch is shorter than one unpadded row (ceil(width / block) * element). Both CopyTextureRegion paths in list.rs pass the title's footprint to the host with only its offset changed. Without this check, a too-short pitch reaches host D3D12, which requires RowPitch to hold a full row (public D3D12_SUBRESOURCE_FOOTPRINT docs). With it, the upload path skips the copy and the readback path refuses it, as both already do for unsized formats. main already checks the 256-byte pitch alignment, so this completes the validation. Unsized formats (element returns None) behave as before. I checked the test values: 65 RGBA8 texels = 260 bytes, and 129 BC1 texels = 33 blocks of 8 bytes = 264. The change is defensive, since a well-formed title call never hits it, but it is small and keeps an invalid call away from the host driver. It sits beside #3006 and #3022 in the same file, and the author says it applies cleanly with either.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 06:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/3034#issuecomment-7184297322) <!-- victory-triage v1 head=374aadedaef9d6c7edf7eeb4316b3f481e62e202 verdict=merge-candidate at=2026-11-26T06:24:00Z --> Automated triage for the maintainers. `PlacedFootprint::bytes` and `rows` (`crates/victory-gpu/src/resource.rs`) now return `None` when `RowPitch` is shorter than one unpadded row (`ceil(width / block) * element`). Both `CopyTextureRegion` paths in `list.rs` pass the title's footprint to the host with only its offset changed. Without this check, a too-short pitch reaches host D3D12, which requires `RowPitch` to hold a full row (public `D3D12_SUBRESOURCE_FOOTPRINT` docs). With it, the upload path skips the copy and the readback path refuses it, as both already do for unsized formats. `main` already checks the 256-byte pitch alignment, so this completes the validation. Unsized formats (`element` returns `None`) behave as before. I checked the test values: 65 RGBA8 texels = 260 bytes, and 129 BC1 texels = 33 blocks of 8 bytes = 264. The change is defensive, since a well-formed title call never hits it, but it is small and keeps an invalid call away from the host driver. It sits beside #3006 and #3022 in the same file, and the author says it applies cleanly with either. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
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/3034/head:github-bot/gh-3034'
git switch 'github-bot/gh-3034'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3034'
git switch 'github-bot/gh-3034'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3034'
git switch 'github-bot/gh-3034'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3034'
git switch 'main'
git merge --squash 'github-bot/gh-3034'
git switch 'main'
git merge --ff-only 'github-bot/gh-3034'
git switch 'main'
git merge 'github-bot/gh-3034'
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/Marvisak--VIctory!3034
No description provided.