0
\$\begingroup\$

I have been banging my head against the wall with this for few days now with no improvement..

The problem is that after build my project keeps using over 30% of the GPU. Even in the editor it takes 20%+ I ended up making a new empty scene with few cubes with rigidbodies, but the performance was still going over 30%. It starts with 3-5 % and within the next 5-10 seconds starts climbing up.

I am using Unity 2019.1.12f1, but the problem is still there even on the newest Unity 2020 version. The project is using LWRP.

I have played around with the quality settings but they seem to have absolutely no effect on the issue, besides turning the V-Sync on, which capped the framerate at acceptable levels.

I am using Windows 10 , my video card is Geforce GTX 1080 Ti.

Here are some screenshots + the project build

Project: https://easyupload.io/foqq5x

enter image description here enter image description here

\$\endgroup\$
12
  • \$\begingroup\$ Do you have vsync On? \$\endgroup\$
    – Vaillancourt
    Commented Sep 20, 2020 at 12:27
  • \$\begingroup\$ @Vaillancourt From what I understood the only way to turn on vsync in Unity is to set the VSync Count to some value. I have it on Every Vbank as it is shown on the screenshot. Before that the build was running on 1000 + FPS and the CPU and GPU were on 100% \$\endgroup\$ Commented Sep 20, 2020 at 12:31
  • \$\begingroup\$ Ah, right, looks like I read your question too fast. \$\endgroup\$
    – Vaillancourt
    Commented Sep 20, 2020 at 12:35
  • \$\begingroup\$ Have you checked if Unity is baking a lightmap in the background? \$\endgroup\$ Commented Sep 20, 2020 at 14:37
  • \$\begingroup\$ @user3797758 In the new scene that I created with the cubes that option was turned on. Still though that shouldnt affect the build version. I tested it now, by clearing all baked data, disabling the auto lightmap baking option and making a new build. It had no effect. Yesterday I even removed all lights from the scene and it still had no effect. \$\endgroup\$ Commented Sep 20, 2020 at 14:43

1 Answer 1

2
\$\begingroup\$

What you are experiencing are various bottlenecks when performance isn't purposely limited.

If you run a game (even a static none-moving cube) a typical game engine will tell the GPU to render and then go through the game loop and tell the GPU to render again. If there is nothing going on in the game this is very fast the GPU spends most of it's time doing a bit of rendering and then spends the rest of the time sending that data to the display and waiting. The cycle repeats and the game might run at a few thousand FPS and look static while using 100% of the resources of the computer, this is normal.

In that scenario you have told the game engine to go crazy and draw as many frames of the same cube as possible, it'll go and do that but certain parts of the rendering process take longer and cause the GPU to wait, like when it has finished and needs new work (but the CPU is busy doing other stuff) so it'll sit there idle waiting for the next draw calls to be sent. You can change the balance a little if you change render resolution which will mean the GPU has to spend more/less time calculating pixel values, accordingly the perceived GPU utilisation will change.

All of this happens when you tell the game to go as fast as possible! If you instead know "I want 60 FPS" you can tell the game to try it's best to make every frame take 16ms and that means that the GPU/CPU will sit idle more (assuming that you where managing more than 60 FPS before) and task manager will tell you it's being used less.

performance sample

So in this picture you can see that it takes roughly the same amount of time to render either way if you have v-sync on or off but the CPU will wait on purpose until the current frame has taken enough time in order to hit a performance target which forces the PC to be idle lowering the resources used.

Things to note

The problem with empty games or static scenes are that if nothing has moved technically nothing needs to be re-rendered but working this out is too slow for modern games where 99% of the time something is happening. If you know that nothing is going to happen (like when you are in a menu or something like that) you can build ways of caching the previous frame and re-render it but that's out of scope for this question. So if you know nothing has changed and you see the GPU doing stuff you might get the impression that the game engine is wasting resources and depending on your point of view it might be but if you where to 'optimise' a standard game engine for that use case it will cost you more performance when you need it once you actually start making stuff move on screen and the calculation tells you not to cache the frame most of the time.

Some game engines will look at the last few frames and notice trends and optimise the game on the fly to get more performance which can change the CPU to GPU load ratio. Unity's Entity system is one case where it takes a few frames to "Warn up" until it knows what requests the game will make and how it needs to structure the data in memory in order minimise overhead (though Unity being Unity this will probably be different in a few years when they inevitably change the system).

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for the reply. Basically you mean those resources aren't actually used, the GPU is just waiting for something to happen. As for my original project it used around 10% more GPU than the empty scene. Does that mean those resources are still not used or I have to optimize my game graphics to take less resources? For example I ran Subnautica which is also done with Unity and the GPU load was the same as for my empty scene. Does that mean their game is optimized really well? Also do you know how can I track the performance load besides the task manager, just the Unity Profiler ? \$\endgroup\$ Commented Sep 22, 2020 at 7:20
  • \$\begingroup\$ Without looking at your project in depth I don't know what your doing that uses resources. There are millions of variables that you could track in one game vs another, I'd look around at what over people have done to increase performance. As for tracking it long term, make performance benchmarks and setup an automated environment to run it every time you add to source control, then you can look at graphs and see the difference over time blogs.unity3d.com/2018/09/25/… \$\endgroup\$ Commented Sep 22, 2020 at 11:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .