IOFramebuffer and VBlank?

Discussion in 'Mac Programming' started by blueshogun96, Feb 7, 2017.

  1. blueshogun96 macrumors regular


    Nov 24, 2012
    After much searching through google and Apple's documentation, I haven't been able to find straight forward answers to these questions.

    1. How do you get an instance of IOFramebuffer that represents your current display? This I do not know how to do. Any ideas on how to get this would be greatly appreciated.

    2. The purpose of getting the above is to track vertical blank events. What I want to do is detect when the screen's vertical blank interrupt begin, as well as when it ends (if possible).

    After taking a look at IOFramebuffer's source, I believe these functions should be enough to get the job done, with kIOFBVBLInterruptType as the interrupt type.

    virtual IOReturn registerForInterruptType( IOSelect interruptType,
                       IOFBInterruptProc proc, OSObject * target, void * ref,
                void ** interruptRef );
        virtual IOReturn unregisterInterrupt( void * interruptRef );
        virtual IOReturn setInterruptState( void * interruptRef, UInt32 state );
        virtual IOReturn getNotificationSemaphore( IOSelect interruptType,
                                                   semaphore_t * semaphore );
    Since I couldn't find any documentation on Apple's website at the time of writing (always says "no overview available" which is quite sad), I simply mad a few assumptions. One assumption is that the interrupt function would only trigger when vertical blank begins, and not when it ends. Is this the case? As for getNotificationSemaphore, does this tell me when the interrupt has finished? Or do I assume that it's only for when the interrupt is signaled? If I can't detect the end of a VBlank interrupt, could I possibly use the function below to time it after the interrupt is signaled?

    virtual void getVBLTime( AbsoluteTime * time, AbsoluteTime * delta );
    This stuff doesn't appear to be well documented. Hours of searching have shown no insight for me. Any ideas? Thanks.

  2. blueshogun96, Apr 12, 2017
    Last edited: Apr 12, 2017

    blueshogun96 thread starter macrumors regular


    Nov 24, 2012

    Is there a replacement for io_connect_get_notification_semaphore in x86_64? I've been at this for quite a while, still haven't found any way of getting interrupts on macOS.


Share This Page