Skip to content

Commit

Permalink
D3D11: Texture - fix DDS mipmap truncation issue (#3290)
Browse files Browse the repository at this point in the history
Compressed texture can't have mipmaps beyond size 4x4, so remove the last two (2x2, 1x1). However the caller can have images which does not have the full mipmaps chain or already removed the last two mipmaps. The code unconditionally removed the last mipmaps which can be useful.

Co-authored-by: stupak <[email protected]>
  • Loading branch information
CsabaStupak and CsabaX authored Feb 20, 2025
1 parent 17c5e21 commit 57fc7df
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion RenderSystems/Direct3D11/src/OgreD3D11Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ namespace Ogre
// determine total number of mipmaps including main one (d3d11 convention)
UINT numMips = (mNumMipmaps == MIP_UNLIMITED || (1U << mNumMipmaps) > std::max(mSrcWidth, mSrcHeight)) ? 0 : mNumMipmaps + 1;
if(D3D11Mappings::_isBinaryCompressedFormat(mD3DFormat) && numMips > 1)
numMips = std::max(1U, numMips - 2);
{
// Compressed texture can't have mipmaps beyond size 4x4, so remove the last two (2x2, 1x1)
UINT nMaxMips = getMaxMipmaps() + 1;
numMips = std::max(1U, std::min(numMips, nMaxMips - 2));
}

D3D11_TEXTURE2D_DESC desc;
desc.Width = static_cast<UINT>(mSrcWidth);
Expand Down

0 comments on commit 57fc7df

Please sign in to comment.