Repository navigation
Merge upstream 67e8ae1: barrier states fix, float depth twins, refresh rewrite - #14
Merged
Merged
Conversation
`bind()` returned false without a reason when a root view's address lay in no host copy, was not set by the title, sat 4 GiB or more into its copy, had no host view heap or found no dynamic slot. The drop ranking then showed such draws as dropped "()": in the intro cutscene about 310 dispatches a frame (run mk3), almost all compute programs of the BVH builder whose root view address is in no host copy. Every such return now records its reason through `not_run`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…GPU time per pipeline The fps line left a share of "preparing" and of the GPU time unexplained. Three diagnostics (diagnostics builds only): * copystat: time making the descriptors the title copies into its heaps as bytes (`sync_heaps`, start of every submission). Run perf1 (intro cutscene, DRED off): 120-180 ms a frame, 13 % of the submitting thread's time, unattributed before. * A "video memory" line: use and budget on the card and in system memory (`QueryVideoMemoryInfo`), to tell whether the memory manager pages at submissions. * With `VICTORY_GPU_TIMING`: GPU time per kind of command and pipeline over each stats window (the 25 costliest), and the lists' wall time against the sum of their commands'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hey took it Every world submission asks for every host copy its heaps' views and page tables reach (~9,000 copies) to be brought up to date, and almost none changed: run perf1 (intro cutscene) made 140-240k change checks a frame, each taking two locks, a set range query and allocations, plus per-copy timing and statistics: ~18 % of the submitting thread's time (refresh batches 195-405 ms a frame in all, the copying itself ~12 %). Each tracker now keeps a flag "some page changed since taken", set where pages are marked changed and cleared where they are taken, all under the tracker's lock, read without one. A batch leaves out clean copies and `Shadow::update` returns at once for them: the same result as before (a take finds nothing), minus the work. A write racing the flag is found by the next submission, as one racing a take always was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…of their own Releasing a resource is a kernel call. In run perf1 (intro cutscene) ~5 % of the title's submitting thread went into releases inside the submission: resources retired while the GPU ran, host copies whose last holder was the submission's own bookkeeping, and (diagnostics) a read-back buffer made and freed at every present for the black-frame probe. Retired resources and the submission's batch, copy-back list and heap list now go to a `victory-release` thread once the submission has run (nothing in flight uses them); the probe keeps one buffer (presents are waited for one by one). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
…p sync `HostHeap::mirror` left a placed texture's view null until a draw reads it through a table, and recorded its slot as never made, so every heap sync (one per submission, over every page the title wrote) processed the slot again: a null view written and the heap census updated each time. `perf`'s profile of run perf1 put `sync_heaps` at 120-180 ms a frame (13 % of the frame thread), most of it these slots (9,000-16,000 placed-texture slots left null in the cutscene, run textures1). The slot's record is now noted like any other; a draw's mirror still makes it (its slot holds no host view yet). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diagnostics builds, every 5 s: the video-memory line also gives the process's private commit and working set, texture staging bytes (upload buffers and title memory read for them) and the console bytes of placed textures made; a second line gives host texture bytes by writer (the GPU: render target, depth or unordered access; or title memory) and by reach (used by a list, only viewed by a heap slot, neither). The heap census also names the placed textures left null: distinct addresses and bytes. Run textures1 (cutscene, with a since-dropped eager step for small placed textures): card 12.3-12.4 GB used of a 10.78 GB budget, system 6.8-7.1 of 16.3 GB; GPU-written 2.29 GB used by lists, 2.10 GB only viewed, 0 neither; from title memory 1.63 GB used, 0.43 viewed, 4.8 GB neither; placed textures left null 12-16k slots at ~12.5k addresses, 8.4-8.9 GB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every title texture got a host texture (VRAM) when the title created it. Run textures1's census in the intro cutscene: of 11.6 GB of host textures, 4.8 GB were textures fed from title memory that no list ever used and no heap slot ever viewed, and the card's usage was 12.3-12.4 GB against a 10.78 GB budget. A title texture's host texture is now made the first time anything asks for it: a list's barrier, binding, copy or upload, a heap slot's view. As textures of one memory can now be made in any order, the first one made takes the uses (render target, depth, unordered access) of every title texture of that memory, so a later one with more uses shares it instead of replacing it (which had left the first one's views on a texture the GPU never writes). The creation's state and clear value are kept for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At `victory_gpu::texture=debug` (diagnostics builds): every detiling of a sampled texture says whether its memory was all zero, and a sampled texture that keeps what the host copied into it (never uploaded from title memory again) is named once. For the terrain's mesh-stage texture that `shards` found holding zeros (run shards2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
A journal-tracked texture's detiling read its title memory into a buffer the texture's staging kept for its whole life: each such texture took its size once more in system memory, besides its upload buffer. The read is now a temporary. Texture staging in the cutscene: 414 MB (run textures2, read buffers kept) against 195 MB (run textures3, not kept). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dumps write 8-bit colour as is and drop alpha; a line per dump now gives each channel's range and how many texels hold zero there (the grass trail map's alpha, for the missing ground). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Snapshot buffers kept for reuse were capped at 2 GiB of private commit. Since shaders mark the pages they write (cd94d35), the cutscene snapshots 0.1-0.8 GB a frame over 26-45 submissions (run textures5: 402 MB a frame; mk2/mk3: 10-134 ms of snapshots), the largest single one the 174 MiB GPU-heap buffer; 512 MiB keeps two of those and frees up to 1.5 GiB of the process's commit (the title's world runs at 25.6-26.9 GB on a 32 GB machine). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tics) The video-memory line also gives the bytes committed in every process heap (Rust code's and the title's C runtime's) and, through a counting global allocator the binary installs in diagnostics builds, the bytes Rust code holds: the 12.5 GB of plain private commit not yet attributed (run textures5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`watch::track` decided from a range's first page whether the whole range was the runtime's GPU memory. Memory outside title buffers gets a host copy of its 4 MiB-aligned window (`shadow::loose`); a window whose first page was free memory was tracked whole, and taking it guarded (made read-only) every committed page in it, other allocations' too. In the crate's tests a constant view of a heap block did that to the process heap: threads faulted inside RtlFreeHeap/RtlAllocateHeap while holding the heap lock and waited in the guard handler for the guard lock, whose holder (a take in another test's submission) waited for the heap lock. The suite hung about one run in two on a branch that added such a test (stacks of two hung runs; the reading of who held which lock is inferred from them). The decision is now made for every region the range covers: write-watched pool memory, or with views anything but plain committed memory and images, as before for the first page. A 64 KiB page touching any other memory is not tracked: never guarded, and copied whole at each use, as a copy of memory with no tracker always was (such a copy is never clean). One write-watch query still answers the common case (the range in one pool) without `VirtualQuery`, which costs milliseconds in the runtime's big pools; the region walk runs once, when a copy is made. In boot-to-world runs no memory was copied whole (perf2, perf3, mk3: 0.0 MB in every window), so this is about robustness. Tests: a window from free memory over a plain allocation into a pool guards the pool only; a title buffer over a pool and a plain allocation copies the plain part at each use, its bytes and their later change, and leaves it writable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y the changed ones Each submission's heap sync (descriptors the title copies into its heaps as bytes) mirrored every slot of every heap page written since the last sync: ~700,000 slots a frame in the intro cutscene (run perf3), two lock takings and a view clone each, 76 ms a frame after the placed-texture fix (113 ms before it, run perf2). `HostHeap::sync_slots` reads a page's records, asks the view registry once whether each names a current view, compares them with what the slots hold under one lock, and calls `mirror` only for slots whose record differs from what the slot holds: the decisions `mirror` makes for the others are to do nothing, so the result is the same. Test: a record copied as bytes and a record cleared are made at the next sync, the others passed by. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…se bitmap The flag from 1953339 let a submission skip host copies the title had not written, but reading it still touched each copy (copy, tracker, flag: a cache miss or more each) and the heap step cloned its ~9,000 merged ranges first: the heap and page-table steps still took 25-41 and 16-26 ms a frame (run perf3) to find the few written copies among ~14,000. Each tracker now owns a bit in a static bitmap (set and cleared under its lock as before, read without one; given back when the tracker goes). The heap's merged ranges and the page table's copy list keep each copy's bit beside it, and both steps read the bits, walk their lists in place and pass only written copies to the batch. Test: a new tracker starts dirty, a taken one reads clean, a tracker with no bit is never clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…keys keep the pipeline * copystat: time spent in copies that met an unmapped page and were redone by 64 KiB and 4 KiB pieces (10-22 MB of unmapped memory a frame in run perf3, thousands of failing kernel reads, not counted before). * `VICTORY_GPU_TIMING`'s per-pipeline table dropped every word starting with a digit, so pipeline hashes starting with one vanished from its keys; the key is now the command's kind and the pipeline's name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A view the title places off its buffer copy's elements gets a host copy of its own bytes (`shadow::exact`), and each was a committed buffer of its own: a kernel call to make it (and one to free it) on the title's recording threads and on the submitting thread during heap syncs, 240-820 a frame in the cutscene, and 64 KiB of memory each for ~2 KB of data (~5,000 live). A stack sample of a `drops` run caught the submitting thread in that kernel call inside the heap sync, which holds the heaps' lock, while three title threads waited for that lock to write views. Such copies now take runs of shared 16 MiB buffers (first fit; a run starts at a multiple of the view's element and of 256 bytes, so the view's first element stays exact; a copy larger than a buffer gets one of its size); a run goes back, joined to its free neighbours, when its copy goes. A host copy knows where it starts in its buffer (`offset` adds it; its mapping and host address point at the run), so the views made over it are unchanged. Copies are now keyed by element size too. Test: runs are aligned to their elements, disjoint, and joined again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s in video memory * copystat: time title threads spend waiting for the shader-visible heaps' lock when they write a view (held by each submission's heap sync). * `VICTORY_COPIES_IN_VIDEO_MEMORY=1`: shared buffers, host copies of title memory among them, in a GPU upload heap (video memory the CPU maps) where the host has one, to measure how much of the GPU's time is shaders reading copies across the bus. CPU reads of the copies get slow (snapshots, copy-backs): for that measurement only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…after each change Each list running heap-indexing shaders asks for the ranges every view of the heap reaches, merged per host copy; they were rebuilt from all ~9,000 copies whenever one range came or went, which the title's view writes do between most lists: the heap step still took 13-27 ms a frame in run perf4 although it now passes clean copies by. The merged range of a copy is now updated where its ranges are counted, only for that copy, and the step walks the current set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the memory line (diagnostics) The counting allocator logs the stack of the first allocation of each power-of-two size class from 32 MiB (who holds our 1.8 GB of large blocks, run textures6), and the video-memory line counts the live list upload blocks (list 0x4a0) and their bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es changed Every list that read a title-written texture through a table recorded the copy of its staging buffer into the host texture, changed or not: run perf7 counted 3,195 texture copy commands in one frame for 149 textures (a 64x64x32 R16 array 24 times, a 512x512 BC7 18 times), 17 ms of GPU time, the largest single GPU item. A list now only defers the texture (staging and host texture). At submission the textures of all its lists are brought up to date once, and those whose memory changed are copied by the submission's own upload list (the one heap-indexed textures already had), which runs first. For memory the change journal follows, a flagged page uploads the texture only if the texture's own bytes changed (a 64 KiB page holds other data too). As for heap-indexed textures, a title copy into texture memory recorded in the same submission shows from the next one on. Test: two lists of one submission upload a texture once, the next submission not at all, and again once the title writes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The per-frame drop ranking (diagnostics) counted draws and dispatches that have a host pipeline but cannot be bound by reason alone, so a reason's hundreds of drops a frame could not be traced to the programs behind them without a traced list. The key now ends with the pipeline's shaders, as the "no host pipeline" keys already do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A descriptor every lane shares, chosen by an if/else nested in another, reaches the outer join with an edge that is itself a join. Such an edge was refused with "a descriptor chosen by control flow": each edge had to be a heap load. The heap index is now computed recursively: a load's index, or a phi at the join of what each predecessor computes at its end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A uniform descriptor joined at a block was traced along every
predecessor edge, so an edge no lane takes stopped it with the registers
it would bring: `indirect_light_probes:CS_Alpha_Schedule` and
`alphaResolve:CS_AlphTransmissionPrefilterMip` load a texture under the
lanes that ran before `s_wqm` and skip the load when there are none; in
compute every lane runs from the start, so nothing takes the skip, but
the skip edge's stale input SGPRs made "a descriptor neither loaded nor
built".
`resource.rs` now gives such an edge (structurisation's lane conditions:
the edge's reach and branch condition cannot hold) a taken edge's source,
and lowering joins a 0 heap index there (`never_taken`, the same test),
so nothing is computed on an edge no lane runs.
Test: `a_descriptor_skipped_only_by_lanes_that_never_run_needs_no_source`
(the `s_wqm` / `s_and_saveexec` / skipped load / sample shape; refused
without the change). Shader list against `main`: 0 newly failing;
`CS_AlphTransmissionPrefilterMip` and
`shadowmask:CS_TraceShadowRays_ScreenSpaceOnlyCheckerboard` emit,
`CS_Alpha_Schedule` stops later ("an address into a descriptor heap with
an untracked high half": the address's high half is set inside the same
skipped region).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title's wave-uniform BVH walks (`shadowmask:CS_TraceShadowRays_ Checkerboard`, `deferred_tiled:CS_LaserLightShadowRaytracing`, the four `rtdirectionalshadows:CS_RTDistantShadow*_Tiled`) keep the lanes of the node being visited in an SGPR: a lane mask on entry, a number popped from an LDS stack (`v_readfirstlane_b32`) on the loop's back edges, read both as a number (`v_and_b32` with the lane's bit, `s_cmp`) and as a mask. The join was refused: "a register joining a lane mask and data, read as data" (40 programs), then "a lane-mask join of an untracked mask". At a join where every branch in is uniform (SCC), every lane comes along the edge the console's wave took, so the register holds that edge's value. In compute (console lanes) a mask's number on its edge is its ballot there (`mask_dword`), exact; read as a mask, a number gives each lane its own bit (`lane_bit`, as `Atom::Opaque` does). A per-lane branch into the join (an EXEC skip, a per-lane loop exit: where lanes would take edges the wave did not; the console compiler's if/else always enters its join that way) keeps the refusal. Tests: `a_mask_joined_with_data_needs_a_uniform_join` (the per-lane loop still refused, the uniform one lowers); `synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_number` (a mask shifted through a VGPR around a uniform loop, read as a number and as each lane's bit; values checked on the GPU, hardware and WARP; fails without each half of the change). Shader list against `main`: 0 newly failing, 29 newly emit; all 40 "a register joining a lane mask and data" programs pass it (16 stop at a later mask join). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Takes back PR Marvisak#1012's recursive heap index (an edge into a descriptor's join that is itself a join). Across the title's shader list it lets one program through, `indirect_diffuse_lighting:CS_ScreenProbes_ActivateRays` (issued every cutscene frame), and that program's host pipeline does not fit the machine: the DXIL validates in 4 s, but the AMD driver's compile passed 6 GB after 64 s under a watchdog (unwatched it reached 26.7 GB commit and starved a title run, drops2). Its DXIL has 22,382 branches, 2,609 heap handles and 2,478 size queries (151k lines), against 3,857 branches for the next largest newly emitted program, which compiles in 24 s and 0.8 GB. The refusal is "a descriptor chosen by control flow" again, as on `main`; edges no lane takes still join no heap index (previous commit). The change can come back once pipelines this costly stay off the title's pipeline worker (`shortcut:` at the arm). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d past the card's budget What was wrong: a host texture, once made, lived as long as its title texture; placed textures (made when shaders read them) for the whole run. The title views far more textures than one frame reads (8.4-8.9 GB of placed textures left null in run textures1), so making them as they are read only grows video memory until the card pages or the process runs out of commit (30.8-32.2 GB with the read marks alone). What changed: a title texture's host texture can be given up and made again on its next use (the owner is a resettable slot; host copies are returned owned). Host textures fed from title memory (no render target, depth or unordered access, nothing written by host copies) carry use stamps: a list of the title's naming them (tables, copies; our own upload lists do not stamp), and, at each pass, every read mark set since the last pass on a heap slot viewing them (the marks are then cleared; a slot's read is reported as new only once, so stamping on the first read alone gave up textures read every frame: run evict1 gave up and made again hundreds a frame). Once per presented frame, before a submission, those unused for 120 s and 300 presented frames are given up (shorter idle times gave up textures read again within a minute, runs evict2 to evict4), and past 90 % of the card's budget the least recently used others until 85 %. Giving one up first gives every heap slot viewing it a null view of its kind (retired until the running submission has run; the record stays noted, so heap syncs pass it by and a draw's or shader's read makes it again), then the title textures let go of it; lists recorded before hold it until they are reset, so no GPU work reads it freed. The next use makes it again from title memory (a fresh upload). Uploads of heap-viewed textures skip those not made. GPU-written textures are never given up; they go with their title texture. The cap on placed texture bytes is gone (the budget bounds video memory instead). Measured, 240 s of the intro cutscene each. With giving up (run evict2) against without (noevict1, the same tree with the pass off): card memory flat at 7.6-9.5 GB against 6.4 GB rising to 10.4 GB (86 % of the budget) at the end; host textures 6.1-7.8 GB against 5.2 GB rising to 8.6 GB; process commit 26.2 GB against 27.7 GB on average (29.7 GB and rising at the end). With the rest of its stack (run evict6) against main (perf13): median world frame 1,206 ms against 475 ms; frames uploading under 50 MB of textures 559 ms (+18 %, run evict4); a new shot's uploads cost 3-4 ms of frame per MB. Evidence: tests `host::tests::textures_read_every_frame_stay_and_title_lists_stamp_theirs`, `host::tests::heap_reads_since_the_last_pass_name_their_textures`, `draw::tests::a_texture_given_up_is_made_again_with_its_bytes_and_recorded_lists_keep_it`, `descriptor::host::tests::a_slot_viewing_a_texture_given_up_is_made_again_when_read`, `resource::tests::only_textures_fed_from_title_memory_are_given_up` and `resource::tests::idle_textures_go_and_past_the_budget_the_least_recently_used`; the crate's tests three times with 8 threads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… read them lately What was wrong: at every submission (about 30 a frame), every texture any heap slot of a heap-indexing list viewed was brought up to date: its staging refreshed and, where its pages had changed, detiled and uploaded, read or not. With placed textures made when read (4-8k textures, 5-8 GB viewed by the heaps) that re-uploaded about 4 GB in 30-46 world frames and took 0.3-3.7 s a frame (runs evict2, noevict1; main 5-25 ms). What changed: a heap-viewed texture is brought up only if the title used it in this presented frame or the last (made then, named by one of its lists, or read through the heap as the eviction pass's stamps found). Textures lists read through tables keep their own rule (the list names them). Uploads of heap-viewed textures are counted with the others. shortcut: a texture read again after a gap is brought up after the submission that read it, which can see bytes one refresh old. Evidence: test `host::tests::heap_textures_unread_lately_are_not_brought_up` (a viewed texture whose pages changed is not uploaded while not read lately; stamped as read, it is); the crate's tests twice with 8 threads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… lock What was wrong: after each submission, the views of heap slots shaders read for the first time (read marks) were made under `SHADER_HEAPS`, which every title thread writing a view takes: making a placed texture (its resource and host texture) took up to milliseconds each, and title threads waited 1-6 s a frame to write views (runs evict2, noevict1; main 0.2-0.3 s). What changed: the slots are looked up under the lock, the placed textures they view are made without it (they are never released, so they outlive it), and the lock is taken again only to make the views. Evidence: test `descriptor::host::tests::views_written_while_read_slots_get_their_textures_do_not_wait` (another thread writes a view while a read slot's texture is being made and finishes within a bounded wait); the crate's tests twice with 8 threads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was wrong: every slot the title rewrote updated a map from each host texture to the slots viewing it (for giving textures up), searching the texture's whole list to take the slot out. A texture viewed in thousands of slots made each rewrite cost ~25 us; the title rewrites ~62,000 slots a frame (it copies per-draw descriptor tables into its heap), so heap syncs took 0.6-2.9 s a frame and held the heaps' lock that title threads writing views wait on (run evict3: 62,208 stale slots a frame at 25.7 us each, 16 us rising to 34 us as the lists grew). What changed: no map; giving textures up walks the heap's slots once per pass that gives any up. Evidence: tests `descriptor::host::tests::a_slot_viewing_a_texture_given_up_is_made_again_when_read` and the eviction tests; the crate's tests twice with 8 threads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts pages What was wrong: textures the heaps view are refreshed at every submission where the title used them lately: 123,000 refreshes a frame (run evict3), each taking its tracker's lock to find, almost always, nothing changed. What changed: a refresh of a tracked texture first reads the tracker's dense clean bit, which needs no lock, and stops there if it is clean. Evidence: the upload tests (`draw::tests::a_texture_is_uploaded_once_per_submission_and_only_when_written`, `a_texture_owning_its_pages_is_uploaded_on_any_write`, `a_write_into_one_mip_uploads_that_mip_alone`); the crate's tests twice with 8 threads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was wrong: making a heap slot's view held the heap's slot lock throughout, including making the texture it views (on first use) or the host copy of the buffer memory it views: title threads binding views for draws and writing views waited on that lock (119 of 307 samples of title threads in our code, run evict5). What changed: a slot whose view is unchanged is answered under the lock as before. One to make again releases the lock, makes what the view needs without it, takes it again and, if the slot still holds the record it prepared for, makes the view (cheap now); if the title wrote another record there meanwhile, that record is made instead. Evidence: tests `descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait` (a thread binds a view while another slot's texture is made, bounded wait) and `a_slot_rewritten_while_its_view_is_prepared_views_the_new_record` (the title writes another record into the slot during the prepare; the slot views the new record's texture); the crate's tests three times with 8 threads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was wrong: at each submission the textures to bring up were read from title memory, detiled into staging buffers and copied one after the other on the submitting thread, while the heaps' view registry stayed locked: in a new shot that was about a third of the submitting thread (reading memory 19 %, making staging buffers 10 %, detiling 6 %, run evict5), frames grew 6-10 ms per MB uploaded, and title threads setting views waited on the lock throughout. What changed: what to bring up is collected under the heaps' locks, then refreshed without them on up to four threads (a quarter of the CPUs), those whose trackers are clean skipped, then recorded. Staging buffers come in powers of two (at least 64 KiB), so a buffer serves other sizes, and are made without the pool's lock. The tracker still decides the bytes: its pages are taken (and guarded) before they are read, so a title write during the read or detile marks them again and the next refresh brings them up (`watch::tests::writes_mark_every_tracker_of_their_page`). Evidence: tests `host::tests::heap_textures_brought_up_together_each_get_their_upload` (six textures refreshed side by side, each uploaded once, none again when unchanged) and the upload tests; the crate's tests three times with 8 threads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…opies at once What lists using title memory write while the frame withholds stays in the host copies until the frame's end: through the page table, through root views (byte for byte) and through marked views. When a list of the submission read or wrote memory with no copy, those results are garbage computed from zeros (BVH builder nodes: +-inf bounds, 0xffffffff, rising u16 pairs), and later submissions of the same frame read them from the copies: in run shards20 the meshlet culling read such bytes in its per-batch meshlet buffers (stale copies with no title-side event after their take; 95.59 % of the batches walked equal to title memory). Now what such a submission withheld counts as changed in every buffer copy holding it right after it completes (`drop_withheld`, which takes the place of `drop_at_frame_end`), so the next submission's refresh takes it from title memory again. What submissions that missed nothing withheld keeps the frame-end retake. Run shards21 (2921092 + the page-table part alone + branch-only diagnostics, same listing as shards20): one list per world frame wrote through the page table, every one missed and was retaken at once (34-19,446 pages); stale copies written through the page table are gone, 98.12 % of 13,509 batches walked equal title memory. Every sampled stale batch left was last written through a declared, unmarked view with no retake after it (the builder's root UAVs, which the page-table path leaves to the byte-for-byte path), hence the root and marked views here too. Test: memory::tests::a_submission_that_missed_leaves_the_copies_at_once (a write through the page table beside a miss; fails before the change: the next submission reads the write instead of title memory's bytes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A console rectangle list gives three corners per rectangle and the hardware adds the fourth opposite the right angle. The geometry shader that completes them on the host (and the CPU expansion used without it) took the right angle to be at v1, as the blits give it (top left, bottom left, bottom right). The tiled lighting's vertex shader (VS_TiledLighting, 3 vertices per tile: corner c = vertex % 3 at x + bit 1, y + bit 0) gives top left, bottom left, top right, the right angle at v0, so every lighting tile drew its upper-left half and the lower-right half of the tile above: tiles whose neighbour below was in another list lost their lower-right half and lit the one above, the right-triangle wedges along silhouettes and kerbs of runs shards22 (frames 1603, 1615, 1627; their depth is clean there). Now the right angle is the corner opposite the longest side (`emit::right_angle`, ties and NaN keep v1), the fourth corner is va + vb - vc and the second triangle (va, vb, v3), turning as the first for any three points; the CPU expansion takes the same rule from the first float element of two or more components. Tests: emit::rect::rule_tests::right_angles_are_found_in_any_order; emit::rect::tests::rectangles_get_their_fourth_corner draws the three orders (and three points on a line, which draw nothing) on hardware and WARP, and fails with the old rule; primitive::tests:: rectangles_complete_opposite_their_right_angle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was wrong: each texture brought up took a staging buffer of its own size class from a pool, and the pool's free buffers rarely fit a new shot's sizes: making upload buffers was 10 % of the submitting thread in a new shot (run evict5), one committed resource per texture. What changed: staging space up to 32 MiB is carved, front to back, from 32 MiB upload buffers, 512-byte aligned as texture copies need; the copies read their footprints at that offset. The chunks are rewound at each submission (the last one has run, as for the pool) and 16 are kept. Larger textures keep a buffer of their own from the pool. Evidence: test `draw::tests::textures_uploaded_together_each_read_their_own_bytes` (two textures brought up in one submission, the second at an offset in the same chunk, each read back with its own bytes) and the upload tests; the crate's tests twice with 8 threads (a timing test of frame waits, `frame::tests::waits_end_on_ticks_and_count_frames`, failed once while a title run loaded the machine, and passed in the other run). Measured together with the upload barrier batch (next commits' run shots2, 240 s of the intro cutscene, quiet): world frame median 964 ms (mean 1,038) against 1,169 ms with only the parallel creation (run shots1) and 1,206 ms before (run evict6); preparing 497 ms against 706; texture refreshes 264 ms for 135 MB a frame against 745 ms for 154 MB. The two were not measured apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was wrong: after a submission, the placed textures of heap slots its shaders read for the first time were made one after the other on the submitting thread, and `texture_at` held its map's lock while making each host texture: in a new shot, hundreds of committed textures, 7 % of the submitting thread (run evict5). What changed: `texture_at` makes the host texture after letting go of its map's lock, and the read slots' placed textures are made on up to four threads (a quarter of the CPUs), with the helper the texture refreshes use. Evidence: test `resource::tests::placed_textures_made_side_by_side_are_one_each` (four threads asking for four memories: one resource and one host texture each) and `descriptor::host::tests::views_written_while_read_slots_get_their_textures_do_not_wait`; the crate's tests twice with 8 threads. Measured alone (run shots1: main 8ff7913 and this commit, 240 s of the intro cutscene, quiet): world frame median 1,169 ms against 1,206 ms before (run evict6), preparing 706 ms against 709: a small gain; the staging chunks and the barrier batch carry the rest (run shots2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was wrong: the upload list a submission runs first recorded, for each texture it brought up, the copies and then that texture's barrier back to shader reads, so every barrier sat between one texture's copies and the next one's. In a new shot the list holds hundreds of textures (154 MB a frame in run shots1), and each barrier kept the GPU from overlapping the copies around it. What changed: record_upload returns the barrier instead of recording it, and the upload list records all of them in one call after the last copy. Evidence: textures_uploaded_together_each_read_their_own_bytes (two textures uploaded by one submission each read their own bytes) and the other upload tests pass. Measured together with the staging chunks (run shots2, 240 s of the intro cutscene, quiet): world frame median 964 ms against 1,169 ms without the two (run shots1); GPU 313 ms against 351. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ir list misses A list in which a program using title memory read or wrote memory with no copy had every range its shaders declared withheld from title memory (and, since ec9e750, dropped from the host copies right after the submission), whichever program declared it. The BVH builder's list also holds ordinary programs (run light13, one list: ~1,000 builder dispatches beside billboard_nobump:CS_ComputeImposterTransform x250, CSGenerateHairVB/IB, bvh_skinning, CS_InstanceRotationFixup), so their output never reached title memory and, after the drop, never reached the frame's later draws either. Now each declared range records whether its program uses title memory (the draw or dispatch being bound, `HostList::writer_uses_memory`), and only those ranges are withheld when their list misses. Other programs write through bounded views from their own inputs: their ranges go back as before the withholding. An ordinary range overlapping a withheld range of the same copy is withheld with it, since its copy-back would take the other's bytes along. Test: host::withholding::only_programs_using_title_memory_are_withheld (a missing list with an ordinary write, a title-memory program's write and an overlapping ordinary write; fails with the whole list withheld). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ssion What was wrong: `texture::host_written` marked a texture as written by the host (a copy, copy-region or resolve into it) when the list holding the copy was recorded, and textures read through tables were checked only then, by `texture::upload` at record time. A list recorded before the writer but submitted after it kept its upload due: its submission uploaded title memory over the texels the host copy had written. Submissions need not run in the order their lists were recorded (`light` is changing the order to the title's own waits between queues), so this decision belongs to the submission. What changed: `texture::host_writes(list, resource)` marks the texture from the submission that runs the writing list (a deferred host step), and the submission's upload gathering skips table-read textures so marked, as the heap path already did. A reader submitted before the writer still gets its upload; one submitted after keeps the host's texels. Evidence: test `draw::tests::a_list_run_after_a_host_write_keeps_the_host_texels` (a reader recorded, title memory written, a later-recorded writer submitted first, then the reader: the host's texels stay). Without the submission-time check it fails (the title's new bytes, 0.502, uploaded over 0.251). victory-gpu tests 179 passed; workspace clippy clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was wrong: every host texture was a committed resource, made one by one. A new shot brings hundreds of textures at once (the placed textures of slots shaders read for the first time, made after the submission), and making them took most of the copying-back phase: windows that made 337 / 134 / 110 MB of placed textures a frame spent 351 / 926 / 300 ms there (run shots2). Measured on the RX 6700 XT, 300 textures of a new shot's sizes (430 MB): committed 255 ms (not zeroed: 274 ms); one heap 32 ms, then placed 3 ms. What changed: textures without render-target, depth, unordered-access or simultaneous use, up to 16 MiB, are placed in 64 MiB heaps (default heaps for textures that are neither render targets nor depth), first fit, with castable formats through `CreatePlacedResource2` as the committed path uses `CreateCommittedResource3`; others stay committed, and so does a texture whose placement the host refuses. A texture's range is free again only once nothing else holds its resource (views' slots keep it until the running submission has run, lists until they are reset), checked at each placement and eviction pass; empty heaps past two are released. The eviction budget counts free heap space as unused. A texture whose memory is not committed when first read gets zeros, as a committed one starts (a placed one starts with what its range held); every other first refresh already uploads every subresource. The host-textures statistics line gives the heaps held and their used and free bytes. Evidence: tests `placement::tests::ranges_are_taken_first_fit_and_joined_when_given_back` and `a_range_is_reused_only_once_nothing_holds_its_texture`; the texture upload tests, whose textures are now placed, pass (victory-gpu 182 passed, twice). Run placed1 (240 s of the intro cutscene, quiet, on main with the narrower withholding of 0a5be3c and the host-write fix): making the read slots' textures 23 ms a frame (median 12; the largest new shots 406 / 568 / 871 slots in 107 / 68 / 43 ms), against up to 926 ms before; copying back 109 ms against 223 (run shots2); world frame median 894 ms against 964. The whole-frame gain shares its main with the withholding change; the read-slot part is placement's alone. No device removal, no stale texels seen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was wrong: Wait32/64BitValueX were ignored and every submission ran
when the title made it. Grand Theft Auto VI's four compute queues start
each list with a wait for the frame's value of a word that a list on
another queue writes at its end (Write64BitValueBottomOfPipeX), and some
lists wait again after their first commands. Run light17's trace, one world
frame (F = the frame counter, all comparisons GREATER_EQUAL):
compute lists (kind 2), 22 queue submissions of one list each:
wait [0xd0417fe00 + 16k] >= F at the start, write [+8] = F at the end
(0xd0417fe00 .. 0xd04180070); the depth-processing list
[w fe10][HBO dispatch, barrier][write fe18 at its end][w fe68, fee8]...
graphics lists (kind 0) of 32-33-list submissions wait on words the
compute lists write (list 1 after 7-8 commands for [0xd0417ff80],
lists 3, 5, 7, ... at their start for [..ff90], [..ffa0], [..ffb0])
So CS_DepthProcessingHBO ran before the character G-buffer it reads, and
CS_MaterialTilesInitial classified the head and hair as sky: the white-grey
hair blob, faces dark or patched, the erased building bodies, the black
shards in the sky and part of the skin's leopard patches.
What changed: a wait recorded after commands cuts the title list into a
new host list (`list::wait`, `State::cut` replays the fixed-function state
and lets the next draw rebind the rest); each queue keeps a FIFO of list
segments, Signals and fence Waits (`hold.rs`). The pump runs a queue's
head once its waits hold, consecutive runnable segments as one host
submission (a piece, its own submission for refreshes, marks, withholding
and copy-back), and tests every queue again after each piece until none
can move. Order within a queue never changes, only the interleaving across
queues. A queue Signal behind held work is delivered after it (its fence
is kept alive meanwhile); CPU fence Signals, GetCompletedValue and
SetEventOnCompletion, PresentX, every submission and a 2 ms timer (values
the title writes from the CPU) pump. D3D12 lets a list be reset as soon as
it is submitted, which the title does up to 21 times a frame while its
work is held: the held part keeps its own host list, its title list's draw
state (dynamic descriptor slots, title-memory page table) and 0x4a0
memory, freed after it ran; host lists back from a queue are reused.
Counted shortcuts (`shortcut:`): a head held 10 s runs anyway (valve);
an unknown comparison holds; CopyPageMappingsBatchX and PresentX do not
wait behind held work. The frame line (when work waited or is held):
submissions, pieces, segments, cuts, early resets, segments that waited
and what released them, the pump's own time, the title's fence-event
waits, what is held at the present with the unmet waits.
Evidence: run light18 (240 s, survived): per world frame 16-42 title
submissions, pieces = submissions + 1, 188-266 segments, 0-11 cuts, 5-10
segments waited (55-1060 ms, every one released by a later submission);
held at the present 0, valve 0, unknown comparisons 0, page mappings with
work held 0. Hair whole against the sky, buildings whole, sky clean, skin
clean, every face present and lit (13 faces in 8 close shots; act3 2700,
without this, has a dark patch over the same woman's face). light19 (the
debug layer, 240 s; median per world frame 30 submissions, 31 pieces,
236 segments, 9 waited; pump 1.1 ms a frame; no fence event left
pending) and light20 (240 s, with the stale-upload fix now in main: 30,
31, 241, 9; pump 1.8 ms) survived; held at the present, valve, unknown
comparisons and page mappings with work held 0 in all three. The debug
layer's resource-state errors of light19 are on main alone too (light21,
same kinds and rate): not from the new order.
Tests: hold::tests (comparisons, a wait across queues, a wait that holds
defers nothing, chained waits across two queues, order kept, a Signal
after held work, a fence wait, work held at the frame's end, unknown
comparisons, the valve) and the GPU test
resource::tests::a_list_waiting_for_another_queues_write_reads_what_it_wrote
(a compute list cut at its wait and reset while held reads back the plain
texture the graphics list fills, as that list left it; on the old code it
reads zeros).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was wrong: each refresh of a tracked texture read the changed title memory into a buffer allocated for it, the texture's whole size (5.6 MB for a BC7 2048), zero-filled and touched page by page: a zero-fill and a page fault per 4 KiB for every texture brought up (129,071 page faults while preparing in one frame of run placed1). The detile itself is not the cost: a BC7 2048 64KB_D texture detiles at 0.04 ms per MB on this machine, as fast as a plain copy of its bytes, against ~2.2 ms per MB for a whole refresh. What changed: the read goes into a buffer the worker thread keeps for its next refresh (up to 32 MiB; larger ones are not kept). Only the touched spans are written, and only they are hashed and detiled, as before. In diagnostics builds, the scan of each texture read for all zeros runs only when its debug message is wanted. Evidence: the texture upload tests, which refresh several textures and single mips on the same threads, pass (victory-gpu 193 passed, twice). Run scratch1 (240 s of the intro cutscene, quiet, on the same main as run placed1): texture refreshes 177 ms of worker time for 98 MB a frame (1.8 ms per MB) against 235 ms for 105 MB (2.2 ms per MB). Its whole frame was slower (median 1,010 ms against 894) through GPU time (mean 450 ms against 318) and after-work, which this change does not touch: one run each, run-to-run variance not separated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lowering leaves much in the DXIL that never runs or counts: branches on constants (lane conditions structurisation already knows, edges no lane takes) and the code only their other edge reaches, empty blocks that only forward to the next, size queries for descriptor words no path reads. The host driver compiles all of it. `indirect_diffuse_lighting:CS_ScreenProbes_ ActivateRays` (with nested descriptor joins, PR Marvisak#1012) is where it showed: 8,745 of its 10,040 conditional branches were on constants, 10,061 of its 22,384 blocks empty forwarders, about 70 % of its instructions reachable only through constant branches' dead edges, and 556 of the 587 size queries in the rest unread; the AMD driver never finished it (over 6 GB at 64 s). The writer (`Module::plan`, `Module::kept`) now: * takes a branch on a constant as a branch to its one target: blocks only the other edge reaches are not written, and phis lose the entries of edges that are gone (their other entries stay); * folds an empty block with one predecessor into it (the predecessor branches to its target), unless it splits a critical edge (lowering keeps loops' exits and preheaders dedicated, as DXC emits them) or its predecessor would then reach the target twice (one phi entry per predecessor); empty latches fold as before; * writes only instructions with effects (stores, atomics, calls neither read-none nor read-only: barriers, discard, wave operations, the write and read marks) and what they read, transitively (it dropped only unread phis before); * declares only the functions it calls and the constant globals it reads (the validator refuses the others); * and the shader flags of heap handles, wave operations and 64-bit integers follow what is written (`Module::uses`; the validator refuses a flag whose use is gone, "Flags must match usage"). Whole list (shaders.rpf, the exe, XboxBvhBuilder, the upscaler; translate --list --validate, against 8ff7913): 0 programs change outcome (14,254 VS/PS, 2,732 compute, 8,765 mesh emitted; 13,313 / 1,984 / 4,625 validated, as before); DXIL bitcode 1,423,424,800 -> 1,246,729,828 bytes (-12.4 %), blocks 3,624,448 -> 3,554,816 (-1.9 %). ActivateRays itself is still refused here (nested joins); its table is in the commit that lets it through. Tests (`emit::bitcode`): a constant branch drops its other side and that side's phi entry only; a loop whose back edge is never taken; empty blocks before a phi fold only where the entry can move; only values with effects or readers are written (read-none and read-only calls, stores, atomics, barriers); constant globals nothing reads are left out; uses count only what is written. The writer's pinned bytes are pinned anew (its test module's last call became one with effects). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The console compiler reloads a descriptor before each use rather than keep it (`indirect_diffuse_lighting:CS_ScreenProbes_ActivateRays` loads table offset 0x640 2,399 times, once before each of its typed buffer loads), and lowering made a heap handle at each load: index arithmetic, for heap buffers the host-view guard, `createHandleFromHeap`, `annotateHandle`. A descriptor resource tracking finds at a fixed address (a table or heap entry, no dynamic term, not a waterfall loop's per-lane load) now gets one handle for the program, made in the entry block from the root parameter's user data. A descriptor chosen by control flow (a phi of heap indices at a join) gets one handle made in its join block, shared by every access the join dominates, instead of one per access. Read marks still go with each access, at the handle's index. ActivateRays (with nested joins allowed, the commit after this one): 2,608 heap handles before the DXIL writer's folding, 674 after it, 65 with this. Whole list, translate --list --validate: 0 newly failing; DXIL bitcode 1,246,729,828 -> 1,197,299,944 (-4.0 %) bytes. Tests: `descriptors_reloaded_from_a_root_table_share_one_handle` (a descriptor loaded in a branch and again after it: one handle), written heap handles counted from the module (`Module::written_calls`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since 4243a96 ("16-bit typed buffer accesses pass bits through integer views") a 16-bit typed buffer access reads its view's format kind from the host's view-stride table, root SRV `t255` (`VIEW_STRIDES`), also for views in tables. The differential harness asserted that a translated program's root views are only the case's own (slots 4 and 5), so the case "16-bit and 64-bit arithmetic" (`RWBuffer<half4>` stores through `buffer_store_format_d16`) failed on its root SRV 255 before anything ran, in every run with the console compiler since that commit (eed1670 passes, 4243a96 fails). `host::view_strides` builds the table as `victory_gpu` fills it for the harness's view heap (element sizes, the integer and signed bits of typed views of integer formats), and the harness binds it where a program asks. The case now runs and matches the console compiler's program on the RX 6700 XT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… flags Since the read marks, every vertex, geometry and mesh program that reads a texture from the resource heap writes the marks' UAV (the write marks do the same for programs writing through views), and its shader flags did not declare "UAVs at every stage" (ShaderFlags bit 16, SFI0 0x4): the validator refused 5,046 programs of the title's list with "Flags must match usage" (VS_OctaWindFire_e6901d4b: declared 0x40000010, actual 0x40010010). The runtime does not validate, so their pipelines were made, but a driver may trust the flags. The validator counts UAV ranges the module declares, not UAVs indexed from the heap: `finish` sets the flag (and the SFI0 bit) when a program that is neither a pixel nor a compute program declares any (root UAVs, the memory bitmap, the marks). Counting every handle annotated as a UAV instead set it wrongly for 26 mesh and vertex programs whose only UAVs come from the heap (`MST_DS_TerrainTransform` and others: declared 0x40092000, actual 0x40082000). Whole list (translate --list --validate), validated: vertex and pixel 13,313 -> 14,254 of 14,254, mesh 4,625 -> 8,694 of 8,765 (the other 71 have outputs over 32 KB), compute 1,984 of 2,732 unchanged (748 sample with implicit LOD); no program newly fails. Test: `emit::shader::tests::uavs_outside_pixel_and_compute_programs_are_declared` (a marked vertex, pixel and compute program and a vertex program writing a heap-indexed UAV each pass the validator; the marked vertex program fails as the list's did without the flag, the heap one with it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dges The console runs pixel programs in whole-quad mode: in every quad a triangle edge crosses, the pixels outside the triangle run as helpers, and the compiler takes derivatives of computed values (and quad reads) by reading the neighbour's register with DPP `quad_perm` or `ds_swizzle`. We lowered those reads to `WaveReadLaneAt` unless the program discards. Wave operations leave helper lanes out on the host, and on AMD a read of one gives 0: every pixel whose quad neighbour lies outside the triangle took a wrong derivative, along every triangle edge. WARP includes helpers in wave reads, so the tests passed there. Quad-local reads in pixel programs now always go through quad reads (`QuadReadLaneAt`), as they already did after a discard. What the host guarantees there: helper lanes execute the program so that derivatives can be taken, and quad operations include them (wave operations do not), so a quad read of a helper gives the value that helper computed, as the console's DPP read of a whole-quad-mode lane does. A discarded pixel stays a helper in the same way. Tests: two control-flow cases draw a triangle whose diagonal crosses quads (`ddx_fine`, `ddy_fine`, `QuadReadAcrossDiagonal`, `QuadReadLaneAt` of a computed value, console compiler against PC DXC). "derivatives and quad reads across a triangle edge": before, RX 6700 XT 24 of 256 texels differ (texel (0, 0): ddx -1 instead of 15, the helper read as 0), WARP 0; now 0 and 0. "discard, then derivatives and quad reads across a triangle edge" discards some neighbours before the reads (the path that used quad reads already): 0 and 0. Whole list (translate --list --validate): 3,005 pixel programs change, 84,589 read sites (median 15 per program, at most 732); no program changes outcome. DXIL 1,197,299,944 -> 1,203,716,752 bytes (+0.54 %) on top of the writer folding (on main without it: 1,423,424,800 -> 1,429,871,224), blocks unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the clamp's own buffer The debug layer reported ~16 resource-state errors a second in the world on main (run light21) and with the queue order (light19), four kinds: Depth twins, and 16-bit depth textures with twins (COPY_SOURCE, UNORDERED_ ACCESS and COMMON against DEPTH_WRITE): a list's prelude swapped each texture's real state for the one the list leaves before recording the twin copies it owed, so those copies moved the textures from the wrong states. The prelude now records the copies from the real states, then the list's moves from them, and only then stores the states the list leaves. The title's 174 MB GPU heap, bound as a vertex buffer while in UNORDERED_ ACCESS, and barriers on it disagreeing with the state an earlier vertex binding promoted it to: our only transitions on a title buffer's copy were the indirect clamp's, UAV to INDIRECT_ARGUMENT and back to UAV. The clamp now reads the title's records through a root view and writes the clamped ones into an argument buffer of the list's own, which the execution reads; only that buffer is transitioned (common, unordered access, indirect argument, common). Title buffers' copies are never transitioned: common between submissions, promoted by every use, ordered by unordered-access barriers (the shortcut is in indirect.rs). The clamp no longer writes the copy of the title's memory; the capture's read-back reads the clamped records from the list's buffer. Tests: a transition log (every barrier built on the test thread) replayed in GPU order by the debug layer's rule: twin::tests::prelude_copies_start_ from_the_real_states (fails on the old order: "before COPY_SOURCE, the resource is in COMMON", run light21's message) and indirect::tests:: argument_buffers_move_from_their_current_states (two lists in either order; the title's copy untouched); the clamp tests now also check the whole title copy is as written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings back PR Marvisak#1012's recursive heap index (taken back by fbac5bb): a descriptor every lane shares, chosen by an if/else nested in another, reaches the outer join with an edge that is itself a join; its heap index is a phi at each join of what each predecessor computes at its end. It lets `indirect_diffuse_lighting:CS_ScreenProbes_ActivateRays` (39f0e9aeb156a61c, issued every cutscene frame) through, whose host pipeline the AMD driver could not make before the two commits ahead of this one. The program itself is large: 74,700 GFX10 instructions, 11,896 branches (488 backward), 1,889 typed buffer loads, each after a reload of the same descriptor. Its DXIL, and what the AMD driver (RX 6700 XT, 32.0.21045) does with it: | | Marvisak#1012 alone | now | |---|---|---| | lines (dxc -dumpbin) | 151,610 | 24,896 | | branches (conditional) | 22,382 (10,040) | 3,070 (1,295) | | blocks | 22,384 | 3,072 | | heap handles | 2,608 | 65 | | size queries | 2,477 | 0 | | phis | 2,883 | 1,124 | | DXIL bytes | 864 K | 144 K | | validator | passes | passes | | host pipeline | over 6 GB at 64 s, never finished (26.7 GB unwatched) | 2.36-2.45 GB, 78-107 s (with other work on the machine) | What remains costly is the program's shape: one loop of 2,941 blocks holding 1,239 of its 1,295 conditional branches, an inner one of 1,440 (the largest loop of the largest program by DXIL bytes, RTShadowTrace32TemporalHQ_OneOver4RPP_Tiled, has 110 blocks; it compiles in 14 s, 353 MB). Making every branch uniform (an experiment) took the compile to 1.9 GB and 54 s, so divergence is not most of it. The pipeline library keeps it after the first make. WARP refuses the pipeline at once (E_INVALIDARG): the program declares the console's wave size (32), which WARP's 4-lane waves cannot run, as for every compute program that declares one. Whole list, translate --list --validate: 0 newly failing, 1 newly emitted and validated (this program). Test: the nested-join lowering test is back (`descriptors_joined_by_nested_control_flow_lower_to_one_uniform_handle`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…otient What was wrong: buffer and typed-buffer loads of normalized formats (UNORM, SNORM) converted a code by dividing it on the host. The host's division is not exact. On the RX 6700 XT, 125 of the 256 8-bit codes loaded one ulp high, and 16-bit codes such as 257, 261, ..., 32896 loaded one ulp low; WARP was exact. The console's buffer unit gives the float nearest the exact quotient, and titles rely on it in decisions: Grand Theft Auto VI's mesh programs read a material index from a vertex colour's alpha as `v_mul_legacy_f32 255.0` then `v_cvt_u32_f32`. A quotient one ulp low truncates to the code below (the 16-bit codes above did), so another material is picked. What changed: for formats up to 16 bits per channel the quotient a / (2^n - 1) is worked out from integers: Q = floor(a * 2^32 / d) as a * K plus a correction (none when n divides 32), rounded to 24 bits up exactly when its highest dropped bit is set (the quotient is never exact, so never a tie), and that integer, at most 2^24 and so exact as a float on any host, scaled by a power of two. The reference is the exact quotient rounded to the nearest float, which removes the dependence on how the host rounds a division or converts a large integer (WARP rounds integers above 2^31 otherwise). Signed formats convert their magnitude the same way; their two lowest codes stay -1.0. The 11- and 12-bit widths, whose smallest codes need more bits, are rounded fully in integers. Cost: about 18-21 DXIL operations a channel where the division was 2 (a division by a constant more where n does not divide 32), so a 4-channel 8-bit fetch is about 80 operations instead of about 12. The car body's mesh program grows from 4,616 to 5,103 instructions (+487 for about 23 normalized channels). In the title it is not measurable: in a run of the intro cutscene with this commit (cost2, on the previous main 4015a18), on world windows with no pipelines being made, the frame median was 881 ms and the GPU 349 ms a frame (median 335), against 1,013 and 389 (365) for the same tree without it (s1a). Two runs of one tree have differed by 132 ms of GPU a frame, so the difference is within run-to-run noise. Evidence: tests `normalized_buffer_formats_load_correctly_rounded_quotients` (every 8- and 10-bit code and a 16-bit sample, unsigned and signed, bit-exact on hardware and WARP; it failed on the RX 6700 XT before, at 8-bit code 3) and `normalized_codes_truncate_back_to_themselves` (the title's truncation gives every code back; 16-bit code 257 came back as 256 before). Offline, the integer arithmetic as emitted matches the exact quotient for every code of every width 2 to 16. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A new committed resource is not always zeroed: on the CI's WARP the 512 KiB mark buffer of heap_direct_texture_reads_mark_their_heap_index came back holding the page table an earlier test had uploaded and freed, so the test saw 16,389 bits besides the one the shader set. Buffers, root UAVs and UAV textures are now made as copy destinations and get zeros from an upload buffer before the dispatch. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
# Conflicts: # crates/victory-gpu/src/draw.rs # crates/victory-gpu/src/host.rs # crates/victory-gpu/src/list.rs # crates/victory-gpu/src/texture.rs # crates/victory-gpu/src/twin.rs # crates/victory-shader/src/emit/lower.rs # crates/victory-shader/src/emit/shader.rs
MagiccConch
marked this pull request as ready for review
November 25, 2026 16:49
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.
Sync upstream/main (67e8ae1) into the fork. Carries upstream's 315cea1 barrier fix ("barriers start from the states resources are in"), which addresses the run-9 debug-layer findings (id=538: a title buffer bound as a vertex buffer while in UNORDERED_ACCESS; the indirect clamp now reads title records through a root view and writes clamped records into a list-owned argument buffer).
Conflict resolutions:
texture.rs: took upstream's refresh rewrite wholesale (per-subresource spans, thread-local staging buffers). Supersedes the fork's PR GPU: a memory-speed digest for the texture change-check #9 whole-texture splitmix digest for the same cost problem.twin.rs: kept BOTH — upstream's float-depth conversion (98c654b: formats 118-120 host D32_FLOAT_S8X24,depth()/u16()helpers) and the fork's packed-colour modes 1-3 (up/down, B5G6R5/B5G5R5A1/B4G4R4A4 twins).emit/shader.rs: kept the fork'sheap_handles_stay_inside_the_host_limits(cap-clamp test) alongside upstream'suavs_outside_pixel_and_compute_programs_are_declared; tests mod is#[cfg(all(test, windows))]per upstream.emit/lower.rs: kept both test counters (heap_propsfork,heap_handlesupstream); dropped the fork's olderhelpers_readduplicate in favour of upstream's 4015a18 semantics (quad && pixel — helpers at edges exist regardless of discards).draw.rs/list.rs: kept the fork's twin-redirect RTV plumbing (format-patched view for packed render targets), upstream'srecord.desc()shape where the function was upstream-owned.host.rs: kept the fork'sby_preference()adapter selection beside upstream'sprocess_memory()diagnostics.Local signal: cargo check + clippy green for victory-shader and victory-gpu (--all-features --all-targets, x86_64-pc-windows-gnu); Linux crates check clean; loader's 3 PE-parsing test failures are Linux-exe artifacts, unchanged from before the merge.
CI run needed on this PR before merge (workflow does not run on non-main branch pushes).