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 

Drawing vertices from the stack... issues?

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



Joined: 20 Nov 2008
Posts: 13

PostPosted: Thu Mar 17, 2011 1:17 pm    Post subject: Drawing vertices from the stack... issues? Reply with quote

Hey guys,

I'm new to GU programming, and having an issue with drawing vertices from the stack. Using the following struct,

struct Vertex
{
uint32_t color;
float x, y, z;
};

If I allocate the storage on the stack, as such:

Vertex stack_cube[36] =
... fill with data to draw a cube with colored faces...
sceGumDrawArray(GU_TRIANGLES, GU_VERTEX_32BITF | GU_COLOR_8888 | GU_TRANSFORM_3D, 36, 0, stack_cube);

the cube is drawn perfectly.

If I allocate the storage on the heap,

Vertex *heap_cube = new Vertex[36];
... fill with data to draw a cube with colored faces...
sceGumDrawArray(GU_TRIANGLES, GU_VERTEX_32BITF | GU_COLOR_8888 | GU_TRANSFORM_3D, 36, 0, heap_cube);

the faces of the cube are all messed up, and some don't even draw.

I've used a loop to compare the values between the two sets of data, and they always match.

Is there something I'm missing when using data from the heap to draw geometry?

TIA.
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 67

PostPosted: Fri Mar 18, 2011 2:06 am    Post subject: Reply with quote

That's a cache issue, you'll need to write back the data cache OR just use sceGuGetMemory to allocate memory for your vertices.
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Criptych



Joined: 12 Sep 2009
Posts: 87

PostPosted: Fri Mar 18, 2011 7:24 am    Post subject: Reply with quote

To clarify: you're telling the GPU that the vertex data is in memory, when actually it might not have gotten there yet. You need to either flush the cache (so the data really is where you say it is), or have the GU library allocate for you (so the data doesn't get cached in the first place).
_________________
PSP-2001 // CFW 6.60 ME-1.2 and GCLite // Genesis Competition Entry
"So, we meet again: for the first time, for the last time." —Spaceballs
Back to top
View user's profile Send private message
goumba



Joined: 20 Nov 2008
Posts: 13

PostPosted: Sat Mar 19, 2011 7:36 am    Post subject: Reply with quote

Cool guys, thanks.

And oops, I meant heap in subject, but you got it.
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