Repository navigation
Shaders: narrow mesh output bounds from GS_ALLOC_REQ M0 analysis (#201) - #1385
Ctrl-Alt-Haze wants to merge 2 commits into
Conversation
catminou4
left a comment
There was a problem hiding this comment.
Mesh output bounds from GS_ALLOC_REQ M0 analysis. The ScalarBound interval analysis over SOP defs is conservative by construction: phi joins widen and bail to TOP after 4 updates, unknown producers stay TOP, and bounds are only trusted when EVERY s_sendmsg/s_sendmsgalloc site proves vertex/primitive counts <= 256 (MAX_HOST_MESH_COUNT, the D3D12 mesh limit); any unproven site keeps the declared maxima. slice_range_val extracts the M0[9:0]/M0[21:12] fields through the def-use chain with cycle guards. The mesh_tests cover the negative cases (unbounded dynamic M0 keeps full bounds, multiple alloc sites take the max and require all proven). +3 macOS tests green. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p victory-shader --locked. Shader execution tests (valu_tests/host/diff_tests) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 99 passed, 0 failed.
|
@catminou4 Thanks for reviewing and testing on macOS arm64! |
|
Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at Not covered here: whether this clears the 53 programs from #201 that #459 left at 53. That needs the title's |
|
@marquezinii Thanks for verifying |
|
Rebased onto upstream Verified locally on Windows 11 x64 / NVIDIA GeForce RTX 5070 Ti + WARP:
|
9e77b5c to
3e630d3
Compare
|
Automated triage for the maintainers. Proposed close: no measured value. This adds about 1,100 lines to On your reply: thank you for running the census and citing the M0 layout sources. With none of the 71 failures cleared, the analysis does not pay for its size, and closing it as you suggest is the right call. The M0 layout references would help in #586. This pull request will be closed in 48 hours unless the author pushes a change or a maintainer removes the Generated by Claude Code |
|
Thanks for the detailed triage review. I ran the clean-room
Addressing your three points:
Since |
Summary
Fixes #201 (mesh shaders exceeding the 32,768 B DXIL output limit because declared
PSV0max_vertices/max_primitivesbounds remain at worst-case 256/256 instead of the provens_sendmsg(MSG_GS_ALLOC_REQ)M0allocation bounds).(Note: #586 has merge conflicts and touches 22 files; this PR is a focused 3-file implementation cleanly on
ffe310eb.)Changes
crates/victory-shader/src/emit/lower.rs:ScalarBoundfixpoint analysis +slice_range_val((m0 >> shift) & 0x3FF) acrosss_mov_b32,s_movk_i32,s_or_b32,s_lshl_b32,s_lshr_b32,s_and_b32,s_bfe_u32,s_min_u32,s_max_u32,s_add_*,s_sub_*,s_cselect_b32,s_cmov_b32/s_cmovk_i32, andPhijoins (with widening on loop phis).shader::Mesh.max_vertices/max_primitivesto the conservative max across alls_sendmsg(GS_ALLOC_REQ)sites only when every site is proven<= 256(clamped toms.max_vertices/ms.max_primitivesand256; left unchanged when 0 sites or any site is unproven).M0lowering forsetMeshOutputCounts(min(v, max_v), min(p, max_p))(inline at block-0GS_ALLOC_REQ, or pure-SOP materialization hoisted to block-0 end for lane-0 guardedGS_ALLOC_REQ), plusmesh_export_limits(MeshExportLimit::Const/Dynamic) somesh_export_guardchecksthreads > emitted_limiteven whenmesh.max_*stays unnarrowed.s_cmov_b32/s_cmovk_i32lowering insop(). Zerounsafeblocks added.crates/victory-shader/src/emit/mod.rs&crates/victory-shader/src/emit/mesh_tests.rs:dxil.dllrejection without narrowing vs DXIL validation + RTX 5070 Ti & WARP Mesh Shader PSO +DispatchMeshexecution for literalM0,s_min_u32-bounded dynamicM0, lane-0 guarded dynamicM0,s_and_b32/s_bfe_u32/s_cselect_b32/Phinarrowing, mixed unbounded-vertex + small-constant-primitive export guarding, and negative soundness controls (unboundedM0,& 0x3FF, unboundedPhi, clamping, multi-site max, fail-open when any site is unproven).Verification
32.0.16.2135), WARP (VICTORY_WARP=1/VICTORY_D3D12_WARP=1), Windows SDK10.0.26100.0dxil.dll, Rust1.98.1, baseffe310eb.cargo xtask policy:155 files okcargo clippy --workspace --all-targets --locked -- -D warnings(default &--all-features): passedcargo test --workspace --locked:349 passed, 0 failed, 6 ignored(victory-shader127/1 ign)cargo test -p victory-shader --features host --locked(RTX 5070 Ti):127 passed, 0 failed, 1 ignoredVICTORY_WARP=1 cargo test -p victory-shader --features host --locked(WARP):127 passed, 0 failed, 1 ignoredcargo test -p victory-gpu --features diagnostics --locked&VICTORY_D3D12_WARP=1:53 passed, 0 failed, 1 ignoredeachrustfmt --edition 2024 --checkon modified files: zero diffs onmesh_tests.rsand all added/modified lines inlower.rsandmod.rs.AI use: Written and verified locally with an AI coding swarm (
gemini-4-hydrogen-high), then independently audited and tested on RTX 5070 Ti + WARP.