Jump to content

  • Log In with Google      Sign In   
  • Create Account


Mipmaps without D3DX11FilterTexture


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
4 replies to this topic

#1 NiteLordz   Members   -  Reputation: 369

Like
0Likes
Like

Posted 26 February 2013 - 03:24 PM

I am using DX10/11 and i am trying to create mipmaps, without using d3dx as i am cross platform and would like to keep it clean of the D3DX library.

 

As a test, i used D3DX11FilterTexture to create the mipmaps, and verify everything works as expected.  And it does.  Now i want to replace this method with, what suggestions or alternatives are there.

 

Currently i load in my textures into an image file, so i have the raw image data. 

 

Thanks much


Code makes the man

Sponsor:

#2 Seabolt   Members   -  Reputation: 615

Like
0Likes
Like

Posted 26 February 2013 - 03:45 PM

This function should do it for you. http://msdn.microsoft.com/en-us/library/windows/desktop/ff476426(v=vs.85).aspx


Perception is when one imagination clashes with another

#3 mhagain   Crossbones+   -  Reputation: 7436

Like
0Likes
Like

Posted 26 February 2013 - 04:07 PM

Note that with GenerateMips:

 

If the base resource was not created with D3D11_BIND_RENDER_TARGET and D3D11_RESOURCE_MISC_GENERATE_MIPS, the call to GenerateMips has no effect.

 

(From the MSDN doc link).

 

If you want to create mipmaps without FilterTexture, you should create an array of D3D11_SUBRESOURCE_DATA, one array element for each miplevel, set pSysMem to the data for each miplevel, set SysMemPitch to the pitch for each miplevel, and (assuming Texture2D) SysMemSlicePitch to 0.  Then pass that array as the second param to your CreateTexture2D call.  There's nothing special you need to do to indicate the end of the array; CreateTexture2D is clever enough to realize when it hits the 1x1 sized level (or the MipLevels member of your D3D11_TEXTURE2D_DESC) that there are no more.

 

Since you have the raw image data, that becomes the pSysMem for your miplevel 0.  For other miplevels you filter it down to the correct size for the level, then use the filtered down data as the pSysMem for those levels.

 

That means having to allocate and subsequently free a chunk of data for each level, so having a memory manager that lets you release it all in one fell swoop is a useful, but by no means essential, thing to have.

 

This method has the bonus that it will work just fine even with immutable textures (it is in fact the only method that will work with immutable textures).


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.


#4 Seabolt   Members   -  Reputation: 615

Like
0Likes
Like

Posted 26 February 2013 - 04:28 PM

Oh man, that's embarrassing, I'm sorry about that. I just remembered a function that did that, and didn't bother to read it. Sorry again.


Perception is when one imagination clashes with another

#5 Adam_42   Crossbones+   -  Reputation: 2361

Like
0Likes
Like

Posted 26 February 2013 - 06:12 PM

My recommendation would be to work with DDS files. The file format is documented so it's not limited to one platform, and it lets you store all the mip maps in the file. Loading them is almost certainly quicker than creating them at runtime, especially if you use a decent quality filter to generate them. It will also handle formats like DXT1 that can cut down video memory usage by a factor of 8.

 

NVidia have a free plugin for Photoshop and some other tools which handle dds files.






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