Possible problem with multithreaded shader loading

Started by
2 comments, last by noatom 9 years, 10 months ago

So its apparently believed that loading shaders via multithreading would be better, but I can't grasp how that would be done, since creating a shader requires the dx device.

What would happen if 2 threads tried to create a shader at the same time? Wouldn't a thread start writing over the other? And if each thread had to wait for the other to finish wouldn't that defeat the purpose?

Advertisement

To create a shader you'll need to use ID3D11Device's Create...Shader commands. AFAIK, ID3D11Device call's should be thread safe.

Cheers!

[edit] You didn't specify the D3D you are using.

D3D11 supports multithreaded resource creation, so the driver will be handle creating two shaders simultaneously on the same device. So if you're using D3D11, you're fine. If you're using D3D10 the device will use a mutex to ensure only one thread can access the device at once, so one thread will end up waiting for the other to finish.

thanks, yea I'm using d3d11

This topic is closed to new replies.

Advertisement