Low FPS and high GPU load with bunch of discs

Avatar
  • updated
  • Fixed

Hi. I got an exreme fps drop on any android mobile device (even on high-end one), all I have on the scene is bunch of discs. Task Manager show GPU loading near to 100% on my PC. If I turn all the discs off, I got something like 40% GPU load and android device run app smoothly. What can I do to increase the FPS?
Here is a link to profiler data from the device

Image 282

Reporting a bug? please specify Unity version:
2020.2.1f1
Reporting a bug? please specify Shapes version:
2.3.2
Reporting a bug? please specify Render Pipeline:
URP
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Fixed

while it's still worth it to make sure GPU instancing is working on your device Denis, I implemented bounds cropping in the next update, the fill rate should be much better in this use case from 3.1.2 and onwards :)

Avatar
Johannes Deml

I think the GPU overhead comes from the disk segment's quad size. Since the Quad keeps the size for the full circle no matter how large the segment is, you end up with a lot of (from a screen perspecitve) large quads. Here is an example how the quad of one segment looks like:

Even though you're already using Opaque elements (at least I guess so from the looks of your edges), each unused pixel of each quad still needs to be discarded. Since mobile devices are very limited in their fillrate, this results in a high GPU demand.

I'm not sure, if you can tweak shapes to get a better performance for this use case, but if this is not possible you might want to look into creating parametric meshes for each segment (e.g. https://github.com/thisotherthing/ui-shapes-kit). This way, the meshes match the segments and there would be no need for discarding any pixels. Just a thought though, maybe Freya has a solution for it using Shapes :)

Avatar
Freya Holmér creator
  • Under Review

the above is likely the issue. I could make the vertex shader a little smarter and change the bounds of the mesh to help alleviate it to some extent

also, are you drawing this in immediate mode or are you using components?

Avatar
Quote from Freya Holmér

the above is likely the issue. I could make the vertex shader a little smarter and change the bounds of the mesh to help alleviate it to some extent

also, are you drawing this in immediate mode or are you using components?

Im using prefab with components. Is the immediate mode faster? Can I manipulate position of discs, which I drew with immediate mode?

Avatar
Freya Holmér creator
Quote from Денис Антипов

Im using prefab with components. Is the immediate mode faster? Can I manipulate position of discs, which I drew with immediate mode?

it depends really, immediate mode can be either faster or slower depending on what you're doing. But in general, components are faster in moderate amounts because they're more native to Unity's rendering pipeline. And yeah, you can change position of immediate mode objects! It's part of the parameters you supply

Avatar
Denis Antipov
Quote from Freya Holmér

it depends really, immediate mode can be either faster or slower depending on what you're doing. But in general, components are faster in moderate amounts because they're more native to Unity's rendering pipeline. And yeah, you can change position of immediate mode objects! It's part of the parameters you supply

I dive a bit into project and found out what my discs are not batching, they have different materials somehow. Even if I don't change color, I still have broken batching. Why is that so, I was sure it should be ok.
By the way, I switched to standart pipeline just to be sure it's not the URP fault,

Avatar
Freya Holmér creator
  • Not a bug

they should definitely batch together unless you have 
1. GPU instancing disabled in general, or it's not supported on the platforms
2. per-shape override settings at the top (there's a warning visible there if you're using a unique material on the shape), and it looks like you might have ZTest overridden to be off - if you reset them to their defaults they should instance together

Avatar
Denis Antipov
Quote from Freya Holmér

they should definitely batch together unless you have 
1. GPU instancing disabled in general, or it's not supported on the platforms
2. per-shape override settings at the top (there's a warning visible there if you're using a unique material on the shape), and it looks like you might have ZTest overridden to be off - if you reset them to their defaults they should instance together

Yea, that's right, I set Depth test to Less Equal and it starts batching, but CPU load still too big. Didn't try the immediate mode though

Avatar
Freya Holmér creator
  • Answer
  • Fixed

while it's still worth it to make sure GPU instancing is working on your device Denis, I implemented bounds cropping in the next update, the fill rate should be much better in this use case from 3.1.2 and onwards :)

Avatar
Johannes Deml

Holy bananas, this is awesome! Great work!

Avatar
Denis Antipov

 Is there ny other way to be sure what GPU instancing is on?

Thanks for bounds cropping, waiting for the update to try it out :)

Avatar
Freya Holmér creator
Quote from Denis Antipov

 Is there ny other way to be sure what GPU instancing is on?

Thanks for bounds cropping, waiting for the update to try it out :)

there's a warning at the top of the shape component that appears if your shape does *not* support GPU instancing due to custom settings