godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
86.96k stars 19.49k forks source link

Forward Plus Renderer causes frameskips/jitter/judder/stutter, GPU frames aren't sorted correctly on Windows #84137

Open Cyangmou opened 8 months ago

Cyangmou commented 8 months ago

Godot version

4.1.3

System information

Windows 11, NVIDIA GeForce GTX 1070, i7-7700K CPU 4.20GHz, 1920x1080 60Hz IPS monitor & a 2560x1440 adaptive 100Hz monitor

Issue description

The forward plus renderer, causes jitters in movement. It's especially visible when V-Sync is switched on. This happens in 2D and 3D Those jitters are more or less pronounced, depending on which screen you use, they might not be very visible on a 60HZ screen but are still there.

!

when i talk about "jitter" i am talking about this effect happening in the video above or clearly observable in this older video here at 5, 8, 11 and 13 seconds: Video

The problem seems to be tha tthe renderer has a cache of 4 GPU frames and that the sorting of those frames is jumbled up. So basically by design we seem to have an reoccuring order of 0, 1, 3, 2, 3, ... 4, 5, 8, 7, 8... This means some frames don't get shown, others get shown twice and the judder is caused by a step back

Currently it's not clear if it's a problem with the way how the frames are put together, or if it's a driver related issue related to memory. It could be 2 bugs, as comment sin the thread show other bugs play into this

Steps to reproduce

Can this be circumvented?

No. It's a very critical and very deep sitting bug. With the forward plus renderer there is no way to circumvent this and it will happen on any hardware. THe higher the resolution, the less obvious the bug is, however it's always there. The forward plus renderer is simply broken and can't be used in the current state.

You could Use the gl_compatibility renderer, which doesn't have this problem, but this is not a good solution either.

Minimal reproduction project:

I made a simple project in which the character can only run left and right per key input. That's literally all the code we need to test the issue properly, the setup described above is key for making it visible.

Conclusion

  1. Only by enabling the gl_compatibility renderer the jitter seems to be solved. The visibility of the problem and the intensity the skips are happening is however different based on the settings.
  2. It happens in 2D and 3D
  3. Disabling V-Sync with the forward plus renderer makes issues less pronounced than with having V-Sync enabled...
  4. ...especially on a 60Hz screen on windows disabling the V-Sync leads to way less experienced jitter, it's still there though
  5. The problem happens with process function and with physics_process() function.

Hypothesis

I think the core of the problem lies with the forward plus renderer (There however might be additional problems with V_Sync, Camera or Physics)

Minimal reproduction project

Project Download This includes a small platformer project. Project settings need to be adjusted according to my tests to reproduce the issues.

jbikeler commented 4 months ago

https://github.com/godotengine/godot/assets/36314810/65ba70b9-c700-4014-aaae-277e83069811

Hey, I've encountered this issue as well within Godot v4.2.1.stable.official [b09f793f5] where toggling VSYNC on and off leads to noticeable changes in tween behavior attached to nodes like Sprites. This seems to extend beyond the previously discussed impacts on character controllers and cameras, affecting animations and movements across the board.

Steps to Reproduce

  1. Attach a script incorporating a tween to a node, for example, a Sprite.
  2. Experiment with turning VSYNC on and off.
  3. Observe the variations in tween behavior with these changes.

To provide a clearer picture, I’ve included a video demonstrating these steps and the observed effects.

Expected vs. Observed Behavior

Ideally, tween operations should remain stable and consistent irrespective of VSYNC status, ensuring animations are smooth. However, toggling VSYNC alters the tween behavior, compromising animation smoothness and predictability.

Technical Environment

Please let me know if further information is required or how I can help contribute to resolving this.

vpellen commented 4 months ago

@jbikeler This may be fixed in 4.3, there was some work done on the renderer, can you reproduce it on the latest dev release?

jbikeler commented 4 months ago

@jbikeler This may be fixed in 4.3, there was some work done on the renderer, can you reproduce it on the latest dev release?

Yes, using 4.3 Dev 4 I still get the same result. I did see earlier in this forum that it could be a swap chain issue and I saw that there are new settings related to VSYNC and swap chain but I haven't done any testing with them in 4.3. Purely through enabling and disabling VSYNC I still get the same results.

https://github.com/godotengine/godot/assets/36314810/bbd0b189-bff0-45f5-8ab9-31926525dd4c

jbikeler commented 4 months ago

The recording I just posted was a duplicated project from 4.2.1 opened in 4.3.dev4, but just to make sure I also completely rebuilt the project for the tween test in 4.3.dev4 from scratch and I still got the same results.

vpellen commented 4 months ago

Do you encounter such issues with the directx renderer, or only vulkan? I had similar jittering but managed to fix it by modifying the uhhh swapchain setting in my nvidia control panel after the render fixes were merged

jbikeler commented 4 months ago

I believe only Vulkan. To be honest, I didn't know we could switch to directx anymore since there wasn't an option when you first create the project. I assume it's this setting in Godot: image And the Nvidia Control Panel is this? : image Is this then a temporary fix? I guess I'm just confused on how these renderers effect players. If I fix jitter on my pc by changing a bunch of settings will players need to do the same to not experience jitter?

darksylinc commented 4 months ago

Can you try a newer NVIDIA driver? There's a chance they fixed it on their end.

jbikeler commented 4 months ago

Can you try a newer NVIDIA driver? There's a chance they fixed it on their end.

After updating my 3060 ti driver to 551.76, Godot 4.3.dev4 fixes most of the jitter issues even with Vulkan. Godot 4.2.1 still has a bit of jitter after updating, but it actually improved a bit with the update.

I'll continue to test, but it seems 4.3 will fix the issue.

DarioSamo commented 4 months ago

Is this then a temporary fix? I guess I'm just confused on how these renderers effect players. If I fix jitter on my pc by changing a bunch of settings will players need to do the same to not experience jitter?

The TL;DR so far from my understanding is that:

I'd not be surprised if this issue is consistent even on other Vulkan applications on NVIDIA/Windows, but I don't have enough evidence to support that yet. It's possible the issue has gone unnoticed because games are far more likely to use D3D on Windows than Vulkan, while on Godot it's the default option since it's the open standard.

EDIT: It seems your latest comment would also support the theory that these are indeed two separate bugs with a similar result.

bazsupport commented 4 months ago

To be honest, I didn't know we could switch to directx anymore since there wasn't an option when you first create the project.

How did you get that direct x option?? Godot_v4 2 1-stable_win64_Oy3G89C5lA

jbikeler commented 4 months ago

How did you get that direct x option??

The option appears in the Godot 4.3.dev build. I don't have it for 4.2.1 either.

mrjustaguy commented 3 months ago

One thing to ask, is GPU hardware scheduling enabled, and or windowed optimizations in windows?