Sign in to follow this  
noatom

Possible problem with multithreaded shader loading

Recommended Posts

noatom    927

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?

Edited by noatom

Share this post


Link to post
Share on other sites
kauna    2922

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. 

Edited by kauna

Share this post


Link to post
Share on other sites
MJP    19755

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this