forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problems with sceGuSwapBuffers

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
DirkJanssen



Joined: 11 Jan 2010
Posts: 9

PostPosted: Mon Feb 15, 2010 2:20 am    Post subject: Problems with sceGuSwapBuffers Reply with quote

Hi,

I am busy with this code I am porting and when I tried to make a render function the game crashes. It comes down to the sceGuSwapBuffers function. When it is in the code it crashes the second time it hits it, or well not crashes the screen just stays black, no debugtext is shown afterwards, but it does not return to the xmb or anything. If I remove the sceGuSwapBuffers from code, this scene just keeps on updating and the game continues (although nothing is shown on screen except the debugging output that lets me know we are actually continueing)

now my question is what can be a cause for the sceGuSwapBuffers failing? the render function itself is just an empty on:
Code:
// Start our rendering
    sceGuStart(GU_DIRECT,list);

   // Clear screen
   sceGuClearColor(0xff000000);
   sceGuClearDepth(0);
   sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

   DebugOutputWait("RENDER: PSP clear screen code\n");

   // Set the ambient light (everything should be lit)
   sceGuAmbient(0xffffffff);
    DebugOutputWait("RENDER: start\n");
sceGuFinish();
   sceGuSync(0,0);
   sceDisplayWaitVblankStart();
    //sceGuSwapBuffers();
    DebugOutputWait("RENDER: End\n");


This same code is used by me in 3 other projects, working just great so I am a bit confused.

Any ideas or known issues?

other maybe important data:
- 3.xx firmware game
- happens second time it enters the render function, first times it does not fail
- 100% occurance
- no crash, just a eternal hang afai can see
Back to top
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Mon Feb 15, 2010 2:41 am    Post subject: Reply with quote

try
pspDebugScreenSetOffset(sceGuSwapBuffers());

sceGuSwapBuffers(); swaps the draw and display buffer.
Did you set them up correctly?
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
DirkJanssen



Joined: 11 Jan 2010
Posts: 9

PostPosted: Mon Feb 15, 2010 3:19 am    Post subject: Reply with quote

Tried that, didn't change anything unfortunately :(

Have I set up the buffers correctly?, I hope so I am using it succesfully on three other projects as well, though this project is 2d and not 3d as the previous projects. Any pointers on what can go wrong with the setting up of the drawbuffers?

Code:
// Initialize the Graphical Unit System
   sceGuInit();

   // We start by creating a list.
   sceGuStart(GU_DIRECT,list);

   // We create a drawbuffer of the 32 bits format.
   sceGuDrawBuffer(GU_PSM_8888,(void*)0,512);

   // We create a display buffer, 480x272 which is the resolution of the PSP screen.
   sceGuDispBuffer(480,272,(void*)0x88000,512);

   // We also create a depthbuffer.
   sceGuDepthBuffer((void*)0x110000,512);

   // We offset so we render in the middle of the 4096x4096 virtual space, leaving enough room to scissor.
   sceGuOffset(2048 - (480/2),2048 - (272/2));

   // create a viewport centered at 2048,2048 width 480 and height 272
   sceGuViewport(2048,2048,480,272);

   // We set the range of our depth tests.
   sceGuDepthRange(0xc350,0x2710);

   // enable custom scissor
   sceGuScissor(0,0,480,272);
   sceGuEnable(GU_SCISSOR_TEST);

   // We setup the depth buffer test.
   sceGuDepthFunc(GU_GEQUAL);
   sceGuEnable(GU_DEPTH_TEST);

   // We setup some additional info on rendering.
   sceGuFrontFace(GU_CW);
   sceGuShadeModel(GU_SMOOTH);
   sceGuEnable(GU_CULL_FACE);
   sceGuEnable(GU_TEXTURE_2D);
   sceGuEnable(GU_CLIP_PLANES);
   sceGuEnable(GU_LIGHTING);
   sceGuEnable(GU_BLEND);

    // Alpha blending
   sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);

    // We tell the GU that we are done.
   sceGuFinish();

   // Wait untill the list has finished.
   sceGuSync(0,0);

   // Turn on the display
   sceGuDisplay(GU_TRUE);


any ideas?
Back to top
View user's profile Send private message
DirkJanssen



Joined: 11 Jan 2010
Posts: 9

PostPosted: Mon Feb 15, 2010 5:38 am    Post subject: Reply with quote

hmmm it seems to be this functions thats causing it?

Code:
sceGuDispBuffer()


It seems that when I set the third parameter to 0 it just works fine.

Code:
dispbp  - VRAM pointer to where the display-buffer starts 


It seems odd to me that it worked previously but then I thought about it is also the first 3.xx firmware software I am making. Does anybody knows how this differs from the 1.5 firmware software? so that I can understand why it did not go as it should have?
Back to top
View user's profile Send private message
unsigned int



Joined: 13 Aug 2009
Posts: 22

PostPosted: Mon Feb 15, 2010 6:08 am    Post subject: Reply with quote

Not sure what the root problem is, but I think that change to sceGuDispBuffer() is merely circumventing it.

What you are doing is basically disabling double buffering as you give the same address to the front buffer and the back buffer (both at 0). Usually you would set one to 0 and the other to 512*272*4 (or 0x88000) as you did initially. This should work regardless of firmware version.
Back to top
View user's profile Send private message
DirkJanssen



Joined: 11 Jan 2010
Posts: 9

PostPosted: Mon Feb 15, 2010 6:59 am    Post subject: Reply with quote

hmmmm that does not sound so good, may end up with problems in the future :s maybe better to find the root problem, any ideas what it may be?
Back to top
View user's profile Send private message
jsharrad



Joined: 20 Oct 2005
Posts: 102

PostPosted: Tue Feb 16, 2010 12:33 am    Post subject: Reply with quote

If it's 2d then you shouldn't need the depth buffer.. you're using ortho right ? I don't see you setting the projection matrix anywhere
Back to top
View user's profile Send private message
unsigned int



Joined: 13 Aug 2009
Posts: 22

PostPosted: Tue Feb 16, 2010 1:16 am    Post subject: Reply with quote

I guess nothing actually gets rendered at the moment if this is the whole drawing function so there shouldn't be any need for further setups.

That being said, it might not be the best idea to clear the screen to black every frame as it makes it impossible to see if the problem lies in missing debug output (with pspDebugScreenPrintf I presume?) or in that the frame doesn't get drawn at all.

Clearing the screen to a different color on every frame would help or just drawing to front and back buffer in different color and then just switching them. Like the following code which just clears one buffer to red, the other to green and then toggles back and forth for about 10 seconds.

Code:

sceGuStart(GU_DIRECT,list);
sceGuClearColor(0xff0000ff);
sceGuClear(GU_COLOR_BUFFER_BIT);
sceGuFinish();
sceGuSync(0,0);

sceGuSwapBuffers();

sceGuStart(GU_DIRECT,list);
sceGuClearColor(0xff00ff00);
sceGuClear(GU_COLOR_BUFFER_BIT);
sceGuFinish();
sceGuSync(0,0);

int i = 0;
while (i < 100)
{
  sceKernelDelayThread(100000);
  sceDisplayWaitVblankStart();
  sceGuSwapBuffers();
  i++;
}
Back to top
View user's profile Send private message
victorprosa



Joined: 14 Jan 2009
Posts: 38

PostPosted: Tue Feb 16, 2010 1:30 pm    Post subject: Reply with quote

I don't work a lot with graphic stuff, but are you sure that 0x88000 is not being used by another process atm, or a previous process used the address and forgot to clean/memset?

Try creaning this specific adress yoursef and see what happens...
Back to top
View user's profile Send private message Send e-mail
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Wed Feb 17, 2010 8:36 am    Post subject: Reply with quote

what is the dimension of the variable list ? it is use to hold all you gu commands
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Wed Feb 17, 2010 8:01 pm    Post subject: Re: Problems with sceGuSwapBuffers Reply with quote

DirkJanssen wrote:
Hi,
When it is in the code it crashes the second time it hits it, or well not crashes the screen just stays black, no debugtext is shown afterwards

I guess your DebugOutputWait is just a wrapper for pspdebug print?
In that case your screen stays black, because the gu will overdraw your debug printing. Simple reason: debug print works synchronously, while sceGu commands work asynchronously.
If you want your text to display, only print AFTER your sceGuSync.

Quote:
but it does not return to the xmb or anything.

That just means that you have a bad (infinite) loop in your code. Inserting single lines of code may cause the kernel to suddenly be able to get out of that infinite loop in the forceful exitgame, but most of the time it won't.
_________________
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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