Skip to main content
GameDev.net gamedev.net
🔒 Locked

Direct3d slowing down other threads

Started by Grasshopper Apr 16, 2013 at 5:44 PM 4 replies 1.2k views
Original Post
Grasshopper
Grasshopper

I've got a MFC program that does all the rendering in the main tread and uses a seperate thread for physics. For some reason when I comment out the main render update function my physics thread runs faster even though no communication is happening between the two threads. If I replace the render update function with code that wastes time in a while loop the physics thread also runs faster. The Direct3D device is being created with D3D11_CREATE_DEVICE_SINGLETHREADED. Does anyone what might be going on here?

Indifferent
Indifferent

There are a few possibilities that spring to mind:

  • You're using a single core CPU (doubtful).
  • The program's affinity mask restricts it to using one core (doubtful, can check with Task Manager).
  • Your physics thread has some form of synchronisation that causes it to wait for the rendering/main thread.
  • One of the two threads is doing some heavy lifting that makes use of multiple cores, perhaps through libraries or system calls, that bottlenecks the other.

Beyond the above reasons and assuming I haven't overlooked anything obvious, it's difficult to say without seeing any code or the program run.

As a note, you ought to double check to make sure that the time wasting white loop is actually indeed wasting CPU time. The common compilers are generally smart enough to optimise out code that has no side-effects.

Hodgman
Hodgman


  • You're using a single core CPU (doubtful).

Also

  • You're using a dual-core CPU with a cache shared by both cores.
Grasshopper
Grasshopper

Thanks for the replies. None of these things seem to be the case as far as I can tell. Back to banging my head against the wall.

Hodgman
Hodgman
You haven't posted much info about the issue, e.g.
What amount of slowdown are you measuring?
Is there normally communication between the two, but you disabled it for this test?
What kind of hardware are you using?
Are these your only two threads?
MJP
MJP

Drivers from AMD and Nvidia (probably Intel too) are heavily multithreaded in order to reduce the overhead of D3D command submission that's visible to your rendering thread. It's very possible that they're fighting with your threads and causing contention. At work we always leave one or two cores available for the driver to use, and we try to make sure that we Sleep on idle threads to give some time back to the OS.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.