Skip to content

Commit 57fc7df

Browse files
CsabaStupakCsabaX
andauthored
D3D11: Texture - fix DDS mipmap truncation issue (#3290)
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]>
1 parent 17c5e21 commit 57fc7df

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

RenderSystems/Direct3D11/src/OgreD3D11Texture.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@ namespace Ogre
244244
// determine total number of mipmaps including main one (d3d11 convention)
245245
UINT numMips = (mNumMipmaps == MIP_UNLIMITED || (1U << mNumMipmaps) > std::max(mSrcWidth, mSrcHeight)) ? 0 : mNumMipmaps + 1;
246246
if(D3D11Mappings::_isBinaryCompressedFormat(mD3DFormat) && numMips > 1)
247-
numMips = std::max(1U, numMips - 2);
247+
{
248+
// Compressed texture can't have mipmaps beyond size 4x4, so remove the last two (2x2, 1x1)
249+
UINT nMaxMips = getMaxMipmaps() + 1;
250+
numMips = std::max(1U, std::min(numMips, nMaxMips - 2));
251+
}
248252

249253
D3D11_TEXTURE2D_DESC desc;
250254
desc.Width = static_cast<UINT>(mSrcWidth);

0 commit comments

Comments
 (0)