Jittering Solutions
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Jittering Solutions
Well my project uses 10-15 high poly models and I am only half way through.
The thing that I have noticed is that as the poly count keeps increasing, I get a jitter on movement of my vehicles, the jitter exists when my camera is static and moving too.
I am puzzled as to where the issue is, I understand the batch count gets high with every high poly model I add, but my game requires it and I am not using low poly game ready models.
The target computer is a high end rig not any mobile platforms.
I originally thought the problem was with Ogre and gave Unity a run, I imported a 200K poly model and gave it life and well jitter again in Unity.
So it's not Ogre specific, is it hardware specific, I am running an i7 @ 3.5Ghz and a GTX760 is my main dev GPU.
In Ogre my game takes 89% CPU usage of a single core, well that explains it my CPU is choked so I thought I ll multithread my game, but on Unity I have only 13% CPU Usage and around 65% GPU Usage but still it jitters too.
So is upgrading my CPU and/or GPU the solution ?
Or is it that today's cards can't handle super high poly models, well if so that's understandable, I ll just have to delay my projects by a decade
The thing that I have noticed is that as the poly count keeps increasing, I get a jitter on movement of my vehicles, the jitter exists when my camera is static and moving too.
I am puzzled as to where the issue is, I understand the batch count gets high with every high poly model I add, but my game requires it and I am not using low poly game ready models.
The target computer is a high end rig not any mobile platforms.
I originally thought the problem was with Ogre and gave Unity a run, I imported a 200K poly model and gave it life and well jitter again in Unity.
So it's not Ogre specific, is it hardware specific, I am running an i7 @ 3.5Ghz and a GTX760 is my main dev GPU.
In Ogre my game takes 89% CPU usage of a single core, well that explains it my CPU is choked so I thought I ll multithread my game, but on Unity I have only 13% CPU Usage and around 65% GPU Usage but still it jitters too.
So is upgrading my CPU and/or GPU the solution ?
Or is it that today's cards can't handle super high poly models, well if so that's understandable, I ll just have to delay my projects by a decade
- Zonder
- Ogre Magi
- Posts: 1168
- Joined: Mon Aug 04, 2008 7:51 pm
- Location: Manchester - England
- x 73
Re: Jittering Solutions
You sure it's not just floating point errors? try using double if you are using single precision.
But I guess it depends what you mean by jitter!
But I guess it depends what you mean by jitter!
There are 10 types of people in the world: Those who understand binary, and those who don't...
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
A slight frame lag every few seconds I supposeZonder wrote: But I guess it depends what you mean by jitter!
-
- Gremlin
- Posts: 196
- Joined: Tue Jan 27, 2009 12:27 am
- x 24
Re: Jittering Solutions
Oh then that's not really jitter (which would be a visual "instability").
More like a stall. If you encounter the same in Unity and Ogre then it's probably hardware yeah.
More like a stall. If you encounter the same in Unity and Ogre then it's probably hardware yeah.
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
Could you confirm it's a hardware issue.N0vember wrote:Oh then that's not really jitter (which would be a visual "instability").
More like a stall. If you encounter the same in Unity and Ogre then it's probably hardware yeah.
It happens when my vehicle is moving irrespective of whether my camera is attached to the vehicle or not.
There is no "jitter/stall " when nothing moves.
So is it because my GTX760 can't take it or is it faulty?
- Kojack
- OGRE Moderator
- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 534
Re: Jittering Solutions
It could potentially be a software issue too, maybe something else on your pc is using a lot of cpu. Maybe a virus checker / firewall / etc.
Unreliable frame timing can also be caused by multi-core cpu timing issues, jumping from one core to another (happens even if you aren't doing multithreaded) can mess up the timer because each cpu has it's own clock and they might not be in sync. Ogre has code to fix that (it's clock only ever runs on the first cpu core, it uses thread affinity), I'd assume unity does too.
If the models themselves were jittering (in position), that can be floating point precision, mainly when they are placed far from the origin. A mesh that animates fine at 0,0,0 may look like crap when placed at 20000000,0,0. Double precision doesn't really help much in that situation, because directx and opengl are still single precision, the gpu will still cause the problems.
If the meshes were too high poly, it would be constant lag, not every few seconds.
Unreliable frame timing can also be caused by multi-core cpu timing issues, jumping from one core to another (happens even if you aren't doing multithreaded) can mess up the timer because each cpu has it's own clock and they might not be in sync. Ogre has code to fix that (it's clock only ever runs on the first cpu core, it uses thread affinity), I'd assume unity does too.
If the models themselves were jittering (in position), that can be floating point precision, mainly when they are placed far from the origin. A mesh that animates fine at 0,0,0 may look like crap when placed at 20000000,0,0. Double precision doesn't really help much in that situation, because directx and opengl are still single precision, the gpu will still cause the problems.
If the meshes were too high poly, it would be constant lag, not every few seconds.
- areay
- Bugbear
- Posts: 819
- Joined: Wed May 05, 2010 4:59 am
- Location: Auckland, NZ
- x 69
Re: Jittering Solutions
That's not how I understand it. A single Ogre::SubEntity is a single batch (per material pass) no matter how many triangles you have. I mean that if you *only* have 15 Ogre::Entity's using this model then you should only have ~15 batches. What is your batchcount?insider wrote:I understand the batch count gets high with every high poly model I add, but my game requires it and I am not using low poly game ready models.
Also, are you using skeletal animation for these? If so, are you doing it in software or hardware and how many blendweights per vertex? And double that expense if you're using shadowmapping also without hardware acceleration.
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
Well I don't have access to my computer right now, but last time I checked the triangle count was 2,660,000 and batch count was around 300 I guess, there are 12+10 entities and there is no skeletal or any animation of any sort.areay wrote:That's not how I understand it. A single Ogre::SubEntity is a single batch (per material pass) no matter how many triangles you have. I mean that if you *only* have 15 Ogre::Entity's using this model then you should only have ~15 batches. What is your batchcount?insider wrote:I understand the batch count gets high with every high poly model I add, but my game requires it and I am not using low poly game ready models.
Also, are you using skeletal animation for these? If so, are you doing it in software or hardware and how many blendweights per vertex? And double that expense if you're using shadowmapping also without hardware acceleration.
I haven't optimized my game yet the so called "jitter" turns me off, but surprisingly I have also tested the above scenario in a fresh new project with a single model ( a high poly truck) on a NxOgre plane, the truck was around 200K poly and no other entities, I can't exactly remember what the batch count for that was but it also caused a "jitter/stall" on movement, now I am not sure where to look if the test case scenario which I tried itself failed, looking for ways to optimize my 2 million poly game would be pointless.
Last edited by insider on Fri May 01, 2015 12:54 pm, edited 1 time in total.
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
And ofcourse if it's a hardware/software issue then hunting for solutions in Ogre would be in vain
@Kojack It's quite possible for it to be software issues too, few years back I had posted the same issue and the problem was with a software called f.lux (I posted the problem and the solution )
I run my computer like a fortress, I am runnning ESET Smart Security (with Firewall disabled), Comodo Firewall, Malwarebytes Anti-Malware( Manual Scan only doesn't startup with my computer).
So yes guess I ll have to check the issues by disabling / uninstalling them and see if the issue arises.
@Kojack It's quite possible for it to be software issues too, few years back I had posted the same issue and the problem was with a software called f.lux (I posted the problem and the solution )
I run my computer like a fortress, I am runnning ESET Smart Security (with Firewall disabled), Comodo Firewall, Malwarebytes Anti-Malware( Manual Scan only doesn't startup with my computer).
So yes guess I ll have to check the issues by disabling / uninstalling them and see if the issue arises.
- Zonder
- Ogre Magi
- Posts: 1168
- Joined: Mon Aug 04, 2008 7:51 pm
- Location: Manchester - England
- x 73
Re: Jittering Solutions
If it won't compromise your project maybe post a compiled example, then you at least know if it's your setup or not.
My machine is similar to yours AMD FX8350 16GB Ram and GTX 770 4GB. I am sure others would give it a try as well.
My machine is similar to yours AMD FX8350 16GB Ram and GTX 770 4GB. I am sure others would give it a try as well.
There are 10 types of people in the world: Those who understand binary, and those who don't...
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
Thanks Zonder I had made a barebones project for testing this problem on a different system 4 months back let me see if I can find that.Zonder wrote:If it won't compromise your project maybe post a compiled example, then you at least know if it's your setup or not.
My machine is similar to yours AMD FX8350 16GB Ram and GTX 770 4GB. I am sure others would give it a try as well.
I just reinstalled Windows 7 on my backup PC last week it runs an i5 @ 3.1Ghz and has GTX560Ti let me see if I can reproduce this issue there, it has no software installed on it except Microsoft Word, so hopefully this problem shouldn't arise there, will keep you guys posted.
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
I think I may have found something, DllHost.exe starts up every 10-15 seconds and quits and my task manager shows 1% CPU Usage when it starts and my mouse cursor also shows a busy icon for half a second.
What does DllHost.exe seek every 10 seconds, it's a legit DllHost.exe, I have scanned it with VirusTotal and its clean, I have also scanned with my Antivirus and AntiMalware no signs of infection either, any ideas what's DllHost.exe upto.
It's quite possible it was causing the "hiccup/jitter/stall" , whatever
What does DllHost.exe seek every 10 seconds, it's a legit DllHost.exe, I have scanned it with VirusTotal and its clean, I have also scanned with my Antivirus and AntiMalware no signs of infection either, any ideas what's DllHost.exe upto.
It's quite possible it was causing the "hiccup/jitter/stall" , whatever
- Zonder
- Ogre Magi
- Posts: 1168
- Joined: Mon Aug 04, 2008 7:51 pm
- Location: Manchester - England
- x 73
Re: Jittering Solutions
dllhost.exe is safe (it it's the real windows one!) but what it is doing may not be.
Have a look at this superuser post http://superuser.com/questions/833914/h ... sid-switch and the original authors answer http://superuser.com/a/838842/181389
Have a look at this superuser post http://superuser.com/questions/833914/h ... sid-switch and the original authors answer http://superuser.com/a/838842/181389
There are 10 types of people in the world: Those who understand binary, and those who don't...
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
Well I reinstalled my OS and the DLLHost is no longer a issue, the problem arised from when I was browsing in google news, that's my cue to stay away from google news, this is the second time this has happened it seems google doesn't check which news site it links, Grr!
Now a new issue I draw to LCD gamepanel of my Logitech G510s using GDIPlus and suddenly after reinstalling Windows 7 none of my games supporting the gamepanel work, I thought GDIPlus resides in System32 but it's missing after reinstallation, is there any reliable source to download the GDIPlus dll.
Now a new issue I draw to LCD gamepanel of my Logitech G510s using GDIPlus and suddenly after reinstalling Windows 7 none of my games supporting the gamepanel work, I thought GDIPlus resides in System32 but it's missing after reinstallation, is there any reliable source to download the GDIPlus dll.
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
Did a little digging and my problem of dlls is as below.
Seems like it is a known issue, all I did was reinstall Windows 7 Pro, Install MS Visual Studio 2010 and 2010 SP1 and then run Windows Update and my Windows is fully updated until May 2015. The last time I ran Windows Update was a year ago so I guess MS messed up something as always in the meantime, has anyone run into a similar issue and any solid solutions would be great.
Issue was brought up here http://stackoverflow.com/questions/1702 ... l-problems and is exactly what I am facing.
I have tried Uninstalling VS 2010 SP1 installed Microsoft Windows 7 SDK and then reinstalled VS 2010 SP1 to no avail.
Any ideas would be great it's 5am here and I am truly exhausted.
Thanks guys
Seems like it is a known issue, all I did was reinstall Windows 7 Pro, Install MS Visual Studio 2010 and 2010 SP1 and then run Windows Update and my Windows is fully updated until May 2015. The last time I ran Windows Update was a year ago so I guess MS messed up something as always in the meantime, has anyone run into a similar issue and any solid solutions would be great.
Issue was brought up here http://stackoverflow.com/questions/1702 ... l-problems and is exactly what I am facing.
I have tried Uninstalling VS 2010 SP1 installed Microsoft Windows 7 SDK and then reinstalled VS 2010 SP1 to no avail.
Any ideas would be great it's 5am here and I am truly exhausted.
Thanks guys
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
Just a quick update, installing Visual Studio 2012 redistributables seems to cause the game not to crash, but my gamepanel is frozen, so it has nothing to do with my game, guess there are few conflicts between the Logitech Gaming Software and redistributable versions, anyway hopefully I can resolve it soon, any advice would be great though, I had made a backup list of the entire software installed on my computer prior to Windows reinstallation, I can post that if anything looks obvious, it's rather long so I can PM you if you want.
Anyway thanks guys as far as the jitter is concerned it is present but reduced remarkably and of course a 2 million poly game can make any moderate card cry out and that's is what's happening I suppose.
Anyway thanks guys as far as the jitter is concerned it is present but reduced remarkably and of course a 2 million poly game can make any moderate card cry out and that's is what's happening I suppose.
- Zonder
- Ogre Magi
- Posts: 1168
- Joined: Mon Aug 04, 2008 7:51 pm
- Location: Manchester - England
- x 73
Re: Jittering Solutions
I suggest you reapply the latest service pack then latest updates. You might have some mismatched versions lurking.
There are 10 types of people in the world: Those who understand binary, and those who don't...
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
Well I just started up Windows with the advanced startup option "Disable Driver Signature Enforcement" for installing a different software and suddenly after that the gamepanel works fine, not sure how that fixed it but it didZonder wrote:I suggest you reapply the latest service pack then latest updates. You might have some mismatched versions lurking.
I had spent long weekends to get information displayed on the gamepanel and would have been rather pissed if a simple Windows reinstallation would ruin my work.
Their SDK's are also very limited, they have no direct support for drawing to the panel, the way I got things to work the way they should almost looks like a hack.
Logitech needs to understand that not just users but programmers too use their keyboards
- insider
- Orc
- Posts: 462
- Joined: Thu Sep 15, 2011 12:50 pm
- x 31
Re: Jittering Solutions
Zonder wrote:..
areay wrote:..
Kojack wrote:..
Back to topic and aha finally a jitter example.N0vember wrote:..
Was just browsing and came across a perfect example of the issue I am going through.
[youtube]dGK41ly5UOk[/youtube]
You can see the so called "stall/jitter" in the vegetation scenes, now it has nothing to do with the recording software, I can assure you that much.
So what causes it, high poly count and slow video cards ?
- 0xC0DEFACE
- OGRE Expert User
- Posts: 84
- Joined: Thu May 21, 2009 4:55 am
- x 7
Re: Jittering Solutions
This is an oldish thread, but I'm not as regular here as I used to be so forgive me!
See this MS article: Acquiring high-resolution time stamps
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Onto the jittering
There are four main reasons people get jittering that you should be looking for:
Loading things in the main thread
This one is pretty straight forward. If you are streaming in assets in the main thread while you navigate the scene, you are at the mercy of the size of said assets. Large assets will cause large stalls. You may also be at the mercy of your hardware, that may exacerbate stalls *cough* HDD *cough*. Move as much loading as possible to background threads and leave the main thread free as much as possible. The size of your assets can also be a source of stalls, but ill cover that next.
Asset transfer stalls
Your graphics drivers will only send Assets to the graphics card the first time they are needed for a frame. So for example, if you load your entire scene and are looking in the other direction, then quickly turn around, you will likely get jitters as all the needed data is sent to the graphics card. There are two main things you can do to help with this. The first is have smaller assets. Simple I know, but using DDS files that remain compressed on the graphics card, rather than other formats will save your band width. Also try reducing the resolution of your textures. And also get your artists to follow their size budgets for their meshes. You can also try using triangle strips and such, but I have never actually seen them used in practice. They are too much hassle and likely less effective than using smaller textures.
The second thing you can do it called Texture/mesh warming. Once you load all your resources invisibly render them to the screen one per frame (or more if they are small, use size as heuristic). Then after they are all warmed up, create the objects that use them. This will spread the transfer over multiple frames and reduce stutter.
Use GPUView (free windows tool). Direct X emits events into the windows log stream when a resource transfer begins and ends. GPU View will show you graphically where they are, and you can see if there is a correlation between long frames and resource transfers.
http://graphics.stanford.edu/~mdfisher/GPUView.html
Dual monitor setups
I once spent two weeks profiling and tweaking and measuring and debugging to try to find a jitter I was getting to no avail. Then, on some obscure forum post I found someone who said that graphics cards are only optimised to deliver the best performance possible to one monitor, the other will always have poorer performance. After reading that I booted my software on another monitor and boom, the issue was gone, or at least significantly reduced. So be wary of Dual monitor setups.
Resource contention
This is when you have a mutex that two threads are trying to get access to the second thread will simply have to wait until the mutex is released before it can continue processing. When that is the main thread you will get a stall. To get around this make sure anywhere you have mutex protected sections are as brief as possible. Also try boosting the priority of your main thread over the others. This will make it more likely that it will get the mutex first, and when it doesn't the process with the lock will get a priority boost until it releases the resource due to windows thread priority inversion.
Add this code to the start of your application:
To see if there is resource contention you will need to do what is called wait analysis. You should be able to do this with your profiling tools. I use Windows Performance Analyser (another free windows tool).
Hope that helps.
We probably shouldn't be doing this any more. CPU's all have their own tick count, but they will all always have the same tick frequency, which means if you query from different threads you will be out by MAX +/-1 tick. Switching threads and setting affinity will likely take longer than one tick, which mean you will be getting less accurate timings if you try to context swap. Maybe the issue used to be on XP, but not even MS supports that anymore. We shouldn't either.Kojack wrote:Unreliable frame timing can also be caused by multi-core cpu timing issues, jumping from one core to another (happens even if you aren't doing multithreaded) can mess up the timer because each cpu has it's own clock and they might not be in sync. Ogre has code to fix that (it's clock only ever runs on the first cpu core, it uses thread affinity), I'd assume unity does too.
See this MS article: Acquiring high-resolution time stamps
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Onto the jittering
There are four main reasons people get jittering that you should be looking for:
Loading things in the main thread
This one is pretty straight forward. If you are streaming in assets in the main thread while you navigate the scene, you are at the mercy of the size of said assets. Large assets will cause large stalls. You may also be at the mercy of your hardware, that may exacerbate stalls *cough* HDD *cough*. Move as much loading as possible to background threads and leave the main thread free as much as possible. The size of your assets can also be a source of stalls, but ill cover that next.
Asset transfer stalls
Your graphics drivers will only send Assets to the graphics card the first time they are needed for a frame. So for example, if you load your entire scene and are looking in the other direction, then quickly turn around, you will likely get jitters as all the needed data is sent to the graphics card. There are two main things you can do to help with this. The first is have smaller assets. Simple I know, but using DDS files that remain compressed on the graphics card, rather than other formats will save your band width. Also try reducing the resolution of your textures. And also get your artists to follow their size budgets for their meshes. You can also try using triangle strips and such, but I have never actually seen them used in practice. They are too much hassle and likely less effective than using smaller textures.
The second thing you can do it called Texture/mesh warming. Once you load all your resources invisibly render them to the screen one per frame (or more if they are small, use size as heuristic). Then after they are all warmed up, create the objects that use them. This will spread the transfer over multiple frames and reduce stutter.
Use GPUView (free windows tool). Direct X emits events into the windows log stream when a resource transfer begins and ends. GPU View will show you graphically where they are, and you can see if there is a correlation between long frames and resource transfers.
http://graphics.stanford.edu/~mdfisher/GPUView.html
Dual monitor setups
I once spent two weeks profiling and tweaking and measuring and debugging to try to find a jitter I was getting to no avail. Then, on some obscure forum post I found someone who said that graphics cards are only optimised to deliver the best performance possible to one monitor, the other will always have poorer performance. After reading that I booted my software on another monitor and boom, the issue was gone, or at least significantly reduced. So be wary of Dual monitor setups.
Resource contention
This is when you have a mutex that two threads are trying to get access to the second thread will simply have to wait until the mutex is released before it can continue processing. When that is the main thread you will get a stall. To get around this make sure anywhere you have mutex protected sections are as brief as possible. Also try boosting the priority of your main thread over the others. This will make it more likely that it will get the mutex first, and when it doesn't the process with the lock will get a priority boost until it releases the resource due to windows thread priority inversion.
Add this code to the start of your application:
Code: Select all
// Slightly boost the overal process priority
SetPriorityClass( GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS );
// Set the Multi Media Class Scheduler characteristics of the software. This will
// provide a priority boost to certain threads when the process has focus.
DWORD index = 0;
HANDLE handle = AvSetMmThreadCharacteristics( "Games", &index );
if( handle )
AvSetMmThreadPriority( handle, AVRT_PRIORITY_CRITICAL );
// This is needed to make sure that background work does not starve the main thread.
// This is only setting priority of this thread, not the whole process.
SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
Hope that helps.