GPU: placed texture sizes leave out the filler words; the twin count is diagnostics-only and capped #409

Open
Esteban-V wants to merge 1 commit from upstream-pr/409 into a-publier
Esteban-V commented 2026-11-27 00:06:46 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by Esteban-V on 2026-11-27T00:06:46Z.


Commit c96b4f2 took words 1 and 13 of a placed texture's description (the layout's filler, where the title leaves stack garbage) out of the PLACED_TEXTURES key, but three other places still keyed on the raw 14 words. PLACED_RAW (crates/victory-gpu/src/resource.rs ~3046-3064) grows by one for each new (address, raw description) pair, is never trimmed, and is read only by the placed_filler_twins log line in copystat.rs:941, which is compiled only with feature = "diagnostics". The placed_bytes_from memo (resource.rs ~1363-1368) was keyed on the raw description and skipped when first == 0 or !held_only(), so those calls went through placed_bytes -> footprint -> texture_layout -> Texture::new every time. This keys all three on the filler-free description.

  • PLACED_RAW, PLACED_TWINS, placed_filler_twins and the counting (moved into count_twin) are now #[cfg(all(windows, feature = "diagnostics"))]. With diagnostics on, the set stops taking entries at 65,536 (twin_room).
  • The memo key is (without_filler(desc), first), with first forced to 0 when !held_only(); first == 0 uses it too and returns placed_bytes(desc), as before.
  • Spans::sizes (descriptor/host.rs 616, 648-655) is keyed on without_filler(desc), a new helper that texture_at and count_twin reuse.
  • The size cannot change: words 1 and 13 are the padding of ResourceDesc (resource.rs:87), and placed_bytes, footprint, texture_layout and read_from read only named fields.
  • The memo is per thread and never trimmed, but now bounded by distinct filler-free descriptions times at most 16 first levels (first_mip <= 15); the comment on PLACED_SIZES says so.
  • No behaviour change, except that the diagnostics-only twin count is gone from non-diagnostics builds (it was never logged there) and is capped. PLACED_TEXTURES keys, texture_at_made, shape_of / Views::shape and VICTORY_PLACED_FILLER are untouched.

Testing

  • Windows CI (windows-latest): Clippy, default tests and diagnostics tests pass (run).
  • Type-checked and clippy-clean for x86_64-pc-windows-msvc on a macOS host (cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings, default and --all-features).
  • Unit tests placed_sizes_leave_out_the_filler and placed_twins_stop_at_the_cap (diagnostics only) added next to a_placed_texture_is_kept_from_the_level_viewed; both compile under clippy --all-targets.
<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:5518912530 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/409). Originally posted by [Esteban-V](https://github.com/Esteban-V) on 2026-11-27T00:06:46Z. --- Commit c96b4f2 took words 1 and 13 of a placed texture's description (the layout's filler, where the title leaves stack garbage) out of the `PLACED_TEXTURES` key, but three other places still keyed on the raw 14 words. `PLACED_RAW` (`crates/victory-gpu/src/resource.rs` ~3046-3064) grows by one for each new (address, raw description) pair, is never trimmed, and is read only by the `placed_filler_twins` log line in `copystat.rs:941`, which is compiled only with `feature = "diagnostics"`. The `placed_bytes_from` memo (`resource.rs` ~1363-1368) was keyed on the raw description and skipped when `first == 0` or `!held_only()`, so those calls went through `placed_bytes` -> `footprint` -> `texture_layout` -> `Texture::new` every time. This keys all three on the filler-free description. - `PLACED_RAW`, `PLACED_TWINS`, `placed_filler_twins` and the counting (moved into `count_twin`) are now `#[cfg(all(windows, feature = "diagnostics"))]`. With diagnostics on, the set stops taking entries at 65,536 (`twin_room`). - The memo key is `(without_filler(desc), first)`, with `first` forced to 0 when `!held_only()`; `first == 0` uses it too and returns `placed_bytes(desc)`, as before. - `Spans::sizes` (`descriptor/host.rs` 616, 648-655) is keyed on `without_filler(desc)`, a new helper that `texture_at` and `count_twin` reuse. - The size cannot change: words 1 and 13 are the padding of `ResourceDesc` (`resource.rs:87`), and `placed_bytes`, `footprint`, `texture_layout` and `read_from` read only named fields. - The memo is per thread and never trimmed, but now bounded by distinct filler-free descriptions times at most 16 first levels (`first_mip` <= 15); the comment on `PLACED_SIZES` says so. - No behaviour change, except that the diagnostics-only twin count is gone from non-diagnostics builds (it was never logged there) and is capped. `PLACED_TEXTURES` keys, `texture_at_made`, `shape_of` / `Views::shape` and `VICTORY_PLACED_FILLER` are untouched. ## Testing - Windows CI (`windows-latest`): Clippy, default tests and diagnostics tests pass ([run](https://github.com/Esteban-V/VIctory-Belobug-AMD/actions/runs/45916876160)). - Type-checked and clippy-clean for `x86_64-pc-windows-msvc` on a macOS host (`cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings`, default and `--all-features`). - Unit tests `placed_sizes_leave_out_the_filler` and `placed_twins_stop_at_the_cap` (diagnostics only) added next to `a_placed_texture_is_kept_from_the_level_viewed`; both compile under clippy `--all-targets`.
lvndrpup commented 2026-11-27 05:00:23 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by lvndrpup on 2026-11-27T05:00:23Z.

Review: COMMENTED


Checked at 056e123 on an RTX 3060 Ti 8 GB, Windows 11 build 26300, Rust 1.98.1, debug:

victory-gpu cargo test --lib cargo clippy --all-targets -- -D warnings
default features 397 passed, 0 failed, 34 ignored (placed_sizes_leave_out_the_filler among them) clean
--all-features 447 passed, 0 failed, 34 ignored (placed_twins_stop_at_the_cap too) clean

I also checked the claim that the size cannot change against ResourceDesc (resource.rs:87, repr(C)). After dimension the u64 alignment leaves 4 bytes of padding (word 1). The fields end at byte 52 and the struct's 8-byte alignment pads it to 56 (word 13). Those are exactly the two words without_filler zeroes, and every other word is a named field.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:review:6083685697 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/409#pullrequestreview-6083685697). Originally posted by [lvndrpup](https://github.com/lvndrpup) on 2026-11-27T05:00:23Z. **Review:** COMMENTED --- Checked at `056e123` on an RTX 3060 Ti 8 GB, Windows 11 build 26300, Rust 1.98.1, debug: | `victory-gpu` | `cargo test --lib` | `cargo clippy --all-targets -- -D warnings` | |---|---|---| | default features | 397 passed, 0 failed, 34 ignored (`placed_sizes_leave_out_the_filler` among them) | clean | | `--all-features` | 447 passed, 0 failed, 34 ignored (`placed_twins_stop_at_the_cap` too) | clean | I also checked the claim that the size cannot change against `ResourceDesc` (`resource.rs:87`, `repr(C)`). After `dimension` the `u64` `alignment` leaves 4 bytes of padding (word 1). The fields end at byte 52 and the struct's 8-byte alignment pads it to 56 (word 13). Those are exactly the two words `without_filler` zeroes, and every other word is a named field.
Esteban-V commented 2026-11-27 14:34:19 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by Esteban-V on 2026-11-27T14:34:19Z.


Thanks for checking the padding against ResourceDesc by hand, that's exactly the assumption the change depends on. And good to see both new tests passing on NVIDIA.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7220952233 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/409#issuecomment-7220952233). Originally posted by [Esteban-V](https://github.com/Esteban-V) on 2026-11-27T14:34:19Z. --- Thanks for checking the padding against `ResourceDesc` by hand, that's exactly the assumption the change depends on. And good to see both new tests passing on NVIDIA.
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/409:upstream-pr/409'
git switch 'upstream-pr/409'

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 'a-publier'
git merge --no-ff 'upstream-pr/409'
git switch 'upstream-pr/409'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/409'
git switch 'upstream-pr/409'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'upstream-pr/409'
git switch 'a-publier'
git merge --squash 'upstream-pr/409'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/409'
git switch 'a-publier'
git merge 'upstream-pr/409'
git push origin 'a-publier'
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
Belobug/VIctory-Belobug-AMD!409
No description provided.