Hi All
http://www.youtube.com/watch?v=A2cQVFbsm14
I am having trouble with software generated by Unity 3D in that the software created does not use the full power of the GPU and yet still falls behind in frame rate. This relates to an earlier topic trying to solve same issue without luck. Any answers would be much appreciated. I have the fully registered PRO version of Unity3D 4.2.2. I will post any conclusions and responses in this video description and keep for future reference.
Many thanks for any help.
Steve Jones
iMica ltd
This is kind of a vague assessment without knowing exactly what you’re doing. Are you sure you’re not CPU Bound somewhere?
You have pro, so post valid profiler results.
CPU usage is very low with this application around 38%, I have an AMD 4/8 core so plenty of room.
I could make the app available for testing if it helps.
You can get the app here if interested to test run
http://www.vrexperience.net/AppDisplay.aspx?id=23time.
I’d like to see a graph of the profiler results. % is not indicative of framerate. Never has been. It is how much out of 100% of time per frame is spent on this task. It could be that your scripts in total are running under 16ms, which = 60fps. But what if your scripts were running at 24ms with 40% utilisation?
% isnt what you are looking for. You are looking for time ms.
This is what I need, I will have a look at how to create one, thanks.
Could not find a save profile so uploaded screen shot.
CPU show heavy usage and yet in the task manager, CPU usage is around 30%
I am new to Unity so I accept this is probably my fault but searching web brings no solution.
You may need to find something you can thread out. CPU usage as a percentage likely will be low but that’s usage across all cores. You likely are saturating one core where all of the work is being done.
Open Task Manager
Click on Resource Monitor
Click the CPU tab
Look at your individual CPUs. I be you’re flooring one. You may be doing too much. I saw on the link you provided a mention of doing some physics updates. Are you using a lot of or complex mesh colliders? If you’re using mesh colliders you may have to create a much simplified mesh to use for the collider. That would be one of my guesses. Physics calculations are probably chewing up too much CPU time.
Also looking at your screen-shot… I’m red/green colorblind so I can’t tell for sure… but look under CPU Usage… something going on there is eating up 33.2ms. The legend on the left should tell you what that is.
And… if I’m reading that correctly:
18.9 million vertices, 8.5 million tris and 7,100 draw calls!?
The mesh suggestion may well be it. I will test by removing all meshes. You have given me some great pointers to look for. I will update findings.
Many thanks
Dustin is right. 8 million? you won’t find that level of geometry on a next gen console let alone anything else. You need to look into culling and ensure materials are shared where possible. These are all normal game development techniques used by all the big boys. You’ll be surprised just how much is carefully optimized in AAA games.
Unity has occlusion culling, check it out in the docs. Not only this its likely rift is doubling everything (I don’t have a rift so I can’t verify).
If that 7100 draw calls figure is correct, that’ll be the source of your problem.
You can double-check this stuff by clicking on the body of the graph marked ‘Rendering’ and pasting the stats you see in the bottom half of the profiler window into this thread.
Firstly here is a picture for Hippocoder hopefully with more details and showing my cpu cores no more than about 50-60% active at any time.
I will upload a profile for superpig as well, thanks. Sorry about the two images, trying to remove one.
I have checked and I am averaging 7k + batched draw calls, I assume this is a lot. However, it does not explain why my CPU and GPU are coasting at around 50% or less load and yet the engine is dropping a lot of frames. Obviously I am missing something.
On the Physics, it does not seem to be taking much time, it is the rendering that is the issue that I can see.
Hopefully this frame shot will show all variables. It is pointing down the town with huge amount of detail to show and this environment is not designed for games on slow machines hence me buying a GTX780 for working on it. However, look at the cores, and read the GPU usage and basically the profiler shows it is hammering away but the OS and GPU tools show they are coasting. So there is still more processing available, unless I am missing something.
Hope this image helps.
As far as % CPU load goes, the reason you’re not seeing 100% usage is because that would imply that all your cores are doing work. Unity is partially multithreaded, but not fully; it can’t spread work like drawcall submission out over multiple cores, at least at the moment.
You’re right that this is a rendering issue, not a physics issue. It’s partly because you’re building a Rift app; this means that your rendering work is effectively doubled, as everything needs to be rendered twice, once for each eye. 7k draw calls in addition to batched draw calls is a pretty huge number - I would guess you need to get it down to half that, if not further.
Things I’d look at:
-
Occlusion culling - if you don’t have it turned on, try turning it on, and if you do have it turned on, review the settings and see if you can tweak them so that only things that are actually visible are being rendered.
-
Material combining / reuse - try and minimise the total number of materials in the scene, through re-use of materials and atlasing of textures.
-
Layer cull distances - if you have small objects that can’t really be made out at distance, put them on a separate layer and configure the cameras to cull that layer at a shorter distance than the far clip plane.
+1 for superpig’s answer. Also… there’s one thing I don’t think you’re quite understanding. It’s not the % of CPU usage that’s the issue. It’s the time it takes for each frame. In order to reach 60fps everything has to be done in 16ms. You are exceeding 33ms (which is 30fps) and this is why you’re seeing frame rate drops. Also keep in mind how the OS works in terms of CPU utilization and sharing. In addition to not using 100% of the CPU, affinity in the OS is also going to help determine which core you share and how much time you get. It may briefly “pause” requests from your application to provide a share of the processor time to a completely unrelated application. You have to wait your turn 
Ok, thanks for the help, seems a shame I cannot fully utilize the horsepower I have. Bit like having a big bucket but only fill it half way and then do a hundred trips with it instead of fifty. I will seriously look into culling and the other suggestions.
Many thanks
You probably are using a chunk of it… CPU usage for example is not exactly realtime. It’s calculated via sampling. So here’s what you have happening:
CPU is pegged, but for 35ms and GPU is idle.
GPU is pegged drawing for 35ms and CPU is idle
Now I just made those figures up but you should be able to get my drift. It’s cyclic. The CPU (or core) is only pegged every so briefly… and the GPU is only pegged ever so briefly (blink and you missed it)… but those time windows amount to more than you can spare to keep a decent framerate. Does that make sense?
Oh OK, so it is spiking the CPU or the GPU because of the draw rate, but the monitors are not quick enough to catch it. The spiking then causes the problem so I need to remove the spikes to get the frame rate up.
That makes more sense now.
I really appreciate the time you have both spent on this question as I move into using Unity more.
I will upload a couple of demos to my VR site later that you can have a look at, although you will need to have Oculus VR glasses to get the best out of the experience.
Many thanks.