Mipmap generation not working with compressed texture?

Started by
8 comments, last by ET3D 15 years, 11 months ago
Hi there! Is there a specific reason why mipmaps aren't generated when I upload the texture as DXT compressed data? (It works fine with uncompressed RGBA...) Maybe DirectX does not support mipmap generation for compressed textures?
Advertisement
Mipmaps aren't generated at upload time, they're generated at load time. How are you loading your texture? If you're loading a .dds file using the D3DX functions, it's entirely possible that the file only has one mip level in it...
Quote:Original post by Evil Steve
Mipmaps aren't generated at upload time, they're generated at load time. How are you loading your texture? If you're loading a .dds file using the D3DX functions, it's entirely possible that the file only has one mip level in it...


Nope, I'm creating the texture with CreateTexture, with D3DFMT_DXT1 and D3DUSAGE_AUTOGENMIPMAP. Then move the raw data to the memory location.

It's working fine, the texture appears, but apparently it has no mipmaps.

I also tried GenerateMipSubLevels(), but no result.


And the same code works fine for uncompressed RGBA images. So i don't get what I could be doing wrong.

Generally mipmap generation is working for compressed textures?
Use IDirect3D9::CheckDeviceFormat() with D3DUSAGE_AUTOGENMIPMAP to check whether automatic MIP map generation for DXT textures is supported by your driver.
Quote:Original post by Porthos
Use IDirect3D9::CheckDeviceFormat() with D3DUSAGE_AUTOGENMIPMAP to check whether automatic MIP map generation for DXT textures is supported by your driver.


Well it fails... but it also fails for RGBA, maybe I'm passing the wrong parameters?

HRESULT result=dxObj->CheckDeviceFormat(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,D3DFMT_A8R8G8B8,D3DUSAGE_AUTOGENMIPMAP,D3DRTYPE_TEXTURE,D3DFMT_DXT1/*D3DFMT_A8R8G8B8*/);


It doesn't return D3DOK_NOAUTOGEN either.
Oops, I used D3DFMT_A8R8G8B8 for the render target, I changed it to D3DFMT_X8R8G8B8 and CheckDeviceFormat seems to be working fine.


Unfortunately for D3DFMT_DXT1 it returns D3DOK_NOAUTOGEN which means it doesn't support mipmap generation for compressed textures. (only for uncompressed)


How is this possible???




Here are my specs:

OS : Windows XP Professional x64 Edition (5.2, Build 3790) Service Pack 1
Video card : NVIDIA GeForce6600
Processor : AMD Athlon(tm) 64 Processor 3000+, ~1.8GHz
DirectX Version : DirectX 9.0c (4.09.0000.0904)
You can do it manually. Just call D3DXLoadSurfaceFromMemory() for each surface level of your texture. That should enable you to resize and compress the texture to DXT on any card.
Quote:Original post by jsg007
Unfortunately for D3DFMT_DXT1 it returns D3DOK_NOAUTOGEN which means it doesn't support mipmap generation for compressed textures. (only for uncompressed)


How is this possible???
Because your drivers don't support it. Support for most things varies depends on driver support, which is why you need to query support for things before using them.
Do you have the latest drivers for your card?

If the driver doesn't support it, you'll have to lock the surface and do it yourself. Also, are you using the Debug Runtimes? This is exactly the sort of thing that I'd expect them to flag...
Thanks for your replies.

I tried to run the code today on a completely different system (with a Radeon card), the same thing happens, so either i'm doing something wrong, or automatic mipmap generation for compressed textures is generally not supported.


Has anyone tried to create a texture with CreateTexture, with D3DFMT_DXT1 and D3DUSAGE_AUTOGENMIPMAP? Are mipmaps generated in this case?


Alternatively what other options do I have to generate mipmaps from DXT data?


Not supported on my Radeon HD 3870. I figure since auto generation for a compressed texture requires realtime compression, that's unlikely to be a common feature. I wonder if there's any hardware that supports it.

This topic is closed to new replies.

Advertisement