| View previous topic :: View next topic |
| Author |
Message |
webjeff
Joined: 05 May 2005 Posts: 66
|
Posted: Sun Jul 24, 2005 7:48 am Post subject: Compiler Issue ( I think ) |
|
|
Ready for some weirdness.
I have a cube, it renders fine when I have these lines:
pspDebugScreenSetXY(0,j*3);
pspDebugScreenPrintf("verts:x %f",verts->Get(j)->x);
pspDebugScreenSetXY(0,j*3+1);
pspDebugScreenPrintf("verts:y %f",verts->Get(j)->y);
pspDebugScreenSetXY(0,j*3+2);
pspDebugScreenPrintf("verts:z %f",verts->Get(j)->z);
for debugging, then I took those lines out and theres a peice of the box missing, like i dont have all the geometry, so I put the debug lines back in, and my box renders fine... WEIRD!
So I talked with someone in the IRC room saying it maybe the compiler messing up. I added -o0.... didn't work. Any other ideas?
My vertices are floats, thats all im rendering, im passing in this:
sceGuDrawArray(GU_TRIANGLES,GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,&m_PSPBuffer[0]);
Any ideas??? |
|
| Back to top |
|
 |
ReKleSS

Joined: 18 Jun 2005 Posts: 73 Location: Melbourne, Australia
|
Posted: Sun Jul 24, 2005 10:28 am Post subject: |
|
|
I'm guessing it has something to do with the cache. Either make sure you're writing to uncached memory (address | 0x40000000) or do a sceKernelDcacheWriteBackAll() before you run the drawing code and see what happens.
-ReK |
|
| Back to top |
|
 |
webjeff
Joined: 05 May 2005 Posts: 66
|
Posted: Sun Jul 24, 2005 10:51 am Post subject: |
|
|
Rekless,
how do I check to see if I'm writing to uncached memory??
Thanks
Jeff |
|
| Back to top |
|
 |
webjeff
Joined: 05 May 2005 Posts: 66
|
Posted: Sun Jul 24, 2005 10:59 am Post subject: |
|
|
The address of my verticies buffer is 0x8a3f278.... looks ok.. I think
Jeff |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Sun Jul 24, 2005 11:13 am Post subject: |
|
|
0x8a3f278 is a cached address. 0x48a3f278 is an uncached address. They both reference the same memory location, except the latter bypasses the CPU cache. Since the GU isn't aware of the CPUs cache, you need to use uncached addresses to make sure it can see the last thing you wrote. Either that or you have to flush the CPUs data cache before calling GU.
Since the data cache is quite small, it's possible that the debug instructions are causing your data to be written out of the cache in time for the GU to see them.
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
webjeff
Joined: 05 May 2005 Posts: 66
|
Posted: Sun Jul 24, 2005 11:54 am Post subject: |
|
|
so how do I use the uncached address. I just say new something and it gives me a new address.... I can try to flush the cpu data cache, but you wound't happen to know a function that does that would ya? I understand the concept of whats going on, just not the details on how to work around it.
Thanks again guys
Jeff. |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Sun Jul 24, 2005 12:15 pm Post subject: |
|
|
| Code: |
THING vertex[10];
THING *uncachedvertexptr = (THING *)(((unsigned int)vertex)|0x40000000);
|
Always access vertex through unchachedvertexptr
or call
| Code: |
sceKernelDcacheWriteBackAll();
|
before starting the GU.
Try not to mix the two. If you access though uncached addresses and then call WriteBack you can clobber the uncached writes.
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
webjeff
Joined: 05 May 2005 Posts: 66
|
Posted: Sun Jul 24, 2005 2:23 pm Post subject: |
|
|
Jim,
Thanks for the help, but what about stuff on the heap? If I wanted to do:
vertex* vert = new vertex();
how do I make sure thats using the right address?
Thanks
Jeff. |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
|
| Back to top |
|
 |
|