Repository navigation
shader: lower v_xad_u32 and v_log_f32 in the mesh frontend - #3903
Conversation
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed f34f450e by reading the diff; not built or run. Then ran the mesh census of #3703 on main f3ab02fee with and without this PR merged on top.
Verdict: approve. Both forms reuse existing shared rules and keep the operand gates; the census matches the claim. No MUST.
| Mesh census (6,685 distinct programs, first refusal each) | main f3ab02fee |
+ #3903 |
|---|---|---|
| translate | 2,046 | 2,046 |
v_xad_u32 |
66 | 0 |
v_log_f32 |
37 | 0 |
| moved to a later refusal | 103 |
0 gained, 0 lost; no other program changed. Next refusals: v_xad_u32 → mesh SAVEEXEC then arm depends on EXEC 54, VCC branch without a whole-wave mask 8, unbound numeric SGPR s7 4; v_log_f32 → v_exp_f32 23, v_med3_f32 14.
- SHOULD
v_xad_u32is not inalu_rules(gfx1013_compute_alu.inl), and it is not in the mesh three-source fallback either (gfx1013_direct_mesh.inl:2924-2926, next tov_add3_u32). Sosourcesis 0 for it anduniform_result(:2947) is always false: av_xad_u32of wave-uniform operands is never recorded as uniform. That is safe (a missed proof, not a wrong value), but a laterv_readfirstlane_b32or scalar use of such a result will refuse. Adding it besidev_add3_u32fixes that. - Checked:
v_log_f32takes the shared float rule (log2, DXIL opcode 23,gfx1013_direct_compute.inl:3976);v_xad_u32lowers toadd(xor(a, b), c)as in compute (:6071). Both stay behind the existing modifier and SDWA/DPP gates. - The Windows CI failure is
native_mesh_entry_registers_ir, which fails on main itself (#3906, fix in #3907), not this PR.
Tests: native_direct_mesh_check.py adds v-xad-u32 (pins the xor/add pair and the POS0.x export), v-xad-unproven (refusal with an unbound source) and v-log-f32 (pins opcode 23 and the export). They reach the two new allowlist entries. CI ran native_direct_mesh at this head and it passed (run 47004569559).
R0Y00
left a comment
There was a problem hiding this comment.
Independently reviewed 5774fb6. Both mesh forms use the existing ALU rules and retain the operand gates. MSVC Debug ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(native_direct_mesh|native_mesh_entry_registers_ir)$' passed 2/2. Removing only v_xad_u32 from the mesh allowlist made the first new XAD case fail with an unsupported mesh instruction at +0x24. Restored, the direct mesh fixture passed. This is an IR result and the updated baseline also passes the formerly red mesh entry case.
Problem
The 3 December work split on #3703 leaves A1 (small ALU) open:
v_xad_u32is the first refusal for 66 mesh programs,v_log_f32for 37, andds_swizzle_b32for 17. The two former already have lowerings in the shared compute ALU; the native mesh frontend simply did not admit them.Change
v_xad_u32(VOP30x345) to the mesh vector list. It takes three sources and lowers to(S0 ^ S1) + S2modulo 2^32, matching the compute frontend.v_log_f32(VOP10x27) to the same list. It evaluates DXIL Log (dx.op.unary.f32, opcode 23) through the shared float ALU.ds_swizzle_b32refused for now; a general lane-swizzle exchange is a separate design.Tests
tests/native_direct_mesh_check.pyadds source-built programs:v_xad_u32 v1, v0, s20, s21withs20 = 0x0000ffffands21 = 0x00ff0000emitsxor i32 %v0, 65535thenadd i32 %xor, 16711680, exported through POS0.x. An unbound third source keepsunbound numeric SGPR s24.v_log_f32 v1, v0emitscall float @dx.op.unary.f32(i32 23, ...)and exports the bitcast result.tests/docs_links_check.pypassed (258 files, 969 links).Coverage
On the issue census, the two forms clear the first refusal for 103 of the 120 A1 programs.
ds_swizzle_b32(17) stays in the bucket and will show the next refusal. This PR does not claim a new total; the census owner can rerun the capture.Refs #3703