Hi,
VFPU load/store instructions seem to support only 16-byte-aligned accesses (similiar to Altivec and SSE). The psplibc already uses this alignment as default for malloc()/realloc() and friends, can we also make this the default for the newlib (here this is right now only done when built for PPC/Altivec)? Then unaligned buffers passed from application to libraries (as textures, matrix pointers, vertex buffers, etc) are less likely, also will realloc work on aligned buffers.
what do you think?
newlib would require to define MALLOC_ALIGNMENT=16 in newlib/libc/include/sys/config.h, the required patch would be trivial.
newlib/psplibc memory alignment for VFPU
newlib/psplibc memory alignment for VFPU
Last edited by holger on Mon Oct 03, 2005 6:37 am, edited 1 time in total.
I agree with Holger, a sacrifice of an average of 4 bytes per memory allocation is definitely worth it for the convenience.
http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip Free texture converter for PSP with source. More to come.
- you can't realloc memalign()'ed chunksweak wrote:why not just use memalign?
- user programs allocate their textures, LUTs, vertex buffers etc usually without knowing the required alignment, so the buffers can neither get directly passed to the DMA engine nor the GE, the graphics library has to touch every vertex or texel, even if it is already in optimal format and the GE could theoretically directly access it (if it would be properly aligned).
- memalign is tagged as obsolete since unix98.
it's undefined by the spec. Everything can happen, also there is no guarantee that the new, reallocated buffer still meets some alignment requirements. (if it becomes reallocated at all - usually memalign is implemented on top of malloc and relies on the fact that free in most implementations does not needs to point on the start address of a memory chunk).