wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

Screen flickering on Nvidia Optimus

Open jsonmona opened this issue 2 years ago • 7 comments

Description Screen flickers (briefly shows white screen) when resizing.

As far as I can test, this only happens with Vulkan backend, and requesting LowPower adapter with nvidia optimus enabled.

  • Using nvidia adapter (by requesting HighPerformance adapter) will eliminate this issue
  • Disabling nvidia adapter will eliminate this issue
  • Using DX12 backend will eliminate this issue
  • Screen refresh rate (60Hz vs 165Hz) is irrelevant

Oddly, I get the same issue whenever I launch Kakaotalk (a Korean messenger app). In that case, the screen goes white without triggering repaint event, causing the app to become stuck on the white screen until the next repaint event occurs.

Repro steps

  1. cargo run --example cube
  2. Keep resizing the window

Expected vs observed behavior Screen flickers (briefly shows white screen).

Extra materials Here is a video recording of the issue (contains flashing lights): video

I do get a single validation error at start, but I believe it's irrelevant because I also get those even when I disabled nvidia adapter.

Platform

  • Windows 11 x64
  • Laptop with Nvidia optimus (Intel iGPU + Nvidia dGPU)
  • wgpu version tested: both current master (42b48ec) and v0.15.0 on crates.io
  • Intel iGPU: 31.0.101.3251 (12th Gen Intel(R) Core(TM) i9-12900H)
  • Nvidia dGPU: 31.0.15.2756 (NVIDIA GeForce RTX 3070 Ti Laptop)

jsonmona avatar Feb 03 '23 09:02 jsonmona

This sounds like a driver issue.

Just a few more questions for completeness:

  • Are you using an external monitor?
  • If yes, can you try to reproduce it with the built-in display?
  • Could you tell us the model of your laptop? Some have a multiplexer and if they don't it would be useful to know how the display outputs are wired internally.

teoxoy avatar Feb 21 '23 14:02 teoxoy

@teoxoy Sure!

  • I tested using built-in monitor.
  • It's Asus Zephyrus M16 (2022). It has MUX to disable internal GPU.
  • Issue persists with a monitor connected to dGPU directly.

According to Nvidia control panel, only built-in display is connected to iGPU, and all external ports are connected to dGPU. So I tried to replicate the issue with a HDMI monitor (which Nvidia control panel reports as connected to dGPU), and the issue was still there.

It indeed sounds like a driver issue. If you can point to some other Vulkan applications, I would be happy to test them too.

Probably not important, but the issue also persists when I attach RenderDoc. For some reason, RenderDoc fails with VK_ERROR_DEVICE_LOST when I click EID 20 and 22 - the vkCmdDrawIndexed call. It might be RenderDoc's bug, but it's weird.

The screenshot of RenderDoc: RenderDoc failing with device lost error

jsonmona avatar Feb 21 '23 23:02 jsonmona

Thanks for all the details! I'm not sure about the RenderDoc issue.

So the conclusion is that just having optimus enabled and using the Intel iGPU causes the flicker on resize behavior.

Not sure what we can do about this, ideally we should use DX12 on Windows (see https://github.com/gfx-rs/wgpu/issues/2719).

teoxoy avatar Feb 22 '23 19:02 teoxoy

I get the same issue. BadReize Pc Specs OS: Window 10 CPU: AMD Ryzen 5 3600 GPU: AMD Rx 6700XT

That was using the primary Backend so i presume Vulkan

n1ght-hunter avatar Mar 23 '23 01:03 n1ght-hunter

Looks like related to this SO question: https://stackoverflow.com/q/58808444

jsonmona avatar Jul 27 '23 10:07 jsonmona

@jsonmona There's kinda slim chance, but can you try https://github.com/gfx-rs/wgpu/pull/5681 to see if this fixes your issue?

cwfitzgerald avatar May 08 '24 23:05 cwfitzgerald

@cwfitzgerald Sorry, but I do not own the laptop anymore. Maybe others could help? @n1ght-hunter

jsonmona avatar May 11 '24 08:05 jsonmona