shader: interpolate f16 parameter halves (V_INTERP_P1LL_F16, V_INTERP_P2_F16) #1792
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1792
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1792/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?
@Nawid3333 on GitHub · 2026-10-21 16:38 UTC · original
Nawid3333:fix/interp-f16→main· +181 −75 · 10 files · 1 commits · merged 2026-10-22 02:54 UTCAnno 1800 Console Edition (PPSA04716) and Assassin's Creed: Black Flag Resynced (PPSA28138) stop with
VOP3 opcode=0x342 ... is not implemented(#281). 0x342 is V_INTERP_P1LL_F16: their pixel shaders read one 16-bit half of a parameter word (the raw words in the two logs,[0xd7420015 0x000201c3]and[0xd7420004 0x00020183], decode tov_interp_p1ll_f16 v21, v0, attr3.w highandv_interp_p1ll_f16 v4, v0, attr3.z high).Change
{attr_word, attr_chan, attr}(RDNA2 ISA, "Parameter Interpolation on 16-bit data"); the operands follow the VINTRP layout plus the half in src3.Tests
F16AttributeInterpolationandF16AttributeInterpolationFlatdraw a triangle whose parameter channel 3 holds two f16 values and whose channels 0/1 hold the same values as f32. Both halves are interpolated into one VGPR (the second through op_sel[3]). Each pixel's f16 result must match the f32 interpolation to within one f16 ulp, and on interior pixels the f32 interpolation must match barycentrics computed from the vertex positions (relative error 1e-3); the flat case checks the first and the last provoking vertex exactly.Results (Windows 11, clang-cl Release, on main
4644c529)F16AttributeInterpolationandF16AttributeInterpolationFlatfail on main and pass with this change on an RX 9070 XT and a Ryzen 7600X iGPU, with native and 32-wide host subgroups.I don't have these games, so this is not game-tested; it removes the decoder stop that both logs show.
AI use: written with Claude Code; I reviewed the change and ran the tests above.
@coderabbitai[bot] on GitHub · 2026-10-21 16:49 UTC · original
📝 Walkthrough
The change adds decoding and translation for
V_INTERP_P1LL_F16andV_INTERP_P2_F16. It adds theGetAttributeF16IR opcode, validates its input references, and emits packed half attributes asf32values using flat selection or smooth barycentric interpolation. Decoder tests cover supported and rejected encodings. Rasterization tests check smooth and flat results, including provoking-vertex selection.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: 🔵 Low · up to
c447eThe new F16 interpolation support works for the standard instruction pairing used by compilers and is covered by decoder and rasterization tests. Shaders that read the P1LL result directly, or that supply non-standard interpolation coordinates, could still get stale or incorrect values. This follows the existing F32 design and is low risk, but the author should either document the limitation or reject those forms in the decoder.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 13.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 8 files. (3 skipped: 1 unsupported, 2 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-21 16:49 UTC · original · edited 2026-10-21 16:56 UTC
On
src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppline 262 (outdated):🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10791
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41914
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42026
Preserve or reject the F16 interpolation coordinates.
DecodeVop3Interpolation16accepts the instruction's coordinate VGPR, butV_INTERP_P2_F16dropsinst.src0and emits only the attribute, channel, and half selector.EmitAttributeF16then uses the built-in barycentrics. A valid instruction with different coordinates can therefore produce the wrong attribute value. Preserve the coordinate through IR and SPIR-V, or reject unsupported coordinate forms in the decoder.@ -111,1 +116,3 @@case Decoder::Opcode::V_INTERP_P1_F32: V_INTERP_P1_F32(); return;// P2 interpolates the whole attribute, so the P1 halves have nothing to compute.case Decoder::Opcode::V_INTERP_P1_F32:case Decoder::Opcode::V_INTERP_P1LL_F16: return;@coderabbitai[bot] on GitHub · 2026-10-21 16:49 UTC · original · edited 2026-10-21 16:56 UTC
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Write the P1LL intermediate to its destination.
If a shader reads the destination after
V_INTERP_P1LL_F16, this return leaves the previous VGPR value in place. The ISA specifies an F32 result ofP10 * I + P0. Emit that intermediate even when no P2 instruction follows. (amd.com)@coderabbitai[bot] on GitHub · 2026-10-21 16:49 UTC · original · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
dc35d9e6-4115-46d9-8c3e-8376996056a9📥 Commits
Reviewing files that changed from the base of the PR and between
4644c52927and c447e145125594c4c43f2ca75d873c177512a642.📒 Files selected for processing: 11
src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.hsrc/graphics/shader/recompiler/frontend/decode/VectorAluOps.cppsrc/graphics/shader/recompiler/frontend/translate/Attribute.cppsrc/graphics/shader/recompiler/frontend/translate/Translator.hsrc/graphics/shader/recompiler/frontend/translate/Vector.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.incsrc/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpptests/ShaderRecompilerComputeTests.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@Nawid3333 on GitHub · 2026-10-21 16:55 UTC · original
On
src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppline 262 (outdated):This follows the existing f32 forms on main:
V_INTERP_P2_F32also ignores the I/J VGPR and lets the host interpolate the attribute (GetAttribute), andV_INTERP_P1_F32emits nothing (Attribute.cpp). Using the actual I/J operand (for example centroid or sample barycentrics) would change both forms, so I'd keep that out of this PR.@ -111,1 +116,3 @@case Decoder::Opcode::V_INTERP_P1_F32: V_INTERP_P1_F32(); return;// P2 interpolates the whole attribute, so the P1 halves have nothing to compute.case Decoder::Opcode::V_INTERP_P1_F32:case Decoder::Opcode::V_INTERP_P1LL_F16: return;@Nawid3333 on GitHub · 2026-10-21 16:56 UTC · original
Same model as
V_INTERP_P1_F32, which emits nothing on main either: P2 does not read the P1 result, it interpolates the whole value itself.@coderabbitai[bot] on GitHub · 2026-10-21 16:56 UTC · original
On
src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppline 262 (outdated):@Nawid3333 Thanks for clarifying. The F16 path follows the existing F32 interpolation model. My comment treated that shared limitation as a defect specific to this PR. I withdraw the finding.
Using the actual I/J operands should be a separate change for both forms. Would you like a follow-up GitHub issue for that work?
✏️ Learnings added
✅ Review thread resolved.
You are interacting with an AI system.
@ -111,1 +116,3 @@case Decoder::Opcode::V_INTERP_P1_F32: V_INTERP_P1_F32(); return;// P2 interpolates the whole attribute, so the P1 halves have nothing to compute.case Decoder::Opcode::V_INTERP_P1_F32:case Decoder::Opcode::V_INTERP_P1LL_F16: return;@coderabbitai[bot] on GitHub · 2026-10-21 16:56 UTC · original
@Nawid3333 Thanks for clarifying.
V_INTERP_P2_F16performs the full interpolation throughGetAttributeF16without reading the P1 result. IgnoringV_INTERP_P1LL_F16matches the existing F32 lowering model. I withdraw this finding.✏️ Learnings added
✅ Review thread resolved.
You are interacting with an AI system.
@Nmzik on GitHub · 2026-10-21 18:39 UTC · original
@Nawid3333 Going forward, we won't accept changes unless they've been properly tested in the game itself (some games use undocumented features). Thanks for understanding. I'll take a look.
@Nawid3333 on GitHub · 2026-10-21 20:25 UTC · original
@Nmzik Understood, thanks. So you have an overview of where our PRs stand:
VUID-...-06479), #1609 (Ghost of Yotei: the compute shader that overflowed now translates), #1630 (Demon's Souls gets past thescalar resource reads overlapstop, tested on099de8d; I'm re-running it on today's main next to #1747).For this PR: I can't run Anno 1800 or AC Black Flag myself. The P2_F16 destination half (op_sel[3]) follows LLVM, not the RDNA2 ISA text, so a run of the games is the real check for it.
@Crispy81 you posted both
opcode=0x342logs in #281. Could you run the two games with this PR's Windows build and post here whether they get past that error, how far they get, a screenshot, and the_kyty.txt? The build is theKytyPS5-Windows-x64artifact of https://github.com/KytyPS5/KytyPS5/actions/runs/39636640597 (downloading it needs a GitHub login).@Crispy81 on GitHub · 2026-10-21 21:52 UTC · original
Anno 1800 now goes ingame with that fork.
@Crispy81 on GitHub · 2026-10-21 21:57 UTC · original
Assassin's Creed Black Flag Resynced goes further, but crashes on:
shader resource specialization failed: sampled image descriptor 43 uses unsupported format 20: root=0 source=1 first_use_pc=0xb6c r128=false words=403d1d00,c1400000,0000c000,90900004,00000000,00700000,00000000,00000000 table_source=0 ordinal=21 dense_matches=1 first_candidate_offset=0x46880
--- Build ---
Source build 68af8de
--- Fatal Error ---
Error: condition (!ShaderRecompiler::IR::MaterializeResources( entry->second.resource_plan, runtime, entry->second.resources, entry->second.specialization)) is true in D:\a\KytyPS5\KytyPS5\src\graphics\host_gpu\renderer\pipeline\pipelineCache.cpp:451
_kyty.txt
So the missing opcodes for both games is resolved using your fork.
@Nawid3333 on GitHub · 2026-10-21 21:57 UTC · original
@Crispy81 thanks! For @Nmzik: that build is this PR's CI build (68af8de = c447e14 merged into main
4644c52), and with it Anno 1800 gets past theopcode=0x342stop into the game (menus and the first island in the screenshots above).@Crispy81 if you get a chance, AC Black Flag with the same build would cover the second log.
@Nawid3333 on GitHub · 2026-10-21 21:58 UTC · original
@Crispy81 our comments crossed, thanks for both. So with this PR both games get past the
opcode=0x342stop: Anno 1800 into the game, AC Black Flag up to a different error (sampled image descriptor 43 uses unsupported format 20, a 32-bit uint image format). That one isn't part of this PR; I'll look at it separately.@Nmzik on GitHub · 2026-10-22 02:53 UTC · original
@Nawid3333 Thanks for PR
@Crispy81 Thanks for real test
@Nawid3333 on GitHub · 2026-10-22 21:12 UTC · original
@Crispy81 thanks, that log helps. The last shader it compiles before the stop is pixel shader
0x079e2c9885c6ba38, so that's most likely the one. Its image 43 is a 4x4 texture in format 20 (32-bit unsigned integer, from the descriptor words in your message).MaterializeResourcesrefuses a sampled integer image in two cases: when the format has no numeric class, which isn't the case here, or when the shader samples it with a depth comparison. So my guess is that the shader does a shadow-compare sample on this small integer texture, but I can't confirm that without the shader itself.Could you run it once more with
--graphics-debug-dumpand attach this one file (zipped)? It's in_Shaders/original/, and its name ends in_new_shader_ps_079e2c9885c6ba38.bin. It's the game's original shader binary, a small file. If it isn't there, a zip of the whole_Shaders/originalfolder works too. With it I can see exactly how image 43 is used.@Crispy81 on GitHub · 2026-10-22 21:38 UTC · original
I don't understand what you mean by --graphics-debug-dump. Where's that option in the launcher gui?
@Nawid3333 on GitHub · 2026-10-22 21:41 UTC · original
@Crispy81 sorry, my mistake:
--graphics-debug-dumpis a command-line option of the emulator, and the launcher doesn't have it. There's an easier way that the launcher does have:decoded RDNA2block in the file, right before the lineShaderRecompiler PS phase begin: stage=PS hash=0x079e2c9885c6ba38 CFG BuildGraph. You can attach the whole_kyty.txtzipped (it gets bigger with this setting), or just copy that block.No hurry, though: I'm getting the game myself too, so if it's a hassle, skip it.
@Crispy81 on GitHub · 2026-10-22 21:43 UTC · original
No, no hassle at all. Do I do this on main or the fork you created? I noticed when I set the log for shaders as file, there is no _Shaders folder created, does it need to be manually created?
@Nawid3333 on GitHub · 2026-10-22 21:48 UTC · original
@Crispy81 thanks! Use the same build as before (68af8de), so it stops at the same place. Main has #1792 since today too, but it also has other changes since then that could move the stop.
You don't need the
_Shadersfolder: with this setting the instructions go into_kyty.txt, the same log as before._Shadersis only written by that command-line dump option, so it's normal that it isn't created.@Crispy81 on GitHub · 2026-10-22 21:52 UTC · original
_kyty.zip
@Nawid3333 on GitHub · 2026-10-23 17:16 UTC · original
@Crispy81 I have a fix for the Black Flag stop from your log (
sampled image descriptor 43 uses unsupported format 20): PR #1867.The shader at 0xb6c does a depth-compare sample (
image_sample_c_lz, like a shadow lookup) on a 4x4 texture whose format is 32-bit unsigned integer (format 20). Kyty only allowed compares on float textures, so it stopped. With the fix it compares the texel bits as a 32-bit float depth, the same way it handles float depth textures. A test that uses the format, size and tiling words from your log (words 1-3 of the descriptor) fails without the change with the sameunsupported format 20error and passes with it, on an RX 9070 XT and a Ryzen iGPU.I couldn't check it in the game myself: on my copy (01.006.038, same as yours) it hung on the first-launch image calibration page, so I never got past it.
Test build (upstream main
9dcff95+ the fix): https://github.com/Nawid3333/KytyPS5/actions/runs/39988770637The Windows download is the
KytyPS5-Windows-x64artifact at the bottom of that page (needs a GitHub login). The window title showsFork build Nawid3333/KytyPS5 b586514.Could you start a new game with it and say where it stops now (the last
Shaders:line and the error, or how far you get)?@Crispy81 on GitHub · 2026-10-23 20:02 UTC · original
Gets the menus now. Selected my options, then it gets to the loading screen, then just exits, with no error message.
_kyty.zip