Jump to content
  • Advertisement
Sign in to follow this  
Infinisearch

DX12 Can you use C++ multithreding with dx12?

This topic is 560 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

Advertisement

How do you think the C++11 multithreading is implemented? It calls the Win32 APIs for threading. DX12's threading behavior is the same between C++11 threads and Win32 threads, because they are the same under the hood.

Share this post


Link to post
Share on other sites
How do you think the C++11 multithreading is implemented? It calls the Win32 APIs for threading. DX12's threading behavior is the same between C++11 threads and Win32 threads, because they are the same under the hood.

I know it uses win32 underneath but I didn't know if you could access this functionality directly or more accurately interacting with fences. 

 

 

You can use any threading API. D3D doesn't create or interact with your threada directly.

For a fence you use WaitForSingleObject and an event. This is what I was referring to.  What are the equivalent things in C++11?

Edited by Infinisearch

Share this post


Link to post
Share on other sites

I understand now. No, as far as I know, there's no C++11 wrapper for a Win32 Event object, just critical sections, threads, condition variables, etc.

My team uses a relatively simple RAII wrapper around the Win32 APIs to make a C++ Event class. We've got a couple versions - ones that are closer to unique_ptr which don't allow copy, and ones which are closer to shared_ptr/CComPtr which use DuplicateHandle to copy.

Share this post


Link to post
Share on other sites

There is no multi-threading built into DirectX but the management resources for you to do so are there. 

Edit (wanted to add more info): In Dx12 you get data structures (command lists, allocators etc) which are usable in a multithreaded system. It does not matter which kind of threading API or libraries you'd use. As Directx12 doesn't necessarily expect STL threading or Windows threading. It only provides you graphics specific handles which you can use with any library you can dream of.

I recommend that you use a system where separate threads build command lists and the main thread submits them to the GPU.

Read the book 'C++ concurrency in action' if you want to learn more about threading.

Edited by Mercesa

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!