Login  Register

Re: Understanding issue with automatic buffer swapping

Posted by xghost on Mar 06, 2017; 10:56am
URL: https://forum.jogamp.org/Understanding-issue-with-automatic-buffer-swapping-tp4037728p4037740.html

Hi Xerxes,

First of all, thanks for your time and help.

Xerxes Rånby wrote
You want to invert the logic on line #L287 of GL4RenderSystem and use
        if (!canvas.getAutoSwapBufferMode())
so that your buffers will get swapped when you have disabled automatic buffer swapping.

https://gitlab.com/ghost-in-the-zsh/sage2/blob/master/src/ray/sage2/rendersystem/gl4/GL4RenderSystem.java#L287
Just to double-check, please make sure you're looking at the branch with the latest content (git checkout -b latest origin/feature/final-updates-and-documentation). The workaround commit I linked in the previous post is there (not master) and does not have the lines.

I apologize for not making this clearer before. (Just basing that on the URL you posted.)

https://gitlab.com/ghost-in-the-zsh/sage2/blob/feature/final-updates-and-documentation/src/ray/sage2/scene/generic/GenericSceneManager.java#L516

https://gitlab.com/ghost-in-the-zsh/sage2/blob/feature/final-updates-and-documentation/src/ray/sage2/rendersystem/gl4/GL4RenderSystem.java#L230

Xerxes Rånby wrote
After fixing that you can remove all the workaround swap logic from GenericSceneManager
Remove lines 517-522.
https://gitlab.com/ghost-in-the-zsh/sage2/blob/master/src/ray/sage2/scene/generic/GenericSceneManager.java#L517-522
I went back to the master branch you seem to have looked at (which disables auto swapping), tested the following based on your suggestions (slightly different):

// Commented out the manual swapping logic on the GL4RenderSystem file to let the SceneManager do it
// if (canvas.getAutoSwapBufferMode())
        // canvas.swapBuffers();

// On the GenericSceneManager file, removed the if-check, so that swapBuffers() is always invoked
  renderSystem.swapBuffers();

I can still observe the problem on my desktop, even though it should always be swapping the buffers like this. It's as if the following were not really swapping the buffers(?)

// https://gitlab.com/ghost-in-the-zsh/sage2/blob/master/src/ray/sage2/rendersystem/gl4/GL4RenderSystem.java#L214-217
    @Override
    public void swapBuffers() {
        canvas.swapBuffers();
    }

Wouldn't it be "preferable" to call swapBuffers only once after all cameras have finished with their viewports (i.e. once per frame) instead of several times?

Is trying to call canvas.swapBuffers() outside the GLEventListener thread incorrect usage?


Just for checks, I had experimented with grabbing a context to see if it was that (pseudo-ish), but IIRC, that caused a recursive lock issue with JOGL:

GLContext ctx = canvas.getContext();
ctx.makeCurrent();
canvas.swapBuffers();
ctx.release();

I figured I was trying using it incorrectly at on that and had returned it back to a simple canvas.swapBuffers(), though the Javadoc didn't seem to indicate it might be a problem.

Thanks again. Much appreciated.
-r

EDIT: Your last post came in as I was writing this one. I'll get to it in a separate reply as needed.