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 

Proper use of sceGuTex* when copying to VRAM?

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



Joined: 31 Dec 2005
Posts: 125
Location: Edinburgh, UK

PostPosted: Thu Jan 12, 2006 1:35 am    Post subject: Proper use of sceGuTex* when copying to VRAM? Reply with quote

Hello,

I've been trying without much success for the last few days to use the limited VRAM space available as a LRU (least recently used) cache for textures stored in system memory.

In case anyone is wondering why, it's because I'm continuing my port of Quake to the PSP by replacing Quake's software rasterizer subsystem with a GU version.

I'm starting off small, by just porting the blitting system. Quake caches textures and images in system memory for me. Unfortunately, I can't use sceGuCopyImage to copy them to VRAM, since they are not aligned or powers of two in size. Because the source data isn't aligned, I have to use memcpy to manually copy the bytes over.

I manage VRAM for myself using a Pool which allocates VRAM in chunks which are multiples of 1K in size.

When I need to use a new texture, I allocate as many chunks as required from VRAM, them memcpy the bytes over. Obviously I could be dirtying memory which is in the texture cache (what is it, 16K?) so I should call sceGuTexFlush.

But when do I call it? I've tried calling it before and after copying the bytes, but I get texture corruption, which I presume means a dirty cache.

And since I'm using memcpy instead of sceGuCopyImage, do I need to call sceGuTexSync?

I could really do with some help, it's driving me crazy! ;-)

Pete
Back to top
View user's profile Send private message Visit poster's website
jsgf



Joined: 12 Jul 2005
Posts: 254

PostPosted: Thu Jan 12, 2006 6:08 am    Post subject: Reply with quote

Are you using cached or uncached addresses for VRAM? If you're using cached addresses, are you flushing the Dcache before trying to use the texture?
Back to top
View user's profile Send private message Visit poster's website
PeterM



Joined: 31 Dec 2005
Posts: 125
Location: Edinburgh, UK

PostPosted: Thu Jan 12, 2006 6:12 am    Post subject: Reply with quote

I think I fixed the problem - it wasn't related to my use of sceGuTexFlush.

Quake was moving the image memory around, causing me to be using memory which it had stomped over... Oops.

Now I make my own copy of the textures, which seems to have solved the problem.

I was using cached addresses (initially getting my VRAM base pointer from sceGeEdramGetAddr()) but I was using sceKernelDcacheWritebackRange() to flush the relevant part of the Dcache after uploading the texture.

Thanks anyway for your help,

Pete
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