shader: multiply all three PSV0 thread dimensions and keep output maxima in mesh_stride #3304
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3304
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3304"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@fuzeofficlal on GitHub · 2026-11-26 16:34 UTC · original
fuzeofficlal:fix/mesh-stride-3d-threads→main· +302 −15 · 1 files · 1 commits · openSummary
Fix two bugs in
mesh_stridecomputation for console mesh shaders incrates/victory-shader/src/emit/mod.rs:[numthreads(X, Y, Z)]truncated toNumThreadsX: Console mesh shaders receiveSV_GroupID.xinv5(Input::MeshGroup) multiplied bymax(threads, max_vertices, max_primitives)and divide by that stride to recover the group index. FromPSV0runtime info v2+ (info_size >= 48, perPSVRuntimeInfo2andemit/container.rs),NumThreadsX,NumThreadsY, andNumThreadsZlive at offsets4 + 36,4 + 40, and4 + 44.emit_withpreviously read onlyNumThreadsX, so valid 2D/3D HLSL mesh shaders such as[numthreads(8, 8, 1)]or[numthreads(4, 4, 4)](64 threads with e.g.max_vertices = 32, max_primitives = 32) gotmesh_stride = 32instead of64, corruptingSV_GroupID.xfor every non-zero group.PSV0fallback skipped output maxima: WhenPSV0was absent or hadinfo_size < 48,threads.map_or(ms.threads, |t| t.max(ms.max_vertices).max(ms.max_primitives))returned rawms.threadswithout taking.max(ms.max_vertices).max(ms.max_primitives), under-multiplyingSV_GroupID.xwhenevermax_verticesormax_primitivesexceededms.threads(e.g. 32 or 64 threads with 64–256 vertices/primitives).Changes
mesh_stride(c: &Container, ms: &crate::native::MeshIo) -> u32incrates/victory-shader/src/emit/mod.rsto multiplyNumThreadsX * NumThreadsY * NumThreadsZ(with overflow and non-zero checks), fall back toms.threads, and always apply.max(ms.max_vertices).max(ms.max_primitives).mesh_stride_multiplies_psv_thread_dimensions_and_applies_output_maximaunit tests covering 1D partial-wave, 2D, 3D (PSV0v3), Z-only, output-dominated, missing/pre-v2PSV0, zeroed, and overflow cases.mesh_group_stride_handles_multidim_psv_and_output_maxima_fallbackend-to-end test validating DXIL (dxil.dll), checkingmul i32 ..., 64viadxc -dumpbin, and dispatching 2 mesh groups on hardware + WARP (where group 1 draws only whenv5 / 64 == 1). Also disambiguatedump_dxil's temporary filename by thread ID so parallel tests usingdump_dxildo not race on the same temp file.Verification
dxc -dumpbinemitted%5 = mul i32 %4, 32for[numthreads(8, 8, 1)], and the hardware mesh draw failed with0of256texels lit for group 1.emit::tests(dev +--release, includingdxil.dll,dxc -dumpbin, hardware GPU, and WARP draws),cargo clippy --workspace --all-targets --locked -- -D warnings,cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, andcargo test -p xtask --locked policy::tests::repository_passes_policyall pass.@Dukestar69 on GitHub · 2026-11-26 16:47 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64:
PSVRuntimeInfo2thread dimensions (NumThreadsX * NumThreadsY * NumThreadsZ) viachecked_mulwith fallback toms.threads, and always taking.max(ms.max_vertices).max(ms.max_primitives)even on fallback, cleanly fixes 2D/3D mesh group strides.cargo test -p victory-shader --lib emit::tests:: -- --test-threads=1: 19 passed, 0 failed (includingmesh_stride_multiplies_psv_thread_dimensions_and_applies_output_maximaandmesh_group_stride_handles_multidim_psv_and_output_maxima_fallback).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
88424ff9dato55f44b94cf@fuzeofficlal on GitHub · 2026-11-26 16:59 UTC · original
Re-pushed identical tree (
88424ff9->55f44b94) to re-trigger CI after an unrelated flaky timing failure invictory-gpu::frame::tests::waits_end_on_ticks_and_count_frames.@oni-swr on GitHub · 2026-11-26 18:24 UTC · original
WARP verification of #3304 (synthetic tests only, no game files, no physical GPU).
Commits
88424ff9da1b4c10bed4c0a59de474f0d2a5d4d6. The PR was re-pushed with an identical tree as55f44b94while I was testing;git diff 88424ff9 55f44b94is empty, so the results apply to both.63bcca43c6a00a758510398fa43096ce7e4f7df0Environment
d3d10warp.dll10.0.26100.9818,dxil.dll1.8.2502.11 (Windows SDK 10.0.26100.0 x64, on PATH next todxc.exe)VICTORY_WARP=1,VICTORY_D3D12_WARP=1. Invictory-shader,VICTORY_WARP=1makes the "hardware" leg ofHost::newuse WARP too, so the physical GPU was never used.New tests, head vs control
Control =
63bcca43with only the PR's test changes applied. Itsmesh_strideis the old logic moved into a function with the PR's signature, so the unit test compiles.emit::tests::mesh_stride_multiplies_psv_thread_dimensions_and_applies_output_maximaleft: 32, right: 64)emit::tests::mesh_group_stride_handles_multidim_psv_and_output_maxima_fallback2D [numthreads(8,8,1)]: expected group 1 to light all 256 texels, got 0)The other mesh tests (
diff_tests::translated_mesh_shaders_draw_as_pc_ones,io::tests::mesh_inputs_and_primitive_export, threenative::tests::*mesh*) pass in both: 5 passed on the control, 7 passed on head.Full
cargo test -p victory-shader --libon head: 300 passed, 4 failed, 3 ignored (307 total, 2264 s).The 4 failures are the same on unmodified
63bcca43, so they are not from this PR:emit::synthetic_tests::permutes_read_the_lane_named_and_zero_from_lanes_left_out(hardware: no pipeline for a wave of 32)emit::synthetic_tests::permutes_mask_high_address_bits_and_divergent_branches(same)emit::synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_number(same)emit::synthetic_tests::gathers_at_a_level_match_the_hardware(lane 4 gather[66,67,35,34]vs[65,66,34,33])I ran only the
synthetic_tests::module on unmodified main: 7 passed, 4 failed, the same four.Not tested
xtask policy.dxc -dumpbinmul i32 ..., 64check is in the test.dxc.exewas next todxil.dll, so it should have run, but I did not confirm that separately.AI use: Claude Code (Claude Sonnet 5.5)
@evan-kolberg on GitHub · 2026-11-26 18:53 UTC · original
I ran fuzeofficlal’s exact #3304 commit on Mac main
bf99e728with an Apple M4 Pro and D3DMetal 4.0 beta 3. In matched generated draws, all three cases (2D, 3D, and legacy PSV0 fallback) went from 0/256 to 256/256 exact pixels. Stride commitA second fixture exercised both changes in one draw. The legacy mesh declared 128 vertices and primitives across 32 native threads, and all 56 channels remained live. Both builds linked it at 30,720 aligned bytes using #397’s aligned eligibility and #401’s repacking. Adding the stride change took group 1 from 0/256 to 256/256 exact pixels. evan-kolberg’s #397 commit · gdemontalivet’s #401 commit
Prepared and tested with Codex.
@borosf on GitHub · 2026-11-26 19:03 UTC · original
Independent local verification on Windows 11 x64, Intel Arc B580 12 GB (12 cores), at this PR's head
55f44b9:Result: victory-shader lib: 302 passed / 2 failed (both known baseline); both new mesh_stride PSV0 tests passed.
Both clippy runs exit 0 (-D warnings, both feature sets). The B580 baseline failures pristine main also hits are: victory-gpu descriptor::host::tests::dynamic_slots_are_held_until_released + memory::tests::lists_share_a_table_and_copies_keep_their_views (#1744/#1829); victory-shader emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros + emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products. No PR regressions.
Synthetic tests only; no game data used. Full log kept locally. — borosf
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 19:21 UTC · original
I checked the stride fix with the direct-grid indexing follow-up for #2624.
0908871retains both exact PR heads (22f5207and55f44b9).The additional test uses original PSV0 dimensions [2, 3, 1] and dispatches [3, 2, 4] and [2, 3, 4] through the normal VIctory guest-list entry point. The translated shader increments a buffer at the guest’s scaled group index. Both grids wrote exactly six increments at each of the 24 expected indices
0, 6, …, 138, with all other counters zero. The 1D and zero-axis cases also passed. I repeated the readback and your stride draw test three times on app-local Agility 1.620.2 / WARP 1.0.22. Full GPU suite 249 passed with one ignored, and both strict all-target Clippy configurations passed.This checks the combination on WARP, using the direct-grid candidate’s X-fastest ordering. If you take the added test or grid follow-up, please preserve the Git author or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>when folding it into another commit.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.