Author Topic: Vsync...well sort of  (Read 2176 times)

Reesy (OP)

  • *
  • Posts: 59
Vsync...well sort of
« on: January 24, 2010, 03:50:52 pm »
Hi,

I've been messing around with trying to improve the double buffering on the dingoo.  There's a few techniques floating about but nobody's mentioned this way so I thought I'd suggest it.  Basically it involves checking the busy status of the SLCD, if its busy performing a DMA from a previous frame buffer update then you wait until it finishes.  Then when its done you wait alittle while longer to give the LCD a chance to update.

Below is some example code which highlights the registers involved.

Code: [Select]
#include "jz4740.h"

void sal_VideoFlip(s32 vsync)
{
int x;
u16 *fb=mFbVirt[mCurrFb];

if(vsync)
{
x=0;
//Wait for any previous DMA to finish
while(REG_SLCD_STATE&SLCD_STATE_BUSY)
{
x=1;
}

//If x is 1 then previous DMA was running
if(x)
{
//It will take X milliseconds before LCD will update
//with contents of DMA, so wait awhile.
sal_Sleep(40);  //40 seems ok but 50 might be better.
}
}

memcpy(_lcd_get_frame(), fb, SCREEN_HEIGHT * SCREEN_WIDTH * sizeof(u16));
__dcache_writeback_all();
_lcd_set_frame();

}

u32 sal_TimerRead()
{
return GetTickCount();
}

void sal_Sleep(u32 delay)
{
u32 timerStart=sal_TimerRead();
timerStart+=delay;
while(sal_TimerRead()<timerStart)
{

}
}


Anyway it appears to do a good job, FPS takes a hammering though.  Without sync I can get 107 fps, with sync the code code gives 85 fps.  So still fast enough for most things. 

Later
Reesy

Nickeng

  • Guest
Re: Vsync...well sort of
« Reply #1 on: January 24, 2010, 04:47:55 pm »
Good to see your looking at the little machine!

Have loved some of your previous work

 :D

 

Post a new topic