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 

Textures in RAM

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



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sun Dec 04, 2005 3:22 am    Post subject: Textures in RAM Reply with quote

Hello
I'm doing a simple 2D lib (using only hardware routines), but I need some more informations. In fact, I would like to let the choice to the user if he want to put a texture in RAM or in VRAM.
- With RAM I have to call malloc. The problem is that malloc will return an address which is not 16 byte aligned, like required by sceGuTexImage, and the image sometimes won't be drawn correctly. A bad thing to do is to allocate texSize + 16 and align this address by hand.
- Also, when a heap compression will occur, this will be problematic as my textures are stored by their address. What should I do instead?
- Heap compression will also be an issue if I'll implement a VRAM memory manager.
So if someone has experience about that (VRAM manager, handles in RAM, etc.), I would appreciate any help.
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
mofig



Joined: 23 Aug 2005
Posts: 3
Location: Oregon

PostPosted: Sun Dec 04, 2005 7:33 am    Post subject: Reply with quote

you can use memalign to allocate memory in ram that is 16 byte aligned

pointer = memalign(16, size);
Back to top
View user's profile Send private message AIM Address
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sun Dec 04, 2005 7:20 pm    Post subject: Reply with quote

Thank you, I'll try it.
In fact, I just realize I'm a real n00b, but I can't find this information on Internet. Is memory allocated with malloc locked?
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sun Dec 04, 2005 9:11 pm    Post subject: Reply with quote

Locked? It doesn't move or change address after you allocate it, if that's what you mean. It only goes away when you call free() or your app exits.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Paco



Joined: 09 Oct 2005
Posts: 54

PostPosted: Mon Dec 05, 2005 7:44 am    Post subject: Reply with quote

There's no automatic heap compression in any of the memory managers supplied with the pspsdk, so pointers becoming invalid behind your back is not an issue. If you create your own memory manager for vram and implement heap compression, you probably want your vram resource class (which stores the pointer to vram) to be involved in the compression process. Or you can use double indirection (pointer to the pointer to vram).

Just some ideas to think about.
_________________
Paco
Back to top
View user's profile Send private message
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Sat Dec 10, 2005 9:31 am    Post subject: Reply with quote

Thank you very much, that's exactly what I need.
For VRAM management and compression, I'll try later.
_________________
Sorry for my bad english
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
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