shader: lower gfx1013 v_ceil_f32 and v_rndne_f32 in pixel_aot #270
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/274"
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-21T20:03:16Z.
Change
tools/pixel_aot.pynow lowers two more gfx1013 rounding instructions, each in its VOP1 (_e32) and VOP3 (_e64) encoding:v_ceil_f32to HLSLceil(DXILRound_pi).v_rndne_f32to HLSLround, which DXC emits asRound_ne(round to nearest, ties to even). This matches the RDNA definition. Rounding half up or half away from zero would not.They share the existing single-source ALU path, so source negation, absolute value and
clampbehave as they do forv_floor_f32. The change adds two ALU table entries and two names to the arithmetic pattern.tests/pixel_aot_check.pyadds arounding()program. It multiplies red and green by a power-of-two constant, then appliesv_ceil_f32_e32andv_rndne_f32_e32. It also appliesv_rndne_f32_e64to a constant tie andv_ceil_f32_e64to a negated constant.expspellings, generated HLSL substrings, and rejection of neighbouring forms:v_ceil_f16,v_ceil_f64,v_rndne_f16, an extra source,mul:2/div:2output modifiers,v_rcp_iflag_f32and a descriptor register as a numeric source.math.ceiland Python's ties-to-evenround. Every product is exact (power-of-two scale), so only the rounding mode decides each pixel. Three negative controls must reportpixel_mismatch:v_rndne_f32replaced withv_floor_f32,v_ceil_f32replaced withv_floor_f32, and the generatedround(replaced withfloor(0.5f +(the -3.5 tie then rounds half up).tests/form_coverage_check.pyasserts that the accepted programs include the four new forms (VOP1v_ceil_f32,v_rndne_f32; VOP3v_ceil_f32_e64,v_rndne_f32_e64) and that a passingpixel_aot_warprecord counts exactly four more gfx1013 forms than the same record without them.docs/experiments.mdlists the instructions and describes the draw and its controls.v_trunc_f32(#258, now on main) and thev_fract_f32clamp (#267) are left to those PRs; this branch is rebased beside #258's truncation draw.Verification
tests/pixel_aot_check.py binary ...passes. Withtools/pixel_aot.pyreverted tomain, it fails withUnsupported instruction 21: v_ceil_f32_e32 v12, v18.tests/form_coverage_check.pypasses; withtools/pixel_aot.pyreverted it fails with the same error.tests/docs_links_check.pypasses._e64lines in the VOP3 encoding:v_rndne_f32_e64 v14, s45is0e 00 a3 d5 2d 00 00 00, andv_ceil_f32_e64 v15, -s46is0f 00 a2 d5 2e 00 00 20.ctest --preset dev --no-tests=error -R '^pixel_aot_(warp|hardware)$' -Vat1446db3(rebased on maind311159, besidev_trunc_f32from #258; earlier runs at 106fd47 and 747a032 gave the same result) on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100, DXC 1.9.2602.17: 2/2 passed,pixel_aot_hardwareon an NVIDIA GeForce RTX 5080 (driver 32.0.16.1692) andpixel_aot_warpon the Microsoft Basic Render Driver, every draw withpixels=4096 channels=16384 max_absolute_error=0. The D3D12 debug layer was not available. The fullctest --preset dev --no-tests=errorpassed 136/136, withbvh_wave64_hardware,bvh_wave64_warpandwave_shuffle_warpskipped.Evidence and follow-up
rounding()shader with-Gis -T ps_6_0; the DXIL usesdx.op.unary28 (Round_pi) for bothceilcalls and 26 (Round_ne) for bothroundcalls. Both constant sets match the ties-to-even reference bitwise on the RTX 5080 and on WARP, and all three negative controls reportpixel_mismatchon both backends.ceil(-0.25)) is unmeasured. NaN and infinity inputs are also unmeasured.v_ldexp_f32,v_frexp_mant_f32/v_frexp_exp_i32_f32,v_madak_f32/v_madmk_f32/v_mac_f32andv_sin_f32/v_cos_f32. Exact lowering is harder for these (unfused multiply-add, revolutions, ldexp overflow and denormal range) and they are left for separate changes.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T21:04:26Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
747a0326b7ℹ️ 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-21T21:20:39Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T21:00:13Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
747a032ℹ️ 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 R0Y00 on 2026-11-21T21:28:05Z.
At
0b20cc2, the merge conflicts are intests/pixel_aot_check.pyandtools/pixel_aot.py. Ceiling has landed in #270. Please rebase to just the remaining round-to-nearest-even behavior and its controls, keeping main's ceiling implementation and fixture.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T21:04:26Z.
Code review location:
tools/pixel_aot.py; line 323For an otherwise-supported pixel program using either new instruction,
scan_unsupported_shaders.analyze_shader_instructions()still reportsunsupported_opcodes, because bothKNOWN_RDNA2_BASE_OPCODESandSUPPORTED_INSTRUCTIONS_REGEXomit these operations. I reproduced this withassembly(False)plusv_ceil_f32_e32 v12, v12, and separately withv_rndne_f32_e32 v12, v12: lowering succeeds, buttools/pso_readiness.py:37-38checks the stale opcode classification before the successful lowering result and marks the pipeline blocked. Update the scanner's recognition and support tables alongside the lowerer so these newly supported programs are not falsely rejected by the scanner and PSO-readiness workflow.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T21:20:39Z.
Code review location:
tools/pixel_aot.py; line 323Fixed in
0b20cc2.tools/scan_unsupported_shaders.pynow listsv_ceil_f32andv_rndne_f32as known RDNA 2 VOP1 opcodes, inSUPPORTED_ALUand in the supported-instruction pattern (both encodings), so a program thatpixel_aotlowers is no longer reported with unsupported opcodes andpso_readinessno longer marks it blocked.tests/rdna2_tools_check.pyaddstest_rounding_instructions_accepted: the canonical pixel shader withv_ceil_f32_e32andv_rndne_f32_e64after the sample wait must be recognized, accepted by the translator and fully supported. It fails without the scanner change (False is not true) and passes with it; the full suite passes on Windows 11 26200.The scanner's tables also omit other forms the lowerer already accepts (for example
v_floor_f32,v_fract_f32,v_trunc_f32,v_add_f32,v_mul_f32); that predates this PR and is left for a separate change.