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 

Compiler Issue ( I think )

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



Joined: 05 May 2005
Posts: 66

PostPosted: Sun Jul 24, 2005 7:48 am    Post subject: Compiler Issue ( I think ) Reply with quote

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
View user's profile Send private message
ReKleSS



Joined: 18 Jun 2005
Posts: 73
Location: Melbourne, Australia

PostPosted: Sun Jul 24, 2005 10:28 am    Post subject: Reply with quote

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
View user's profile Send private message
webjeff



Joined: 05 May 2005
Posts: 66

PostPosted: Sun Jul 24, 2005 10:51 am    Post subject: Reply with quote

Rekless,

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

Thanks
Jeff
Back to top
View user's profile Send private message
webjeff



Joined: 05 May 2005
Posts: 66

PostPosted: Sun Jul 24, 2005 10:59 am    Post subject: Reply with quote

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

Jeff
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sun Jul 24, 2005 11:13 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
webjeff



Joined: 05 May 2005
Posts: 66

PostPosted: Sun Jul 24, 2005 11:54 am    Post subject: Reply with quote

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
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sun Jul 24, 2005 12:15 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
webjeff



Joined: 05 May 2005
Posts: 66

PostPosted: Sun Jul 24, 2005 2:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sun Jul 24, 2005 3:49 pm    Post subject: Reply with quote

You still just OR the address with 0x40000000.
Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
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