Skip to content
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

Godot4 using > 80% of the CPU when moving a directional light #65894

Closed
tavurth opened this issue Sep 16, 2022 · 11 comments
Closed

Godot4 using > 80% of the CPU when moving a directional light #65894

tavurth opened this issue Sep 16, 2022 · 11 comments

Comments

@tavurth
Copy link
Contributor

tavurth commented Sep 16, 2022

Godot version

Beta 1

System information

MacBook Pro (13-inch, 2019) 2.4 GHz Quad-Core Intel Core i5

Issue description

When starting a blank project in the new Godot4 beta I see >80% of the CPU being used at all times.

The godot editor also frequently becomes unresponsive, showing as Not responding in the task manager.

Steps to reproduce

  1. Open a blank project in Godot beta 4 (1st beta)
  2. Add a directional light
  3. Move the directional light every frame

Minimal reproduction project

godot_directional_light.zip

extends DirectionalLight3D

func _process(delta):
	var amount = delta / 4
	self.rotation.y += amount
@tavurth
Copy link
Contributor Author

tavurth commented Sep 16, 2022

Screenshot 2022-09-16 at 13 19 09

Screenshot 2022-09-16 at 15 34 14

@bruvzg
Copy link
Member

bruvzg commented Sep 16, 2022

Can't reproduce on M1 mac, It's about 1% on background and 6% idle on foreground.

@Calinou
Copy link
Member

Calinou commented Sep 16, 2022

Related to #64708.

@tavurth
Copy link
Contributor Author

tavurth commented Sep 16, 2022

Related to #64708.

Could be but in the above comment I have a screenshot showing the godot window unobstructed in the foreground 🤔

@tavurth
Copy link
Contributor Author

tavurth commented Sep 17, 2022

Hmm I tried to build godot 4 to check this in a profiler but then I created a new project and the issue disappeared.

The original project I opened was actually the one referenced in this issue: #53969

So this issue still persists, but it seems now it has become a CPU bound operation.

@tavurth tavurth changed the title Godot4 using > 80% of the CPU on MacOS Monterey Godot4 using > 80% of the CPU when moving a directional light Sep 17, 2022
@tavurth
Copy link
Contributor Author

tavurth commented Sep 17, 2022

godot_directional_light.zip

This is the project which causes the CPU drop @bruvzg

@tavurth
Copy link
Contributor Author

tavurth commented Sep 17, 2022

@Calinou is this expecting too much from the renderer?

We are moving the directional light every frame after all 🤔

@Calinou
Copy link
Member

Calinou commented Sep 17, 2022

We are moving the directional light every frame after all thinking

Yes, this should be avoided when possible. AAA games that feature day/night cycles will generally move the light only 20 times per cycle or so, snapping between increments every so often (with a small period of continuous transition that only lasts a few seconds).

Changing the sky update mode to Real-Time in the Environment resource should help decrease CPU/GPU usage a bit when updating the sky, but moving the light continuously all the time should still be avoided.

@bruvzg
Copy link
Member

bruvzg commented Sep 17, 2022

godot_directional_light.zip

This is the project which causes the CPU drop

It's the same, 7-8% on M1 mac, probably it's an issue with a older Intel GPUs.

@clayjohn
Copy link
Member

@tavurth How is your performance when using the realtime update mode? When updating every single frame the realtime update mode is likely a better option than then automatic mode. In either case though, updating the sky every frame on a low powered integrated GPU is probably going to consume a large portion of your frame budget. I recommend setting the DirectionaLight3D's sky_mode to LIGHT_ONLY so that the sky is not updated every frame along with the sun.

@tavurth
Copy link
Contributor Author

tavurth commented Sep 19, 2022

Ok this is weird but I now have around 18% CPU usage in the same scene.

The only thing I've changed is renaming the folder.

Could it be that Godot4 is somehow re-using the cached shaders from the previous Godot3 version?

Renaming the folder back does not bring back the CPU usage however.

I will close this for now as sadly non-reproducible 🤷

@tavurth tavurth closed this as completed Sep 19, 2022
@Calinou Calinou removed this from the 4.0 milestone Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants