• Advertisement
Sign in to follow this  

Async Texture Upload

This topic is 444 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,
I want to load textures in secondary threads and then render these in primary thread.
Please suggest how it can be achieved in D3D9 and D3D11, considering I am very new in DirectX Programming.
Thanks.

Share this post


Link to post
Share on other sites
Advertisement

In D3D9 - create the texture on the main thread and then map it. Then on the background thread, stream the texture data into the mapped memory. Then on the main thread, unmap the texture.

In D3D11 you can do the same thing, or, the background thread can stream the texture into memory and then create the texture itself (d3d11 devices are thread-safe) using "initial data" structure.

Share this post


Link to post
Share on other sites

Thanks Hodgman,

1) Can we follow same procedure in D3D9 as you mentioned for D3D11? I've read that D3D9 devices can also be made thread safe using a flag 
D3DCREATE_MULTITHREADED.

2) In D3D11, will we have true asynchronous nature? I mean will multiple threads be able to create/stream texture simultaneously using same D3D11 device or they will be waiting for another to finish the execution?
 

3) Also could you suggest if following is feasible in D3D9/D3D11:
create new D3Dx device for each thread, use it to upload new texture and then share with the Main thread for rendering it? Maybe we'll need to share main thread's D3Dx device with new threads. Is there any way to do this. Maybe it looks bad. But i've taken inspiration for this from OpenGl where we can share context with secondary threads and create new context for each of new threads and then use the context for creating/uploading texture. Main thread will be able to render the texture uploaded by other thread(s) as the context was shared.

Please do guide.

Share this post


Link to post
Share on other sites
1) you can, but it will not perform well. That flag just tells D3D to lock a mutex inside every single D3D function, so that only one thread can use the API at a time. It doesn't actually give you any concurrency.

2) I assume yes, but I haven't tested extensively. IIRC, theres a "caps bit" somewhere that tells you whether the driver supports async resource creation or not.

3) I would not use that approach in D3D. GL requires you to do it that way because it's single-threaded by design, like D3D9.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement