Jump to content
  • Advertisement
Sign in to follow this  
Dr_Asik

Tearing using render targets with WPF

This topic is 2091 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'm writing a video player in WPF using Direct3D and the D3DImage object. This object takes a pointer to a Direct3DSurface9 and displays it.

 

I've been basically following the D3DImage tutorial and the MSDN sample, and that works well, however these assume the rendering happens on the UI thread, in sync. For my application, I want the rendering to be happening on a different thread, and the UI to take frames to display when it wants.

 

I've managed to do this using a single render target and passing its pointer to D3DImage. However, even when using locks to ensure the GUI isn't updating D3DImage when the rendering thread is rendering and vice-versa, I get a lot of tearing. I've then tried using two different D3DImages on top of each other, each with its own render target, alternate their visibility and always render in the hidden one, but even then if the rendering thread goes too fast, there is tearing.

 

I've read that when you call IDirect3DDevice::EndScene(), this doesn't mean the buffer is ready to be displayed, just that it's queued for rendering; this could be the reason I'm seeing tearing. I'm not calling "Present" (as the D3DImage tutorial explains), and just passing the pointer to WPF after calling EndScene().

 

I'm not very knowledgeable with Direct3D and I don't know what would be a good approach to solve this issue. How can I ensure a buffer is ready to be displayed, while locking as little as possible between the GUI and rendering thread and having good performance? My intuition is I should be using a chain of render targets of some sort, but there are many options and I don't know where to start.

Edited by Dr_Asik

Share this post


Link to post
Share on other sites
Advertisement
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!