CIrrDeviceMacOSX::flush()

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
devonsoft
Posts: 8
Joined: Thu Oct 04, 2012 2:01 am

CIrrDeviceMacOSX::flush()

Post by devonsoft »

Code: Select all

void CIrrDeviceMacOSX::flush()
{
    if (CGLContext != NULL)
    {
        glFinish();
        CGLFlushDrawable(CGLContext);
    }
}
OpenGL performance on OSX was twice as slow as Windows on the same machine for our game, so I finally profiled it with OpenGL Profiler: Image.


Wow, that's a lot of time in glFinish. Taking out glFinish makes it go from 28fps to 60fps. I wasn't sure if there was a reason glFinish() was being called as taking it out didn't seem to affect anything and Windows just calls SwapBuffers instead. I'm thinking the explicit glFinish is unneeded as according to Apple: "An implicit glFlush operation is performed by CGLFlushDrawable before it returns. For optimal performance, an application should not call glFlush immediately before calling CGLFlushDrawable." https://developer.apple.com/library/mac ... shDrawable
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: CIrrDeviceMacOSX::flush()

Post by Nadro »

Yes, glFinish should be removed. Thanks for report. I'll fix it today ;)

Update:
Fixed in trunk.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
devonsoft
Posts: 8
Joined: Thu Oct 04, 2012 2:01 am

Re: CIrrDeviceMacOSX::flush()

Post by devonsoft »

I can't explain this, but when updating Octodad for OSX 10.14 and 64-bit it seems like now the opposite is true and not calling glFlush() before CGLFlushDrawable causes a synchronization issue or something and it is considerably slower and the null driver FPSCounter is incorrect. Re-adding glFlush() seems to get rid of the stuttering and the FPSCounter then matches my quartz debug fps. I have only tested this on my one machine but may be related to this (although I noticed it with my discrete gpu not the intel one) https://github.com/lionheart/openradar- ... sues/12866

I have to check out the Metal driver sometime because Apple's opengl implementation is always a nightmare.

**This might not matter in 1.8 because it seems like endScene has been restructured
CuteAlien
Admin
Posts: 9646
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: CIrrDeviceMacOSX::flush()

Post by CuteAlien »

There is no metal driver, only a branch with no commits :-(
If anyone wants to maintain OS X - right now we have several people with commit-rights and none of them using them. I'm fine with adding more. Even if it's just about fixing compile-errors once in a while. As for now we don't even have anyone doing compile-checks (I'll fix them whenever I get a report, but I can't test).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply