[pr-fix][rendering][memory] Retry temporary stand-in texture allocation failures #245

Open
andrewpozdnakov7-jpg wants to merge 1 commit from andrewpozdnakov7-jpg/Darner:port/4863-retry-neutral-texture-allocation into main
First-time contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

Stand-in textures use a once-initialized cache. Main caches the first failed allocation for the rest of the run. Cache only a successful allocation and retry a failed one at most once per second per texture kind. Other kinds keep their own retry deadline.

Restores locally saved VIctory-NVIDIA work from December 1, 2026. Recovered revision: c9e0b97. Adapted by andrewpozdnakov7-jpg (GitHub profile).

How it was tested

  • Tested revision: 76cdf41 on f3840d7.
  • Commands and results: A standalone Rust fixture compiled the current and patched initializer with an injected allocator and clock. Main stayed empty after the first failure. The patch waited for the deadline, retried once across eight callers, cached the success and did not block another kind. cargo check --locked -p darner-gpu --lib --tests, xtask policy, and git diff --check passed.
  • Changes a default: no.
  • Gates run on that revision: none of the three workspace-wide gates.
  • Coverage gaps: Synthetic allocation results, no GPU allocation failure or gameplay was induced.

Checklist

  • I ran this change in the game.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #231 touches a different descriptor path for cached raw views.
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: <!-- optional --> ## What it changes Stand-in textures use a once-initialized cache. Main caches the first failed allocation for the rest of the run. Cache only a successful allocation and retry a failed one at most once per second per texture kind. Other kinds keep their own retry deadline. Restores locally saved VIctory-NVIDIA work from December 1, 2026. Recovered revision: c9e0b97. Adapted by [andrewpozdnakov7-jpg](https://git.gtahub.st/andrewpozdnakov7-jpg) ([GitHub profile](https://github.com/andrewpozdnakov7-jpg)). ## How it was tested - Tested revision: 76cdf41 on f3840d7. - Commands and results: A standalone Rust fixture compiled the current and patched initializer with an injected allocator and clock. Main stayed empty after the first failure. The patch waited for the deadline, retried once across eight callers, cached the success and did not block another kind. cargo check --locked -p darner-gpu --lib --tests, xtask policy, and git diff --check passed. - Changes a default: no. - Gates run on that revision: none of the three workspace-wide gates. - Coverage gaps: Synthetic allocation results, no GPU allocation failure or gameplay was induced. ## Checklist - [ ] I ran this change in the game. - [x] This PR contains one change based on main. - [x] The diff follows docs/asset-policy.md. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #231 touches a different descriptor path for cached raw views. - Replaces or overlaps: none found
Adapt locally saved VIctory-NVIDIA work from December 1, 2026 (c9e0b97). Cache successful gray texture creation, retry failed creation at a bounded rate per kind, and keep already initialized textures recognizable.

https://git.gtahub.st/andrewpozdnakov7-jpg
https://github.com/andrewpozdnakov7-jpg
Collaborator

Code-read review of 76cdf41. I did not build or run it.

Caching only a success and retrying at most once a second per kind is the right shape: on main get_or_init(|| make_neutral(kind)) (descriptor/host.rs:550) stores a None for the whole run. The double-checked texture.get() under the per-kind mutex means one thread builds.

One hazard, which exists on main but which this PR makes repeatable. In make_neutral, queue.ExecuteCommandLists(..) (PR head :650) is followed by queue.Signal(&fence, 1).ok()? (:651) and fence.SetEventOnCompletion(..).ok()? (:653). If either fails, the function returns and drops made, the list, the allocator and the queue while the copy may still be executing. That should only happen with a removed device, but main hit it at most once per kind and this retry can hit it once a second per kind. Suggested: on a failed Signal or SetEventOnCompletion, leak (std::mem::forget) the list, allocator, queue and fence, or return Some(made) only after the wait succeeded and otherwise keep the objects alive for the rest of the run.

Smaller: a failed attempt is silent, so a stand-in that never arrives leaves no trace in the log. One tracing::warn! on the first failure of each kind would help triage.

This comment was written with AI assistance (Claude Code).

Code-read review of 76cdf41. I did not build or run it. Caching only a success and retrying at most once a second per kind is the right shape: on main `get_or_init(|| make_neutral(kind))` (`descriptor/host.rs:550`) stores a `None` for the whole run. The double-checked `texture.get()` under the per-kind mutex means one thread builds. One hazard, which exists on main but which this PR makes repeatable. In `make_neutral`, `queue.ExecuteCommandLists(..)` (PR head `:650`) is followed by `queue.Signal(&fence, 1).ok()?` (`:651`) and `fence.SetEventOnCompletion(..).ok()?` (`:653`). If either fails, the function returns and drops `made`, the list, the allocator and the queue while the copy may still be executing. That should only happen with a removed device, but main hit it at most once per kind and this retry can hit it once a second per kind. Suggested: on a failed `Signal` or `SetEventOnCompletion`, leak (`std::mem::forget`) the list, allocator, queue and fence, or return `Some(made)` only after the wait succeeded and otherwise keep the objects alive for the rest of the run. Smaller: a failed attempt is silent, so a stand-in that never arrives leaves no trace in the log. One `tracing::warn!` on the first failure of each kind would help triage. This comment was written with AI assistance (Claude Code).
Contributor

Code review only (read the diff at 76cdf41), nothing built or run. I agree with the earlier review on the retry shape and the one-time warn!. Additions:

  • The failure is reachable without a device loss. make_neutral starts with host.upload_buffer(256)?, and main documents that upload buffer being refused under memory pressure at world load (host.rs:18076-18081). On main, one such refusal leaves every missing texture of that kind with a null (black) view for the rest of the run, so this PR plausibly helps memory-tight PCs. Those failures come before anything is submitted, so retrying them is safe.
  • The drop hazard after ExecuteCommandLists: I read it as real but unlikely to repeat. Signal fails essentially only on a removed device, and after that every retry fails earlier (CreateCommittedResource or CreateCommandQueue), before anything is submitted. So it can happen about once, as on main, not once a second. Not a blocker in my view. If wanted, std::mem::forget the queue, list, allocator, upload buffer and texture on those two error paths.
  • Overlaps: #380 conflicts textually here (neutral_of, NEUTRALS, is_neutral) and adds a second stand-in table that caches failure the old way. #335 adds a third (far_occlusion_of). Whichever lands second may want the same retry.

Reviewed with Claude Code (AI-assisted); findings checked by a human before posting.

Code review only (read the diff at `76cdf41`), nothing built or run. I agree with the earlier review on the retry shape and the one-time `warn!`. Additions: - **The failure is reachable without a device loss.** `make_neutral` starts with `host.upload_buffer(256)?`, and `main` documents that upload buffer being refused under memory pressure at world load (`host.rs:18076-18081`). On `main`, one such refusal leaves every missing texture of that kind with a null (black) view for the rest of the run, so this PR plausibly helps memory-tight PCs. Those failures come before anything is submitted, so retrying them is safe. - **The drop hazard after `ExecuteCommandLists`:** I read it as real but unlikely to repeat. `Signal` fails essentially only on a removed device, and after that every retry fails earlier (`CreateCommittedResource` or `CreateCommandQueue`), before anything is submitted. So it can happen about once, as on `main`, not once a second. Not a blocker in my view. If wanted, `std::mem::forget` the queue, list, allocator, upload buffer and texture on those two error paths. - Overlaps: #380 conflicts textually here (`neutral_of`, `NEUTRALS`, `is_neutral`) and adds a second stand-in table that caches failure the old way. #335 adds a third (`far_occlusion_of`). Whichever lands second may want the same retry. Reviewed with Claude Code (AI-assisted); findings checked by a human before posting.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'port/4863-retry-neutral-texture-allocation:andrewpozdnakov7-jpg-port/4863-retry-neutral-texture-allocation'
git switch 'andrewpozdnakov7-jpg-port/4863-retry-neutral-texture-allocation'

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 'main'
git merge --no-ff 'andrewpozdnakov7-jpg-port/4863-retry-neutral-texture-allocation'
git switch 'andrewpozdnakov7-jpg-port/4863-retry-neutral-texture-allocation'
git rebase 'main'
git switch 'main'
git merge --ff-only 'andrewpozdnakov7-jpg-port/4863-retry-neutral-texture-allocation'
git switch 'andrewpozdnakov7-jpg-port/4863-retry-neutral-texture-allocation'
git rebase 'main'
git switch 'main'
git merge --no-ff 'andrewpozdnakov7-jpg-port/4863-retry-neutral-texture-allocation'
git switch 'main'
git merge --squash 'andrewpozdnakov7-jpg-port/4863-retry-neutral-texture-allocation'
git switch 'main'
git merge --ff-only 'andrewpozdnakov7-jpg-port/4863-retry-neutral-texture-allocation'
git switch 'main'
git merge 'andrewpozdnakov7-jpg-port/4863-retry-neutral-texture-allocation'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!245
No description provided.