Skip to main content
gamedev.net
🔒 Locked

BltFast Question

Started by EnochDagor Nov 7, 2000 at 5:30 PM 9 replies 600+ views
Original Post
EnochDagor
EnochDagor
Which is faster? Blitting a RECT that is 640x480 once OR Blitting a RECT that is 32x24 20 times? Explanations would be nice too. E.D.
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
cheez_keeper
cheez_keeper
If u are using the BltFast routine it is much faster to do the one large blt than the several small ones. The main reason for this is that every time u call Blt or BltFast DirectX has to Lock the surface to copy memory to it, then Unlock it when it is finished. Both Lock() and Unlock() have a huge overhead that = lower framerates in your game if u call them too much.

Best Alternative: write your own bltter so you contol when and how often surfaces are Lock()ed and Unlock()ed. This is why u dont see many people using Blt or BltFast. Also, there are many fine tutorials on this site on writing custom blitters and alpha blitters.

Brett Lynnes
cheez_keeper@hotmail.com
Brett Lynnescheez_keeper@hotmail.com
pUnkOuter
pUnkOuter
someone correct me if i''m wrong (i haven''t really researched it), but i believe the reason people generally use Blt() and BltFast() is because it takes advantage of the hardware blitter (hardware acceleration) where available...

and i''m pretty certain that a single blit will be faster than multiple, smaller blits...

------------------------
IUnknown *pUnkOuter

"Try the best you can
try the best you can
the best you can is good enough"
--Radiohead
------------------------IUnknown *pUnkOuter"Try the best you cantry the best you canthe best you can is good enough" --Radiohead
cheez_keeper
cheez_keeper
All a Blt contains is a routine to move memory from one location to another... not much the HLE can help with there... still much faster to run your own.

Brett Lynnes
cheez_keeper@hotmail.com

VOTE!!!
Brett Lynnescheez_keeper@hotmail.com
bogdanontanu
bogdanontanu
Yeah if video memory to video memory Blt is used and if hardware accel (today most cards have it) then this is the fastest...
(single 640x480 Blt)

However its possible to be faster to do multiple Blts if source is much the same (like tilesets on a tile based map) and take advantage of some form of cache (more offten in system memory but video also)

BltFast is not so "fast" if hardware accel is used, its only faster in system memory an with no hardware accel... but here u can usually do better using ASM code

Bogdan

obysoft
furby100
furby100
Doing smaller blits is always slower than one big blit. Why? Because:
a) Without color-keying there are larger areas of contigious memory which are faster to move to because it can be done using rep stosd or MMX instructions for a larger part of the picture than the smaller blits
b) With color-keying, you will be able to read and write to contigious memory, thereby utilizing the cache better, and so there will be an increase in performance.



Please state the nature of the debugging emergency.


sharewaregames.20m.com

furby100
furby100
BltFast is just as fast as Blt with hardware acceleration. BltFast does not perform clipping and cannot be used on a surface with a clipper attached. BltFast does have the added advantage of no possibility of accidentally stretching or shrinking the image you are Bltting, and you can Blit without color-keying. In HEL mode, BltFast is faster than Blt, since it can skip certain things like clipping and color-keying if neccessary.



Please state the nature of the debugging emergency.


sharewaregames.20m.com

EnochDagor
EnochDagor
Wow, great response! Please keep it coming. This is more knowledge then I was expecting!

For the post about BltFast Locking and unlocking each time it is called... this scares me.

On a recent article here on gamedev, it stated to simply do two For Loops...

    
for(Y = 0; Y<TilesOnScreen; Y++)
{
for(X = 0; X<TilesOnScreenX; X++)
{
BltFast(etc....);
}
}


To get my Terrain on the screen... so are you saying that BltFast just won''t cut it? If I was to create my own Blt functions what would be the disadvantages as opposed to Blt and BltFast? Would I simply use a memcpy from the source surface to the dest surface? What would happen to color keying?

E.D.
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
Tooon
Tooon
It all dependes on where you store your tile-surface, in SYSRAM or in VIDEOMEM.
Most videocards today have HW accelerated blits, if BOTH surfaces are in Videomemory.
Blits from Sysram to Vidmem will always be performed by the HEL (HW Emulation Layer).

So, what I would have done is to either store all tiles in a vidmem surface and blit the way you do now. Or, store them in a Sysram surface, and write by own asm blitter routine.

/ Tooon
Prosper/LOADED
Prosper/LOADED
I made some test and ...

quote:
Original post by EnochDagor

Blitting a RECT that is 640x480 once




Is much faster for VIDEO->VIDEO memory blit.

quote:


Blitting a RECT that is 32x24 20 times?

Explanations would be nice too.




Is a bit slower for SYSTEM->VIDEO and SYSTEM->SYSTEM blits.

By the way, i have a P3-500 with a GeForce 32 Mo. But i think the results are wuite the same on any configuration.

Topic Locked

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

Sign in to reply to this topic.