Skip to content

Commit

Permalink
TextureLoader: align mip level row stride to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Nov 24, 2023
1 parent c1fec85 commit b50f47c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions TextureLoader/src/TextureLoaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,18 @@ void TextureLoaderImpl::LoadFromImage(const TextureLoadInfo& TexLoadInfo)

for (Uint32 m = 1; m < m_TexDesc.MipLevels; ++m)
{
auto MipLevelProps = GetMipLevelProperties(m_TexDesc, m);
m_Mips[m].resize(StaticCast<size_t>(MipLevelProps.MipSize));
const MipLevelProperties MipLevelProps = GetMipLevelProperties(m_TexDesc, m);

Uint64 MipSize = MipLevelProps.MipSize;
Uint64 RowSize = MipLevelProps.RowSize;
if ((RowSize % 4) != 0)
{
RowSize = AlignUp(RowSize, Uint64{4});
MipSize = RowSize * MipLevelProps.LogicalHeight;
}
m_Mips[m].resize(StaticCast<size_t>(MipSize));
m_SubResources[m].pData = m_Mips[m].data();
m_SubResources[m].Stride = MipLevelProps.RowSize;
m_SubResources[m].Stride = RowSize;

if (TexLoadInfo.GenerateMips)
{
Expand Down

0 comments on commit b50f47c

Please sign in to comment.