D3DSWAPEFFECT_DISCARD vs ..._COPY or _COPY_VSYNC
Ok, this is driving me crazy. Can anybody explain to me why D3DSWAPEFFECT_DISCARD in the D3DPRESENT_PARAMETERS struct would make a difference in frame rate versus D3DSWAPEFFECT_COPY or COPY_VSYNC? With just _DISCARD I can get 90+ frames/sec with nothing on the screen other than a blue solid color. I put in _COPY and the rate drops to 5 frames/sec. I am using The Zen of Direct3D game programming code from chpt 12. I wonder if they send these books to editors who don''t know anything about a computer.
Anyway, any any help would be helpful here.
Happy Coding!
-Escaflowne75
This is explained in the DX8 SDK docs for the D3DSWAPEFFECT enumerated type, but this might help:
When Present is called and you''ve set:
D3DSWAPEFFECT_DISCARD
This happens:
windowed
blit from render target to window
fullscreen
page flip back buffer to front buffer
D3DSWAPEFFECT_FLIP
This happens:
windowed
blit from window to temp buffer
blit from render target to window
blit from temp buffer to render target
fullscreen
page flip back buffer to front buffer
D3DSWAPEFFECT_COPY
This happens:
windowed
blit from window to temp buffer
fullscreen
blit from back buffer to temp buffer
page flip back buffer to front buffer
blit from temp buffer to back buffer
D3DSWAPEFFECT_COPY_VSYNC
This happens:
windowed
wait until vblank occurs
blit from window to temp buffer
fullscreen
same as D3DSWAPEFFECT_COPY
If you don''t have room in video memory for the temp buffers in the scenarios above, the temp buffer will be created in system memory. A blit from video memory down to system memory is one of the slowest operations on the planet. I wouldn''t be at all surprised if this is causing the dramatic drop in frame rate that you''re seeing.
Why do you need to set the D3DSWAPEFFECT_COPY* mode?
When Present is called and you''ve set:
D3DSWAPEFFECT_DISCARD
This happens:
windowed
blit from render target to window
fullscreen
page flip back buffer to front buffer
D3DSWAPEFFECT_FLIP
This happens:
windowed
blit from window to temp buffer
blit from render target to window
blit from temp buffer to render target
fullscreen
page flip back buffer to front buffer
D3DSWAPEFFECT_COPY
This happens:
windowed
blit from window to temp buffer
fullscreen
blit from back buffer to temp buffer
page flip back buffer to front buffer
blit from temp buffer to back buffer
D3DSWAPEFFECT_COPY_VSYNC
This happens:
windowed
wait until vblank occurs
blit from window to temp buffer
fullscreen
same as D3DSWAPEFFECT_COPY
If you don''t have room in video memory for the temp buffers in the scenarios above, the temp buffer will be created in system memory. A blit from video memory down to system memory is one of the slowest operations on the planet. I wouldn''t be at all surprised if this is causing the dramatic drop in frame rate that you''re seeing.
Why do you need to set the D3DSWAPEFFECT_COPY* mode?
I noticed that the author had used it in his code on the CD while it wasn''t there in the book. I took it out in his code and his engine off the CD is still slow. Though I did manged to fix my problem...simple array overflow for a frame rate variable. oops
So are you saying that i should just use _DISCARD all the time?
Happy coding!
-Escaflowne75
So are you saying that i should just use _DISCARD all the time?
Happy coding!
-Escaflowne75
use _DISCARD unless you''re holding onto the frame and doing something more with it. For example, cool progressive-blurring demos often do this, altering each frame rather than creating it anew. But unless you have an odd application like this, stick with _DISCARD.
Don''t listen to me. I''ve had too much coffee.
Don''t listen to me. I''ve had too much coffee.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement