Recommended Posts

Hi,
at the moment I have to write a little benchmarkprogram using Visual C++ 6. The task is to show the "evolution" from GDI -> DirectDraw -> DirectGraphics. For this reason I programmed a simple test program in a Form (no MFC):
2 Bitmaps (256x256@8bit) with transparent areas
1 Bitmap (1x1@8bit) which is stretched on the background
Now the test is always the same:
1. GetTickCount()
2. Start loop
3. Draw Background
4. Move the 2 sprites (one from upperleft to lower right and the other lower right to upper left)
5. As the 2 Sprites are crossing each other, the transparency is visible
6. Flip the Surfaces
6. loop
7. GetTickCount again to measure the elapsed time
The GDI-Test has been done with the StretchBlt and Blt functions (Masking the DC to get transperancy and so on)
In the DirectDraw-Test I only used the FastBlt function.
Each test can be started by clicking a button. In the DirectDraw-case the DirectDraw gets initialized as you know it:

After the DirectDraw-Test the program returns from fullscreen back to the desktop-view with the programform and everything works fine. But now something is going strange:
If I run the GDI-Test it always needs approx. 6 seconds to finish. And I can repeat this as often as I want .. its always near to the 6 seconds. But if I do the DirectDraw-Test and after that start the GDI-Test again it is much more faster! Now it only need approx. 1.5 seconds to finish. Can somebody describe me, what happened?? This effect holds on until I restart my application.
[Edited by - Coder on May 22, 2005 4:50:25 PM]

0

Share this post

Link to post

Share on other sites

Original post by Flash2005If I run the GDI-Test it always needs approx. 6 seconds to finish. And I can repeat this as often as I want .. its always near to the 6 seconds. But if I do the DirectDraw-Test and after that start the GDI-Test again it is much more faster! Now it only need approx. 1.5 seconds to finish. Can somebody describe me, what happened?? This effect holds on until I restart my application.

Good question, I've noticed similar anomalies myself.Another interesting thing is that there's often a large speed is that there's often a large difference in performance between performing GDI blits from DIB bitmaps and the equivalent GDI blits from DirectDraw surfaces (with IDirectDraw::GetDC).

You really shouldn't be different pixel formats for the source bitmap and the display, especially not mixing between rgb and palettized modes. How did you get DirectDraw to perform any color conversion at all?

Despite conducting such a test ourselves (between GDI, DirectDraw and DirectGraphics, on 20 machines or so) we haven't been able to predict their relative performance with any accuracy yet.GDI is often the fastest on new hardware although some new machines (and almost all of the older ones) prefer DirectDraw, DirectGraphics was rarely the fastest but often the most stable and excells at pixel format conversions.

0

Share this post

Link to post

Share on other sites

Okay, this is my first project in Visual C++. Till now I worked with the more comfortable C++ Builder and old style console C. Also this is my first try using DirectX, so my benchmark may be a bit like comparing apples with pears because I do not use exactly the same functions to get the similar result. I just use "common" functions to get the same result (=moving some sprites with transparency around the screen). Hope you can get the point? So I did not use DDraw:GetDC and other GDI-like DD-functions except FastBlt. I wrote this little class for my Sprites:

There is also a function that does the flipping for all the sprites on lbddsBack. I do not have any problems with pallettes if I use 800x600@16bit. If I return to 8 bit mode I get some ugly flickering and fragments on the screen. I used 16bits because I assumed that the desktop is also set to 16 bit to get a better comparison. So I didn't bother any more about pallettes (*please dont kill me*). In my machine there is an old Riva TNT2, but I will test it on a GeforceFX soon.

[Edited by - Coder on May 22, 2005 4:31:59 PM]

0

Share this post

Link to post

Share on other sites

Original post by Flash2005There is also a function that does the flipping for all the sprites on lbddsBack. I do not have any problems with pallettes if I use 800x600@16bit. If I return to 8 bit mode I get some ugly flickering and fragments on the screen. I used 16bits because I assumed that the desktop is also set to 16 bit to get a better comparison. So I didn't bother any more about pallettes (*please dont kill me*). In my machine there is an old Riva TNT2, but I will test it on a GeforceFX soon.

Heh, don't worry. I was just refering to that your original post claimed to use 8-bit pixels while the code was setting 16-bit display mode instead.

But as long long as they match you shouldn't have any problems. So make sure you either use native bitmaps in GDI or DIBs exactly matching the screen's format (probably through BI_BITFIELDS).

Maybe returning from fullscreen mode is moving the window around a few pixels? I've experienced huge performance drops with unaligned GDI blits on a TNT2 card before.It's a long shot but you could try moving the window a few pixels horizontally a little yourself to see if you notice any differences.