Flipping or Discarding in windowed mode

Started by
0 comments, last by i1977 21 years, 10 months ago
I am currently learning Direct3D 8 and I''ve come upon something that I find a bit odd. I have this simple windowed application. If I set the ''SwapEffect'' member of my presentation parameters structure to D3DSWAPEFFECT_FLIP, I get a higher frame rate than if I set it to D3DSWAPEFFECT_DISCARD. Why? Since the app is running in a window, aren''t both methods actually displaying a frame by copying it to the screen? Why is D3DSWAPEFFECT_FLIP faster then? Unless I misunderstood something, the Direct3D documentation seems to say that D3DSWAPEFFECT_DISCARD is normally faster.
Frederic FerlandStrategy First, Inc.http://www.strategyfirst.com
Advertisement
It depends. If you are building your application in debug mode using D3DSWAPEFFECT_DISCARD will be slower. When using D3DSWAPEFFECT_DISCARD you are telling the gfx card that you don''t need the information stored in any backbuffers. This means that the information in the backbuffer is considered invalid after a call to Present(). It might in some cases be valid though and if you read from the backbuffer, you might get correct results on some cards but not on others. Using D3DSWAPEFFECT_DISCARD in debug mode, makes Direct3D fill the backbuffers with garbage to prevent you from accidently reading valid data from the backbuffers. Filling the backbuffers with garbage takes time, and therefore using D3DSWAPEFFECT_DISCARD in debug mode will be slower. It should be faster if you build in release mode.


Real programmers don''t document, if it was hard to write it should be hard to understand


Real programmers don't document, if it was hard to write it should be hard to understand

This topic is closed to new replies.

Advertisement