I have made others tests with a rgb565 texture.
texconv.exe -i romdisk_boot/damier.png -o romdisk_boot/damier.dtex -f RGB565
I use this code to load texture in pvr :
unsigned short * image_data;
pvr_ptr_t texture_pointer;
int width, height;
FILE *image_file = NULL;
image_file = fopen("/rd/damier.dtex", "rb");
image_data = (unsigned short *)malloc(512 * 512 * 2);
width = 512;
height = 512;
texture_pointer = pvr_mem_malloc(512 * 512 * 2);
fread(&dtex_header, sizeof(dtex_header), 1, image_file);
fread(image_data, dtex_header.size, 1, image_file);
printf("Texture: %s %d %d %lu %d\n", dtex_header.magic, (int)dtex_header.width, (int)dtex_header.height, dtex_header.type, (int)dtex_header.size);
pvr_txr_load_ex(image_data, texture_pointer, width, height, PVR_TXRLOAD_16BPP);
free(image_data);
fclose(image_file);
For drawing:
pvr_poly_cxt_txr(&cxt, PVR_LIST_PT_POLY, PVR_TXRFMT_RGB565, width, height, texture_pointer, PVR_FILTER_NONE);
The header is ok : DTEX, width=512, height=512, size = 524280 but the image is bad.
I have checked the type of the header to see the format of the conversion (certainly bad way):
printf("Types : TWI %lu, STR %lu, VQ %lu\n", dtex_header.type & (1 << 26), dtex_header.type & (1 << 21), dtex_header.type & (1 << 30));
TWIDDLED = 0; STRIDE = 0; VQ_ENABLE = 0;
I also check the format and i have PVR_TXRFMT_RGB565 (1 << 27)
I tried to Stride (with -s) because texconv doesn't have twiddled function and it's works:
pvr_poly_cxt_txr(&cxt, PVR_LIST_PT_POLY, PVR_TXRFMT_RGB565, width, height, texture_pointer, PVR_FILTER_NONE);
texconv.exe -s -i romdisk_boot/damier.png -o romdisk_boot/damier.dtex -f RGB565
I have as header : 0xE000010
1110 00000000 00000000 00010000b
So I have : PVR_TXRFMT_RGB565 (1 << 27) and PVR_TXRFMT_NONTWIDDLED (1 << 26) But why this : <<25 equal the palette selector
So it's works this way. My code load the image and show it. But I can"t compress a Stride images.
When I use : texconv -c my picture doesn't works.
I tried again with
texconv.exe -c -i romdisk_boot/damier.png -o romdisk_boot/damier.dtex -f RGB565
The Hex header = 0x48000000 <=> 1001000 00000000 00000000 00000000
27 = 1 = RGB565
30 = 1 = PVR_TXRFMT_VQ_ENABLE
Doesn't works
:
pvr_poly_cxt_txr(&cxt, PVR_LIST_PT_POLY, PVR_TXRFMT_RGB565|PVR_TXRFMT_VQ_ENABLE, width, height, texture_pointer, PVR_FILTER_NONE);