• Advertisement
Sign in to follow this  

IDirect3DBaseTexture9::GenerateMipSubLevels not working

This topic is 1906 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

Some time ago I had a topic going about GenerateMipSubLevels not working on DTXn textures. This is because hardware does not support mipmap generation on compressed textures.

Well I now have the texture in D3DFMT_A8R8G8B8 format and still this function refuses to do the job!

In PIX I can tell that if I specify 5 mipmap levels only the top surface will have the image, and rest are just black as before. Getting CAPS on my nvidia GTX690 it will say that it supports mipmap generation on D3DFMT_A8R8G8B8 targets.


hr = pGraphicsDevice->GetDevice()->CreateTexture(Width, Height, 5, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &pTex, NULL);
if( hr!=D3D_OK ) return NULL;
LPDIRECT3DSURFACE9 pSurface = NULL;
if (SUCCEEDED (pTex->GetSurfaceLevel(0, &pSurface)))
{
RECT rc;
SetRect(&rc, 0, 0, Width, Height);
hr = D3DXLoadSurfaceFromMemory(pSurface, NULL, NULL, pTextureData, (D3DFORMAT)Format, Pitch, NULL, &rc, D3DX_FILTER_NONE, 0);
}
if(pSurface) pSurface->Release();
pTex->GenerateMipSubLevels(); //won't work


Setting usage to D3DUSAGE_AUTOGENMIPMAP in CreateTexture makes all surfaces black when the Levels parameter is 2 or higher.
If Levels in CreateTexture is set to zero with D3DUSAGE_AUTOGENMIPMAP only one mipmap level is present (PIX), in conflic with documentation.

Anyone have a hunch of what might be going on?

Share this post


Link to post
Share on other sites
Advertisement
You should set levels 0 in your CreateTexture call to specify a full mipmap chain, use D3DUSAGE_AUTOGENMIPMAP, then call GenerateMipSubLevels. Note that this usage is documented as making all levels beyond the first inaccessible to your application - the driver is now taking over management of those.

Alternatively look at D3DXFilterTexture an another option for generating mipmap sublevels.

Share this post


Link to post
Share on other sites
So... even though PIX is telling me only one surface is present, on the driver level the full chain is present. So PIX can't see all the lower levels?

Share this post


Link to post
Share on other sites
Hi again, still no solution to my first post. However the D3DXFilterTexture works! But does this function do it in hardware or software?

If someone can offer a solution or explanation to why GenerateMipSubLevels does not work in the first post please give me your best shot.


if(FAILED(pGraphicsDevice->GetDevice()->CreateTexture(Width, Height, 5, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &pTex, NULL)))
{
return NULL;
}
LPDIRECT3DSURFACE9 pSurface = NULL;
if (SUCCEEDED (pTex->GetSurfaceLevel(0, &pSurface)))
{
RECT rc;
SetRect(&rc, 0, 0, Width, Height);
hr = D3DXLoadSurfaceFromMemory(pSurface, NULL, NULL, pTextureData, (D3DFORMAT)Format, Pitch, NULL, &rc, D3DX_FILTER_NONE, 0);
}
if(pSurface) pSurface->Release();
//pTex->SetAutoGenFilterType(D3DTEXF_LINEAR);
//pTex->GenerateMipSubLevels();
D3DXFilterTexture(pTex, NULL, 0, D3DX_DEFAULT); //Works!

Share this post


Link to post
Share on other sites

So... even though PIX is telling me only one surface is present, on the driver level the full chain is present. So PIX can't see all the lower levels?
Yes. This stumped me too, so I wrote a test shader that used tex2Dlod to display the mip levels of a texture, and found that the auto-generated levels were present, theyre just hidden from PIX for some reason.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement