native: trace how host texture copies overlap (identical vs different layouts, owner changes) #355
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/355"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by m0rff on 2026-11-27T13:49:59Z.
Refs #352
One commit on
main. It only measures and changes nothing a draw samples. It is meant to show what the copies that #359's sharing and covered give-up leave behind are made of (#356: 7507 MiB of copies over 1566 MiB of distinct memory on a world load).What this adds
VICTORY_TRACE_TEXTURE_OVERLAP=1is off by default. When set, it logs once a second:overlap::excess), split into two kinds:Layout(dimensions, mips, element size, swizzle; not the format). Since #359, copies that also have the same host format at the same title address share one texture. They sit inTitle::copies_of, notTitle::textures, so they are not counted here. What this figure counts is the rest: another host format over the same layout, which one texture with views could serve, or the same pages reached through two title addresses (sharing goes by title address, this trace by pool offset).Layout, or another start over the same bytes. These could not share a texture.Overlap::take, an interval map updated after each upload insync_apply). An upload that takes bytes from another copy is counted by what that copy was:With the variable unset, the cost is one cached
OnceLockcheck per upload and per sync.Rebased on #359
an_upload_over_another_copy_counts_what_that_copy_wasfailed on top of #359 because its second texture had the same description over the same memory as the first, so #359 makes it share the first one's texture.realizeputs it incopies_of,note_uploadfinds no copy of its own and returns, and only two of the three kinds were counted. The trace is right about this: a key that shares is never uploaded on its own, so its ranges never change owner. The test now:How it was tested
overlap::tests::an_upload_takes_the_bytes_it_covers_from_their_last_owner,overlap::tests::the_excess_splits_into_identical_and_different_layouts,texture_tests::an_upload_over_another_copy_counts_what_that_copy_was.cargo test -p victory-hle -p victory -p victory-gpu -p xtask(victory-gpu native arm64: 415 passed, 6 ignored);cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warningsclean;cargo xtask policy: 399 files ok.VICTORY_TRACE_TEXTURE_SYNC=1is asked for on #356.Checklist
VICTORY_*variable, off by default, documented in docs/native-host.mddocs/native-host.md also says what #359's sharing can catch: two placed copies at one address never share, because
texture_placedreleases the copy of another description there before the new one is made, and the same description at the same address is already the same key.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:23:39Z.
#301 and #359 are on main now (
582670f1). I left this one out: on top of #359 its testan_upload_over_another_copy_counts_what_that_copy_wasfails (counts[(0, 0), (1, 4096), (1, 4096)]instead of three(1, 4096)), I think because #359 makes the identical copy share one texture. Could you rebase it on main and update the test? The trace itself looks fine and is off by default.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by m0rff on 2026-11-27T22:51:42Z.
@LakshanSivakumar rebased on main (
b998bb65) as one commit,10892d1b.You were right about the cause. The test's second texture had the same description over the same memory as the first, so #359 has it share the first one's texture.
realizeputs it incopies_ofinstead oftextures,note_uploadfinds no copy of its own, and nothing is counted, which gave[(0, 0), (1, 4096), (1, 4096)]. The trace is right to count nothing there: a key that shares a copy is never uploaded on its own, so its range never changes owner. I changed the test, not the trace. It now checks that a shared key counts nothing and is not counted in the budget again, and it gets the identical-layout case from B8G8R8A8 over RGBA8 (same layout, another host format, so a copy of its own). The swizzled copy and the released one stay as they were, one count each.The rebase also had conflicts with
give_up_coveredanduploaded_mipsfrom main. I kept both sides; the trace only adds lines next to them. The PR description now says what "identical" counts after #359. I'll mark this ready once CI is green.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T00:37:18Z.
Review: CHANGES_REQUESTED
Thanks for this PR! We're helping the maintainer clear the queue tonight, and main has moved a lot (the preview branch landed as
86cefd22, then a batch of PRs; main is nowa6a58361). This branch now conflicts with main incrates/victory-gpu/src/native/textures.rs.Could you merge current
maininto the branch (a merge commit is fine, no need to rebase) and resolve the conflict? Once GitHub shows it as mergeable and CI is green on the new head, we'll read it through and merge it if it holds up.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.