SDL2 and multi-threading |
SDL2 and multi-threading |
Doug
Guest
|
I imagine the rules from 1.2 are still a reasonably good guide to go by:http://www.libsdl.org/docs/html/thread.html
~ Doug. On Tue, Dec 11, 2012 at 9:41 AM, Jared Anderson wrote:
|
|||||||||||||
|
SDL2 and multi-threading |
Sik
|
The thread that created the main window is the only thread that can
access it (including e.g. handling events). This is more of a limitation of the underlying APIs, really (I recall the WinAPI imposes this limitation, for instance). Otherwise I can't think of any, locking aside. 2012/12/11 Doug:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
SDL2 and multi-threading |
Jared Anderson
Guest
|
Does anyone see any problems with the following setup, locking aside?
main thread used to create and interact with SDL_Windows, and call SDL_PumpEvents. SDL_Renderers locked to a thread (one renderer per thread probably). No other SDL calls locked to a thread. |
|||||||||||
|
SDL2 and multi-threading |
Sik
|
The renderers make use of the GPU (Direct3D, OpenGL, etc.) which in
turn need access to the window, so renderer functionality needs to be done in the same thread that created the window as well. 2012/12/11 Jared Anderson:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
SDL2 and multi-threading |
Sam Lantinga
|
In general the SDL APIs are not designed for thread safety.
The events API is explicitly thread-safe, and SDL provides the primitives you need to construct pretty much any synchronization primitive, but other than that if you call the same function on multiple threads you're likely to be asking for trouble. This isn't because of any specific design decision, more because games tend to be careful about what work they do on different threads and it hasn't been a big issue. Somebody is welcome to do an audit of the SDL code and propose changes where they are necessary and useful. Cheers! On Mon, Dec 10, 2012 at 5:41 PM, Jared Anderson wrote:
|
|||||||||||||
|