Compiler Issue ( I think )

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

Moderators: cheriff, TyRaNiD

Post Reply
webjeff
Posts: 66
Joined: Thu May 05, 2005 2:51 am

Compiler Issue ( I think )

Post by webjeff »

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???
User avatar
ReKleSS
Posts: 73
Joined: Sat Jun 18, 2005 12:57 pm
Location: Melbourne, Australia

Post by ReKleSS »

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
webjeff
Posts: 66
Joined: Thu May 05, 2005 2:51 am

Post by webjeff »

Rekless,

how do I check to see if I'm writing to uncached memory??

Thanks
Jeff
webjeff
Posts: 66
Joined: Thu May 05, 2005 2:51 am

Post by webjeff »

The address of my verticies buffer is 0x8a3f278.... looks ok.. I think

Jeff
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

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
webjeff
Posts: 66
Joined: Thu May 05, 2005 2:51 am

Post by webjeff »

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.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

Code: Select all

THING vertex[10];
THING *uncachedvertexptr = (THING *)(((unsigned int)vertex)|0x40000000);
Always access vertex through unchachedvertexptr
or call

Code: Select all

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
webjeff
Posts: 66
Joined: Thu May 05, 2005 2:51 am

Post by webjeff »

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.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

You still just OR the address with 0x40000000.
Jim
Post Reply