Why code runs 40 times faster than other? |
Why code runs 40 times faster than other? |
Leonardo
|
My guess the reason is the flag SDL_RENDERER_PRESENTVSYNC that you're creating the render with.
Per SDL docs/wiki on SDL_CreateRenderer (https://wiki.libsdl.org/SDL_CreateRenderer):Â
Meaning SDL_RenderPresent waits until the correct time to do its job and then return, effectively controlling your frame rate. If you want your iterations to be as fast as possible, maybe you shouldn't use this flag or you should put your simulation code in another thread (but thats a whole different can of problems, imho). HTH Leonardo. Em sex, 13 de mar de 2015 Ã s 14:03, bilsch01 escreveu:
|
|||||||||||||||
|
Why code runs 40 times faster than other? |
Jonny D
|
I would suppose it's vsync limiting you to (typically) 60 fps on the "slow" code. Note: vsync is a good thing for most programs.
Jonny D On Fri, Mar 13, 2015 at 1:03 PM, bilsch01 wrote:
|
|||||||||||||
|
Why code runs 40 times faster than other? |
Ken Paulson
Guest
|
If you look at the documentation you will see this:
SDL_RENDERER_PRESENTVSYNC: present is synchronized with the refresh rate So if the refresh rate of your monitor is 60Hz, then your code will only be able to run at 60 fps. On 13/03/2015 1:03 PM, bilsch01 wrote:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
bilsch01
|
Thanks. I verified it is SDL_RENDERER_PRESENTVSYNC that makes it slow.
|
|||||||||||
|
Why code runs 40 times faster than other? |
Jared Maddox
Guest
|
As others have said, it's the VSync. You say that you're rendering a graph, I assume of a mathematical nature (as opposed to a render graph). Are you saving the rendered graph for external use, or is it purely a "real-time" display? 1) If you're saving the rendered graphs, then I'd suggest Leonardo's suggestion, + render targets. 2) Otherwise, I'd suggest assessing your code to see if the behavior of the similation is affected by render time: 2 I ) If it is, then I'd suggest Leonado's suggestion again, but without render targets this time, 2 II ) If it isn't affected, then you should usually (or even always) be fine with VSync. How did you notice the speed difference? Speed differences produced by VSync are normally only a VALID concern if the speed either impedes development, or during the shift from "developing" status to "publishing" status. The vast majority of those who post about the subject seem to be trying to optimize too early into their development efforts. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|