Skip to main content
gamedev.net
🔒 Locked

Render bitmap

Started by cobolt123 Feb 26, 2008 at 1:11 AM 4 replies 2.5k views
Original Post
cobolt123
cobolt123
Hi, I need to render bitmaps really fast with great performance. Since I at the same time need to do other CPU demanding operations it is prefered if the rendering can be handled as much as possible by the graphics card. But the rendering must perform ok even if there is no 3D support in the graphics card. I have tried several rendering methods without coming to a conclusion. I have tried these methods: MFC: ---------------------------- CDC::StretchDIBits CDC::StretchBlt CDC::BitBlt GDI: ---------------------------- SetDIBitsToDevice DirectDraw: ---------------------------- IDirectDrawSurface7::BltFast DirectX 9 ---------------------------- IDirect3DDevice9::SetTexture IDirect3DDevice9::StretchRect ID3DXSprite::Draw One method is by far fastest on all three systems I have tested with. The system setup is similar for all three, except for the graphics cards: Windows XP. service pack 2 Intel Pentium D CPU 3.40 GHz, 2GB Ram The graphic cards differ accordingly: 1. Matrox Millenium G550. 32MB 2. Intel 82915. 128MB 3. Geforce8600GT 256Mb The by far fastest rendering method is "IDirectDrawSurface7::BltFast". It is also the only method which is slowest on system 1 with the worst graphics card, and by far fastest on system 3 with the best card. Many of the other methods are worst on system 3, with the best graphics card! However, I'am not very happy with using an old method from DDraw7, when there should be methods which are faster and more optimized for new graphic cards in DirectX 9. Furthermore BltFast does not support resizing. But which method is this, that is best optimized for new graphics cards but also has good performance on computers with old graphics cards? And how do I use it to get the best performance and to minimize CPU usage, while letting the GPU do the work when supported by the graphics card? What my application does is: Retrieving several video streams on the network in MJPEG and MPEG4 format. Decoding the video to device independent bitmaps and finally rendering the bitmaps to screen in either original size, upscaled or downscaled. (An optional solution is to handle the resizing manually). So the method has to be good at resizing the image, and I don't think I need any time consuming dubbel buffering, since I always draw the pictures in the same size at the same place once started. Thanks for all help!
Evil Steve
Evil Steve
Quote:
Original post by cobolt123
...and I don't think I need any time consuming dubbel buffering, since I always draw the pictures in the same size at the same place once started.
You will need double buffering. Otherwise you could be halfway through updating the image when the screen updates, causing tearing.

The best method is to use a textured quad, using Direct3D9. This should be the fastest on modern hardware, but might be slower on your Matrix card. Although you can't expect one method to work on hardware that old / unused and still get amazing performance on a GeForce 8.

You should create a dynamic texture, and update it with the video data each frame. You could also double buffer it and have two textures, and use them in a round-robbin fasion, which might be slightly faster, but will add one frame of lag.

For rendering, you should be rendering a quad either in screen space (With transformed vertices), or using an orthogonal projection matrix, so the quad isn't scaled by perspective correction. Scaling up / down will be handled automatically and you can use the GPU's texture filtering to decide how you want the image filtered (E.g. nearest neighbour, bilinear, etc). You could even use a pixel shader to do that if you wanted to (maybe).
cobolt123
cobolt123
Ok, sounds great!

However, I have no idea of how to accomplish this...

The closest I've come so far is what I've got from this article using Textured Quads:
http://www.gamedev.net/reference/articles/article1972.asp

But I got really bad performance using this. I dont know if something is badly done, or just some optimization isn't done.

Can you point me in the right direction?
Do you know any great articles or books on the subject?
Evil Steve
Evil Steve
That method looks fine to me, so long as you're not creating and destroying things every frame (like the vertex buffer), and so long as you're not updating the vertex buffer or texture every frame.

What hardware did it give you bad performance on? That should be the fastest way to render anything on current hardware.
cobolt123
cobolt123
Ok, so it's just the dynamic texture I should update for each video frame?

I will try to make a minimal application, for just rendering the bitmap with maximum performance, from the code in the article.

It gave me bad performance both on Geforce 8600 and on integrated Intel 82915. About 30 fps!

Thanks for your help so far, I'll be back when I have a clean application following your directions... Might be a while :-)
Evil Steve
Evil Steve
Yup, you just want to update the texture. If you're updating the texture every frame, make sure it's created as dynamic; specify D3DUSAGE_DYNAMIC when you call CreateTexture() - or are you creating the texture in some other way?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.