Switch from DDraw to D3D make frame rate drop

Started by
3 comments, last by anglee 15 years, 4 months ago
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.
Advertisement
Have you tried IDirect3DDevice9::UpdateSurface()?
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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.
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.

This topic is closed to new replies.

Advertisement