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 

sceGuGetMemory and alignement

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



Joined: 13 Jan 2007
Posts: 126

PostPosted: Wed Dec 02, 2009 6:47 pm    Post subject: sceGuGetMemory and alignement Reply with quote

short version of the question:
assuming my display list is 32bits aligned, will calls to sceGuGetMemory return 32bits aligned data ?

Long version:
I am experiencing weird screen issues described in that thread:
http://forums.ps2dev.org/viewtopic.php?t=12187

recent tests seem to show that my calls to sceGuGetMemory don't return 32bits aligned data (haven't checked that myself yet).
I *believe* I need 32 bits aligned data because I am calling sceGuDrawArray, which according to the doc requires 32bits aligned vertices:
http://psp.jim.sh/pspsdk-doc/group__GU.html#g7ee605d6909a72f989cae1cc4bf6264f

can somebody confirm if calls to sceGuGetMemory return 32bits aligned data?

I understand it probably depends on the initial alignment of my display list, which is theoretically 16bytes aligned:
static unsigned int __attribute__((aligned(16))) list[262144];

I am trying to understand if I am not doing the calls correctly, or if I am doing some awful overflow somewhere else

for reference, here is the code of sceGuGetMemory (I'm extremely bad at binary shifting which is why I'm asking...)

http://svn.ps2dev.org/filedetails.php?repname=psp&path=%2Ftrunk%2Fpspsdk%2Fsrc%2Fgu%2FsceGuGetMemory.c&rev=0&sc=0

Are there cases when the result of that function could be not 32bits aligned ?
_________________
Wagic. Play that card game against an AI on your PSP
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Fri Dec 04, 2009 7:52 pm    Post subject: Reply with quote

Short answer: No, sceGuGetMemory won't return unaligned data if your initial display list provided in sceGuStart was aligned properly.

In detail: This is made sure, by aligning the allocated size on 32bit (first 3 lines in the code, size = ((size + 3) >> 2) << 2), hence every following allocation will again start at a 32bit aligned address.
The other code just stores an "gu optimized" address scheme in the first 8 byte of the allocated buffer, hence again not breaking the 32bit alignment.

What tests exactly did you do, to come to the conclusion that the address returned isn't 32bit aligned?
_________________
<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
willow :--)



Joined: 13 Jan 2007
Posts: 126

PostPosted: Fri Dec 04, 2009 8:07 pm    Post subject: Reply with quote

I printed the result of sceGuGetMeMory (the pointer).

But it was actually correct, I was expecting it to be 32bytes aligned instead of 4bytes.

Thanks for the answer :)
_________________
Wagic. Play that card game against an AI on your PSP
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