startup: lower v_cvt_off_f32_i4 in gfx2hlsl #2444
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2452"
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 triggered02 on 2026-11-25T17:08:49Z.
Lowers gfx1013
v_cvt_off_f32_i4(VOP10x0eand VOP3A_e640x18e) intools/startup/gfx2hlsl.py.### What changed-tools/startup/gfx2hlsl.py: -VEC_U_TO_F: added'v_cvt_off_f32_i4': (1, '(float(int({0} << 28) >> 28) * 0.0625)')(bits[3:0]as signed 4-bit two's complement[-8, +7]scaled by1/16to[-0.5, +0.4375]). -Stage.lower: added'v_cvt_off_f32_i4'to thelow16_only=Truetuple. -UNIFORM_VALU: added'v_cvt_off_f32_i4'. -Stage.sdwa&check_encoding: keep SDWA forms and VOP3AABS/NEGsource modifier bits refused.-tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py,CMakeLists.txt, anddocs/experiments.md.### Measured checks (2be3ae93onorigin/main82bb67ef)-tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py(pure Python): PASS — 12 decode vectors, 820 nibble/garbage/modifier evaluations (all 16 nibbles0..15, upper-bit garbage0x12345678/0xfffffff8,clamp/mul:2/mul:4/div:2), 7 constant-source checks, 5low16_onlychecks, 5UNIFORM_VALUchecks, 11 encoded-byte refusals + 4 arity refusals, and 2 unlowered controls.-tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py draw <dxc> <offscreen_check> warp <fxc>(Microsoft Basic Render Driver1414:008c,10.0.26100.9818): PASS — 14/14 draws matched (FXCps_5_1+ DXCps_6_0), and 6/6 mutated draws read their expected mutated words.- 66/66 parallel checks (63startup_gfx2hlsl_*,startup_translator_check.py,docs_links_check.py,bidi_controls_check.py) andgit diff --check: PASS.- 6 fail-first mutations ontools/startup/gfx2hlsl.py: all 6 caught (exit 1).### Not established- AMD hardware was not exercised. The physical-GPUhardwaredraw has since been measured by @Makto94 on an NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.2101), Windows 11 build 26300.9974, MSVC 19.44.35230,devpreset, serial-j1runs:startup_gfx2hlsl_cvt_off_f32_i4_hardwarepassed withdebug_errors=0 debug_warnings=0, 0 capability skips, and the hardware log reads14 draws matched, 6 mutated draws read their mutated words, so the mutated draws fail as intended (report: https://github.com/R0Y00/Xbox2Windows/pull/2452#issuecomment-7170698276).AI-assisted (Gemini).DPP16 quad broadcast
eeds_sm6. This is intended � the merge base refused every form of the op because the op itself was unsupported. ests/startup_gfx2hlsl_cvt_off_f32_i4_check.py now pins it: lane 2 and lane 3 broadcasts, the shader-model bump, the nibble sign-extend on the broadcast value, and refusals for a non-broadcast and mixed quad_perm, a partial
ow_mask, ound_ctrl:0, an entry mask not proven whole-quad, and a vertex stage.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T17:12:52Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
e8bd6cb227ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T17:09:00Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
e8bd6cbℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T17:21:21Z.
Five mutations: four caught, and the survivor is the one that should survive here
Baseline:
startup_gfx2hlsl_cvt_off_f32_i4_check: all controls passed, exit 0.0.0625→0.125int(x << 28) >> 28→<< 27) >> 27(five-bit extension)(x << 28) >> 28)v_cvt_off_f32_i4from thelow16setword0 & 0x700 or word1 & 0xe0000000→word0 & 0x100 or word1 & 0x20000000I flagged the identical mask on #2450 an hour ago as a gap, so I want to be explicit that it is not one here.
v_cvt_off_f32_i4is a one-source VOP1 instruction:w0[10:8]carries ABS for src0/src1/src2, but bits 9 and 10 have no source to modify, and the same holds forw1[31:29]beyond bit 29. Narrowing the mask therefore cannot accept a modifier the instruction can carry — the mutation is behaviour-preserving, and the wide mask is a stricter check on reserved bits rather than a covered case. On #2450 the same constant guards three sources, which is why it needed per-slot coverage there.That difference is worth one line in the comment, by the way:
0x700on a one-source instruction reads as if three sources were being handled.What the fixture pins that I did not expect
0.0625and shift-width mutations both die, which means the table is checked value by value rather than by one representative.low16set membership separately from the arithmetic: removingv_cvt_off_f32_i4from('v_cvt_f32_f16', 'v_cvt_f32_ubyte0', 'v_cvt_f32_ubyte1', …)fails the check, so thelow16_only=Truemarking is not incidental to the arithmetic cases._e320x0eand_e640x18e) with their ownunlowered controllines, so the acceptance demonstrably comes fromVEC_U_TO_Fand not from a path shared with something else.One documentation nit worth fixing before merge
The doc says the result is "signed two's-complement bits
[3:0]in[-8, +7]scaled by1/16, producing exact binary32 steps in[-0.5, +0.4375]". That is the ISA'soffconversion written as plain scaling, and it is correct — but a reader who knows the instruction by name will expect a- 8term and go looking for it. Saying explicitly that the offset is inherent in the signed nibble (there is no separate bias to subtract in this encoding) would save that reader the trip; I checked the arithmetic against the table and it matches, so this is wording rather than a defect.AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T17:37:51Z.
Updated in
f2082044(rebased cleanly as a single commit ontoorigin/main1a0e506d):startup_gfx2hlsl_cvt_off_f32_i4_controlsto theprtest preset regex inCMakePresets.json, and addedtests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyto.github/workflows/windows.yml(python-linux) andAGENTS.md.v_cvt_off_f32_i4_e64is a 1-source instruction whose active modifier bits arew0[8]/w1[29]while0x700/0xe0000000also guards the unusedsrc1/src2modifier bits.[3:0]in[-8, +7], with no separate- 8bias term subtracted).Re-ran
startup_gfx2hlsl_cvt_off_f32_i4_check.py(pure Python + WARP FXCps_5_1& DXCps_6_0),run_checks_parallel.py(66/66 passed),startup_tools_lint_check.py, andgit diff --checkatf2082044.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T17:12:53Z.
Code review location:
CMakeLists.txt; line 3111The new controls are registered with CTest here, but neither PR CI path runs them:
ctest --preset prfilters to the names inCMakePresets.json's PR regex, which excludes this test, and the explicit LinuxRun Python checkslist in.github/workflows/windows.ymlalso omits this script. Consequently, the new decoder, lowering, and provenance checks are only exercised by the full non-PR test run; please add the script to the Linux list or include this control test in the PR preset.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-25T18:17:07Z.
Hardware run and Windows 11 MSVC build at head
f2082044.Environment: Windows 11 Pro build 26300.9974, Debug (
devpreset), MSVC toolset 14.44.35207 (cl 19.44.35230.0), driver 32.0.16.2101. The hardware test printsadapter=NVIDIA GeForce RTX 3070 Ti vendor=10de device=2482andbackend=hardware debug_layer=enabled, withdebug_errors=0 debug_warnings=0. The runs were serial (-j1).Build:
cmake --build --preset devexited 0. This PR changes no C++ source.Tests:
ctest --preset dev --no-tests=error -j1 -R 'startup_gfx2hlsl_cvt_off_f32_i4' -E 'hardware' -V: 2/2 passed (startup_gfx2hlsl_cvt_off_f32_i4_controls,_warp).ctest --preset dev --no-tests=error -j1 -R 'startup_gfx2hlsl_cvt_off_f32_i4_hardware' -V: 1/1 passed. 0 capability skips (77).The hardware test prints
hardware: 14 draws matched, 6 mutated draws read their mutated words. The mutated draws fail as expected, so the check can fail.The PR body lists as not established: "Physical GPU
hardwaredraw was not run locally (WARP only)." This run adds that measurement.Not covered by this run: AMD hardware; only this fixture was run, and only the draw (pixel shader) path of the translated shader.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T18:45:41Z.
Thanks — that closes the
hardwaregap the description listed. I have recorded it in the PR body (the "not established" bullet now says the physical-GPU draw was measured on your RTX 3070 Ti with driver 32.0.16.2101, Windows build 26300.9974, MSVC 19.44.35230,devpreset,debug_errors=0 debug_warnings=0, 0 capability skips, and links this comment). AMD hardware remains unexercised, which I left as a limit rather than a pass.One thing did change after your run:
mainmoved and this PR was CONFLICTING againstb976e8bc. I rebased it, so the head is nowce625973(wasf2082044). The only conflict was theprtest-preset regex inCMakePresets.json—mainhad addedstartup_indirect_mesh_lease_warp_dualand this branch addsstartup_gfx2hlsl_cvt_off_f32_i4_controls; both are now in the same alternation, and the file parses.git patch-idof the replayed commit is identical tof2082044, so the lowering and the check are the same code your run measured.Re-ran after the rebase:
tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyexit 0,startup_translator_check.pyexit 0,docs_links_check.pyexit 0 (470 links),git diff --checkclean. I did not re-run hardware once625973— my local adapter is a GTX 1660 SUPER, so your run on the pre-rebase head is the hardware evidence; if you want to repeat it once625973it should behave identically, but I have not measured that head on hardware.Nothing else in the PR changed, and the description now matches
ce625973.Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T19:22:34Z.
Review: COMMENTED
Review of head
ce625973. I found no P1 or P2 issues. It needs a rebase, and there's one question about DPP; I'll merge once those are settled and CI is green.What I checked
Semantics against RDNA 2
V_CVT_OFF_F32_I4:float(int(x << 28) >> 28) * 0.0625readsS0[3:0]as a signed nibble (−8 to +7) and gives −0.5 to 0.4375 in steps of 1/16, the same formulapixel_aotuses./Gis/-Giscan't change it.clampwith omod emitssaturate((…) * 2.0), which scales before clamping, the hardware order.Inline float constants lower as their bit patterns, matching LLVM's i32 source type:
1.0becomes0x3f800000u(nibble 0), and0.15915494becomes0x3e22f983u(nibble 3).Refusals:
Uniformity: the
low16_onlyandUNIFORM_VALUmemberships are sound, because the op reads only bits [3:0] of its own lane.Cache revision:
x2w-startup-shader-14and14csare unchanged. I replayed the 844 distinctPipeline/ComputePipelineinputs built by 71 passing gfx2hlsl checks through the merge base and this head:v_cvt_off_f32_i4.So no bump is needed.
Commands executed (Windows 11 build 26300; AMD Radeon RX 9070 XT 1002:7550, driver 32.0.32029.2010, debug layer enabled; WARP 10.0.26100.9818; DXC/FXC from SDK 10.0.26100; LLVM 15.0.7)
…_controls…_warpdebug_errors=0…_hardware(RX 9070 XT)There were no capability skips. This is the AMD hardware run @triggered02 left as a limit, measured at the rebased head
ce625973; @Makto94's RTX 3070 Ti run was onf2082044.Negative control
Each mutation is one line of
tools/startup/gfx2hlsl.py, applied alone and reverted. The draws ran on WARP and the RX 9070 XT, and the expected words arebf000000,bf000000,3ee00000,bd800000:820 … evaluations match RDNA2 ISA: MISMATCH3f000000,3f000000,3ee00000,3f700000(x & 15) − 8TypeErrorin the CPU evaluator00000000,00000000,bd800000,3ee00000be800000,be800000,3e600000,bd0000003f000000,3f000000,bee00000,3d800000refused: SDWA BYTE_1: MISMATCHrefused: e64 neg on inline 3: MISMATCHAll were caught. With the offset-binary mutant, the CPU evaluator raises a
TypeErrorrather than printing a mismatch line. It still fails, but a mismatch line would be clearer.To resolve before merge
docs/experiments.mdconflicts with currentmain(an append at the end; keep both). #2450 adds acheck_encodingblock at the same spot ingfx2hlsl.py; keeping both works, and both checks pass onmain+ #2452 + #2450.v_cvt_off_f32_i4_dpp v0, v1 quad_perm:[k,k,k,k] row_mask:0xf bank_mask:0xfis now accepted through the genericdpp_broadcastpath, which admits anyVEC_U_TO_Fop. It lowers toQuadReadLaneAt(v1, …)followed by the conversion. The merge base refused it asDPP form of v_cvt_off_f32_i4. The lowering looks correct, but the description and docs only mention SDWA, and nothing tests it. Is this intended? If so, please add one broadcast row; otherwise refuse DPP the way SDWA is refused.e8bd6cb2one06aca8b; the head isce625973.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T19:29:34Z.
Rebased onto current main (fba03c9) as @TheVoid asked. Head is now
1f6cb0c4(wasce625973); the single commit replayed, and the only conflict was the docs/experiments.md append-tail (main's newest section kept, this PR's record re-appended). No conflict markers.Verified on
1f6cb0c4: ests/startup_gfx2hlsl_cvt_off_f32_i4_check.py exit 0; check file blob-identical to the pre-rebase head; CMakePresets.json parses and startup_gfx2hlsl_cvt_off_f32_i4_controls still matches the pr include regex; docs_links_check.py 19 files/472 links; git diff --check clean. Diff vs main is the PR's 7 files (+773/-4). PR is MERGEABLE and CI is running.Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T19:34:10Z.
Thanks for the rebase, @triggered02. Two things remain before I can merge this:
v_cvt_off_f32_i4_dpp … quad_perm:[k,k,k,k]is now accepted through the genericdpp_broadcastpath; the merge base refused it. Is that intended? If so, one broadcast row in the check would pin it. If not, refuse DPP the way SDWA is refused.check_encodingblock at the same spot ingfx2hlsl.py; keep both.The stale "Measured checks (
e8bd6cb2…)" heading in the description is cosmetic.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T19:41:44Z.
Both items done, head is
2be3ae93(rebased onto currentmain82bb67ef).1. DPP16 quad broadcast — intended, and now pinned.
Stage.dpp_broadcastis deliberately op-agnostic: it proves whole-quad activity (s_wqm exec+ the entry EXEC mask + straight-line pixel stage), reads the lane thequad_permnames withQuadReadLaneAt, then runs the base operation on that value — for a unary op that is the ISA order (broadcast the source, convert the value). The merge base refused the DPP form only because it refusedv_cvt_off_f32_i4entirely; the op is now inVEC_U_TO_F, so the same generic path accepts it, as it would for any other lowered VOP1. Nothing in the lowering was special-cased for DPP.tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pygainscheck_dpp_broadcast(), which pins the acceptance rather than just observing it:quad_perm:[2,2,2,2]QuadReadLaneAt(v1, 2u)int(v256 << 28) >> 28×0.0625needs_sm6quad_perm:[3,3,3,3][1,0,3,2], mixed[2,2,2,3]row_mask:0x7,bound_ctrl:0wqm_exec=False)All 11 rows pass, and the whole check is
all controls passed(exit 0).2. Rebased onto
mainafter #2450 merged, bothcheck_encodingblocks kept. Exactly the spot you warned about:mainnow carries thev_sad_u8/u16/u32ABS/NEG guard and this PR adds thev_cvt_off_f32_i4_e64guard.2be3ae93keeps both in sequence (sad guard first, then cvt), and I tightened the cvt comment while resolving it — it previously rambled; it now states that the instruction has one source, so onlyw0[8]/w1[29]can carry a modifier, and masking all three positions also refuses the unused src1/src2 bits. Verified both guards still fire: the sad check (merged inmain) still passes, and the cvt check still refuses abs/neg on the operand.Verification on
2be3ae93:cmake --build --preset dev --target offscreen_checkexit 0;drawon WARP and on the GTX 1660 SUPER → both14 draws matched, 6 mutated draws read their mutated words;tests/startup_gfx2hlsl_cvt_off_f32_i4_check.pycontrols exit 0;startup_gfx2hlsl_sad_check.pyexit 0;docs_links_check.py19 files/475 links;startup_translator_check.pyexit 0;git diff --checkclean; no conflict markers. Diff vsmainis the PR's 7 files (+856/−4).3. Stale heading fixed: the description now reads
### Measured checks (2be3ae93onorigin/main82bb67ef)and carries a short DPP16 paragraph, so it matches this head.Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T20:19:45Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T20:19:52Z.
Review: APPROVED
Approved at head
f6b86579, which is @triggered02's rebase ontomainafter #2450 with the DPP pin. Thanks for answering the open points.What changed since my review of
ce625973check_dpp_broadcast()now pins it: acceptance,QuadReadLaneAt, the conversion on the broadcast value, the lanequad_permnames, and refusal of mixed and non-broadcastquad_perm, a partialrow_mask, an unproven whole-quad entry mask and the vertex stage.check_encodingblocks kept: thev_sad_*guard from #2450, then thev_cvt_off_f32_i4guard.Re-verification at
f6b86579(Windows 11 build 26300; AMD Radeon RX 9070 XT 1002:7550, driver 32.0.32029.2010, debug layer enabled; WARP 10.0.26100.9818; DXC/FXC from SDK 10.0.26100)v_sad_*controls and draws on the same tree, so both encoding guards work together.dpp_broadcast …: oklines print.main.Negative control (new for the DPP pin)
I hard-coded the broadcast lane in
dpp_broadcast(lanes.group(1)replaced with'2'). The check fails:dpp_broadcast reads the lane quad_perm names, not a fixed one: MISMATCH. After reverting, it passes. The semantic mutants from my earlier review (unsigned nibble, offset-binary, 1/32 scale, sign flip, SDWA and e64 guards) are against the unchanged lowering.No cache bump is needed: this only accepts forms that were refused before, as established in my earlier review. That's independent of the
15/15csrevision #2467 just landed.Merge checks: required CI passed at this head. The
/O2and coverage skips come from explicit workflow conditions. There are no unresolved review threads. I read the whole thread in full.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T20:19:45Z.
Code review location:
CMakeLists.txt; line 3111Addressed at head
f6b86579:startup_gfx2hlsl_cvt_off_f32_i4_controlsis in theprpreset regex inCMakePresets.json, andtests/startup_gfx2hlsl_cvt_off_f32_i4_check.pyis in the LinuxRun Python checkslist in.github/workflows/windows.yml(line 230). Resolving. AI-assisted.