shader: lower 64-bit float ALU and conversions in gfx2hlsl (Part of #1723) #2078
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!2078
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2078/head"
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?
@tedin7 on GitHub · 2026-11-25 00:03 UTC · original
tedin7:x2w-b3-f64-alu→main· +426 −0 · 4 files · 3 commits · closed without mergingPart of #1723
What this unblocks: shaders that use 64-bit float math (
v_add_f64,v_mul_f64,v_fma_f64,v_cvt_f32_f64,v_cvt_f64_f32) no longer stop translation ingfx2hlsl.py.A binary64 value is a VGPR/SGPR pair. The lowering reads both words into one HLSL
doublewithasdouble(), computes, and writes both result words from oneasuint(double, lo, hi)call, so an in-place destination keeps the original operands until the result is complete. Pair and inline-constant sources accept-and|abs|. Output modifiers (clamp,mul:,div:),op_sel, a destination that is not a VGPR pair, wrong operand counts and the binary32-only inline constant0.15915494are refused, not dropped. No opcode in this slice was on main or in an open PR.Verification:
python3 -B tests/startup_gfx2hlsl_f64_alu_check.py: all checks passed on this branch; onorigin/mainit stops withUnsupported: v_add_f64.for t in tests/startup_gfx2hlsl_*_check.py; do python3 -B $t; done: all pass.CMakeLists.txtasstartup_gfx2hlsl_f64_alu.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:03 UTC · original · edited 2026-11-25 00:13 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
ed782a1ℹ️ 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.
@ -2697,0 +2769,4 @@if len(ops) != 2:raise Unsupported('v_cvt_f64_f32 with %d operands, expected 2' % len(ops))lo, hi = self.f64_pair_destination('v_cvt_f64_f32', ops[0])value = 'double(%s)' % self.f(ops[1])@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:12 UTC · original
For gfx1013 bytecode encoding
v_cvt_f64_f32_e64 v[2:3], neg(1), the decoder prints the source as-1, and this call emitsdouble(F(0xffffffffu)), a NaN. The actual source bits after NEG are0x80000001, representing a finite negative subnormal, not a NaN. Likewise,neg(0)decodes as-0and emitsdouble(0.0), losing the sign. Preserve these modifiers from the instruction encoding, ascheck_encoding()already does for ambiguousv_cndmask_b32_e64immediates, or refuse the affected forms instead of silently widening a different value.Useful? React with 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:12 UTC · original
For fetched vertex shaders, this block-shaped statement is rejected by
Pipeline.hlsl_vs()'s definite-assignment guard, which recognizes writes only as lines starting withvN = ...and otherwise treats every VGPR name as a read. With a fetch defining v4/v5,v_add_f64 v[12:13], v[4:5], v[4:5]lowers here but subsequently raisesUnsupported('vertex stage reads v12...')because its destination is mistaken for an uninitialized source. The same issue affects multiply, FMA, and the widening conversion. Make both destination writes visible to that guard while preserving evaluation before either write.Useful? React with 👍 / 👎.
@ -2697,0 +2769,4 @@if len(ops) != 2:raise Unsupported('v_cvt_f64_f32 with %d operands, expected 2' % len(ops))lo, hi = self.f64_pair_destination('v_cvt_f64_f32', ops[0])value = 'double(%s)' % self.f(ops[1])@tedin7 on GitHub · 2026-11-25 01:02 UTC · original
Fixed in 7e15003d (rebased on main, push pending): check_encoding now refuses NEG/ABS on an inline integer source of v_cvt_f64_f32_e64, so neg(1) and neg(0) are no longer widened as a different value. Test: tests/startup_gfx2hlsl_f64_alu_check.py. Ran locally: startup_gfx2hlsl_f64_alu_check.py, startup_gfx2hlsl_f64_alu_warp_check.py (controls), refusals/arity/cvt_alu checks. The Win2025 draw run is still pending.
AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 01:02 UTC · original
Fixed in 7e15003d (rebased on main, push pending): the pair result is computed into temporaries first, then each half is its own
vN = ...line, so the vertex fetch guard sees both writes and the operands are still evaluated before either write. Test added in tests/startup_gfx2hlsl_f64_alu_check.py; the WARP swap control was updated to the new shape. The Win2025 draw run is still pending.AI-assisted; commands listed were executed locally.
@Makto94 on GitHub · 2026-11-25 10:43 UTC · original
First hardware run reported in this thread:
startup_gfx2hlsl_f64_alu_hardwarepasses on head9335d4a0with both FXC and DXC.Environment: NVIDIA GeForce RTX 3070 Ti (
10de:2482), driver 32.0.16.2101, Windows 11 build 26300.9974, Debug build, fxc 10.0.26100.9457, dxc 1.9.2602.17, D3D12 debug layer enabled, hardware run serial on an idle machine, 0 capability skips (77). The log has 30fxclines and 30dxclines (15 pixel rows and 15 "mutation: fails as expected" rows per compiler), anddebug_errors=0 debug_warnings=0on all 60 runs.Same head, WARP and CPU checks:
100% tests passed, 0 tests failed out of 3(startup_gfx2hlsl_f64_alu,startup_gfx2hlsl_f64_alu_controls,startup_gfx2hlsl_f64_alu_warp); the WARP test has 30fxclines, 30dxclines anddebug_errors=0 debug_warnings=0on all 60 runs.@thepatrickworld on GitHub · 2026-11-25 11:54 UTC · original
Run on the AMD adapter, backend
hardware, both compilers:startup_gfx2hlsl_f64_alu_warp_check.py draw <dxc> <offscreen_check> hardware <fxc>.BODY_SOURCEhas five operations (v_add_f64,v_mul_f64,v_fma_f64,v_cvt_f32_f64,v_cvt_f64_f32); the run gives 15 readbacks and 15 mutation runs per compiler, every readback matches its reference, and every mutation reads its mutated words.Branch checked out at
9335d4a0; the log itself does not record the head.One check is much looser than the others. In
controls()all five operations are validated by looking for a substring of the translated text. For four of them that substring is the whole expected expression:so for
v_cvt_f64_f32the assertion is "the text containsdouble(". Any lowering containing that substring satisfies it — a lowering that read the wrong register would too. I have not tested such a lowering; the point is that this control could not catch one. The other four pin the expression.Limit. I ran the
hardwarebackend; thewarpbackend named in the usage line is not covered by this run.AI-assisted.
@tedin7 on GitHub · 2026-11-25 11:54 UTC · original
Thank you @Makto94 for the RTX 3070 Ti run at
9335d4a0:startup_gfx2hlsl_f64_alu_hardwarepassed with FXC and DXC, CPU/controls/WARP 3/3. Recorded as extra evidence for this PR.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 13:52 UTC · original
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.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:12 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
ed782a1ab4ℹ️ 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".
Pull request closed