PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

speeding up rotation

Hi,

I've being playing around with rotations of 90,180 and 270 degrees to rotate the display.

I have come up with the following two methods. On my spv c600 I get 180fps while clearing the screen and printing fps in 90degrees. In 180 degrees I get 190fps doing the same. Is there anyway to speed this up? I have run out of ideas and it makes me wonder as GAPIDRAW state they can rotate the screen with no performance loss. I also read about cache misses but I dont fully understand this and wondered if this is being effected by them?

90 degree
Code:
USHORT* p = (USHORT*)m_rfbi.pFramePointer;

int wid = m_windowHeight;
int hi = m_windowWidth;

int start1 = wid;
int loopX = 0;

USHORT* buffer = m_screenBuffer;

//Rotate one pixel at a time
for (int x=wid;x!=0;--x)
{
for(int y=hi;y!=0;--y)
{
p[start1-loopX]=*(buffer);

start1+=wid;
++buffer;
}
start1=wid;
++loopX;
}


180 degree
Code:
int end = m_windowArea;
USHORT* buffer = m_screenBuffer;
USHORT* p = (USHORT*)m_rfbi.pFramePointer;
p+=end;

for(int i=m_windowHeight; i !=0; --i)
{
for(int j=m_windowWidth; j !=0; --j)
{
*(p) = *(buffer);
++buffer;
--p;
}
}


Any help appreciated
thanks
Mike
gapidraw doesn't have a performance loss because all of their source images are pre-rotated, so when you blit it to the screen buffer it is simply a copy, rather than having to jump around in memory. this method has one serious negative aspect, you have to code all of your routines 4 different ways.

a much better way to do it, IMO, is to do it as you are, only rotate on the final blit, BUT, a huge performance increase can be gained by doing a few things:

1) read sequentially from the source image and copy non-sequentially to the display, this is much faster because reads are cached but writes are not, using this method you can obtion near pre-rotated speeds.
2) use forward caching by preloading lines into the cache, there are several other posts about this, although i never obtained any noticable results with it.
3) use memcpy when possible, it will be optimized on some devices.

on a side note when something is running at 190fps on a mobile phone, there is little need to make it faster before your game is done, because i highly doubt it will be a bottleneck compared to other things you will be doing in your game.
thanks for the reply.

ahh that explains why they get no performance loss? doesnt this mean they have to store the image in memory in all its pre-rotated forms which wastes memory?

When you say (im guessin u mean read in order 0,1,2 pixels etc when you say read sequentially)
1) read sequentially from the source image and copy non-sequentially to the display, this is much faster because reads are cached but writes are not, using this method you can obtion near pre-rotated speeds.

This is the method I have used to rotate? I lost 6fps when doing it the opposite way in the 180, wondered why that was :).

As you say 190fps is pretty good but this still loses around 100fps from the rotate. I have seen mobile games run at around 10fps so you would have to do alot to kill performance as you say.