How to do fast ASM blt? -no asm xp

Started by
24 comments, last by BeanDog 23 years, 10 months ago
You know, I am always reading things like, "Yeah, BltFast is the best unless you do the fast ASM blit." and such. Well, HOW DO YOU DO A FAST ASM BLIT? I''ve tried and it is REALLY slow! (Believe me, you don''t want to see my code) Please help me out, I need a really fast full-screen regular blit, no effects or anything. ~BenDilts( void );
Advertisement
Seriously, what''s the point? What could you possibly be trying to do that BltFast isn''t fast enough? It''s fast enough for 99% of game developers.
quote:Original post by BeanDog

You know, I am always reading things like, "Yeah, BltFast is the best unless you do the fast ASM blit." and such. Well, HOW DO YOU DO A FAST ASM BLIT? I''ve tried and it is REALLY slow! (Believe me, you don''t want to see my code)

Please help me out, I need a really fast full-screen regular blit, no effects or anything.

~BenDilts( void );





Maybe there are other parts of your game that you could optimise.
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
ASM Blits means that you copy pixels to the screen 32-bits at a time using only ASM registers - no references to memory except to where the bitmap is located and the video memory address (0xA0000000). I''m guessing you''re copying pixels to the screen ONE at a time, using something like REP MOVSB. You can copy four pixels at a time using REP MOVSD, for the B is for Byte, and the D is for Double Word. Processors these days can do both in the same amount of time, therefore quadrupling blitting speed.

-Ender Wiggin
I''ve found the mmx instructions to be slightly faster (copy 8 bytes instead of 4). It depends a bit on the processor though. Also in DirectX your video memory address may not be 0xA0000000. You can only access the primary surface''s memory directly if you''re in exclusive mode (as far as I know). Otherwise you''ll have to blt to a client surface or some other secondary surface in video memory. If you need to get a pointer for something in video memory use Lock.
For a good time hit Alt-F4! Go ahead try it, all the cool people are doing it.
quote:
"Yeah, BltFast is the best unless you do the fast ASM blit."


BeanDog,

Nothing is faster than a hardware blt (Bltfast), and asm IS software, no
matter how you slice it.
Most cards don't support blting from system to video. So if the surface you want to copy from is in system memory it's faster to use asm.

Edited by - blue-lightning on June 17, 2000 10:47:59 AM
For a good time hit Alt-F4! Go ahead try it, all the cool people are doing it.
Anonymous Poster : BltFast doesn''t always work in hardware btw, and certainly won''t be in hardware if, as possibly mentioned, the surface the guys wants to copy is in system memory. And furthermore, there''s nothing directx does that you can''t do with ASM anyway, even bltfast.

My personal advice:
Use bltfast if you are copying hardware->hardware memory.
Use ASM if you are copying system->hardware memory. Preferably with the MMX instructions (still they aren''t that much faster because of the 32-bit bus or something like that)
Bltfast is damn slow for RAM->VRAM and RAM->RAM.
I''ve made some benchmarking here. Blitting 128x128 image, 1000 times RAM->RAM. Look the results:
BltFast : 270 ms
My MMX blit routine : 32 ms

The best thing to do is, write your own asm blitters, blit all sprites to an RAM back surface. After all done, you blit this back surface to the Ddraw primary surface located at VRAM.
John Carmack used this approach on Quake.

This topic is closed to new replies.

Advertisement