shader: lower v_xad_u32 and v_log_f32 in the mesh frontend #3903
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3903"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-03T00:35:44Z.
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
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-03T01:20:53Z.
Review: APPROVED
Reviewed
f34f450eby reading the diff; not built or run. Then ran the mesh census of #3703 on mainf3ab02feewith 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.
f3ab02feev_xad_u32v_log_f320 gained, 0 lost; no other program changed. Next refusals:
v_xad_u32→mesh SAVEEXEC then arm depends on EXEC54,VCC branch without a whole-wave mask8,unbound numeric SGPR s74;v_log_f32→v_exp_f3223,v_med3_f3214.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.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.native_mesh_entry_registers_ir, which fails on main itself (#3906, fix in #3907), not this PR.Tests:
native_direct_mesh_check.pyaddsv-xad-u32(pins thexor/addpair and the POS0.x export),v-xad-unproven(refusal with an unbound source) andv-log-f32(pins opcode 23 and the export). They reach the two new allowlist entries. CI rannative_direct_meshat this head and it passed (run47004569559).Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T01:53:53Z.
Review: APPROVED
Independently reviewed
5774fb64. Both mesh forms use the existing ALU rules and retain the operand gates. MSVC Debugctest --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.