shader: lower v_rcp_iflag_f32 in direct Compute and Pixel DXIL #3256
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3256
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3254"
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?
@legacy-code-archaeologist on GitHub · 2026-11-28 01:59 UTC · original
legacy-code-archaeologist:shader/direct-rcp-iflag-f32→main· +317 −2 · 7 files · 1 commits · merged 2026-11-28 04:14 UTCLower RDNA 2
v_rcp_iflag_f32(VOP1 0x2b,VOP3 0x1ab, SDWA, DPP16) identically tov_rcp_f32(1.0f / x) in the direct Compute and Pixel DXIL path (#2935).Fixes #3254
Refs #2935
Summary
src/gfx1013_compute_alu.inl: Addedv_rcp_iflag_f32toalu_rules(1.0 / {0}), enabling both ALU rule checks and DPP lowering.src/gfx1013_compute_opcodes.inl: Addedcase 0x2b: return "v_rcp_iflag_f32";.src/gfx1013_compute_native.cpp: Added"v_rcp_iflag_f32"to the SDWAfloatsset.src/gfx1013_direct_compute.inl: Loweredv_rcp_iflag_f32alongsidev_rcp_f32(fdiv float 1.000000e+00, a) inDirectCompute::float_alu().tests/native_rcp_iflag_check.py&tests/cmake/native_rcp_iflag.cmake: Added16Compute +4Pixel DXIL equivalence cases (VOP1 VGPR/SGPR/inline/literal, VOP3 abs/neg/clamp/omod, SDWA, DPP16) and2refusal controls (controls,compute_hardware,pixel_warp,pixel_hardware).docs/experiments/native-rcp-iflag-f32.md: Documented verification, sensitivity mutants, and limits.Verification
Host: Windows 10.0.26100,
devpreset, DXC10.0.26100.0.cmake --build --preset dev --target compile_dxil native_store_replay offscreen_check native_compute_ir_dump: passed.ctest --preset dev --no-tests=error -R '^native_rcp_iflag_' -V:native_rcp_iflag_controls: Passed (16Compute +4Pixel cases compiled identically tov_rcp_f32DXIL;2refusals matched).native_rcp_iflag_pixel_warp: Passed (Microsoft Basic Render Driver,4quad draws matched).native_rcp_iflag_pixel_hardware: Passed (NVIDIA Quadro M1000M,4quad draws matched; debug layer unavailable).native_rcp_iflag_compute_hardware: Skipped (77,Intel(R) HD Graphics 53031.0.101.2111requires SM 6.6 with wave32).ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure: 68/68 passed (0skips).drop_direct_iflaganddrop_sdwa_iflagboth failednative_rcp_iflag_controls(rc=8).python -B tests/docs_links_check.py: passed (131Markdown files,631links).AI-assisted.
github-bot referenced this pull request2026-11-28 02:20:33 +00:00
@pigalot on GitHub · 2026-11-28 04:13 UTC · original · approved these changes
I reviewed
f6be56c9merged overmainff524dff. The merge is clean (treed5a1f554) andgit diff --cached --checkis clean.What I traced. RDNA 2 VOP1
0x2bisv_rcp_iflag_f32, and VOP30x1abis the same opcode plus0x180. It differs fromv_rcp_f32only in which exception flag it raises, so lowering it the same way asv_rcp_f32is right.The direct paths:
vop1_namesingfx1013_isa_tables.inl;float_alunow gives it thev_rcp_f32fdiv float 1.0, a;floatsset gives it float source modifiers;alu_rulesentry is what admits DPP (gfx1013_direct_compute.inl:3761).native_rcp_iflag_controlscompiles each case as both0x2band0x2a, and requires identical DXIL.What I ran. I built
compile_dxil native_store_replay offscreen_check native_compute_ir_dump native_global_srv_heap_replay native_compute_manifest_reasonsindevandrelease, then ran:_warptests skip with 77, the same WARP capability skips as onmain, in both Debug and Release/O2.native_rcp_iflag_controlsandnative_rcp_iflag_pixel_warppass.native_rcp_iflag_compute_hardwareruns here (it skipped on your Intel adapter), as do the DPP, DPP8 and SDWA neighbours.Mutants. Each was rebuilt in
dev, then I ran the fournative_rcp_iflag_*tests:float_aluno longer lowersv_rcp_iflag_f32floatssetalu_rulesentry removedrsq(dx.op 25)mnemonic()case 0x2bremoved (gfx1013_compute_opcodes.inl)alu_rulesexpression"2.0 / {0}"Restored and rebuilt afterwards;
git diff --quietis clean.Non-blocking: the legacy HLSL profile is enabled too, without a test. The two survivors only reach the legacy
gfx1013-compute-wave32@profile. For a non-direct request, the decoder names an opcode only throughmnemonic(), andEmitwrites HLSL from the rule's expression. Onmain, that profile has neither for0x2b, so it refusesv_rcp_iflag_f32. This PR adds both.I ran the controls' VOP1/VOP3 cases on
gfx1013-compute-wave32@0. SDWA and DPP are refused there, as for any opcode. The0x2band0x2aDXIL are identical, so the behaviour is right. But with the expression mutated to"2.0 / {0}", 12 lines of that DXIL change and no registered test fails. The controls''fdiv float 1.000000e+00,'check would not carry over as-is: on that profile, DXC folds the constant inputs, and nofdivis left.Two ways to cover it:
controls;0x2bout ofmnemonic()(the direct paths don't need it), so the legacy profile stays refused, and say so in the description.Verdict: approve on
f6be56c9.Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and WARP, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32; I did not check the debug-layer status.
CI:
Build and test on Windowspasses onf6be56c9.This reply was AI-assisted.