Textures in RAM

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

Moderators: cheriff, TyRaNiD

Post Reply
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Textures in RAM

Post by Brunni »

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
Image Oldschool library for PSP - PC version released
mofig
Posts: 3
Joined: Tue Aug 23, 2005 4:55 am
Location: Oregon

Post by mofig »

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

pointer = memalign(16, size);
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

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
Image Oldschool library for PSP - PC version released
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

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
Paco
Posts: 54
Joined: Sun Oct 09, 2005 6:53 pm

Post by Paco »

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
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

Thank you very much, that's exactly what I need.
For VRAM management and compression, I'll try later.
Sorry for my bad english
Image Oldschool library for PSP - PC version released
Post Reply