Jump to content

  • Log In with Google      Sign In   
  • Create Account


IDirect3DBaseTexture9::GenerateMipSubLevels not working


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Tispe   Members   -  Reputation: 982

Like
0Likes
Like

Posted 03 November 2012 - 11:11 AM

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?

Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 7644

Like
0Likes
Like

Posted 03 November 2012 - 12:34 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 Tispe   Members   -  Reputation: 982

Like
0Likes
Like

Posted 03 November 2012 - 02:30 PM

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?

#4 Tispe   Members   -  Reputation: 982

Like
0Likes
Like

Posted 03 November 2012 - 04:56 PM

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!


#5 Hodgman   Moderators   -  Reputation: 28649

Like
0Likes
Like

Posted 03 November 2012 - 05:32 PM

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.

#6 Tispe   Members   -  Reputation: 982

Like
0Likes
Like

Posted 04 November 2012 - 03:05 AM

Thank you.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS