Using Mipmap with DXT textures...

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Shazz
Posts: 244
Joined: Tue Aug 31, 2004 11:42 pm
Location: Somewhere over the rainbow
Contact:

Using Mipmap with DXT textures...

Post by Shazz »

Hello folks...

I wonder how the GU should be set to handle a DXT texture with mipmap.
Using a 1 level (no mipmap) DXT texture works, using normal 8888 textures at different size and setttign the mipmap levels works but I did not find how to set the different mipmaps textuers for 1 DXT..

What I mean is :
To handle normal 8888 texture and mipmap you can do :

Code: Select all

sceGuTexMode(GU_PSM_8888,2,0,0); // 2 levels mipmap
sceGuTexImage(0,128,128,128,texture128);
sceGuTexImage(1,64,64,64,texture64);
sceGuTexImage(2,32,32,32,texture32);
sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGB);

sceGuTexFilter(GU_LINEAR_MIPMAP_LINEAR,GU_LINEAR_MIPMAP_LINEAR);
but for one DXT texture as you don't know the textureS offsetS, how can you define the mipmaps ???

I tried this but it doesn't work well (looks like bad offset + texture size), only the biggest (0) texture is ok

Code: Select all

// dxt5 mipmapped, DXT5 texture is 512*512 and 3 level mipmap

sceGuTexFilter(GU_LINEAR_MIPMAP_LINEAR,GU_LINEAR_MIPMAP_LINEAR);
sceGuTexMode(10, 3, 0, 0);
sceGuTexImage(3, TEXTURE_WIDTH/8, TEXTURE_HEIGHT/8, TEXTURE_WIDTH/8, textureDXT5);        
sceGuTexImage(2, TEXTURE_WIDTH/4, TEXTURE_HEIGHT/4, TEXTURE_WIDTH/4,textureDXT5);
sceGuTexImage(1, TEXTURE_WIDTH/2, TEXTURE_HEIGHT/2, TEXTURE_WIDTH/2, textureDXT5;
sceGuTexImage(0, TEXTURE_WIDTH, TEXTURE_HEIGHT, TEXTURE_WIDTH, textureDXT5); 
should you have 4 different DXT textures for each mipmap LOD ?

(Note : I use PSPTex to generate the psptex DXT5 file)
- TiTAN Art Division -
http://www.titandemo.org
hitchhikr
Posts: 83
Joined: Sat Feb 04, 2006 3:33 pm

Post by hitchhikr »

I updated the plugin, now it generates constants in the .h files containing the locations of the different mipmaps within the file (x_MIPMAPS_OFFSETx)

http://perso.orange.fr/franck.charlet/PSPTex.zip

Tell me if it helps.
User avatar
Shazz
Posts: 244
Joined: Tue Aug 31, 2004 11:42 pm
Location: Somewhere over the rainbow
Contact:

Post by Shazz »

Yep it helps a lot :D
It works now :D

by the way... is there a loss of quality implied with DXT1 textures ?
DXT5 textures are perfect but DXT1 is totally ugly (visible pixel blocks) whatever the LOD level
Last edited by Shazz on Mon Sep 25, 2006 9:39 pm, edited 1 time in total.
- TiTAN Art Division -
http://www.titandemo.org
hitchhikr
Posts: 83
Joined: Sat Feb 04, 2006 3:33 pm

Post by hitchhikr »

I noticed the dxt1 problem, it may be a bug in the compressor (or in the gpu (?)), i'll see what i can do.
User avatar
Shazz
Posts: 244
Joined: Tue Aug 31, 2004 11:42 pm
Location: Somewhere over the rainbow
Contact:

Post by Shazz »

I just tested NVDIA DXT tools (http://udn.epicgames.com/pub/Content/Te ... _TOOLS.zip) and I generated the same texture in DXT1c and DXT5 and there is no "easy-seeing' quality difference...

So I guess there is a bug somewhere... I hope that's in your compressor :D

By the way, again, I did some perf tests to compare DXT5 and Palette (T8) textures as for 5 levels mipmap, a DXT5 texture or a T8 texture takes the same memory space :
T8: 8bits indexed color
vs.
DXT5 : 4bits (color) + 4bits (alpha)

and as a result it seems that performance are equal for small textures (mipmap 16x16, 32x32) but when bigger textures are used (higher LOD) (128x128, 256x256) the performance decrease quickly when using DXT 5

So I bet using T8 textures is better to save (V)RAM if you don't need an alpha layer....
- TiTAN Art Division -
http://www.titandemo.org
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

If you don't need alpha you might as well use DXT1, since DXT5 ~= DXT1 + alpha.

Although it's likely that T8 will still be faster since the DXT format occupy a lot of texture cache (it's decompressed into the cache) and thus cause more cache thrashing.
http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip Free texture converter for PSP with source. More to come.
User avatar
Shazz
Posts: 244
Joined: Tue Aug 31, 2004 11:42 pm
Location: Somewhere over the rainbow
Contact:

Post by Shazz »

ector,

Using DXT1 was the goal (at least so save VRAM) but seems there si a bug somewhere in PSPTex or GU as the result is totally ugly.... which shouldn't be the case.

I succeeded in tuning the stuff by manually setting the lod slope to have better performance using DXT5 textures but definitively using T8 is better....

thanks for the DXT technical cache explanation ;)
- TiTAN Art Division -
http://www.titandemo.org
Post Reply