Repository navigation
Fix the black world from the loop-cap barrier refusal and two merge slips - #506
Conversation
…dd its fused model
# Conflicts: # crates/victory-shader/src/emit/semantics_tests.rs
hackgods
left a comment
There was a problem hiding this comment.
Tested 4c87cf7 in-game on the M5 Pro (diagnostics build, same save as #497): the world renders lit (cell, player and yard; mean luma 44–47 at 200, 300 and 400 frames into the world). 34 compute shaders are refused, none of them at the loop cap. Main without this PR drew it white with 47 refused (15 at the cap). Thanks for picking this up.
One gap in the tests. cap_barriers_refused() is hard-coded to true in test builds (mod.rs +487–490), so the default that ships, barriers kept, is never exercised. Inverting the gate at lower.rs:4255 would pass every test. A per-thread override (like with_thread_ticket) plus a test both ways would cover it. Ours is an_s_barrier_after_a_capped_loop_is_kept_unless_the_switch_refuses_it on hackgods@9e68076 (lower/tests.rs), if it's useful.
Minor points:
cap_barriers_fromdoesn't trim, soVICTORY_CAP_BARRIERS=" 1"stays off.shader_cache.rs:677fails if the tests run withVICTORY_CAP_BARRIERS=1set.
Prepared with Claude Code.
DispatchX(x, y, z, flags) with flag 0x20 (the console's dispatch initiator bit "use thread dimensions") gives thread counts. The host ignored the flags and ran x * y * z groups, so a ray-tracing structure builder stage dispatched this way ran up to 64 times its threads and stored over the structures after its own. The host now runs the groups that hold the threads (div_ceil by the program's numthreads, kept in pipeline::Translated). Where the last group along x is a part of one, the dispatch takes a second form of the pipeline (pipeline::thread_limited), made on the first such dispatch: its shader translated again with emit::Options::thread_limits, under a cache key of its own (bit 9 of translation_build, after pragyaangaur#511's halves apart and pragyaangaur#506's cap barriers). In that form a compute program of one dimension whose lanes never wait for each other (no s_barrier, no barriers for narrow host waves, not in 32-lane halves that pass values, not in literal halves, whose group must take one path) reads a user-data word, emit::USER_DISPATCH_THREADS_X, the threads along x that run, and the lanes past it leave before anything else, so wave counts, first-lane reads and stores see only the lanes the console starts. The host sets the word after binding. Every other translation is as before, so programs no such dispatch reaches keep their DXIL; containers of one-dimensional compute programs are kept for the second translation (at most the ~22 MB all compute containers came to in a world run). The lowering's part is in lower/thread_limits.rs and lower/retry.rs, so lower.rs stays under the file limit. Each pipeline's first dispatch counted in threads is logged ("a dispatch counted in threads"), with a warning where a part of a group runs whole. VICTORY_THREAD_DIMENSIONS=0 takes the counts for groups again. Ported from DexNom/VIctory bc3cd4b0 (DexNom: the flag, and the lanes past the count leaving in two builder programs chosen by digest), as carried in the cool_fox fork's 810efe5 (RyanLockwoood/VIctory-cool_fox- LockWood). This tree has no builder detection, hence the form made on demand. Tests: halves_tests::the_lanes_past_a_count_of_threads_do_not_run (wave32 and wave64 on the host, counts 0 to 128 over two groups of 64); halves_tests::only_programs_whose_lanes_never_wait_leave_past_a_count_ of_threads (pragyaangaur#435's whole-wave retry included: a program it takes reads no count); thread_dispatch_tests::a_dispatch_counted_in_threads_runs_ only_those_threads, from a console container through State::dispatch_x: threads 70 to 127 write nothing, the pipeline's own translation reads no count (fails with VICTORY_THREAD_DIMENSIONS=0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DispatchX(x, y, z, flags) with flag 0x20 (the console's dispatch initiator bit "use thread dimensions") gives thread counts. The host ignored the flags and ran x * y * z groups, so a ray-tracing structure builder stage dispatched this way ran up to 64 times its threads and stored over the structures after its own. The host now runs the groups that hold the threads (div_ceil by the program's numthreads, kept in pipeline::Translated). Where the last group along x is a part of one, the dispatch takes a second form of the pipeline (pipeline::thread_limited), made on the first such dispatch: its shader translated again with emit::Options::thread_limits, under a cache key of its own (bit 9 of translation_build, after pragyaangaur#511's halves apart and pragyaangaur#506's cap barriers). In that form a compute program of one dimension whose lanes never wait for each other (no s_barrier, no barriers for narrow host waves, not in 32-lane halves that pass values, not in literal halves, whose group must take one path) reads a user-data word, emit::USER_DISPATCH_THREADS_X, the threads along x that run, and the lanes past it leave before anything else, so wave counts, first-lane reads and stores see only the lanes the console starts. The host sets the word after binding. Every other translation is as before, so programs no such dispatch reaches keep their DXIL; containers of one-dimensional compute programs are kept for the second translation (at most the ~22 MB all compute containers came to in a world run). The lowering's part is in lower/thread_limits.rs and lower/retry.rs, so lower.rs stays under the file limit. Each pipeline's first dispatch counted in threads is logged ("a dispatch counted in threads"), with a warning where a part of a group runs whole. VICTORY_THREAD_DIMENSIONS=0 takes the counts for groups again. Ported from DexNom/VIctory bc3cd4b0 (DexNom: the flag, and the lanes past the count leaving in two builder programs chosen by digest), as carried in the cool_fox fork's 810efe5 (RyanLockwoood/VIctory-cool_fox- LockWood). This tree has no builder detection, hence the form made on demand. Tests: halves_tests::the_lanes_past_a_count_of_threads_do_not_run (wave32 and wave64 on the host, counts 0 to 128 over two groups of 64); halves_tests::only_programs_whose_lanes_never_wait_leave_past_a_count_ of_threads (pragyaangaur#435's whole-wave retry included: a program it takes reads no count); thread_dispatch_tests::a_dispatch_counted_in_threads_runs_ only_those_threads, from a console container through State::dispatch_x: threads 70 to 127 write nothing, the pipeline's own translation reads no count (fails with VICTORY_THREAD_DIMENSIONS=0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Reject --jobs 0 in both translation modes before starting workers. - Cover the CLI exit and diagnostic without including title files.
Issue #497 (4TheDoctor, M3 Max) and hackgods (M5 Pro) bisected a black world on main to #408: its rule refuses 15 to 37 compute shaders (the tile-list, lighting, temporal anti-aliasing and average luminance programs) because a lane may leave at a capped loop's iteration limit while the others wait at an
s_barrier. Keeping those barriers, as before #408, draws the world on both Macs without hangs in their runs. This makes the refusal opt-in withVICTORY_CAP_BARRIERS=1(documented in docs/macos.md), and the shader cache key follows the switch.Two slips from the same round of merges are fixed too. #435 or #440 made
halves_testsbuild on every host, but it uses the Windows-only validator, socargo test -p victory-shaderdid not build on a Mac. It is Windows-only again. And #406 made the legacy multiply-add fused, as RDNA 2 decodesv_mad_legacy_f32andv_mac_legacy_f32, but the reference model insemantics_testsstill composed a multiply and an add, soarithmetic_matches_the_hardwarefailed on any machine with a hardware GPU (CI has none, so it stayed green). The model now follows the fused rule, and the test passes under Wine with D3DMetal.Checks: native workspace tests, clippy for both feature sets on the Windows target, the asset policy, and the victory-shader tests under Wine.
A third slip from #440 is fixed here as well, found by hackgods and the #435 rebase: with the predication on, a
v_writelane_b32into a lane that the block leaves inactive was lost in the merge after the block (the lane read 0 where the console reads the written value), and nothing in CI notices because the test that shows it needs a hardware GPU. Such a write is now refused in a predicated block, and the whole-wave retry of #435 takes the program, which gives the console's value again.