GS/DX12/VK: Shader based sprite round/clamp/align for upscaling. (WIP)#14187
GS/DX12/VK: Shader based sprite round/clamp/align for upscaling. (WIP)#14187TJnotJT wants to merge 5 commits intoPCSX2:masterfrom
Conversation
Yes, that screen is fixed at 2x (edit: there's a line next to "S" in the bottom-right that's also in SW so will need to be checked on a PS2): However, it causes a line in another UI (also in master/PR SW) so it needs to be checked on a PS2: PR 1x (see above the "Piece"): Edit: Looks like both lines occur on a PS2 also:
Shining Force EXA_SLUS-21567_20240617191607.gs.xz.zip |
|
@TJnotJT - NICE! Thanks for the info. :) |
88f17f5 to
c9e610f
Compare
Thanks for catching that. I did some quick testing with a Tekken Tag dump, and setting |
|
I can report that at least menu part of the bug was fixed, thank you, @TJnotJT ! But as I reported earlier in another pr, hub map, all icons and menu boxes are now all shifted to the right. Text looks a bit off too. Also all the circle borders around the icons are uneven, but they are not shifted. And my eyes are not decieving me here, if you fast scroll between two images in a viewer, you can see how the whole screen has a shift. I tried to reproduce the scene as close as I can in two different builds. Actually AccurateUVRounding = 0 fixes the shift, but the fonts are off again and now icons shift is inverted. On the bright side, menu lines are still fixed I've made two dumps of this frame (all with 3x scaling as before), first with default settings And this with rounding set to 0 Hope you can get to the bottom of it. Edit. |
|
@Shifroval Thanks for testing and the feedback. The blocky text and alignment issues are a limitation of this PR, as it relies on native alignment/rounding as a guide. Here’s a frame captured on a PS2, showing similar issues: We could try heuristics or additional settings to mitigate this, but that may be tricky and might fix some cases while breaking others. It’s something we could explore in the future. |
|
Ok, I finally got my old ps2 up and running (SCPH-90008 with opl running games over ethernet), I've no capture card, but I fiddled with gsm settings to make image more or less acceptable to take a photo. So I guess that concludes the case? The only thing that I still can't be certain about is the image shift, is it a byproduct of the fix, or the whole time pcsx2 was rendering the image wrong? I know you can run gs dumps on your ps2, @TJnotJT, could you please capture how they look for you? You see the shift too, right? Also I faintly remember there was a pr many years ago that fixed map rendering glitch, I believe it also 'fixed' how ps2 was rendering it, making it more geometrically accurate, but apparently less hardware accurate. For instance the screenshots of old lparchive playthrough have uneven edges, but centered icons, but that's from 2011 If the whole purpose of pcsx2 is to be as accurate to the real hardware as possible, then your fix actually nailed it down perfectly. But maybe the shift is still wrong. |
In many cases, the fix applied in #14078 results in a 1-pixel texture shift due to how the GS rounds UV coordinates. Here are the frames for comparison, the map does appear to be shifted between PS2/PR and master. |
Thank you for testing this, I can see that menu sprites are shifted, yes (and I think that's expected, as you say texture shift), but I'm more concerned about 3d geometry or viewport space (not sure how to call it here) shift. In all cases I never touched the camera and only paused the game at the exact same spot, you can see that 2 screens from PR have identical street and city geometry layout and position of the portal model on the screen (ignore npcs, they're always running around), but Master's viewport is slightly shifted to the left. I can reproduce these shots easily and in all cases can see it. On your frames I can only see sprite shift. |
|
@Shifroval Yes, there is a viewport shift as well, the PR applies a native half-pixel offset to all geometry. The idea is to align upscaled pixels with the native pixel grid so they map cleanly (e.g., at 2x, each native pixel corresponds to a 2×2 block; at 3x, 3×3, etc.). This makes it easier to snap sprites to native coordinates and do rounding, since the mapping between upscaled and native pixels is unambiguous. There are definitely some downsides as noted in the OP, but I’m not entirely sure which of them are specifically due to the half-pixel offset versus the overall alignment/rounding approach. |
c9e610f to
c3fd0ef
Compare






















Status: Currently a WIP for testing so bug reports are appreciated.
Description of Changes
Rationale behind Changes
Details/Config
Implements the following sprite adjustments:
Adds the following INI settings:
AccurateUVRounding:0(off)1(on)1.SpriteAlign:0(off)1(align)2(align + clamp)2.Limitations
AccurateUVRounding = 1may cause some texture to lose resolution. Can sometimes be improved withAccurateUVRounding = 0and keepingSpriteAlign = 2to prevent lines.SpriteAlign = 2(clamp+align) can sometimes cause seams. Can sometimes be improved withSpriteAlign = 1(align only).Suggested Testing Steps
Use DX12 or VK with 2x or higher upscaling. The following settings are enabled by default:
The following may be better in some cases at reducing lines while keeping good UI quality:
The followin may be better in some caes (e.g. some Tekken games) where there are seams in the frame:
Did you use AI to help find, test, or implement this issue or feature?
To ask questions about GLSL/HLSL and other topics. Also see the answer here: #14078.
Comparisons (fixes)
bge.gs.xz (needs autoflush enabled)
Master 2x

PR 2x

Yu-Gi-Oh! The Duelists of the Roses_SLUS-20515_20250511091941.gs.xz (font lines)
Master 2x

PR 2x (some font clipping as with native)

Dynasty_Warriors_5_-_Xtreme_Legends_floor.gs.xz (lines in UI and floor)
Master 2x

PR 2x

Street Fighter III - 3rd Strike_SLPM-65621_20220827100351.gs.xz (lines)
Master 2x

PR 2x

Psychonauts_SLUS-21120_20240704234653.gs.xz (bloom on signs)
Master 2x

PR 2x

Armored.core.2.Arena.text.gs.xz (font lines)
Master 2x

PR 2x

Astro Boy_SLUS-20867_20260131162220.gs (UI lines)
Master 2x

PR 2x

Astro Boy_SLUS-20867_20260131162220.zip
Disney G-Force_SLUS-21891_20260131161732.gs (font lines)
Master 2x

PR 2x

Disney G-Force_SLUS-21891_20260131161732.zip
hack_Infection_3x.gs (font lines)
Master 2x

PR 2x (some blocky font like native)

hack_Infection_3x.zip
Comparisons (breaks)
Dragon Quest VIII - Journey of the Cursed King_SLES-53974_20240619012551.gs.xz (broken bilinear antialias, see face)
Master 2x

PR 2x

Jak_and_Daxter_-_The_Precursor_Legacy_SCES-50361.gs.xz (broken bilinear antialias, fuzzy)
Master 2x

PR 2x

Pac-Man_World_2_SLUS-20224_20220816132032.gs.xz (blocky UI/balls; a bit better with rounding disabled)
Master 2x

PR 2x

PR 2x (

AccurateUVRounding = 0,SpriteAlign = 2)Armored_Core_2_SLUS-20014_20240407012352.gs.xz (fixes lines but lowers UI quality to native; a bit better with rounding disabled)
Master 2x

PR 2x

PR 2x (

AccurateUVRounding = 0,SpriteAlign = 2)