Repository navigation
Upstream correctness picks, set 1A - #8
Merged
Merged
Conversation
VICTORY_TRACE_SHADERS now also reads back the records of every indirect execution whose pipeline holds a listed shader, in every frame, not only in dumped capture frames, and the line names the frame. Traced commands are logged without the 500 cap in listed capture frames. Why: whether the tiled-lighting draws get instances could only be seen in frames with VICTORY_DUMP_TARGETS, which cost ~40 s each and at today's speeds never reached a cutscene shot with geometry. Run light2 (traced VS_TiledLighting 25ebc92075b62822): 2,760 executions over world frames 1678-1723, 10-16 of the 60 per frame with an instance in cutscene shots, 2 in sky shots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 0086ccb)
A request into the engine's physical pool carries as its page list a pointer into the engine's own page-number table (sub_144ffd8c0), and Grand Theft Auto VI fills that table for a batch's pages only in its submit path, right before Submit (sub_1400e88f0 runs the batch's page mappings, sub_140f2c470 -> sub_1455aa6a0, then EnqueueStatus and Submit). A queue that submitted itself at half capacity started such reads early: they found page 0 and failed after the 8 ms retry (93-498 requests a run, every one with an all-zero page list in shards2), or found the page's previous number and wrote the data into a page that now belongs to something else, silently. A half-full queue still submits itself, but its reads into physical pages, and the status entries behind them, now wait for the title's Submit; a full queue submits everything, so a title that never submits cannot deadlock. The page list is still read when the data is written. The failure warning names the list, options, file and offset, and an info line counts self-submits (capacity, reads held). Measured: shards2 (before) 33 failed page writes, all with an all-zero page list, and 5 written late; shards3 (after, same build otherwise) 0 and 0, to the 200 s time-out. Self-submits in shards3: 2 by the world's start, the second holding 2,079 reads into physical pages (capacity 4,159): the title's streaming batch is larger than half its queue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit eddde73)
…n the write ends DirectStorage writes streamed data into physical pages through views of its own and then tells the title views showing those pages, so that the GPU side's host copies of them take the new bytes. The list of addresses was looked up when the write started. A page window's decode (zlib or BCPack) takes milliseconds, and the title maps streamed pages into its GPU heap meanwhile (CopyPageMappingsBatchX): the remap marks the copies there, a refresh can take the page before the bytes land (zeros, or part of them), and the report at the end named only the old addresses, so the copy at the new one stayed stale with a clean tracker for good. The addresses are now looked up when the write ends (PageWindow::drop, after the copy in write_physical). An address mapped during the write is reported; one that stopped showing the page during the write is not, and needs not be: the unmap itself marked the copies there, and they read the address's new contents at their next refresh. A mapping made after the report is marked by its own remap. Test page_windows_report_where_the_pages_show_when_done: a page shown at A is mapped at B and unmapped from A while a window writes it; the drop reports B only (and write_physical the same). On the previous code it reports A. Found with the meshlet culling's copies: in title runs 5-8 % of culled batches read meshlet buffers whose host copies (4 MiB windows over the GPU heap's mapped pages) held zeros where title memory held the buffer, with the tracker clean: whole batches culled, run-dependent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2921092)
A take guards a tracked page and every other mapping of the same physical page (the runtime links them when it maps them), so that a write through the title's pool view marks the copy of its tiled heap. But when a tracker went away, every page no tracker held any more got write access back, including a page guarded for a tracker of another mapping: after an exact or buffer copy over the pool view was dropped, the title's writes there went unseen by the loose window over the tiled heap, which stayed clean with stale bytes (shards' sweep: 9,520 such pages, ~620 MB, all guarded at the window's own address; for 2,789 a newer copy held the fresh bytes). Now a page stays guarded while a linked mapping of it is held; the next write there faults once, marks that tracker and opens it. The new test fails without the change (the write through the other view goes unseen). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a3b0f36)
The title reads textures back from the world's first frame on
(CopyTextureRegion, texture to a placed footprint in a buffer) and VIctory
dropped every such copy ("texture to buffer copies not implemented",
TODO.md since 2026-11-23): whatever the title computes from those bytes
on the CPU used stale memory.
The region is now copied on the host into readback memory laid out as
the title's footprint (offset 0, the title's 256-byte pitch), and once the
list has run, before its bottom-of-pipe writes and so before the title
can see its fence, each row of the region goes into the title's buffer
(watch::writing + write_mapped, as copy-backs do). Refused with a reason,
once: depth or stencil textures, pitches not a multiple of 256, regions
outside the footprint. Diagnostics: the first read back of each
(texture, buffer) pair is logged with the texture's memory, size and
format, and every 5 s "texture read backs: N/frame, KB/frame".
Measured (run shards5, this on 5622159): the title reads back two
textures from the world's first frame on, each into one of two buffers it
alternates between: a 5x1 R32G32B32A32_FLOAT (80 bytes, written by
avgLuminanceCompute:LuminanceMinMaxDownsampleFinalCS) and a 1x1
R32G32B32A32_FLOAT (16 bytes, written by
ComputeAverageDepthWeightedLuminanceFromHistogramCS): the auto-exposure
values its CPU side adapts with, so far read stale. 4.0 read backs a
frame, 0.2 KB a frame; nothing refused.
Tests: a footprint's row ranges, and a round trip through the title's API
(a texture filled from a buffer through our list's copy slot, a region of
it read back into a second title buffer through the same slot, run by our
queue; the region's rows land at the footprint's offset and pitch, the
rest of the buffer is untouched). The round trip caught a first version
whose readback memory ended at the region's last row: the host copies
into a footprint only in a buffer that holds all of it, so the list
failed and the process ended.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5cb63d8)
The console's 16-bit depth with stencil (formats 118-120; Grand Theft Auto VI's material depth) was a host D24S8 texture. CS_GenerateMaterialMasks and CS_MaterialTilesInitial write it through 16-bit unordered views (the depth twin), the 180 tiled-lighting draws then test it EQUAL at z = the material index times the title's 1/65535 (0x37800080), and the twin reached the depth plane as 24-bit unorm by copy. On the RX 6700 XT a draw at those depths passed EQUAL for k = 258 only of 1..4096: the driver keeps 24-bit depth as floats (AMD hardware has no 24-bit depth), so a copy stores d24 / (2^24 - 1) and the rasteriser the unquantised z, and the two agree only by accident. Every tiled-lighting draw failed its depth test on every pixel. Now 118-120 are D32_FLOAT_S8X24 (20-22) on the host, and the twin converter writes the float the title's own shaders compute for 16-bit value u, f32(u) * 0x37800080 (back: round(f * 65535)), so the depth plane holds the very float a draw rasterises. That float equals the correctly rounded u / 65535 (what the console's R16_UNORM view reads) for every u but 512 values from 257 up (1 ULP); every float rounds back to its u. Evidence: a_depth_texture_written_through_unordered_views_reads_as_depth now draws a square (two triangles, as the title's rectangles become) per pixel at the title's depth for k = 1..4096 against the UAV-written plane and asserts all pass (24-bit: only k = 258), on the RX 6700 XT (suite 147 passed) and WARP (150 passed, with diagnostics); the twin round trip, stencil and clear-to-16-bit checks still pass. Runs light5-light7 (240 s, warm, with the luminance read-back): no crash or removal. Run light7, frame 1515 (raw dumps): the lighting records with an instance (0, 1, 5, 7, 29) are exactly the material indices present; pixels whose 128x120 group lets their draw run are 86-99 % exactly zero after the lighting submission (index 5: 1.31 M pixels, 99 %), pixels whose group culls it only 41-60 %; the lighting pipelines test depth EQUAL, write no depth, use no stencil, depth bounds or blending. So the draws now pass and overwrite the target with their own result. Expect DARKER surfaces in the cutscene until the shadow tracing runs; not a regression of this change. Before it, those pixels kept what the material mask pass had written into the lighting target (light3's "lit-looking" buildings were those leftovers, not light). The tiled-lighting shader's per-light shadow factor reads a tile map and atlas (15360x180 R32_UINT, 4096x3640 R8_UINT) that are all zero because CS_TraceShadowRays_Checkerboard is dropped untranslated, so every shadowed light is skipped and the result is 0 there. Shortcut (comment at pc_format): a depth bias on such targets counts in float steps, not 1/65535. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 98c654b)
What was wrong: `run` kept the exe as read (114 MB) and its patched copy (another 114 MB) alive until the title exited, though nothing reads them after the loader writes the patched copy and maps it: ~228 MB of the Rust heap for the whole run (large-allocation stacks of run textures8). What changed: the read bytes are a temporary of `prepare`, and the prepared image is dropped right after `load`. The mapped image, its path (`GetModuleFileName`), title DLLs and crash reports come from the loaded image and the files, not from these buffers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 5c4c685)
A frame-event wait (the title's flip wait before each present) always slept until the next tick after now, even when the frame had run long past the tick it was waiting for: in the intro cutscene, where frames take 0.5 s against a 33 ms interval, that added 0-33 ms to every frame (4 % of the submitting thread's samples, run perf3). A wait now takes the latest tick passed when that is after the last tick its kind took (still one wait per tick per kind), as an event signalled at each tick and left signalled until a wait takes it would; the next wait waits for the next tick as before, so a title that keeps up is paced as before. That a late wait returns at once on the console is an assumption: nothing at hand says what a wait begun after its event does. Diagnostics: per stats window, frame waits and those that ended at once, and presents whose flip tick was the previous present's (should stay 0). Test: after two missed ticks a flip wait ends at once on the latest one, the next on the tick after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 9c179ea)
host.rs: keep both diagnostics lines (heap stats and texture read backs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upstream correctness fixes cherry-picked (
-x, upstream authorship kept) ontomain(d11272a). No shader translator change, so existing shader caches stay valid.Picked (8)
0086ccb49dc509eddde735038ccc29210921d5984da3b0f36f63357a5cb63d8aff2d6b98c654bac85b0b5c4c68546b00cb9c179eae2a8151Resolutions made while picking:
2921092(xmem.rs): kept the lazy copy-back flush of pending GPU writes before a write into physical pages (at the addresses showing the pages when the write starts), and took upstream's report at the addresses showing them when the write ends.5cb63d8(host.rs): upstream's newmapped_buffer(size, readback)has the same name as our shared-buffer helpermapped_buffer(size, upload); ours is renamedshared_mapped(two callers). Folded into the pick so every commit builds.9c179ea(frame.rs,host.rs,queue.rs): the real change is dropping the+ 1in ournext_tick; the configurable-interval and uncapped paths are kept, upstream's wait counters and its late-wait test sit next to ours.Not in this PR
9cc37c5(lists wait on memory values; queues hold work): picked first, then dropped. With it the live run ended with exit code0xC0000005on the first world frame (+95 s), with no crash report and no device removal; the same run without it was stable for the full 241 s. One run each, so this is an attribution, not a root cause. It also sits on upstreamf68442f, which is not picked: its own testa_list_waiting_for_another_queues_write_reads_what_it_wrotefails here at its last step withoutf68442f, andf68442fconflicts inbindless.rsanddraw.rs(it belongs with the placed-texture chain). Bring both in together.2d4aa55(snapshot pool keeps at most 512 MiB): picked, measured, then dropped. In the measured run page faults went from about 8,400-9,000 to 50,000-73,000 per frame and the frame got about 60 ms slower (numbers below). It is the only pick that touches the pool, and a pool that drops buffers means fresh ones with a page fault per 4 KiB. The head of this PR is the measured tree minus that one-constant change; it has not had a live run of its own.315cea1(barriers from real states; the indirect clamp writes its own argument buffer): skipped,indirect.rs/draw.rsare being changed elsewhere right now.0086ccbabove is its context prerequisite.f68442fand the placed-textures-on-read chain: a later set.Gate
On the tree with
2d4aa55still in:cargo clippy -D warningsforvictory-gpu,victory-hleandvictory --features diagnostics;cargo test -p victory-gpu -- --test-threads=1182 passed, 5 ignored;cargo test -p victory-hle146 passed;cargo xtask policyok. After dropping2d4aa55(one constant back to its value onmain): clippy forvictory-gpuandvictory, policy, and the diag build again; tests not re-run.Live runs (RTX 5090, diag build, uncapped, upload heaps and lazy copy-back on, 240 s each)
Steady state in the world, against the previous build's run with the same switches (capped pacing). "with 2d4aa55" is the 8 picks plus
2d4aa55(+201 s to +241 s); "this PR's head" is the head of this branch (+163 s to +239 s, one 468 ms spike at +229 s left out):2d4aa55Dropping
2d4aa55brings the frame back to the previous build's range (about 3 fps). Preparing sits about 10-20 ms above the earlier run and page faults about 4-7k higher; with one run each that is within run-to-run noise and no single pick can be named for it.About 5,000 draws per frame, about 265 dropped without a host pipeline and 18 indirect, as before. Texture read-backs run (8.0 per frame). Both runs: no device removal, no crash, ran to the 240 s cap.
Captures: the world frames are not like-for-like with the earlier run (the uncapped menus put the captures at other cutscene shots). What they show: surfaces are still unlit silhouettes against a bright, slightly blown-out sky. No lighting or exposure change can be claimed from them.
🤖 Generated with Claude Code