shader: zero-extend native 16-bit destination writes #419
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!419
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/419/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?
@brandostrong on GitHub · 2026-08-30 19:52 UTC · original
brandostrong:fix/native-16bit-zero-extend→main· +27 −10 · 3 files · 1 commits · closed without mergingProblem
#370 changed native 16-bit destinations to preserve the untouched half. On that commit
GTA V draws red wireframe outlines over geometry, black window interiors and a grey
horizon band.
Bisecting the commits merged that day isolates it — everything up to and including #404
renders correctly, adding #370 does not.
Before #370, VOP2 F16 already wrote the low half, since
ApplyDefaultVop2F16Destinationforced
sdwa_sel = 4. So the effective change was that VOP1/VOP3 native writes went fromzero-extending the dword to preserving the upper half.
Change
Write16Bitszero-extends for a destination the instruction did not encode as SDWA, andmerges only when a half is explicitly selected.
ApplyDefaultVop2F16Destinationisrestored — without it VOP2 F16 flips from preserve to zero-extend, a regression the other
way.
The rest of #370 stands:
explicit_sdwa_dst, the relaxed destination gates, clamp on theinexact conversions, the
V_CVT_PKRTZ_F16_F32modifiers.NativeAndSdwa16BitDestinationWritespins the old semantics, so its expectations move.Index 10 stays
0xaaaa4200(VOP2V_ADD_F16DPP) and index 6 keeps its0xf00dhigh half(explicit SDWA,
DST_UNUSED = PRESERVE), which is what bounds the change. Index 6's lowhalf moves
0x3c00->0x7c00: it readsWORD_1of a register a native write filledearlier, now
0.0h, soV_RCP_F16returns+inf.I could not find preserve-vs-zero for GFX10 native 16-bit destinations stated in the RDNA2
ISA guide or the LLVM GFX10 tables, so the evidence here is the game and not the doc.
Claude bisected this and wrote the change. If preserve is actually right for the hardware
and GTA V is leaning on zero-extension for some other reason, some other fix may be better
@Nmzik on GitHub · 2026-08-30 23:19 UTC · original
@brandostrong Yeap, both RDNA2 docs and LLVM say native 16-bit writes preserve the untouched half... So, bug may be somewhere else
@brandostrong on GitHub · 2026-08-31 02:42 UTC · original
Yeah, I saw that for 5 specific opcodes, in 12.12 of the rdna2 docs. My only argument is that it says it for those but not necessarily the rule for others, but I wouldn't expect that kind of ambiguity either. This is pretty beyond me in low-levelness though, so I defer to you.
I'll try digging into it a bit deeper.
@brandostrong on GitHub · 2026-08-31 04:20 UTC · original
I sent myself down a red herring, #370 did not cause the wireframes. I was able to confirm multiple ways that the preserve does in fact happen in situ, using prosperos among other things, totally refuted this PR multiple ways. The red wireframes were separate problem unrelated to this upstream entirely.
Pull request closed