i need to do a 90 degrees rotated blit of a camera image (so i have no possibility to generate it rotated).
blitting non-rotating is very fast but it seems when blitting rotating due to cache misses (i have no other explanation) thigs slow down very much: from 11 fps to 7fps.
i currently do the following:
BUFFERTYPE::PIXELTYPE is unsigned short (16-bits) and the PITCHX and PITCHY are set to walk correctly across the destination buffer. the source is in 32-bits.
it should be pretty clear what this code does.
the question is: is there a way to get it a lot faster (removing the cache misses)?
interestingly the code is even slower if i try to reverse the run (let the destination pointer do the small steps and write to 2 pixels at once into 32bit memory addresses).
any suggestions?
thanks,
DANIEL
blitting non-rotating is very fast but it seems when blitting rotating due to cache misses (i have no other explanation) thigs slow down very much: from 11 fps to 7fps.
i currently do the following:
- Code:
dst += BUFFERTYPE::OFFSET;
const unsigned char *srcI = (const unsigned int*)src;
register a;
h = backBuffer.getHeight();
while(h--)
{
BUFFERTYPE::PIXELTYPE *dst2 = dst;
const unsigned int *srcI2 = srcI;
w = backBuffer.getWidth();
while(w--)
{
a = *srcI2;
*dst2 = ((a>>8)&0xF800) | ((a>>5)&0x07E0) | ((a>>3)&0x1F);
srcI2++;
dst2 += BUFFERTYPE::PITCHX;
}
srcI += BUFFERTYPE::WIDTH;
dst += BUFFERTYPE::PITCHY;
}
BUFFERTYPE::PIXELTYPE is unsigned short (16-bits) and the PITCHX and PITCHY are set to walk correctly across the destination buffer. the source is in 32-bits.
it should be pretty clear what this code does.
the question is: is there a way to get it a lot faster (removing the cache misses)?
interestingly the code is even slower if i try to reverse the run (let the destination pointer do the small steps and write to 2 pixels at once into 32bit memory addresses).
any suggestions?
thanks,
DANIEL