diff options
author | Petr Skramovsky <[email protected]> | 2013-07-17 09:20:46 +0200 |
---|---|---|
committer | Petr Skramovsky <[email protected]> | 2013-07-17 09:20:46 +0200 |
commit | 9fce91044649c9f97bd94c5791a10270afad7570 (patch) | |
tree | a69fa244ddeb78e52248d4306a4ecc6b27e924da /src/jogl/native | |
parent | 5116d72f0150bdd6353ee664ef76e414bd61f87e (diff) | |
parent | bfb10d309d97c19a33f9b6758f647186f8e0ddd6 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/jogl/native')
-rw-r--r-- | src/jogl/native/GLDebugMessageHandler.c | 8 | ||||
-rw-r--r-- | src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m | 63 | ||||
-rw-r--r-- | src/jogl/native/timespec.c | 5 | ||||
-rw-r--r-- | src/jogl/native/timespec.h | 3 |
4 files changed, 43 insertions, 36 deletions
diff --git a/src/jogl/native/GLDebugMessageHandler.c b/src/jogl/native/GLDebugMessageHandler.c index fea9d90ce..2e9d6033a 100644 --- a/src/jogl/native/GLDebugMessageHandler.c +++ b/src/jogl/native/GLDebugMessageHandler.c @@ -21,11 +21,11 @@ static jmethodID glDebugMessageARB = NULL; // int source, int type, int id, int severity, String msg static jmethodID glDebugMessageAMD = NULL; // int id, int category, int severity, String msg -typedef void (GLAPIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); -typedef void (GLAPIENTRY* _local_GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +typedef void (APIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef void (APIENTRY* _local_GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -typedef void (GLAPIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, const GLvoid *userParam); -typedef void (GLAPIENTRY* _local_GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +typedef void (APIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, const GLvoid *userParam); +typedef void (APIENTRY* _local_GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); /* * Class: jogamp_opengl_GLDebugMessageHandler diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 6738364a7..046171efc 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -818,40 +818,39 @@ static const GLfloat gl_verts[] = { - (void)waitUntilRenderSignal: (long) to_micros { - BOOL ready = NO; - int wr = 0; + struct timespec t0, to_until; + BOOL tooLate; + int wr; + if( 0 >= to_micros ) { + to_micros = 16666 + 1000; // defaults to 1/60s + 1ms + NSLog(@"MyNSOpenGLContext::waitUntilRenderSignal: to_micros was zero, using defaults"); + } pthread_mutex_lock(&renderLock); - SYNC_PRINT("{W %ld us", to_micros); - do { - if(0 >= swapInterval) { - ready = YES; - } - if(NO == ready) { - #ifdef DBG_SYNC - struct timespec t0, t1, td, td2; - timespec_now(&t0); - #endif - if( 0 >= to_micros ) { - to_micros = 16666 + 1000; // defaults to 1/60s + 1ms - NSLog(@"MyNSOpenGLContext::waitUntilRenderSignal: to_micros was zero, using defaults"); - } - struct timespec to_abs = lastWaitTime; - timespec_addmicros(&to_abs, to_micros); - #ifdef DBG_SYNC - timespec_subtract(&td, &to_abs, &t0); - fprintf(stderr, ", (%ld) / ", timespec_milliseconds(&td)); - #endif - wr = pthread_cond_timedwait(&renderSignal, &renderLock, &to_abs); - #ifdef DBG_SYNC - timespec_now(&t1); - timespec_subtract(&td, &t1, &t0); - timespec_subtract(&td2, &t1, &lastWaitTime); - fprintf(stderr, "(%ld) / (%ld) ms", timespec_milliseconds(&td), timespec_milliseconds(&td2)); - #endif - ready = YES; + timespec_now(&t0); + to_until = lastWaitTime; + timespec_addmicros(&to_until, to_micros); + tooLate = timespec_compare(&to_until, &t0) < 0; + #ifdef DBG_SYNC + struct timespec td_until; + timespec_subtract(&td_until, &to_until, &t0); + SYNC_PRINT("{W %ld ms, to %ld ms, late %d", to_micros/1000, timespec_milliseconds(&td_until), tooLate); + #endif + if( 0 < swapInterval ) { + if( tooLate ) { + // adjust! + to_until = t0; + timespec_addmicros(&to_until, to_micros); } - } while (NO == ready && 0 == wr) ; - SYNC_PRINT("-%d-%d-%d}", shallDraw, wr, ready); + wr = pthread_cond_timedwait(&renderSignal, &renderLock, &to_until); + #ifdef DBG_SYNC + struct timespec t1, td, td2; + timespec_now(&t1); + timespec_subtract(&td, &t1, &t0); + timespec_subtract(&td2, &t1, &lastWaitTime); + fprintf(stderr, "(%ld) / (%ld) ms", timespec_milliseconds(&td), timespec_milliseconds(&td2)); + #endif + } + SYNC_PRINT("-%d-%d}\n", shallDraw, wr); timespec_now(&lastWaitTime); pthread_mutex_unlock(&renderLock); } diff --git a/src/jogl/native/timespec.c b/src/jogl/native/timespec.c index 50f0ca8c5..a69f4635e 100644 --- a/src/jogl/native/timespec.c +++ b/src/jogl/native/timespec.c @@ -75,3 +75,8 @@ long timespec_milliseconds(struct timespec *a) { return a->tv_sec*1000 + a->tv_nsec/1000000; } + +long timespec_microseconds(struct timespec *a) +{ + return a->tv_sec*1000000 + a->tv_nsec/1000; +} diff --git a/src/jogl/native/timespec.h b/src/jogl/native/timespec.h index f900bfa16..a621562b9 100644 --- a/src/jogl/native/timespec.h +++ b/src/jogl/native/timespec.h @@ -17,4 +17,7 @@ void timespec_subtract(struct timespec *r, struct timespec *a, struct timespec * /** convert the timespec into milliseconds (may overflow) */ long timespec_milliseconds(struct timespec *a); +/** convert the timespec into microseconds (may overflow) */ +long timespec_microseconds(struct timespec *a); + #endif /* _timespec_h */ |