gpu: isolate AMD driver compiler crashes (crashed.txt) and skip self-CopyResource #2

Open
github-bot wants to merge 2 commits from github-bot/gh-2 into main AGit
Owner

@⁠jmal423 on GitHub · 2026-11-25 15:34 UTC · original
jmal423:pr/rdna4-pipeline-crash-isolation → main · +135 −19 · 3 files · 2 commits · open

Enables DexNom/VIctory to boot and run on AMD RDNA4 (tested on Windows 11 / AMD Radeon RX 9070 XT, Series X target) without crashing inside amdxc64.dll:

  • Per-pipeline driver crash isolation (crashed.txt): installs a Vectored Exception Handler around Create*PipelineState in pipeline::library that logs the failing pipeline hash, records it in crashed.txt (skipped on subsequent runs), and parks the faulting worker thread instead of crashing the process.
  • Automatic worker replacement: tracks parked worker threads via library::LOST and spawns replacement workers in pipeline::make::start so the pipeline worker pool never starves (preventing 12s/frame stalls when multiple PSOs fault in one session).
  • Skip self-CopyResource: skips CopyResource when to == from (same host texture).

Tested on Windows 11 / AMD Radeon RX 9070 XT:

  • Previously crashed ~3s after launch at amdxc64.dll+0x861b9f (0xc0000005, read 0x8).
  • With this patch, isolated the faulting RDNA4 pipelines into crashed.txt and ran in-game (both raster and experimental RT at 1.3-1.5 fps / 687-777 ms/frame in the prison scene).
**@⁠jmal423** on GitHub · 2026-11-25 15:34 UTC · [original](https://github.com/DexNom/VIctory/pull/2) `jmal423:pr/rdna4-pipeline-crash-isolation` → `main` · +135 −19 · 3 files · 2 commits · open Enables `DexNom/VIctory` to boot and run on AMD RDNA4 (tested on Windows 11 / AMD Radeon RX 9070 XT, Series X target) without crashing inside `amdxc64.dll`: - **Per-pipeline driver crash isolation (`crashed.txt`)**: installs a Vectored Exception Handler around `Create*PipelineState` in `pipeline::library` that logs the failing pipeline hash, records it in `crashed.txt` (skipped on subsequent runs), and parks the faulting worker thread instead of crashing the process. - **Automatic worker replacement**: tracks parked worker threads via `library::LOST` and spawns replacement workers in `pipeline::make::start` so the pipeline worker pool never starves (preventing 12s/frame stalls when multiple PSOs fault in one session). - **Skip self-`CopyResource`**: skips `CopyResource` when `to == from` (same host texture). Tested on Windows 11 / AMD Radeon RX 9070 XT: - Previously crashed ~3s after launch at `amdxc64.dll+0x861b9f` (`0xc0000005`, read `0x8`). - With this patch, isolated the faulting RDNA4 pipelines into `crashed.txt` and ran in-game (both raster and experimental RT at `1.3-1.5 fps` / `687-777 ms/frame` in the prison scene).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:31:27 +00:00
Author
Owner

@⁠DiegoStefanini on GitHub · 2026-11-25 15:45 UTC · original

Thanks for this! I merged it locally on top of current main (921d8d3), together with #1: no conflicts, clippy clean with and without --all-features, and the whole workspace test suite passes (623 passed, 0 failed) on an RTX 4060 Laptop. As expected it changes nothing on NVIDIA, since no driver crash happens there.

Two things I noticed while reading it:

  1. WAITING never comes back down after a parked worker. The worker that faults never returns from next().make(), so the WAITING.fetch_sub(1, …) in the worker loop never runs for that pipeline. After the first isolated crash, WAITING stays one too high for the rest of the session: drained() no longer fires (no "host pipelines all made" log, no library save on drain), and the pending count on the frame line stays above zero. Decrementing WAITING in compiler_crashed (next to LOST.fetch_add) before parking would keep the count right. The replacement worker then takes over the queue as it does now.

  2. Parking the thread inside the driver. The handler stops the faulting thread in the middle of Create*PipelineState, so whatever the driver's compiler held at that moment (an internal lock, for instance) stays held for good. If another Create*PipelineState on a replacement worker needs the same lock, that worker blocks too, and so on. It evidently didn't happen in your RDNA4 run, so this may be fine in practice. Still, a short note in the doc comment would help, and so would a log line when a replacement worker starts, so a stall like that is easy to recognise later.

Nothing else from me. The self-CopyResource skip and the spawn_worker refactor look good.

**@⁠DiegoStefanini** on GitHub · 2026-11-25 15:45 UTC · [original](https://github.com/DexNom/VIctory/pull/2#issuecomment-7167298909) Thanks for this! I merged it locally on top of current `main` (921d8d3), together with #1: no conflicts, clippy clean with and without `--all-features`, and the whole workspace test suite passes (623 passed, 0 failed) on an RTX 4060 Laptop. As expected it changes nothing on NVIDIA, since no driver crash happens there. Two things I noticed while reading it: 1. **`WAITING` never comes back down after a parked worker.** The worker that faults never returns from `next().make()`, so the `WAITING.fetch_sub(1, …)` in the worker loop never runs for that pipeline. After the first isolated crash, `WAITING` stays one too high for the rest of the session: `drained()` no longer fires (no "host pipelines all made" log, no library save on drain), and the pending count on the frame line stays above zero. Decrementing `WAITING` in `compiler_crashed` (next to `LOST.fetch_add`) before parking would keep the count right. The replacement worker then takes over the queue as it does now. 2. **Parking the thread inside the driver.** The handler stops the faulting thread in the middle of `Create*PipelineState`, so whatever the driver's compiler held at that moment (an internal lock, for instance) stays held for good. If another `Create*PipelineState` on a replacement worker needs the same lock, that worker blocks too, and so on. It evidently didn't happen in your RDNA4 run, so this may be fine in practice. Still, a short note in the doc comment would help, and so would a log line when a replacement worker starts, so a stall like that is easy to recognise later. Nothing else from me. The self-`CopyResource` skip and the `spawn_worker` refactor look good.
Author
Owner

@⁠manoel0810 on GitHub · 2026-11-25 16:29 UTC · original

Estava corrigindo exatamente isso! Estou testando aqui.

**@⁠manoel0810** on GitHub · 2026-11-25 16:29 UTC · [original](https://github.com/DexNom/VIctory/pull/2#issuecomment-7168067137) Estava corrigindo exatamente isso! Estou testando aqui.
Author
Owner

@⁠jmal423 on GitHub · 2026-11-25 17:22 UTC · original

Thanks for the thorough review @⁠itsonewi! Updated the PR to address this:

  • Replaced OnceLock<HashSet<String>> with OnceLock<Mutex<HashSet<String>>> (crashed_set()), and note_crashed() now inserts into it in-memory via try_lock() as well as appending to crashed.txt, so repeated requests for a broken pipeline in the same run return Err immediately without re-faulting or parking more threads.
  • Documented the lock-free invariant above Making::new so future edits don't move any runtime lock across create().
**@⁠jmal423** on GitHub · 2026-11-25 17:22 UTC · [original](https://github.com/DexNom/VIctory/pull/2#issuecomment-7169406602) Thanks for the thorough review @⁠itsonewi! Updated the PR to address this: - Replaced `OnceLock<HashSet<String>>` with `OnceLock<Mutex<HashSet<String>>>` (`crashed_set()`), and `note_crashed()` now inserts into it in-memory via `try_lock()` as well as appending to `crashed.txt`, so repeated requests for a broken pipeline in the same run return `Err` immediately without re-faulting or parking more threads. - Documented the lock-free invariant above `Making::new` so future edits don't move any runtime lock across `create()`.
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 15:35 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 15:35 UTC · [original](https://github.com/DexNom/VIctory/pull/2#pullrequestreview-6060607178) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Author
Owner

@⁠itsonewi on GitHub · 2026-11-25 16:12 UTC · original · reviewed

probe from review endpoint

**@⁠itsonewi** on GitHub · 2026-11-25 16:12 UTC · [original](https://github.com/DexNom/VIctory/pull/2#pullrequestreview-6060976268) · **reviewed** probe from review endpoint
Author
Owner

@⁠itsonewi on GitHub · 2026-11-25 16:13 UTC · original · reviewed

Part 1 of a review of this patch against main (split up because the API kept failing on the long version).

The crashed name is never refused within the same run, so one broken pipeline crashes, parks and replaces in a loop.

crashed() reads crashed.txt once into a OnceLock<HashSet<String>>; note_crashed() only appends to the file and never touches that set. So in the run where the fault happens, crashed(name) is false for the rest of the run. A title that binds the same broken material pipeline every frame then repeats this: pipeline() -> not crashed -> create() -> the driver faults -> the VEH parks this worker and LOST += 1; the next make::start spawns a replacement that pops the next job, not the lost one; the next request for that name arrives and the cycle runs again.

Cost per attempt: one access violation, one log line, one permanently parked thread, one new thread. Unbounded over a session.

Fix: record the name in memory on the crash path as well (a Mutex<HashSet<String>> seeded once from the file, or a second OnceLock<Mutex<HashSet>>), so the second request in the same run returns Err immediately.

This is also the fix for the stall the description targets: the parked thread never sets made or left_out on the Pending it popped, so every frame that needs that pipeline waits its wait_budget (12 s per kind by default, pipeline/make.rs) for something that can no longer be made.


AI use: read the patch and crates/victory-gpu/src/pipeline/{make,library}.rs on main via the GitHub API; nothing built or run.

**@⁠itsonewi** on GitHub · 2026-11-25 16:13 UTC · [original](https://github.com/DexNom/VIctory/pull/2#pullrequestreview-6060987528) · **reviewed** Part 1 of a review of this patch against `main` (split up because the API kept failing on the long version). **The crashed name is never refused within the same run, so one broken pipeline crashes, parks and replaces in a loop.** `crashed()` reads `crashed.txt` once into a `OnceLock<HashSet<String>>`; `note_crashed()` only appends to the file and never touches that set. So in the run where the fault happens, `crashed(name)` is `false` for the rest of the run. A title that binds the same broken material pipeline every frame then repeats this: `pipeline()` -> not crashed -> `create()` -> the driver faults -> the VEH parks this worker and `LOST += 1`; the next `make::start` spawns a replacement that pops the *next* job, not the lost one; the next request for that name arrives and the cycle runs again. Cost per attempt: one access violation, one log line, one permanently parked thread, one new thread. Unbounded over a session. Fix: record the name in memory on the crash path as well (a `Mutex<HashSet<String>>` seeded once from the file, or a second `OnceLock<Mutex<HashSet>>`), so the second request in the same run returns `Err` immediately. This is also the fix for the stall the description targets: the parked thread never sets `made` or `left_out` on the `Pending` it popped, so every frame that needs that pipeline waits its `wait_budget` (12 s per kind by default, `pipeline/make.rs`) for something that can no longer be made. --- **AI use:** read the patch and `crates/victory-gpu/src/pipeline/{make,library}.rs` on `main` via the GitHub API; nothing built or run.
Author
Owner

@⁠itsonewi on GitHub · 2026-11-25 16:14 UTC · original · reviewed

Part 2 of the review (the rest, and one invariant worth writing down).

A parked thread leaves its Call entry behind. call() in library.rs pushes (thread, what, name, since) and removes it in Drop; a parked thread never drops it, so removal_note() reports make <pipeline> as a call running now for the rest of the run — which is exactly the report that diagnostic exists for.

crashed.txt never expires, and the README does not mention it. After a driver update that fixes the compiler the pipeline stays refused forever, and the only way out is finding and editing an undocumented file. A driver version or a date on the line, or one sentence in the README's known-issues list, would make it recoverable.

Confirmed on purpose, so that a later edit does not break it by accident: AddVectoredExceptionHandler(1, ...) returning 0 for exceptions that are not ours, the ExceptionInformation[1] >= 0x10000 filter, and the parking itself are free of the runtime's locks because create() runs outside them (// Compiled outside any lock), call() / one_call() / same_name() are scoped before it, and Pending::make compiles inside HostPipeline::new before touching DONE. That invariant deserves a line next to Making::new: moving any lock across create() would turn a parked thread into a deadlock that the replacement workers cannot repair.

Nothing here was built or run; this is from the patch and main.


AI use: read the patch and crates/victory-gpu/src/pipeline/{make,library}.rs on main via the GitHub API; nothing built or run.

**@⁠itsonewi** on GitHub · 2026-11-25 16:14 UTC · [original](https://github.com/DexNom/VIctory/pull/2#pullrequestreview-6060990486) · **reviewed** Part 2 of the review (the rest, and one invariant worth writing down). **A parked thread leaves its `Call` entry behind.** `call()` in `library.rs` pushes `(thread, what, name, since)` and removes it in `Drop`; a parked thread never drops it, so `removal_note()` reports `make <pipeline>` as a call running now for the rest of the run — which is exactly the report that diagnostic exists for. **`crashed.txt` never expires, and the README does not mention it.** After a driver update that fixes the compiler the pipeline stays refused forever, and the only way out is finding and editing an undocumented file. A driver version or a date on the line, or one sentence in the README's known-issues list, would make it recoverable. **Confirmed on purpose, so that a later edit does not break it by accident:** `AddVectoredExceptionHandler(1, ...)` returning `0` for exceptions that are not ours, the `ExceptionInformation[1] >= 0x10000` filter, and the parking itself are free of the runtime's locks *because* `create()` runs outside them (`// Compiled outside any lock`), `call()` / `one_call()` / `same_name()` are scoped before it, and `Pending::make` compiles inside `HostPipeline::new` before touching `DONE`. That invariant deserves a line next to `Making::new`: moving any lock across `create()` would turn a parked thread into a deadlock that the replacement workers cannot repair. Nothing here was built or run; this is from the patch and `main`. --- **AI use:** read the patch and `crates/victory-gpu/src/pipeline/{make,library}.rs` on `main` via the GitHub API; nothing built or run.
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 origin '+refs/pull/2/head:github-bot/gh-2'
git switch 'github-bot/gh-2'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2'
git switch 'github-bot/gh-2'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2'
git switch 'github-bot/gh-2'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2'
git switch 'main'
git merge --squash 'github-bot/gh-2'
git switch 'main'
git merge --ff-only 'github-bot/gh-2'
git switch 'main'
git merge 'github-bot/gh-2'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.