dolphin
dolphin copied to clipboard
VertexShader: Remove the Offset for the Pixel Center + Rename
The pixel center is the same as the rendering APIs we use and there is no need for any offset of 1/12.
Also rename pixel center correction to pixel position correction for the rest of the usages.
This should fix a bunch of the minor graphical issues where lines may be visible between textures.
Fixes issue 12844
FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:
ab11-homebrewonogl-lin-mesa: diffaeon-charge-attackonogl-lin-mesa: diffbk-tevonogl-lin-mesa: diffburnout2-vehicletexturesonogl-lin-mesa: diffchibi-robo-fastdepthonogl-lin-mesa: diffchibi-robo-zfightingonogl-lin-mesa: diffcustom-brawl-charonogl-lin-mesa: diffdbz-depthonogl-lin-mesa: diffdjfny-menuonogl-lin-mesa: diffdjhero2-blendonogl-lin-mesa: diffDKCR-Charonogl-lin-mesa: diffDKCR-fast-depthonogl-lin-mesa: diffea-pinkonogl-lin-mesa: diffed-updatedonogl-lin-mesa: diffet-vidonogl-lin-mesa: difffifa-streetonogl-lin-mesa: difffind-miionogl-lin-mesa: difffishing-resort-maponogl-lin-mesa: difffog-adjonogl-lin-mesa: difffortune-streetonogl-lin-mesa: difffortune-street-fogonogl-lin-mesa: difffortune-street-white-boxonogl-lin-mesa: difffsa-layersonogl-lin-mesa: difff-zero-rainonogl-lin-mesa: diffgoldeneye-depthonogl-lin-mesa: diffgormitionogl-lin-mesa: diffhb-discgolfonogl-lin-mesa: diffinverted-depth-rangeonogl-lin-mesa: diffjb-shadowonogl-lin-mesa: diffjd2-fmvonogl-lin-mesa: diffjj-awae-mirroredonogl-lin-mesa: diffkirby-logicoponogl-lin-mesa: diffkirby-shadowsonogl-lin-mesa: difflast-story-shadowsonogl-lin-mesa: difflego-star-wars-crane-shadowonogl-lin-mesa: difflesson08onogl-lin-mesa: diffline-width-testonogl-lin-mesa: difflm-mario-portraitonogl-lin-mesa: diffluigi-shadowsonogl-lin-mesa: diffmajor-minoronogl-lin-mesa: diffmario-baseball-shadowsonogl-lin-mesa: diffmario-golf-oobonogl-lin-mesa: diffmario-sluggers-baronogl-lin-mesa: diffmario-tennis-menuonogl-lin-mesa: diffMaS-LOG-wiimoteonogl-lin-mesa: diffmegaman-heatonogl-lin-mesa: diffmelee-depthonogl-lin-mesa: diffmelee-lightingonogl-lin-mesa: diffmetroid-visoronogl-lin-mesa: diffmii-channelonogl-lin-mesa: diffmilotic-textureonogl-lin-mesa: diffmini-ninjasonogl-lin-mesa: diffmkdd-babyparkonogl-lin-mesa: diffmkdd-efbonogl-lin-mesa: diffmkw-bridgeonogl-lin-mesa: diffmkw-flagsonogl-lin-mesa: diffmkwii-blueboxonogl-lin-mesa: diffmmx-lightonogl-lin-mesa: diffmonkeyball-fuseonogl-lin-mesa: diffmp2-scanneronogl-lin-mesa: diffmp3-bloomonogl-lin-mesa: diffmp4-vertexcacheonogl-lin-mesa: diffmp7-textonogl-lin-mesa: diffmp8-widescreenonogl-lin-mesa: diffmtennis-zfreezeonogl-lin-mesa: diffmy-word-coachonogl-lin-mesa: diffnddemo-bumpmappingonogl-lin-mesa: diffnddemo-lightingonogl-lin-mesa: diffnes-vconogl-lin-mesa: diffnfsu-purplerectonogl-lin-mesa: diffnfsu-reflectionsonogl-lin-mesa: diffnhl-slaponogl-lin-mesa: diffnintendo-channelonogl-lin-mesa: diffnsmbw-coinsonogl-lin-mesa: diffnsmbw-introonogl-lin-mesa: diffpbr-sfxonogl-lin-mesa: diffpm-hc-jponogl-lin-mesa: diffpw-black-barsonogl-lin-mesa: diffquake-gxonogl-lin-mesa: diffrs2-bumpmappingonogl-lin-mesa: diffrs2-glassonogl-lin-mesa: diffrs2-skyboxonogl-lin-mesa: diffrs2-zfreezeonogl-lin-mesa: diffrs3-bumpmappingonogl-lin-mesa: diffrs3-skybox2onogl-lin-mesa: diffsadx-uionogl-lin-mesa: diffsfa-shadowsonogl-lin-mesa: diffsf-assault-flashingonogl-lin-mesa: diffshadow-eyesonogl-lin-mesa: diffsimpsons-gameonogl-lin-mesa: diffsmb-mirroronogl-lin-mesa: diffsmg2-fogonogl-lin-mesa: diffsmg-marioeyesonogl-lin-mesa: diffsmg-mmgonogl-lin-mesa: diffsmg-roaronogl-lin-mesa: diffsms-bubblesonogl-lin-mesa: diffsms-coconut-drinksonogl-lin-mesa: diffsms-gconogl-lin-mesa: diffsms-wateronogl-lin-mesa: diffsoa-blackonogl-lin-mesa: diffsoniccolors-mmonogl-lin-mesa: diffsonic-riders-bluronogl-lin-mesa: diffsonic-riders-zg-4ponogl-lin-mesa: diffsonicriderszg-gbonogl-lin-mesa: diffspyro-bloomonogl-lin-mesa: diffspyro-depthonogl-lin-mesa: diffssbb-mod-lloydonogl-lin-mesa: diffssbm-pointsizeonogl-lin-mesa: diffss-maponogl-lin-mesa: diffsuper-sluggers-white-outonogl-lin-mesa: diffsw3-dtonogl-lin-mesa: difftaiko-depthonogl-lin-mesa: diffthps3-earlyzonogl-lin-mesa: diffthps4-shadowonogl-lin-mesa: difftla-menuonogl-lin-mesa: difftos-invis-charonogl-lin-mesa: difftp-skinonogl-lin-mesa: difftsp3-pinkgrassonogl-lin-mesa: diffvegas-party-depthonogl-lin-mesa: diffviewitful-joe-distortiononogl-lin-mesa: diffww-song-of-passingonogl-lin-mesa: diffxblade-bloomonogl-lin-mesa: diffxenoblade-menuonogl-lin-mesa: diffzelda1-vconogl-lin-mesa: diffztp-grassonogl-lin-mesa: diffzww-armosonogl-lin-mesa: diffzww-wateronogl-lin-mesa: diffzww-wavesonogl-lin-mesa: diffab11-homebrewonmvk-osx-m1: diffaeon-charge-attackonmvk-osx-m1: diffbk-tevonmvk-osx-m1: diffburnout2-vehicletexturesonmvk-osx-m1: diffchibi-robo-fastdepthonmvk-osx-m1: diffchibi-robo-zfightingonmvk-osx-m1: diffcustom-brawl-charonmvk-osx-m1: diffdbz-depthonmvk-osx-m1: diffdjfny-menuonmvk-osx-m1: diffdjhero2-blendonmvk-osx-m1: diffDKCR-Charonmvk-osx-m1: diffDKCR-fast-depthonmvk-osx-m1: diffea-pinkonmvk-osx-m1: diffed-updatedonmvk-osx-m1: diffet-vidonmvk-osx-m1: difffifa-streetonmvk-osx-m1: difffind-miionmvk-osx-m1: difffishing-resort-maponmvk-osx-m1: difffog-adjonmvk-osx-m1: difffortune-streetonmvk-osx-m1: difffortune-street-fogonmvk-osx-m1: difffortune-street-white-boxonmvk-osx-m1: difffsa-layersonmvk-osx-m1: difff-zero-rainonmvk-osx-m1: diffgoldeneye-depthonmvk-osx-m1: diffhb-discgolfonmvk-osx-m1: diffinverted-depth-rangeonmvk-osx-m1: diffjb-shadowonmvk-osx-m1: diffjd2-fmvonmvk-osx-m1: diffjj-awae-mirroredonmvk-osx-m1: diffkirby-logicoponmvk-osx-m1: diffkirby-shadowsonmvk-osx-m1: difflast-story-shadowsonmvk-osx-m1: difflego-star-wars-crane-shadowonmvk-osx-m1: difflesson08onmvk-osx-m1: diffline-width-testonmvk-osx-m1: difflm-mario-portraitonmvk-osx-m1: diffluigi-shadowsonmvk-osx-m1: diffmajor-minoronmvk-osx-m1: diffmario-baseball-shadowsonmvk-osx-m1: diffmario-golf-oobonmvk-osx-m1: diffmario-sluggers-baronmvk-osx-m1: diffmario-tennis-menuonmvk-osx-m1: diffMaS-LOG-wiimoteonmvk-osx-m1: diffmegaman-heatonmvk-osx-m1: diffmelee-depthonmvk-osx-m1: diffmelee-lightingonmvk-osx-m1: diffmetroid-visoronmvk-osx-m1: diffmii-channelonmvk-osx-m1: diffmilotic-textureonmvk-osx-m1: diffmini-ninjasonmvk-osx-m1: diffmkdd-babyparkonmvk-osx-m1: diffmkdd-efbonmvk-osx-m1: diffmkw-bridgeonmvk-osx-m1: diffmkw-flagsonmvk-osx-m1: diffmkwii-blueboxonmvk-osx-m1: diffmonkeyball-fuseonmvk-osx-m1: diffmp2-scanneronmvk-osx-m1: diffmp3-bloomonmvk-osx-m1: diffmp4-vertexcacheonmvk-osx-m1: diffmp7-textonmvk-osx-m1: diffmp8-widescreenonmvk-osx-m1: diffmtennis-zfreezeonmvk-osx-m1: diffmy-word-coachonmvk-osx-m1: diffnddemo-bumpmappingonmvk-osx-m1: diffnddemo-lightingonmvk-osx-m1: diffnfsu-purplerectonmvk-osx-m1: diffnfsu-reflectionsonmvk-osx-m1: diffnhl-slaponmvk-osx-m1: diffnintendo-channelonmvk-osx-m1: diffnsmbw-coinsonmvk-osx-m1: diffnsmbw-introonmvk-osx-m1: diffpbr-sfxonmvk-osx-m1: diffpm-hc-jponmvk-osx-m1: diffpw-black-barsonmvk-osx-m1: diffquake-gxonmvk-osx-m1: diffrs2-bumpmappingonmvk-osx-m1: diffrs2-glassonmvk-osx-m1: diffrs2-skyboxonmvk-osx-m1: diffrs2-zfreezeonmvk-osx-m1: diffrs3-bumpmappingonmvk-osx-m1: diffrs3-skybox2onmvk-osx-m1: diffsadx-uionmvk-osx-m1: diffsfa-shadowsonmvk-osx-m1: diffsf-assault-flashingonmvk-osx-m1: diffshadow-eyesonmvk-osx-m1: diffsimpsons-gameonmvk-osx-m1: diffsmb-mirroronmvk-osx-m1: diffsmg2-fogonmvk-osx-m1: diffsmg-marioeyesonmvk-osx-m1: diffsmg-mmgonmvk-osx-m1: diffsmg-roaronmvk-osx-m1: diffsms-bubblesonmvk-osx-m1: diffsms-coconut-drinksonmvk-osx-m1: diffsms-gconmvk-osx-m1: diffsms-wateronmvk-osx-m1: diffsoa-blackonmvk-osx-m1: diffsoniccolors-mmonmvk-osx-m1: diffsonic-riders-bluronmvk-osx-m1: diffsonic-riders-zg-4ponmvk-osx-m1: diffsonicriderszg-gbonmvk-osx-m1: diffspyro-bloomonmvk-osx-m1: diffspyro-depthonmvk-osx-m1: diffssbb-mod-lloydonmvk-osx-m1: diffssbm-pointsizeonmvk-osx-m1: diffss-maponmvk-osx-m1: diffsuper-sluggers-white-outonmvk-osx-m1: diffsw3-dtonmvk-osx-m1: difftaiko-depthonmvk-osx-m1: diffthps3-earlyzonmvk-osx-m1: diffthps4-shadowonmvk-osx-m1: difftla-menuonmvk-osx-m1: difftos-invis-charonmvk-osx-m1: difftp-skinonmvk-osx-m1: difftsp3-pinkgrassonmvk-osx-m1: diffvegas-party-depthonmvk-osx-m1: diffviewitful-joe-distortiononmvk-osx-m1: diffww-song-of-passingonmvk-osx-m1: diffxblade-bloomonmvk-osx-m1: diffxenoblade-menuonmvk-osx-m1: diffztp-grassonmvk-osx-m1: diffzww-armosonmvk-osx-m1: diffzww-wateronmvk-osx-m1: diffzww-wavesonmvk-osx-m1: diffab11-homebrewonmtl-osx-m1: diffaeon-charge-attackonmtl-osx-m1: diffbk-tevonmtl-osx-m1: diffburnout2-vehicletexturesonmtl-osx-m1: diffchibi-robo-fastdepthonmtl-osx-m1: diffchibi-robo-zfightingonmtl-osx-m1: diffcustom-brawl-charonmtl-osx-m1: diffdbz-depthonmtl-osx-m1: diffdjfny-menuonmtl-osx-m1: diffdjhero2-blendonmtl-osx-m1: diffDKCR-Charonmtl-osx-m1: diffDKCR-fast-depthonmtl-osx-m1: diffea-pinkonmtl-osx-m1: diffed-updatedonmtl-osx-m1: diffet-vidonmtl-osx-m1: difffifa-streetonmtl-osx-m1: difffind-miionmtl-osx-m1: difffishing-resort-maponmtl-osx-m1: difffog-adjonmtl-osx-m1: difffortune-streetonmtl-osx-m1: difffortune-street-fogonmtl-osx-m1: difffortune-street-white-boxonmtl-osx-m1: difffsa-layersonmtl-osx-m1: difff-zero-rainonmtl-osx-m1: diffgoldeneye-depthonmtl-osx-m1: diffhb-discgolfonmtl-osx-m1: diffinverted-depth-rangeonmtl-osx-m1: diffjb-shadowonmtl-osx-m1: diffjd2-fmvonmtl-osx-m1: diffjj-awae-mirroredonmtl-osx-m1: diffkirby-logicoponmtl-osx-m1: diffkirby-shadowsonmtl-osx-m1: difflast-story-shadowsonmtl-osx-m1: difflego-star-wars-crane-shadowonmtl-osx-m1: difflesson08onmtl-osx-m1: diffline-width-testonmtl-osx-m1: difflm-mario-portraitonmtl-osx-m1: diffluigi-shadowsonmtl-osx-m1: diffmajor-minoronmtl-osx-m1: diffmario-baseball-shadowsonmtl-osx-m1: diffmario-golf-oobonmtl-osx-m1: diffmario-sluggers-baronmtl-osx-m1: diffmario-tennis-menuonmtl-osx-m1: diffMaS-LOG-wiimoteonmtl-osx-m1: diffmegaman-heatonmtl-osx-m1: diffmelee-depthonmtl-osx-m1: diffmelee-lightingonmtl-osx-m1: diffmetroid-visoronmtl-osx-m1: diffmii-channelonmtl-osx-m1: diffmilotic-textureonmtl-osx-m1: diffmini-ninjasonmtl-osx-m1: diffmkdd-babyparkonmtl-osx-m1: diffmkdd-efbonmtl-osx-m1: diffmkw-bridgeonmtl-osx-m1: diffmkw-flagsonmtl-osx-m1: diffmkwii-blueboxonmtl-osx-m1: diffmonkeyball-fuseonmtl-osx-m1: diffmp2-scanneronmtl-osx-m1: diffmp3-bloomonmtl-osx-m1: diffmp4-vertexcacheonmtl-osx-m1: diffmp7-textonmtl-osx-m1: diffmp8-widescreenonmtl-osx-m1: diffmtennis-zfreezeonmtl-osx-m1: diffmy-word-coachonmtl-osx-m1: diffnddemo-bumpmappingonmtl-osx-m1: diffnddemo-lightingonmtl-osx-m1: diffnfsu-purplerectonmtl-osx-m1: diffnfsu-reflectionsonmtl-osx-m1: diffnhl-slaponmtl-osx-m1: diffnintendo-channelonmtl-osx-m1: diffnsmbw-coinsonmtl-osx-m1: diffnsmbw-introonmtl-osx-m1: diffpbr-sfxonmtl-osx-m1: diffpm-hc-jponmtl-osx-m1: diffpw-black-barsonmtl-osx-m1: diffquake-gxonmtl-osx-m1: diffrs2-bumpmappingonmtl-osx-m1: diffrs2-glassonmtl-osx-m1: diffrs2-skyboxonmtl-osx-m1: diffrs2-zfreezeonmtl-osx-m1: diffrs3-bumpmappingonmtl-osx-m1: diffrs3-skybox2onmtl-osx-m1: diffsadx-uionmtl-osx-m1: diffsfa-shadowsonmtl-osx-m1: diffsf-assault-flashingonmtl-osx-m1: diffshadow-eyesonmtl-osx-m1: diffsimpsons-gameonmtl-osx-m1: diffsmb-mirroronmtl-osx-m1: diffsmg2-fogonmtl-osx-m1: diffsmg-marioeyesonmtl-osx-m1: diffsmg-mmgonmtl-osx-m1: diffsmg-roaronmtl-osx-m1: diffsms-bubblesonmtl-osx-m1: diffsms-coconut-drinksonmtl-osx-m1: diffsms-gconmtl-osx-m1: diffsms-wateronmtl-osx-m1: diffsoa-blackonmtl-osx-m1: diffsoniccolors-mmonmtl-osx-m1: diffsonic-riders-bluronmtl-osx-m1: diffsonic-riders-zg-4ponmtl-osx-m1: diffsonicriderszg-gbonmtl-osx-m1: diffspyro-bloomonmtl-osx-m1: diffspyro-depthonmtl-osx-m1: diffssbb-mod-lloydonmtl-osx-m1: diffssbm-pointsizeonmtl-osx-m1: diffss-maponmtl-osx-m1: diffsuper-sluggers-white-outonmtl-osx-m1: diffsw3-dtonmtl-osx-m1: difftaiko-depthonmtl-osx-m1: diffthps3-earlyzonmtl-osx-m1: diffthps4-shadowonmtl-osx-m1: difftla-menuonmtl-osx-m1: difftos-invis-charonmtl-osx-m1: difftp-skinonmtl-osx-m1: difftsp3-pinkgrassonmtl-osx-m1: diffvegas-party-depthonmtl-osx-m1: diffviewitful-joe-distortiononmtl-osx-m1: diffww-song-of-passingonmtl-osx-m1: diffxblade-bloomonmtl-osx-m1: diffxenoblade-menuonmtl-osx-m1: diffztp-grassonmtl-osx-m1: diffzww-armosonmtl-osx-m1: diffzww-wateronmtl-osx-m1: diffzww-wavesonmtl-osx-m1: diff
automated-fifoci-reporter
I looked into this years ago. I imagine there are cases where our pixel center correction rounds incorrectly. Even in the fifoci you can see a case (nhl-slap) where we can see some improvement.
I was hopeful this would fix some of our higher IR scenarios (ex: Mario Kart Wii) but it does not. In fact, when combined with our vertex rounding hack, it now makes some titles worse (Silent Hill and Spongebob), I'm assuming because the rounding no longer is applied in the same way.
It also doesn't seem to fix known issues but at native it does seem to be mostly positive.
I can't really say what is right, as this was supposedly hardware tested.
Curious if @JMC47 remembers why the offset was added in the first place?
And will tag @Pokechu22 as well.
This is likely a necessary change based on the fifoci fixes, but we may need to adjust higher internal resolutions differently to prevent issues.
For reference, the original issues, for why this was added in the first place: https://bugs.dolphin-emu.org/issues/267, https://bugs.dolphin-emu.org/issues/7196 .
See article entry: https://dolphin-emu.org/blog/2014/04/30/dolphin-progress-report-april-2014/#40-1474-consider-shifted-pixel-centers-by-neobrain
If this is really redundant now, we should figure out what fix made it that way. It might play into a higher IR fix (and remove the need for vertex rounding?)
After more serious testing, this does break a lot of stuff too. Sonic Heroes - the game mentioned in that issue report, breaks.
The issue with Sonic Heroes was exposed by this change but when using native the issue is only on OpenGL and I know what's gone wrong. OpenGL is wrongly is clamping EFB in the wrong direction, because the Y is reversed as compared to other video backends.
I will fix that issue.
What about the issues in the menus of Sonic Heroes on Vulkan, the "no memory" card screen looks really wrong for instance.
OpenGL
Vulkan
On Just Dance 2 FMV, it's still not working properly
https://fifo.ci/compare/12546504-12538644/
I'll quote degasus here.
https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoBackends/Software/Rasterizer.cpp#L333
"trunc(pos * 16) - 8, the trunc operation moves the center of the pixel.
Vertex rounding with an offset would be correct. However everything just at 1xIR. With upscaling, I'd expect game developers to not care and to just floor "a bit" so that .5+-epsilon as position gets a deterministic rounding "
The pixel center is the same as hardware backends and there is no need for any offset of 1/12.
I'm a bit confused about what "hardware backends" is supposed to mean here (unless you instead mean the software renderer?)
Also, I've always wondered how BPMEM_DISPLAYCOPYFILTER affects this. GX_SetCopyFilter only makes use of that if antialiasing is enabled, but it sets all 4 of them to 0x666666 if antialiasing is disabled. That value may still be relevant, though I'm not sure if any games actually set it to a different value outside of antialiasing (it's probably not exposed at all). (We don't emulate the GameCube/Wii antialiasing at all, either.)
@JMC47
After more serious testing, this does break a lot of stuff too. Sonic Heroes - the game mentioned in that issue report, breaks.
I have opened a PR to handle the Sonic Heroes issue in PR #12982.
On Just Dance 2 FMV, it's still not working properly
I will not be able to resolve the issue with Just Dance 2 FMV as it's not even working on the software renderer. The issue does not originate from this change.
What about the issues in the menus of Sonic Heroes on Vulkan, the "no memory" card screen looks really wrong for instance.
If there are other backend specific issues, then the issue is not with fixing the pixel center, the issue is with that backend. But, I will look at that too and see what's happening.
@Pokechu22
I'm a bit confused about what "hardware backends" is supposed to mean here (unless you instead mean the software renderer?)
Sorry, I had meant the hardware backends's APIs, as in the rendering APIs themselves since OpenGL, Direct3D and Vulkan place the pixel center at exactly (0.5, 0.5)
Also, I've always wondered how BPMEM_DISPLAYCOPYFILTER affects this.
There is definitely more to tackle with offset issues and that might hold some answers
Sorry to hijack this PR, but is there any chance that this "pixel center" calculation (or its interaction with BPMEM_DISPLAYCOPYFILTER) is behind the problem reported in this issue (corrupted map in Twilight Princess for GC when using Native Resolution + SSAA)? The issue seems to be related to getting a proper "pixel center" in the case of even IRs. Sorry again if this is completely unrelated. Thanks!