Skip to content

fix(shader): throw for v_readlane_b32 of a register-selected lane on one-lane waves - #14068

Merged
oneandonlydean merged 5 commits into
boykopovar:mainfrom
frankea:fix/one-lane-readlane-register-selector
Nov 7, 2026
Merged

oneandonlydean merged 5 commits into
boykopovar:mainfrom
frankea:fix/one-lane-readlane-register-selector

Conversation

@frankea

@frankea frankea commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What

On a device whose subgroupSupportedStages lacks the vertex stage (lavapipe, MoltenVK), vertex and local programs run as one-lane waves (#4470), where a shuffle returns the invocation's own value. EmitReadLane checked the lane of a v_readlane_b32 only when a constant named it. A lane held in an SGPR passed ReadLaneEliminator, which skips non-immediate selectors, and reached EmitSubgroupShuffle, whose one-lane branch copies the invocation's value whatever lane is named. The console reads that lane's VGPR: the lane is S1 % 64 in wave64 (RDNA 2 ISA, 12.12, V_READLANE_B32, page 183). The review of #13807, which puts tessellation evaluation programs on the same path, pointed this out; this is the follow-up I said I would open there.

  • Change. On a one-lane wave (HostSubgroupNarrowerThanWave with a host width of 1), EmitReadLane accepts a register-selected lane only when OwnLaneSelectorWalk proves it is the invocation's own. The selector must be the FindILsb32 of s_ff1_i32_b32, or the s_ff1_i32_b64 lowering of sFfI32B64 (Select(lo != 0, FindILsb32(lo), Select(hi != 0, FindILsb32(hi) + 32, -1))) with its condition testing that same lo. The mask must be built from EXEC and ballots: a ballot word, 0 (or 1 in its low word), an AND with such a word, ORs, XORs and selects of such words, or a phi of them, which covers s_mov_b64 from EXEC, s_and_b64 with a compare result, s_bitset0_b64 and the loop phis of a waterfall. On one lane a ballot is the invocation's own bit, so such a mask holds at most bit 0 in its low word and nothing in its high word. The mask must also hold that bit wherever the read runs: it is the entry EXEC (Ballot(true)), or a branch on the way to the read tested it for zero. The walk follows unique predecessors up from the read and the incoming edges of phis, and takes each conditional branch's condition from BlockInfo: LogicalNot, LogicalAnd and LogicalOr of tests, and != 0 or == 0 of the word, of word | high or of the 64-bit pair, whose high word is zero on one lane. That covers the back edge of an s_ff1 waterfall (s_cmp_lg_u64, s_cbranch_scc1) and a guard before one (s_cbranch_scc0 on the SCC of s_and_b64). s_ff1 of an empty mask is -1 (RDNA 2 ISA, 12.3, S_FF1_I32_B64, page 114), which reads lane 63 in wave64, so a mask that may be empty throws, as a constant lane 63 does. Any other selector throws through FailOutsideHostSubgroup: v_readlane_b32 of a register-selected lane is outside the 1-lane host subgroup that runs this wave64 program at one lane per invocation. Accepted programs emit the same SPIR-V as before, and devices with vertex subgroups are not affected.
  • Other one-lane shuffles. AppendConsume shuffles from the first active lane, which on one lane is the invocation's own, so it needs no check. EmitDsMaskedLaneRead (ds_swizzle_b32, ds_bpermute_b32), DPP moves and v_permlane16_b32 are not checked here: on one lane they read another lane as inactive (0 or the old value), or with fetch-inactive as the invocation's value. The debt entry lists them; they are a separate change.
  • Debt. The vertex entry in docs/dev/debt/shader.md was 1,254 characters, over the 1,000 that check_conventions.py allows for a changed entry, so its one-lane rules move to a new "One-lane vertex waves" entry, which now states the v_readlane_b32 rule and the unchecked shuffles. The s3 layout stays in the old entry.
  • Tessellation evaluation. fix(shader): run tessellation evaluation stages one lane per invocation on devices without subgroups there #13807 is on main now, so tessellation evaluation programs without subgroups take the one-lane path and this check with no further code. The merge of main into this branch drops the sentence of its debt entry that said a register-selected lane is not checked, and verifySingleLaneDomainWave gets the same register-selector case as the vertex test.

Title: none. In my Gran Turismo 7 (PPSA01317) shader disk cache from MoltenVK runs on an Apple M5 Max (16,739 entries), the 56 entries (7 distinct programs) that hold a v_readlane_b32 with an SGPR lane are all compute programs (thread ids from v_lshl_add_u32 vN, sM, 6, v0, no exports), so none of the vertex or tessellation evaluation programs GT7 reached there starts throwing.

Tested

Windows 11 on an RTX 4090 (driver 616.92, Vulkan 1.4.341), winlibs GCC 15.2.0, Release with BUILD_TESTING=ON. The 4090 has vertex subgroups, so its draws keep the subgroup path; the one-lane path runs there only in verifySingleLaneVertexWave, which compiles for explicit targets.

  • 38 ctest entries pass 3 times in a row on this branch (c999c741ac, with main 029463c merged in) and on that main: request_serializer, the 21 entries of agc_shader_memory_tests, agc_driver_read_lane, agc_driver_write_lane, agc_driver_lds_mask_waterfall, agc_driver_exec_host_lanes, agc_driver_ngg_vertex_wave_reduction, agc_driver_pixel_wave_reduction, agc_driver_pixel_row_reduction, agc_driver_wave32_subgroup, agc_driver_window_lane_spill, agc_driver_scalar_sop1, agc_driver_tessellation, agc_driver_tessellation_depth_range_remap, agc_tessellation_pipeline_cache, agc_tessellation_factor_ring, agc_tessellation_lowering and agc_driver_vertex_elected_atomic_max (skipped: the 4090 has vertex subgroups). They passed the same way on dcd3021fea, and before the merge, the first 34 of them passed the same way on 283e3e773a and 5e086eaac8 against main e8c25dd. They pass once more under VK_LAYER_KHRONOS_validation with ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1 (ctest -V) on both, with no VUID- lines and no was not found but was requested by env var VK_INSTANCE_LAYERS; the loader log for agc_driver_read_lane in that environment shows the layer inserted.

Apple M5 Max, macOS 27.0.1, x86-64 under Rosetta 2: request_serializer and the 21 agc_shader_memory_tests entries pass 3 times in a row on this branch (dcd3021fea), built natively, and agc_shader_memory_tests passes 3 times in a row on c999c741ac. These compile for explicit targets and run no GPU work. One local build aid that is not part of this pull request was needed for the build: the GuestMemory.cpp part of #11447.

New checks, in verifySingleLaneVertexWave (tests/ShaderMemory.cpp):

  • A v_readlane_b32 of v5 (gl_VertexIndex) at the lane v_readfirstlane_b32 takes from v5 throws without vertex subgroups and builds on a 32-lane vertex subgroup.
  • An s_ff1_i32_b64 waterfall over s_mov_b64 s[0:1], -1 instead of EXEC throws without vertex subgroups.
  • An s_ff1_i32_b64 waterfall that reads v5 over exec & vcc after v_cmp_gt_u32 throws without vertex subgroups, since it can enter with an empty mask; behind s_cbranch_scc0 on the SCC of that s_and_b64 it builds without subgroup operations and still uses them with vertex subgroups, as the existing waterfall over EXEC and a plain s_ff1_i32_b32 of EXEC do.
  • An s_cselect_b32 that picks s_ff1_i32_b32 of EXEC or -1 on s_cmp_eq_u32 of v_readfirstlane_b32 of the vertex index throws without vertex subgroups.
  • In verifySingleLaneDomainWave, a v_readlane_b32 of v5 at the lane v_readfirstlane_b32 takes from v5 throws without tessellation evaluation subgroups and builds on a 32-lane tessellation evaluation subgroup; the existing domain waterfall over EXEC still builds without them.
  • A mask that s_ff1 reads throws without vertex subgroups when a ballot word is combined with a word v_readfirstlane_b32 took from the vertex index, one case per rule of the walk: an AND of two such words, EXEC ORed, XORed or s_cselect_b32-selected with one, each tested for zero first; EXEC ANDed with one, and s_cselect_b32 of EXEC or 0, both untested; an OR of two compare results; a compare result with EXEC in the high word, tested by s_cmp_lg_u64 and by the SCC of s_and_b64; a compare result read only when s_cmp_lg_u32 found it zero; and EXEC behind an s_cselect_b32 on a test of another word or of that copy against 0. A compare result tested for zero, a copy of EXEC, and a copy of EXEC ORed with a compare result build without subgroup operations.
  • With any one of the walk's rules weakened (an AND accepting any word, && changed to || for OR, XOR or select of mask words, or for AND or select of words that must hold the invocation's bit, an OR holding that bit accepting any words, any ballot word index accepted in the high word, or the dominating-branch test accepted without a branch), the test fails at the case for that rule.
  • With the new check removed, the test fails with a vertex program without vertex subgroups read the lane v_readfirstlane_b32 took from the vertex index. With the selector proof of 5e086eaac8, it fails on the unguarded waterfall and, with that case taken out, on the s_cselect_b32 case.

tools/check_conventions.py --base origin/main passes. main 029463c is merged into the branch; its only conflict was the debt entries next to #13807's.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA RTX 4090 (Windows 11, driver 616.92, Vulkan 1.4.341)
  • AI-assisted: yes (Claude Code)

…one-lane waves

Vertex and local programs on a device without vertex subgroups run as
one-lane waves, where a shuffle returns the invocation's own value.
v_readlane_b32 checked its lane only when a constant named it: a lane
held in an SGPR read the invocation's value whatever lane it named,
where the console reads that lane's VGPR (RDNA 2 ISA 12.12,
V_READLANE_B32: the lane is S1 % 64 in wave64).

On a one-lane wave a register-selected lane must now be the s_ff1 of a
mask built from EXEC and ballots, as in a waterfall loop. Such a mask
holds no lane but the invocation's own, so the read is its own value;
the -1 of an empty mask (RDNA 2 ISA 12.3, S_FF1_I32_B64) reads it too.
Any other selector throws through FailOutsideHostSubgroup. Accepted
programs emit the same SPIR-V as before.

The one-lane rules leave the vertex entry debt line for an entry of
their own, which also lists the cross-lane reads still unchecked there:
DPP moves, ds_swizzle_b32, ds_bpermute_b32 and v_permlane16_b32.
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 15573 docs/dev/debt/shader.md L25-27

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
docs/dev/debt/shader.md
PR 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 6280 docs/dev/debt/shader.md
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 6416 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 6924 docs/dev/debt/shader.md
PR 7410 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
docs/dev/debt/shader.md
PR 7642 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 8004 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 9356 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 9748 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 10193 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 10233 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 10359 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 10652 docs/dev/debt/shader.md
PR 10757 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 11483 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 12324 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
PR 12828 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 13847 docs/dev/debt/shader.md
PR 13928 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 13929 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 14212 docs/dev/debt/shader.md
PR 14377 docs/dev/debt/shader.md
PR 14853 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 14944 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 15548 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — changes requested

I found an unsound acceptance in the new register-selector proof: it can treat a lane-63 read as a lane-0 read on a one-lane host.

What I ran

Reviewed head 5e086eaac896fb794a8a59c947e3427ca6ebde43 against base 0f302813cebfc09e3e0b6f8fced15262d186879e; the merge preview is clean. Environment: Debian Linux 6.1, Python 3.11.2, GCC 12.2.0; I did not build or run CTest.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14068 --output-dir /tmp/anyps5-14068-review
git diff --check 0f302813cebfc09e3e0b6f8fced15262d186879e...5e086eaac896fb794a8a59c947e3427ca6ebde43
python3 tools/check_conventions.py --base 0f302813cebfc09e3e0b6f8fced15262d186879e --head 5e086eaac896fb794a8a59c947e3427ca6ebde43 --title "fix(shader): throw for v_readlane_b32 of a register-selected lane on one-lane waves" --body /tmp/anyps5-14068-review/pr-body.md
python3 tools/pr_stack_check.py 14068 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-14068-review/stack

Results

Check Result
Patch and conventions Passed.
Dependency and merge preview Passed; no declared dependencies and a clean preview against current main.
Register-selector proof Failed source review: FindILsb32 is accepted when its proven-own-word is zero, and the SelectU32 fast path does not validate its condition. Both can admit a selector of 0xffffffff, which becomes lane 63.
Author-reported focused tests The PR description reports 34 CTest entries passing three times on the branch and a prior main ancestor, plus validation-layer runs; I did not independently run these. The listed negative control removes the guard, so it does not cover either false-acceptance case below.
Hosted CI Windows and relinker jobs passed; Linux was skipped. These results do not exercise the focused shader test reported by the author.
Raw outputs and source excerpts

git diff --check output (empty):

Conventions output:

All conventions checks passed.

Stack report:

- PR #14068: **clean** against current base; head `5e086eaac896fb794a8a59c947e3427ca6ebde43`
No declared PR dependencies were found in the target PR chain.

Negative control

Assertion Mutation or input Did the new test fail?
A one-lane host must not silently substitute lane 0 when the guest selector can be lane 63. FindILsb32(0) as the v_readlane_b32 selector, or SelectU32(unrelated_false, FindILsb32(1), 0xffffffff). Not exercised by the added tests; not run locally. Both shapes pass the current source proof.

Findings

Blocking

selector() accepts FindILsb32 whenever ownWord() proves the input contains no bits except bit 0, but ownWord() also accepts zero. The ISA’s s_ff1 result for an empty word is -1; EmitReadLane masks the selector with waveSize - 1, making it lane 63 for wave64. The one-lane host implementation then copies the current value regardless of the selector. A guest lane 0 that remains active while a separate ballot-derived mask is empty can therefore read lane 63 on the console but receive lane 0’s value here.

The SelectU32 fast path has a second gap: it checks that the true branch is FindILsb32 and the false branch matches noLane(), but it never proves the select condition tests that same low word. For example, an unrelated false condition can select 0xffffffff while the low mask contains lane 0. Please restrict acceptance to selector expressions that prove lane 0 for every executing invocation; in particular, prove non-emptiness for FindILsb32 and validate the select condition and its relation to the branches. Add regression cases for an empty low mask with lane 0 still active and for an unrelated condition selecting the -1 branch.

Non-blocking

None.

Sources

Not verified

No build, CTest run, GPU run, or console run was performed in this review. The test and validation results in the PR description are author-reported.

To get this to a good state

Make the selector proof fail closed for these cases and add the two regression cases above. I will rerun the same source and no-build checks on the new head.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 5e086ea merged onto main 73f4f7e · tested 2026-10-31 18:08 UTC · 14 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,336 passed · 4 failed (0 new, 4 also fail on main) · 48 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,388 of 3,072 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (878 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_bda_device 46.8 s, ⚠️ agc_driver_graphics 30.2 s
Failing on main too (4, not counted against this PR)
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (3 IDs in 387 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (387 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_passes, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, and 379 more
VUID-vkCmdCopyImage-srcImage-01548 (12 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_sampling, and 4 more
VUID-vkCmdCopyImage-srcImage-01551 (12 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_sampling, and 4 more
Skipped (48)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_msaa_dcc_compared_import_2: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_4: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_8: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_deferred: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or plat
Reproduce
git fetch origin 5e086eaac896fb794a8a59c947e3427ca6ebde43 73f4f7e06e4f210a8c6570e335fd654dc0a86134
git checkout 73f4f7e06e4f210a8c6570e335fd654dc0a86134 && git merge --no-ff 5e086eaac896fb794a8a59c947e3427ca6ebde43
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@frankea the refusal itself is the right call and the walk reads sound at 5e086eaac8: a lane read from another invocation has no host source on a one-lane wave, and the new verifySingleLaneVertexWave cases pin the refusal as a deliberate behaviour. One thing to address:

The negative side of the walk is only pinned for immediates and v_readfirstlane_b32. In a copy of the branch, changing case IrOpcode::BitwiseAnd32: return walk(word->Argument(0), half) || walk(word->Argument(1), half); in OwnLaneSelectorWalk::ownWord to return true; leaves every agc_shader_memory_tests run passing, so no test would notice the AND rule accepting a mask that neither side proves is the invocation's own. Replacing the immediate rule by return true; is caught by the everyLaneWaterfall case. Please add a case where a ballot word is ANDed with a word that is not from EXEC or a ballot (user data SGPRs, for example) before the s_ff1_i32_b64, expecting the same refusal, and one each for the OR/XOR/select forms if you want them pinned.

…ane_b32 lane on one-lane waves

The selector proof accepted the s_ff1 of a mask built from EXEC and
ballots whenever that mask held no lane but the invocation's, empty
masks included. s_ff1 of an empty mask is -1 (RDNA 2 ISA 12.3,
S_FF1_I32_B64), which v_readlane_b32 reads as lane 63, the read a
constant lane 63 already refuses. It also took
Select(c, FindILsb32(mask), -1) without checking that c tests that mask.

The mask must now hold the invocation's bit wherever the read runs: it
is the entry EXEC, or a branch on the way to the read tested it for
zero, which covers the back edge of an s_ff1 waterfall and a guard
before one. The select must test mask != 0. Selects and phis of
selectors are no longer accepted.

New cases: a waterfall over an unguarded compare result and an
s_cselect_b32 of s_ff1_i32_b32 of EXEC or -1 throw; the same waterfall
behind s_cbranch_scc0 and a plain s_ff1_i32_b32 of EXEC build. Both
rejected cases build with the previous selector proof.
@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Oct 31, 2026
frankea added a commit to frankea/AnyPS5 that referenced this pull request Oct 31, 2026
…e ds_bpermute_b32 address

The review of boykopovar#14072 found the sum and OR rules of the address proof
unpinned: weakening either let a ds_bpermute_b32 whose address added the
vertex index to a lane-0 term build and read the invocation's own value.
Guest code reaches neither rule. Its lane id comes from v_mbcnt as a
BitCount, which the proof never accepts, so the only register address
it needs is the one the translator builds for image_sample_*_cd. The
proof now accepts just that: the lane id, an AND with it, or the quad's
first active lane, shifted left by 2. Sums, ORs, selects and offsets
throw. Four new cases pin this: the v_mbcnt lane id plus the vertex
index, the vertex index plus 32, the vertex index OR 32, and the vertex
index at offset 128.

Merged hull programs never reach these checks, because
TessellationLowering's requireOwnLanes already throws for every
cross-lane opcode before emission. The lane id is therefore accepted in
every stage, and the v_readlane_b32 call site is back to boykopovar#14068's.
@frankea

frankea commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Thanks, both cases are real. I pushed 283e3e773a on top of 5e086eaac8.

  1. Empty mask. The mask must now hold the invocation's bit wherever the read runs, not just hold no other bit. That holds when it is the entry EXEC (Ballot(true)), or when a branch on the way to the read tested it for zero. The walk follows unique predecessors up from the read and the incoming edges of phis, and reads each conditional branch's condition from BlockInfo (LogicalNot, LogicalAnd/LogicalOr of tests, and != 0 or == 0 of the word, of word | high or of the 64-bit pair, whose high word is zero on one lane). That keeps the existing waterfall (entry EXEC, then the s_cmp_lg_u64 back edge) and a waterfall behind s_cbranch_scc0. A mask that may be empty now throws, as a constant lane 63 does.
  2. Select condition. The selector must be FindILsb32(mask) or Select(mask != 0, FindILsb32(mask), …) with the same mask. Selects and phis of selectors are no longer accepted.

New cases in verifySingleLaneVertexWave:

  • Your first case is comparedWaterfall: the exec & vcc waterfall after v_cmp_gt_u32 vcc, 4, v5 with no guard, which can enter with an empty mask. It was a passing case in 5e086eaac8 and now throws.
  • Your second case is conditionalLane: s_cselect_b32 s2, s2, -1 over s_ff1_i32_b32 s2, exec_lo, on s_cmp_eq_u32 of v_readfirstlane_b32 of the vertex index, which lowers to Select(c, FindILsb32(mask), -1). It throws.
  • guardedWaterfall (the same waterfall behind s_cbranch_scc0 on the SCC of its s_and_b64) and execLane (s_ff1_i32_b32 of EXEC) build without subgroup operations.
  • I ran the new tests against the selector proof of 5e086eaac8: they fail on comparedWaterfall and, with that case taken out, on conditionalLane.

On the RTX 4090, the 34 ctest entries listed in the description pass 3 times at 283e3e773a, and once more under VK_LAYER_KHRONOS_validation with no VUID- lines (layer inserted per the loader log). On the M5 Max, the 21 agc_shader_memory_tests entries pass 3 times at 283e3e773a. The branch still merges cleanly with main ca073ec. I updated the description to match.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked — new head, looks good

The updated selector walk and added negative cases address the prior test-coverage concern, and I found no blocking issue in the exact-head re-review.

What I ran

Reviewed head 283e3e773aecc5d9d744b223ff2d11331b11dd7e against PR base 0f302813cebfc09e3e0b6f8fced15262d186879e; the no-build precheck recorded a clean merge preview against current main ca073ec3ad0d766ea9f4658e418a5c977001a353. I inspected the selector proof, its control-flow and mask analysis, and the added verifySingleLaneVertexWave cases. I did not build or run the C++ tests locally.

python3 /root/.codex/skills/anyps5-pr-review/scripts/pr_snapshot.py 14068 --repo boykopovar/AnyPS5
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14068 --output-dir /tmp/anyps5-14068-review
gh api repos/boykopovar/AnyPS5/commits/283e3e773aecc5d9d744b223ff2d11331b11dd7e/check-runs

Results

Check Result
Diff and conventions Passed
Current-main merge preview Clean
Hosted Windows product job Passed
Hosted Ubuntu and Windows relinker jobs; ASan Passed
Author-reported focused Windows and macOS tests Passed, including the new refusal cases and reported negative controls; not independently reproduced
Hosted Linux job Skipped
Hosted macOS relinker jobs Queued at review time

Findings

Blocking

None found in this re-review.

Non-blocking

The host-side tests on Windows and macOS are author-reported; I did not independently reproduce them. The queued macOS relinker jobs and skipped Linux product job do not change the reviewed selector proof or the reported focused test evidence.

Sources

Not verified

I did not run a local build, Linux runtime or GPU test, or console behavior. The repository's hosted Linux product job was skipped.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 283e3e7 merged onto main 73f4f7e · tested 2026-10-31 19:10 UTC · 26 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,335 passed · 5 failed (0 new, 4 also fail on main, 1 unstable on main) · 48 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,388 of 3,072 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (878 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_graphics_maps_fallback 30.4 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_submit_progress: failed in 7 of the last 10 main runs
Failing on main too (4, not counted against this PR)
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (3 IDs in 387 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (387 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_passes, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, and 379 more
VUID-vkCmdCopyImage-srcImage-01548 (12 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_sampling, and 4 more
VUID-vkCmdCopyImage-srcImage-01551 (12 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_sampling, and 4 more
Skipped (48)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_msaa_dcc_compared_import_2: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_4: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_8: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_deferred: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or plat
Reproduce
git fetch origin 283e3e773aecc5d9d744b223ff2d11331b11dd7e 73f4f7e06e4f210a8c6570e335fd654dc0a86134
git checkout 73f4f7e06e4f210a8c6570e335fd654dc0a86134 && git merge --no-ff 283e3e773aecc5d9d744b223ff2d11331b11dd7e
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

…-register-selector

# Conflicts:
#	docs/dev/debt/shader.md
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 1, 2026
Tessellation evaluation programs without subgroups now take the one-lane
path from boykopovar#13807, so verifySingleLaneDomainWave checks that a
v_readlane_b32 at the lane v_readfirstlane_b32 takes from v5 throws there
and builds on a 32-lane tessellation evaluation subgroup.
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 1, 2026
@RNK123

RNK123 commented Nov 1, 2026

Copy link
Copy Markdown

Linux / AMD RDNA 4 (RADV) paired validation run for current head dcd3021fea merged cleanly onto main 0a148be963 (the PR checklist currently covers Windows NVIDIA and macOS).

Host & GPU: CachyOS Linux (7.3.1-1-cachyos), 12th Gen Intel Core i5-12400F, GCC 16.2.1 (Release, -DBUILD_TESTING=ON), AMD Radeon RX 9060 XT (1002:7590, RADV GFX1200, Mesa 26.2.5-1, Vulkan 1.4.354, subgroup 64), Khronos validation layer 1.4.363.

Environment: ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest --repeat until-fail:3 -V across the 38 focused CTest entries listed in the PR description (request_serializer, all 21 agc_shader_memory_tests entries including agc_shader_memory, the 13 agc_driver_* wave/lane/tessellation entries, and the 3 agc_tessellation_* entries). VK_LOADER_DEBUG=layer confirmed Insert instance layer "VK_LAYER_KHRONOS_validation", and neither log reports was not found but was requested by env var VK_INSTANCE_LAYERS.

Tree Passed (3x serial) Skipped Known Mesa 26.2.5 RADV bug (#5444) VUID- / SYNC-HAZARD-
main (0a148be963) 35 / 38 (3/3 each, 7.35 s total) 2 (agc_driver_ngg_vertex_wave_reduction, agc_driver_vertex_elected_atomic_max: GFX1200 has vertex subgroups and subgroup size 64) 1 (agc_driver_tessellation segfaults in libvulkan_radeon.so nir_opt_varyings) 0
main + #14068 (dcd3021fea) 35 / 38 (3/3 each, 7.05 s total) Same 2 Same 1 (#5444) 0 (0 new)

AI-assisted hardware test run (Antigravity).

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head dcd3021 merged onto main 3741ca9 · tested 2026-11-01 07:58 UTC · 17 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,423 passed · 5 failed (0 new, 3 also fail on main, 2 unstable on main) · 44 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,472 of 3,121 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (929 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 50.7 s, ⚠️ agc_driver_graphics_maps_fallback 36.0 s
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_submit_progress: failed in 6 of the last 10 main runs
agc_submit_progress_no_timeline: failed in 8 of the last 10 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (5 IDs in 480 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (480 tests): agc_driver, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, and 472 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_prepared_exports
VUID-VkShaderModuleCreateInfo-pCode-08737 (1 test): agc_driver_image_sample_derivatives
Skipped (44)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_deferred: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_main: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_fresh: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_f
Reproduce
git fetch origin dcd3021fea4f5504772906b15ec1321a39b0f127 3741ca9327246d0df81638726a986cef862b6db5
git checkout 3741ca9327246d0df81638726a986cef862b6db5 && git merge --no-ff dcd3021fea4f5504772906b15ec1321a39b0f127
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@oneandonlydean oneandonlydean self-assigned this Nov 5, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @frankea, following up on the earlier request about the negative side of the walk. The new head dcd3021fea pins more of the refusal (the compare-result waterfall and the conditional lane both fail as they should), but most rules of the lane walk are still not exercised by any test. In a copy of the branch I changed one rule at a time in OwnLaneSelectorWalk and ran agc_shader_memory_tests; every run below still passed:

  • ownWord, BitwiseAnd32: return true; instead of requiring either side to be proven
  • ownWord, BitwiseOr32/BitwiseXor32: && changed to ||
  • ownWord, SelectU32: && changed to ||
  • exactlyOwn, BitwiseAnd32 and SelectU32: && changed to ||
  • exactlyOwn, BitwiseOr32: the other operand's LowKind check replaced by true
  • ownWord, ballot extract: the word-index condition replaced by true

Only dropping the dominating-branch proof in nonEmpty (tested(...) replaced by true) fails a test. So an s_ff1 mask built from a ballot ANDed/ORed/XORed/selected with a word that is not the invocation's own (user data SGPRs, for example) would be accepted on a one-lane wave and read the wrong lane silently. Please add one rejected case per rule above (a ballot word combined with a non-ballot word through that op, before the s_ff1_i32_b64, expecting the same "register-selected lane" refusal), so each rule fails a test when it is weakened.

…with a word that is not the invocation's own
@frankea

frankea commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@oneandonlydean thanks, each of those rules now has a rejected case, in c999c741ac. Each mask is a ballot word combined with a word v_readfirstlane_b32 took from the vertex index, before s_ff1, and each throws v_readlane_b32 of a register-selected lane:

  • ownWord AND: an AND of two such words, tested for zero.
  • ownWord OR and XOR: EXEC ORed, and XORed, with one, tested for zero.
  • ownWord select: an s_cselect_b32 of EXEC or one, tested for zero.
  • exactlyOwn AND and select: EXEC ANDed with one, and an s_cselect_b32 of EXEC or 0, both untested.
  • ballot word index: a compare result in the low word and EXEC in the high word, tested by s_cmp_lg_u64 and by the SCC of s_and_b64.

The exactlyOwn OR rule could not fail a test as written: the other operand's LowKind check repeats what the mask's own LowKind walk already requires of every word in it. So that check is gone, and the function is now holdsOwnBit: an OR holds the invocation's bit when either side does. Its case is an OR of two compare results, neither tested.

I weakened each rule in turn (the AND accepting any word, && to || for OR, XOR and select in ownWord and for AND and select in holdsOwnBit, the holdsOwnBit OR accepting anything, any ballot word index, and tested(...) replaced by true), and each makes agc_shader_memory_tests fail at its own case. Tested on the Mac: agc_shader_memory_tests passes 3 times on c999c741ac, which merges cleanly with current main. The RTX 4090 runs in the description are from dcd3021fea; I'll rerun them there.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head c999c74 merged onto main 5299939 · tested 2026-11-06 15:09 UTC · 14 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,917 passed · 4 failed (0 new, 4 also fail on main) · 52 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,973 of 4,210 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (979 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 116.7 s
Failing on main too (4, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
web_library_assets
Validation IDs already present on main (9 IDs in 587 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (587 tests): agc_driver, agc_driver_address_draw_space_reuse, agc_driver_address_passes, agc_driver_address_passes_targets_split, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, and 579 more
VUID-VkShaderModuleCreateInfo-pCode-08737 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08739 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08741 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_prepared_exports
VUID-VkPipelineShaderStageCreateInfo-module-parameter (1 test): agc_driver_float16_unused_nan_payloads
VUID-VkPipelineShaderStageCreateInfo-pSpecializationInfo-06849 (1 test): agc_driver_float16_unused_nan_payloads
Skipped (52)
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_net_ctl_disconnected: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_device_capability: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_disabled: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_four_k: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_height_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_limit: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_malformed: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_width_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not a
Reproduce
git fetch origin c999c741ac87f7a67632cc15f85ad9ced2c6798f 5299939ecfa9e186e1eb457c6f4bd133bdb087c7
git checkout 5299939ecfa9e186e1eb457c6f4bd133bdb087c7 && git merge --no-ff c999c741ac87f7a67632cc15f85ad9ced2c6798f
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@frankea

frankea commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

The RTX 4090 rerun is done: on c999c741ac and on main 029463c the 38 ctest entries in the description pass 3 times in a row, and once more under VK_LAYER_KHRONOS_validation (SDK 1.4.363.0) with no VUID- lines (layer inserted per the loader log). I updated the description.

@oneandonlydean
oneandonlydean merged commit 6e18365 into boykopovar:main Nov 7, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants