else
{
uint32_t curWidth = baseWidth;
- // translate mip width from pixels to blocks for block compressed formats
- // @note hAlign is already in blocks for compressed formats so no need to convert
- if (info.isBC) curWidth /= info.bcWidth;
+ // @note hAlign is already in blocks for compressed formats so upconvert
+ // so that we have the desired alignment post-divide.
+ if (info.isBC)
+ {
+ hAlign *= info.bcWidth;
+ }
offset = GFX_ALIGN(curWidth, hAlign);
for (uint32_t l = 1; l < lod; ++l)
offset += curWidth;
}
- if (info.isSubsampled)
+ if (info.isSubsampled || info.isBC)
{
offset /= info.bcWidth;
}
else
{
uint32_t curWidth = baseWidth;
- // convert mip width from pixels to blocks for block compressed formats
- // @note hAlign is already in blocks for compressed formats so no need to convert
- if (info.isBC) curWidth /= info.bcWidth;
+ // @note hAlign is already in blocks for compressed formats so upconvert
+ // so that we have the desired alignment post-divide.
+ if (info.isBC)
+ {
+ hAlign *= info.bcWidth;
+ }
curWidth = std::max<uint32_t>(curWidth >> 1, 1U);
curWidth = GFX_ALIGN(curWidth, hAlign);
- if (info.isSubsampled)
+ if (info.isSubsampled || info.isBC)
{
curWidth /= info.bcWidth;
}
offset = 0;
uint32_t mipHeight = baseHeight;
- // translate mip height from pixels to blocks for block compressed formats
- // @note VAlign is already in blocks for compressed formats so no need to convert
- if (info.isBC) mipHeight /= info.bcHeight;
+ // @note vAlign is already in blocks for compressed formats so upconvert
+ // so that we have the desired alignment post-divide.
+ if (info.isBC)
+ {
+ vAlign *= info.bcHeight;
+ }
for (uint32_t l = 1; l <= lod; ++l)
{
offset += ((l != 2) ? alignedMipHeight : 0);
mipHeight = std::max<uint32_t>(mipHeight >> 1, 1U);
}
+
+ if (info.isBC)
+ {
+ offset /= info.bcHeight;
+ }
}
}