Hi Ken,
I plugged in a custom loop that calls as fast as it can the display() method on each of my registered GLCanvas. It did not improve anything …
I disabled the autoSwapBuffer (so nothing was never displayed), and I got a 3x fps boost (from 500 to 1500) for a single GLCanvas. I added 1, 2 and then 3 others, and fps goes down and down linearly with the number of GLCanvas. I suppose the code in GLContext.invokeGL is the bottleneck …
Anyway … it seems that the CPU is not that much stressed. But … I added params -Djogl.verbose -Djogl.debug.GLContext and saw that a lot of context swaps occur, even when only a single GLCanvas is created.
AWT-EventQueue-0: wglMakeCurrent(hdc 0xffffffff87010542, hglrc 0x10000) succeeded
AWT-EventQueue-0: Making context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@1a16869 current
AWT-EventQueue-0: Freeing context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@1a16869
AWT-EventQueue-0: wglMakeCurrent(hdc 0xffffffff87010542, hglrc 0x10000) succeeded
AWT-EventQueue-0: Making context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@1a16869 current
AWT-EventQueue-0: Freeing context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@1a16869
AWT-EventQueue-0: wglMakeCurrent(hdc 0xffffffff87010542, hglrc 0x10000) succeeded
AWT-EventQueue-0: Making context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@1a16869 current
AWT-EventQueue-0: Freeing context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@1a16869
... and so on for each frame
When I have two contexts :
AWT-EventQueue-0: wglMakeCurrent(hdc 0x4012247, hglrc 0x10000) succeeded
AWT-EventQueue-0: Making context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@1a16869 current
AWT-EventQueue-0: Freeing context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@1a16869
AWT-EventQueue-0: wglMakeCurrent(hdc 0x7b0119d9, hglrc 0x10001) succeeded
AWT-EventQueue-0: Making context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@7c6768 current
AWT-EventQueue-0: Freeing context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@7c6768
AWT-EventQueue-0: wglMakeCurrent(hdc 0x4012247, hglrc 0x10000) succeeded
AWT-EventQueue-0: Making context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@1a16869 current
AWT-EventQueue-0: Freeing context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@1a16869
AWT-EventQueue-0: wglMakeCurrent(hdc 0x7b0119d9, hglrc 0x10001) succeeded
AWT-EventQueue-0: Making context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@7c6768 current
AWT-EventQueue-0: Freeing context net.java.games.jogl.impl.windows.WindowsOnscreenGLContext@7c6768
... and so on
It seems natural to swap context when you have more than one, but when you have only one ?
The animator code (simplified) :
// Add a canvas
public void addCanvas(GLCanvas canvas) {
//Link to internal thread
canvas.setRenderingThread(thread);
canvasList.add(canvas);
}
// Main loop
public void run() {
goOn = true;
while (goOn) {
canvasList.get(index).display();
index++;
if (index == canvasList.size()) {
index = 0;
}
}
}
vsync is disabled in each Canvas’ listener init function with a gl.setSwapInterval(0) ; and the canvas is created this way :
GLCapabilities glcaps = new GLCapabilities();
m_Canvas = GLDrawableFactory.getFactory().createGLCanvas(glcaps);
m_Canvas.setIgnoreRepaint(true);
m_Canvas.addGLEventListener(new EVJOGLListener(this)) ;
GLCanvasAnimator animator = GLCanvasAnimator.getInstance();
animator.addCanvas(m_Canvas);
m_Canvas.setNoAutoRedrawMode(true);
m_Canvas.setAutoSwapBufferMode(false) ;
Is this the best I can do about it ?