Jump to content
  • Advertisement
Sign in to follow this  
Daichi

DirectX Multithreading

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

Is it safe to run my DX9 game loop in a separate thread from my message-pump? Here is what I got right now. My DX class is a global. Inside my WinMain: - initialize my DX class - start my Game loop thread - start a simple 'GetMessage' Message-pump Now this works find and dandy, but If I loose my d3ddevice, I'm unable to reset it and I get this message. Direct3D9: (ERROR) :Reset can only be called from the thread that the device was created from. And I get other errors if I try to create the d3ddevice within my game thread. I suppose I can go back to a single thread and using 'PeakMessage' instead but I was hoping to try some multithreading. -Daichi

Share this post


Link to post
Share on other sites
Advertisement
Yes, multithreading is fine, so long as the calls to D3D are all from the same thread. If you want to make D3D calls from several threads, you need to pass the D3DCREATE_MULTITHREADED flag to IDirect3DDevice9::CreateDevice() - But IDirect3DDevice9::Reset() can only be called from the thread that called CreateDevice(). From the decumentation:
Quote:
A call to IDirect3DDevice9::Reset will fail if called on a different thread than that used to create the device being reset.


In your code, you probably reset the device in your window proc. What you really should be doing, is signalling to the render thread that it's ok to reset the device (Or spin the render thread in a TestCooperativeLevel() loop until it returns D3DERR_DEVICENOTRESET).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I wasn't having any luck with it. I'm actually doing next to nothing in my WinProc. I am using the multithreaded flag. I assume I need to Create the device in the same thread I render in? But that was just spitting out other errors. I also tried putting the message pump in it's own thread which I also didn't have much luck with. I'm obviously doing things wrong, So I think I'll give up for now and come back to it after I do more reading on the topic. :(

Or does anyone know if there are any DX multithreaded examples I could take a look at?

-Daichi

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!