Speed up tiled texture copies with fixed-size chunks #186
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!186
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-186"
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?
@venglov on GitHub · 2026-11-24 22:19 UTC · original
venglov:perf/tiled-texture-copy-chunks→main· +118 −29 · 1 files · 1 commits · openSummary
The GPU upload path calls
Layout::detileon the submitting thread when a sampled texture changes. The existing implementation specializes the width of 8-, 16-, and 32-byte copies, but still builds checked byte ranges for both sides of each copy.For aligned, equal-sized runs, slice the linear row once and copy through fixed-size byte arrays. Each copy then only needs to index the tiled side. Both copy directions use the same traversal and validation. Short final runs, irregular layouts, and linear copies use byte ranges.
The fixed-width copies already present in this fork specialize the copy length. This PR also removes the per-run linear slice checks. The related proposals split larger subresources into row bands (#92) and reduce time waiting for remaps (#175). The fixed-width changes in VIctory #603 and VIctory #1097 use byte slices for individual copies.
Measurements
Single-threaded, synthetic uploads on an Apple M1 Pro. The Windows x64 build used Rust 1.98.1 targeting
x86_64-pc-windows-gnuand ran under Wine 11.21 with Rosetta. Baseline is2119b0e. The before and after routines run in the same process, alternate batch order, and compare the entire output against each other before timing.A second Wine run reproduced the tiled detile savings within one percentage point. The reverse copy took 10–34% less time across the same tiled cases. The native arm64 macOS build took 9–34% less time across the ten tiled detile cases.
Windows x64 with MSVC
The same benchmark ran twice on a GitHub-hosted Windows VM (AMD EPYC 9V45, Rust 1.98.1,
x86_64-pc-windows-msvc). The ranges report the two process medians. Each run checked the full output byte-for-byte before timing. Benchmark logOn this runner the gains were concentrated in the smaller tiled cases. The larger cases generally moved by a few percent or less. Gameplay frame time remains unmeasured.
Validation
cargo test -p victory-formats --lockedpassed on macOS and for Windows x64 under Wine (25 passed, four ignored on each).blake3/pureto avoid needing MASM on macOS.cargo xtask policyandgit diff --checkpassed.AI-assisted implementation and verification.
Reproduce the synthetic detile benchmark
From the checkout, extract
crates/victory-formats/src/texture.rsfrom2119b0eintobase.rsand copy the changed file topatch.rsin a temporary directory. Save the program below beside them and compile withrustc +1.98.1 --edition 2024 -O -A dead_code bench.rs. For the Wine timings, add--target x86_64-pc-windows-gnu -C linker=x86_64-w64-mingw32-gccand run the resulting executable with Wine.@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:19 UTC · original · edited 2026-11-24 22:21 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
07259b3ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@LeonardoS11 on GitHub · 2026-11-25 03:07 UTC · original
Tested on another NVIDIA card, picture checked against
main.diagbuild withdiagnostics.mainatc96b4f2with only this PR's commit cherry-picked (no conflict), no environment switches.c96b4f2: walls, the mesh in the window, the characters and the posters on the wall are the same or better; nothing missing thatmainshows. No device loss in 330 s.One run only; the "walls missing in some launches" of
maindid not show in it.(Runs and screenshots by me on the hardware above; comparison and this note written with Claude Code.)
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.