Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize and use increased precision when normalizing light directions #10477

Merged
merged 1 commit into from Aug 4, 2022

Conversation

Pokechu22
Copy link
Contributor

This normalization was added in 02ac5e9, and changed to use floats in 4bf031c. The conversion to floats means that sometimes there is insufficient precision for the normalization process, which results in values of NaN or infinity. Performing the whole process with doubles prevents that, but games also sometimes set the values to NaN or infinity directly (possibly accidentally due to the values not being initialized due to them not being used in the current configuration?).

The version of Mesa currently in use on FifoCI (20.3.5) has issues with NaN. Although this bug has been fixed (https://gitlab.freedesktop.org/mesa/mesa/-/commit/b3f3287eac066eae16dce0e47aad3229dcff8257 in 21.2.0), FifoCI is stuck with the older version.

This change may or may not be incorrect, but it should result in the same behavior as already present in Dolphin, while working around the Mesa bug.

This PR is an alternative to #10475 that does not introduce regressions of things fixed by #394, but also does not cause mp3-bloom to be hardware-accurate. It would make sense to merge this as a stopgap to work around the Mesa issue while I research this behavior further.

@Pokechu22
Copy link
Contributor Author

I've looked over the fifoci differences and they all seem correct. shadow-eyes still shows an issue, but the problem that that case is looking at is that the eyes have NaN for normal vectors, so I'm not surprised that they have a transparency issue with Mesa with that NaN problem. I also noticed that rs2-skybox2 has an issue on the last frame fixed here, but not on #10475; I'm not sure why.

As one more clarifying note, the issue being targeted here is for Mesa's llvmpipe, which is rendering on the CPU. I don't think most end-users are affected by this problem, but it still is annoying to not have correct rendering on FifoCI, and thus worth working around like this.

This normalization was added in 02ac5e9, and changed to use floats in 4bf031c.  The conversion to floats means that sometimes there is insufficient precision for the normalization process, which results in values of NaN or infinity.  Performing the whole process with doubles prevents that, but games also sometimes set the values to NaN or infinity directly (possibly accidentally due to the values not being initialized due to them not being used in the current configuration?).

The version of Mesa currently in use on FifoCI (20.3.5) has issues with NaN.  Although this bug has been fixed (https://gitlab.freedesktop.org/mesa/mesa/-/commit/b3f3287eac066eae16dce0e47aad3229dcff8257 in 21.2.0), FifoCI is stuck with the older version.

This change may or may not be incorrect, but it should result in the same behavior as already present in Dolphin, while working around the Mesa bug.
@dolphin-emu-bot
Copy link
Contributor

FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:

  • burnout2-vehicletextures on ogl-lin-mesa: diff
  • chibi-robo-fastdepth on ogl-lin-mesa: diff
  • chibi-robo-zfighting on ogl-lin-mesa: diff
  • custom-brawl-char on ogl-lin-mesa: diff
  • ea-pink on ogl-lin-mesa: diff
  • find-mii on ogl-lin-mesa: diff
  • fishing-resort-map on ogl-lin-mesa: diff
  • fortune-street-white-box on ogl-lin-mesa: diff
  • jb-shadow on ogl-lin-mesa: diff
  • jj-awae-mirrored on ogl-lin-mesa: diff
  • kirby-logicop on ogl-lin-mesa: diff
  • last-story-shadows on ogl-lin-mesa: diff
  • mario-golf-oob on ogl-lin-mesa: diff
  • MaS-LOG-wiimote on ogl-lin-mesa: diff
  • melee-depth on ogl-lin-mesa: diff
  • melee-lighting on ogl-lin-mesa: diff
  • milotic-texture on ogl-lin-mesa: diff
  • mkdd-efb on ogl-lin-mesa: diff
  • mkw-bridge on ogl-lin-mesa: diff
  • mkwii-bluebox on ogl-lin-mesa: diff
  • monkeyball-fuse on ogl-lin-mesa: diff
  • my-word-coach on ogl-lin-mesa: diff
  • pm-hc-jp on ogl-lin-mesa: diff
  • rs2-skybox on ogl-lin-mesa: diff
  • rs3-bumpmapping on ogl-lin-mesa: diff
  • rs3-skybox2 on ogl-lin-mesa: diff
  • sfa-shadows on ogl-lin-mesa: diff
  • shadow-eyes on ogl-lin-mesa: diff
  • smg2-fog on ogl-lin-mesa: diff
  • smg-roar on ogl-lin-mesa: diff
  • sms-bubbles on ogl-lin-mesa: diff
  • sms-gc on ogl-lin-mesa: diff
  • sms-water on ogl-lin-mesa: diff
  • soa-black on ogl-lin-mesa: diff
  • sonic-riders-blur on ogl-lin-mesa: diff
  • sonic-riders-zg-4p on ogl-lin-mesa: diff
  • sonicriderszg-gb on ogl-lin-mesa: diff
  • ssbb-mod-lloyd on ogl-lin-mesa: diff
  • ssbm-pointsize on ogl-lin-mesa: diff
  • tp-skin on ogl-lin-mesa: diff
  • viewitful-joe-distortion on ogl-lin-mesa: diff
  • ztp-grass on ogl-lin-mesa: diff

automated-fifoci-reporter

@Tilka Tilka merged commit ceae42b into dolphin-emu:master Aug 4, 2022
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants