Skip to content

Shaders: wave64 compute programs run in 32-lane halves on hosts of 32-lane waves - #2633

Open
chippy01 wants to merge 4 commits into
Marvisak:mainfrom
chippy01:shaders/wave64-in-32-lane-halves
Open

chippy01 wants to merge 4 commits into
Marvisak:mainfrom
chippy01:shaders/wave64-in-32-lane-halves

Conversation

@chippy01

@chippy01 chippy01 commented Nov 25, 2026 •

Copy link
Copy Markdown

The problem

A console wave64 compute program that needs the console's lanes (cross-lane reads, masks read as numbers, LDS one wave shares) declares WaveSize(64). NVIDIA and Intel run waves of at most 32 lanes (WaveLaneCountMax 32) and refuse it. On an RTX 3070 Ti the debug layer says:

Shader wants wave lane count of 64 but maximum wave lane count for device is 32 (id 622)

and the pipeline is refused with E_INVALIDARG. A Series S run to the loading screen refused 100 compute pipelines; 95 of them were for this reason.

The change

On such a host, a wave64 program that needs the console's lanes is translated for waves of 32 ("halves", emit::lower::halves, set by emit::Options::host_wave32):

  • The thread relabelling gives each host wave a 32-aligned run of thread ids, so host wave 2w + h holds lanes 32h..32h + 31 of console wave w.
  • Exact within a half: DPP rows, ds_swizzle, and ds_bpermute_b32, which the console's wave64 permutes within each half on its own (RDNA2 ISA; measured on RDNA2 in Shaders: scope wave64 ds_bpermute_b32 to 32-lane halves #573). A lane's bit of a mask held as a number, v_writelane_b32, v_mbcnt and the row a DPP row mask names take the console lane, so lane 32 tests bit 0 of the high dword and is in row 2.
  • Refused where it is lowered: reads across the halves, i.e. ballots (masks read as data), v_readlane_b32 of a lane that may be in the other half, and whole-wave reductions and prefix sums. Each refusal gives a reason that names the host. A crossing value the program never uses costs nothing (the lowering's retry with the value missing), so a program is refused only when it really needs the read.
  • LDS: a group of 33 to 64 threads with LDS (one console wave, ordered without barriers by the console compiler) is refused. Larger groups keep the console's barriers, and groups of 32 or fewer are one host wave.
  • Group shapes: the relabelling needs each host wave to hold a run of consecutive thread ids. Hosts fill the waves of a group of several rows with 16 x 2 tiles when its rows are 32 threads wide or more, so such groups, and rows that are not a power of two wide, are refused. That was measured here on the RTX 3070 Ti and the Radeon iGPU (32x2, 32x8, 64x4, 32x32 and 32x2x2 lose half their ids), and in Shaders: compute threads that read other lanes keep unique ids in 2-D groups (NVIDIA) #2126 on an RTX 5070 Ti. None of the title's translating programs is in such a group.
  • First-lane reads: v_readfirstlane_b32 reads the host wave's first lane, which in the upper half is console lane 32 or later. It is kept for a value proven the same in every lane of the console wave (halves::lane_uniform: what the console compiler reads first lanes for) and in groups of 32 threads or fewer, which one host wave holds whole. Any other first-lane read is refused with its reason.

victory-gpu asks the device once (D3D12_OPTIONS1) and translates for it. The shader cache keys on it, so entries made for 64-lane hosts are never read on a 32-lane one, or the other way round. victory translate --wave32 translates for such a host offline; with --pipelines it follows the GPU that makes them.

New code lives in emit/lower/halves.rs (lower.rs stays at 494 KB, under the policy's 512 KiB cap).

Evidence

victory translate --list --pipelines over shaders.rpf, the executable, XboxBvhBuilder.dll and amd_fidelityfx_upscaler_xbox.dll on an RTX 3070 Ti (driver 32.0.16.2124), Windows 11:

main 67e8ae1 this PR
compute programs emitted 2,733 2,369
compute pipelines made 2,328 2,369
refused by the driver 405 0
vertex/pixel, mesh pipelines 14,254 / 8,765 14,254 / 8,765
  • No pipeline made on main is lost (all 25,347 kept).
  • With main 842b0cb merged (f60027f) and the third commit: 2,369 compute programs emitted and 2,369 pipelines made, none refused by the driver; vertex/pixel 14,258 and mesh 8,765 (main's own changes add four vertex/pixel programs).
  • The 44 new ones include the depth pyramids (depth_pyramid:*, occlusion), the sky and atmosphere gathers (scattering_transmittance_system:*, the sky radiance cache), shader_binning_utils, the mipmap generators and fire/particle lighting.
  • Those refused in halves say why: 192 LDS in a one-wave group, 91 ballots, 48 lane reads across halves, 20 reductions, 17 first-lane reads of values that may differ between the halves, 2 group shapes a host wave may tile. Those need an exchange between the two host waves, which is a change of its own.
  • The second commit (first-lane reads, DPP row masks) takes 3 programs out (2,372 → 2,369 emitted): they read the first lane of a value that may differ between the halves. Each is a program in halves, which main declares WaveSize(64) and this driver refuses, so no pipeline made on main is lost.

In the title (Series S mode, diagnostics build, to the loading screen, 2.5 min): no pipeline refused (main: 100). The 113 programs that do not translate give their reason (51 LDS, most of the rest ballots).

Tests

emit::halves_tests (new):

  • wave64_programs_in_halves_match_the_console_on_every_gpu: one wave64 program (DPP, ds_swizzle, ds_bpermute, v_mbcnt, v_writelane to lane 40, a constant mask's high dword) runs on every hardware adapter: in halves everywhere, and as one wave64 where the adapter has 64-lane waves. All 64 lanes give the console's results on:
    • RTX 3070 Ti, in halves (its wave64 form is refused there, as expected);
    • the Radeon iGPU of a Ryzen 9 7900X (RDNA2), in halves and as one wave64.
  • reads_across_32_lane_halves_are_refused_with_their_reason, lds_of_a_one_wave64_group_is_refused_in_halves, a_wave64_program_reading_lanes_declares_32_lane_waves_in_halves: offline.
  • dpp_row_masks_name_the_console_rows_on_every_gpu: row_mask:0xc (rows 2 and 3, lanes 32-63). Before the fix in this PR's second commit, lanes 32-63 kept their old value in halves on both GPUs (32 of 64 wrong).
  • first_lanes_kept_in_halves_match_the_console_on_every_gpu: the thread id's first lane in a group of 32, and l >> 6 in a group of 128 (one value per console wave). Before that fix, the thread id's first lane in a group of 64 gave 32 in lanes 32-63 on both GPUs (the console gives 0); it is refused now.
  • groups_a_host_wave_may_tile_are_refused_in_halves (offline) and every_thread_keeps_its_own_id_in_halves_on_every_gpu: 32x2, 64x4, 32x2x2 and 6x6 groups are refused; 8x8, 16x2, 4x4x4 and 64x1 store every thread's id on both GPUs, in halves and (Radeon) as one wave64.
  • the_test_programs_are_what_their_comments_say: the hand-encoded words checked against the disassembler.
  • shader_cache::tests::the_key_covers_translator_encoding_and_settings now covers the wave width.

emit::host::Host::each_hardware (test host) lists every hardware adapter, so a test can compare GPUs of different wave widths on one machine.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings and the same with --all-features: clean. cargo xtask policy: ok. cargo test -p victory-shader --lib -- --test-threads=1: 307 passed, 3 failed (on main 842b0cb merged); main 67e8ae1: 266 passed, the same 3 failed on this NVIDIA machine (stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware). memory_tests::heap_direct_texture_reads_mark_their_heap_index crashes the test process (access violation) on main here too, so it was skipped in both runs. victory-gpu: dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views fail on main and here alike (the 1,000,000-view heap cap, #1835).

Related pull requests

This overlaps #189, #192, #233, #1960 and #2176 (wave64 on 32-lane hosts) and #578 (refusing them). It differs in two ways: cross-half reads are refused at the site that makes them, with a reason, instead of by instruction name (programs whose crossing value is unused still translate), and halves are checked against the console's own wave64 on an RDNA2 adapter in the same test. The cache-key idea is #2176's (n-romanovich). It does not change ds_bpermute_b32 for 64-lane hosts, which is #573's.

Credits

Found on the way, not changed here

A wave64 mask built by two s_mov_b32 (low and high dword written apart) reads its low dword for all 64 lanes: Lower::pair_high looks for the high dword in the instruction that wrote the low one. The test shows it the same way on AMD's own wave64 and in halves, so it is not this change's.

AI-assisted (Co-authored by Claude Opus 5.5 Max) and measured on my own machine.

@Aniseto

Aniseto commented Nov 25, 2026 •

Copy link
Copy Markdown

Ran the new halves tests at a7e78c1 (clean PR head on main 13f91ca):

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB), driver 32.0.16.2124
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXIL validator from the Windows SDK default path (this filter does not print its version), debug build

Results

  • cargo test --locked -p victory-shader --lib emit::halves_tests -- --test-threads=1 --nocapture: 5 passed, 0 failed, 0 ignored, 273 filtered out (exit 0)
  • wave64_programs_in_halves_match_the_console_on_every_gpu printed: NVIDIA GeForce RTX 5070 Ti (halves): 0 lanes of 64 differ from the console, and NVIDIA GeForce RTX 5070 Ti (wave64): no pipeline for 64-lane waves; skipped, twice (both adapters in the host list).

What this adds
The author's hardware evidence in the thread is an Ampere RTX 3070 Ti plus an RDNA2 iGPU. This adds a Blackwell wave32 part: the GPU parity test ran here and all 64 lanes matched the console's result in the halves form, while the 64-lane form was refused by the adapter as expected. The other four halves tests also pass.

Not tested
The whole victory-shader library (the description lists three pre-existing failures on NVIDIA), victory-gpu, the retail shader-pack census, a title run, the console compiler, release profile, Intel GPUs and native-wave64 hardware.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

Update (25/11, after the head moved to 25db879): relative to the head I tested (a7e78c1), the new commit only changes README.md; no shader code changed. Re-ran the same command at 25db879:

cargo test --locked -p victory-shader --lib emit::halves_tests -- --test-threads=1 --nocapture
5 passed; 0 failed; 0 ignored; 273 filtered out      (exit 0)

Same GPU output: NVIDIA GeForce RTX 5070 Ti (halves): 0 lanes of 64 differ from the console, and the 64-lane form skipped because this adapter has no 64-lane waves.

@chippy01
chippy01 force-pushed the shaders/wave64-in-32-lane-halves branch from a7e78c1 to 25db879 Compare November 25, 2026 17:20
@kotekompotek

Copy link
Copy Markdown

Heads-up: the README hunk contains a committed merge conflict — <<<<<<< HEAD / ======= / >>>>>>> a7e78c1 markers are in the diff (GPU: world + Shaders table rows). The branch needs a rebase resolving that hunk (keep the new wave64-halves text), otherwise the table renders the raw markers.

The actual change — --wave32 translate flag conflicting with --cache, wave64 split halves on 32-lane hosts — looks right otherwise; CI green.

…-lane waves

What was wrong: a console wave64 compute program that needs the
console's lanes (cross-lane reads, masks as numbers, LDS one wave shares)
declares WaveSize(64). NVIDIA and Intel run waves of 32 lanes at most
(WaveLaneCountMax 32) and refuse it: on an RTX 3070 Ti (driver
32.0.16.2124) the debug layer gives "Shader wants wave lane count of 64
but maximum wave lane count for device is 32" (id 622), and every such
pipeline is refused with E_INVALIDARG. A Series S run to the loading
screen refused 100 compute pipelines, 95 of them for this.

What changed: on such a host, a wave64 program that needs the console's
lanes is translated for waves of 32 (`emit::Options::host_wave32`;
`emit::lower::halves`). The thread relabelling gives each host wave a
32-aligned run of thread ids, so host wave 2w + h is console wave w's
lanes 32h..32h + 31. What a lane reads within its half is exact: DPP
rows, ds_swizzle, and ds_bpermute_b32, which the console's wave64
permutes within each half on its own (RDNA2 ISA; measured in Marvisak#573). A
lane's bit of a mask held as a number, v_writelane_b32 and v_mbcnt take
the console lane. Reads across the halves have no host form and are
refused where they are lowered, with a reason that names the host:
ballots (masks read as data), v_readlane_b32 of a lane that may be in the
other half, whole-wave reductions and prefix sums; one a program never
uses costs nothing (the lowering's retry with the value missing). A group
of 33 to 64 threads with LDS, which the console compiler orders without
barriers as one wave, is refused too. v_readfirstlane_b32 reads the host
wave's first lane, as it already does in every program without console
lanes (marked as that shortcut).

victory-gpu asks the device once (OPTIONS1) and translates for it; the
shader cache keys on it, so entries made for 64-lane hosts are not read.
`victory translate --wave32` translates for such a host offline; with
--pipelines it follows the GPU that makes them.

Approach after DexNom's fork (DexNom/Victory 5f4c3df: the host's wave
width and the relabelling into halves) and Marvisak#2176 (n-romanovich: the
setting in the cache key); here the setting is a translation option, and
cross-half reads are refused at the sites that make them instead of by
instruction name, which keeps programs whose crossing value is unused.

Evidence, `translate --list --pipelines` over shaders.rpf, the
executable, XboxBvhBuilder.dll and the FidelityFX DLL, RTX 3070 Ti:

| | main 67e8ae1 | this |
|---|---|---|
| compute programs emitted | 2,733 | 2,372 |
| compute pipelines made | 2,328 | 2,372 |
| refused by the driver | 405 | 0 |

No program that made a pipeline on main fails to now (25,347 pipelines,
all kept). In the title (Series S mode, diagnostics build, to the
loading screen, 2.5 min): no pipeline refused, against 100 on main; the
113 programs that do not translate say why (51 LDS, the rest mostly
ballots). The 44 new ones include the depth pyramids (occlusion),
the sky and atmosphere gathers (scattering_transmittance_system),
shader binning and the mipmap generators. The 361 still refused now say
why: 192 LDS in a one-wave group, 107 ballots, 48 lane reads across
halves, 20 reductions (those need an exchange between the two host waves,
a change of its own).

Tests (halves_tests): one wave64 program (DPP, ds_swizzle, ds_bpermute,
v_mbcnt, v_writelane to lane 40, a constant mask's high dword) runs on
every hardware adapter, in halves and, where the adapter has 64-lane
waves, as one wave64: all 64 lanes give the console's results on the RTX
3070 Ti (halves) and the Radeon iGPU of a Ryzen 9 7900X (RDNA2: halves
and wave64). The refusals and the LDS rule each have an offline test;
the hand-encoded words are checked against the disassembler.

Found on the way, not changed here: a wave64 mask built by two
s_mov_b32 (low and high dword written apart) reads its low dword for all
64 lanes (`Lower::pair_high` looks for the high dword in the instruction
that wrote the low one); the same with and without this change, on AMD's
own wave64 too.

Co-Authored-By: Claude Opus 5.5
@chippy01
chippy01 force-pushed the shaders/wave64-in-32-lane-halves branch from 25db879 to 360f8aa Compare November 25, 2026 17:54
@chippy01

Copy link
Copy Markdown
Author

Heads-up: the README hunk contains a committed merge conflict — <<<<<<< HEAD / ======= / >>>>>>> a7e78c1 markers are in the diff (GPU: world + Shaders table rows). The branch needs a rebase resolving that hunk (keep the new wave64-halves text), otherwise the table renders the raw markers.

The actual change — --wave32 translate flag conflicting with --cache, wave64 split halves on 32-lane hosts — looks right otherwise; CI green.

My bad, I just fixed it

@sergiocr06

Copy link
Copy Markdown

Ran the halves tests on a machine that has both kinds of host, a 32-lane NVIDIA dGPU and an RDNA3 iGPU with native wave64, so wave64_programs_in_halves_match_the_console_on_every_gpu checks all three paths on one box. PR head 25db879 on main 13f91ca.

System: RTX 5060 Laptop GPU 8 GB (Blackwell, driver 610.47) + Radeon 780M (RDNA3 iGPU, driver 32.0.31018.1), Ryzen 7 260, 32 GB, Windows 11 build 26300, Rust 1.98.1, debug build, validator from Windows SDK 10.0.26100.

NVIDIA GeForce RTX 5060 Laptop GPU (halves): 0 lanes of 64 differ from the console
NVIDIA GeForce RTX 5060 Laptop GPU (wave64): no pipeline for 64-lane waves; skipped
AMD Radeon 780M Graphics (halves): 0 lanes of 64 differ from the console
AMD Radeon 780M Graphics (wave64): 0 lanes of 64 differ from the console

Full victory-shader --lib:

main 13f91ca this PR
RTX 5060 (--skip heap_direct_texture_reads_mark_their_heap_index, #2571) 266 passed, 3 failed 271 passed, same 3 failed
Radeon 780M 270 passed, 0 failed 275 passed, 0 failed

The 3 are the known NVIDIA failures (#1835): stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware. No regression on either GPU.

Note for hybrid-laptop testers: Host::new in the test host takes the first adapter with dedicated memory. On this laptop that is the 780M (it reports a 417 MB carve-out), so a plain cargo test runs the single-adapter hardware tests on the iGPU, not the NVIDIA card. I forced the dGPU with a per-exe GPU preference (HKCU\Software\Microsoft\DirectX\UserGpuPreferences, GpuPreference=2;) and confirmed with nvidia-smi that the test process was on it.

AI-assisted (Claude Code); the runs were done on my machine.

@justrealyme

Copy link
Copy Markdown

Tested this on an RTX 5070 Ti (driver 621.40, Windows 11). The halves tests pass here too. I found one wrong result, though: v_readfirstlane_b32 in halves reads the host wave's first lane, which is console lane 32 for the upper half. Dispatched in halves (with v_mbcnt so the program has console lanes), v_readfirstlane_b32 s12, v0 gives 32 in all 32 upper lanes; the console gives 0.

Fix with tests: chippy01#1 (onto this branch, rebased on 360f8aa). It keeps the first-lane read only for values proven alike across the console wave, ported from the analysis in fxceless/victory-fork, and refuses the rest with a reason. Offline over the title, 12 of 2,372 compute programs drop out with that reason; nothing else changes. On the GPU, alike values give 0 of 128 lanes wrong on the 5070 Ti and the Intel iGPU.

AI-assisted (Claude Code); no game data.

@KainanP

KainanP commented Nov 25, 2026

Copy link
Copy Markdown

On a machine that also has a 16-lane Intel iGPU (UHD 8086:a78b, WaveLaneCount 16..16), wave64_programs_in_halves_match_the_console_on_every_gpu fails with Intel(R) UHD Graphics (halves): no pipeline, because each_hardware() lists the iGPU and that driver refuses WaveSize(32) too. On that device the PR also keeps WaveSize(64), which is refused. On the RTX 4060 the halves form is exact (0 of 64 lanes differ). Details and table: #2220 (comment)

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.

@chippy01

chippy01 commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

If this PR gets merged, I'll follow up by working on a way to implement Selective Cross-Wave Communication or, alternatively, a Hybrid Wave64 (32 physical + 32 virtual lanes) approach. The goal would be to allow the compiler to correctly execute instructions that require communication between lanes 0–31 and lanes 32–63.
In my opinion, addressing the underlying problem at its root is a better approach than introducing workarounds to bypass its limitations.
If this PR doesn't get merged, I'll still try to pursue at least one of these approaches, applying it to whichever alternative PR gets merged.
If anyone has any ideas or suggestions, I'll be glad to listen.

@Mericas77

Copy link
Copy Markdown

Tested on NVIDIA: RTX 4070 (the only adapter), driver 621.01, Windows 11, rustc 1.98.1. Head 360f8aa against main 13f91ca. That's an Ada card, a generation after the 3070 Ti in the description.

  • halves_tests (--test-threads=1): 5/5 pass. wave64_programs_in_halves_match_the_console_on_every_gpu prints (halves): 0 lanes of 64 differ from the console and (wave64): no pipeline for 64-lane waves; skipped, which is the expected result on a 32-lane host.
  • victory-shader --lib (with --skip heap_direct_texture_reads_mark_their_heap_index, Shader tests: heap_direct_texture_reads_mark_their_heap_index kills the test process on a real GPU (RTX 5070, main 67e8ae1) #2571): 271 passed / 3 failed. That's main's 266 plus the 5 new tests, and the same 3 known NVIDIA failures (a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware).
  • victory-gpu: 193 passed / 2 failed, the same as main (the two 1,000,000-view heap-cap tests).

No regression on Ada. No game data; the title was not run.

AI-assisted.

@TaynanGT

Copy link
Copy Markdown

Independent run on another machine: Ryzen 9 9950X3D with an RTX 4090 (driver 32.0.16.2140) and the CPU's Radeon iGPU (RDNA2, driver 32.0.21045.29003), Windows 11 26H2.

victory translate --list --pipelines over the same four inputs as in the description, main 13f91ca against this PR 360f8aa, pipelines made on the RTX 4090:

main this PR
compute programs emitted 2,733 2,372
compute pipelines made 2,328 2,372
refused by the driver 405 0
vertex/pixel, mesh pipelines 14,254 / 8,765 14,254 / 8,765

Every pipeline made on main (25,347) is made here too, and 44 are new. The programs this PR refuses give their reason: 192 LDS in a one-wave group, 107 ballots, 48 lane reads across halves, 20 reductions.

halves_tests with --nocapture, which lists both adapters:

NVIDIA GeForce RTX 4090 (halves): 0 lanes of 64 differ from the console
NVIDIA GeForce RTX 4090 (wave64): no pipeline for 64-lane waves; skipped
AMD Radeon(TM) Graphics (halves): 0 lanes of 64 differ from the console
AMD Radeon(TM) Graphics (wave64): 0 lanes of 64 differ from the console

cargo test --release -p victory-shader --lib -- --test-threads=1, skipping memory_tests::heap_direct_texture_reads_mark_their_heap_index as in the description: main 266 passed and 3 failed, this PR 271 passed and the same 3 failed (stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware).

@qtLkz

qtLkz commented Nov 25, 2026

Copy link
Copy Markdown

Tested on NVIDIA Ada, a 32-lane-only host: RTX 4070 Ti, driver 621.01, Windows 11 Pro build 26300, Rust 1.98.1 pinned, this PR merged onto main 13f91ca (clean merge).

cargo test -p victory-shader --lib --locked -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index
(The skipped test crashes the NVIDIA driver on main, #2571. The fix is in #2596 / #2587.)

All 5 new tests pass:

  • halves_tests::wave64_programs_in_halves_match_the_console_on_every_gpu ... ok
  • halves_tests::a_wave64_program_reading_lanes_declares_32_lane_waves_in_halves ... ok
  • halves_tests::reads_across_32_lane_halves_are_refused_with_their_reason ... ok
  • halves_tests::lds_of_a_one_wave64_group_is_refused_in_halves ... ok
  • halves_tests::the_test_program_is_what_its_comments_say ... ok

Whole lib: 271 passed, 3 failed, 3 ignored. The 3 failures (stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware) fail the same way on plain main on this card (#2317). Nothing new from this PR.

So in addition to the RTX 3070 Ti (Ampere) in the description, the halves path checks out on Ada.

AI-assisted (Claude).

…sole wave

What was wrong: two results in halves were wrong in the upper host wave
(console lanes 32-63). Measured before this change on an RTX 3070 Ti
(driver 32.0.16.2124) and the Radeon iGPU of a Ryzen 9 7900X (RDNA2),
32 of 64 lanes wrong on both, while the Radeon's own wave64 form gave the
console's results:

- v_readfirstlane_b32 read the host wave's first lane, which in the upper
  half is console lane 32 or later: a first-lane read of the thread id gave
  32 in lanes 32-63, the console 0 (reported on Marvisak#2633 by justrealyme).
- A DPP row mask was applied by the host lane's row, 0 or 1: with
  row_mask:0xc, lanes 32-63 (the console's rows 2 and 3) kept their old
  value instead of taking the DPP result.

What changed:

- A first-lane read in halves is kept for a value proven the same in every
  lane of the console wave (halves::lane_uniform: values made from scalars,
  constants and such values, under conditions that are themselves alike;
  LDS reads, and buffer loads through a scalar descriptor, at alike
  addresses; the thread id shifted past the console wave) and in groups of
  32 threads or fewer, which one host wave holds whole. Any other is
  refused with its reason; one nothing uses costs nothing. The analysis is
  justrealyme's (#1), ported from fxceless/victory-fork
  (Marvisak#497 there). Added here: buffer loads (a typed buffer's element the
  compiler loads with a vector load, then reads the first lane of), the
  dwords a waterfall loop reads (each lane's own, so not alike), and the
  small-group exception.
- DPP row masks take the row from the console lane.
- The GPU tests share one dispatch helper.

Evidence, translate --list --wave32 over shaders.rpf, the executable,
XboxBvhBuilder.dll and the FidelityFX DLL: compute programs emitted
2,372 -> 2,369. The 3 no longer emitted read the first lane of a value the
analysis cannot show is alike (scattering_transmittance_system's cloud
multiple-scattering cache: a value joined from a branch on a per-lane
compare; two ptx_prerender light-atlas programs: a select on a mask made
from EXEC, in a loop), so in halves they could compute per-half values. 14
programs refused before give this reason first now; no other outcome
changes. The analysis as #1 has it refuses 12: the
small-group exception keeps 5 of them, buffer loads 4. No program of the title uses a DPP row mask
other than 0xF in halves, so that fix changes none of its translations.

Tests (emit::halves_tests):

- dpp_row_masks_name_the_console_rows_on_every_gpu (new): row_mask:0xc;
  0 of 64 lanes differ on both GPUs (32 before).
- first_lanes_kept_in_halves_match_the_console_on_every_gpu (new): the
  thread id's first lane in a group of 32 and l >> 6 in a group of 128;
  0 lanes differ on both GPUs.
- reads_across_32_lane_halves_are_refused_with_their_reason: the thread
  id's first lane is refused in a group of 64 and kept in a group of 32;
  an unused one costs nothing; a buffer dword loaded at an offset alike in
  every lane is kept, at the thread id's offset refused.
- the_test_programs_are_what_their_comments_say: every hand-encoded
  program checked against the disassembler.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 273 passed, 3 failed, the same 3
as on main on this NVIDIA machine (two stride_tests,
gathers_at_a_level_match_the_hardware);
heap_direct_texture_reads_mark_their_heap_index skipped as before. lower.rs
is 495,122 bytes.

Co-Authored-By: justrealyme <82029927+justrealyme@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chippy01

Copy link
Copy Markdown
Author

Pushed a second commit with two fixes. Both were wrong results in the upper host wave (console lanes 32-63), and both now have tests:

  1. First-lane reads. Thanks @justrealyme for the report and the fix in Shaders: in halves, a first lane is read only of a value alike in both halves chippy01/VIctory#1; it's folded into this commit with you as co-author. v_readfirstlane_b32 read the host wave's first lane, which for the upper half is console lane 32. Reproduced here on the RTX 3070 Ti and the Radeon iGPU: the first lane of the thread id gave 32 in lanes 32-63, where the console gives 0. The Radeon's own wave64 form gave 0. A first-lane read is now kept only for values proven the same in every lane of the console wave. The analysis gains two cases:

    • buffer loads at alike addresses through a scalar descriptor (how the compiler reads one element of a typed buffer)
    • groups of 32 threads or fewer, where one host wave holds the whole console wave

    Every other first-lane read is refused with its reason. Offline over the title, compute programs emitted go from 2,372 to 2,369. The 3 dropped read values that can really differ between halves: the cloud multiple-scattering cache, for example, reads a value joined from a branch on a per-lane compare.

  2. DPP row masks. The row came from the host lane (0-1), so the upper half applied row_mask bits 0-1 to console rows 2-3. With row_mask:0xc, lanes 32-63 kept their old value on both GPUs (32 of 64 lanes wrong); now 0 are. No program in this title uses such a mask in halves, so none of its translations change.

New GPU tests: dpp_row_masks_name_the_console_rows_on_every_gpu and first_lanes_kept_in_halves_match_the_console_on_every_gpu. The refusal cases are in reads_across_32_lane_halves_are_refused_with_their_reason. victory-shader --lib: 273 passed, with the same 3 NVIDIA failures as main. Clippy (both runs) and cargo xtask policy are clean.

The refused first-lane reads come back exactly once the two host waves can exchange values, which is the follow-up mentioned above.

@TaynanGT

Copy link
Copy Markdown

Thanks, @qtLkz, for running the five tests on the RTX 4070 Ti, and @chippy01 for the first-lane and DPP row-mask fixes. My RTX 4090 results above are from 360f8aa, before the follow-up. The 2,372 compute programs in that table are from that earlier revision.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs the maintainer's decision, plus one small fix. The rebase merges cleanly and CI check is passing. The approach is gated by emit::Options::host_wave32, which is set from Host::wave32 (D3D12_OPTIONS1, at most 32 lanes with 32 among them). It runs console wave64 compute programs as two 32-lane host waves. Reads across halves, LDS in one-wave groups, unproven first-lane reads, and tile-prone group shapes are refused with reasons in emit/lower/halves.rs. The shader cache key in crates/victory-gpu/src/shader_cache.rs now includes the wave width. Several testers report the halves tests exact on NVIDIA Ampere/Ada/Blackwell and on RDNA2/RDNA3 (where they also match the native wave64 form).

On your reply: the third commit's refusal of group shapes a host wave may tile, and the merge of main (using #573's ds_bpermute_b32 within halves), read correctly.


Generated by Claude Code

Conflicts resolved:

- emit/lower.rs: ds_bpermute_b32 takes main's lowering (Marvisak#573: within
  the reader's own 32-lane half, the half's base from the host lane),
  which in halves is the host wave itself, so halves::permute_lanes,
  which did that for halves alone, is gone. Lowered keeps both sides'
  test fields (wave_size, and main's uses_lane_index and
  has_half_wave_mask).
- emit/host.rs: main's Host::new (one shared WARP device, the warp
  field). Host::each_hardware and create_device share one SM 6.6 check,
  the sm66 function.
- apps/victory/src/main.rs: --wave32 beside main's non-zero --jobs.
- README.md: main's "GPU: world" row, this branch's "Shaders" row.

For main's new code: host_wave32: false in four new tests' lower::Parts
and in one emit::Options; victory-gpu takes its shader host by
Host::from_device, as main now has it.

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

Copy link
Copy Markdown

First run in the world with this PR, on the same Ampere card as the description: RTX 3070 Ti 8 GB, driver 621.40, Windows 11 26200, 32 GB RAM. diag build, VICTORY_D3D12_DRED=1. The base is 13f91ca + #2319 + #1906 + #2178 (without those, this card does not get through the world on NVIDIA; #1906 is in main now). This PR at b15a57b; the only conflict there was shader_cache.rs against #2178 (each adds a key parameter; I kept both). Cache and pipelines rebuilt for each build. These runs are of your two commits before your merge of main (f60027f); the conflict resolution in that merge is not covered here.

Offline (translate --cache --pipelines, same four inputs), on the base and then with this PR:

base + this PR
pipelines refused by the host 397 1
containers refused by the translator 233 597
pipelines made or already in the library 26,736 26,777

In the title, two 15-minute runs from the start screen through the world and the intro cutscene, one per build. The script stopped both; neither had a device removal:

base + this PR
compute programs refused by the host (unique) 170 0
programs dropped in total (host or translator, unique) 178 170
dropped on the base, running here 9
running on the base, dropped here 0 (one program refused here was not requested in the base run)
host submissions in the slow log / longest 92 / 0.68 s 13 / 0.99 s
world frame time, median of 10-s samples 0.84 s 0.83 s

The 170 dropped here all give a reason. The ones I could classify: 76 for LDS one console wave64 shares without barriers, 18 for lane masks or lane reads across halves, 11 for reductions over both halves, 7 for first-lane reads of values that may differ between the halves. emit::halves_tests passes 7/7 here: (halves) 0 lanes of 64 differ from the console, and the wave64 form is skipped as expected. victory-shader --lib and victory-gpu --lib show no new failures against the base.

I did not compare images, so this says nothing yet about whether the 9 programs that run now draw correctly.

AI-assisted (Claude Code); the runs are on my machine.

@TaynanGT

Copy link
Copy Markdown

Thanks for running this in-game, @davesousa. The drop from 170 host refusals to zero on the 3070 Ti lines up with what I saw offline on the 4090. The median world frame time barely moved, even with fewer slow submissions.

Your numbers give us a baseline for b15a57b on the stack you listed. A matched run on f60027f with screenshots would show whether those results held after the merge and what the nine newly running programs actually draw.

What was wrong: the thread relabelling gives a thread the flat id of its
host wave's first lane, rounded down to 32, plus its host lane. That is
a bijection only while every host wave holds a 32-aligned run of flat
ids. Hosts fill the waves of a group of several rows with tiles when its
rows are 32 threads wide or more. A wave then holds a 16 x 2 tile, two
waves round down to the same base, and two threads share every id while
half the ids go unused. Measured in halves with a program that stores 1
at its own id, on an RTX 3070 Ti (driver 32.0.16.2124) and the Radeon
iGPU of a Ryzen 9 7900X (RDNA2):

- 32x2, 32x8, 64x4, 32x32 and 32x2x2 groups store half their ids, on
  both;
- 8x4, 4x4, 8x8, 16x2, 16x4, 8x16, 16x16, 4x4x4, 2x2x16, 8x8x4 and
  one-row groups store all of them.

Marvisak#2126 (0xkn0wh3r3) measured the same tiling on an RTX 5070 Ti, and for
rows 24, 12 and 10 threads wide too, for main's 32-lane programs.

What changed: halves refuse a group of several rows whose rows are 32
threads wide or more or not a power of two wide, with its reason
(`halves::halves_tiles`). halves.rs and halves_tests.rs are
rustfmt-clean.

Evidence: translate --list --wave32 over shaders.rpf, the executable,
XboxBvhBuilder.dll and the FidelityFX DLL, on main 842b0cb merged: no
emitted program changes (2,369); with --pipelines on the RTX 3070 Ti,
2,369 compute pipelines are made, none refused by the driver. The
title's programs in halves that translate are in groups of 8x8, 8x4, 4x4
or one row. Its programs in groups of 32x2, 32x32 or 6x6 were refused
already; 2 of them (GpuParticleEmit's water emitters) now give this
reason first, the rest the one-wave LDS reason. The exchanges planned
next would otherwise have run them wrongly.

Tests (emit::halves_tests):

- groups_a_host_wave_may_tile_are_refused_in_halves: 32x2, 64x4, 32x2x2
  and 6x6 are refused; 8x8, 16x2, 4x4x4 and 64x1 translate.
- every_thread_keeps_its_own_id_in_halves_on_every_gpu: 8x8, 16x2, 4x4x4
  and 64x1 store every id on both GPUs, in halves and (on the Radeon) as
  one wave64.

Found on the way, not changed here: under main's rounding to 64, the
Radeon's own wave64 stores 128 of a 64x4 group's 256 ids (32-wide groups
are laid out in rows there). Marvisak#2126's per-wave tickets cover that too;
once it lands, halves can take their ids from it and drop this refusal.

Checks: cargo clippy --workspace --all-targets --locked -- -D warnings,
and with --all-features: clean. cargo xtask policy: ok. cargo test -p
victory-shader --lib -- --test-threads=1: 307 passed, 3 failed, the same
3 as on main on this NVIDIA machine;
heap_direct_texture_reads_mark_their_heap_index skipped as before.

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

Copy link
Copy Markdown
Author

Merged main (842b0cb) in f60027f. main's own ds_bpermute_b32 lowering from #573 already reads within the reader's half, so it replaces the halves-only permute_lanes. The Host test helpers now sit on main's shared WARP device. Nothing measured changes.

Then pushed a third commit: halves now refuse group shapes that a 32-lane host wave may tile.

The relabelling gives a thread the first flat id of its host wave, rounded down to 32, plus its host lane. That is right only while every host wave holds a run of consecutive ids. I ran a program in halves that stores 1 at its own id, on the RTX 3070 Ti and the Radeon iGPU. 32x2, 32x8, 64x4, 32x32 and 32x2x2 groups store half their ids on both GPUs, because the host gives a wave a 16x2 tile of the group. 8x4, 4x4, 8x8, 16x2, 16x4, 8x16, 16x16, 4x4x4, 2x2x16, 8x8x4 and one-row groups store all of them. #2126 found the same tiling on an RTX 5070 Ti for main's 32-lane programs.

No program the title translates in halves uses such a group; they are 8x8, 8x4, 4x4 or one row, so 2,369 are still emitted. Its 32x2, 32x32 and 6x6 programs were refused already, and they would have run wrongly once the exchanges arrive. When #2126's per-wave tickets land, halves can take its ids from them and drop this refusal.

New tests: groups_a_host_wave_may_tile_are_refused_in_halves and every_thread_keeps_its_own_id_in_halves_on_every_gpu. victory-shader --lib: 307 passed on the merged head, with the same 3 NVIDIA failures as main.

@TaynanGT

Copy link
Copy Markdown

Thanks for testing those group shapes on both adapters, @chippy01. The store-at-own-ID test shows where the flat-ID assumption breaks: a 16×2 tile crosses rows, and the wider groups lose half their writes.

The unchanged count of 2,369 gives us a reference for 86a16dc. A matched run of that head and b15a57b can check whether the picture and frame times still agree after the merge and the new guard.

@steven-seagull27

Copy link
Copy Markdown

I tested the single-half case on 86a16dc. A 32-thread group fits entirely inside one Wave32. The guest compares the thread ID, saves and narrows EXEC, runs v_readfirstlane_b32 s12, v0, restores EXEC, and writes the scalar from all 32 threads. There is no branch or second half. The four masks select lane 0, lane 7, lane 31, or no lanes (the lane-zero fallback).

Wrong output dwords out of 128 This PR This PR merged locally with #2830 (36eb5f6)
RTX 5080, Wave32 64 0
WARP 1.0.22, Wave32 64 0
WARP 1.0.22, Wave64 64 64

Both Wave32 runs returned zero for the lane-7 and lane-31 masks before #2830. The two PR heads merge cleanly. Windows' built-in WARP advertises Wave4 only here and skipped both requested widths.

I also compiled a standalone HLSL shader with DXC to check the remaining WARP result. With [WaveSize(64)], 32 threads per group, and tid = SV_GroupIndex, thread 7 reported an all-zero WaveActiveBallot(tid >= 7). A direct WaveReadLaneAt(100 + tid, 7) in the same shader returned 107. Changing only the group size to 64 produced ballot words ffffff80 ffffffff and elected lane 7. A native Wave64 Radeon readback on the 32-thread fixture would help distinguish the WARP result.

Test-only commit a5a1999. To run from the head of this PR:

git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2633-masked-first-lane
git cherry-pick a5a1999
cargo test -p victory-shader --lib first_lane_of_a_small_group_respects_guest_exec -- --nocapture

@TaynanGT

Copy link
Copy Markdown

Thanks for the minimal repro, @steven-seagull27. The 32-thread fixture reproduces the lane 7 and 31 failures within a single half, and both Wave32 runs go from 64 wrong dwords to zero with #2830. I can use a5a1999 for the same comparison on my 4090.

I'd still like to see a native Wave64 Radeon run of the 32-thread fixture, especially whether the ballot is zero when the direct lane read returns 107.

@steven-seagull27

Copy link
Copy Markdown

@TaynanGT I put both comparisons on one branch at 34c8e1c. It contains this PR, #2830 and the guest fixture, plus a separate HLSL shader compiled by the Windows SDK's PC DXC. It prints the actual adapter, selected wave width, ballot words, elected read, and direct read from lane 7.

@zed6000 Thanks for the native Wave64 result on #1737. If your 7900 XTX is available for this one, could you post the Radeon lines for the 32-thread group and the 64-thread control? From an existing clone, the following creates a separate worktree:

git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2633-radeon-comparison
git worktree add --detach ../victory-2633-radeon FETCH_HEAD
cd ../victory-2633-radeon
cargo test -p victory-shader --lib first_lane_of_a_small_group_respects_guest_exec -- --nocapture
cargo test -p victory-shader --lib native_ballot_in_a_partial_wave -- --ignored --nocapture

In the standalone test on WARP 1.0.22, 25 of the 32 threads had their own predicate missing from the Wave64 ballot. Thread 7 read 100 through the elected lane and 107 directly from lane 7. Increasing only the group size to 64 gave 107 both ways and 0/64 wrong. On the RTX 5080, Wave32 had zero wrong for both group sizes. The standalone test prints all adapter/width results before reporting any mismatches.

@TaynanGT

Copy link
Copy Markdown

Thanks for putting both fixtures on 34c8e1c, @steven-seagull27. I can use that head for the 4090 check and report the actual wave width with the ballot and both reads.

I'd look for whether Radeon also gets 100 from the elected lane and 107 from lane 7 with 32 threads, then 107 both ways with 64. That would show whether the WARP result also reproduces on native Wave64 hardware.

@TaynanGT

Copy link
Copy Markdown

@steven-seagull27 I ran both tests on 34c8e1c. The guest first-lane test matched all four masks on the RTX 4090 in Wave32 and on the Ryzen 9 9950X3D's integrated Radeon in Wave32 and native Wave64.

Standalone DXC run 32 threads 64 threads
RTX 4090 (621.40), Wave32 0/32 wrong 0/64 wrong
Radeon iGPU (32.0.21045.29003), Wave32 0/32 wrong 0/64 wrong
Radeon iGPU, native Wave64 0/32 wrong 0/64 wrong

For thread 7, the 4090's Wave32 ballot was ffffff80 00000000 with either group size. On the Radeon in Wave64, it was ffffff80 00000000 with 32 threads and ffffff80 ffffffff with 64. In all of those runs, lane 7 was elected and both reads returned 107.

The built-in WARP adapter reported Wave4 and skipped Wave32 and Wave64.

Steenax6 added a commit to Steenax6/VIctory-NVID that referenced this pull request Nov 26, 2026
…ounter

A console program whose code reads other lanes runs in host waves of the
console's size, and its threads were relabelled so that each console lane
is its host lane: the flat id of the wave's first lane, rounded down to the
wave size, plus the host lane. That is a bijection only while every host
wave holds a run of flat ids. Hosts fill the waves of a group of several
rows with tiles when its rows are 32 threads wide or more, or not a power
of two wide: two waves then round to the same base, two threads share
every id, and half the ids go unused. On the RTX 4070 Ti here a 32 x 2
group stored 32 of its 64 ids that way (the new card test, without the
change).

Such a group now takes its waves' bases from an LDS counter, as the
programs run in halves and the paired form already did (wave_base): every
thread zeroes it, the group meets once, each wave's first lane adds a
wave. Only for groups of whole waves; a group with a part-filled wave
keeps the old relabelling. Over the title's archive no program is in such
a group today (counted with a temporary log line): no translation changes.

The paired form was checked for upstream's two defects as well: its host
group is one row and its bases come from the counter (no tiling), and its
first-lane read takes the lower lane first, the upper only when no lower
lane is in EXEC (the paired v_readfirstlane in lower.rs), as the console.

From Marvisak/VIctory PR Marvisak#2633 (86a16dc, "in halves, a group a 32-lane
host wave may tile is refused", measured on an RTX 3070 Ti and RDNA2;
Marvisak#2126 for rows 24, 12 and 10 wide on an RTX 5070 Ti). Here relabelled by
the counter instead of refused.

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

Copy link
Copy Markdown
Author

@TaynanGT here is the matched comparison. Same card as davesousa's, an RTX 3070 Ti 8 GB, but on driver 621.24 (theirs was 621.40). Ryzen 9 7900X, 32 GB RAM, Windows 11 26200, TDR delay at the default 2 s. diag builds, VICTORY_D3D12_DRED=1, --console series-x. b15a57b is on davesousa's stack (+ #2319 + #1906 + #2178). 86a16dc has #2319 + #2178; #1906 comes with the merge. shader_cache.rs keeps both key parameters, as davesousa did. Cache and pipelines were rebuilt for each build.

Offline, translate --cache --pipelines on the same four inputs:

b15a57b 86a16dc
containers refused by the translator 597 593
pipelines refused by the host 1 1
pipelines made or already in the library 26,777 26,779

b15a57b reproduces davesousa's column exactly.

translate --list --wave32 on the same inputs, program by program:

b15a57b 86a16dc
compute programs emitted (in halves) 2,369 of 2,763 2,369 of 2,763
vertex and pixel programs emitted 14,254 of 14,259 14,258 of 14,259
mesh programs emitted 8,765 of 8,765 8,765 of 8,765

No compute program changes outcome. The guard refuses two programs, both of which b15a57b already refused for a lane mask read as data. The guard now stops them before that check. The other halves reasons have the same counts on both builds: 192 LDS, 48 lane reads across halves, 20 reductions, 17 first-lane reads. Four pixel programs change outcome: b15a57b refused them for a lane mask read as data, and they translate after the merge.

In the title I couldn't get the 15-minute runs. Both builds stopped in the world, the same way:

b15a57b 86a16dc
world's first frame 2.4 min 3.7 min
run ended 8.5 min 5.2 min
compute programs refused by the host 0 0

Once the world loaded, the emulator's working set reached 20-22 GB, VRAM sat at 7.0-7.2 of 8 GB, and about 1 GB of RAM was left. Frames took seconds each (up to 15 s). Then no frame came for about a minute, and the title's own crash handler ended it ("Game Running" in its report). Both builds did this, even with most apps closed, so I read it as a limit of this machine rather than of either commit. The page file and the game data are both on a nearly full QLC SSD. davesousa's runs got through 15 minutes with the same card and RAM. Frame times from these runs aren't meaningful.

In the part both runs covered, no program ran on one build and was dropped on the other. The 43 programs 86a16dc refused in its run all give halves reasons; none of them is the new tile-prone-group refusal.

The captures can't answer the picture question on NVIDIA yet. In both builds the world frames show only the cutscene's subtitles and letterboxing over a flat background. Both runs log the same host refusal of a 2560x1440 texture (#797), which looks like the scene target.

One more thing about b15a57b's stack. Its first boot on a fresh library hung for 28 s shortly after a library save, and the title crashed itself in "Game Init". b15a57b doesn't have #2179, so a pipeline load waits while a save serialises the whole ~1 GB library. 86a16dc gets #2179 with the merge. The hang didn't happen on every first boot. To keep the two builds alike, each got one throwaway boot on its fresh library before its run.

@TaynanGT

Copy link
Copy Markdown

Thanks for running both builds, @chippy01. The 2,369 compute programs on each build answer my question about the guard. It rejects the same two programs earlier, and the merge gets four more pixel programs through translation.

The picture and frame-time comparison is still open. Both runs hit the same 2560×1440 texture refusal and ended before 15 minutes. Could you share the HRESULT and the format and flags for texture #797 if they're in the log? The 28-second fresh-library stall also fits the save/load contention that #2179 addresses.

@chippy01

Copy link
Copy Markdown
Author

@TaynanGT it's in the logs. Both builds write the same pair of lines once per run, at the cutscene (b15a57b at 08:40:10, 86a16dc at 08:52:16):

WARN victory_gpu::resource: the host refuses castable formats: textures of one memory in other formats get their own host texture error=Parametro non corretto. (0x80070057) desc=ResourceDesc { dimension: 3, alignment: 0, width: 2560, height: 1440, depth_or_array_size: 1, mip_levels: 1, format: 115, sample_count: 1, sample_quality: 0, layout: 0, flags: 1 }
WARN victory_gpu::resource: no host texture error=Parametro non corretto. (0x80070057) desc=ResourceDesc { dimension: 3, alignment: 0, width: 2560, height: 1440, depth_or_array_size: 1, mip_levels: 1, format: 115, sample_count: 1, sample_quality: 0, layout: 0, flags: 1 }
  • HRESULT 0x80070057 (E_INVALIDARG; "Parametro non corretto" is the Italian system text). It comes back on both tries: first with castable formats, then as a plain texture.
  • TEXTURE2D, 2560x1440, 1 mip, 1 slice, 1 sample. format: 115 is DXGI_FORMAT_B4G4R4A4_UNORM and flags: 1 is D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET.
  • The D3D12 debug layer was off for these runs, so there's no message saying which part it objects to. I can rerun with VICTORY_D3D12_DEBUG=1 if you want the debug layer's own reason.

That's one of the two textures in #797. The other one (format: 86, B5G5R5A1_UNORM, flags: 5) is created in both runs now. main makes it without unordered access; the log line just before the refusal is no unordered access for this format: textures are made without it, their unordered views are refused format=86. So on this card only the 115 texture is still refused.

On the 28 s stall: agreed, that's the save/load contention #2179 removes. It's why each build got one throwaway boot before its measured run.

@steven-seagull27 thanks for the masked first-lane fixture. The wrong lanes come from main's lowering, not from the halves. An instruction with a scalar destination drops its EXEC guard, so under a narrowed EXEC v_readfirstlane_b32 reads the host wave's lane 0 on any host. #2830 fixes that on main, and with it the halves path matches (TaynanGT's run on the 4090 and the Radeon iGPU at 34c8e1c). I'll leave that fix to #2830 rather than duplicate it here.

@TaynanGT

Copy link
Copy Markdown

Yes, please try VICTORY_D3D12_DEBUG=1 on 86a16dc, @chippy01. A run to the cutscene is enough. Could you paste the debug-layer message ID and text for the plain creation of the B4G4R4A4_UNORM render target?

Thanks for checking both formats. Format 86 now creates without the UAV flag, and 115 still returns E_INVALIDARG on the plain path. If you already have a format-support dump, could you include the D3D12_FORMAT_SUPPORT1_RENDER_TARGET bit for 115?

@chippy01

Copy link
Copy Markdown
Author

@TaynanGT the debug layer can't get this title to the cutscene on this PC. With VICTORY_D3D12_DEBUG=1, 86a16dc (the same diag build and stack as the matched run) stopped in Game Init. The boot's descriptor work went several times slower than without the debug layer: a few thousand title-slot warnings per 10 s instead of 40,000-85,000. The title's own watchdog ended the run at 79 s. Its deliberate write at +0x2215c35 left a crash report that says Game State: Game Init, Frame: 0. Without the debug layer the emulator gets to that texture at 81 s.

So I repeated the two calls make_texture makes for that texture outside the emulator, with the debug layer on. The arguments are the same: 2560x1440, 1 mip, B4G4R4A4_UNORM, ALLOW_RENDER_TARGET, default heap. The castable list is what castable(115) gives (formats 49-52, 54, 56-59, 68, 69, 85, 86).

call RTX 3070 Ti Radeon iGPU (Ryzen 9 7900X)
CreateCommittedResource3 with those castable formats and a clear value in format 115 E_INVALIDARG, ID 817 made
CreateCommittedResource3 with the same castable formats, no clear value made made
CreateCommittedResource (plain), with or without that clear value E_INVALIDARG, ID 599 made

ID 599 is D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDMISCFLAGS (severity ERROR, category STATE_CREATION):

ID3D12Device::CreateCommittedResource: A texture that has D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET set in D3D12_RESOURCE_DESC::Flags must be created with a format that either can be used as a render target, or cast to a format that could be used as a render target. FeatureLevel is D3D_FEATURE_LEVEL_12_2. D3D12_RESOURCE_DESC::Format is B4G4R4A4_UNORM.

ID 817 is D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDCLEARVALUEFORMAT:

ID3D12Device::CreateCommittedResource3: When D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET is set in D3D12_RESOURCE_DESC::Flags, D3D12_CLEAR_VALUE::Format must be valid to be used as a render target. FeatureLevel is D3D_FEATURE_LEVEL_12_2. D3D12_CLEAR_VALUE::Format is B4G4R4A4_UNORM.

In the runs the castable try failed as well. Outside the emulator it only fails with a clear value in format 115, so the title most likely passes one. The emulator then falls back to the plain creation, which fails with 599.

Format support (CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT)):

RTX 3070 Ti, driver 621.24 Radeon iGPU
115 B4G4R4A4_UNORM, Support1 0x008413f0, RENDER_TARGET clear 0x02e4d3f0, RENDER_TARGET set
86 B5G5R5A1_UNORM, Support1 0x00e4d3f0, RENDER_TARGET set 0x02e4d3f0, RENDER_TARGET set

Both adapters report RelaxedFormatCastingSupported. So on this card 115 can never be a render target format, but the castable texture is accepted once the clear value in 115 is left out. I haven't tested whether its render target views work in one of the castable formats.

1 similar comment
@chippy01

Copy link
Copy Markdown
Author

@TaynanGT the debug layer can't get this title to the cutscene on this PC. With VICTORY_D3D12_DEBUG=1, 86a16dc (the same diag build and stack as the matched run) stopped in Game Init. The boot's descriptor work went several times slower than without the debug layer: a few thousand title-slot warnings per 10 s instead of 40,000-85,000. The title's own watchdog ended the run at 79 s. Its deliberate write at +0x2215c35 left a crash report that says Game State: Game Init, Frame: 0. Without the debug layer the emulator gets to that texture at 81 s.

So I repeated the two calls make_texture makes for that texture outside the emulator, with the debug layer on. The arguments are the same: 2560x1440, 1 mip, B4G4R4A4_UNORM, ALLOW_RENDER_TARGET, default heap. The castable list is what castable(115) gives (formats 49-52, 54, 56-59, 68, 69, 85, 86).

call RTX 3070 Ti Radeon iGPU (Ryzen 9 7900X)
CreateCommittedResource3 with those castable formats and a clear value in format 115 E_INVALIDARG, ID 817 made
CreateCommittedResource3 with the same castable formats, no clear value made made
CreateCommittedResource (plain), with or without that clear value E_INVALIDARG, ID 599 made

ID 599 is D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDMISCFLAGS (severity ERROR, category STATE_CREATION):

ID3D12Device::CreateCommittedResource: A texture that has D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET set in D3D12_RESOURCE_DESC::Flags must be created with a format that either can be used as a render target, or cast to a format that could be used as a render target. FeatureLevel is D3D_FEATURE_LEVEL_12_2. D3D12_RESOURCE_DESC::Format is B4G4R4A4_UNORM.

ID 817 is D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDCLEARVALUEFORMAT:

ID3D12Device::CreateCommittedResource3: When D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET is set in D3D12_RESOURCE_DESC::Flags, D3D12_CLEAR_VALUE::Format must be valid to be used as a render target. FeatureLevel is D3D_FEATURE_LEVEL_12_2. D3D12_CLEAR_VALUE::Format is B4G4R4A4_UNORM.

In the runs the castable try failed as well. Outside the emulator it only fails with a clear value in format 115, so the title most likely passes one. The emulator then falls back to the plain creation, which fails with 599.

Format support (CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT)):

RTX 3070 Ti, driver 621.24 Radeon iGPU
115 B4G4R4A4_UNORM, Support1 0x008413f0, RENDER_TARGET clear 0x02e4d3f0, RENDER_TARGET set
86 B5G5R5A1_UNORM, Support1 0x00e4d3f0, RENDER_TARGET set 0x02e4d3f0, RENDER_TARGET set

Both adapters report RelaxedFormatCastingSupported. So on this card 115 can never be a render target format, but the castable texture is accepted once the clear value in 115 is left out. I haven't tested whether its render target views work in one of the castable formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.