diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java | 30 | ||||
-rw-r--r-- | src/newt/native/drm_gbm_legacy.c | 27 |
2 files changed, 41 insertions, 16 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java index b5985c66c..75062287d 100644 --- a/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java @@ -39,6 +39,7 @@ import com.jogamp.newt.Display; import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.GLCapabilitiesChooser; import com.jogamp.opengl.GLCapabilitiesImmutable; +import com.jogamp.opengl.GLContext; import com.jogamp.opengl.GLException; import com.jogamp.opengl.egl.EGL; @@ -288,15 +289,18 @@ public class WindowDriver extends WindowImpl { final long nativeWindowHandle = getWindowHandle(); final DrmMode d = screen.drmMode; + final GLContext ctx = GLContext.getCurrent(); + final int swapInterval = ctx.getSwapInterval(); + if(!EGL.eglSwapBuffers(display.getHandle(), eglSurface)) { throw new GLException("Error swapping buffers, eglError "+toHexString(EGL.eglGetError())+", "+this); } if( 0 == lastBO ) { lastBO = FirstSwapSurface(d.drmFd, d.getCrtcIDs()[0], getX(), getY(), d.getConnectors()[0].getConnector_id(), - d.getModes()[0], nativeWindowHandle); + d.getModes()[0], nativeWindowHandle, swapInterval); } else { lastBO = NextSwapSurface(d.drmFd, d.getCrtcIDs()[0], getX(), getY(), d.getConnectors()[0].getConnector_id(), - d.getModes()[0], nativeWindowHandle, lastBO); + d.getModes()[0], nativeWindowHandle, lastBO, swapInterval); } return true; // eglSwapBuffers done! } @@ -377,27 +381,33 @@ public class WindowDriver extends WindowImpl { protected static native boolean initIDs(); // private native void reconfigure0(long eglWindowHandle, int x, int y, int width, int height, int flags); - private long FirstSwapSurface(final int drmFd, final int crtc_id, final int x, final int y, final int connector_id, final drmModeModeInfo drmMode, final long gbmSurface) { + private long FirstSwapSurface(final int drmFd, final int crtc_id, final int x, final int y, + final int connector_id, final drmModeModeInfo drmMode, + final long gbmSurface, final int swapInterval) { final ByteBuffer bb = drmMode.getBuffer(); if(!Buffers.isDirect(bb)) { throw new IllegalArgumentException("drmMode's buffer is not direct (NIO)"); } return FirstSwapSurface0(drmFd, crtc_id, x, y, connector_id, bb, Buffers.getDirectBufferByteOffset(bb), - gbmSurface); + gbmSurface, swapInterval); } - private native long FirstSwapSurface0(int drmFd, int crtc_id, int x, int y, int connector_id, Object mode, int mode_byte_offset, - long gbmSurface); + private native long FirstSwapSurface0(int drmFd, int crtc_id, int x, int y, + int connector_id, Object mode, int mode_byte_offset, + long gbmSurface, int swapInterval); - private long NextSwapSurface(final int drmFd, final int crtc_id, final int x, final int y, final int connector_id, final drmModeModeInfo drmMode, final long gbmSurface, final long lastBO) { + private long NextSwapSurface(final int drmFd, final int crtc_id, final int x, final int y, + final int connector_id, final drmModeModeInfo drmMode, + final long gbmSurface, final long lastBO, final int swapInterval) { final ByteBuffer bb = drmMode.getBuffer(); if(!Buffers.isDirect(bb)) { throw new IllegalArgumentException("drmMode's buffer is not direct (NIO)"); } return NextSwapSurface0(drmFd, crtc_id, x, y, connector_id, bb, Buffers.getDirectBufferByteOffset(bb), - gbmSurface, lastBO); + gbmSurface, lastBO, swapInterval); } - private native long NextSwapSurface0(int drmFd, int crtc_id, int x, int y, int connector_id, Object mode, int mode_byte_offset, - long gbmSurface, long lastBO); + private native long NextSwapSurface0(int drmFd, int crtc_id, int x, int y, + int connector_id, Object mode, int mode_byte_offset, + long gbmSurface, long lastBO, int swapInterval); } diff --git a/src/newt/native/drm_gbm_legacy.c b/src/newt/native/drm_gbm_legacy.c index a6356bacf..1aa8d5f82 100644 --- a/src/newt/native/drm_gbm_legacy.c +++ b/src/newt/native/drm_gbm_legacy.c @@ -181,7 +181,8 @@ static DRM_FB * drm_fb_get_from_bo(int drmFd, struct gbm_bo *bo) JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_FirstSwapSurface0 (JNIEnv *env, jobject obj, jint drmFd, jint jcrtc_id, jint jx, jint jy, - jint jconnector_id, jobject jmode, jint jmode_byte_offset, jlong jgbmSurface) + jint jconnector_id, jobject jmode, jint jmode_byte_offset, + jlong jgbmSurface, jint swapInterval) { uint32_t crtc_id = (uint32_t)jcrtc_id; uint32_t connector_id = (uint32_t)jconnector_id; @@ -216,14 +217,19 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_FirstSwapSu drmFd, crtc_id, fb->fb_id, jx, jy, connector_id, drmMode->name, ret, strerror(errno)); return 0; } - DBG_PRINT( "EGL_GBM.Window FirstSwapSurface0 nextBO %p, fd %d, crtc_id 0x%x, fb_id 0x%x, pos %d/%d, conn_id 0x%x, curMode %s\n", - nextBO, drmFd, crtc_id, fb->fb_id, jx, jy, connector_id, drmMode->name); + DBG_PRINT( "EGL_GBM.Window FirstSwapSurface0 swapInterval %d, nextBO %p, fd %d, crtc_id 0x%x, fb_id 0x%x, pos %d/%d, conn_id 0x%x, curMode %s\n", + swapInterval, nextBO, drmFd, crtc_id, fb->fb_id, jx, jy, connector_id, drmMode->name); return (jlong) (intptr_t) nextBO; } +#ifdef VERBOSE_ON +static int nextSwapVerboseOnce = 1; +#endif + JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_NextSwapSurface0 (JNIEnv *env, jobject obj, jint drmFd, jint jcrtc_id, jint jx, jint jy, - jint jconnector_id, jobject jmode, jint jmode_byte_offset, jlong jgbmSurface, jlong jlastBO) + jint jconnector_id, jobject jmode, jint jmode_byte_offset, + jlong jgbmSurface, jlong jlastBO, jint swapInterval) { uint32_t crtc_id = (uint32_t)jcrtc_id; uint32_t x = (uint32_t)jx; @@ -246,6 +252,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_NextSwapSur ERR_PRINT("Failed to get a new framebuffer BO (1)\n"); return 0; } +#if 0 if( fbNext->x != x || fbNext->y != y ) { // position changed, hard drmModeSetCrtc(..) w/o vsync fbNext->x = x; @@ -265,7 +272,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_NextSwapSur drmFd, crtc_id, fbNext->fb_id, jx, jy, connector_id, drmMode->name, ret, strerror(errno)); return 0; } - } else { + } else +#endif + if( 0 != swapInterval) { // same position, use vsync ret = drmModePageFlip(drmFd, crtc_id, fbNext->fb_id, DRM_MODE_PAGE_FLIP_EVENT, &waiting_for_flip); @@ -300,7 +309,13 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_WindowDriver_NextSwapSur gbm_surface_release_buffer(gbmSurface, lastBO); } - // DBG_PRINT( "EGL_GBM.Window NextSwapSurface0 %p -> %p\n", lastBO, nextBO); +#ifdef VERBOSE_ON + if( nextSwapVerboseOnce ) { + nextSwapVerboseOnce = 0; + DBG_PRINT( "EGL_GBM.Window NextSwapSurface0 swapInterval %d, bo %p -> %p, fd %d, crtc_id 0x%x, fb_id 0x%x, pos %d/%d, conn_id 0x%x, curMode %s\n", + swapInterval, lastBO, nextBO, drmFd, crtc_id, fbNext->fb_id, jx, jy, connector_id, drmMode->name); + } +#endif return (jlong) (intptr_t) nextBO; } |