GPU/texture: detile only the pages written since the last refresh (VICTORY_TEXTURE_PAGES) #1130
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1130
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1130"
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?
@Lkxex on GitHub · 2026-11-25 21:04 UTC · original
Lkxex:texture-page-detile→main· +437 −123 · 2 files · 1 commits · openGPU/texture: detile only the pages written since the last refresh (VICTORY_TEXTURE_PAGES)
Problem
crates/victory-gpu/src/texture.rsdocumented its own shortcut: "a changedetiles the whole texture, not the pages written." In the write-watched
refresh path,
refresh_timedread the entire texture (copy_mappedofsizebytes) and detiled all of it (self.detile(read)), even when thetitle had written only a handful of 64 KiB pages. On 8 GB cards this is a
large part of the "preparing" time (issue reports ~1.6 s/frame) and of the
bytes touched per refresh. The write-watch already reported which pages
changed (
watch::writesreturns per-page write times), but that informationwas only used as an all-or-nothing "did anything change" gate.
Change
victory-formats: addLayout::detile_window, which detiles a window ofthe texture's tiled memory (starting at byte
window, shorter than thewhole texture) into the staging buffer, leaving bytes outside the window
untouched. The walk is restricted per row and per run, so only elements
whose tiled address falls in the window are written.
victory-gpu: record, per staging buffer, the byte range each subresource(mip + slice * mips) occupies in title memory (
ranges), including theshared tail block. Add
refresh_pages, which merges the pages writtensince the last asking into 64 KiB runs, reads each run once, and detiles
the overlapping subresources via
detile_window. Wire it intorefresh_timed's write-watched branch (only whenprevious != 0), fallingback to the whole-texture path on 3D textures, on-demand levels, missing
range tables, or
VICTORY_TEXTURE_PAGES=0.Correctness
previous == 0) and the partly-mapped (hash) path keepthe whole-texture behaviour, so a texture's first sight and streaming-in
mips are unaffected.
ranges = Noneand take the existing whole-texture path.VICTORY_TEXTURE_PAGES=0restores the previous behaviour.tests;
detile_windowof a whole window reproducesdetile.Limitations
and detiled in the synthetic CPU path, not measured frame time.
granular GPU copies are a separate follow-up.
Assisted By NetherySiloX
@LeonardoS11 on GitHub · 2026-11-25 23:44 UTC · original
Measured here carried over an integration branch (current main plus a few open PRs), RTX 3080 Ti 12 GB, Windows 11 26200, Series S profile, the fixed room of the prologue, 300 s runs with pipelines cached.
Written with Claude Code.
@LeonardoS11 on GitHub · 2026-11-26 05:52 UTC · original
A correction to my comment above, and a defect report. I wrote that the image did not change in our room; that room has almost no texture the title rewrites, so it could not have shown this. Reading the code since (not yet confirmed by a picture; we are checking that now):
In
4720e4c(VICTORY_TEXTURE_PAGES, on by default),refresh_pages()incrates/victory-gpu/src/texture.rsintersects each subresource's range with a run of written pages (let a = rs.max(run_start as u64); let b = re.min((run_start + run_len) as u64);, around line 1344), but the ranges are built as offsets in the texture's memory (base + start, base = slice * slice_size, around line 1741) whilerun_startis an absolute title address (page * PAGE, clamped toself.memory). The two never meet, soa >= bfor every subresource and no page is detiled, yet the function still marks the texture dirty and returnsSome(read). A watched texture the title rewrites would keep its old texels from its second refresh on, and the frame stops paying for the detile it skips, which also flatters any timing taken with the switch on.The fix we carry: intersect in the texture's offsets —
let run_at = run_start - self.memory as usize;, thena = rs.max(run_at),b = re.min(run_at + run_len), slicingbuf[(a - run_at)..(b - run_at)]— and pass that offsetatodetile_window(), which takes the window's offset within the texture.VICTORY_TEXTURE_PAGES=0reads the whole texture as before.Written with Claude Code.
@D4rkGh057 on GitHub · 2026-11-26 21:21 UTC · original
Hi, I read the diff of this PR (code only, I have not built or run it). I am looking at it for the plan in avatarmanz/VIctory-7900XTX#358, and the page-granular detile looks like a better fit than the per-mip split proposed there. Two questions I could not answer from the diff:
walk. The checkrow_base + bytes <= starttreats a row asbytescontiguous bytes of tiled memory. In a swizzled layout the elements of one row are spread over several blocks, so the runs of a row can sit well pastrow_base + bytes. Could a row whose runs fall inside the window be skipped and keep stale data? Was it tried with a partial window on a texture wider than one block?detilewould settle question 1. Also,Swizzle::SW_256B_Sdisappears from the list intiled_chunks_match_element_offsets_with_odd_row_pitches: is that intended?Smaller notes:
copy_runs(the 8/16/32-byte chunked path) is removed and the full detile used it, which may be an artifact of the branch base; andlast.askedis set before detiling, so pages whose detile fails are logged but not retried.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.