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 

Alignment woes?

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



Joined: 19 Sep 2005
Posts: 75

PostPosted: Sat Mar 11, 2006 2:14 pm    Post subject: Alignment woes? Reply with quote

For quite a while now I have been battling what I beleive to be alignment woes. everything would be running just fine and then I would add a few lines of code and then I would get mostly black screen with just the first few pixel lines of display showing through.

I tried to track this down and thought that maybe I had an alignment issue so I put in a
Code:
sprintf(xdebug_string, "%0X", (unsigned int)(&acme8pt_start) );
(this is outside the main loop and only gets called once at startup)
on my init code to see if maybe some of my common objects data was getting loaded to a address that was not a multiple of 16 bytes. Funny thing was that the sprintf cleaned up the flashing black screen.

Then I would add more code and it would come back. For the past couple of weeks I have been in the habbit adding/removing lines of sprintf so that everything runs ok like this
Code:
sprintf(xdebug_string, "%0X", (unsigned int)(&acme8pt_start) );
sprintf(xdebug_string, "%0X", (unsigned int)(&acme8pt_start) );
sprintf(xdebug_string, "%0X", (unsigned int)(&acme8pt_start) );
//sprintf(xdebug_string, "%0X", (unsigned int)(&acme8pt_start) );

I do this until the flashing black screen goes away. I have used this for at least a couple of weeks and it may take a couple of tries to get the right number of sprintf's in there but it always works.

For the past two days I have been trimming my vertex format down to optimize my game, but have now run into a situation where no amount of sprintf's make the flashing black screen go away.

Has anyone experienced anything like this? It seems like an alignment issue to me but I have spent the past two days making sure everything I can is aligned and I just can't get this to go away this time.

I realize it's a long shot but I am getting desperate...
Back to top
View user's profile Send private message
weak



Joined: 13 Jan 2005
Posts: 114
Location: Vienna, Austria

PostPosted: Mon Mar 13, 2006 10:20 pm    Post subject: Reply with quote

first of all, use memalign to get correct alignment.

and maybe you have some caching issues too. take a look at the howto
Back to top
View user's profile Send private message
ipsp



Joined: 01 Feb 2006
Posts: 26
Location: Sydney

PostPosted: Tue Mar 14, 2006 12:53 pm    Post subject: Memory Bug Reply with quote

From experience, this type of behaviour is generally caused by memory overrun, and less commonly memory leak.

Generally speaking if you have a piece of code writing into memory that it was not asigned then you may experience bad results but not always. For me this is generally a String related problem but often occurs when you are memcpy() structures of different sizes.

In 'C' a simple solution to memory alignment problem is to NOT let 'C' automatically added fillers to structures, as all integers are boundary bound i.e. if an integer does not sit on a boundary 'C' automatically inserts a filler until the integer does sit on a boundary.

The reason the 'printf()' might work is they might force memory to be alocated differently internally and hence no bad results will be seen. But I agree with the first person that responded use 'memalign()', but note this may still not fix your problem.
Back to top
View user's profile Send private message
starman2049



Joined: 19 Sep 2005
Posts: 75

PostPosted: Thu Mar 16, 2006 7:43 pm    Post subject: Reply with quote

I double checked all my memory allocation is using memalign(128, xxx) to be safe and make sure that xxx is a mulitple of 64 as well so as to avoid cache writeback issues.

Still haven't found the problem, it can be fixed by adding junk padding code (such as sprintf's above).

Visually, the top 20-30 pixel lines get drawn and then black for the rest of the screen (actually BGCOLOR, not black)
Back to top
View user's profile Send private message
weak



Joined: 13 Jan 2005
Posts: 114
Location: Vienna, Austria

PostPosted: Thu Mar 16, 2006 11:06 pm    Post subject: Reply with quote

texture and clut data has to be 16 byte aligned
Back to top
View user's profile Send private message
starman2049



Joined: 19 Sep 2005
Posts: 75

PostPosted: Fri Mar 17, 2006 7:49 am    Post subject: Reply with quote

Double-checked that and they are all ok.

It looks like the draw buffer is getting cleared around 15 pixel lines into the draw. From what little I can see the scene appears to have rendered ok though.

If I remove the sceDisplayWaitVblankStart() then the 15 pixel band moves scrolls down the screen.

As luck would have it I can always get it to go away by adding 0-4 lines of those sprintfs, it just really slows me down and I wish I could get it to go away.
Back to top
View user's profile Send private message
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Fri Mar 17, 2006 9:12 am    Post subject: Reply with quote

How do you make sure you do not start rendering on the displaybuffer? It sure sounds like the next displaylist has started executing while the buffer is still displaying. Remember that when you use GU_DIRECT mode in sceGuStart(), the list will start executing right away as you fill it. I remember in another post we talked about double-buffering the displaylists, which adds complexity to which list is running and which screen is being displayed. What happens if you sleep until the list has finished executing?

If this is your problem, you could use a signal-interrupt (sceGuSignal()) to make sure you don't start rendering too early. Also, rolling your own sceGuSwapBuffers() that waits for the vertical blank before swapping the buffer (look at the parameters for the sceDisplaySetFrameBuf()-call) could also help. You still need to synchronize your rendering, just not synchronize your CPU to the currently executing list.
_________________
GE Dominator
Back to top
View user's profile Send private message
starman2049



Joined: 19 Sep 2005
Posts: 75

PostPosted: Thu Mar 30, 2006 12:34 pm    Post subject: Reply with quote

Still trying to figure this out, and trying to think of how I can put your suggestions to good use. I don't see how adding some junk lines of code would make this go away if the problem is as deep as you suggest.

It sure feels like an alignment issue. I tried to generate a map file using:
Code:
-Map,main.map
but that did not work for me. Is there a way to generate a map file with the psp toolchain?
Back to top
View user's profile Send private message
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