Is your game rendering more geometry than your GPU can handle? Here, let me show you a few steps to check if your geometry is causing a performance bottleneck on your players' GPU.
In this blog post, I'll share with you:
What geometry complexity is and how it affects your players.
How to check if geometry complexity is a bottleneck to your game performance.
Steps to simplify your geometry to boost your game performance.
Quick Navigation
Consequences of Geometry Complexity
Is Your Unity Game Performance Vertex-Bound?
How to Reduce Unity Vertex Count With Simplygon
Introductory Rambling
Remember last week?
Following our plan, today's topic is about a specific GPU Performance Pillar...
We are about to cover the famous performance area of Geometry Complexity.
The Game Guru's Performance Pillars - GPU Performance
Why is geometry complexity important for you?
Well, you know games...
And players.
Sometimes they're happy.
Sometimes they're screaming "this lame game doesn't run 144 fps, gimme my money back".
But those comments don't necessarily help you find your performance bottlenecks, do they?
Those you have to find yourself.
Performance bottlenecks come in different sizes and colors, depending on the current scene and on the hardware of your players.
It's your responsibility to find the exact origin of your performance bottlenecks.
And geometry complexity is one of these potential bottlenecks... one that severely affects your GPU 😉
Once you finish reading this post, you'll be able to answer these two questions:
Is geometry causing a bottleneck in my game?
Good. How do I fix it?
Let's start.
What is Geometry Complexity?
We all want astonishing visuals in our games.
And geometry is the basic foundation for all the visuals of your game, no matter your style.
It doesn't matter if you're developing a 3d game or a 2d game.
It's all vertices and triangles, i.e. geometry.
Wireframe Mode - Displaying Geometry
Each vertex is a point in (object) space.
And each vertex has often more data to it than just the position, such as UV0, UV1, colors and the such.
More vertex attributes means more you require more memory bandwidth. That, in turn, means less frame-rate and more power drain.
Warmer hands in winter, that's it.
Geometry complexity is basically the amount of vertices and triangles you're pushing to your GPU. That includes attributes.
So, what happens when we push too much geometry to the GPU?
Consequences of Geometry Complexity
If you're pushing too many vertices, then you're overwhelming your GPU's vertex shading units.
And your Render Thread.
And your memory.
And your battery.
And your wallet
Pushing too many vertices will slow down your game, as you're forcing your GPU to fetch shitloads of data (memory bandwidth) that you then have to process (arithmetic operations).
Overdo it and it'll require more time than 144 fps allows, resulting in wasted players' crocodile tears.
Now, if you keep your timings under control, you'll keep your players happy. And your boss.
This is why specializing on game performance is so important nowadays.
For your players... and for you.
So, how would you go about finding if your game is vertex-bound?
Is Your Unity Game Performance Vertex-Bound?
Let's say your game is running at 20 FPS and your boss is breathing down your neck.
You don't like that sensation, you're about to take action to fix this problem for good.
You have a hunch that your vertex count is causing this, but you want to confirm it.
What do you do?
→ Just drastically reduce the vertex count and see if that massively increases your framerate.
That sounds reasonable... But it's easier said than done.
Luckily, we have great tools to help out.
Before we get into the tools, let me say this...
The ideal approach involves doing one extra step before all of this.
Ideally, we'd want to simplify the rest of the game first to make sure our bottleneck is indeed coming from the vertex stage.
That means, temporarily getting rid of the cost of different stages:
CPU: disable AI, physics, networking, animations, audio; reduce draw calls.
GPU: reduce render resolution, reduce texture max sizes to 32, change materials' shaders to unlit color.
If you get rid of all other expensive parts and your game is still not performing, then you can be sure it's due to complexity.
Otherwise, you can't be 100% sure, because the bottleneck could come from another place.
Let's see an example.
Here's a profiler capture showing a geometry bottleneck (zoom if necessary):
Profiling Session Showing Vertex-Count Bottleneck
You see?
Almost no CPU overhead.
The main and render threads are just sitting idle, waiting for the GPU to finish.
So, ideally, here's what you have to do: