Skip to content

Fix GPU hangs, memory leak, and mesh shader exports; render intro cre… - #458

Open
techselect wants to merge 1 commit into
Marvisak:mainfrom
techselect:fix/intro-credits-rendering-stability
Open

techselect wants to merge 1 commit into
Marvisak:mainfrom
techselect:fix/intro-credits-rendering-stability

Conversation

@techselect

Copy link
Copy Markdown

…dit text

This change stabilizes world loading and enables rendering intro credit text in GTA VI:

  1. Mesh Shader Output Clamping:

    • Added bounds guards in emit_indices and export against max_primitives and max_vertices.
    • Prevents WARP 0xC0000005 access violations and discrete GPU hardware traps/hangs on DispatchMesh.
  2. Command List Slicing & TDR Watchdog Reset:

    • Split monolithic multi-list command submissions into per-list ExecuteCommandLists calls with intermediate fence synchronization.
    • Resets Windows WDDM 2.0s TDR watchdog between lists, preventing driver resets.
  3. 60GB Memory Leak Resolution:

    • Added LRU cache eviction (capped at 384 entries) for PLACED_TEXTURES in resource.rs.
    • Hooked title_memory_remapped and XMemFreeDefault to evict freed textures and loose 4MB shadow buffers.
  4. Shared Buffer State Collision Resolution:

    • Unified buffer read states under BUFFER_GENERIC_READ (0xAC3) in host.rs.
  5. Indirect Draw Barrier Desynchronization Fix:

    • Routed indirect argument buffer barriers through transition_buffer; eliminated rogue UNORDERED_ACCESS state forcing in indirect::done.
  6. Discrete GPU Selection & DRED in Release:

    • Prioritized discrete high-performance GPUs over integrated/WARP.
    • Enabled DRED crash diagnostics in release builds via VICTORY_D3D12_DRED=1.

…dit text

This change stabilizes world loading and enables rendering intro credit text in GTA VI:

1. Mesh Shader Output Clamping:
   - Added bounds guards in emit_indices and export against max_primitives and max_vertices.
   - Prevents WARP 0xC0000005 access violations and discrete GPU hardware traps/hangs on DispatchMesh.

2. Command List Slicing & TDR Watchdog Reset:
   - Split monolithic multi-list command submissions into per-list ExecuteCommandLists calls with intermediate fence synchronization.
   - Resets Windows WDDM 2.0s TDR watchdog between lists, preventing driver resets.

3. 60GB Memory Leak Resolution:
   - Added LRU cache eviction (capped at 384 entries) for PLACED_TEXTURES in resource.rs.
   - Hooked title_memory_remapped and XMemFreeDefault to evict freed textures and loose 4MB shadow buffers.

4. Shared Buffer State Collision Resolution:
   - Unified buffer read states under BUFFER_GENERIC_READ (0xAC3) in host.rs.

5. Indirect Draw Barrier Desynchronization Fix:
   - Routed indirect argument buffer barriers through transition_buffer; eliminated rogue UNORDERED_ACCESS state forcing in indirect::done.

6. Discrete GPU Selection & DRED in Release:
   - Prioritized discrete high-performance GPUs over integrated/WARP.
   - Enabled DRED crash diagnostics in release builds via VICTORY_D3D12_DRED=1.
@DaviTostes

Copy link
Copy Markdown

Built 360f382 for x86_64-pc-windows-msvc (release) and ran the suites under Wine 11.22 on Arch Linux x86_64:

  • victory-gpu: 44 passed, 0 failed, 1 ignored.
  • victory-hle: 85 passed, 1 failed — only modules::net::tests::only_loopback_is_reachable (known Wine WSAConnectByList gap, Wine: fall back where ws2_32 lacks exports; hook and cfg fixes #217).
  • victory-shader: 62 passed, 7 failed — exactly the 7 VALU tests that fail on main too (“neither hardware nor WARP SM 6.6 device available”); this prefix cannot exercise them.

So the tree compiles and the synthetic suites do not regress. The claims that need the title — WARP 0xC0000005 on DispatchMesh, the TDR watchdog, the 60 GB leak, intro credits — are not verifiable here (no game data), and the DRED/GPU-selection changes are not covered by a test.

Coordination: this is a 14-file PR mixing independent fixes. git merge-tree against other open work:

@techselect

techselect commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

Booted into prologue but lacking models

@upipibi upipibi mentioned this pull request Nov 24, 2026
@techselect

Copy link
Copy Markdown
Author
image

@KingKaom

Copy link
Copy Markdown

Tested 360f382 on the RX 9070 XT box from my #304 confirmation (9800X3D, Win11 26300, driver 32.0.32029.2010). Still faults entering the world (~15 s of dark-scene frames) — but the DRED with breadcrumbs now names the victim, and one number is striking:

  • Stopped list: command 117 of 153, op 5 = ExecuteIndirect kind 2 (max 1), compute cabb87599722e59a, five queued indirect args in flight on the same compute pipeline.
  • Page fault at 0x8000037c3000. On main my baseline crashes reported 0x8000037d1000 — across two builds, several runs and different list counts, the fault always lands within 56 KB of 0x8000037c0000, while the title-memory and heap base addresses around it shuffle run to run. So the bad read is not a wild index — it consistently targets one stable mapping around 0x8000_037c_0000, which reads like a fixed-offset overrun of one specific buffer rather than random descriptor garbage.
  • The table dump shows all its u-slot heap reads resolving to null descriptors (u4 … [heap 333264: null], u5 … [heap 682765: null]), consistent with reads landing past the made slots.

The guard change may have moved the fault off the mesh exports (this death is a compute indirect, not a DispatchMesh) without removing the underlying bad read. Happy to run anything on this box — the near-constant fault VA may be the sharpest lead in this whole thing.

@miniongk

Copy link
Copy Markdown

Tested 360f382 on an RTX 5080, driver 621.24, Windows 11 26300, using a local Xbox Series 1.0.2.1 copy.

  • cargo test --workspace: 264 passed, 0 failed, 4 ignored.
  • The native run still ended in DXGI_ERROR_DEVICE_HUNG; DRED again implicated indirect execution and mesh dispatch.
  • The pre-existing host-pipeline refusals and packed-format texture-creation failures are still present on this standalone branch.

So this does not resolve #97 on my hardware as a standalone change. A combination test would be needed to separate the mesh guard from the other fixes. Only aggregate counts and error classes shared. AI-assisted (Kimi Code).

@miniongk

Copy link
Copy Markdown

Combination follow-up on the RTX 5080 / 621.24 setup: 360f382 combined with #413, #320, #483, #89 and #137 on the local 1.0.2.1 copy.

The resource/watch overlaps were resolved locally so LRU eviction also advances the bindless invalidation epoch. cargo test --workspace passed: 292 passed, 0 failed, 4 ignored. On the real title path, host-pipeline refusals, packed-format texture failures and the old readback warning were all zero. No host device was removed, but the title later reached the same explicit null-write fatal path seen with #413.

This is not a world-stability fix on my setup. Only aggregate counts and error classes shared. AI-assisted (Kimi Code).

@Mesrine67

Mesrine67 commented Nov 24, 2026 •

Copy link
Copy Markdown

Local validation on Windows 11 with an AMD Radeon RX 6750 XT (driver 32.0.21045.29003), against PR head 360f382:

  • The pinned Rust 1.98.1 workspace suite passed: 265 passed, 4 ignored, 0 failed.
  • The targeted D3D12 HostHeap test passed. Temporary local-only instrumentation confirmed it created a default D3D12 device rather than taking its no-GPU early return; WARP and diagnostic variables were unset. The only display adapter enumerated was the RX 6750 XT.
  • cargo build --release --locked -p victory passed.
  • The title EXE loader preflight mapped the image, bound its title DLLs, reported 0 missing imports, and stopped at “not executing.”

These are unit, D3D12-device, build, and loader-preparation checks; they do not test title execution or world rendering.

Full logs as downloadable files are in a public diagnostics branch, separate from the PR diff: log index · workspace tests · D3D12 hardware check · original preflight · latest shader tests · latest Clippy · merged-source preflight · launch blocker checks.

Sync update (2026-11-24): Marvisak/VIctory main and my fork’s main are both at ffe310e. Conflict-resolution merge e06a73a is pushed to my fork’s fix/intro-credits-rendering-stability branch. PR #458 still points to techselect/VIctory at 360f382; push to that source repository was denied, so the PR itself remains unchanged.

On the merged source, the shader suite passed (120 passed, 1 ignored), Clippy passed, and the diagnostic build/preflight resolved all imports. The title entry point was not executed: Defender history reports the supplied EXE as Trojan:Win32/MalUri.A!cl, and Windows Sandbox is unavailable on this host.

@claude-GTA6

claude-GTA6 commented Nov 24, 2026 •

Copy link
Copy Markdown

From a tester working with Claude (AI-assisted); measured on my own machine.

Combined with the buffer-state tracker this PR adds, ExecuteIndirect reads its arguments from a buffer in UNORDERED_ACCESS state.

Seen: RTX 5090 (621.24), diag build with VICTORY_D3D12_DEBUG=1, world of the first mission. In one run the debug layer printed 347 lines of this:

ID3D12CommandList::ExecuteIndirect: ... Resource state (0x8: D3D12_RESOURCE_STATE_UNORDERED_ACCESS) of resource (...'title buffer 0x242c0000+0xae00000') is invalid for use as a indirect argument

Why:

  1. indirect::bound clamps the records, then moves the shadow to generic read.
  2. prepare / bind follow. If the draw's own shaders write the same title buffer, readable moves the shadow back to UAV. Here the buffer is one 174 MB pool that holds both the arguments and what the shaders write.
  3. ExecuteIndirect then reads arguments from a buffer in UAV state.

A buffer can't be in the indirect-argument and UAV states at the same time, so no barrier ordering fixes this.

Fix: HostList::indirect_copy copies the clamped records, and the count when there is one, into list-owned memory right after the clamp. ExecuteIndirect reads the copy, and the title buffer stays in whatever state the shaders need. With it, the debug layer reports none of these.

Branch on top of this PR: https://github.com/claude-GTA6/VIctory/tree/indirect-copy-on-458 (one commit, 49e15fe; was aaacaf3 before an author-metadata rewrite).

BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 24, 2026
The rewrite pass already writes records at or past the title's count as
empty draws, so ExecuteIndirect does not need the count: it now runs all
records from the list's own arguments buffer, with no count buffer. The
rectangle path then changes the state of no title buffer: the count's
host copy was moved to INDIRECT_ARGUMENT and back around the draw, which
a buffer-state tracker such as Marvisak#458 or Marvisak#334 may have moved elsewhere,
and which the draw's own shaders may need in another state (reported by
claude-GTA6 on Marvisak#346: a device removal with Marvisak#458 stacked).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 24, 2026
The rewrite pass already writes records at or past the title's count as
empty draws, so ExecuteIndirect does not need the count: it now runs all
records from the list's own arguments buffer, with no count buffer. The
rectangle path then changes the state of no title buffer: the count's
host copy was moved to INDIRECT_ARGUMENT and back around the draw, which
a buffer-state tracker such as Marvisak#458 or Marvisak#334 may have moved elsewhere,
and which the draw's own shaders may need in another state (reported by
claude-GTA6 on Marvisak#346: a device removal with Marvisak#458 stacked).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 24, 2026
The rewrite pass already writes records at or past the title's count as
empty draws, so ExecuteIndirect does not need the count: it now runs all
records from the list's own arguments buffer, with no count buffer. The
rectangle path then changes the state of no title buffer: the count's
host copy was moved to INDIRECT_ARGUMENT and back around the draw, which
a buffer-state tracker such as Marvisak#458 or Marvisak#334 may have moved elsewhere,
and which the draw's own shaders may need in another state (reported by
claude-GTA6 on Marvisak#346: a device removal with Marvisak#458 stacked).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ortomanic pushed a commit to Ortomanic/VIctory that referenced this pull request Nov 24, 2026
The rewrite pass already writes records at or past the title's count as
empty draws, so ExecuteIndirect does not need the count: it now runs all
records from the list's own arguments buffer, with no count buffer. The
rectangle path then changes the state of no title buffer: the count's
host copy was moved to INDIRECT_ARGUMENT and back around the draw, which
a buffer-state tracker such as Marvisak#458 or Marvisak#334 may have moved elsewhere,
and which the draw's own shaders may need in another state (reported by
claude-GTA6 on Marvisak#346: a device removal with Marvisak#458 stacked).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit b43e8a7)
DuarttBR added a commit to DuarttBR/VIctory that referenced this pull request Nov 24, 2026
The backstop cap on placed textures (from Marvisak#458) was 384, while the prologue's world views thousands of streamed textures. Memory the title remaps or frees still releases them. Diagnostics builds also log, every ten seconds, how many heap textures the uploader knows, has copied and found empty, the formats of the views it sees, and the outcome of each texture view made in a host heap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
suirentakamura pushed a commit to suirentakamura/VIctory that referenced this pull request Nov 24, 2026
The rewrite pass already writes records at or past the title's count as
empty draws, so ExecuteIndirect does not need the count: it now runs all
records from the list's own arguments buffer, with no count buffer. The
rectangle path then changes the state of no title buffer: the count's
host copy was moved to INDIRECT_ARGUMENT and back around the draw, which
a buffer-state tracker such as Marvisak#458 or Marvisak#334 may have moved elsewhere,
and which the draw's own shaders may need in another state (reported by
claude-GTA6 on Marvisak#346: a device removal with Marvisak#458 stacked).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-gpu/src/draw.rs, crates/victory-gpu/src/host.rs, crates/victory-gpu/src/resource.rs, crates/victory-shader/src/emit/lower.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

PastiiJay pushed a commit to PastiiJay/klbf-lab that referenced this pull request Nov 25, 2026
The rewrite pass already writes records at or past the title's count as
empty draws, so ExecuteIndirect does not need the count: it now runs all
records from the list's own arguments buffer, with no count buffer. The
rectangle path then changes the state of no title buffer: the count's
host copy was moved to INDIRECT_ARGUMENT and back around the draw, which
a buffer-state tracker such as Marvisak#458 or Marvisak#334 may have moved elsewhere,
and which the draw's own shaders may need in another state (reported by
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants