 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
e_boris
Joined: 19 May 2007 Posts: 25
|
Posted: Fri Oct 05, 2007 2:07 am Post subject: Problem with dynamic texturing |
|
|
Hi, buddy, has any one tried dynamic texture generated (by CPU not by GU) texture.
I got flicking result without set a hard waiting on sending GU commands.
| Code: | 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);
|
At first I guess the generated texture was just in cache, so I add Patch A (call sceKernelDcacheWritebackRange). This makes a little bit better, but flicking remains at some region.
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 ^_^ |
|
| Back to top |
|
 |
Smong
Joined: 04 Sep 2007 Posts: 82
|
Posted: Fri Oct 05, 2007 2:57 am Post subject: |
|
|
These are just guesses looking at the docs, have you tried sceGuTexSync() "Synchronize rendering pipeline with image upload"? It's used in the sdk gu samples "copy" and "spharm". There's also sceGuTexFlush() "Flush texture page-cache" but no sdk samples seem to be using that. _________________ (+[__]%) |
|
| Back to top |
|
 |
e_boris
Joined: 19 May 2007 Posts: 25
|
Posted: Fri Oct 05, 2007 6:04 am Post subject: |
|
|
Thanks Smong, but sceGuTexSync does not work. I checked the doc, it is used to sync with sceGuCopyImage.
In my code, the major issue is how to keep waiting until the execution of sceGuDrawArray finish. I suppose sceGuSync is the right method, but it is not, or I made some mistake in using it. |
|
| Back to top |
|
 |
Smong
Joined: 04 Sep 2007 Posts: 82
|
Posted: Fri Oct 05, 2007 6:50 am Post subject: |
|
|
Have you tried it without a "dynamic texture generated by CPU"? If not do you have something like this at the end of your graphics code?
| Code: | sceGuFinish();
sceGuSync(0, 0);
sceDisplayWaitVblankStart(); |
_________________ (+[__]%) |
|
| Back to top |
|
 |
e_boris
Joined: 19 May 2007 Posts: 25
|
Posted: Fri Oct 05, 2007 4:29 pm Post subject: |
|
|
Everything is ok, If I move GenerateTexture outside the loop.
I have these lines of sceGuFinish and etc. I just get ride of them for simple |
|
| Back to top |
|
 |
e_boris
Joined: 19 May 2007 Posts: 25
|
Posted: Fri Oct 05, 2007 7:08 pm Post subject: |
|
|
| I just tried sceGuTexFlush, the problem remains. :~( |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|