Skip to content

Shaders/GPU: fixes for #604, #610, #720, #724/#725, #736, plus upstream fixes ported in - #1

Merged
MfDev0 merged 123 commits into
mainfrom
arena/59fabb00-victory
Nov 24, 2026
Merged

MfDev0 merged 123 commits into
mainfrom
arena/59fabb00-victory

Conversation

@MfDev0

@MfDev0 MfDev0 commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Fixes and tests taken from open issues in Marvisak/VIctory, each with a regression test.

1. Shaders: a value with no DXIL form stays missing through a join only another join reads

Closes Marvisak#604.

Lower::get marks the phi a value is read from, and fill_phis used that mark to decide whether a missing incoming value fails the program or is silently replaced by zero (or false). A join that only feeds another join is never read through get, so it counted as unread: a timestamp read (s_memtime, which has no DXIL form) reaching a branch through two joins translated, while the same read with no join in between was refused with a scalar memory read as data.

follow_phi_reads now follows the incoming values of a read phi, so any phi that a read phi takes a value from counts as read too. The refusal then reaches the reader, as it does without a join, and a value that really is dead (the group id is read instead) still translates.

The test is the reproducer from the issue. On the base commit it fails with left: None, right: Some("a scalar memory read as data").

2. GPU: VICTORY_D3D12_WARP=0 picks the hardware adapter again

Closes Marvisak#610.

The code only checked whether the variable was set, so VICTORY_D3D12_WARP=0 still created the host device on the software adapter. 0 now counts as unset. 1, an empty value and every other value still select WARP. The README row says so.

The predicate is split into warp_switch(value) so the test doesn't have to change the process environment while other tests run.

3. Shaders: test that a built program is SSA and every read is dominated

A new invariant test for ir::build. It decodes 20,000 random programs across all 18 encodings. For every program that builds, it checks that each value has exactly one definition and that every read is dominated by its definition, using a reference dominator computation written independently of ir::idoms. A 400k-program run found no violations; the committed test is sized to finish in about 0.3 s.

4. Shaders: a heap view written anywhere is a UAV in every access, and glc makes it globally coherent

Addresses Marvisak#724 and Marvisak#725.

For a descriptor from the SM 6.6 resource heap, SRV or UAV was decided per instruction. A load of a view that the program also stores to got an SRV handle (0xB, 0) and the store got a UAV handle (0x100B, 0), for the same descriptor. A scalar read of it became a constant buffer.

  • uav_bits now decides IsUAV from all uses of the descriptor, including twin loads of the same dwords. A store or atomic through any of them makes it a UAV. When the root signature declares a kind, that kind still wins.
  • Scalar reads (s_buffer_load) of a UAV are raw UAV loads (11 | 0x1000) instead of a constant buffer.
  • A UAV with a plain glc access also sets IsGloballyCoherent (0x4000, per DXC's DxilResourceProperties.h) on all of its handles. glc on an atomic only asks for the old value, so it doesn't count. glc on a view that nothing writes leaves it an SRV.

The test reads the handle props through a test-only Lowered::handle_props. It covers load+store in both orders, glc, glc with no writes, and a scalar read with and without a write. With the inference disabled it fails with left: [(11, 0), (4107, 0)], right: [(4107, 0)], the mismatch the issue describes.

5. Shaders: cube-map arrays sample their slice and face, not layer 0's +X face

Addresses Marvisak#720.

For a cube array, the console takes the face operand of image_sample* / image_gather4* (dim CUBE) as 8 × slice + face, and GFX10 MIMG has no array bit. The lowering always declared a TextureCube and matched the operand against faces 0–5 only. So any slice above 0 sampled slice 0's +X face, with no refusal or log line.

  • cube_array treats a cube descriptor as a TextureCubeArray (kind 9) when some sample or gather through it builds its face operand in one of these ways:

    • a multiply-add by 8.0 (v_fma/v_fmac/v_fmamk/v_fmaak/v_mad/v_mac/v_madmk/v_madak, which is how Mesa's prepare_cube_coords emits it);
    • an add of a product by 8.0;
    • a constant of 8 or more (a constant slice folded in).

    This is decided per descriptor, so every access through it, including image_get_resinfo, uses the same kind.

  • The slice floor(face / 8) becomes the fourth coordinate and face − 8 × slice the face. Both are exact in f32.

  • A size query of a cube array reports its layers in faces (6 × cubes), as the hardware does. radv sets lower_txs_cube_array, which divides that by 6.

  • A bare face id (v_cubeid_f32) stays a cube, as before.

The test is built on the issue's reproducer. It covers v_fmac by 8.0, v_mul + v_add, the constant 10.0 (slice 1, face 2), a multiply-add by 4.0 (stays a cube), and a size query alongside an array sample and alongside a bare-face sample. With the inference disabled it fails with left: 5, right: 9. It hasn't been checked on a GPU. A WARP run with a cube-array view whose texels hold 10 × slice + face would confirm the texels.

6. Shaders: only a timestamp stays missing through joins, not every value

Addresses Marvisak#736 (the regression upstream's JMAN730#612 caused, which section 1 shared).

Section 1 marked every phi that a read phi takes a value from as read, so any missing incoming value of such a join refused the program. Upstream measured the same change in Marvisak#736: 323 programs that used to translate and validate stopped translating. Most of the refusals were on descriptor dwords, lane masks and interpolation halves that only joins carry after their last use, where the zero never reaches a reader.

Phis read only through other joins are now kept apart from phis an instruction reads directly (phis_read_through_joins). For a phi reached only through joins, a missing incoming value refuses the program only when zero would silently misrepresent it: an s_memtime / s_memrealtime timestamp, which is the JMAN730#604 case (zero_is_wrong). Every other value becomes zero on that edge, as it did before JMAN730#604. The test keeps the timestamp case and adds an s_getpc_b64 carried through the same two joins. It is refused when read directly and translates when only joins carry it. I checked the test by reverting the fix: it fails.

7. Shaders: compute samples clamped by _cl keep the console's lanes

Outside pixel shaders, image_sample_cl and image_sample_b_cl lower like image_sample(_b): as explicit gradients from each quad of lanes. They were missing from implicit_derivatives, so a compute program that used only these forms did not get the console's lane order. The gradients then came from whichever host lanes shared a quad, and a debug assertion fired in tests. The new test lowers each of the five forms in compute. It fails on image_sample_cl with the old list.

8. Docs and housekeeping

9. Upstream fixes ported into this fork

These are merged PRs from Marvisak/VIctory that this fork didn't have. Each commit keeps the original author and names the upstream PR. Where the fork's code had diverged, the change was adapted, and the commit message explains how.

Upstream PR Commit Change
Marvisak#696 5b93bd0 Docs: drop a private intra-doc link
Marvisak#685 d56d408 Shaders: gate the constant_color test helper to Windows
Marvisak#681 8cd5f10 GPU: unbind vertex buffer slots for null view arrays
Marvisak#680 1169a3b GPU: host upload path for texture staging copies
Marvisak#675 d45ef2e Docs: rustdoc builds without warnings
Marvisak#654 b197a34 GPU diagnostics: buffer UAVs described by range
Marvisak#637 9ba912d Shaders: GFX10 packed inline constants by operand type
JMAN730#565 e488762 Shaders: centroid position with conservative depth
Marvisak#706 510d880 Shaders: v_cmp_lg ordered on AMD hosts (conflict resolved by hand)
JMAN730#418 be15b44 GPU: half subnormals from f32 rectangle outputs (also checked against ties-to-even for every f32 below 2^-14)
JMAN730#432 c48acf0 Shaders: uninitialized SGPRs read as zero
Marvisak#671 17ef0d2 GPU: upload CPU-written textures before CopyResource / CopyTextureRegion
Marvisak#666 600e362 Loader tests: probe fixture under CARGO_TARGET_TMPDIR (the Proton override is kept)
Marvisak#634 244cd02 Shaders: image_sample_o with constant offsets. Adapted so the offsets also reach the quad-gradient path, and given a new regression test (in range, both ends of -8..7, out of range, and per-lane offsets)
JMAN730#205 0c8ec39 GPU: null texture UAVs keep the title's view dimension. The game shader name was dropped from the comment to follow the asset policy
JMAN730#336 bc188e3 GPU: 2^18 dynamic descriptor slots where the heap fits, else 2^16. Only the heap sizing was ported, because this fork already falls back to the title's slots instead of dropping the draw
JMAN730#611 626937d core: test that a data_dir inside the repo is refused (the rest was already here)

Upstream JMAN730#612 is not ported, because section 6 replaces it. The other recent upstream merges were already in this fork, sometimes in a newer form.

10. Upstream JMAN730#566 merged

The per-lane descriptor and waterfall-loop work from upstream JMAN730#566 (upstream commits a3d3bc9, ffa6635, 077ec8b, 6285e19, 6638098, b1c8306, 6c63dea, 74a9d33, ffe310e) is merged in 872361e. The track callers in tests/resource_tracking.rs were updated for its new signature. With this merge the shader lib tests go from 114 to 140.

11. Crash and hang fixes for reported issues

Issue Commit Change
Marvisak#735 ac62f72 GPU: view heaps are sized against the device's limit (D3D12_OPTIONS19.MaxViewDescriptorHeapSize, else 1,000,000). A 1,310,720-view heap was created on NVIDIA but refused by the runtime, and the device was removed when it was used. Test: view_heaps_stay_within_the_device_limit
Marvisak#747 4ab908f GPU: a capped view heap keeps the full 2^18 dynamic slots and mirrors fewer title slots (737,856). With 2^16, most of the world's indirect draws were dropped as "no dynamic slots", as measured on an RTX 4070 Ti, 5060 Ti and 5070 Ti
Marvisak#735, Marvisak#741 f32ed74 GPU: render-target and UAV textures in B5G5R5A1_UNORM (no UAV on PC) and B4G4R4A4_UNORM (no RT on PC) are made as R8G8B8A8_UNORM through target_format, the same way R9G9B9E5 becomes RGBA16F. Cross-family copies with such a texture are skipped. Tests: small_unorm_targets_substitute_rgba8, copies_stay_within_a_format_family, and an extended host-creation test
Marvisak#758 73b2ae6 GPU: a texture a copy wrote now uploads again once the title rewrites its memory. This is detected with the write-watch, counting only pages wholly inside the texture. Test: copied_texture_uploads_again_after_the_title_rewrites_it
Marvisak#756 079e387 GPU: indirect DispatchMeshX runs through indirect execution instead of being dropped. Ported from upstream PR JMAN730#24 (artor410)
Marvisak#771 2fae4db GPU: ClearUnorderedAccessViewUint/Float are recorded for resource-backed textures instead of hitting the missing-method stub. Ported from fuzeofficlal's commit d359499, which was tested on an RTX 5090 and WARP. Tests: uav_clears_fill_their_slots, uav_clears_tolerate_null_values

Checked but not changed:

12. Shader, HLE and loader fixes from forks, and the Pilot tool

Issue Commit Change
Marvisak#745, Marvisak#726 d9198ed Shaders: v_med3_f32 tests NaN on its operands' bits instead of with a float compare, which NVIDIA folds away. Ported from raphael-riesner (Kebap11). Test: med3_f32_tests_nan_on_bits_not_a_float_compare
Marvisak#765 7c60b93 HLE: a null or empty OEM registry subkey opens the key itself. Ported from Peppacodes
Marvisak#764 98f0fcf HLE: GetProcAddress sets ERROR_PROC_NOT_FOUND (127) on a miss. Ported from Peppacodes. Test: a_missing_export_of_our_modules_sets_the_last_error
Marvisak#762 a513e77 Loader: a title DLL is found whatever its name's case. Ported from Peppacodes. Test in tests/title_dlls.rs
Marvisak#742 4012fe9 Loader: the unwind test touches one stack page before RtlCaptureStackBackTrace, which returned 0 frames on Windows 10 when it crossed the guard page. Ported from DrTardis1963
Marvisak#727 162b70b HLE: a display deferral succeeds where PowerSetRequest answers ERROR_NOT_SUPPORTED (headless, Remote Desktop); other refusals keep their error. Idea from geiyiliyabumo, re-done for this tree. Test: a_system_without_display_power_keeps_the_deferral
Marvisak#734 565af2d Shaders: lower v_mad_u64_u32 / v_mad_i64_i32. Ported from 9hvn9yt2vk-netizen. Test: mad_64_of_32_bit_operands_translates (fails before, passes after)
Marvisak#734 6cd5aab Shaders: lower v_ldexp_f32, v_frexp_mant_f32, v_frexp_exp_i32_f32. Ported from 9hvn9yt2vk-netizen. Test: ldexp_and_frexp_translate
Marvisak#734 11f3dd8 Shaders/GPU: run the console's 64-lane waves on hosts without them (NVIDIA, Intel) through group-shared memory where every lane gets there; anything else is refused with a reason. The device's lane counts are read at creation and keyed into the shader cache. Ported from 9hvn9yt2vk-netizen and adapted (two extra read_lane callers here now pass on its refusal). On an RTX 4080 (Xeltax) the 114 compute pipelines the host refused on main became 0. Tests: wave64_fixtures::*

scripts/pilot/ (92fde68) adds VIctory Pilot, a Windows helper. It builds, runs and tests VIctory, catches crashes and hangs, and files them as [Pilot] issues on this fork with a local dashboard at http://localhost:8765/. It is review-only here because the sandbox has no PowerShell.

Checked but not changed:

Testing

On Linux with the toolchain pinned in rust-toolchain.toml:

  • cargo test -p victory-shader -p victory-formats: 144 shader lib tests (4 ignored) and 3 integration tests pass; formats has 36 passed and 6 ignored.
  • cargo clippy -p victory-shader -p victory-formats -p victory-game --all-targets -- -D warnings reports nothing.
  • rustfmt --check passes on every changed file.

victory-gpu, victory-loader and victory-hle only build on Windows. So the JMAN730#610 test, the GPU ports (Marvisak#681, Marvisak#680, Marvisak#654, Marvisak#671, JMAN730#205, JMAN730#336, JMAN730#418) and the section 11 GPU fixes and the loader test (Marvisak#666) were not compiled here. They were reviewed against this fork's helpers instead. The JMAN730#418 conversion was also tested on its own, copied into a standalone crate. The valu_tests.rs part of Marvisak#706 is Windows-only too.

The pure logic of the section 11 fixes was copied into standalone crates and tested there: heap sizing, format substitution, the copy-family check, and the rewrite check. victory-gpu itself cannot be compiled without a Windows target, so Windows testers should confirm. For Marvisak#735, check that "host view heap capped" is logged and there is no device removal. For Marvisak#747, check that "no dynamic slots" no longer appears.

Update (2026-11-24, VIctory Try 1.2)

2026-11-24 (later): more upstream PR ports, VIctory Try 1.3

2026-11-24 (black screen)

2026-11-24 (gameplay: NVIDIA shader translation, world view, copies)

Ports of the work that got this title into the world on NVIDIA (upstream Marvisak#1132 / Marvisak#778 stacks):

2026-11-24 (world pipelines, Try 2.0-2.2)

  • 82fe2564 program part found when a container has no DXIL part (falls back to a part holding the XDAT table); refusals list the container's parts.
  • 4f2e4b44 33 ms pipeline wait per frame once 64+ requested pipelines wait; E_OUTOFMEMORY pipelines retried (100/400/1600 ms, one at a time).
  • 81454da2 VICTORY_PRESENT_1440P=auto skips presented planes and menu frames (only frames with 800+ draws), logs the frames' color targets.
  • 6a11fb8f Fix NVIDIA Ada Lovelace (RTX 4060) D3D12 compatibility, 2s TDR submissions, and 16 GB host OOM Marvisak/VIctory#1076 0d7b1d33 buffer stride from Built descriptor bits (legayclightning22).
  • 2796175 heavy pipelines no longer hold up the world's draws: Try 2.1 log showed 275 compute programs of 60-78 KB, ~18 s of driver compile each, holding every worker while ~1,600 draw pipelines waited (4-9 made a minute, draws dropped, black picture). Containers past 32 KB go to a heavy lane (1-3 workers); workers are 2/3 of the logical CPUs (2-10) and run at normal priority while a long backlog waits; pipelines slower than 2 s are logged.
  • 8e22f5f title memory copies of 8 MB+ split over up to 4 threads (160-360 MB copied a frame in the world).
  • 7e5228e / 5f48ae6 VICTORY_DUMP_FAILED=<dir> saves untranslatable and slow shader containers for offline study; Try sets it to %LOCALAPPDATA%\VIctoryTry\failed-shaders.
  • VIctory Try 2.0 (mirrors + bundle backup), 2.1 (loop limit 64, Series S auto world view), 2.2.

2026-11-24 (new base: fxceless/victory-gta6, Try 3.0-3.1)

MfDev0 and others added 4 commits November 24, 2026 07:26
…another join reads

`Lower::get` marks the phi a value is read from, and `fill_phis` used that
mark to decide whether a missing incoming value fails the program or is
silently replaced by zero (or false). A join that only feeds another join
is never read through `get`, so it counted as unread: a timestamp read
(`s_memtime`, which has no DXIL form) that reaches a branch through two
joins translated, while the same read with no join in between was refused
with `a scalar memory read as data`.

Follow the incoming values of a read phi, so a phi an actually read phi
takes a value from is treated as read too. The refusal then reaches the
reader, as it does without a join, and a value that is genuinely dead (the
group id is read instead) still translates.

Found and reported by Dathinel in Marvisak#604; the test is theirs.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The switch was read as "is the variable set", so `VICTORY_D3D12_WARP=0`
still created the host device on the software adapter: a `0` left in the
shell, or set for one command in a batch file, had to be removed instead
of turned off. `0` now counts as unset; `1`, an empty value and every
other value still select WARP.

Reported in Marvisak#610.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
`ir::build` hands the emitter one value per register dword and a block
graph, and the emitter relies on two things it never checked: that a
value is written once, and that the block a read is in is dominated by
the block that writes it (a phi's argument by its predecessor). A program
that broke either would lower a read to a value that does not exist yet,
or to the wrong one.

The test builds programs at random from every instruction word the
decoder accepts (every opcode of every encoding), and checks those
invariants against a dominator set computed by the naive iterative
algorithm, so the check does not share code with what it checks.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…lc makes it globally coherent

A descriptor from the SM 6.6 resource heap was annotated SRV or UAV per
instruction: the load of a view the program also stores to got an SRV
handle ((0xB, 0)) and the store a UAV one ((0x100B, 0)), for one and
the same descriptor; a scalar read of it became a constant buffer.

Every access now takes IsUAV from all uses of the descriptor (twin
loads of the same dwords included) when the root signature says
nothing: a store or atomic through any of them makes it a UAV. A known
kind still wins. Scalar reads of a UAV are raw UAV loads.

A UAV with a plain glc access (skip the per-CU cache, how GFX10 code
sees another group's writes) also sets IsGloballyCoherent (0x4000) on
all of its handles. glc on an atomic only returns the old value and
does not count; glc on a view nothing writes leaves it an SRV.

Upstream issues Marvisak#724 and Marvisak#725.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@MfDev0 MfDev0 changed the title Two diagnostics and shader-emitter fixes from the open issue tracker Shaders/GPU: fixes for #604, #610, #724/#725 and an SSA invariant test Nov 24, 2026
…X face

For a cube array the console takes the face operand of image_sample* and
image_gather4* (dim CUBE) as 8 × slice + face; GFX10 MIMG has no array
bit. The lowering always declared a TextureCube and matched the operand
against faces 0-5 only, so any slice above 0 sampled slice 0's +X face,
silently.

A cube descriptor is now a TextureCubeArray (kind 9) when some sample or
gather through it builds its face operand that way: a multiply-add by
8.0 (v_fma/v_fmac/v_fmamk/v_fmaak/v_mad/v_mac/v_madmk/v_madak, as Mesa's
prepare_cube_coords emits it), an add of a product by 8.0, or a constant
of 8 or more (a constant slice folded in). Every access through the
descriptor takes that kind, as the view is one. The slice,
floor(face / 8), becomes the fourth coordinate and face - 8 × slice the
face (both exact in f32). A size query of a cube array reports its
layers in faces (6 × cubes), as the hardware does (Mesa divides them by
6 for txs). A bare face id stays a cube, as before.

Upstream issue Marvisak#720.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@MfDev0 MfDev0 changed the title Shaders/GPU: fixes for #604, #610, #724/#725 and an SSA invariant test Shaders/GPU: fixes for #604, #610, #720, #724/#725 and an SSA invariant test Nov 24, 2026
MfDev0 and others added 21 commits November 24, 2026 09:42
The Marvisak#604 fix (f1fa9d5) marked every phi a read phi takes a value from
as read, so any missing incoming value of such a join refused the
program. Upstream merged the same change as Marvisak#612 and measured it
(Marvisak#736): 323 programs that translated and validated before stopped,
mostly on descriptor dwords, lane masks and interpolation halves that
only joins carry after their last use, where the zero never reaches a
reader.

Phis read only through other joins are now kept apart from the ones an
instruction reads. A missing incoming value refuses such a phi only when
zero would silently misrepresent it: an s_memtime or s_memrealtime
timestamp, the Marvisak#604 case. Every other value becomes zero on that edge,
as before the fix.

The test keeps the timestamp case and adds an s_getpc_b64 carried
through the same two joins: refused when read directly, translated
when only joins carry it.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Upstream issue Marvisak#761. The Portuguese translation had the
same line.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
rustdoc warns that the module docs link to the private const MICRO
(rustdoc::private_intra_doc_links). Plain code formatting keeps the
reference without the broken link.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 0f0c872)
Its only callers (stub_pipeline_is_created, constant_color_validates)
are #[cfg(windows)], so on macOS/Linux the helper is dead code and
cargo check --all-targets warns 'function constant_color is never used'.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit ab3eb92)
Queue the list-owned D3D12 staging upload as a host fill so Wine does not skip it based on the title-memory VirtualQuery check.

(cherry picked from commit af22e5d)
describe looked only for a host texture, so every UAV over a buffer printed 'uav None' in device-removed reports and drop traces, though the view is made. It now prints the buffer's title range, as a buffer shader view does.

(cherry picked from commit d74558c)
Pixel programs that write SV_DepthLessEqual or SV_DepthGreaterEqual
failed validation: "Interpolation mode for PS input position must be
linear_noperspective_centroid or linear_noperspective_sample when
outputting oDepthGE or oDepthLE". The position is now declared
linear_noperspective_centroid in those programs, as DXC declares it;
without multisampling the value is the same.

translate --validate on shaders.rpf: vertex/pixel 12172 -> 12186
validated; the error is gone from the list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c249f02)
v_cmp_lg_{f32,f16} ("less or greater") is ordered and not equal: false
when either operand is a NaN, on RDNA2 hardware as in the ISA. It was
lowered to `fcmp one`, which says the same, but the AMD D3D12 driver runs
`fcmp one` as unordered and returns true for a NaN. NVIDIA and WARP get it
right. It now lowers as `olt | ogt`, which all three run alike.

New GPU test v_cmp_lg_is_false_for_nan covers both widths: NaN on either
side, both NaN, a signalling NaN, +0 against -0, inf against inf and
against -inf, and junk in the unread high halves for f16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

(cherry picked from commit 51f1627, upstream Marvisak#706)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
constant_color became Windows-only (upstream Marvisak#685), which left its two
imports unused on Linux; the DXIL of the descriptor-data test is only
read by the validator and the host, so its binding is unused there too.
Gate the imports and allow the binding off Windows, so
`cargo clippy --all-targets -- -D warnings` (the CI gate) passes for
victory-shader on Linux. Also drops a redundant rebinding in the Marvisak#604
test.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
(cherry picked from commit eb30a0d, upstream Marvisak#418; the
subnormal path checked against exact ties-to-even rounding for every f32
below 2^-14, both signs)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Compute programs read SGPRs the hardware does not initialize when two
branches make the paths look like they allow a read before a write, even
though the branch that skips the write does not reach the read. That stops
translation with 'a hardware SGPR input is not supported' and drops the
program's dispatches.

ComputeIo::initialized_sgprs() counts the user SGPRs, the enabled system
ones and the scratch wave offset. A read of a general SGPR (0..=105) at or
above that count holds whatever the previous wave left, so no program can
depend on its value: read it as zero, as unset VGPRs already are. Reserved
registers (VCC, trap temporaries, M0, EXEC) keep their current handling.

(cherry picked from commit f4438b3, upstream Marvisak#432 by
Proudnoob4)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
A texture the title fills through memory has its contents in the
staging copy until an upload records them; a copy out of it before
any draw read it copied the stale host texture.

(cherry picked from commits 0064c08 and 4f53d6f, upstream
Marvisak#671; adapted to this tree's `&list` handle)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
(cherry picked from commit 764fa19, upstream Marvisak#666;
this tree's VICTORY_HLE_PROBE override for Proton is kept)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
image_sample_cl and image_sample_b_cl lower like image_sample(_b):
outside pixel shaders, as explicit gradients from each quad of lanes.
They were missing from implicit_derivatives, so a compute program using
only them did not get the console's lane order, and the gradients came
from whichever host lanes shared a quad (a debug assertion in tests).

Also moves reads_mask_as_data's doc comment back onto it.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
DXIL takes immediate texel offsets in -8..=7; the console's are 6-bit
fields a byte apart in the first address VGPR and may be computed. A
constant word in range becomes the immediates; anything else is refused.
Outside pixel shaders the sample takes its level from each quad, so it
needs the console's lanes like image_sample.

(cherry picked from commit 260611a, upstream Marvisak#634;
adapted: the offsets also reach this tree's quad-gradient path, plus a
regression test)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
When the host cannot make an unordered-access view (no host texture, a
format the host does not allow, a placed texture not mirrored), null_for()
wrote a 2D null UAV whatever the title asked for. A shader that writes a
3D texture through it then has a dimension mismatch, which GPU-based
validation reports for the world's wind field update. Shader views already
get a null view of the title's dimension (null_like); unordered views did
not.

Null texture UAVs now keep the title's dimension: 1D, 1D and 2D arrays,
3D (WSize -1). Multisampled and unnamed dimensions stay 2D.

(cherry picked from commit cbb50b8, upstream Marvisak#205;
the title's shader name is left out of the comment and message per the
asset policy)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Command lists take per-draw table slots from a view heap's dynamic range;
2^16 of them ran out seconds into the world (every world run on an RX 9070
XT, each a device removal shortly after; upstream Marvisak#59). View heaps now get
2^18 dynamic slots where the host takes them on top of every title slot,
else 2^16 as before (a capped heap, NVIDIA), then the portable cap.

(cherry picked from commit e8d3b64, upstream Marvisak#336;
heap sizing only: this tree already falls back to the title's slots when a
table does not fit, instead of dropping the draw)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The test from upstream Marvisak#611 (commit 9a8908c); the rest of
that change is already here in a newer form (show_config prints data_dir
with its origin).

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@MfDev0 MfDev0 changed the title Shaders/GPU: fixes for #604, #610, #720, #724/#725 and an SSA invariant test Shaders/GPU: fixes for #604, #610, #720, #724/#725, #736, plus upstream fixes ported in Nov 24, 2026
Ports upstream Marvisak#566 and the follow-up ffe310e. The
console compiler handles a descriptor that differs per lane with a
"waterfall" loop: read the first active lane's descriptor
(v_readfirstlane), run the access for the lanes that match, drop them,
and repeat. Before this, the resource tracker refused every such program
("descriptor-as-data" was the largest refusal class upstream measured in
Marvisak#736).

- resource.rs: descriptors chosen by s_cselect / s_cmov are traced per
  SCC outcome. Per-lane loads, per-lane choices and if/else joins are
  traced per lane. A waterfall loop is accepted only when EXEC
  selection is proven (the loop really narrows to the matching lanes),
  and it is lowered as one non-uniform access.
- lower.rs: a waterfall's first-lane read becomes the lane's own dword,
  and the heap index comes from each lane's descriptor.
- track() takes the structured program (Option<&Structured>), so
  structurisation now runs before resource tracking.
- New tests: 26 resource/lowering tests plus the GPU-run
  waterfall_tests.rs (Windows).

Merged into this fork by three-way file merge: the tracker keeps its
memo of address sums (now in a RefCell, since the tracker is &self
upstream), structure keeps select_masks next to paired_masks, and the
threading retry path in emit passes the structured program too.

(upstream commits a3d3bc9 ffa6635 077ec8b 6285e19 6638098 b1c8306
6c63dea 74a9d33 ffe310e)

Co-authored-by: fuzeofficial <bochunran@gmail.com>
Co-authored-by: Marvis <marvis@noreply.invalid>

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
MfDev0 and others added 8 commits November 24, 2026 14:18
Like the argument clamp: vkd3d-shader's HLSL compiler (D3DCompile under
Wine) has no RWByteAddressBuffer methods and embeds no root signature,
so the rectangle expander never built under Proton and indirect
rectangle-list draws were dropped. Both passes now read structured
buffers of words (byte offsets become word indices; the 64-bit and wider
loads and stores split into words) and take root signatures built in
code, the same eight constants and root views as before.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The console ignores blending on integer render targets and the title
leaves it on (the world has a mesh pipeline blending into an R8_UINT
target). D3D12 does not allow it: vkd3d-proton refuses such a pipeline
with E_INVALIDARG and its draws are lost. The host pipeline now turns
blending off on integer targets; with one description for all targets,
each target gets its own copy so the others keep theirs.

Hand-ported from pablogonz12 ceaf806.

(cherry picked from commit ceaf806)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
v_*_co_ci_u32 refused when its carry-in mask was not one structure
followed (a plain SGPR number), and v_cndmask_b32 refused inline 0 and -1
masks. A carry-in now fails as an untracked select does, so compute
retries it with console lanes and the lane tests its own bit of the
register (pair in wave64); inline 0 and -1 masks are constants.

Ported from undeadhuman37 fda0c77 (from upstream PR Marvisak#585, the mask
part); our selects had the console-lane fallback already. New test runs
on Linux: fails before, passes after.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
A descriptor whose dwords the code reads as numbers (a size) but never
uses was taken only when eight dwords with no range or an SRV range: a
2D texture. Now the range the entry falls in says what it is: a storage
image's or a buffer's size (raw, or structured by the range's stride)
translates too. Four dwords no range names stay refused.

The fork measured "a descriptor read only as data" 395 -> 18 over its
corpus with this change (compute emitted 1441 -> 1743). New Linux test:
fails before, passes after.

Ported from undeadhuman37 9d8df90.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The console compiler spills scalars, lane-mask pairs among them, with
v_writelane_b32 into constant lanes of a VGPR and restores them with
v_readlane_b32 of the same lane. The restored pair was an opaque mask, so
the selects, EXEC writes and joins that used it refused ("a select on an
untracked mask", "an opaque lane mask", "a lane-mask join of an
untracked mask"). structure now follows a constant-lane readlane back
through a plain chain of writelanes to the scalar written to that lane,
and gives the restored pair that scalar pair's mask. A chain with a phi
or another write of the VGPR stays opaque (shortcut noted in code).

The fork measured vertex/pixel programs emitted 12250 -> 12269 and
compute 1443 -> 1452. The test runs on Linux: fails before, passes after.

(cherry picked from commit fec0486)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…d vertex programs

A register can hold a compare result's high dword on one path and a
loaded number on another; the compiler only reads it where the number is
live. The join's mask side was "a lane mask read as data", which refused
the program. A pixel or vertex program now takes the mask's ballot as
that incoming value (counts and zero tests mean the same on any wave
size). shortcut: the ballot is the host wave's, so a join read some other
way would differ from the console.

The fork measured "a lane mask read as data" 250 -> 212. Hand-ported
(the ballot is only taken where the incoming value is missing); the
test runs on Linux and fails before.

(cherry picked from commit 3e662eb)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The console packs a primitive's three vertex indices in 10-bit fields
(up to 1023), while the host mesh shader declares max_vertices outputs.
EmitIndices with an index at or past that count is undefined; on an
RTX 5080 a shadow mesh program hung the GPU on such a draw. A primitive
with any index out of range is now culled like bit 31 does (all indices
0, no area).

Likewise a console group can have more lanes than the mesh declares
vertices or primitives: a lane past the declared count no longer writes
a vertex, primitive output or primitive (undefined on the host).

From kaoxyd 4f5ffe3 (jlefebure's fork) and Mic0Lee 48fea7b,
2389344, ff65879, hand-ported.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
A loop that only rereads one address until another workgroup, queue or
the command processor changes it (decoupled look-back, persistent-thread
queues, locks) waits microseconds on the console. On the host the write
may never come: the writer's view can be another host resource, null or
not yet mirrored, and the host compiler may hoist a load out of a loop
that writes nothing (bufferLoad is readonly). The loop then runs to the
2^20 limit in every lane: about a second per wave of uncached reads,
the order of the 650-930 ms world submissions spend on an RX 7600.

Such loops are found in the IR (emit/spin.rs): no stores, exports, LDS
writes, barriers or messages; every memory read and atomic at an
address the loop does not change; and nothing loop-carried made by
arithmetic, only lane masks, compares and what was read. They stop at
VICTORY_SHADER_SPIN_LIMIT (default 4096, never above the loop limit);
the shader cache keys on it. VICTORY_SHADER_LOOP_LIMIT now works in
release builds too (PastiiJay e5b117a).

Ported from PastiiJay/klbf-lab 1fcaf13 and e5b117a.

(cherry picked from commit 1fcaf13)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@MfDev0
MfDev0 force-pushed the arena/59fabb00-victory branch from 7a0849e to b7e8d83 Compare November 24, 2026 14:31
IgorRend and others added 19 commits November 24, 2026 14:33
Check that the mandatory shader stage produced DXIL before calling
CreateComputePipelineState / CreateGraphicsPipelineState. On hardware a
null bytecode can be accepted, the GPU then runs empty code and removes
the device (0x887A0006); on WARP it surfaces as E_INVALIDARG. Refusing
early avoids the spurious creation calls and the device removal.

From IgorRend 17a35d9, the pipeline part only: its raw-buffer change
took a range with no declared stride for a raw buffer and dropped the
index, which would read structured buffers of unknown stride at the
wrong addresses instead of refusing them.

(cherry picked from commit 17a35d9)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
A mesh record is now clamped to 4,096 groups (captured direct mesh work
peaks at 260) and mesh groups have their own per-list budget of 2^15:
allowing D3D12's 65,535 let one corrupt indirect record hold an RX 6700
XT until Windows reset it. The budget buffer's two words are zeroed
together.

Each title list now goes to the queue in its own ExecuteCommandLists:
the OS resets a device whose submission runs for about 2 s, and world
submissions of every list took 0.5 to 1.8 s, while each list is well
under that. The lists are still waited for once, after the last (each on
its own with diagnostics timing), so no wait bubble is added per list.

From arthercz bba82d4, hand-ported onto the structured-buffer clamp;
its per-list waits are left out.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
(cherry picked from commit adeb9ff)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
… queries

(cherry picked from commit 7d0302b)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…ools::meet

(cherry picked from commit 80a235e)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…lting

emulate_amd_only copies only the bytes left in the faulting page and
gated clwb_len on n >= 15 because clwb_len took a fixed [u8; 15]. A
4- to 10-byte clwb starting in the last 14 bytes of a page (or falling
back from a clwb_loop that straddles the page end) was therefore
skipped, leaving pre-Ice Lake Intel CPUs with an unhandled
STATUS_ILLEGAL_INSTRUCTION.

Change clwb_len to take &[u8], bounds-checking each byte read and
returning Some(len) only when len <= code.len(), and drop the n >= 15
guard in emulate_amd_only.

Fixes Marvisak#924.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 60d2cf9)
`resolve` canonicalizes the longest existing prefix and re-appends the rest, but it walks up with
`Path::file_name()`, which is None for a trailing `..`. A path such as `<tmp>/a/../b` (nothing exists yet) hit the
`_` arm and returned PolicyError::Io, so a cache_dir or data_dir with a `..` in a directory that does not exist yet
was rejected, and `normalize`'s `..` handling for the missing tail was never reached.

A trailing `..` is now kept in `rest` so `normalize` resolves it lexically.

Test: resolves_dot_dot_in_a_path_that_does_not_exist_yet (fails before, passes after). cargo test -p victory-core,
cargo fmt --check and cargo clippy --tests are clean.

(cherry picked from commit 52f0a09)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 033598b)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
… RDNA2 does

Previously `half_src` applied VOP3 `op_sel` bits to every 16-bit operation, causing 16-bit compares (`v_cmp_*` and `v_cmpx_*` on f16, u16, and i16) to read the high half when `op_sel` was set. As measured on gfx1036 (RDNA2) across 146 cases in Marvisak#833 (VGPR, SGPR, literal, inline-constant sources, wave32/wave64, and `v_cmpx_*_e64`), RDNA2 hardware ignores VOP3 `op_sel` on 16-bit compares and always compares the low halves, while non-compare 16-bit ops such as `v_add_nc_u16` still honour `op_sel`.

Ignore VOP3 `op_sel` in `half_src` (which `half_fsrc` calls as well) for `v_cmp*` instructions except `v_cmp_class*` (not measured), while keeping SDWA word selects intact, and add an end-to-end VALU test covering f16/u16/i16 compares, `v_cmpx_lt_f16`, and `v_add_nc_u16` as a control.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
(cherry picked from commit a8aa1d1)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e477c4b)
)

A descriptor whose only use is an s_buffer_load is a raw buffer to the
host; descriptor_data fell through to "a scalar memory read as data".
Upstream reports 771 -> 0 such failures and +231 programs translated.

From upstream PR Marvisak#953 (c42cbb0), hand-ported.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
DXIL waveReadLaneFirst reads the first active non-helper lane, while the
console's WQM keeps helper lanes in EXEC. In a pixel waterfall loop a
helper lane never matches the value it reads and spins to the loop
limit. In pixel shaders, select the lane's own value when isHelperLane
(SM 6.6, opcode 221) holds.

From upstream PR Marvisak#946 (c159604), hand-ported.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…#757)

A command signature with root-constant arguments before its draw or
dispatch was dropped. Map each title constant argument onto the host
root parameter carrying the user data of the stage that reads it (or an
unused range when none does), build a host signature bound to the
pipeline's root signature (cached on the pipeline), and clamp the
draw/dispatch argument at its offset in each record. The planner is
pure and tested on every platform.

Not mapped yet: root view arguments, a constant two stages read, a
spilled (root CBV) user-data stage, rectangle lists.

From upstream PR Marvisak#956 (71967c1), hand-ported.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@MfDev0
MfDev0 merged commit 41ca03a into main Nov 24, 2026
MfDev0 pushed a commit that referenced this pull request Nov 24, 2026
Co-authored-by: ZazaJr24 <218105339+ZazaJr24@users.noreply.github.com>
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.

Diagnostics: VICTORY_D3D12_WARP=0 still selects the software adapter Shader emitter accepts an unsupported timestamp read after two SSA joins