// Flushes all available packets over the network... returns number of bytes sent
    bool AsyncStream::Flush(Socket &s)
    {
        OVR_CAPTURE_CPU_ZONE(AsyncStream_Flush);

        bool okay = true;

        // Take ownership of any pending data...
        SpinLock(m_bufferLock);
        Swap(m_cacheBegin, m_flushBegin);
        Swap(m_cacheTail,  m_flushTail);
        Swap(m_cacheEnd,   m_flushEnd);
        SpinUnlock(m_bufferLock);

        // Signal that we just swapped in a new buffer... wake up any threads that were waiting on us to flush.
        m_gate.Open();

        if(m_flushTail > m_flushBegin)
        {
            const size_t sendSize = (size_t)(m_flushTail-m_flushBegin);

            // first send stream header...
            StreamHeaderPacket streamheader;
            streamheader.threadID   = m_threadID;
            streamheader.streamSize = sendSize;
            okay = s.Send(&streamheader, sizeof(streamheader));

            // This send payload...
            okay = okay && s.Send(m_flushBegin, sendSize);
            m_flushTail = m_flushBegin;
        }

        OVR_CAPTURE_ASSERT(m_flushBegin == m_flushTail); // should be empty at this point...

        return okay;
    }
예제 #2
0
EGLint GL_FlushSync( int timeout )
{
#if defined(OVR_ENABLE_CAPTURE)
	OVR_CAPTURE_CPU_ZONE(GL_FlushSync);
#endif
	// if extension not present, return NO_SYNC
	if ( eglCreateSyncKHR_ == NULL )
	{
		return EGL_FALSE;
	}

	EGLDisplay eglDisplay = eglGetCurrentDisplay();

	const EGLSyncKHR sync = eglCreateSyncKHR_( eglDisplay, EGL_SYNC_FENCE_KHR, NULL );
	if ( sync == EGL_NO_SYNC_KHR )
	{
		return EGL_FALSE;
	}

	const EGLint wait = eglClientWaitSyncKHR_( eglDisplay, sync,
							EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, timeout );

	eglDestroySyncKHR_( eglDisplay, sync );

	return wait;
}
 // Flush all existing thread streams... returns false on socket error
 bool AsyncStream::FlushAll(Socket &s)
 {
     OVR_CAPTURE_CPU_ZONE(AsyncStream_FlushAll);
     bool okay = true;
     g_listlock.Lock();
     for(AsyncStream *curr=s_head; curr; curr=curr->m_next)
     {
         okay = curr->Flush(s);
         if(!okay) break;
     }
     g_listlock.Unlock();
     return okay;
 }
예제 #4
0
void GL_Flush()
{
#if defined(OVR_ENABLE_CAPTURE)
	OVR_CAPTURE_CPU_ZONE(GL_Flush);
#endif
	if ( eglCreateSyncKHR_ != NULL )
	{
		const EGLint wait = GL_FlushSync( 0 );
		if ( wait == EGL_FALSE )
		{
			LOG("eglClientWaitSyncKHR returned EGL_FALSE");
		}
	}

	// Also do a glFlush() so it shows up in logging tools that
	// don't capture eglClientWaitSyncKHR_ calls.
//	glFlush();
}
예제 #5
0
void GL_Finish()
{
#if defined(OVR_ENABLE_CAPTURE)
	OVR_CAPTURE_CPU_ZONE(GL_Finish);
#endif
	// Given the common driver "optimization" of ignoring glFinish, we
	// can't run reliably while drawing to the front buffer without
	// the Sync extension.
	if ( eglCreateSyncKHR_ != NULL )
	{
		// 100 milliseconds == 100000000 nanoseconds
		const EGLint wait = GL_FlushSync( 100000000 );
		if ( wait == EGL_TIMEOUT_EXPIRED_KHR )
		{
			LOG( "EGL_TIMEOUT_EXPIRED_KHR" );
		}
		if ( wait == EGL_FALSE )
		{
			LOG( "eglClientWaitSyncKHR returned EGL_FALSE" );
		}
	}
}