Jump to content
  • Advertisement
Sign in to follow this  
anglee

Switch from DDraw to D3D make frame rate drop

This topic is 3496 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 am writing a function that brings the content of a offscreen surface to the screen. The function is called after a frame finished rendering to the offscreen surface. Using Direct3D, the frame rate is much lower than using DirectDraw and the result animation jitters, which is very annoying. I'm wondering if there is a way to achieve same frame rate. Here is how I did it: In DirectDraw, I use the Blt functiton to copy the offscreen surface directly to the onscreen surface:
directDrawObj->GetVerticalBlankStatus(&s);
if (s == FALSE)
	directDrawObj->WaitForVerticalBlank( DDWAITVB_BLOCKBEGIN, NULL );
HRESULT hr = screenSurface->Blt(&dstR, offscreenSurface, &srcR, DDBLT_WAIT, NULL );

In Direct3D, the surface is copied to the backbuffer and than present. I am Using D3DPRESENT_INTERVAL_ONE, D3DSWAPEFFECT_DISCARD:
LPDIRECT3DSURFACE9 offscreenPlainSurface;
LPDIRECT3DSURFACE9 backSurface;

d3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backSurface);
d3dDevice->StretchRect(offscreenPlainSurface, srcR, backSurface, dstR);
d3dDevice->Present(dstR, dstR, NULL, NULL);

Comparing Direct3D method to DirectDraw method, the frame rate drop about 50% which kinda can be expected. I've also tried D3DSWAPEFFECT_FLIP, and it didn't help much there. Is there a way to solve this problem? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Directly accessing the frame buffers in D3D is generally a bad idea - it's quite common for people who use Direct3D in a DirectDraw style to get very bad performance. Where possible you want to use the ::Draw**() commands to get images on to the screen - directly modifying or accessing resources is more a last resort...

Without more details on what you're trying to achieve its difficult to suggest a solution, but you could look into "screen aligned quad" rendering. That and render target textures may get you what you need.


hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by Adam_42
Have you tried IDirect3DDevice9::UpdateSurface()?


Thank you for the suggestion.
I have tried it. However, to use UpdateSurface(), the surface must be D3DPOOL_SYSTEMMEM . But the other two functions I am using, StretchRect and ColorFill, require D3DPOOL_DEFAULT on the other hand.

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
...
Without more details on what you're trying to achieve its difficult to suggest a solution, but you could look into "screen aligned quad" rendering. That and render target textures may get you what you need.


hth
Jack


Thank you very much Jack. I will definitely look into screen aligned quad rendering.

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!