 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
goumba
Joined: 20 Nov 2008 Posts: 13
|
Posted: Thu Mar 17, 2011 1:17 pm Post subject: Drawing vertices from the stack... issues? |
|
|
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 |
|
 |
psPea
Joined: 01 Sep 2007 Posts: 67
|
Posted: Fri Mar 18, 2011 2:06 am Post subject: |
|
|
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 |
|
 |
Criptych

Joined: 12 Sep 2009 Posts: 87
|
Posted: Fri Mar 18, 2011 7:24 am Post subject: |
|
|
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 |
|
 |
goumba
Joined: 20 Nov 2008 Posts: 13
|
Posted: Sat Mar 19, 2011 7:36 am Post subject: |
|
|
Cool guys, thanks.
And oops, I meant heap in subject, but you got it. |
|
| Back to top |
|
 |
|
|
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
|