I am trying to load textures from a different thread but it fails everytime on this following method:


Turning off my multithreaded routines make the textures load correctly.

How do I allow the device to load from a texture from a different thread?

  • 1
    \$\begingroup\$ How about doing it indirectly - loading the file into memory in a background thread, then creating the texture on the main thread using D3DX10CreateShaderResourceViewFromMemory? \$\endgroup\$ – Daniel Rusznyak Feb 22 '14 at 10:47
  • \$\begingroup\$ Why aren't you using D3D11? It runs on every OS that D3D10 does (via a platform update /service pack on Vista), supports the exact same hardware via feature levels, and has lots of documentation on threading. \$\endgroup\$ – Sean Middleditch Feb 22 '14 at 17:41
  • \$\begingroup\$ @SeanMiddleditch I wasn't aware of the feature levels. I hope that we are not too far into dev to make the change. \$\endgroup\$ – bluejamesbond Feb 22 '14 at 19:56
  • \$\begingroup\$ Feature levels are in D3D11 too, that's what let's it support DX9 class hardware. D3D10 and 11 are very very similar APIs, upgrading should be pretty easy. \$\endgroup\$ – Sean Middleditch Feb 22 '14 at 20:33

By default, the Direct3D 10 device interface is 'thread-safe' if you don't use D3D10_CREATE_DEVICE_SINGLETHREADED. This means it should work from multiple threads, but could well have lock contention.

Direct3D 11.x splits the device into two parts: a Direct3D 11 device interface which is always 'thread-safe' (again unless you use D3D11_CREATE_DEVICE_SINGLETHREADED), and the Direct3D 11 device context interface which is explicitly not 'thread-safe'. This essentially lets you create resources on multiple threads, but you can't 'Map/Unmap' them from multiple threads.

Now all that said, D3DX itself may or may not be thread-safe. Are you using the 'thread-pump' mechanism?

Note that D3DX is deprecated. For Direct3D 11, you can use DDSTextureLoader or WICTextureLoader. They are 'thread-safe' unless you provide a device context for auto-gen mipmaps.

See this MSDN topic.


I can't tell you haw direct X does it. But in OpenGl you have the same problem. There the opengl context is bound to a specific thread and no other thread is allowed to call functions to opengl. But it is possible to explicitly share the context across threads, so that you can load textures in a different thread. Look for multi threaded direct x and you might find a solution.

  • 1
    \$\begingroup\$ This doesn't really provide an answer to the question. Perhaps you meant to leave a comment instead? \$\endgroup\$ – user1430 Feb 22 '14 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.