| View previous topic :: View next topic |
| Author |
Message |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Sun Dec 04, 2005 3:22 am Post subject: Textures in RAM |
|
|
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 |
|
 |
mofig
Joined: 23 Aug 2005 Posts: 3 Location: Oregon
|
Posted: Sun Dec 04, 2005 7:33 am Post subject: |
|
|
you can use memalign to allocate memory in ram that is 16 byte aligned
pointer = memalign(16, size); |
|
| Back to top |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Sun Dec 04, 2005 7:20 pm Post subject: |
|
|
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 |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Sun Dec 04, 2005 9:11 pm Post subject: |
|
|
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 |
|
 |
Paco
Joined: 09 Oct 2005 Posts: 54
|
Posted: Mon Dec 05, 2005 7:44 am Post subject: |
|
|
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 |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Sat Dec 10, 2005 9:31 am Post subject: |
|
|
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 |
|
 |
|