Skip to content

GPU: constant buffer views of at most 64 KiB - #24

Open
NuraadGit wants to merge 1 commit into
fxceless:mainfrom
NuraadGit:gpu/constant-view-64k
Open

NuraadGit wants to merge 1 commit into
fxceless:mainfrom
NuraadGit:gpu/constant-view-64k

Conversation

@NuraadGit

Copy link
Copy Markdown

The fix I described in #5, as a PR on 1684989. The same change is Marvisak/VIctory#1640 (the code is the same there).

A constant buffer view of more than 65,536 bytes removes the host device (0x887A0001). The size from the title's descriptor went to CreateConstantBufferView as it was. The heap keeps old contents in slots the title doesn't use, and a view is made for each. In two runs on an RTX 2080 that ended that way, the last 64 views (your the host device went while buffer views of the heap were made list) included constant buffer views of 969,472 and 896,256 bytes. This caps them at 64 KiB, which is all a shader can index.

Test. an_oversized_constant_buffer_view_leaves_the_device_alive makes both sizes through make and one through constant_at, and checks the device after each. Without the cap it fails at the first ("a view of 969472 bytes"); with it, it passes. cargo test -p victory-gpu --lib on an RTX 2080: 111 passed, 1 ignored. cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean.

Not shown: I haven't run the title with this yet, and a third run with the same removal had no oversized view in its list, so it may not be the only cause. A probe on the same card shows that a view not on a 256-byte address, or of a size that isn't a multiple of 256, also removes the device; make already guards against both.

AI-assisted (Claude Code); counts and log lines only, nothing from the game attached.

The host removes the device for a constant buffer view of more than 65,536
bytes. The title's view heap holds larger sizes in slots it does not use,
and the size went to the host as it was.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T20:24:32.214968Z 1d2f476 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@rafaconvaitis

Copy link
Copy Markdown

Independent Windows 11 result on an RTX 4070 (driver 32.0.16.1664), Series X mode, pinned 578d459 with local adapter selection and test input. One run reached the lit prologue and later reported DXGI_ERROR_INVALID_CALL (0x887A0001) during the buffer-view mirror pass. The last 64 sampled views included an aligned CBV of 1,228,032 bytes. At removal, 105,231 submissions had started and finished, with no submission in flight. The sample does not identify which creation call triggered removal.

In a synthetic D3D12 WARP probe with the debug layer, the same aligned, 1,228,032-byte backing allocation left the device at S_OK with a 65,536-byte view. Asking for a 1,228,032-byte view produced message 650 and 0x887A0001 before any GPU submission. That corroborates the API failure at the observed size. A separate 30m56s run without this PR reached controllable gameplay and had neither device removal nor message 650. I have not tested the cap from this PR in the title. The in-title trigger remains unconfirmed.

AI-assisted capture and log analysis. No title data attached.

@NuraadGit

Copy link
Copy Markdown
Author

In-title result for this, on an RTX 2080 (7b0f736 + this change + a diagnostics-only present log, no loop limit, Series X profile).

  • One session of 17 min 42 s (frame 3,822), ended by me, with 0 device removals.
  • 3 min 15 s in, the cap cut a view of 955,136 bytes at 0x7fe8ba580000. The line is logged once per run, so later ones would not show.
  • Before this change, three runs here ended in 0x887A0001 about 5 to 6.5 minutes after launch, two of them with a view like this among the 64 made last. The probe (in GPU: constant buffer views of at most 64 KiB Marvisak/VIctory#1640) shows that making one removes the device.

It is one session, so it shows that such a view does turn up in the title and that the device stays, not how often the old build would have ended.

AI-assisted (Claude Code); counts and log lines only, nothing from the game attached.

@adriaespii

Copy link
Copy Markdown

Independent test run on commit 1d2f476 (AMD RDNA4):

  • Hardware: AMD Radeon RX 9070 (driver 32.0.32015.7029), AMD Ryzen 5 7600, Windows 11 Pro, Rust 1.98.1 (x86_64-pc-windows-msvc)
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings
  • cargo test --workspace: 497 passed, 0 failed, 7 ignored (victory-gpu: 111 passed, 0 failed, 1 ignored; victory-shader: 210 passed, 0 failed, 2 ignored)
  • Not tested: live game run (no game files on this machine)

AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.

@arminkhaleghirod

Copy link
Copy Markdown

Ran the game with this (1d2f476) on an RTX 4080, Windows 11, Series X profile, default settings. 5.5 min from boot into the opening cutscene. No device loss, no 0x887A0001. 0.7–1.8 fps in the cutscene.

Korsuma added a commit to RicerBoy/DropItLikeItsHot that referenced this pull request Nov 24, 2026
…, #188)

Integrates selected runtime, GPU, and shader fixes from FulGerNet/macca-cl
(cd81e89, GPL-3.0-or-later) plus remaining clean upstream PRs on top of
origin/main (da435f1):

From FulGerNet/macca-cl:
- console_insn.rs: mwaitx yields (std::thread::yield_now) instead of spinning
  with pause so waiting threads do not starve video/audio/pipeline workers.
- texture.rs: mark view-aliased textures (Bink intro video frames) so they hash
  on every refresh rather than every 8th frame.
- pipeline/make.rs: VICTORY_PIPELINE_THREADS override, 3/4 core default (2-8),
  early prewarm at THREAD_PRIORITY_LOWEST and draw-requested at NORMAL.
- pipeline/library.rs: per-writer atomic cache staging files (+2 tests).
- shader_cache.rs & emit/{mod,shader}.rs: key translated shader cache by
  translation_limits() (host_max_wave + view_heap_limit) and wave/strict env
  options (+test), plus DXIL validator warning pass (VICTORY_DXIL_STRICT=1).
- emit/{mod,lower}.rs: last-resort wave-wide compute fallback on 32-lane hosts
  before WaveSize(64) (VICTORY_WAVE_WIDE=0 disables), plus mixed flat and
  interpolated input row lowering (+test).
- draw.rs, list.rs, queue.rs: host heap COM-pointer tracking (ABA guard),
  root-signature invalidation, recycled transient table submission guard, and
  initial pipeline bind on list creation (+3 tests).
- kernel.rs & xgame.rs: CP_ACP ANSI path encoding for GetModuleFileNameA and
  XLaunchNewGame (+test).

From upstream PRs:
- fxceless/victory-fork#25: uniform control-flow immediate samplers (+test).
- fxceless/victory-fork#24: cap constant buffer views at 64 KiB (+test).
- fxceless/victory-fork#23: gameinput reading history 32 -> 256.
- Marvisak/VIctory#1623: inline GFX10 instruction words (+from_word helper).
- Marvisak/VIctory#188: SSE2 16-byte TLS scan at startup.

Verified on Windows 11, RTX 4080 16 GB (Wave32), Ryzen 7 7800X3D, 32 GB RAM:
- cargo xtask policy --staged: 22 files ok
- cargo clippy --workspace --all-features --lib --tests -- -D warnings: clean
- cargo test --workspace: 0 failures (215/215 victory-shader passed)
- Live 2560x1440 diag run (VICTORY_DISPLAY_MODE=2560x1440): smooth Bink intro
  video at 30.0 fps (33.3 ms/frame, 12.7 MB/frame texture streaming, 0.4 ms GPU,
  0 dropped draws) -> UI Text Size setup screen (25.4-30.0 fps, 7.1 GB private,
  552 MB VRAM), 0 crashes (crashes.log empty).

Fixes #6
Fixes #8
@Aminou973

Copy link
Copy Markdown

Confirmed on an RTX 3080 10 GB (Windows 11, driver 621.14). Without this change the device is removed with INVALID_CALL at frames 2,498 and 3,387 (debug layer: CreateConstantBufferView: Size of 2785536 exceeds maximum constant buffer view size). With the same clamp there is no removal over 3,400–4,400 frames and the prologue renders (details in #72). AI-assisted.

@ericomeehan

Copy link
Copy Markdown

The evidence in this thread is unusually strong: four cards with before/after runs, and the debug layer naming the oversized view, so the cause looks settled.

One small test thing: in an_oversized_constant_buffer_view_leaves_the_device_alive, the three constant_bytes asserts come after the let Some(host) = host() else { return; } early return, so on a machine without a GPU (CI runners, for one) the test passes without checking the rounding at all. A separate CPU-only test for constant_bytes (480 → 512, 64 KiB → 64 KiB, u32::MAX → 64 KiB) would get those checked everywhere. The same applies to the port in Marvisak/VIctory#1640.

Written with an AI assistant (Claude).

@tippythetaidum

Copy link
Copy Markdown

Test report on current main (f85101b), RTX 5080 16 GB, driver 621.14, Windows 11, Series X profile, diagnostics build, default settings (so the relay is on).

Without this change, f85101b loses the device at world entry here: 2 runs of 2.

Run Tree Result
A f85101b device removed (0x887A0001) 2 min 1 s after launch, as the opening cutscene starts; "the host device went while buffer views of the heap were made"
B f85101b, VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_DRED=1 device removed 2 min 10 s after launch; the debug layer's last message before RemoveDevice is the one below
C f85101b + this PR's commit cherry-picked (applies clean) full 11 min (stopped by my timeout), 80,000+ submissions, 4,037 frames, 0 device removals, through the opening cutscene into the prison interior

Run B, the two lines in order:

D3D12: ID3D12Device::CreateConstantBufferView: Size of 1406720 exceeds maximum constant buffer view size of 65536. id=650 severity=1
D3D12: ID3D12Device::RemoveDevice: Device removal has been triggered for the following reason (DXGI_ERROR_INVALID_CALL: ...). id=232 severity=1

Note for anyone reading run A's kind of log: the list of the last 64 views in the "buffer views of the heap were made" error did not contain the oversized view (its largest Constant was 480 bytes), so that list alone can miss the cause; the debug layer names it.

an_oversized_constant_buffer_view_leaves_the_device_alive passes on this card with the commit on f85101b.

Not shown: runs A and C each ran once at default settings. All three trees also carried a local diagnostics-only counter of mine (it reads the lists' copy steps and does not touch descriptor views). Frame rate in run C's last five minutes: median 4.6 fps in 5-second readings (diagnostics build).

AI-assisted (Claude Code): runs, log reading and this text. Counts and log lines only, nothing from the game attached.

PiloteCode added a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
…celess#24/fxceless#104), null CBVs (fxceless#304), tables at list cuts (fxceless#742), heap entries (fxceless#589), barriers (fxceless#787), depth-stencil UAV barriers (fxceless#214), windows ending at recorded writes (fxceless#663), sRGB views (fxceless#644), wide accesses across pages (fxceless#846), view-guard costs (fxceless#812/fxceless#853), the fill latch (fxceless#860), pipeline waits (fxceless#709), robustness; opt-in fxceless#868/fxceless#845
SaymonMaster14 added a commit to SaymonMaster14/victory-fork that referenced this pull request Nov 26, 2026
deynesdev pushed a commit to deynesdev/Protonida that referenced this pull request Nov 26, 2026
… scan

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
deynesdev pushed a commit to deynesdev/Protonida that referenced this pull request Nov 26, 2026
… main added since)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants