sceGuGetMemory and alignement

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

sceGuGetMemory and alignement

Post by willow :--) »

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. ... cc4bf6264f

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?r ... rev=0&sc=0

Are there cases when the result of that function could be not 32bits aligned ?
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

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
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Post by willow :--) »

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 :)
Post Reply