Skip to content

fix(recompiler): read f16 inline constants as half values and honour VOP3 f16 op_sel - #162

Merged
boykopovar merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:fix/f16-inline-constants
Sep 30, 2026
Merged

boykopovar merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:fix/f16-inline-constants

Conversation

@MichonGoddijn231849

Copy link
Copy Markdown
Contributor

What

  • A float inline constant (0.5, 1.0, 2.0, 4.0 and their negatives, 1/(2π)) read by an f16 operation is the half-float value in the low 16 bits, as LLVM's getInlineEncodingV216 documents. It was read as the low half of the f32 bits, which is 0.
  • op_sel[0..2] now selects the high half of the v_fma_f16, v_min3_f16, v_max3_f16 and v_med3_f16 sources. The decoder already set it, but the read ignored it.
  • Integer 16-bit operations keep the f32 bits.

Found in GTA V's FidelityFX CAS sharpen pass: v_fma_f16 v38, 4.0, v22, 1.0 computed 1 + 4w as 0, so the pass returned rcp(0) and stored a black frame.

Tested

Windows 11 Pro, AMD Ryzen 5 7600 (6-core), NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • GTA V (PPSA04264): the frame renders after this change, and was black before.
  • 376 saved recompile requests replayed before and after: only 2 GTA V f16 shaders change. All 178 Demon's Souls requests give byte-identical SPIR-V.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

…VOP3 f16 op_sel

A float inline constant (4.0, 2.0, -4.0...) read by an f16 operation is the half value in the low
16 bits (LLVM getInlineEncodingV216); it was the low half of the f32 bits, 0. op_sel[0..2] now
selects the high half of v_fma/min3/max3/med3_f16 sources. GTA V's CAS sharpen computed
rcp(1 + 4w) as rcp(0) and stored black.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the shader core/shader label Sep 29, 2026
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Sep 30, 2026
…s half values and honour VOP3 f16 op_sel)
@boykopovar
boykopovar merged commit c227fe4 into boykopovar:main Sep 30, 2026
3 checks passed
@MichonGoddijn231849
MichonGoddijn231849 deleted the fix/f16-inline-constants branch October 9, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants