Repository navigation
Upstream: 31 conflicting fixes ported by hand (stacked on #653) - #716
coderanonymus wants to merge 149 commits into
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Offline check on the retail shader pack: no program gained or lost, but 17,346 programs' DXIL changes. So this changes code in most of the title's shaders, and needs an in-game look before it lands. Setup: RTX 5090, Windows 11.
A sample of 3 changed programs,
I have not checked what the changes do in game. AI use: Claude Code with Claude Opus 5.5 ran the pack, compared the dumps and wrote this. Nothing from the title is in it. |
- indirect.rs: the timing rig kept the written depth view it never reads after setup; drop the field. - draw.rs: the scissor census sorts by a reversed key. - resource.rs: placed_filler_twins is read only by the diagnostics build's copystat; allow it to be dead without the feature, as shadow and pipeline do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… frames A frame that ends in a packet where no frame begins (the tail of a frame that crossed packets, then padding) left the next frame pointing into that padding, which ended the stream early. Now the next frame is found by following each packet's skip to the next packet with frames. (cherry picked from commit ba42db6)
… now Our own completions looked their call up again by block address: after a provider's DoWork returned, after a cancel, after a failed begin, and when queued DoWork ran. A provider usually ends its call itself (XAsyncComplete from DoWork or Cancel), and once it has, the title may begin a new call on the same block, from its completion routine or from a thread that polls the status. The lookup then found that new call: - the old call's DoWork result (S_OK, size 0) or cancel (E_ABORT) ended the new call before it had done anything, ran its cleanup and fired the completion routine a second time; - DoWork still queued for a canceled call ran the new call's DoWork. Each queued DoWork now carries the call that scheduled it and runs only while that call is still the block's, and DoWork, cancel and begin complete that call. A call that is already over ignores a second complete, so nothing reaches the next call. XAsyncComplete itself still goes by block, as providers name their call by its block. (cherry picked from commit d01b170)
Fail when a requested scan root cannot be opened. Report traversal errors below a readable root alongside the other skipped inputs. (cherry picked from commit b1bdd89)
A callback submitted with a delay waited on a thread of its own and was delivered when the delay ran out, whether or not the queue had been terminated meanwhile. XTaskQueueTerminate only canceled what was already in the ports, so a pending delayed callback was not canceled: it ran later as live work (canceled = false), after the termination callback, by which time a title may have freed what the callback uses. The queue now keeps its delayed callbacks in a list until their delay runs out. Terminate cancels them along with the queued ones, before it calls the termination callback, and a delay that runs out after that finds nothing to deliver. A submit racing Terminate checks `terminated` under the list's lock, so the callback is either canceled or refused. (cherry picked from commit b9ff219)
`victory run GTA6.exe`, run from the game folder, gives an exe path with
an empty parent, and that empty folder was mounted as G:. An empty path
cannot be made absolute, so the root stayed empty and G:\x64\a.rpf
became \x64\a.rpf: the root of the current drive. The title then found
none of its files.
An empty root is now the current directory, which is what an empty
folder means everywhere else (`Path::new("").join("x")` is `x` in the
current directory). Passing a path with a folder in it is unaffected.
(cherry picked from commit 01ae55a)
imdct_half worked out every pre- and post-rotation with sin_cos on each call (n of them per subframe) and ran its FFT on two fresh Vecs. The rotations, the bit-reversed order and the butterfly rotations now come from a table built once for 128, 256 and 512 samples; the work buffers live on the stack. Every value is computed with the same expression (the butterflies with the same running product), so the output is bit for bit what it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4eb0898)
Decoder::decode took the caller's bit count as the end of the frame. Past the data the bit reader returns zeros, and a stereo tile header reading only zeros gives the subframe to no channel, so it never moves on; with a count beyond the data it never overreads either, and looped for good. Clamp the end to the bits the data holds. A frame from read_frame always holds its bits, so its decoding does not change. Add deterministic noise tests (xorshift64, fixed seeds, as BCPack's): buffers of noise packets, streams of noise frames with clean and damaged headers, frames in mono and stereo at each sample rate, bit counts past the data, and read_frame and packet at any offset. Every walk is bounded and every decode must give one frame of samples. The bit-count test hangs without the fix; the others pass on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit d4d1822)
GetModuleFileNameA/W on the host clears the thread's last error when the name fits, and code tells a truncated name from a whole one by it (grow the buffer while the last error is ERROR_INSUFFICIENT_BUFFER; or fail if it is, also when the name filled the buffer exactly). Our answer for a title image set the error when the name was cut and left it alone otherwise, so after one call with too small a buffer, or after any earlier call on the thread that left 122, a whole name still read as truncated. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit 3c7d845)
When a frame ended a loop, decode cut it at the loop's end subframe, set the loop's skip (the subframes of the loop's first frame that lie before the loop) and then took that skip out of the frame in hand: the loop's last. So the head of the last frame was dropped instead, and the first frame played from its start, with the audio before the loop in it. The number of samples came out the same; the seam did not. The pending skip is still applied to the frame in hand, and the loop's skip is set after it, for the frame decoded next. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit 985d8d4)
The source resolver's rule (local files only) knew a share as `\..`, `//..` or `file://server/..`. The host knows more spellings: any two leading separators (`/\server\share`), the object manager's prefix (`\??\UNC\server\share`), and a `file:` URL with no host whose path starts with two separators (`file:////server/share`, `file:\server\share`, also percent-encoded). Those fell through as relative paths or drive-less local files and went to the host's resolver unchanged. They are refused now, naming the server. Paths with one leading separator, a drive after the slashes or the prefix, and the path of a URL that names this machine pass as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit 11ca3ce)
(cherry picked from commit e57e76a)
Stack dumps (VICTORY_STACKS, diagnostics builds) read another thread's TEB right after NtQueryInformationThread and suspended it only later: a thread exiting in between frees its TEB, and the read faults. The thread is now suspended first and resumed on every way out. The dump times went through Duration::from_secs_f64, which panics on `inf` or `1e20`, killing the dump thread (the crash hook logs it as a crash). They are parsed by `schedule` now, which leaves out NaN and times no Duration holds. 1 new test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit acdcc41)
Calls are filed by their block's address, and a call that succeeded with a result stays filed until XAsyncGetResult takes it. XAsyncBegin refused any block whose address had a call filed. So when a title never took a result and freed the block, the next block it was given at that address could not begin a call: E_INVALIDARG, every time, with the old call's provider never cleaned up. A zeroed block is a new one: the block of a result left behind holds the result's size, so it never reads zero. XAsyncBegin now ends a finished call filed under the address of a zeroed block (its provider gets its cleanup) and begins the new one. A call still in flight keeps its address, and a block still holding a result is refused as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit 5cff000)
… forever The decoder fills an XMA voice's output ring until the write block (word 0, bits 27-31) comes round to the title's read block (word 9, bits 0-4). The write block wraps modulo the ring size (word 0, bits 22-26), and so does a read block moved on by command 18, but a read block the title set up at or past the ring's end was compared as it was: no write block ever equalled it. With a stream that loops forever the pass never ended, holding that voice's lock, so the title's next command on the voice (advance, disable) waited for good, and releasing the context arrays did too. Take the read block modulo the ring size as well, as the write side already does. A test sets up read block 6 on a ring of four with an endless loop and requires the pass to end within seconds, with blocks 0 and 1 filled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 1054fe8)
No graphics object's interface list holds IUnknown, so QueryInterface for it (and every call that hands out an object by interface id) said E_NOINTERFACE and returned null. COM code asks for it to compare two pointers for identity, to keep an object as a plain reference, or to pass it on to an API that takes any object. object::is, which all of those go through, now also matches IUnknown. The DXGI device answers with the D3D12 device, which it already stands for: one pointer whichever of the object's interfaces is asked. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit 92f2c60)
XStoreQueryPackageIdentifier documents E_INVALIDARG for a store id that has no installed package. We returned XPackage's 0x89245208 instead. (cherry picked from commit e3bef08)
host::module held the module cache's lock while it called LoadLibraryExA. Loading a DLL that is not loaded yet takes the OS loader lock, and title code runs under that lock too (a title DLL's thread attach, TLS callbacks run as threads start), where it can need the cache: any first use of a host! function, or a late-bound title DLL. One thread holding the cache and waiting for the loader lock, another holding the loader lock and waiting for the cache: the process hangs, and cannot even exit, as ExitProcess needs the loader lock too. The cache is now looked up, then unlocked for the load, then locked again to keep the handle; a thread that loaded the same DLL meanwhile got the same module, which stays loaded. (cherry picked from commit c6959ac)
(cherry picked from commit 93a24b7)
The MicrosoftGame.config reader ended a tag at its first '>', but XML allows '>' unescaped inside an attribute value. A value with one (DefaultDisplayName="A > B") cut the tag short: its '/>' was never seen, so the element stayed open and every element after it was read as its child. Game/TitleId and the storage quota were then not found, and the title ran as id 00000000 with no storage quota, its saves and temporary files in that folder, without a warning. A tag now ends at the first '>' outside quotes. (cherry picked from commit d549b63)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit e6ebec9)
XGameUiShowTextEntryAsync documents a 1024-character maximum on console, 1024 for a maxTextLength of 0, and 1024 for the Password scope whatever the title asks. 0 meant no limit here, larger limits were kept and the scope was ignored. (cherry picked from commit 936e5e5)
A slice may not start at null, even an empty one, so asking for a title image's name with (NULL, 0) was undefined behaviour; a debug build aborted the process. A null buffer is now no buffer: nothing is written, 0 is returned and the last error is ERROR_INSUFFICIENT_BUFFER. (cherry picked from commit c000581)
A literal is 32 bits; in a 64-bit operand the hardware sign-extends it when the operand is signed (i64) and zero-extends it otherwise (LLVM's AMDGPU operand rules). Every literal was zero-extended, so v_cmp_lt_i64 v[1:2], -100 compared with 4294967196, and so did the other i64 compares, v_ashrrev_i64 and s_ashr_i64. Literals of operands of i64 instructions are now sign-extended, in the vector and the scalar paths. (cherry picked from commit 7d04943)
…nd invalid enum values (cherry picked from commit e6fe8ec)
…n time order (cherry picked from commit 3f5eff5) Port notes: the only conflict was the shortcut comment upstream deletes, which the fork had reworded to not name the title; it is deleted here too. The walk and its test are upstream's unchanged; the fork's other edits to this file (comment wording, the diagnostics-only scripted keys on the real host's first pad) are kept and do not touch the fake host the test uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`GraphicsState::elements()` placed an element with `D3D12_APPEND_ALIGNED_ELEMENT` right after the previous one. D3D12 (and vkd3d) start it at the next multiple of min(4, its size), so after a 1- or 2-byte element (R8, R16, R8G8...) the offset was too small. The host pipeline gets the title's descriptions unchanged, so only the offsets read here were wrong: the rectangle-list expansion read the fourth vertex's attributes from the wrong bytes. An explicit offset near 4 GiB also overflowed the next appended offset (a panic in debug builds); it now saturates. Tests: `appended_elements_are_aligned` and `a_huge_explicit_offset_does_not_overflow` fail without the change. Port notes: the `elements()` change applied unchanged (the fork's function was identical to upstream's). The fork's host.rs already has a `#[cfg(test)] mod tests` (pipeline-library and depth-bounds tests), so upstream's new tests module was merged into it instead of being added as a second module. (cherry picked from commit 691236d) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inter
The device-removed report matched a breadcrumb node to a submitted list by
comparing `as_raw()` of the list with the node's `pCommandList`. On an
RTX 4070 no node ever matched, even without the debug layer: every list
was reported as `None`.
With device-removed data on, each host list is now named ("victory host
list <n>") when it is made, and a node is also matched by the name the
runtime copied (`pCommandListDebugNameW`). The pointer is still compared
first, against every interface pointer our live list answers with (its
own, IUnknown, ID3D12Object, ID3D12DeviceChild, ID3D12CommandList). The
node's pointer is only compared, never dereferenced: a node may name a list
that is long released.
With the debug layer on (`VICTORY_D3D12_DEBUG=1`) the nodes still do not
match; that case is left open.
Port notes: the fork's make_list keeps its lazy prelude (the list's
prelude is made on first need), so only the id and the name are added
after it; the new helpers sit after the fork's Chunk type, next to its
Scratch, and the tests join the fork's host tests. The report's two
pointer comparisons are the same code on the fork and are replaced as
upstream does.
(cherry picked from commit 6526965)
Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g layer hides them (ported from upstream commit 8a358e3) Upstream: with VICTORY_D3D12_DEBUG=1 and VICTORY_D3D12_DRED=1 every breadcrumb node still came out as `None`. Upstream opened every submission with a sentinel list of 17 markers and, when no node matched a list by pointer or name, took the nodes after the last sentinel as the submission's lists in order (`positional`). It also named each list with the private data keys for a node's ANSI and wide name, compared both name fields of a node, and logged the last node's pointer and names when no node matched. Port notes: only the parts that upstream keeps are ported. Upstream's next commit (52d528b) removes the sentinel list, the matching by position, the "matched by position" note in the report and the private data keys again (lists are named with SetName only), so they are left out here: on the fork they would have had to reach every path that reports device-removed data (`submit`, `relay_land` and `settle`), only to be deleted. Ported: the report collects the nodes once and matches each to a run once (used for the progress line and for the stopped lists), `HostList::is_node` compares the ANSI name field as well as the wide one, and the warning with the last node's pointer and names when no node names one of our lists. Upstream's tests for this commit cover only the removed sentinel and position code, so none are added; the ANSI name test comes with 52d528b. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e; drop the position fallback (ported from upstream commit 52d528b) A run on an RTX 4070 with the debug layer on showed why a list's name did not match a node: the runtime appends its own note to the name we gave, as in "victory host list 158 (debug layer indirect)". The name now matches exactly or followed by " (", and never as the start of another number ("victory host list 1580"). Both name fields of the node are read, as before. That makes the sentinel list and the matching by position of the previous commit unnecessary, so they are removed, together with the extra private data keys it set: lists are named with SetName again. The warning that logs the last node's pointer and names when no node matches a list stays. Tests: the name with the note matches in the wide and the ANSI field, a longer number and a name without the " (" do not; with the match for the exact name disabled or loosened to a prefix, the tests fail. Port notes: the sentinel list, the matching by position and the private data keys this commit removes upstream were never ported to the fork (see the port of 8a358e3), so only the match of the name followed by " (" and its tests are added. One assert of the new test is wrapped as rustfmt would. The fork's code now has the same additions and removals as upstream's three commits together. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The d16 forms of the typed buffer loads return each channel as 16 bits, two per VGPR, low half first; the decoder already sizes their data that way. The lowering only treated `buffer_` names as d16, so a tbuffer_load_format_d16_* went through the 32-bit path: the first VGPR got channel x as a 32-bit value (the f32 bits of 1.0 instead of the f16 pair (1.0, 2.0)) and the other channels were dropped. The format path now packs its channels for d16: integer formats keep their low 16 bits, the other formats become f16 (as the MUBUF d16 path converts them). Port notes: the fork's buffer lowering has the byte and 16-bit (`narrow`) accesses right before the d16 test, which conflicted; both are kept, with upstream's d16 test for buffer and tbuffer names. The fork's format_load is upstream's, so d16_channels and the test apply as they are. (cherry picked from commit c430b1d) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Buffer format loads divide a UNORM or SNORM field by its largest value. A host may divide through a reciprocal and land just below 1.0: on an RX 9070 (RDNA 4), 16_16_UNORM's 65535 loaded through the d16 path as the half 0x3BFF instead of 0x3C00. The largest value now selects 1.0, and an SNORM field's two lowest values select -1.0, as the formats define them. Port notes: applied without conflicts on top of the d16 port; the fork's format_load is upstream's. (cherry picked from commit 645391b) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f177aae) Port notes: the only conflict was the constants block, where the fork added MAX_MEETS and the Meets struct for its memoised meet search; MAX_MEMO now sits after MAX_MEETS. The ite and forget changes applied unchanged: the fork's ite, mk and forget match upstream, and every fork caller that reads `overflow` (structure_wide, the lane-condition fixpoint, the exit lowering) still fails with TOO_LARGE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
src2 plus the sum of the unsigned differences |a - b| of the operands' bytes (v_sad_u8), halves (v_sad_u16) or whole dwords (v_sad_u32), wrapping at 32 bits. v_sad_hi_u8 adds the byte sum shifted to the high half; v_msad_u8 leaves out a byte whose mask byte (src1) is 0. AI-assisted (Claude Code). (cherry picked from commit 5d6889e) Port notes: the lowering applied unchanged (same place, before the min3/max3/med3 arm). Only the test conflicted: the fork has its own buffer_cache_invalidations_lower_as_no_ops test at the spot upstream added sums_of_absolute_differences_lower, so both are kept, the fork's first. The fork's lowers_valu helper is the same, so the test needs no change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mask_b32 (ported from upstream commit 67c4f53) Structurisation now exports the lane masks not derived from EXEC or VALU results (`Structured::other`: uniform selects, constants, opaque values), and `v_cndmask_b32` resolves its mask there and takes inline constant masks: 0 is no lane, -1 every lane, another constant this lane's bit of it where host lanes are the console's. Port notes: the fork's v_cndmask_b32 already lowers a mask held as a number in compute programs by reading the register pair at the use (exact for wave64 halves written apart, refused in a half-wave); that path is kept for masks in `other` that reach an opaque atom, directly or through lane-mask joins (the walk `lane_constant_masks` does, now shared as `mask_reaches`). Uniform and constant masks from `other` go through `boolean` as upstream does, so they also work outside compute, and a constant one without console lanes stops with "a constant lane mask" instead of tripping `cross_lane`'s debug assertion. `other` is exported without the split wave64 low dwords, as the fork does for `masks`. Inline constant masks are taken only as integers (128..=208, as structurisation reads them; a float constant's 64-bit form differs), and another constant is refused in a half-wave as the fork's number path does. Upstream's test selected on a mask from an unsupported s0 input into a dead v1; it now enables TGID_X (s0 an input), makes the second select read v1, and also checks that a constant naming lanes, inline or in a register, is refused without console lanes. The shortcut note in `lane_constant_masks` now says what an opaque mask only a select reads still does in compute. On host waves of 32 that do not exchange (a console wave64 run as two halves), `lane_bit` takes the host lane, so both waves would pick a constant's bits from the low dword. On the paths this change opens or touches (an inline constant, a constant in `other`, and the fork's own path for a mask held as a number, which checked only `local`), a constant mask is refused there: "a constant lane mask in a half-wave". The test a_constant_select_mask_on_host_halves_is_refused covers the inline and held forms. The held form translated wrongly before this change; the inline one was refused as an untracked mask. A mask in Structured::masks reaches `lane_bit` through atom() too; the commit "a constant or opaque lane mask on host halves is refused" closes that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mit 59035de) A list's scratch chunks now grow: each new chunk is twice the last, at least what is asked, at most SCRATCH_CHUNK, instead of every chunk after the first being 4 MiB. A length whose 256-byte rounding overflows gets None instead of a debug-build panic or a wrapped, empty allocation. Diagnostics builds log each chunk taken (target victory_gpu::scratch), and a new chunk's buffer name carries its size, now that chunks come in several sizes. Port notes: reimplemented by hand; the fork's scratch is a different design (chunks shared between lists through the Spare pool and given back on reset, a 256 KiB first chunk, VICTORY_SCRATCH_POOL=0 for 4 MiB chunks kept by their list). The growth applies to the shared chunks only and starts from the fork's SCRATCH_FIRST rather than upstream's 64 KiB; sizes are powers of two (upstream: multiples of 64 KiB) so that the pool, which matches sizes exactly, keeps few size classes. VICTORY_SCRATCH_POOL=0 keeps 4 MiB chunks as before. The fork already skipped chunks that do not fit with a while loop, so upstream's if-to-while change was present. Upstream's test is adapted: chunk sizes follow the fork's policy, and after a reset it checks that shared chunks went back (their addresses can be taken by other lists in between) or, without the pool, that the list's own first chunk is used again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The GPU shader tests dropped Host::new's error, so a machine without a usable device printed only "no SM 6.6 hardware device; skipped". On Windows 10 without the Agility SDK (fxceless#84) the hardware adapter reports SM 6.5 and WARP SM 6.2; the 15 VALU and waterfall tests then fail with "neither hardware nor WARP SM 6.6 device available" and nothing says the runtime is the cause. The seven skip sites now print the error: no SM 6.6 hardware device (the device supports SM 0x65 only); skipped no SM 6.6 warp device (the device supports SM 0x62 only); skipped Checked on Windows 10 22H2, RTX 3060 + RTX 3090: both clippy runs of CI pass; the victory-shader tests give the same 105 passed / 15 failed as before, now with the reason. (cherry picked from commit 100de0e) Port notes: the fork's valu_tests run_cases_on loops over a `devices` slice instead of upstream's fixed hardware/WARP pair; the conflict was resolved by keeping the fork's loop and taking upstream's match. The fork has six more skip sites with the same `let Ok(host) = ... else` shape (intersect_tests, rect.rs, four in wave64_tests, the latter saying "not run"); they print the error the same way. The two sites that skip silently (valu_tests' wave-size f64 case, mod.rs' optional run after validation) are left as they were. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e52777a) Port notes: the fork already passed the initial pipeline into new_list and set it in the list's draw state (with its own doc comment and the fork's `earlier`/`gate` list fields); what was missing is the `pipeline::bound` call after a successful hand-out, so a pipeline first bound at list creation now logs its "first bind" like set_pipeline and reset do. The fork's `#[cfg(not(windows))] let _ = pipeline;` is gone since `pipeline` is now used on every target. Upstream's test is kept as is; the fork's create_compute, ComputeHead and pipeline::bound match upstream's for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f096774) Port notes: the fork's Host also carries the adapter (for the video memory budget) next to the presenter, and its resize path first settles presents sent ahead and logs the new buffers and video memory. Kept all of that; the settle_now(WHY_SYNC) wait moved inside the throttled closure, so a frame skipped by the retry wait does not stall on the GPU. The fork's video-memory logging around swap-chain creation stays as is. Upstream's test was added next to the fork's existing host tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ted() GetCopyableFootprints does not pad the final row of the final subresource to RowPitch, so pitch * rows * depth in Staging::detile can exceed the mapped upload buffer size (UB in from_raw_parts_mut). committed() also used unchecked p + len (wrapping to end < p in release) and ignored PAGE_NOACCESS / PAGE_GUARD. - Keep Staging.size unconditionally and clamp subresource slice length to size - footprint.Offset via subresource_len(). - Check overflow with checked_add / saturating_add and reject PAGE_NOACCESS / PAGE_GUARD in committed(). - Add regression tests for both. (cherry picked from commit 4fc9d70) Port notes: the fork's Staging already keeps the buffer's size unconditionally in `bytes` (the same `total` from GetCopyableFootprints that sizes the upload buffer), so detile clamps against `self.bytes` and the diagnostics-only `size` field stays as it was. The fork's committed() asks QueryWorkingSetEx page by page by default (saturating, no wrap) and only uses the VirtualQuery walk (committed_by_query()) under VICTORY_COMMITTED_QUERY=1; upstream's overflow and PAGE_NOACCESS / PAGE_GUARD hardening goes there. The regression test runs against both committed() and committed_by_query(), next to the fork's title_memory_tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ge flags) (cherry picked from commit c0228d9) Port notes: the fork's emit_indices also culls a primitive whose corner names a vertex past the written count (min of max_vertices and the lane count), so on the fork the 10-bit mask did not read out of range but made every edge-flagged triangle (index 512 or more) vanish. The conflict was only that rewrite: the fork's loop is kept and its mask is now 0x1FF, so the bounds cull sees the real index. Upstream's tests are taken as they are (the fork's host helpers match); the translation test's comment says the old mask culled the primitive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f E_NOTIMPL ID3D12Device::GetDeviceRemovedReason "gets the reason that the device was removed, or S_OK if the device isn't removed" (Microsoft D3D12 reference). Slot 37 (0x128) in the device function table was left on the default handler, returning E_NOTIMPL (0x80004001) on a healthy device, which a title checking FAILED(GetDeviceRemovedReason()) takes as a lost device. Wire slot 37 to removed_reason, which queries the host device's GetDeviceRemovedReason() and returns S_OK on Ok (or when there is no host device) and the error's HRESULT otherwise. Add a unit test verifying slot 0x128 returns S_OK on a healthy device. Co-Authored-By: Gemini 4 Neon <noreply@google.com> (cherry picked from commit 13185f5) Port notes: the conflict was only positional. The fork has its own unknown_pipeline handler where upstream's removed_reason lands, and the test module's tail differs: upstream's context carried shader_model_and_wave_options_are_the_consoles from an earlier upstream commit the fork does not have, which is left out. removed_reason, the slot 37 entry and the new test are upstream's unchanged; slot 0x128 was unset on the fork as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The f16 interpolation always wrote the low destination half via low_half() and dropped the VOP3 output modifiers. Write through write_half() (op_sel[3], SDWA) and apply omod then clamp to the f16 result in f32 so the conversion rounds once, matching write_f()'s order. Addresses VIC-BT-029 from audit fxceless#1242. Validation: - cargo test -p victory-shader --locked -- --test-threads=1 --skip emit::valu_tests --skip emit::waterfall_tests - cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings - cargo xtask policy (cherry picked from commit e29391f) Port notes: the fork's interp() evaluates a packed half as an f32 and narrows it once (to_f16) instead of upstream's narrow16 per half, and it lowers v_interp_p1ll_f16 (an f32 result) separately. So half_modifiers() here takes that f32 and applies omod then clamp before the single legacyF32ToF16, rather than round-tripping f16 bits through legacyF16ToF32 as upstream does; the fork's p1ll and flat-dword paths are unchanged. The mod.rs conflict was upstream test context the fork lacks (emit_pixel, rows, texcoord and the tests using them); only the new dump_dxil helper and test were taken, with the test's p2 comment fixed to the encoding's real operands (v2, v1, attr0.x, v2). The test is Windows-only (dxc -dumpbin). Its "low write keeps the high half" check (-65536) cannot hold on the fork: bitcode::opt folds the merge away because the old v2 is the constant 0. It checks instead that the low write is masked to 65535 and not shifted. The emitted, optimized module (disassembled on Linux) holds that (low), a shl by 16, the 2.0 multiply and dx.op.unary opcode 7 (high), and no saturate in the low variant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the console, whole-quad mode puts a pixel shader's helper lanes in EXEC, so a waterfall loop (read the first lane's value, run the lanes with that value, take them out of EXEC) serves them too. On the host, wave operations leave helper lanes out: once only helper lanes are left in such a loop, WaveReadLaneFirst reads no lane, no lane matches, and the loop runs to the iteration limit in each of them. In a retail title's world, draws took 0.3 to 1.3 s each until a submission passed the host's 2 s limit: DEVICE_HUNG about 200 s into the world. A helper lane now takes its own value, so it matches in the first pass and leaves. What it computes only feeds derivatives; its stores are dropped already. Waterfall reads the proof already turns into per-lane reads are unchanged. (cherry picked from commit 0601955) Port notes: the fork's generic v_readfirstlane_b32 arm reads through first_lane (a ballot of the guard where the instruction is guarded) and, for compute programs split into two exchanging host waves, through the halves exchange; the helper select is applied to that arm's result, after the fork's logic. The fork's own_bits and waterfall-read arms already give each lane its own value and are unchanged; the exchange paths are compute-only, where the helper never applies. Upstream's helpers_read context next to read_lane is not on the fork and was not taken. The doc comment notes that the fork's pixel loop limit is its own (128 by default) rather than LOOP_LIMIT; upstream adds no tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ted from upstream commit ed0dbfd) Shadow::update skipped the ranges an earlier list of the same submission declared as written by shaders, so the title's writes there (constants, sizes) stayed stale in the copy for the whole submission; on an RTX 4050 Laptop a dispatch read its sizes as zeros and looped until the device was removed. None of the submission's own shaders has run when it refreshes: update_busy copies the pages the title wrote there since they were taken, and puts the same bytes into the snapshot, so copy-back neither takes them for the GPU's nor puts them back over a later title write. Test: title_writes_under_a_busy_range_are_copied fails without this and should pass with it. Port notes: reimplemented by hand, the fork's Shadow differs too much for the cherry-pick (no Tracked::take, a whole-copy snapshot instead of segments, copies in the card's memory). The fork also sends submissions ahead (late/relay, on by default), so `pending` can hold ranges of flights still on the card, and upstream's premise (the previous submission is done) does not hold for those. So the port records, per copy, the parts the submission being prepared declared that no earlier declared range held (`own`, in `writing`), refreshes only those through the fork's write-watch path (update_free/copy_stale, with the copied runs also written into the snapshot), and clears them when the submission goes to the card (`writes_sent`, called in Host::submit after take_snapshots). Ranges a flight holds keep the fork's handling (stale_under_flights/merge_under_writes). For copies in the card's memory the refreshed runs go up with the dirty upload before the lists and are hashed after it, as other refreshes. With wide_back (the default) the snapshot is taken after the refreshes anyway; the sync keeps the other snapshot modes right. The test is adapted: a write-watched VirtualAlloc instead of upstream's watch::tests::pool, read_host/write_host test helpers added, take_snapshots/writes_sent/copy_back_done called as Host::submit does, and one more assertion that a sent range is left alone. It is Windows-only and needs a host GPU (it returns early otherwise). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`Instruction::name()` binary-searches the opcode table, and the pipeline asks about every instruction eight times per translation: `ir::build`, `structure`, `resource` (which has the most call sites), `io` and `lower`. The answer cannot change - the encoding and opcode are decoded from the words and never rewritten - so resolve it once when the instruction is built and read the field after that. Measured with the synthetic bench from fxceless#1002 (no game data), sixteen interleaved rounds per arm, best of each, nanoseconds per instruction, at 256/1k/4k/16k instructions: resource 17 -> 9, 15 -> 7, 24 -> 16, 23 -> 15 (0.47-0.67) lower 511 -> 479, 428 -> 411, 440 -> 401, 477 -> 428 (0.90-0.96) io 27 -> 23, 26 -> 21, 26 -> 22, 30 -> 22 (0.73-0.85) whole 926 -> 881, 920 -> 874, 958 -> 921, 1019 -> 939 (0.92-0.96) `decode` pays the one search it used to be spared (112 -> 115 at 16k, inside the run-to-run spread); every stage after it reads a field. The emitted DXIL is byte-identical at all four sizes. cargo test --workspace --locked: 342 passed, 0 failed, 7 ignored. Both clippy configurations clean; cargo xtask policy ok. (cherry picked from commit 146dfef) Port notes: the fork rewrites decoded instructions in ir::unspill (a scalar parked in a VGPR lane becomes s_mov_b32/s_mov_b64 or s_nop), which built the struct by hand in another module. With the name cached in a private field, that rewrite now goes through a new crate-internal Instruction::new that resolves the name, and decode uses it too, so a rewritten save or restore is not left named v_writelane_b32 / v_readlane_b32. Added ir test parked_scalars_become_moves_with_their_names for that path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Based on fxceless#34 by ka1qux (commit faa0a9a), rebased over fxceless#45, which added the same flag and register helpers for clwb loops; the duplicates are merged into gpr/cmp_flags/CMP_FLAGS. clzero: the two loops compilers build around it are done whole in one exception, leaving registers and flags as the last pass would. Anything else around it is one line and the next instruction. rdpru: returns the time-stamp counter for MPERF and APERF, 0 for other counters, and leaves the flags as they are: a Ryzen 7 5800X3D running it natively in user mode changes none, for known counters or not. Added over fxceless#34: - loop 1 rejects cmp rax, rax (it fell into the loop and left wrong flags); - tests that go through the emulation on any CPU (both loop shapes, the rax-rax and wrong-neighbour fallbacks, rdpru with both flag states), since on an AMD host the native tests never enter the handler. Port notes: crash.rs took the change as it is, but on the fork the vectored handler first gives every illegal instruction to console_insn::emulate (the emulator ported from XCL), which decodes clzero, the `clzero; add rax, 0x40; cmp rax, b; jb` loop and rdpru itself; emulate_amd_only only sees what it declines (a line that is not writable, such as a block the GPU write watch guards). Its loop arm left rax at the limit and the flags as they were, and zeroed nothing for a loop that ends after one pass (cmp rax, rax), so upstream's native test would fail on an Intel host. It now zeroes the lines the passes zero (still region by region, as Windows reports them writable) and steps over the clzero alone with rax at the last pass: the CPU runs that pass's add, cmp and jb, and leaves rax and the flags as the real loop does. Spans of 2 GiB or more keep the fork's old shortcut. A plain clzero whose line is writable now goes to crash::clzero (pub(crate)), so the `mov rax, a; add a, 0x40; clzero; cmp a, b; jb` loop runs whole on the live path too; its lines after the first are not checked (one that is not writable faults inside the handler, as the fallback's unchecked writes already did). rdpru on the live path stays console_insn's (QueryPerformanceCounter for MPERF and APERF, 0 for other counters, flags kept); upstream's TSC version is the fallback. Added a console_insn test of the live path. (cherry picked from commit 0de9efc) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port notes: applied as it is. These tests call emulate_amd_only directly, so they cover crash::clzero, which on the fork also does the second loop shape for console_insn's live path. (cherry picked from commit 514927d) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the ported fixes, crates/victory-shader/src/emit/lower.rs reached 525,703 bytes. That is past the asset policy's 512 KiB limit for one file, so xtask's repository_passes_policy failed. Its test module moves, unchanged apart from one level of indentation, to emit/lower/tests.rs, which leaves lower.rs at 497,625 bytes. Upstream has also begun moving parts of lower.rs into emit/lower/ (bvh.rs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A console wave64 program can run on host waves of 32 that do not exchange (halves set, exchange None). There lane_bit takes the host lane, so both host waves test the low dword of a mask held as a number: console lanes 32-63 get the bits of lanes 0-31. The ported v_cndmask_b32 change refuses this for its own paths. A review of the stack found that a mask in Structured::masks still reaches lane_bit through atom(), for example a compare ANDed with a constant (s_and_b64 s[0:1], vcc, 1) or with a pair written apart. That hole was already on main. atom() now refuses an opaque mask there, and a constant one unless its two dwords are equal (the host lane's bit is then exact). The test a_constant_select_mask_on_host_halves_is_refused gains three cases: a compare with a constant, a compare with a pair, and a constant pair in Structured::other. Without this change, they translated. Also corrects helper_reads_own's doc: on the fork a pixel loop stops after 128 passes, not at LOOP_LIMIT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ported mesh primitive test (c0228d9) dropped Host::new's error. The other skip sites print it since 0dde6f9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ef4e8a9 to
dfeed68
Compare
…ull requests and the host FidelityFX on our layer; our translator, title memory and copy-back kept 319 commits past ffe310e, merged onto wave4. Most of its runtime pull requests were here already, picked one by one (fxceless#653 and fxceless#716, prhle, offpr): where a change arrived both ways, the copy this branch had is kept (net, audio, xg, runtime, lifecycle with its one stand-in window (#1677), files, kernel, xasync, xgamesave, xmem, gameinput, the loader's crash, clzero and publish code, the pipeline cache, #1658's staging clamp). The rest is the resolution first made on wave2 (offm-on-wave2, ab1d525), carried over: - crates/victory-shader: ours (every conflict --ours). Kept from theirs only what landed whole: fxceless#661 SP3 text operands, fxceless#1021 s_atc_probe's immediate, #1636 FLAT offsets. Reverted where half landed: fxceless#1180, range.rs, fxceless#617's bench, #1337's sampler, ACCC, SOURCE_HASH, and new test files whose mod lines are in conflicted files. The rest is to be ported on its own. - victory-gpu: ours plus the official units taken, each from its own diff: host.rs (fxceless#615 switch=0 is off, fxceless#1082 TDR log, #1626 swap-chain retries throttled), descriptor/host.rs (fxceless#974, its walk no longer cut at 2^18 steps by ours), descriptor.rs (fxceless#52: a mirror holds the heaps' lock while it uses the heap, a read lock on this branch's RwLock, and so does our re-mirror of waiting slots), resource.rs (fxceless#52, fxceless#504 depth/stencil footprints, #1390 A8), pipeline/host.rs (fxceless#618), pipeline.rs (a stream subobject past its end not read), capture.rs (fxceless#615, fxceless#1146, a D24 depth plane dumped as depth), frame.rs (fxceless#174, with our late-wait shortcut inside the tick reservation), device.rs (fxceless#928, feature queries 7/8/23), list.rs (#1446, fxceless#52), external.rs (host FidelityFX, VICTORY_FIDELITYFX_DIR, off unless set), switch.rs, tdr.rs, and the small PRs (fxceless#553, #1562, fxceless#270, fxceless#153, #1453, #1204, fxceless#1173, #1206, fxceless#474). - Not taken, ours kept: title memory at raw addresses (27c3dc9, 0f63757, 6d021fe: their memory.rs and Upload), page marks (cd94d35, 940d32f: with our shaders every write through a view would be lost), bindless.rs and the change journal (c75fdba), root views and retirement at execute end (d71c388: unsafe with flights in the air), rectangle GS and table constants in place (683ad7a), twins and shared host textures (13bbd6f), heap copies (86a5ed6, bacb06a), the shader cache key, warm-up, pipeline queue and library (c47b529, 9c58a1c, fxceless#1000, #1660), #1510, #1635, #1246, fxceless#322, #1322, fxceless#669, fxceless#197 (turned down by prhle), #1726 (ours waits longer; its test added), the console upscaler's UAV clears. `translate --cache` is `--warm all` (with the adapter probe); the pipeline pre-build is not in. - Also taken: the shader pack and the database's effects (shader-info), the startup archive check (fxceless#12, on this branch's KnownBuild with its patches), and the runtime PRs not here yet (FidelityFX's config and module). - The title is not named in the merged-in comments (4e17478). Details, the overlaps and what to watch: README, "The official repository, merged".
Stacked on #653, which brings over the 113 upstream fixes that apply cleanly. Please merge that one first; this PR's own commits are the 34 after it.
Rebased on main (a26859f)
Rebased with #653 onto a26859f. The port of 4ab20fc (indirect budget charged in record order) is dropped. a26859f rewrote the same clamp shader, and I won't merge two rewrites of it without a run. Everything else applied. Clippy passes with and without
--all-featureson a clean build, Linux tests (263) pass, and so does the asset policy.Why
#653 left out the upstream commits that conflict with the fork. Most of those are fixes inside code the fork rewrote. This PR ports them by hand, so the fork has them without a full upstream merge.
What
cherry picked fromorported from).lane_bit), 4e60ea3 (indirect drop before clamp), 42363ab and ccfb029 (shader tests skip without a GPU). The fork has each in its own form; the reviewers checked each claim.emit/lower.rsreached 525,703 bytes, past its 512 KiB limit, sorepository_passes_policyfailed. Its test module moves toemit/lower/tests.rs. The move is byte-for-byte, apart from one level of indentation (checked with diff). Upstream has started splittingemit/lower/the same way.lane_bitthen tests the low dword in both host waves.atom()now refuses an opaque mask there, and a constant one unless its two dwords are equal. The portedv_cndmask_b32change refuses its own paths the same way. Theatom()hole was already onmain, for example a compare ANDed with a constant feeding a select. Test:a_constant_select_mask_on_host_halves_is_refused, with five cases, all of which translated (wrongly) or reached the wrong path before.How it was made and reviewed
Ultracode workflow:
v_cndmask_b32constant masks: the half-wave miscompile above.atom()hole, fixed above, and two small slips, fixed in the last commit. It found no other interactions between ports.Some of these ports may overlap open fork PRs, judged by title only: #165 (
Staging::detile), #325 (frame waits), #97 (DirectStorage page 0; d09f3aa itself was left out for that reason).Verification
cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with--all-features, forx86_64-pc-windows-msvc(cross-checked from Linux): clean on the stacked branch.No game data used; the game isn't named in the tree.
Ported (upstream sha, author)
🤖 Generated with Claude Code