From 54d34cb749dd877fffcbb2d33cc3707763b94b7e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 4 Dec 2019 19:47:33 +0100 Subject: Bug 1156, Bug 1406: NEWT DRM/GBM WindowDriver.surfaceSwap(): Pass swapInterval to optionally skip VSYNC if 0 --- .../jogamp/newt/driver/egl/gbm/WindowDriver.java | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/newt/classes') 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); } -- cgit v1.2.3