Skip to content

GPU diagnostics: count texture data without row padding - #2528

Open
andrewpozdnakov7-jpg wants to merge 3 commits into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex1/probe-texture-rows
Open

andrewpozdnakov7-jpg wants to merge 3 commits into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex1/probe-texture-rows

Conversation

@andrewpozdnakov7-jpg

@andrewpozdnakov7-jpg andrewpozdnakov7-jpg commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The diagnostic probe reads the first slice of a 1D or 3D UAV texture after a dispatch. Its dword count and sample values came from pitched rows, so padding changed the denominator and could appear in the sample.

Count the unpadded bytes of each row and stop the mapped span at the last texel. A final partial dword is zero-extended. D3D12 footprint row size and pitch

The same synthetic test uses a 2 × 2 R32 layout with 256-byte row pitch, three nonzero values, and sentinel bytes in the padding. The original counting logic from 67e8ae1 reports 127 of 128 dwords set. ca477f2 reports 3 of 4 and returns all four texels in order. It also passes the unpadded final-row and partial-dword cases.

Windows/WARP serial GPU suite passed with 199 passed and 1 ignored under both D3D12 debug flag settings. Strict GPU Clippy in both modes and the asset policy passed. AI-assisted. The change affects diagnostic statistics.

Coordination claim

Please preserve the Git author when reapplying the change. If you fold the code or test into another commit, please add this trailer.

Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. Re-reviewed after the rebase (0e48cc8, merges cleanly into current main). The diagnostics probe for 1D/3D UAV textures after a dispatch (State::probe_written in crates/victory-gpu/src/draw.rs) now reads from the footprint's offset and stops at the last texel. written_texture_words counts only each row's unpadded bytes and zero-extends a final partial dword, so row padding no longer inflates the dword count or appears in the sample. The span length (rows - 1) * pitch + row_bytes is bounded by the readback footprint, and element handles block-compressed rows. The change is diagnostics-only (behind feature = "diagnostics"), and the unit test covers padded rows, an unpadded final row and a partial dword. CI: check passing.


Generated by Claude Code

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor Author

Updated the branch for 67e8ae1. The same native Windows test gets 127 of 128 nonzero dwords from the old counting logic and 3 of 4 after the patch. The test checks all four texels, the unpadded final row and a partial dword. Serial Windows/WARP GPU suite 199 passed and 1 ignored in both debug flag settings. Strict GPU Clippy in both modes and policy passed.

Updated commit

If you fold the change or test into another commit, please preserve the Git author or add this trailer.

Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor Author

I resolved the test-module conflict with #1778 and kept both fixtures in 0e48cc8.

The same synthetic 256-byte-pitch fixture run with the unchanged counting logic in f3578e3 counts 127 of 128 dwords set. The update counts 3 of 4 without including row padding, preserves the four sample values, and passes the short final-row and partial-dword controls. The upstream sampler-heap test also passes.

Both serial Windows/WARP GPU suites passed with 244 tests and one ignored. GPU Clippy with and without diagnostics and asset policy passed.

Please retain the Git author when carrying the fix or tests. If folded into another commit, please add this trailer.

Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Code review and hardware + WARP verification at head 0e48cc8cf3a3 merged cleanly onto main (63bcca43c6a0):

  • Code review: Scoped cleanly to #[cfg(feature = "diagnostics")] probe_written in crates/victory-gpu/src/draw.rs. Computing rows = Height.div_ceil(block) and row_bytes = Width.div_ceil(block) * element via resource::element handles both 4x4 block-compressed and uncompressed formats, and sizing the mapped slice to (rows - 1) * pitch + row_bytes removes 256-byte row-pitch padding noise and avoids reading past the end of subresource 0's readback buffer. written_texture_words slices each row to row[..row_bytes], zero-pads partial trailing <4-byte rows without bleeding across rows, and safely returns None for formats not covered by resource::element.
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • cargo xtask policy: 191 files ok
    • cargo clippy --locked -p victory-gpu --tests -- -D warnings (default + --features diagnostics): 0 warnings
    • Default draw::tests (VICTORY_D3D12_DEBUG=1): 20/20 passed
    • RTX 5090 (--features diagnostics, VICTORY_D3D12_DEBUG=1, draw::tests): 21/21 passed (including written_texture_probe_counts_texels_without_row_padding)
    • WARP (--features diagnostics, VICTORY_D3D12_DEBUG=1, draw::tests): 21/21 passed

Looks clean and ready to merge.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants