OpenGL Tearing Issues GeForce 940M

Thinkpad T450s - i7 5600U - 940M Driver 372.54 - Windows 10

So recently I switched to using my laptop’s the dedicated 940M for OpenGL development (after I discovered you can enable it directly with NvOptimusEnablement). However I’ve been experiencing some -extreme- tearing issues. These are less like your typical horizontal tears and more like the screen is being ripped apart. I’ve written a simple Win32/OpenGL program that reproduces the issue https://gist.github.com/albertelwin/5c2f4d9de337b1b707850462be986aed.

I’ve been trying to figure this out for several weeks now and I’ve narrowed it down to a few things. Firstly, this is only a problem on the 940M, the integrated HD 5500 is fine. Secondly, the tearing goes away when I disable VSync but this is obviously a less than ideal solution. Also it seems to be limited to bordered windows. When I switch to borderless the issue goes away. Typically when I’m developing I also have Chrome running in the background, but I noticed that if I close Chrome the tearing disappears. However when Chrome isn’t running, and I’m in full-screen, I sometimes get a strange strobing issue that looks like the current frame and previous frame are being displayed at the same time.

I took a look at some of the Nvidia OpenGL samples and they don’t seem to suffer from this problem. This led me to believe it might be something to do with my Win32 code because the OpenGL samples use GLFW. However when I tested several of my previous GLFW-based OpenGL projects they all had this tearing issue. I’m not sure what the Nvidia OpenGL samples are doing differently.

At this point I’m pretty certain it’s a driver issue. From what I’ve read online it seems to be a common problem on Optimus systems https://forums.geforce.com/default/topic/903422/geforce-mobile-gpus/diagonal-screen-tearing-issues-on-gtx-860m-870m-960m-965m-970m-980m-/14/, but I really want to know for sure.

Am I right in thinking it’s driver issue? And if so is there anything I can do on my end to help? And if it’s not a driver problem then where am I going wrong?

Since I reinstalled my laptop a few days ago, I get the same issues. Your description fits perfectly, although I didn’t test the effects of running or not running Chrome in the background. Using a Geforce GTX 760M with driver version 372.70, Windows 10 on an Acer Aspire V3-772G laptop. After some research and testing the same programs on my desktop machine without any problems, I’m assuming this is a driver issue as well.

One thing that I found fixes the issue entirely is disabling “Threaded Optimization” in the NVidia control panel, which previously was set to Auto. My desktop machine has it set to Auto as well, but does not suffer from any of the described effects.

I tried to research what exactly “Threaded Optimization” does, and what triggers Auto uses to decide whether or not to switch it one, but wasn’t very successful with this so far - any insight appreciated.