Skip to content

Integration: PR #5–#11 merged, all switches off by default - #12

Open
oceansde012 wants to merge 83 commits into
mainfrom
claude/project-thread-wjvj0t
Open

oceansde012 wants to merge 83 commits into
mainfrom
claude/project-thread-wjvj0t

Conversation

@oceansde012

Copy link
Copy Markdown
Owner

Requested by Vlad · project thread

One branch with every open fps PR, for the combined A/B.

With no env set, behaviour should equal f4b48ad.

Tests on the PC (Windows, cargo test -p victory-gpu -p victory-hle --release, before PR #11 was merged in): 526 passed, 2 failed, 38 ignored. Both failures are known and also fail on f4b48ad (indirect::tests::host_list_budget_starts_empty_at_each_submission, warp_batch_charges_every_execution). The game has not been run on this branch yet: the per-PR A/B is in progress, and the best switch combination will be measured here afterwards.


Generated by Claude Code

claude and others added 30 commits November 27, 2026 13:07
card_dirty ran Vec::retain over every Weak<Shadow> in CARDED (~3600)
on each of ~16 submissions a frame, ~3 ms a frame of the submitting
thread (diag profile 2026-11-27). VICTORY_CARD_DIRTY_LIST=1 keeps the
ids of copies touched since the last call (pushed when `touched`
goes from false to true, under the dirty lock) and a map id -> Weak,
and visits only those; CARDED is pruned every 256 calls. Off by
default: unchanged.

Also VICTORY_WIDE_THREADS=<1..=16> sets the number of wide() helper
threads (default formula unchanged).

Risk: with the switch on the output order is by copy id instead of
CARDED order. Code by DeepSeek (deepseek-v4-pro), reviewed by Claude.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRojSmSHTKsTdTNBDGp
~10300 refreshes a frame in ~38 flushes, ~9100 of them known to copy
nothing. Above 256 in a flush they were all handed to ask_ahead (kernel
write-watch queries) and fanned out to wide_each, where the empty ones
returned. VICTORY_REFRESH_SKIP_EMPTY=1 runs the nothing_new filter
first in refresh_front and flush_all (on several threads above 256),
asks ahead only for the rest and updates small remainders inline.
nothing_new reads only the submission's ask_once results, so moving it
ahead of ask_ahead keeps what is copied. Off by default: unchanged.

Code by DeepSeek (deepseek-v4-pro), reviewed by Claude.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRojSmSHTKsTdTNBDGp
…TH=1, off by default)

A console pixel program whose DB_SHADER_CONTROL has DEPTH_BEFORE_SHADER
(bit 12, HLSL's [earlydepthstencil]) is translated with DXIL's
ForceEarlyDepthStencil flag when VICTORY_EARLY_DEPTH=1. The translator read
DB_SHADER_CONTROL but never used it, so every such program ran with the late
test on the host wherever it writes unordered views or discards, and its
writes to unordered views landed for pixels the depth test then rejected.

What that broke (capture C:\dev\captures\haze2, a character's head in front
of a window): the transparent pass (list 247; pixel programs
629743ca412296d4, 8ba01719b71d1d35, 5436c45060d74ebe and others,
DB_SHADER_CONTROL 0x1450) keeps the nearest transparent depth and its
velocity with 64-bit atomics in texture 46225 (R32G32, 1706x960); draw
271:34 (pixel 00ae3e9b98a0ae26, depth test ALWAYS, depth write on) writes
that depth into the scene depth 6481 and that velocity into the motion
vectors 38269 wherever it holds one. The glass, behind the head, wrote
there too: at the head's pixels in front of it the scene depth that the
heat-haze and in-scattering pass 731a39171b568298 (279:303) reads holds the
glass's (0.176, 0.85 m, for the head's 0.39, 0.38 m) and the motion vectors
hold the glass's velocity (-24, +31 where the head's own is +43, +35).
13.7% of that frame's transparent texels lie behind the opaque depth. The
haze pass picks heat haze (beyond 20 m) and in-scattering (beyond 137 m
there) by each pixel's distance, in 16x16 tiles: where the false depth is
far, it works on character outlines (expected cause of the blocks on hair,
not yet confirmed in a run).

The switch joins the shader cache's key only while it is on, so the default
translation and its cache entries stay as they were. Counted at the shader
cache's log line: programs given the early test, left late (switch off),
left late as they write depth or stencil. Tests: the decision, and a pixel
program translated with and without the switch (dxil.dll validates it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 41b4a056d6e176656a062355d7198058d0065ca6)
…ed copy (switches)

The title's write-combined memory (protection 0x400: 2.2 and 3.2 GB,
0x2404) is what its CPU writes and does not read. Of the gameplay frame's
compares (coolfox-20261126-184458) seven of the eight largest ranges, about
360 of 730 MB a frame, lie in it, and 36 MB a frame of it was fetched and
merged into title memory.

- xmem notes write-combined regions (forgotten when freed or decommitted),
  `victory_gpu::title_memory_write_combined`.
- VICTORY_WC_NO_BACK=1: a copy with two sides of write-combined memory has
  no write-back: no hashes, compare, fetch or merge; what shaders write stays
  on the card. Refreshes still send whole pages.
- VICTORY_WC_BAR=1: a write-combined title buffer gets one copy in card
  memory the CPU maps (GPU upload heap, resizable BAR): refreshes write it
  through the bus, nothing is sent, no CPU side, no write-back. Counted
  with the card sides of copies (card_limits) and made while a fifth of the
  budget is free.

Both off by default. Risks (shadow.rs, wc_no_back): the title's CPU reading
what shaders wrote there reads older bytes; a page the title writes goes up
whole and takes back what shaders wrote in the same 4 KiB page; another
host copy of the same bytes does not see shader writes. The frame line says
how many MB of declared writes were left on the card.

Test: the registry of write-combined regions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 50c15a145a527aaa40f64b9e393c13e468ee6a3b)
The submitting thread runs above normal, but the threads it waits for
(the wide pool, the landing pools, heap records, the heap pass beside
the lists) ran at normal priority, level with the title's threads and
the list translators. On a six-core CPU they were often not running
while it waited. VICTORY_HELPER_PRIORITY (on unless 0, VICTORY_AB can
flip it) raises them to above normal.

A/B in one run on an i5-12400F with an RTX 3060 (run10, Series S at
540p, off / on): 8.6 / 9.6 fps, refreshes 23.1 / 17.6 ms a frame,
waiting for heap records 6.2 / 2.5 ms, card idle behind the submitting
thread 24.7 / 13.2 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 80c70b719f2cd0c21d7acbb2b19caccc469b43ba)
…ORY_PORT_CONSTANTS=1, off by default)

The title's routine at image+0x1e86440 reserves 185 MB of graphics memory
below 4 GiB, splits it into five pieces, takes all their physical pages
in one XMemAllocatePhysicalPages and maps them in order: one stretch of
one section. Its 174 MB buffer at 0x34e10000 (the ring of constants, and
what the skinning passes write through one view of all of it) had a host
copy in the card's memory, ~17 MB a frame sent up in ~600 pieces, shader
writes fetched back and compared, and ~6,000 constant fills a frame.

With the switch the stretch is mapped once more at an address of ours and
opened as a host heap there (OpenExistingHeapFromAddress1); title buffers
and windows in it are buffers placed in that heap, the existing in-place
form of a host copy: nothing tracked, sent up, fetched back or compared.
The title's own views stay free to change; when it maps other pages
there the region is forgotten. A line on the frame-rate report counts
the CPU fills and buffer copies of ours that still read or write it.

Replay (play-1125-0127, heap in the PC's memory): the title's own work
+~3 ms on the card; the 30 ms added there are our compare passes, which
do not run over memory in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 86dc109)
(cherry picked from commit 5af02b4dcbfe2fe4a2188425df837112f4f996d5)
…n address order

Run port1-1: the title maps the five pieces of its 185 MB heap in another
order than their addresses, so the heap was views of one section in a
scattered order ("not one stretch of a section: Scattered") and nothing
was placed. With VICTORY_PORT_CONSTANTS=1 xmem now gives the page numbers
mapped into a 32-bit graphics reservation the slices at their offset in
it, when the reservation is all one section and both slices are fresh
(never mapped or written: no commit bit), which the title cannot observe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4b82f6c)
(cherry picked from commit fa9411b4fdfe3228646ebbe7259b631b3a8b0e7b)
… the 64 KiB page flag

This build of the title reserves its 185 MB graphics heap with kind 0x42000
(no 64 KiB page flag), so it was not a placeholder, never recorded as a
32-bit reservation, and its pages stayed scattered ("not one stretch of a
section"): nothing was placed. A reservation without commit counts now. Logs
say why large mappings are left as they were.

With VICTORY_PORT_CONSTANTS=1 the heap is in place (185 MB, nothing sent up
or fetched back for it); opening cutscene 24.4 fps against 21.6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 6349f8c0eadc92d3d800b4a200061194f74457aa)
…ds' lock shared by faults and refreshes, a block's claim held while its state changes; view memory not asked of the kernel

The sets of guarded blocks are of atomic words and GUARDS is a reader-writer
lock. With the switch a write fault, a refresh guarding its range and a block
made known by its bits take the lock shared and the claims (BUSY bits) of the
blocks they change: faults wait only for whoever changes the same block, not
for one another, and refreshes do not wait for faults. Faults wait for claims
in block order, refreshes only try for theirs (a block they cannot claim stays
written, told so at the next asking), so no two wait for each other. What
changes more than single blocks (mappings, kernel reads, freed memory, holes)
still holds the lock alone, as before. Blocks known as view memory (VIEWS) go
to the guards at once instead of a kernel asking that is refused.
VICTORY_GUARD_HOT=<ms> (off): blocks written again soon after each taking
rest longer. End-of-run line: renderer port 6 per frame.
Tests: three stress tests of the view writes with the switch on (all
threads, half of them, resting and hot blocks).

(cherry picked from commit 9d723e8)

Ported onto teste/exata: renderer port 2's fault note (crate::port_descriptors) and port 5's line (crate::port_cbv) left out, neither is in this tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit accf24b1b2768ecbd4ef8e77be54004383f7a5e7)
…ll clean?) under the shared lock too

(cherry picked from commit 2edf844)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a011c13516c242471596d6df2ec1729637c6e69b)
…textures) is not asked: the kernel refuses it

(cherry picked from commit 65f9707)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 14ecddbdb371b72c774097b946b6d1055d012013)
…hing goes to the threads beside the submitting one (VICTORY_PORT_GUARD_PLAN=0: on it, as before); spans of the refresh planning on the timeline

One submission a frame spent up to 6 ms in that look alone (run guard-3,
the timeline at 100 s: 5.8 ms with nothing else on the lane) while the six
threads beside it waited; with more than 256 refreshes it was already done
beside them, as each one's first step.

(cherry picked from commit 00ab2ac)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5d5b46991f7cecc62d06cd94defe19e9cf6b6ff6)
…nt made per list on the threads beside the submitting one and joined in order (with VICTORY_PORT_GUARD_PLAN, from 4,096 steps)

Run guard-4's timeline: the submission with most of the frame's steps spent
2.9 ms gathering them and 3.9 ms on the spans, alone. Each list's steps are
now folded per copy beside it (fold_touches: the span of its refreshes
before its first write by shaders, whether it writes it) and the folds
joined in list order (join_keys), which gives what front_spans gives of the
whole submission, span for span and in order: front_tests, 3,000 random
submissions of lists, parts, refreshes and writes.

(cherry picked from commit 8f02bf7)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit af827959b02ca7680092314e6e489fd9ea735ebf)
Whether the submission's asking holds a range was asked two or three times
per refresh (10,000 a frame), each a walk through all its ranges (a few
hundred). They are now kept by their starts with the furthest end so far:
the same answers in a few steps.

Measured and left out (run ask-3b, A/B in one city run, no ray tracing):
VICTORY_ASK_NORESET lane asking 7.2 ms a frame against 5.4 off, kernel
3.7 against 4.4 ms; VICTORY_ASK_SPREAD kernel askings 17 ms against 4.4
(they wait for each other in the kernel), lane 6.5; both 8.1 ms and frames
74 ms. Both stay off.

Tried and dropped (run ask-4): askings within one reservation only (the
refused askings stayed at 280-300 a frame: they are not the ahead runs'; and
VirtualQuery of the pieces stalled the lane 100-1100 ms every 5 s), and
askings of the refreshed ranges only (they are 99% of the copies' spans).

(cherry picked from commit c83e54c)

Ported onto teste/exata as a dependency of renderer port 7 (its journal keeps these ranges). This tree's ask_rest has no spread askings nor the diagnostics of ranges asked alone (avatar's 122d354, fb28d49): its loop is kept as it was, the ranges asked ahead looked up through Ahead; same answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4429c53bf4bb036d74ca819b8e16ff401f8945a2)
…it; a warning)

Tests: victory-gpu 330 pass. Replay of captures\replay5\capture-1 (3 loops)
ran to its picture.

(cherry picked from commit 71537d0)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a063d653437e36d38ec1e3f362b6689d92ad1716)
…D_HOT off: worse in run guard-6)

(cherry picked from commit 88b63a2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8de4211b7553485daa79b7ea485060154f978994)
…aps' records asked for at the title's submit (renderer patch 4's part 1, brought over), the journal's notes in parts with locks of their own

The heaps' records: a round of the heap-sync thread is asked for when the
title submits, and the lane waits for that round, or for one begun after a
wait of its queue went or a step of ours wrote a heap's memory
(port/lane 97033e5a; its plans part is left out, port 6 plans beside the
lane already).

The journal: the pages' notes are in 64 parts, each under a lock of its
own. With the switch an answer is noted holding the journal shared and its
pages' parts for writing (writes, landed_beside, a submission's asking
before its ranges and number are set alone); what has nothing to change
(wrote with no asking standing, ask_once_end, ask_ahead_done) looks shared
first. A fresh number to answer with is taken holding the range's parts,
switch or not, so an A/B run mixes both safely; a page's note only goes up.

End-of-run line each second: renderer port 7 (heaps' waits with and
without the switch, rounds asked at submit; the journal's waits, the
lane's own among them). Tests: parts and ranges, notes out of order, a
fresh number sees every lower note with no deadlock (8 threads), no write
lost with the switch on in all threads and every other one.

(cherry picked from commit 673be0e)

Ported onto teste/exata: port 5's and port 2's modules (port_cbv, port_descriptors) left out of lib.rs, and the copies' guard-page test (avatar's c277533) that came with the end of the file; the test of a submission's asking calls this tree's ask_rest (no held argument: avatar's e000e02 is not here).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 43afb5a27641c450a549a3da5d37577ea20e8a7a)
…nly by waits met in memory, the round asked for when the wait goes (renderer patch 4's part 2, that piece)

Run p7-1 (in-run A/B): with part 1 alone the lane still waited 4.1 ms of
5.3 for the heaps' records; 2.4 of 16 preparings a frame found their round
asked earlier. A wait that goes now asks for its round at once (as patch 4's
part 2 did), and one met by the card's own write raises no floor. Counted:
preparings that had to ask at the preparing, and those with no mark.

(cherry picked from commit a609a2f)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit b440d036df987715ae4d4ff995c9c23141f1e249)
… to p7-5)

(cherry picked from commit a39509f)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c0fefb293f016283191d48d6287e9c8459e67566)
Cherry-picked unchanged from cocainebunnylaboratories/cblvictoryvi
dab3f08e25d360f675f80cba299dbebaef5998ba (GPL-3.0-or-later). Plans
aligned page groups with an interval for contiguous destinations
instead of materialising every page and a per-group HashSet. Same
groups, same order, same mapping calls; CPU-only.

(cherry picked from commit dab3f08e25d360f675f80cba299dbebaef5998ba)

Co-Authored-By: isuru <isuru2003a@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRnS9CFngQ578Jqe1Ty
…s read as raw bytes, the title's in place given to the card where they are

The console takes constant buffers on 16 bytes, D3D12 views on 256, so every
constant buffer a draw's tables name was copied at each submission into upload
memory of ours (~23,000 a frame of the city, ~9 MB, out of the title's graphics
memory that renderer port 1 already has the card read in place), and each root
one not on 256 bytes (64 KiB each).

With the switch, translated shaders read constant buffers as raw bytes
(victory_shader::emit::constants_raw): a table's (or one picked from the heap)
through the raw twin of its slot, a root one as a root SRV. The host makes a
table's constant buffer in title memory in place a raw view of the title's
bytes in that twin (descriptor::host::constant_raw_at): no copy, no step at
submission. Others are copied as before (their twin is a raw view of the copy);
a title slot's constant buffer view gets a raw twin (a raw read through a
constant buffer view has no end on AMD). The shader cache keys on the switch
(only when on: translations cached without it keep their key, so the
translator version stays). VICTORY_PORT_CBV_PLACE=0 copies again while reading
raw; with VICTORY_AB=<s>,VICTORY_PORT_CBV_PLACE both sides in one run.
Per-second line: "renderer port 5 (VICTORY_PORT_CBV=1) per frame: ...".
Test: emit::tests::table_constant_buffers_read_as_raw_bytes_through_their_twins
(WARP: the twin is read, the slot's own view is not).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit fad4e53629e19a7834495ffeeaef4fa11be5f92e)
…ock shared by faults and refreshes, a block's claim held while its state changes; view memory not asked of the kernel

The sets of guarded blocks are of atomic words and GUARDS is a reader-writer
lock. With the switch a write fault, a refresh guarding its range and a block
made known by its bits take the lock shared and the claims (BUSY bits) of the
blocks they change: faults wait only for whoever changes the same block, not
for one another, and refreshes do not wait for faults. Faults wait for claims
in block order, refreshes only try for theirs (a block they cannot claim stays
written, told so at the next asking), so no two wait for each other. What
changes more than single blocks (mappings, kernel reads, freed memory, holes)
still holds the lock alone, as before. Blocks known as view memory (VIEWS) go
to the guards at once instead of a kernel asking that is refused.
VICTORY_GUARD_HOT=<ms> (off): blocks written again soon after each taking
rest longer. End-of-run line: renderer port 6 per frame.
Tests: three stress tests of the view writes with the switch on (all
threads, half of them, resting and hot blocks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c781843b41be3d52662d412b2ea8dd01673e9a17)
…ean?) under the shared lock too

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4802054e833930b946d61b02248f19632754f6c1)
…res) is not asked: the kernel refuses it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 78b09e548a9add52ab71373e210a2e9c82469637)
…goes to the threads beside the submitting one (VICTORY_PORT_GUARD_PLAN=0: on it, as before); spans of the refresh planning on the timeline

One submission a frame spent up to 6 ms in that look alone (run guard-3,
the timeline at 100 s: 5.8 ms with nothing else on the lane) while the six
threads beside it waited; with more than 256 refreshes it was already done
beside them, as each one's first step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9f83fe9a65308541f3aa4f71261def17770c3093)
…de per list on the threads beside the submitting one and joined in order (with VICTORY_PORT_GUARD_PLAN, from 4,096 steps)

Run guard-4's timeline: the submission with most of the frame's steps spent
2.9 ms gathering them and 3.9 ms on the spans, alone. Each list's steps are
now folded per copy beside it (fold_touches: the span of its refreshes
before its first write by shaders, whether it writes it) and the folds
joined in list order (join_keys), which gives what front_spans gives of the
whole submission, span for span and in order: front_tests, 3,000 random
submissions of lists, parts, refreshes and writes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit bf1fb825930a01dfe68c9a4076a2ad482f88444e)
… off: worse in run guard-6)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9828b0a04b8501e094b426a7895a01847e16643d)
…ORY_PORT_CONSTANTS=1, off by default)

The title's routine at image+0x1e86440 reserves 185 MB of graphics memory
below 4 GiB, splits it into five pieces, takes all their physical pages
in one XMemAllocatePhysicalPages and maps them in order: one stretch of
one section. Its 174 MB buffer at 0x34e10000 (the ring of constants, and
what the skinning passes write through one view of all of it) had a host
copy in the card's memory, ~17 MB a frame sent up in ~600 pieces, shader
writes fetched back and compared, and ~6,000 constant fills a frame.

With the switch the stretch is mapped once more at an address of ours and
opened as a host heap there (OpenExistingHeapFromAddress1); title buffers
and windows in it are buffers placed in that heap, the existing in-place
form of a host copy: nothing tracked, sent up, fetched back or compared.
The title's own views stay free to change; when it maps other pages
there the region is forgotten. A line on the frame-rate report counts
the CPU fills and buffer copies of ours that still read or write it.

Replay (play-1125-0127, heap in the PC's memory): the title's own work
+~3 ms on the card; the 30 ms added there are our compare passes, which
do not run over memory in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c496640276bbabd8551d2d193c7332b67c5471e8)
…n address order

Run port1-1: the title maps the five pieces of its 185 MB heap in another
order than their addresses, so the heap was views of one section in a
scattered order ("not one stretch of a section: Scattered") and nothing
was placed. With VICTORY_PORT_CONSTANTS=1 xmem now gives the page numbers
mapped into a 32-bit graphics reservation the slices at their offset in
it, when the reservation is all one section and both slices are fresh
(never mapped or written: no commit bit), which the title cannot observe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5e0c9ab01e7be216628516ff975445682555c366)
…d reads in place are clamped alone, right before they run, not ahead in a batch or window (VICTORY_PORT_CONSTANTS_ORDER=0: as before); their ranges logged with the frame line

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2652705aa637dde3b24feb78654c815eb94bbf7e)
edsuuu and others added 20 commits November 27, 2026 16:31
Coalesce full remap and page-write queues without losing coverage of
changed memory. Keep their existing bound and report compaction in the
diagnostics. Cover the overflow with a disjoint-range regression test.

Adapted from edsuuu/VI-BR-PORT commit 87dc3075c735acf9032cc41629ea44bbc6f0d0c8.
The source port follows fxceless/victory-fork #896.

(cherry picked from commit 53a1f16)
Track GPU alias copies separately from texture uploads so a view can read the newer GPU contents. Verify the copy with D3D12 readback.

Adapted from edsuuu/VI-BR-PORT 5c17c8c83b782a9c5f1bfa12fb1d2fa438c23e5b, following kesku in fxceless/victory-fork #1241.

(cherry picked from commit 7993c1b)
VICTORY_TEXTURE_CHANGE_COMPACT=1: a full queue of changed texture
ranges is compacted instead of dropped (#137). VICTORY_ALIAS_AFTER_UPLOAD=1:
an alias copy from a GPU-written source is redone after a CPU upload in
the same list (#141). Unset, both keep the old behaviour, so the picture
stays at base f4b48ad. Tests cover both paths of the queue; the alias
readback test forces its switch on.

Code by DeepSeek (deepseek-v4-pro), reviewed by Claude.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRnS9CFngQ578Jqe1Ty
Add `EXT_FOLD` (bit 128) to `VICTORY_SHADER_OPT` for extended integer
algebraic/bitwise/shift identities, power-of-two strength reduction,
two-valued compare/select folding, and canonical comparison reuse and
branch facts, keeping `DEFAULT` (`63`) bit-identical to existing output.

- Gate every extended `simplify`, `learn`, `key`, and `merge` rule behind
  `EXT_FOLD` (`128`), leaving `DEFAULT = 63` unchanged.
- Keep shift-width and division/remainder safety checks intact; boolean
  `select -> or/and` rewrites stay unguarded because this IR emits no
  `nsw`/`nuw`/`exact` poison flags.
- Add unit tests for algebraic/bitwise/shift/compare/select folds, IEEE
  754 float negation (including NaNs and avoiding `fcmp one`), canonical
  branch facts, and `DEFAULT = 63` invariance.

(cherry picked from commit 651fbac97adc752815de9516a7884b015ee15979)
…load reuse

Add `MEM_FWD` (bit 256) to `VICTORY_SHADER_OPT` for alias-aware
forwarding and overwritten-store elimination on non-escaping private
globals (`space == 0`), plus non-aliasing shared-memory (`space == 3`)
load reuse and `WriteKind` resource invalidation, keeping `DEFAULT`
(`63`) bit-identical to existing `LOADS` output.

- Trace arbitrarily deep GEP chains to canonical scalar-leaf paths with
  escape analysis (`escaped_globals`) and signed/multi-dim bounds checks.
- Never forward `space == 3` (groupshared) stores to later loads,
  preserving barrier-free wave-ordered LDS exchange (leader election).
- Leave the original `LOADS` path untouched when `MEM_FWD` is unset.
- Add unit tests for private/shared aliasing, DSE, wave-ordered LDS
  leader election, escaped globals, loop headers, and deep GEP chains.

(cherry picked from commit 18b2c93c6cc07848810bbe92e561c338f5ac3dfd)
Add `LICM` (bit 512) to `VICTORY_SHADER_OPT` to hoist pure, non-trapping
loop-invariant instructions out of guaranteed loop blocks (plus provably
in-bounds constant-table loads) to a dominating preheader, lazily
splitting conditional entry edges while keeping `DEFAULT` (`63`)
bit-identical.

- Compute dominator tree immediate dominators (`Tree::idom`) and natural
  loops, hoisting innermost-first only from guaranteed-executed loop
  blocks (before any `dx.op.discard` or unknown write) plus provably
  in-bounds constant-table loads.
- Leave speculative hoisting out of conditional loop blocks off under
  plain `LICM` (`512`) so register-pressure trade-offs can be measured
  under a separate opt-in bit.
- Add unit tests covering preheader splitting, nested loops, trap
  guards, conditional resource/ALU/discard/uniformity negatives, and
  signed OOB constant-table GEP rejection.

(cherry picked from commit 70981f334726203fdbf604e5d69c60788f65abbf)
Add `BARRIERS` (bit 1024) to `VICTORY_SHADER_OPT` to drop immediately
adjacent covered `dx.op.barrier` calls and bounded read-after-read LDS
barriers within a block, keeping `DEFAULT` (`63`) bit-identical.

- Eliminate adjacent `dx.op.barrier` calls whose mode bits are already
  covered by the preceding barrier with no intervening memory/lane ops.
- Coalesce read-after-read barriers between non-escaping `space == 3`
  LDS loads bounded on the left by a covering group+TGSM barrier and on
  the right by either a covering group+TGSM barrier or `Term::Ret` (for
  non-UAV barrier modes), resetting on stores, atomics, resource/wave
  calls, unknown loads, and branches.
- Work cleanly both standalone (`BARRIERS` / `DEFAULT | BARRIERS`) and
  alongside `MEM_FWD`, with positive and negative soundness unit tests.

(cherry picked from commit aaa9fe248d68eada202860982016067e28548cc8)
Add `SPEC_LICM` (bit 2048) to `VICTORY_SHADER_OPT` to hoist non-trapping
ALU and pure math intrinsics (`is_speculatable_pure_call`) out of
conditional (non-guaranteed) loop blocks, separate from plain `LICM`
(`512`).

- Document the speculative execution and register-pressure / occupancy
  trade-off when hoisting out of cold conditional loop branches.
- Keep plain `LICM` (`512`) restricted to guaranteed loop blocks plus
  provably in-bounds constant-table loads; never hoist resource,
  descriptor, or uniformity-sensitive calls speculatively under either
  bit.
- Add unit tests verifying `LICM` (`512`), `SPEC_LICM` (`2048`), and
  `LICM | SPEC_LICM` (`2560`) orthogonally.

(cherry picked from commit ade8249c53c6424a84495eb83dee4ae17b911cb3)
Add `with_shader_opt` test override in `emit/mod.rs`, `DEFAULT = 63`
invariance coverage across all five opt-in passes (`128`/`256`/`512`/
`1024`/`2048`), and `dxil.dll` + D3D12 HW/WARP parity tests exercising
`0`, `DEFAULT` (`63`), and `ALL & !WIDE` (`4031`).

- Verify `DEFAULT = 63` leaves `EXT_FOLD`, `MEM_FWD`, `LICM`,
  `BARRIERS`, and `SPEC_LICM` off while `4031` activates all five.
- Verify bit-exact GPU parity across loop+LICM+NaN+guarded-div, LDS
  barriers, GFX10 compute loop, GFX10 waterfall, split-LDS Wave32
  read-after-read barrier coalescing (HW + WARP), and wave-ordered LDS
  leader election (no space-3 store-to-load forwarding).

(cherry picked from commit 6a52a47b5a746eae11353a7849d89384ebf70f8f)
…WAIT

Inspired by Marvisak/VIctory PR 3353 (fewer dropped frames while
pipelines compile for the first time). Not a direct port: the PR holds
presentation of affected images; this waits up to 10 s on a pipeline's
first request, independent of the per-frame wait budget, so intermediate
draws are not dropped on a cold cache. Off by default;
VICTORY_PIPELINE_FIRST_WAIT=1 enables it.

Verified: cargo check -p victory --release passes. cargo test --release
-p victory-gpu: 334 passed, 2 failed; both failures are the pre-existing
indirect tests that assume VICTORY_INDIRECT_REST=1.

Implemented by Codex; verified and committed by Claude.

(cherry picked from commit 76e5b5c)
(cherry picked from commit 7bb03fe)
…AIT_FRAME_MS)

With VICTORY_PIPELINE_FIRST_WAIT=1 each pipeline's first use waited up
to 10 s, so a frame meeting many new pipelines on a cold cache could
pass the title watchdog's 30 s. The first-use waits of one frame now
end 12 s (VICTORY_PIPELINE_FIRST_WAIT_FRAME_MS) after the frame's first
such wait; later pipelines of that frame wait within the normal budget.
Idea from voidopcode/vilocity cad132d (per-frame deadline for compute
waits, issue 1). Switch off: unchanged.

Code by DeepSeek (deepseek-v4-pro), reviewed and applied by Claude.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRpSS6xqa6TodU6iPSk
…in this base)

The cherry-picked VI-BR-PORT parity tests build HostShader with a
half_views field that f4b48ad does not have (Windows test target only).
Command by DeepSeek, applied by Claude.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRpSS6xqa6TodU6iPSk
@oceansde012 oceansde012 self-assigned this Nov 27, 2026

Copy link
Copy Markdown
Owner Author

CI check is red because of a clippy 1.98 lint that already exists on the base: clippy::precedence at crates/victory-formats/src/texture.rs:1346 (i * 7 >> 3). This PR does not touch that file, and main (f4b48ad) fails the same way (see PR #5). The fix belongs in a separate small PR for the base lints.


Generated by Claude Code

…y DeepSeek)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants