• Advertisement
Sign in to follow this  

Multithreaded renderer (with multiple devices)

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

I have a directx 9 application that needs to run on a Windows XP (embedded) machine with two monitors.

My first iteration of the renderer was a single [font=courier new,courier,monospace]IDirect3DDevice9[/font] object and then I [font=courier new,courier,monospace]IDirect3DDevice9::CreateAdditionalSwapChain()[/font] per "screen", which rendered out multiple 'windows' positioned and sized to simulate full screen.

This worked well, however I'd get lots of screen tearing since I used [font=courier new,courier,monospace]D3DPRESENT_INTERVAL_IMMEDIATE[/font] within the presentation parameters because I don't want to stall the updates waiting for vBlank. Also, I assume that with only one device querying one adapter, I'd not be able to safely assume the vBlank period for both monitors, only the 'main' monitor.

So this lead me to re-writing the renderer to use multiple devices (one for each monitor), and each device has its own adapter for its respective monitor. For my purposes, this is working just as well as the additional swap chains method, however I'm back to the same issue of tearing since the alternative is stalling the main thread twice for both vBlank's, which leads to unacceptable framerate jittering.

[hr]
If I were to put forth the incredible amount of effort of rewriting my engine to be a multi-threaded renderer, will this solve my screen tearing issue? More specifically, am I able to create a thread for each device and render/present them independently? If I must keep all DX API calls on the same thread (which I believe is the case), will stalling multiple times waiting for vBlank still allow me to achieve a 60hz FPS?

-or-

Is there an easier way to know when to invoke [font=courier new,courier,monospace]IDirect3DSwapChain9::Present()[/font] without [font=courier new,courier,monospace]D3DPRESENT_INTERVAL_DEFAULT[/font] and on a single thread?

I've tried polling [font=courier new,courier,monospace]IDirect3DSwapChain9::GetRasterStatus()[/font] to manually present an already rendered backbuffer in the vBlank period (per device/monitor), but that doesn't seem to be accurate enough as I still get tearing. Edited by CrescentFresh

Share this post


Link to post
Share on other sites
Advertisement

directx will only vsync in fullscreen exclusive mode. So your windowed mode must be false for all your swapchains. Search fullscreen exclusive mode on MSDN should take you through it step by step.

 

Good luck.

Share this post


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

  • Advertisement