LoadImage Threading

BlitzMax Forums/BlitzMax Programming/LoadImage Threading

BLaBZ(Posted 2010) [#1]
How is it made possible that images can be loaded on threads other then the main?

I'm using miniB3D and would like to also load textures on a child thread though it doesn't seem to work


Brucey(Posted 2010) [#2]
You should be okay with LoadPixmap() since it doesn't require any graphics card interaction (which tend to require the main thread).


BLaBZ(Posted 2010) [#3]
Perfect =D

Can I perform any pixmap operation off the main thread?


GfK(Posted 2010) [#4]
Pixmaps aren't stored on the graphics card, so yes.

I found when experimenting with threading that I couldn't even build collision layers in a child thread, I assume because it used TImages to do it. It worked 99% of the time but every now and again I'd get a freak error (the details of which escape me), and which never ever happened without threading.


BLaBZ(Posted 2010) [#5]
hmm, I don't know much about this, but it seems like Max2D occasionally uses OpenGL commands that require the main thread,


ima747(Posted 2010) [#6]
some graphics operations can (but shouldn't) be performed on child threads, such as creating TImages (pixmaps are perfectly fine on child threads...). I say shouldn't because if you include certain flags you can crash, also if the creation overlaps with other graphics functions (such as flip) you could crash as a result of some of the internal graphics variables and objects (not opengl, but bmax) not being thread safe due to graphics not being intended for threaded use, because MOST graphics calls use the graphics subsystem (opengl/directx) and therefore are not thread safe at the OS level.

Threading is great when it works, but it requires a lot of planning to keep from tripping over something crashy.