Try off?
Same deal.
I didn't catch that your rate limiter used a busy wait, sorry. How is that implemented?
if(!mTimer.isStarted())
{
mTimer.start();
}
mTimer.update();
Profiler::beginFrame();
double dt = mTimer.getTimeSinceLastUpdate();
// Spin if FPS gets too high.
if(RenderOptions::getBool(RenderOptions::OPTION_FRAMERATE_CAP) && mMaxFramerate > 0)
{
double minDeltaTime = 1.0 / (double)mMaxFramerate;
while(dt < minDeltaTime)
{
mTimer.update();
dt += mTimer.getTimeSinceLastUpdate();
}
}
This is bizarre so you're probably going to have to share some job system code to find the problem.
for(ParticleSystem* ps : mUpdateList)
{
ps->updateInJob(time, mUpdateJobGroupHandle);
}
bool success = JobSystem::waitForJobGroup(mUpdateJobGroupHandle, 10000);
BASIS_ASSERTD(success, "The particle system update job(s) timed out.");
ParticleSystem::updateInJob() looks like this:
void ParticleSystem::updateInJob(const Time& time, JobGroupHandle jobGroupHandle)
{
mCurrentDeltaTime = (float)time.deltaTime;
updatePendingStateChange();
if (mState == ParticleSystem::StatePlaying)
{
JobSystem::scheduleJob(Basis::MakeDelegate(this, &ParticleSystem::updateJob), jobGroupHandle);
}
}
I have plans to support adding multiple jobs to the system in one go instead of having to do loops like that, locking/unlocking the job system internals on every iteration. But then again, the system performs really well as long as I don't use VSync, so who knows how big of a problem it is.
I appreciate the help!
One more thing. When the PS update jobs are run there are no other jobs running in the system. There are a few jobs that run each frame but they are started after the PS jobs have run and they are waited for too. Also, in the test case I don't use any job priorities other than JobPriorityDefault.
It seems like it might be something with the particles code. Can you replace that with something else simpler to test it?
Is all the particle memory on the CPU only? Your not doing any kind of lock or anything from the GPU before updating the particles?
Have you tried replacing WaitForSingleObject() with a simple atomic flag/spin loop? If it is truly the cause of the problem, removing it entirely should indicate that.