gonetz / GLideN64

A new generation, open-source graphics plugin for N64 emulators.
Other
774 stars 181 forks source link

VS 2017 Whole Program Optimization (/GL) breaks Zelda OOT N64 rotating logo (AMD issue) #2098

Closed oddMLan closed 4 years ago

oddMLan commented 5 years ago

image

AMD Radeon R7 240 drivers 19.6.1, Win10 LTSC x64, deleted shader cache, restarted computer

oddMLan commented 5 years ago

@gonetz If you got a second could you look at the Discord64 server (#gliden64 channel) for a moment? there's something we want to overlook with you

oddMLan commented 5 years ago

Apparently it's the /GL flag cauing the breakage. If I disable it, the logo displays fine. Maybe the latest VS 2017 changed something. My msbuild ver. is 15.9.21.664

gonetz commented 5 years ago

@oddMLan I did not visit discord for a long time and forgot how to enter it. Please send a short instruction on my email.

gonetz commented 5 years ago

Microsoft Visual Studio Professional 2017 Version 15.9.11 No problems with Zelda OOT logo on GeForce. I'll try to update and rebuild.

gonetz commented 5 years ago

I updated VS to ver. 15.9.16 It is current version. I rebuilt GLideN64 with it. Still no problems with Zelda OOT logo.

oddMLan commented 5 years ago

What Toolkit/SDK are you using for the Solution? It asks for the Windows 8.1 SDK, but when prompted, I retargeted to Windows 10 SDK 10.0.17763.0

Last thing I suspect can be breaking the whole program optimization, is GLideNUI, though that sounds unlikely... since I got it from the "lazy way" for VS2017 in the wiki page. Installed the QT VS Addon, not from here (I got an error from the server at the time) but from here https://download.qt.io/official_releases/vsaddin/2.4.1/

I installed it, restarted VS, then configured QT VS Tools, added my path to the precompiled Qt files. Then I had to do some extra steps I didn't remember having to do before, because I was getting errors like this when trying to build GLideNUI

image

Then I right clicked the solution in the Solution Explorer > Qt Project Settings. Qt Modules Tab, enabled "Widgets". Less errors now. So go back and enable what I think will be necessary, GUI, Core, Multimedia, OpenGL, etc. I went again and left only the following modules: Core, GUI, UI Tools, Widgets and Windows Extras. Now the GUI builds fine. But the result? Logo is still broken with /GL on my end.

I attach the Release and Debug builds here, and see if one of the optimizations is breaking AMD but not Nvidia... though I doubt it. Debug.zip

gonetz commented 5 years ago

First, I use QT Visual Studio Tools addon, which I found in Tools->Extensions and Updates panel, Online section. May be it is the same vsaddin as the one you installed. I had no errors with building GLideNUI using my "lazy way" static build for VS2017 I just open GLideN64 solution, choose solution QT version (right click the solution) and build.

Second, your builds work fine on my GeForce, both release and debug. That is Zelda logo is correct. May be something wrong with new AMD drivers? My radeon is quite old, and I had no issues with Zelda logo on it too. I did not test your builds with it though.

You may also build GLideN64 for mupen64plus and check, how it works. If the problem persists with mupen64plus, it definitely is not a problem with QT.

oddMLan commented 5 years ago

Okay, I'll build a mupen ver. and check with it.

oddMLan commented 5 years ago

image Nope, still broken with Mupen64Plus

gonetz commented 5 years ago

I tried your builds from Debug.zip on my desktop with AMD CPU + Radeon. Zelda logo works correct with both builds. It seems to be a problem with your configuration. May be you have some Reshade filters enabled?

oddMLan commented 5 years ago

I don't have external shaders applied. Are you using the latest drivers? Maybe it is a problem only with the latest drivers. Although, I wonder why the /GL flag is breaking it, and why disabling it fixes it. It doesn't make sense. I also disabled AMD's driver cache, and that didn't fix it. Your builds have the /GL flag, and they work correct on my end. For the VS project, I chose "Retarget solution" to Windows 10 SDK 10.0.17763.0. What SDK do you use? I can try downloading a previous SDK, and see if that is a problem.

gonetz commented 5 years ago

Are you using the latest drivers?

No, ver. 22.19.677.257, two years old.

Your builds have the /GL flag, and they work correct on my end.

I use VS 2015 mostly.

What SDK do you use?

I have only one option in "Retarget solution" : 8.1

oddMLan commented 5 years ago

I uninstalled my GFX driver with DDU, and did a clean install of a newer version. Same issue. Changing the SDK to Windows 8.1 didn't solve the issue either. I just confirmed that this is a VS 2017 problem. Compiling in VS 2017 with the VS 2015 toolset doesn't have this issue on my AMD card with latest drivers, even with /GL . However, on your end my VS 2017 build with /GL didnt manifest the issue. So this is a very specific compiler + driver issue...

oddMLan commented 5 years ago

Clearly some optimization done by VS 2017 is breaking on AMD and not Nvidia. Is there a good way to compare the relevant assembly code generated across VS2015 and VS2017, both with /GL? What code does the N logo lightning? Some lightning normalization step?

gonetz commented 5 years ago

Is there a good way to compare the relevant assembly code generated across VS2015 and VS2017, both with /GL?

Never did anything like this.

What code does the N logo lightning? Some lightning normalization step?

LIGHTING + TEXTURE_GEN (generation of texture coordinates depending on LookAt structures) : gSPProcessVertex

Craftyawesome commented 4 years ago

I am having the same issue on oot 1.0, but on nvidia. Only on 1.0, not on 1.2. image GLideN64-517723d3 (appveyor zilimar) Nvidia GTX 1060 441.20 drivers (latest)

oddMLan commented 4 years ago

AppVeyor builds use VS 2017. Good to know that it is reproducible on Nvidia too. Sounds like a bad compiler optimization. @fzurita got any ideas that can help us diagnose the issue?

kev4cards commented 4 years ago

This happens for me, also. Same GlideN64 build, same game version, and same graphics card+driver. The problem also occurs with Intel UHD Graphics 630 (integrated, i7-8750H processor). I can see part of the N go from black to color as it rotates from the right to the front (if that's worth anything).

On a side note (most likely unrelated), checking "render N64 frame buffer to main screen" produces a white screen.

oddMLan commented 4 years ago

Fixed, no significant performance hit noticed.