Repository navigation
shader: support 64-bit source operands in gfx2hlsl (Part of #1723) - #2039
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19a3637896
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
19a3637 to
df127ec
Compare
|
Fixed and pushed in df127ec (docs updated, tests pass). |
|
Run at head 12 readbacks per compiler over AI-assisted. |
|
Thanks for the hardware run. It was at head All 12 readbacks per compiler match on the AMD hardware backend. The sign-filling case ( AI-assisted; commands listed were executed locally. |
|
Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is. We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here. AI-assisted; commands listed were executed locally. |
|
A data point from a local request cache, in case it helps prioritise this (counts only).
Not measured: any effect at run time. The counts come from one local cache and were taken on a tree that is not current 🤖 Generated with Claude Code |
|
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
What changed since Not covered here: the hex literal as the 64-bit value has no GPU readback yet (the draws use the literal only as the shift amount), and the one-scalar-or-literal constant-bus rule in the docs is not enforced by the translator (same on main). AI-assisted; commands listed were executed locally. |
|
@MasterDomino #2039 is ready for review/merge.
AI-assisted; commands listed were executed locally. |
|
A second capture, consistent with the data point above (local, counts and instruction shape only), at main I did not run this branch. With main's translator plus an in-memory wrap of
AI-assisted. |
|
@Leyukaka thank you for the second capture, and @NiiRoZz for the first one. No code change is needed here. I checked The 25 requests that stop next at Head Commands run locally: AI-assisted; commands listed were executed locally. |
MasterDomino
left a comment
There was a problem hiding this comment.
Requesting one small change at 45a18be5.
The vector lowering looks right. A 32-bit hex literal fills the low word, and the high word is zero for v_lshlrev_b64/v_lshrrev_b64 and copies bit 31 for v_ashrrev_i64. Wider literals and literal destinations stay refused.
The problem is in scalar_wide_op (tools/startup/gfx2hlsl.py:3755). It now passes helper == 'shr64i' to i64_words as the signedness. But s_bfe_u64 and s_bfe_i64 both use helper bfe64 and differ only in signed (:3804, :3807). So s_bfe_i64 with a hex literal source, refused before this PR, is now accepted with the literal zero-extended.
- Example:
s_bfe_i64 s[20:21], 0x80000000, s9emitsbfe64(2147483648u, 0u, s9, 1u). Under the rule this PR states (sign-extend when the operation is signed), the high word should be4294967295u. Any field that reaches bit 32 or above reads differently. - Suggested fix:
self.i64_words(ops[1], helper == 'shr64i' or signed is True), plus ans_bfe_i64row instartup_gfx2hlsl_shift64_literal_check.py. With that change applied locally, the shift64 and bfe tests still pass.
Docs: please also extend the paragraph.
- The PR newly accepts hex literals as the 64-bit source of
s_lshl_b64,s_lshr_b64,s_ashr_i64,s_bfe_u64ands_bfe_i64, not only of the vector shifts. - "the rule the scalar 64-bit operations use" reads as an existing precedent, but scalar shift and bfe literals were refused until this PR. Only
s_mov_b64zero-extended a hex literal before.
Cache revision: no bump needed, since only formerly refused programs change.
Verified locally (Windows 11 build 26300; WARP 10.0.26100.9818 and AMD Radeon RX 9070 XT, driver 32.0.32029.2010; debug layer on):
ctest --preset dev --no-tests=error -j4 -R shift64: 7/7 passed, 0 skipped.ctest --preset dev --no-tests=error -j4 -R startup_gfx2hlsl: 169/170. The one failure,startup_gfx2hlsl_fma_mix_dispatch_hardware, also fails on this adapter without this PR, so this PR didn't cause it.- The branch is 168 commits behind
mainbut merges cleanly, and the shift64/bfe Python checks pass on the merged tree. - Mutants: five one-line mutants of the new code (no sign fill, 9-digit literals, the scalar signed flag dropped, the vector call always signed, bit 30 in place of bit 31) were all caught, but only by the string-match
startup_gfx2hlsl_shift64_literal. As already noted, no draw reads a literal 64-bit value back yet.
AI-assisted; commands listed were executed locally.
|
Checked on Command
The runs below call the script directly, with the Reading
LimitsEmitted text of the lowering checked by the branch's own assertions, not an instruction-level measurement: the change only turns formerly refused programs into accepted ones, so there is nothing to draw on a GPU. One translation per form. AI-assisted. |
MasterDomino
left a comment
There was a problem hiding this comment.
Approving 51842db4; the change request is resolved.
- The fix:
0c4e94a3passeshelper == 'shr64i' or signed is Truetoi64_words, so a hex literal source ofs_bfe_i64is sign-extended ands_bfe_u64stays zero-extended. - Pinned: both cases now have rows in
startup_gfx2hlsl_shift64_literal_check(bfe64(4294967295u, 4294967295u, s9, 1u)againstbfe64(4294967295u, 0u, s9, 0u)). - Docs: the paragraph now covers the scalar shifts and the bitfield extracts.
51842db4tightens the change: a hex literal is now accepted only on the shift and bitfield-extract paths (theliteralflag oni64_words). It stays refused as the 64-bit addend ofv_mad_u64_u32/v_mad_i64_i32, which now has a refusal row, and the scanner pattern and the Linux CI list match.
Pure-Python checks at this head, all passing (Windows 11 build 26300):
startup_gfx2hlsl_shift64_literal_checkstartup_gfx2hlsl_scalar_shift64_bfe_check(3498 helper cases)startup_gfx2hlsl_shift64_checkrdna2_tools_check(19 skips, none failed)
The WARP and RX 9070 XT runs from my earlier review were at 45a18be5; the only code changes since are the signedness fix and the narrower literal acceptance. CI is green at this head.
AI-assisted; commands listed were executed locally.
|
@MasterDomino fixed in
Verification:
Re-requesting your review. AI-assisted; commands listed were executed locally. |
Part of #1723
What this unblocks: Run 20 census #10 (
64-bit source N, 62 pairs).gfx2hlslrefusedv_lshlrev_b64,v_lshrrev_b64andv_ashrrev_i64whenever the 64-bit source was a 32-bit hex literal (for example0x80000000) instead of a register pair or an inline constant. These now lower. The literal fills the low word. The high word is zero for the two unsigned shifts and copies bit 31 forv_ashrrev_i64, the same rule the scalar 64-bit operations already use.Known limit: decimal literals outside the inline range (
65,-17), literals wider than 32 bits, float constants,vccandexecas a 64-bit source stay refused. The zero/sign extension of a literal is taken from the existing scalar rule, not measured on a console.Changes:
tools/startup/gfx2hlsl.py:i64_wordsaccepts0xliterals of up to 8 hex digits; the signed shift sign-extends.tests/startup_gfx2hlsl_shift64_literal_check.py(new, registered inCMakeLists.txtasstartup_gfx2hlsl_shift64_literal): checks the emitted line for each shift with literals that have bit 31 clear and set, and that a 33-bit literal and a literal destination stay refused.tests/startup_gfx2hlsl_shift64_check.py:0x41removed from the refusal list, since it is now supported.Verification (head
51842db4f9a5ec1e487771f30070dfab8521e2b3):python3 -B tests/startup_gfx2hlsl_shift64_literal_check.py,startup_gfx2hlsl_shift64_check.py,startup_gfx2hlsl_mad64_check.py,startup_gfx2hlsl_scalar_shift64_bfe_check.py,python3 -m unittest tests.rdna2_tools_check -k shift64: PASS. Withtools/startup/gfx2hlsl.pyfromorigin/mainthe literal check fails (Unsupported: 64-bit source 0x41).ctest --preset devand--preset release-R '^(startup_gfx2hlsl_shift64_literal|startup_gfx2hlsl_shift64_controls|startup_gfx2hlsl_shift64_warp|startup_gfx2hlsl_scalar_shift64_bfe_controls|startup_gfx2hlsl_mad64.*)$': 7/7 passed on dev, 7/7 on release;tests/rdna2_tools_check.pyok.AI-assisted; commands listed were executed locally.