Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3D11Texture DDS mipmap truncation issue #3290

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
D3D11Texture DDS mipmap truncation issue
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.
  • Loading branch information
CsabaX committed Feb 20, 2025
commit cba3e352abea68df274c2fcf8ce10d14fd7932f2
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
Loading