![]() |
|
This thread is locked; no one can reply to it.
![]() ![]() |
1
2
|
fastest bliting method |
lucaz
Member #4,194
January 2004
|
what is the fast method?, 1)use iterative loops 2)memcpy 3)other. |
Steve Terry
Member #1,989
March 2002
![]() |
Direct memory line access? Depends really what depth you are running at, you can use block memory access in 8bpp, or 32-bit words at a time in 16-bpp, etc. ___________________________________ |
lucaz
Member #4,194
January 2004
|
direct line access is the first option right?. for(int x=0; x<bmp1->w ;x++) for(int y=0; y<bmp1->h ;y++) bmp1->line[x][y] = bmp2->line[x][y];
|
Steve Terry
Member #1,989
March 2002
![]() |
Right... ___________________________________ |
Chris Katko
Member #1,881
January 2002
![]() |
3) MMX. But then again, you didn't specify video/memory/system bitmaps and the destination, and also any blending. -----sig: |
lucaz
Member #4,194
January 2004
|
this is the fastest method?, ¬_¬ .... |
Steve Terry
Member #1,989
March 2002
![]() |
Depends on how much time you want to spend on your custom blitter ___________________________________ |
Krzysztof Kluczek
Member #4,191
January 2004
![]() |
Quote: for(int x=0; x<bmp1->w ;x++) Bitmap line array works as line[y][x], but remember about different bits per pixel count in different formats. Also you should blit in rows, not in columns, to make better use of cache. Using memory pointers can help a bit too. int y,*s,*d,*e; for(y=0; y<bmp1->h ;y++) { s = bmp1->line[y]; e = s + (bmp1->w*bpp+3)/4; // bpp = bytes per pixel d = bmp2->line[y]; while(s<e) *d++ = *s++; }
And MMX is completely useless in blitting unless you are doing blending in 24/32bpp, since it just gives additional math operations and none are required here. ________ |
lucaz
Member #4,194
January 2004
|
are you sure this is the fastest method?, memcpy seems more useful, it dont iterate... just take a block of memory a copy it to another- |
Steve Terry
Member #1,989
March 2002
![]() |
I'm not saying memcpy wouldn't work however that will only allow you to copy a bitmap, not manipulate it or make a custom blitter, why not just use blit instead? ___________________________________ |
ReyBrujo
Moderator
January 2001
![]() |
You can move 8 blocks of data using the MMX movq operators, instead of the one block at each time with memcpy. Problems: target machine should be MMX enabled, the addresses should be aligned, and the array should be 4x multiple. I have the code at home, will check it out later. -- |
Gnatinator
Member #2,330
May 2002
![]() |
Just blitting straight to the screen is extremley fast (I can pull thousands of frames per second). Its putting that data into memory first, then to the screen thats slow
|
ReyBrujo
Moderator
January 2001
![]() |
Faster way will always be using DRS instead of updating the whole screen. -- |
Kris Allen
Member #4,639
May 2004
![]() |
of course memcpy iterates, how else would it move more than one piece of data? - Kris |
lucaz
Member #4,194
January 2004
|
I dont know its code. but at least it just does one for(), not 2 |
Steve Terry
Member #1,989
March 2002
![]() |
What exactly are you trying to accomplish, we may find the best method for what you want to implement. ___________________________________ |
ReyBrujo
Moderator
January 2001
![]() |
Kris, There is a difference between manually iterating (using a loop and jump) and letting the processor iterate for you (like, in example, using repnz movsb):
-- |
Kris Allen
Member #4,639
May 2004
![]() |
ah cool, didnt know about that, no wonder it's so fast :B - Kris |
Krzysztof Kluczek
Member #4,191
January 2004
![]() |
I'm not sure, but I think that my method and any other which should be faster than it will be memory bus limited anyway. And of course fastest blitting method is to use HW acceleration. ________ |
decsonic
Member #4,150
December 2003
|
Wouldnt bother writing your own blitting methods unless blending is applied tho, if even then. Programmer's paranoia: Don't trust anybody's code, not even your own. |
Richard Phipps
Member #1,632
November 2001
![]() |
I really don't think it's worth spending the time trying to optimise things like this. Doing the rest of the program is more important.. |
lucaz
Member #4,194
January 2004
|
who likes to optimise blit? |
ReyBrujo
Moderator
January 2001
![]() |
Well, first optimize your game fully. You don't try optimizing printf, you try optimizing your program so that it won't use that many first. -- |
Richard Phipps
Member #1,632
November 2001
![]() |
Quote: who likes to optimise blit?
Er.. your thread title is 'fastest blitting method' (And I didn't say blit, I said things like this..) |
decsonic
Member #4,150
December 2003
|
read my sig Programmer's paranoia: Don't trust anybody's code, not even your own. |
|
1
2
|