Friday, November 4, 2022
HomeGame Developmentstructure - Message pump and D3D11 DXGI in separate threads

structure – Message pump and D3D11 DXGI in separate threads


I’ve learn:

https://study.microsoft.com/en-us/home windows/win32/direct3darticles/dxgi-best-practices#multithreading-and-dxgi

https://study.microsoft.com/en-us/home windows/win32/direct3ddxgi/d3d10-graphics-programming-guide-dxgi#multithread-considerations

Threading setup

Major thread (Major loop): Create window and run the message pump (PeekMessage()).
Add messages (keyboard, mouse, …) to a thread secure double buffered queue.

Render thread (Render loop): Create DirectX 11 stuff (Machine, …).
Learn recreation state N from recreation thread. Replace GPU buffers, draw calls, swapchain current.

Recreation Thread (Recreation loop): Create recreation world. Recreation logic, physics, replace recreation state N + 1.

Thread pool: spawn further employee threads.

In response to the posted hyperlinks, DXGI could name SendMessage (synchronous name), which may result in impasse
when the message pump and DXGI are on separate threads. However so far as I perceive it,
there should not be any issues on this case with the principle thread, as a result of the one factor it does is to
pump messages and add them to a thread secure queue. or am I lacking one thing?
Can a impasse nonetheless happen when switching to an unique fullscreen mode?
Calling the swapchain current? or different DXGI calls?
I will not add another code in the principle thread that might make the message pump thread wait on the render thread.

If that is okay, how do I cut back the CPU utilization in the principle thread? Working this loop will devour 100% of the CPU core.
However on the similar time, we wish the enter to really feel responsive.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments