DX11 auto mips generation for render targets

Started by
1 comment, last by MickeyMouse 13 years ago
How do I get automatic mipmap generation to work with render targets in DX11?

Here's what I'm doing (very standard "render to texture" scenario):

(1) Create 2D texture with automatic mipmap generation enabled (D3D11_TEXTURE2D_DESC::MipLevels set to 0).

(2) Create associated render target and shader resource views.

D3D11_RENDER_TARGET_VIEW_DESC::Texture2D::MipSlice set to 0
D3D11_SHADER_RESOURCE_VIEW_DESC::Texture2D::MostDetailedMip set to 0
D3D11_SHADER_RESOURCE_VIEW_DESC::Texture2D::MipLevels set to -1

(3) Bind my texture's render target view and draw to it.

(4) Bind back buffer render target view and draw to it sampling from my texture's shader resource view.

The problem is: non-top mip levels haven't been auto-generated; the top level is fine.
Should I not expect auto mips generation to work in that case and instead use ID3D11DeviceContext::GenerateMips() ?

Thanks!
Maciej Sawitus
my blog | my games
Advertisement
MipLevels UINT The maximum number of mipmap levels in the texture. See the remarks in D3D11_TEX1D_SRV. Use 1 for a multisampled texture; or 0 to generate a full set of subtextures.

So, a setting of zero should generate a full set of mipmaps on texture creation. After you change the texture, you must call GenerateMips each time you want the mipmap chain made
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.

So, a setting of zero should generate a full set of mipmaps on texture creation. After you change the texture, you must call GenerateMips each time you want the mipmap chain made


Hmm, but then why do I not have to call GenerateMips() every time I change the top mip level using UpdateSubresource()? In this case mip tail generation is automatically triggered.
Is it some kind of API inconsistency or am I not fully understanding things?
Maciej Sawitus
my blog | my games

This topic is closed to new replies.

Advertisement