-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
The new ClearPass leads to flickering when fps is less than 60 #3307
Comments
I tried reproducing by adding |
The pbr_pipelined example normally runs as it should, but if I add a thread sleep of 16ms inside ShadowPassNode, then I get a black screen (in windowed mode). Whenever I move the mouse, I get flickering frames coming through. What's weird though is that when I maximize the screen, things seem to work as expected. Edit: still flickering on fullscreen, but much less than in windowed mode. I have these issues on Linux both for X11 and Wayland. |
Can't reproduce on my mac with a sleep inside It may be a linux issue, or on how your card driver handles the command. Could you add the info from your gpu if someone can reproduce? |
This is on a Dell Xps 9310 AdapterInfo {
name: "Intel(R) Xe Graphics (TGL GT2)",
vendor: 32902,
device: 39497,
device_type: IntegratedGpu,
backend: Vulkan
} It might be a graphics card issue, but if I disable the ClearPass and do the clear as before inside MainPass3d, then it works again without flickering. |
I can reproduce the issue on my end with the following minimal example. The screen flickers very rapidly between a grey frame and a black window. use bevy::{
prelude::{App, Commands},
render2::camera::PerspectiveCameraBundle,
utils::Duration,
PipelinedDefaultPlugins,
};
fn main() {
App::new()
.add_plugins(PipelinedDefaultPlugins)
.add_startup_system(setup)
.add_system(sleep)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn_bundle(PerspectiveCameraBundle::default());
}
fn sleep() {
std::thread::sleep(Duration::from_millis(20));
} |
Do we need to test it on additional environments? I have:
|
Did a lot more testing and I think I'm hitting three different issues, but they give similar results:
|
@zamazan4ik would be great if you can confirm seeing the same behavior on your Fedora. (I'm testing on Fedora 35 with a Tiger Lake integrated GPU) Might also be good to check on Windows for sure. |
I can reproduce this on Ubuntu 18 (Intel® UHD Graphics 630). Attaching a heavily flickering run of flickering.mp4 |
|
Running
It could definitely be a GPU issue. From what I've heard Intel's drivers for Vulkan on Linux are not very good. |
Ok so I just remembered I also had an Intel laptop around: An i5-3210M (HD Graphics 4000) Ivy Bridge processor running Arch Linux.
Maybe it's still an Intel issue, but only with newer iGPUs? We'll need more testing from people with Intel chips to see. This might be a stretch, but there could be other factors involved such as monitor refresh rates? Still, using the older method the flickering doesn't happen, so... stuff is happening. |
@manokara I think the main issue with ClearPass only occurs when the ShadowPass takes a noticable amount of time. This is the order of the renderpasses:
Before the ClearPass PR, clearing and painting the whole scene happened at the same time. Could you see what happens if you add a |
I was able to fix the flickering for X11 by disabling vsync (either Immediate or Mailbox are fine. Fifo triggers the issue). For Wayland, the issue still persists. |
I assume that by "putting a sleep in ShadowPassNode" means putting it in its The problem might be somewhere in the process of passing graphics data to wgpu, maybe double-buffering related. Until recently the rationale was that it's Intel related, but it works fine on my 3210M (albeit slow) as I commented before. |
This seems like a logical error somewhere below us in the stack (wgpu or a driver). The final output from our render graph is a single command queue that does clear passes first, then draws on top of them after that. Timing shouldn't come into play here because the final "command list" submitted to the gpu will be identical no matter how long each step takes. Pulling in wgpu folks to get their take on this: @kvark and @cwfitzgerald. |
Does it reproduce if you capture an API trace and then replay it, either locally or on a different machine? |
Someone experiencing this issue can capture the trace by running the lighting example on main (where the new renderer is now the default and the cargo run --example lighting --features wgpu_trace The trace should show up in a |
@kvark I've attached two traces for the lighting example on X11 and Wayland. Both casue the flickering (wgpu 0.11.5). When I maximize the windows, the flickering disappears. Thank you for looking into this! AdapterInfo {
name: "Intel(R) Xe Graphics (TGL GT2)",
vendor: 32902,
device: 39497,
device_type: IntegratedGpu,
backend: Vulkan
} |
Replaying the first capture doesn't show me any flickering. So this isn't about any kind of logical ordering issues within wgpu itself. |
I don't fully understand the Bevy code, but I was able to disable the creation of the first surface, so there's only one being used. The flickering is still happening though. @cart a surface gets created in bevy_render/lib:116 and then another one bevy_render/view/window:132. To reproduce the issue, I clone the bevy repo and then run |
Running this example on Bevy revision c825fda doesn't expose any flickering to me on Linux.
|
you have the same graphics card as I have? What distro are you running? The results seem to be different for me whether I run the X11 build under Xorg, or under XWayland (the latter gives much more flickering). The most flickering is for Wayland builds under Wayland. The flickering only seems to happen for apps where present_frame is not called within 16ms. You could try the lighting example |
Yes, looks like I have the same GPU, just in a different laptop. I'm running NixOS with KDE (with X11).
Notice the driver version and see how it compares to yours. That |
To add on to your point of graphics card and distro: What Mesa Version are you running? There are recent issues on the mesa repository concerning flickering on intel graphics. Edit: Though the flickering there seems to be different from here. So maybe unrelated. |
Nope, you're right! If I downgrade mesa-* to 21.2.3, then the flickering is gone, so definitely an issue with the new mesa drivers. |
Seems like a fix is underway https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14207 Fixes the flickering in https://gitlab.freedesktop.org/mesa/mesa/-/issues/5744 |
I can reproduce that downgrading mesa to v21.2.5 fixes the issue. Does someone have the setup to locally build and install mesa from source? It would be nice to know if https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14207 resolves our issue. The documented build & install steps in the Readme fail for me at |
@NiklasEi there's a new PR for the issue https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14237 I'll just wait it out for now. |
I can't build this right now because it requires libdrm that is too new, but generally building Mesa was straightforward for me, so I'd like to encourage you to try building it and resolve issues on Bevy discord (can cc me if needed). It would let Intel devs know that the patch is good, or not, before merging. |
I just installed the new Fedora 35 21.3.2 build in pending/testing and everything works as expected now! |
Version |
Bevy version
Latest git
Operating system & version
Fedora
What you did
cargo run --example 3d_scene_pipelined
What you expected to happen
The scene should render without flickering.
What actually happened
Sometimes the scene stays blank. Other times, it flickers between the correct frame and a blank frame.
This seems to be caused by the changes in #3209
Additional information
The scene runs at 40fps on my laptop. Most time seems to be spent in light clustering:
Improving the performance of the clustering might fix this issue, but the real issue seems to be that clear happens every frame, while new frames might not be ready yet, leading to the blank frames.
If I go to a commit right before the ClearPass, then the scene renders as expected.
The text was updated successfully, but these errors were encountered: