[SDL] Two threads updating screen
René Dudfield
renesd at gmail.com
Wed Jun 10 22:32:46 PDT 2009
hi,
You could easily have a back buffer for the UI thread. Then update
all the parts from the video thread.
Update the UI backbuffer Surface to the screen from the video thread.
That's how I make use of multiple threads/processes for blitting. You
can split the screen up into multiple sections that way.
Another trick is to do separate layers in separate threads(if you use
layers)... but still only update the screen from the main thread.
Note that you'll probably want to use ncpu-2 threads for the other
sections... as you have one main thread, and one OS thread. eg with
an X server the X server uses a separate cpu/thread already. Runtime
benchmarking is always useful of course (especially with hyper
threading coming back with the latest intel cpus and telling you you
have fake cores/cpus).
cu,
On Wed, Jun 10, 2009 at 5:54 PM, shree 0987<shr0987 at gmail.com> wrote:
> My application has one fast video thread (updating at 33 ms) using the top
> part of the screen, and a slow UI thread (using the bottom of the screen).
> If the user hits a button, then some response is required within the UI area
> of the screen. The UI has no effect on the video, and the two threads work
> on mutually exclusive areas of the screen.
>
> Based on the feedback, I'm considering two approaches:
> Approach 1:
> When an event happens, the UI thread (i) refreshes screen, (ii) flips
> screen, (iii) refreshes screen. This ensures that both screen buffers are
> updated. The video thread simply refreshes and flips every 33 ms.
>
> Approach 2:
> The video thread updates video AND Ui every 33 ms.
>
> Is one better than the other?
>
> Thanks,
> --Shree
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>
More information about the SDL
mailing list