feat(shader): allow directed rounding modes for packed f16 minmax #14793
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14793"
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 boykopovar/AnyPS5. Originally posted by AlexWhitehouse on 2026-11-01T17:58:34Z.
What
TranslationContext::packedFloat16(core/shader/recompiler/Translation/src/FloatInstructions.cpp) threwpacked f16 at pc … in FLOAT_MODE … (f16 rounding not to nearest even) is not implementedfor every packed f16 instruction whenever the f16 round field ofFLOAT_MODEis not nearest even. This PR exemptsv_pk_min_f16andv_pk_max_f16from that throw.minMaxF16Bitspath, so no rounding step happens. AMD's RDNA 2 ISA guide, §12.10 (printed p. 164, VOP3P opcodes 17 and 18), defines them as componentwise FP16 minimum and maximum.op_sel, negation and clamp handling is unchanged.v_pk_add/mul/fma/fmac_f16, which do round, still throw.FLOAT_MODE0xcc that thev_fma_mixlo_f16debt entry records for ps5-opengl has the f16 round field set to toward zero, so every packed f16 instruction in such a shader threw before.Debt.
docs/dev/debt/shader.md, two edits:v_fma_mixlo_f16entry's note about packed f16 rounding names the exception.Both entries were already over 1,000 characters on
main, socheck_conventionswarns on them; the PR changes only those clauses and keeps their measurement records.Tested
agc_driver_float16_min_max_bits(tests/execution/Float16MinMaxBits.cpp) gains packed-only runs in every f16 round mode (0 to 3), crossed with:The packed runs use the test's existing
PackedCode, selector and negation checks, and CPU bit model. Rows now include signed zeros, infinities, quiet and signalling NaNs, denormals and minimum normals in every mode. The change passes 696,320 bit-exact comparisons.Mutation check: swapping the min and max selection fails (actual
0x00010000, expected0x00018000); restoring it passes.Required focused comparison:
ctest -R "^agc_driver_float16_min_max_bits$" -Vonmain(f2d874c1fd) and this PR, with the same test source andANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:packed f16 at pc 20 in FLOAT_MODE 52 (f16 rounding not to nearest even) is not implemented; this PR passes.VK_LOADER_DEBUG=layershowed the validation layer loaded and inserted. Neither log has a missing-layer warning or aVUID-error. This run used 4534907f0b, which differs from this PR only in the debt text.VUID-error.VUID-error.maind2ce337078, which changed the add/mul/fma path ofpackedFloat16(#11368), with the same variables on both GPUs:mainfails at the same throw and this PR (35335272ae) passes with 696,320 comparisons. The layer was inserted, and none of the four logs has a missing-layer warning or aVUID-error.main6f1d2c70ae, which added a native fma path topackedFloat16(#14892), with the same variables on both GPUs:mainfails at the same throw and this PR (8281e5821b) passes with 696,320 comparisons. The layer was inserted, and none of the four logs has a missing-layer warning or aVUID-error.Wider runs of
-R "agc_driver_.*(f16|float16|half|mode|sdwa|packed)|agc_shader_mode"with the same variables:Neither run has a
VUID-error.python3 tools/check_conventions.py --base origin/main: no errors; twodebt-lengthwarnings on the two entries above, which were already over the limit.python3 tools/pr_overlap.py: no confirmed overlap. The tool could not compare 23 open PRs that conflict withmain, all throughdocs/dev/debt/shader.md. None of their diffs touches the packed-f16 orv_fma_mixlo_f16entries,packedFloat16,v_pk_min/max_f16orFloat16MinMaxBits.cpp. #5021 also editsFloatInstructions.cpp, but only one line invLdexpF16.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T18:03:38Z.
Review: COMMENTED
Reviewed — no blocking findings
The directed-rounding exemption is limited to packed min/max opcodes, while other packed arithmetic remains guarded; the added cases exercise the min/max path across the configured mode combinations.
What I ran
Reviewed head
97c53a1d091b3ac085e1adf011485edddc8f6935against basef2d874c1fdccf781c0fa5d86619bb5dd8894b958; the merge preview is clean. Environment: Linux x86-64, GCC 12.2.0, Python 3.11.2. I reviewed the source diff, test-mode construction, test registration and debt edits. No build or GPU test was run locally.Results
Float16MinMaxBits.cpp.Raw precheck output
The report's diff check passed. Its convention check passed with these warnings:
The overall precheck could not launch its workspace-only
pr_abi_audit.pyandpr_test_quality.pyhelpers from the isolated exact-head checkout. Those helper launch errors are not code or test failures. The live stack check passed.Negative control
Not run by me. The PR reports that swapping the min/max selection made the test fail with an output mismatch; I did not repeat that mutation.
Findings
Blocking
None found in the reviewed changes.
Non-blocking
None.
Sources
Not verified
The reported RTX 3060 and lavapipe runs, the 696,320 comparisons, the mutation result, and validation-layer output were read from the PR description but not independently reproduced. No console behavior was tested. Hosted checks remain queued.
To get this to a good state
No source change is requested. Once the hosted checks complete, I can recheck this head and approve if they pass.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T19:30:05Z.
Review: COMMENTED
Reviewed — no blocking findings
The exemption is sound:
v_pk_min_f16andv_pk_max_f16select operand bits and never round, so the rounding-mode throw does not apply to them. Approval waits for the macOS relinker jobs, which were queued at review time.What I ran
67a16bfa4003957fe0648197946f492e9f3c66d2; basef2d874c1fd(merge base is the same commit). 3 files, +26/-7:FloatInstructions.cpp(1/1),Float16MinMaxBits.cpp(23/4),docs/dev/debt/shader.md(2/2). I read the whole diff.FPMin32andFPMax32reachpackedFloat16only from the packed min and max opcodes, withquietSnanset (VectorInstructions.cpplines 956-958). That branch takespackU16Lanes(minMaxLane(...))(FloatInstructions.cpplines 61 and 68), which selects 16-bit lanes throughminMaxF16Bitswith no rounding step. The add, multiply and fma opcodes still take the throw.Results
Commands and unedited precheck output
Commands:
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14793 --output-dir <scratch>/precheck/14793(report.md in that directory).git fetch https://github.com/boykopovar/AnyPS5.git pull/14793/head.git grep -n 'packedFloat16(' 67a16bfa4003957fe0648197946f492e9f3c66d2.gh api repos/boykopovar/AnyPS5/commits/67a16bfa4003957fe0648197946f492e9f3c66d2/check-runs.Precheck table (unedited):
The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check f2d874c1fdccf781c0fa5d86619bb5dd8894b958...67a16bfa4003957fe0648197946f492e9f3c66d2/marc/Conlyse-VIEJO/.venv/bin/python3 tools/check_conventions.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head 67a16bfa4003957fe0648197946f492e9f3c66d2 --title feat(shader): allow directed rounding modes for packed f16 minmax --body /dev/shm/reviewer-run/precheck/14793/pr-body.md/marc/Conlyse-VIEJO/.venv/bin/python3 tools/pr_abi_audit.py --base f2d874c1fdccf781c0fa5d86619bb5dd8894b958 --head 67a16bfa4003957fe0648197946f492e9f3c66d2 --jsonNo changed Python implementation files.No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.No changed test_*.py files./marc/Conlyse-VIEJO/.venv/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14793 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14793/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./marc/Conlyse-VIEJO/.venv/bin/python3 /dev/shm/reviewer-run/precheck/14793/head-67a16bfa4003-785579a1/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14793/head-67a16bfa4003-785579a1 --json core/libs/prx/libSceAgcDriver/tests/execution/Float16MinMaxBits.cpp core/shader/recompiler/Translation/src/FloatInstructions.cpp docs/dev/debt/shader.mdNo changed Python test module in tools/ can be run as a no-build base-source control.Negative control
Not run here. The PR reports a mutation check (swapping min and max fails the test; restoring passes); I did not rerun it.
Findings
Blocking
None.
Non-blocking
v_fma_mixlo_f16entry indocs/dev/debt/shader.mdwere already over 1,000 characters, socheck_conventionswarns on them. The PR keeps that length and says so.Sources
github.com/boykopovar/AnyPS5@67a16bfa40/core/shader/recompiler/Translation/src/FloatInstructions.cpp (L13-L16)github.com/boykopovar/AnyPS5@67a16bfa40/core/shader/recompiler/Translation/src/FloatInstructions.cpp (L61-L68)github.com/boykopovar/AnyPS5@67a16bfa40/core/shader/recompiler/Translation/src/VectorInstructions.cpp (L952-L962)github.com/boykopovar/AnyPS5@67a16bfa40/core/libs/prx/libSceAgcDriver/tests/execution/Float16MinMaxBits.cppNot verified
To get this to a good state