GPU/Shader: declare wave64 wave size and strip unsupported video-texture flags #1281
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1281
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1281"
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?
@kss306 on GitHub · 2026-11-24 17:06 UTC · original
kss306:fix/wave64-tdr-and-video-textures→main· +35 −2 · 2 files · 1 commits · openWhat
Three fixes found by running GTA VI on an NVIDIA RTX 4080 Super (wave32-only device) with the D3D12 debug layer and DRED enabled.
1. Strip unsupported flags from NV12 and B4G4R4A4_UNORM textures (victory-gpu)
Xbox D3D12.X permits creating NV12 (format 86) textures with ALLOW_RENDER_TARGET | ALLOW_UNORDERED_ACCESS, and B4G4R4A4_UNORM (format 115) textures with ALLOW_RENDER_TARGET. PC D3D12 returns E_INVALIDARG for both combinations.
Without this fix the Bink2 video texture is never created. The intro cutscene plays audio for ~10 s but shows no image, then aborts early. With this fix the texture is created as a shader resource and the cutscene runs for its full duration. Character video is still missing (Bink2 needs UAV write access to decode frames — a separate issue).
2 + 3. Declare wave_size = 64 for wave64 compute and mesh shaders (victory-shader)
Xbox RDNA2 runs most compute and mesh shaders in wave64 mode (64 lanes/wavefront). NVIDIA GPUs run exclusively in wave32. The shader translator already declared wave_size = Some(64) for compute shaders with explicit cross-lane operations, but not for wave64 shaders without them. Those shaders were executed on NVIDIA hardware where their exec-mask handling enters an infinite loop, hanging the GPU for 7+ seconds and triggering Windows TDR (device removed).
Diagnosis: D3D12 debug layer reported Shader wants wave lane count of 64 but maximum wave lane count for device is 32 for the refused pipelines; DRED reported DXGI_ERROR_DEVICE_HUNG: TDR mechanism has been triggered as the removal reason.
Fix: declare wave_size = Some(64) for all wave64 compute shaders (not only those with cross-lane ops), and add the same declaration for wave64 mesh shaders (the mesh-shader branch had no wave_size handling at all). D3D12 refuses these pipelines cleanly at creation time instead of letting the GPU hang.
Results (RTX 4080 Super, GTA VI Xbox Series X)
The complete startup sequence — intro cutscene, world loading, and initial in-game state — now runs for its full ~6 minutes without a crash or TDR. The player reaches the in-game state.
The black world is the pre-existing rendering issue: the refused wave64 shaders include lighting, culling and shadow compute work. Wave64→wave32 translation is the next step, not part of this PR.
Testing
Built with cargo build --profile diag --features diagnostics and run with VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_DRED=1. No regression in cargo test --workspace.
AI-assisted (Kiro/Claude).
@kss306 on GitHub · 2026-11-24 17:10 UTC · original
https://github.com/user-attachments/assets/f6a8363d-02dc-4916-8b54-7f6301d1e453
@geiyiliyabumo on GitHub · 2026-11-24 17:26 UTC · original
Independent verification and code review of \
5db86f2\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200) / Rust 1.98.1 MSVC:Two issues found in the diff:
esource.rs:127), whereas **\DXGI_FORMAT_NV12 = 103**! As written, \NV12\ textures are not stripped at all, while \B5G5R5A1_UNORM\ loses RTV/UAV flags.
AI-assisted; synthetic tests only, no game files.
@hamdog0203 on GitHub · 2026-11-24 17:29 UTC · original
I audited and tested this PR (
5db86f2) on Windows 11 with an NVIDIA GeForce RTX 4060 (wave32-only), WARP, anddxil.dll.While the existing test suite passes (
cargo clippy --workspace --all-targets --locked -- -D warnings,--all-features,victory-gpu: 50 passed / 1 ignored,victory-shader: 120 passed / 1 ignored;diff_testsskipped withoutVICTORY_CONSOLE_DXC), targeted checks against the modified paths show four issues:DXGI_FORMAT_NV12is103, not86(crates/victory-gpu/src/resource.rs)86in DXGI isDXGI_FORMAT_B5G5R5A1_UNORM, whileDXGI_FORMAT_NV12is103(103is not matched bymatch d.format { 86 => ..., 115 => ... }, andformat_size()inresource.rs/texture::format()invictory-formatsdo not map103either).RENDER_TARGETstill passesclear_valuetoCreateCommittedResourcehost_texture(),clear_valueis still passed aspOptimizedClearValueafterRENDER_TARGET(1) is cleared.host_texture(): format115(B4G4R4A4_UNORM) withflags = 1succeeds whenclearis null (true), but fails (false) when a non-nullclear_valueis passed, since D3D12 rejectspOptimizedClearValue != NULLwithoutALLOW_RENDER_TARGET/ALLOW_DEPTH_STENCIL.dxil.dllrejectsWaveSizeon mesh shaders (crates/victory-shader/src/emit/lower.rs)s.wave_size = Some(64)underStageIo::Mscausesdxil.dllvalidation to fail even for a minimals_endpgmwave64mesh shader:Function: main: error: WaveSize only allowed on compute or node shaders/Validation failed.wave_size = Some(64)on allwave64compute shaders rejects wave-independent shaders on wave32 GPUs and WARP5db86f2, even a minimals_endpgmwave64compute shader (threads: [64, 1, 1], no cross-lane ops, no lane-mask data reads, no LDS) passesdxil.dll(Ok(())), and then failsCreateComputePipelineStateon both RTX 4060 and WARP withErr("The parameter is incorrect.")(E_INVALIDARG).structure.rsremovesEXECfor normal control flow, ordinarywave64shaders without lane-layout or intra-wave LDS dependencies can run in wave32 mode; if specific shaders still hang on NVIDIA due to an undetected mask/wave dependency, catching those patterns inconsole_laneswould avoid breaking all wave-independentwave64compute pipelines on wave32 GPUs.@kss306 on GitHub · 2026-11-24 17:38 UTC · original
Thank you both (@geiyiliyabumo, @hamdog0203) — all four issues were valid. Updated in
72e794b:1. Wrong format constant for B5G5R5A1_UNORM (
esource.rs) — fixed
You are correct: DXGI format 86 is DXGI_FORMAT_B5G5R5A1_UNORM, not NV12 (103). The original comment was wrong. The behaviour was still useful — B5G5R5A1_UNORM does not support typed UAV on PC, so stripping ALLOW_UNORDERED_ACCESS is correct — but the comment has been corrected. Format 115 (B4G4R4A4_UNORM) is unaffected.
2. clear_value passed after RENDER_TARGET stripped (
esource.rs) — fixed
Good catch. pOptimizedClearValue is now nulled out when RENDER_TARGET was stripped, so D3D12 no longer sees a non-null clear value on a resource without that flag.
3. WaveSize on mesh shaders is invalid DXIL (lower.rs) — fixed
The mesh-shader branch no longer sets s.wave_size. As hamdog0203 identified, DXIL rejects WaveSize outside compute/node shaders. The comment now explains why we deliberately omit it: the translator already rejects mesh shaders with cross-lane ops, so a successfully translated wave64 mesh shader has no lane-layout dependency and can run in wave32 mode.
4. Unconditional wave_size = Some(64) on all wave64 compute shaders — reverted
Reverted to the original console_lanes || one_wave && s.lds_dwords > 0 condition. Wave-independent wave64 shaders no longer get a forced wave-size declaration on wave32 hosts.
Note on the TDR that motivated this PR: on RTX 4080 Super a compute shader with 3840 threads and no detected cross-lane ops caused DXGI_ERROR_DEVICE_HUNG at world entry. That shader passed console_lanes undetected; improving console_lanes to catch that pattern is a follow-up, not part of this PR.
Tests after update (
72e794b), RTX 4080 Super, Rust 1.98.1 MSVC, debug build:cargo test -p victory-shader --lib → 120 passed; 0 failed; 1 ignored cargo test -p victory-gpu --lib → 50 passed; 0 failed; 1 ignored cargo clippy --workspace → cleanAI-assisted (Kiro/Claude).
@Aniseto on GitHub · 2026-11-24 17:11 UTC · original · edited 2026-11-24 17:49 UTC
Ran the two crates this touches at
72e794b(re-run after the head moved from5db86f2). The PR adds no test of its own, so this is a regression check:Environment: Windows 11 Pro build 26200 x64, Intel Core i5-12400F, 64 GB RAM, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only) driver 32.0.16.2124, Rust 1.98.1 (pinned by
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.Both still match
mainon this machine (ffe310e), so existing behaviour is undisturbed. It is worth noting for this PR: this host is wave32-only (WaveLaneCountMin = Max = 32), so every console wave64 program here takes the emulated path, which is exactly the case a wave-size declaration affects. The suites show no regression in that path, but a title run would be the real check and I have no game data.Not tested: the title (no game data here), RDNA2/RDNA4 and Intel GPUs, release build.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran both crates, wrote this report; no game data was used.
@geiyiliyabumo on GitHub · 2026-11-24 18:09 UTC · original
Re-verified \
72e794b\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200) / Rust 1.98.1 MSVC:Thanks for addressing all four items cleanly! One tiny optional polish on
esource.rs:860: gating \clear_value\ on \d.flags & (RENDER_TARGET | DEPTH) != 0\ (rather than !strip_rtv) would also guard any other texture whose title flags lack RTV/DSV.
AI-assisted; synthetic tests only, no game files.
@adamdotpy on GitHub · 2026-11-24 19:49 UTC · original
Reviewed at head
72e794b(worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). Findings, ranked:1. The resource-flag stripping is correct and the format numbers check out. In
host_texture(victory-gpu/src/resource.rs:826),B5G5R5A1_UNORM(DXGI 86) andB4G4R4A4_UNORM(DXGI 115) — the standard enum values, matching how this crate uses raw DXGI numbers (pc_formatmaps 118/119/120, etc.) — now stripRENDER_TARGET(86 and 115) andUNORDERED(86), the combinations PC D3D12 rejects with E_INVALIDARG even though Xbox allows them as RT/UAV. The clear-value handling is the part that easy to get wrong and is handled right: whenRENDER_TARGETis stripped,pOptimizedClearValueis nulled too, because D3D12 rejects a non-null clear value on a resource withoutALLOW_RENDER_TARGET/ALLOW_DEPTH_STENCIL— without that, the "fix" would just move the E_INVALIDARG. The depth-format path below is untouched and still runs after.2. The shader-side part is comment-only and accurate.
lower.rsadds no behavior: the existingwave_sizedeclaration for lane-order-dependent/one-wave-LDS compute shaders stays, and the new comments correctly note that DXIL forbidsWaveSizeon mesh shaders (validator would reject), so mesh shaders run at host wave width — safe because the translator already refuses mesh shaders with cross-lane ops.3. Verified here.
cargo test -p victory-gpu50 passed / 0 failed / 1 ignored;cargo test -p victory-shader --lib120 passed / 0 failed / 1 ignored;cargo clippy -p victory-gpu -p victory-shader --all-targets --all-features --locked -- -D warningsclean;cargo build --release -p victorybuilds;rustfmt --edition 2024 --checkon both files shows only the pre-existing hunks main has (resource.rs:867 → 888 shifted by the addition; lower.rs's 3 unchanged).4. Gap, not a defect: the flag stripping has no test —
host_textureneeds a live device, and the strip logic isn't extracted into a pure function. If you want it pinned, pulling the(format, flags) -> flagsdecision into a small pure helper would make it unit-testable (86 → strip RT|UAV, 115 → strip RT, others unchanged, clear value nulled iff RT stripped). Worth doing, not blocking.Nothing found that would block this.
@Marvisak on GitHub · 2026-11-25 02:33 UTC · original
Automated triage for the maintainers. As it stands this does not build on current
main.mainhas split texture creation intohost_descandmake_textureincrates/victory-gpu/src/resource.rs. The flag stripping lands inhost_desc, butmake_textureusesstrip_rtvfor the clear value, andstrip_rtvdoes not exist there. Please rebase and carry the decision through, for example by nulling the clear value whenever the host description has neither RENDER_TARGET nor DEPTH. Further points: (1) Since the review round thelower.rspart only adds comments, so please update the title and description, which still describe forcingwave_size = 64. (2) Format 86 (B5G5R5A1_UNORM) loses RENDER_TARGET too, although your own comment says PC accepts it as a render target. Stripping a flag the title asked for also makes its later RTV/UAV views on that texture fail quietly. Please ask the device (CheckFeatureSupportwithD3D12_FEATURE_FORMAT_SUPPORT, astyped_storeindescriptor/host.rsalready does) and strip only what it refuses, then say what happens to the title's views. (3) A short unit test of the flag decision would pin it.Generated by Claude Code
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.