GPU: create texture staging outside the global table lock #1157
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!1157
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1157"
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?
@fladit123 on GitHub · 2026-11-25 22:02 UTC · original
fladit123:fix/texture-staging-reservations→main· +486 −33 · 2 files · 2 commits · draftMotivation
The conventional texture staging path holds the global staging table lock through footprint preparation, pool checkout, buffer clearing, and D3D12 upload-buffer creation. Cached lookups for unrelated textures can therefore wait behind expensive creation work.
This change narrows the scope of the global lock without allowing duplicate creation for the same resource identity.
Implementation
OnceLock.Three permanent, deadline-bounded concurrency tests cover independent progress and single creation, failure and panic recovery, and concurrent removal across generations.
Test hooks are compiled only in test builds.
Synthetic performance measurements
The following measurements were obtained on the original pinned base (
d510ee4) and original runtime candidate (ca56ec0), before rebasing. They have not been repeated on the current base.Synchronized mixed workload
RTX 4060, two threads:
Fixed producer with free-running readers
Eight threads:
These latency reductions come with trade-offs. At eight threads, independent-hit p95 increased on both adapters, and producer throughput decreased by 10.90% on RTX 4060 and 15.12% on WARP.
Repeated paired throughput measurements
Twelve independent pairs per configuration, alternating execution order:
Churn showed substantial run-to-run variability, with buffer clearing dominating the instrumented time.
These results suggest that the main benefit is reducing interference between independent resources, rather than universally improving staging throughput.
No real-game FPS or frame-time improvement is claimed.
Validation on the current base
Base:
9c184b35b43de3455b74ac1770e1c8734a047810Candidate:
7f1685dd6a77b65983d6bebefb5ab7603dcc2592The two original patches were cherry-picked onto the current base.
git range-diffconfirmed patch equivalence.Environment:
Build:
cargo test --offline --locked -p victory-gpu --lib --release --features diagnostics --no-run -j 2Results:
Total: 16 successful test executions, including repeated execution of the three permanent tests. Zero failures, zero timeouts, and no reported hardware skips in these runs.
The injected creator panic is intentional and is handled by the recovery test.
Test executable SHA256:
48BBAE0E86F29F830EEAE5E0A0D9BABE838B7C0FDF92677D3D98D55545F491B5Additional checks:
git diff --check: passed.186 files ok, exit code 0, in the available sparse checkout.The test executable was compiled from a disposable source-only copy with the BCPack module declaration omitted. This exclusion is not part of the PR. A full unmodified workspace build has not been validated.
Previous validation
On the original runtime candidate, a graphical confirmation test read back 174,080 exact bytes per adapter with zero D3D12 debug-layer errors.
The existing WARP indirect-budget test failed at the same draw-order assertion in 19 of 30 independent baseline processes and 17 of 30 candidate processes. This test does not exercise texture staging.
Related issue: #888.
Interaction with other work
PR #995 introduces additional staging preparation, adoption, and pool changes. Its conventional staging path still retains the table lock in the inspected revision. Pending reservations would need to be considered when combining the two approaches.
PR #1078 addresses a complementary lock-holding problem during texture refresh.
The current proposal does not incorporate either PR.
Limitations and draft status
Opening as a draft to gather feedback on the concurrency design and the measured latency/throughput trade-offs.
AI disclosure
AI-assisted with OpenAI Codex for the original implementation and test development, and ChatGPT (GPT-6.2) for subsequent review, validation planning, integration guidance, and documentation.
All reported local builds and tests were executed on my Windows machine. Test fixtures use synthetic data.
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.