   Threaded Texture Loading
  Hey AllI'm loading textures on a thread using D3DXCreateTextureFromFileEx().When the thread completes, I need to swap textures.I'm doing it like this:pOldTexture->Release();pOldTexture = pNewTexture;This works great, except for once in a while it crashes, as you might expect because I've done nothing to prevent the thread from completing at random times.What do I need to do to make texture loading in DX thread safe?-programmer_tom   
  Are you using D3DCREATE_MULTITHREADED? That's the main thing required for using D3D from multiple threads.If you want to avoid using that flag (which can affect performance somewhat) then load the texture on the thread into memory using say fread(), and once that's complete on the main thread call D3DXCreateTextureFromFileInMemoryEx().   ;  With D3D9 you really want to keep all of your code that accesses D3D interfaces on a single thread (the thread that created the window and pumps messages).  You can use the MULTITHREADED flag to make the device thread safe, but this will slow things down significantly.  This means that for loading textures you best option is to do all of the file i/o on a separate thread, and read the image data into memory.  Then you can pass that data off to your main thread, which can use the device or D3DX functions to make the actual texture object.   