I got flicking result without set a hard waiting on sending GU commands.
Code: Select all
struct vertex_
{ unsigned short u, v;
float x, y, z;
};
DWORD pG[64*64];
sceGuEnable(GU_TEXTURE_2D);
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD,GU_SRC_ALPHA,GU_ONE_MINUS_SRC_ALPHA,0,0);
sceGuTexMode(GU_PSM_8888,0,0,0);
{
int x=sx;
int y=sy;
for(;x<480;x+=64)
{
GenerateTexture(pG,64,64); //pure CPU code, animates the buffer pG;
sceKernelDcacheWritebackRange(pG,64*64*4); // Patch A
sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA);
sceGuTexFilter(GU_NEAREST,GU_NEAREST);
sceGuTexImage(0,64,64,64,pG);
vertex_* vertices = (vertex_*)sceGuGetMemory(2*sizeof(vertex_));
vertex_& v1=vertices[0]; vertex_& v2=vertices[1];
v1.u = 0; v1.v = 0;
v2.u = 64; v2.v = 64;
v1.z = 0; v2.z = 0;
v1.x = x; v2.x = x+64;
v1.y = y; v2.y = y+64;
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices);
::sceKernelDelayThread(1000); // Patch B
}
}
sceGuDisable(GU_TEXTURE_2D);
sceGuDisable(GU_BLEND);
Then I guess sceGuDrawArray command is not finished while GenerateTexture modified the buffer (pG) in the next loop. So I add Patch B, call sceKernelDelayThread to wait for 1ms. This makes correct result, flicking totally disappeared. But FPS drops since I waited too much time.
So I am asking the way to sync with GPU at the end of sceGuDrawArray. I tried sceGuSync(0,0) / sceGuSync(0,1) / sceGuSync(0,2). None works.
Thanks ^_^