shader: lower gfx1013 floating-point truncation #255
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/258"
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 Vonsek on 2026-11-21T19:35:21Z.
Change
Lower gfx1013
v_trunc_f32to HLSLtruncin the straight-line pixel translator. The instruction can use the existing floating-point source modifiers and clamp handling. A truncation write into an unfinished texture sample destination is rejected.The opcode is distinct from the bitwise and conversion work in #232, the three-input extrema in #169, and the partial-wait implementation in #176. See the AMD RDNA 2 ISA reference, section 12.8 and the HLSL
truncreference.Verification
Commit
18ece1122e029a8e5ec20adeeb239edf768b364con upstreamc832696c7b9731d2cc77d755608a48b0405a0b7f.cmake --preset devin the Visual Studio x64 environment with the local venv set asINTAKE_PYTHON, followed bycmake --build --preset dev --target offscreen_check. Configure and build passed.ctest --preset dev --no-tests=error -R '^pixel_aot_(warp|hardware)$' --output-on-failure. Before the implementation, the software test failed onUnsupported instruction 21: v_trunc_f32_e32. With the first lowering in place, moving a truncation write beforevmcnt(0)failed the invalid-input check. With the write guard in place, both draw targets passed on the Microsoft Basic Render Driver (WARP 10.0.26100.9818) and the NVIDIA GeForce RTX 5080 (driver 32.0.16.1692). The debug layer was unavailable and neither adapter skipped the check.python -B tests/pixel_aot_check.py binary $asm $objcopy $llvm. Passed with the LLVM 15.0.7 Windows release. The local assembler wrapper invokesclang -cc1as -triple amdgcn--amdpal -target-cpu gfx1013 -filetype obj <source> -o <object>. The remaining arguments are the release'sllvm-objcopy.exeandLLVM-C.dll. The normal Ubuntu workflow usesllvm-mc-15.git diff --check c832696 HEAD. Passed.python -B tests/docs_links_check.pyandctest --preset dev --no-tests=error -R '^docs_links$' --output-on-failure. Passed, with 64 links checked across 10 files.Evidence and follow-up
The MIT-licensed fixture adds original assembly to the repository's synthetic texture and constant-buffer program. Two constant sets compare packed color against the CPU's floating-point integer component for positive and negative fractions, signed zero, e32 and e64 forms, negated absolute input and clamped output. Replacing truncation with floor failed at (0, 0) on both adapters, where red expected -1 and got -2. A separate WARP run with the upper clamp temporarily removed also failed at (0, 0), where alpha expected 1 and got 2. Both fixtures passed with the normal lowering.
A private read-only archive survey found the instruction in 53 of 1,829 pixel programs that independently decoded as straight-line candidates with a single terminator before documented padding. It confirmed that a subsequent multiply-add consumes the truncation result in one candidate. These observations motivate the instruction test. The synthetic fixture verifies desktop lowering under the existing sampling and mask contract. The survey did not verify end-to-end translation of any archive shader.
Checklist
This contribution was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T19:46:03Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
1d27192826ℹ️ 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 Vonsek on 2026-11-21T19:48:33Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T19:41:22Z.
@codex review
Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T19:48:56Z.
@codex review
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T19:51:19Z.
Codex Review: Didn't find any major issues. Delightful!
Reviewed commit:
ccb4018ba9ℹ️ 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 R0Y00 on 2026-11-21T19:59:27Z.
At
ccb4018,tools/pixel_aot.pyconflicts with main after #267. Please keep thefract32lowering alongside the new truncation lowering and outstanding-sample write check. Rerunpixel_aot_warpon the combined head.Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T20:07:42Z.
@codex review
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T20:10:01Z.
Codex Review: Didn't find any major issues. Nice work!
Reviewed commit:
9e5e4dede7ℹ️ 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 R0Y00 on 2026-11-21T20:28:05Z.
At
9e5e4de, Git reports conflicts inREADME.md,tests/pixel_aot_check.pyandtools/pixel_aot.py. #273 now guards every floating-point arithmetic destination against pending samples, so truncation can reuse that guard. Please preserve #277's single-word loads and both sets of draw controls.Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T20:32:52Z.
@codex review
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T20:35:48Z.
Codex Review: Didn't find any major issues. Delightful!
Reviewed commit:
18ece1122eℹ️ 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-21T19:35:34Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
18ece11ℹ️ 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 chatgpt-codex-connector[bot] on 2026-11-21T19:46:03Z.
Code review location:
tools/pixel_aot.py; line 123Accepting
v_trunc_f32adds a public translation capability, but this commit updates neither the relevant README row nordocs/experiments.md. RootAGENTS.mdexplicitly requires a documentation update when public capabilities change. Record the new instruction support and the truncation fixture’s measured coverage in the shader capability documentation so contributors can discover the supported behavior and its evidence outside the commit message.AGENTS.md reference: AGENTS.md:L145-L146
Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T19:48:33Z.
Code review location:
tools/pixel_aot.py; line 123Updated the README shader row and the offline pixel shader experiment in
ccb4018. The experiment describes the instruction forms, exact synthetic readback coverage, floor and clamp controls, and the desktop pipeline scope. The existing LLVM and CTest commands reproduce the fixture. The standalone link check and the devdocs_linkstarget passed. Experiment documentation