The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL2 and TripleBuffering
mediata


Joined: 10 Mar 2014
Posts: 12
Hello,
I am trying to enable TripleBuffering and Use it in SDL2. I develop under linux, and as far as i know i must enable first this option into Driver.
Here is my code:
Code:

Section "Device"
        Identifier "Intel Graphics"
        Driver "intel"
        Option "TripleBuffer" "On"
        Option "SwapbuffersWait" "Off"
        Option "ModeDebug" "yes" # to see if triple buffer is enabled
EndSection

After restart i see that TripleBuffer is enabled.
Quote:

[ 8.154] (**) intel(0): Wait on SwapBuffers? disabled
[ 8.154] (**) intel(0): Triple buffering? enabled


Everything is fine, but how i can tell to my program that must use triple buffering?

I tried with SDL_RenderPresent() but when I disable VSYNC there are horizontal lines on my window, but when i with TripleBuffer this cannot be happen.
SDL2 and TripleBuffering
Nikos Chantziaras
Guest

On 13/11/15 12:50, mediata wrote:
Quote:
Everything is fine, but how i can tell to my program that must use
triple buffering?

I tried with SDL_RenderPresent() but when I disable VSYNC there are
horizontal lines on my window, but when i with TripleBuffer this cannot
be happen.

AFAIK, SDL does not allow you to explicitly set triple buffering. You
can only set the SDL_GL_DOUBLEBUFFER GL attribute. If you configured
your driver to use triple buffering, then this *should* mean triple
buffering will be used for all GL apps. Hopefully someone who knows more
about this can provide more information about the issue.

Note though, that triple buffering on its own doesn't do anything. It
needs VSync. Without VSync, it does nothing (or at least, nothing
useful.) Triple buffering does *not* eliminate tearing ("horizontal
lines"). Only VSync does that. TB works together with VSync to avoid
blocking your render loop while waiting for the next vblank. The result
of that is that if your framerate isn't high enough, it gets halved.
Without vsync, there's no wait for vblank, and thus the problem doesn't
exist, so TB does nothing in that case.

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: SDL2 and TripleBuffering
mediata


Joined: 10 Mar 2014
Posts: 12
Nikos Chantziaras wrote:
On 13/11/15 12:50, mediata wrote:
Quote:
Everything is fine, but how i can tell to my program that must use
triple buffering?

I tried with SDL_RenderPresent() but when I disable VSYNC there are
horizontal lines on my window, but when i with TripleBuffer this cannot
be happen.

AFAIK, SDL does not allow you to explicitly set triple buffering. You
can only set the SDL_GL_DOUBLEBUFFER GL attribute. If you configured
your driver to use triple buffering, then this *should* mean triple
buffering will be used for all GL apps. Hopefully someone who knows more
about this can provide more information about the issue.

Note though, that triple buffering on its own doesn't do anything. It
needs VSync. Without VSync, it does nothing (or at least, nothing
useful.) Triple buffering does *not* eliminate tearing ("horizontal
lines"). Only VSync does that. TB works together with VSync to avoid
blocking your render loop while waiting for the next vblank. The result
of that is that if your framerate isn't high enough, it gets halved.
Without vsync, there's no wait for vblank, and thus the problem doesn't
exist, so TB does nothing in that case.

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


From what i read here. http://www.anandtech.com/show/2794/2 . TripleBuffering is different from what you describe.
While one buffer is presenting to monitor you can draw into other two. And when you finish with front buffer you can switch with ready one. And you can draw
Or am wrong Confused
SDL2 and TripleBuffering
Eirik Byrkjeflot Anonsen
Guest

mediata writes:

Quote:
Nikos Chantziaras wrote:
Quote:
On 13/11/15 12:50, mediata wrote:

Quote:
Everything is fine, but how i can tell to my program that must use
triple buffering?

I tried with SDL_RenderPresent() but when I disable VSYNC there are
horizontal lines on my window, but when i with TripleBuffer this cannot
be happen.


AFAIK, SDL does not allow you to explicitly set triple buffering. You
can only set the SDL_GL_DOUBLEBUFFER GL attribute. If you configured
your driver to use triple buffering, then this *should* mean triple
buffering will be used for all GL apps. Hopefully someone who knows more
about this can provide more information about the issue.

Note though, that triple buffering on its own doesn't do anything. It
needs VSync. Without VSync, it does nothing (or at least, nothing
useful.) Triple buffering does *not* eliminate tearing ("horizontal
lines"). Only VSync does that. TB works together with VSync to avoid
blocking your render loop while waiting for the next vblank. The result
of that is that if your framerate isn't high enough, it gets halved.
Without vsync, there's no wait for vblank, and thus the problem doesn't
exist, so TB does nothing in that case.

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


From what i read here. http://www.anandtech.com/show/2794/2 . TripleBuffering is different from what you describe.
While one buffer is presenting to monitor you can draw into other two. And when you finish with front buffer you can switch with ready one. And you can draw
Or am wrong Confused

Both Nikos and anandtech is right.

Without vsync, you are always "finished with" the front buffer. So as
soon as there is a "ready" buffer it will be swapped with the front
buffer immediately. Since this can happen in the middle of sending the
frame to the monitor, you will get tearing.

It is only with vsync that there is any waiting before the front buffer
is swapped with the "ready" buffer. In this case, the buffer is only
swapped between two frames are sent to the monitor. Thus all frames are
sent completely from a single frame buffer, and you will have no tearing
(regardless of whether you are using double buffering or triple
buffering).

Thus, with triple buffering enabled and vsync disabled, you will always
have 1 front buffer and 2 "not-ready" back buffers. With both triple
buffering and vsync enabled, you may have 1 front buffer that will be
displayed until the next vsync, 1 "ready" buffer that will become the
front buffer on the next vsync and 1 "not-ready" buffer that you can
render into.

eirik
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org