C++11 Threads

C

Chris Forone

hello group,

im working on an app and have two (ok more) questions:

1) i want to sync my pgm-logic to its "natural" periode: the vertical
retrace of the monitor. i do this with a function named eglSwapBuffers
(http://www.khronos.org/registry/egl/sdk/docs/man/xhtml)

this func blocks until the vsync occurs: "Subsequent client API commands
may be issued on that context immediately after calling eglSwapBuffers,
but are not executed until the buffer exchange is completed." (quote) i
think its some sort of polling-func?!

now i have the idea, to put some kind of logic to the new c++11 threads.
in pseudo-code:

getTimeStamp start (from steady-clock)
doAllLogic to listOfObjects
drawAllObjects (should be fast because of opengl/gpu)
getTimeStamp now

if timeStamp now - start < refreshRateTime
sleep

eglSwapBuffers

is this a good approach or are there big problems because of
thread-resolution and this things?

can i have an influence to some thread-params to optimize thread-behavior?

sorry for my bad english.

second question will follow soon...

thanks for your time, cheers, chris
 
N

Nobody

1) i want to sync my pgm-logic to its "natural" periode: the vertical
retrace of the monitor. i do this with a function named eglSwapBuffers
(http://www.khronos.org/registry/egl/sdk/docs/man/xhtml)

this func blocks until the vsync occurs:

No it doesn't:
"Subsequent client API commands
may be issued on that context immediately after calling eglSwapBuffers,
but are not executed until the buffer exchange is completed." (quote) i
think its some sort of polling-func?!

eglSwapBuffers() inserts a "swap buffers" operation into the graphics
pipeline. The operation will only be performed once any preceding
operations have completed. If vsync has been enabled with
eglSwapInterval(), it will only be performed once the current frame has
finished being displayed.
now i have the idea, to put some kind of logic to the new c++11 threads.
in pseudo-code:

getTimeStamp start (from steady-clock)
doAllLogic to listOfObjects
drawAllObjects (should be fast because of opengl/gpu)
getTimeStamp now

if timeStamp now - start < refreshRateTime
sleep

eglSwapBuffers

is this a good approach or are there big problems because of
thread-resolution and this things?

This is pointless.

If vsync is enabled, your program will naturally be clamped to the refresh
rate by virtue of the graphics pipeline having a fixed size. If you try to
render frames faster than the refresh rate, the pipeline will fill and
rendering functions will block until space is available.

Neither EGL nor OpenGL ES have any direct way of monitoring the progress
of the graphics pipeline (unlike OpenGL 3.x which has sync objects).
 
C

Chris Forone

Am 05.11.2012 13:04, schrieb Nobody:
No it doesn't:


eglSwapBuffers() inserts a "swap buffers" operation into the graphics
pipeline. The operation will only be performed once any preceding
operations have completed. If vsync has been enabled with
eglSwapInterval(), it will only be performed once the current frame has
finished being displayed.


This is pointless.

If vsync is enabled, your program will naturally be clamped to the refresh
rate by virtue of the graphics pipeline having a fixed size. If you try to
render frames faster than the refresh rate, the pipeline will fill and
rendering functions will block until space is available.

Neither EGL nor OpenGL ES have any direct way of monitoring the progress
of the graphics pipeline (unlike OpenGL 3.x which has sync objects).
in this article they add a glFinish after the swap to achieve sync:
http://www.opengl.org/wiki/Swap_Interval but this is apparently no good
solution.

thanks a lot, chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top