Question

I am doing a lot of blitting (write many 2d game prototypes in recent months), and I am searching for the fastest blit possible Is there maybe anything faster than SetDIBitsToDevice or StretchDIBits ? Those are about 1-5 ms as far as I remember for usual window sizes so they are not terribly fast (hard or impossible to write something faster than 200 fps) though it is normal, I think, cause RAM itself is not so fast.

Was it helpful?

Solution

It depends.

The bottleneck for most machines will be pushing from system memory to graphics memory.

In many cases, there won't be any effective difference between a SetDIBitsToDevice and a BitBlt, but, in some cases, there can be. If you're running in a low color mode (e.g., 256), then it'll be faster to push 1-byte indexes than 32-bpp pixel data and have it remapped on the card. (Whether the remapping is handled in the graphics adapter or the system will depend on the driver--I assume.)

I believe the safest thing you can do is BitBlt from a device-dependent (compatible) bitmap. I don't think this will ever be worse than SetDIBitsToDevice, but it may often be a tie.

I would expect (but haven't tested) that any stretching blit may be slightly more expensive than a straight blit, unless the extra pixels are synthesized on the GPU.

You might consider some of the newer APIs, like Direct2D, which are designed to work closer with the hardware rather than present an idealistic software model.

Whichever solution you choose, I'd be prepared for big performance differences between machines.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top