Reputation: 1
I haven't been able to find a decent explanation on how to manage using D3D11 for rendering graphics while using DirectCompute at the same time (DC could be used in the UI thread or on a background thread). My C++ scientific program uses D3D11 extensively for rendering data. Works great. Now I'd like to begin weaving in DirectCompute to do some of the heavy data processing. Some questions:
It looks like I'll need to create a second D3D11Device for doing DirectCompute in the background data processing thread because the main UI thread's D3D11Device can only have one D3D11DeviceContext in use at a time. Is that correct? I'm not doing deferred rendering, I just want to use DirectCompute in other threads that are strictly for data processing. In addition, I don't need to share any of the DirectCompute results with the rendering thread (not directly).
How do you deal with calling a function, that uses DirectCompute for processing, that can be called from multiple threads? Would you pass a D3D11Device+D3D11DeviceContext to the function or would you use TLS to silently pass them in the background? I like the idea of using TLS so that the ability to use DirectCompute is kind of just sitting there, ready to be used. An alternative would be to have a cache of D3D11Devices, where a thread requests a device when it wants to run a Compute Shader and then releases it back to the cache when it's done.
I'm interested in how people have solved these design issues.
Thanks
Upvotes: 0
Views: 25