Search code examples
texturesdirect3dtexture2dmipmapsdirect3d11

Update miplevel of a texture after its creation in D3D11


In Direct 3D 11 one can create an empty texture using ID3D11DeviceContext::CreateTexture2D and update the texel data using ID3D11DeviceContext::UpdateSubresource method, specifying the required mip level to change in the D3D11_BOX structure. While this is possible, is it possible to change the number of mip levels of a 2D texture after it's creation in Direct 3D?

I know this question begs a "Why would you do that?!" response, but due to some porting/testing requirements, I'm constrained to do so.


Solution

  • No, you can't change the number of mipmaps after the texture is created. You could only create another texture and using ID3D11DeviceContext::CopySubresourceRegion to copy the required mipmaps (though It would be better to work directly on the texture with the correct mipmap levels...).