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

Move Depsgraph to Separate Thread #1877

Open
JYamihud opened this issue Feb 22, 2024 · 0 comments
Open

Move Depsgraph to Separate Thread #1877

JYamihud opened this issue Feb 22, 2024 · 0 comments

Comments

@JYamihud
Copy link

Problem

Depsgraph is being waited for before rendering starts.

Computers have two separate devices: CPU and GPU that could run simultaneously, but UPBGE apparently doesn't take advantage of this. I read through the KX_Scene.cpp file to confirm my fears. And as I far as I understand the depsgraph is being waited for before calling the rendering. Which is a problem.

I have a game scene where depsgraph is taking between 10 to 20 ms to run. Which could result in a descent FPS on its own. But rendering also takes addition 10 to 20 ms. In which case, with a computer that is capable of giving me about 60 fps I get only 25 to 30.

I did everything I could to optimize the scene. To use as little depsgraph updates as possible. But I have been met with a wall, crossing which makes the game unplayable. It is either I get 25 FPS ( or lower ) or I should not have any objects in the scene at all.

Other people were met with similar issues online. Like in these posts:

https://blenderartists.org/t/depsgraph-what-exactly-is-it-upbge-0-3/1396267
https://blenderartists.org/t/how-to-optimize-for-the-depsgraph-or-disable-it-in-upbge-0-3/1397793

Solution

Move Depsgraph to separate thread so it would calculate in the same time as rendering.

Obviously the main issue with that is that render has to have the updated scene to render it. But having a delay of one or two frames will not be a significant problem, if instead we double the overall FPS of the game. Basically we can let the renderer render the latest available frame, while the depsgraph will update for the next frame. If both depsgraph and render each take 15 ms to finish, we will still need only 15 ms. Not 30 ms as in the current configuration.

At the very least this could be introduced as an option, so people with heavy scenes like mine could sacrifice some accuracy for performance.

@JYamihud JYamihud mentioned this issue Feb 27, 2024
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant