Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   C++11 Threads (http://www.velocityreviews.com/forums/t954214-c-11-threads.html)

Chris Forone 11-05-2012 10:18 AM

C++11 Threads
 
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

Nobody 11-05-2012 12:04 PM

Re: C++11 Threads
 
On Mon, 05 Nov 2012 11:18:43 +0100, Chris Forone wrote:

> 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).


Chris Forone 11-05-2012 08:43 PM

Re: C++11 Threads
 
Am 05.11.2012 13:04, schrieb Nobody:
> On Mon, 05 Nov 2012 11:18:43 +0100, Chris Forone wrote:
>
>> 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).
>

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


All times are GMT. The time now is 07:35 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.