Flickering with backbuffer usage[SOLVED]

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
anmabagima
Posts: 87
Joined: Thu Oct 01, 2009 8:43 pm

Flickering with backbuffer usage[SOLVED]

Post by anmabagima »

Hi there,

i'm started the first PSP development in drawing some animated pixels to the PSP screen. I'm using draw buffer and backbuffer. After everything was drawn to the backbuffer I flip them. It's nothing really using GU and very simple. However, if I do NOT use sceDisplayWaitVblankStart(); the screen flicker, other wise it not flicker, but is very slow....

Here is my code snipped:

Code: Select all

#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)
#define PIXELSIZE	4				//in short
#define	LINESIZE	512				//in short
#define	FRAMESIZE	(SCR_HEIGHT * LINESIZE * PIXELSIZE)

Color* pg_vramtop = (Color *)(0x40000000 | 0x04000000);
bool pg_drawframe = true;


Color *pgGetVramAddr()
{
	if (pg_drawframe)
		return pg_vramtop + FRAMESIZE / sizeof(Color);
	else
		return pg_vramtop;
}

void setPixel(int x,int y, Color color)
{
     Color* vram = pgGetVramAddr();
     vram[x + LINESIZE*y] = color;
}

int main(int argc, char* argv[])
{
	Color* vram;
	 // setup of common call backs
   setupCallbacks();
   // run the application
   while(running()){

	  vram = pgGetVramAddr();
                  // clear the drawbuffer
	  memset(vram, 0, FRAMESIZE);
//create some fancy pixels using setPixel()                  
                 Render();
                sceDisplaySetFrameBuf(vram, LINESIZE, PSP_DISPLAY_PIXEL_FORMAT_8888, PSP_DISPLAY_SETBUF_NEXTFRAME );
		pg_drawframe = pg_drawframe?false:true;
                //do not wait for Vblank start
                //sceDisplayWaitVblankStart();
	}
.....

The reoson why I do not want to use "sceDisplayWaitVblankStart();": It completely slows down everything ...

Any Ideas what may be wrong here ? Sorry that I'm just posting the code snippets, but I guess the kind of setting the pixels using some random method does not matter, doesn't it ?

Thanks in advance...
AnMaBaGiMa
Last edited by anmabagima on Thu Oct 08, 2009 4:38 pm, edited 1 time in total.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Your code snippet doesn't show the double-buffering you claim to be doing, just single buffering. Please post enough of the code that we can see how your program REALLY handles the buffers.
anmabagima
Posts: 87
Joined: Thu Oct 01, 2009 8:43 pm

SOLVED

Post by anmabagima »

Hi,

I've solved it in using the Parameter PSP_DISPLAY_SETBUF_IMMEDIATE instead of PSP_DISPLAY_SETBUF_NEXTFRAME within
sceDisplaySetFrameBuf.

However, the double buffering is there:

Code: Select all

Color *pgGetVramAddr() 
{ 
   if (pg_drawframe) 
      return pg_vramtop + FRAMESIZE / sizeof(Color); 
   else 
      return pg_vramtop; 
} 
points dependent of the flag "pg_drawframe" to two different addresses (buffers). The sceDisplaySetFrameBuf switches between these buffers...

Thanks.

Regards,
AnMaBaGiMa
Post Reply