Repository navigation
GPU and shaders: Grand Theft Auto VI runs its first 3D scene on a 32-lane laptop GPU (wave64 split and fallback, capped heaps, null root views, castable stand-in views, mapped pipeline library) - #3147
Conversation
A compute program that reads other lanes declares the console's wave size (WaveSize), so a wave64 one could only be created on a GPU with 64-lane waves: NVIDIA's run 32 lanes only, and pipeline creation failed there. The translation now knows whether the host has 64-lane waves (emit::set_host_wave64, default yes). Without, such a program declares WaveSize(32) and each console wave becomes two host waves (lower/wave64.rs). Thread ids keep the console's lane order, the console lane is the host lane plus 32 in the second half, and what stays within a half is exact as it was: DPP, ds_swizzle, v_writelane, v_mbcnt, a lane's bit of a mask. What spans both halves goes through group-shared scratch (store, group sync, load, group sync): 64-bit ballots of lane masks read as data, v_readlane at any lane, v_readfirstlane, ds_bpermute (the lane read and its bit of EXEC's ballot), and whole-wave reductions and prefix sums (each half's, combined with the other half's). A group sync is made only in blocks every thread of the group runs once (no loop contains them, every path to an end passes them); elsewhere the program is refused, as it is for a group of 33 to 64 threads with LDS (one console wave, which the console compiler leaves without barriers), for scratch beyond 32 KiB of group-shared memory, and for 16-bit whole-wave sums (shortcut: not joined over the halves). A group of at most 32 threads is one host wave and needs no exchange. Every waveGetLaneIndex the translation makes sets the wave-operations feature flag. v_readfirstlane under a lane guard (an EXEC the structurisation could not prove) read the host's first active lane, which can be outside EXEC; it now reads the first lane of the guard's ballot, on any wave size (a pixel helper lane still takes its own value). The test host can now enumerate hardware adapters (Host::hardware: GPUs as the default adapter is chosen, not software and with video memory of their own) and read their wave sizes (Host::wave_lanes). Tests (emit/wave64_tests.rs): hand-assembled wave64 programs of 128, 96, 64 and 32 threads with ballots (s_bcnt1, s_ff1, v_mbcnt), lane reads at lanes of both halves, v_readfirstlane with full and partial EXEC, a ballot under a narrowed EXEC, v_writelane, whole-wave sum, prefix sums and maximum sections, a ballot after a divergent branch, and ds_bpermute across the halves with full and partial EXEC, each lane checked against a model of the console's wave. Each runs on every hardware adapter and WARP for the wave sizes it supports: the RTX 5060 (32 lanes) ran the split programs, the Radeon 780M (32-64) both the split and the WaveSize(64) ones, WARP (4 lanes) neither. Refusals are tested for a ballot in divergent code, a lane read in a loop and LDS in one console wave. The tests fail when the exchange reads its own half instead of the other, when the every-thread check is dropped (the 2 refusal tests), and the permute test when ds_bpermute reads within its half; the guarded v_readfirstlane test failed on the 780M's 64-lane waves before the fix.
The translation can split wave64 compute programs into host waves of 32 lanes, but only when told the host lacks 64-lane waves. The host device now reads WaveLaneCountMin and WaveLaneCountMax (D3D12 OPTIONS1) when it is created, logs them and passes whether 64 lies between them to emit::set_host_wave64. Translation (at first use and `translate --cache` alike) creates the device first, so the setting is in place before any program is translated, and the shader cache keys translations for hosts without 64-lane waves apart from the others. README: what is still missing on such hosts. Builds and passes clippy and the workspace tests; not run against the title (no game data here).
…e host lacks - Shaders clamp view heap indices below the largest view heap the host takes (probed at device creation; NVIDIA and AMD cap at 1,000,000), and the null buffer views sit inside it; the shader cache keys on the size. - The host device is made on the high-performance adapter (a laptop's discrete GPU) when there is one. - Unordered views in a format the host cannot store to are left null instead of removing the device (B5G5R5A1). - Render targets and unordered textures in formats the host cannot render or store to get a stand-in of the same element size (RGB9E5 by R11G11B10 float, B4G4R4A4 by B5G5R5A1 or B5G6R5), as do their clear values, views and the pipelines drawing to them. - Translated loops stop after 2^12 iterations per lane (2^20 still hung). - VICTORY_PREBUILD_VERBOSE keeps the pre-build's per-pipeline log lines. - The shader test host prefers the high-performance adapter.
On a host that caps its view heaps (the RTX 5060: 1,000,000 slots) the dynamic slots were cut to 2^16, which Grand Theft Auto VI's world used up about a minute in: draws were dropped for want of slots and the title then waited for their work for good. They now keep their full 2^18 where the heap has room for twice that; the title's slots left below them go from 934,461 to 737,853, the rest reading null as those past the cap already did.
…er waves On a host without 64-lane waves, wave64 compute programs the exact split cannot take (LDS shared without barriers in one console wave of 33 to 64 threads, cross-lane operations spanning both halves where not every thread arrives) were left out: 139 of the programs the title's world runs, its frames then black behind the text. With the switch, such a program is lowered as for 64-lane waves and declares no wave size, so it runs in the host's waves with its cross-lane results possibly wrong instead of not at all. Off by default; the shader cache keys on it.
A wave64 program lowered approximately (VICTORY_WAVE64_APPROX) can loop waiting for what the other half of a console wave was to give, which in the host's 32-lane waves never comes; at the 4096 iterations per lane every loop gets, Grand Theft Auto VI's first 3D scene in Series S mode kept the RTX 5060 busy for minutes (no reset: the GPU stays preemptible) and the title waited for good. Loops of such programs now stop after 64.
Unlike VICTORY_POKE (writable data, twice a second), a patch is written once before the title's code runs and may change read-only data: the page protection is lifted for the write and restored. Grand Theft Auto VI sizes its window and render targets from a display mode table in .rdata (1280x720, 1664x936, 1920x1080, 2560x1440, 3840x2160 at 60 Hz; the last is what Series X mode uses, chosen before the title asks the host for its modes): 615c100:8007000038040000 makes that entry 1920x1080.
The pipeline library (over 2 GB for the world) was read whole into process memory and kept for the run, and every save serialised it into another buffer of its size: two private copies, the second allocated every 20 s while pipelines were added (a 2,164,033,260-byte allocation failed when memory ran short). The library is now mapped from its file, so the host drops and rereads its pages instead of paging them out, and saves serialise straight into a mapped file. Windows refuses to replace a mapped file, so each save writes the next generation (host-pipelines-<n>.bin; host-pipelines.bin is generation 0) and older ones go once nothing maps them, as do temporary files a killed save left. Saves come every 5 minutes instead of 20 s: each writes the whole library and holds its lock.
A run whose pipelines all came from the library still changed the list of pipelines to start early, and that rewrote the whole library (over 2 GB) a few seconds into every run. The list alone is written then.
…wered wave64 programs The limit (64) still let some of Grand Theft Auto VI's approximately lowered programs keep the GPU busy for minutes at the first 3D scene. It is now read from VICTORY_WAVE64_LOOPS (1 to 4096, 64 by default) and goes into the shader cache key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the null view Grand Theft Auto VI's frame dropped some 190 dispatches before its lighting (light lists, it seems) for a root view that was not set or not in a title buffer, and the lit image stayed black. A console shader need not touch a root view on every path: the dispatch now runs with the null buffer view there (zeros read, writes lost) and the case is logged once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s a twin Grand Theft Auto VI's compute writes two 192x108 lighting textures as R32_UINT and its lighting reads the same memory as R9G9B9E5_SHAREDEXP, a view the host does not allow of an R32 texture: refused, the lighting read zeros and the scene stayed black. Such a shader-resource view now reads a twin texture in its format, given the texture's bytes before every submission (texture to buffer to texture, placed footprints of one texel size), from the texture's real state and back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… title's format A host texture standing in for R9G9B9E5 (R11G11B10) that was made castable to R9G9B9E5 and R32_UINT is written as R32_UINT by Grand Theft Auto VI's compute and read as R9G9B9E5 by its lighting; the view was rewritten to the stand-in's format and read the bits as R11G11B10. A view format the texture is castable to is now kept (logged: shader views in a format of another family than their texture). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…holds again Scalar results are written whatever EXEC holds (Marvisak#2468), so the lane guard no longer reached v_readfirstlane, and in a split wave64 it read the host wave's first lane instead of the first lane of EXEC (lane_reads_reach_the_other_half: 0 for lanes above 36 in EXEC). The op now gets EXEC's lanes beside its unguarded write. The wave64 permute test follows main's ds_bpermute, which reads within its 32-lane half (RDNA 2 ISA, 10.4.4). Clippy: is_multiple_of in VICTORY_PATCH parsing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d write Taking EXEC's lanes for every scalar result failed a v_readlane under a join of an untracked mask (a_scalar_result_needs_no_exec); only v_readfirstlane needs them. Clippy: parentheses in the permute model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I found an ordering case in the fallback format twin on
In the middle row all 32 twin texels still contained their own previous seed. This reproduced on the RTX 5080 (621.40) and Windows inbox WARP. It matches the placement of Which path did the descriptor builder actually take? I also created 853×480 guest textures through the production resource and SRV paths, requested either I then dispatched a typed The separate fallback test keeps your existing control and adds an opt-in same-list regression that currently fails after checking the next-submission recovery. Fallback reproduction commit git fetch https://github.com/steven-seagull27/VIctory.git codex/pr3147-format-twin-order
git cherry-pick bc9f2f405de02df83a620ddd8557196d6ab7a707
$env:VICTORY_D3D12_DEBUG = '1'
$env:VICTORY_D3D12_WARP = '0'
cargo test --locked -p victory-gpu --features diagnostics --lib format_twin::tests:: -- --include-ignored --nocapture --test-threads=1Set |
The format twin (a copy in the view's format, refreshed at submission) missed writes earlier in the same list: a reviewer's same-list test read the twin's old texels, 0 of 32. The title's lighting textures take the castable view instead (f5a9b50's path), which the same reviewer checked on the production descriptors with a same-list R32_UINT write and R9G9B9E5 read, 128 of 128 texels; no twin was made in a run of the title. The twin is removed; the log of views in a format of another family stays. wave64_tests failed on CI, which has no GPU: no device runs a 64-lane program split or whole there (WARP runs 4-lane waves). They now say they skipped, as the other hardware-only tests do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Offscreen verification of Passing: all 11
vkd3d-proton matches Windows' incompatible-blob semantics (your Next for me is a guarded title trial of this branch (720p, Series S mode) — the wave64 split plus your capped view heaps and the null-buffer-view root fallback are exactly the loading-stage blockers I measured on this machine (310,720 AI use: omp, harness model |
|
Following the move from #1960, here is the integration patch, regression shader and CPU probe for the overlap with #2126. The original fix and RTX 5070 Ti test are by @0xkn0wh3r3 in their demo branch. The patch was prepared on the combined #1960 ( |
|
Follow-up as promised: guarded title trial of Result: stopped by the RAM guard during loading at 112.9 s, 1,757 MiB available (GPU 3,263 MiB) — the loading-stage memory wall on this machine is unchanged by this PR, and the empty-library refusal above means its pipeline-library lever is inert here. What the run shows:
No FPS, world-entry, or input-response claim. Logs kept locally ( AI use: omp, harness model |
|
@steven-seagull27 thank you. Your same-list case is right: the twin was only refreshed in the submission's prelude, so a write earlier in the same list never reached it. And your second finding agrees with what I saw in the title: in a run with the logging from 372d56f, the lighting textures took the castable view, and no twin was made. So in 4596ccb the twin is gone. A fallback that misses same-list writes is worse than refusing the view. The castable-view fix (372d56f) stays, along with its once-per-format-pair log of views in a format of another family. I cherry-picked your direct-path test as 0ddd54c, with you as the author. Here it passes on the RTX 5060 Laptop ( The CI failure was the Locally (RTX 5060 Laptop):
|
Fixes found while running Grand Theft Auto VI in Series S mode on a laptop: RTX 5060 Laptop (8 GB, 32-lane waves only), Radeon 780M iGPU beside it, 23 GB RAM, Windows 11. With these it gets past the hangs at the first 3D scene and runs it, with the camera moving. The lit image is still black at the end: what remains is in the lighting pass, below.
This is one branch on top of
main63bcca4. It carries #1960 (wave64 on 32-lane hosts), rebased onto today'smain, so it supersedes that PR.What is in it
Hosts this title did not run on
main'sds_bpermute, which reads within its 32-lane half, and keepsv_readfirstlanereading the first lane of EXEC after Shaders: guarded scalar writes kill stale SGPRs in dead_on_edge #2468 (scalar results unguarded).VICTORY_WAVE64_APPROX(opt-in): runs the refused wave64 programs in 32-lane waves anyway. They can be wrong, but they are not missing. Their loops stop afterVICTORY_WAVE64_LOOPSiterations (64 by default). At 64, some of the title's programs still kept the GPU busy for minutes at the first 3D scene. At 8 they all finish.Rendering
f6e47efa50226beb,3b90165a77d95cdf, …). Each case is logged once, with the address.Format twins: removed after review (they missed writes earlier in the same list). The castable view above is the path the title takes; @steven-seagull27's testpacked_lighting_uav_write_is_visible_to_a_same_list_rgb9e5_srv(ignored by default, needs a GPU) covers it.Memory and tools
host-pipelines-<n>.bin, because Windows refuses to replace a mapped file. They come every 5 minutes, not every 20 s. A run that made no pipeline writes only the early list.VICTORY_PATCH=<rva>:<hex>,...writes title bytes once, before the title runs. I used it to make the title render at 720p by rewriting its display-mode table.VICTORY_DISPLAY_MODElists another display mode.Where the black image comes from (for whoever continues)
From
VICTORY_CAPTURE_WORLD=30andVICTORY_DUMP_TARGETS=1: geometry and materials render.f0c91b4d2578f5bf's 853x480 targets show the characters and the room. The lit HDR target stays black:348e1e8c414c7ecaand63381c3250b287fawrite it, at 853x480, format 10. With this branch nothing is skipped and no root view drops a dispatch, so the next suspect is one of the lighting inputs.VICTORY_TRACE_SHADERS=348e1e8c414c7ecalists them.Testing
On the machine above, Windows 11 26300:
cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings: clean.cargo test --workspace --locked: passes, with two exceptions that behave the same on unmodifiedmain63bcca4 on this machine.emit::memory_tests::heap_direct_texture_reads_mark_their_heap_indexcrashes with STATUS_ACCESS_VIOLATION, so it was skipped. The twostride_tests::a_heap_buffer_*tests andsynthetic_tests::gathers_at_a_level_match_the_hardwarefail.wave64_testspass on the RTX 5060 (split programs) and on the 780M. On a machine without a GPU (CI) they skip.🤖 Generated with Claude Code