What is this and why have I never seen this until recently? And most importantly why is it killing performance when it didn’t do it before in older versions? It seems like the more things they expose into the profiler the slower things get.
Heck I even went out and bought GPU Instancer - and things got multitudes of times slower because of whatever this is when GPU Instancer should make things considerably faster.
In fact GPU Instancer makes it take 250+ MS per frame at times, but averages 50-60 MS per frame.
Turn off GPU Instancer - with 50,000 trees on a terrain I get roughly 23ish FPS, with GPU Instancer - 1.5-10FPS…
I’m emphasizing GPU Instancer in this case because it’s supposed to optimize things. But it’s not only GPU Instancer, even Voxeland bring up this dirty problem.
So how can I get rid of this, if it’s even possible. I’ve tried the last 3 versions of Unity and this problem is persistent and it’s breaking performance to the point it’s impossible to make my game.
[Edit]
I feel I should mention: I just turned off GPU Instancer and left the scene like a regular scene and this problem goes away… So yeah, Voxeland and GPU Instancer both have this problem.
But the problem is - it’s coming from tried and true assets on the asset store that seems to be nobody else is complaining about this problem but me. But it only happens when I use said assets.
Scene without GPU Instancer - thousands of draw calls is better than a scene with 80 draw calls with GPU Instancer.
I can’t do GPU profiler, apparently isn’t supported for AMD Rx 480.
Don’t don’t confuse this with Gfx.WaitForPresent, (Unless this is that renamed to : WaitForPresentGfxThread.)
Another example would be Voxeland. I’m not sure if You’ve used this or not, but I tested this theory out. I started a fresh new project and imported only Voxeland, changed nothing but to Linear color space (like I always do). And bam the moment the player gets near the grass meshes that come in the demo scene - instantly 15 FPS. The main culprit? Gfx.WaitForPresentGfxThread… Didn’t change anything, didn’t do anything but change to linear color space, gamma didn’t make a difference either.
If I remove GPU Instancer: the whole Gfx.WaitForPresentGfxThread disappears. And same with Voxeland.
Map Magic on the other hand - it doesn’t exist on, so that works fine.
But this still doesn’t make sense to me because you’d figure GPU Instancing, and even a basic baren Voxeland demo scene would be far superior than rendering everything outright without any form of Instancing and culling.
Like literally - Remove GPU Instancer and put a lot more work on the GPU = better performance. Like that makes any sense. It doesn’t.
I mean if someone can explain to me how 10 million polygons, 1000+ batches, 800+ shadows is better than 119.4K Tris, 60 shadows and 154 batches I’m all ears. (because this is what GPU instancer is giving me).
Also again - on Voxeland the same exact problem - I could literally have 1 single piece of grass and the moment the player gets within a couple meters - this Gfx.WaitForPresentGfxThread appears and kills all performance. Literally a single piece of grass.
[Edit]
Yes I’ve tried starting a new scene with only a regular terrain and one thing of trees, same issue - Gfx.WaitForPresentGfxThread kills all performance ONLY if GPU Instancer is in the scene, otherwise I get better performance just handling all the data at once.
Putting more stuff onto GPU doesn’t necessarily mean better performance. Remember that if the GPU is getting 30 fps, then so will the CPU, since it has to wait. The more stuff you make the GPU do, the slower it is. This is called being GPU-Bound. And, as you can see by the profiling, the GPU is having a very hard time for some reason, with a very low fps. So this is the reason why WaitForPresentGfxThread is happening.
So now lets see why the GPU is having such a bad time! First off, what graphics card are you using? Also, could you show what the profiling looks like with GPU Instancer turned off vs on?
And this is for Voxeland. Keep notice of how the GPU skyrockets after a period of time.
The issue with this is - the grass can be visible from a distance and stay fine. But the moment a player gets meer meters from it - the chaos instills with this same problem. But yet - nobody on this green earth experiences none of this but me. Literally straight off the demo scene, not a single thing changed. But yet - none of the other countless hundreds or even thousands of people have complained about this. (The Spikes in the CPU) are from the Gfx.WaitForPresentGfxThread.
[edit] I think I should mention that I have used Voxeland in the past - with no issue. So I’m really starting to think Unity has a bug somewhere that simply don’t like my current graphics card. I’ve never downgraded a card, so if anything my current card is better than my last if I tried it last time on my old card (it’s been awhile, so I can’t say) if it was this or the last card. My last card was an R9 290. (not 290x)
Once again, this is clearly something on the GPU side, not by WaitForPresentGfxThread directly. WaitForPresentGfxThread is caused by having a lot of computations on the GPU, and as you can see, this is clearly happening. But yeah, I have no clue what is causing this massive explosion of GPU calculations. Looks like BatchRenderer is a lot of the time, specifically the BatchRenderer.RenderSingle / BatchRenderer.Flush calls.
Lets look deeper. If you extend the BatchRenderer.RenderSingle, we’ll see what sub functions are taking most of the time. : )
EDIT: I’m talking about the voxelland one, by the way. Looks like Voxelland and GPU Instancer are causing entirely different issues, from the look of it. For now, the Voxelland one looks the most interesting, so lets focus on that one for now.
Very interesting, looks like batching a single mesh is taking 103 ms to render. Wowee.
Now figuring out why this is will be interesting. If you click the details button on the right of the hierarchy window, it should have some info related to the name of the mesh and such. You could also try looking at the frame debugger to try to find which step is that rendering step, which should have some more info
Well I just had a buddy with a GTX 1070 try it and he said it was butter smooth. I mean sure it’s faster, but mobile phones can play games made with Voxeland…
So it’s making me think that this is an AMD related issue.
Well Details window it shows
And this is the frame debugger.
But I feel I should emphasize - this only happens when the player gets close to a grass piece. You could be 100 meters away and look at all the grass and keep perfect FPS, but the moment you get close, that’s when the issues happen.
Hence why I’m thinking there’s a bug in Unity and AMD cards. Because Voxeland has been used in mobile android projects in the past and simply worked. Not saying without any overhead, but if a phone can have grass, certainly my card can have grass lol.
[Edit]
The literal only thing I can think of aside from the above is if something has changed in Unity API that is causing so many issues with both GPU Instancer and Voxeland to where it isn’t updated for current Unity versions. But still, GTX 1070 ran it butter smooth. Mobile phones have ran Voxeland in the past as well. So i’m not entirely sure, I just know I’m getting so exhausted trying to figure this out.
Is the frame you’re showing the one that is causing the issue? If so, maybe that would explain why distance is a factor - shadows are only rendered for nearby stuff. If you disable shadows does this lag spike still happen?
It’s not a spike by the way, it’s constant bogging. The best way to describe it would be to run 10 debug logs in update at one time in 10 different scripts… That constantly - lag the frames never giving them a chance to reach higher counts.
Well I’m going to head to sleep now, I appreciate the help. I’ll probably contact Unity support tomorrow when I wake up, or file a bug report, or both. Because something simply ain’t right with all this going on.
I might simply reformat my computer, perhaps I got old conflicting drivers fighting eachother or something, considering the built in Video recorder for my graphics card can’t even pick up my microphone input, makes me wonder what else may be going on with my computer.
But before anything I’ll probably stick my brothers 1060 in my PC, which is pretty much equivalent to my RX480, just a slight bit better, so should be more on par with what I have vs a 1070. Even though, like I’ve said - mobile phones from 3 years ago have had Voxeland stuff on their games before, so something is a big culprit here and something tells me it’s simply something wrong on Unity’s end, or AMD’s end.