OneThirty8-
I thank you for your function vo_txr_load ( it has been put to use in my project, DCMC )
However, it is still limited to width being evenly divisible by 32.
I have used this function to allow arbitrary resolution texture loading.
It is a bit application-specific, however, you should get the idea:
Code:
/* Copy a frame from RAM to VRAM, pixel by pixel. Mutex protected. */
int pvr_pixel_load( uint16 * src, struct pvr_frame *pvr ) {
int x, y;
uint16 *texture;
uint16 *image;
/* Copy the image data from RAM to VRAM, byte by byte */
image = (uint16 *)src;
texture = (uint16 *)pvr->vram_tex;
PVR_lock_mutex();
for (y=0; y<pvr->tex_height; y++)
{
for (x=0; x<pvr->tex_width; x++)
texture[x] = image[x];
texture += pvr->vram_width; image += pvr->tex_width;
}
PVR_unlock_mutex();
/* free the resources */
sq_clr(image, sizeof(image));
sq_clr(texture, sizeof(texture));
return 1;
}
I do have a related question. Does the PVR Memory HAVE to be allocated by powers of 2?
Currently, I use this to allocate PVR Memory:
Code:
/* Find and allocate the smallest possible PVR VRAM texture area */
int pvr_malloc( struct pvr_frame * pvr ) {
/* Check if Texture resolution exceeds PVR maximum */
if ( pvr->tex_width > PVR_TEX_WIDTH || pvr->tex_height > PVR_TEX_HEIGHT ) {
printf("ERROR: IMAGE Exceeds PVR maximum resolution!\n");
return 0;
}
/* Find the smallest PVR Polygon size to fit the Texture, from 8x8 to 1024x1024 */
pvr->vram_width = pvr->vram_height = 0x08;
while( pvr->vram_width<pvr->tex_width )
pvr->vram_width<<=1;
while( pvr->vram_height<pvr->tex_height )
pvr->vram_height<<=1;
/* Allocate PVR VRAM for the current Texture */
if(pvr->vram_tex) pvr_mem_free(pvr->vram_tex);
pvr->vram_tex = pvr_mem_malloc(pvr->vram_width*pvr->vram_height*2);
return 1;
}
But, is that really necessary?
It seems like a waste of vram to allocate 1024x512 for a 640x480 image.
Is it ok to allocate PVR Memory by 640x480?