Use block info for minimum texture block size.

This commit is contained in:
Branimir Karadžić 2014-03-01 20:08:50 -08:00
Родитель 490e31de52
Коммит c7ad5a0095
3 изменённых файлов: 17 добавлений и 9 удалений

Просмотреть файл

@ -1742,6 +1742,8 @@ namespace bgfx
uint32_t kk = 0;
const bool compressed = isCompressed(TextureFormat::Enum(m_textureFormat) );
for (uint8_t side = 0, numSides = imageContainer.m_cubeMap ? 6 : 1; side < numSides; ++side)
{
uint32_t width = textureWidth;
@ -1768,10 +1770,10 @@ namespace bgfx
srd[kk].pSysMem = temp;
srd[kk].SysMemPitch = srcpitch;
}
else if (isCompressed(TextureFormat::Enum(m_textureFormat) ) )
else if (compressed)
{
srd[kk].SysMemPitch = (mip.m_width/4)*mip.m_blockSize;
srd[kk].SysMemSlicePitch = (mip.m_height/4)*srd[kk].SysMemPitch;
srd[kk].SysMemPitch = (mip.m_width/blockInfo.blockWidth)*mip.m_blockSize;
srd[kk].SysMemSlicePitch = (mip.m_height/blockInfo.blockHeight)*srd[kk].SysMemPitch;
}
else
{

Просмотреть файл

@ -1681,7 +1681,6 @@ namespace bgfx
;
const bool compressed = isCompressed(TextureFormat::Enum(m_requestedFormat) );
const uint32_t min = compressed ? 4 : 1;
for (uint8_t side = 0, numSides = imageContainer.m_cubeMap ? 6 : 1; side < numSides; ++side)
{
@ -1696,8 +1695,8 @@ namespace bgfx
width = bx::uint32_max(1, width);
height = bx::uint32_max(1, height);
depth = bx::uint32_max(1, depth);
mipWidth = bx::uint32_max(min, mipWidth);
mipHeight = bx::uint32_max(min, mipHeight);
mipWidth = bx::uint32_max(blockInfo.blockWidth, mipWidth);
mipHeight = bx::uint32_max(blockInfo.blockHeight, mipHeight);
uint32_t mipSize = width*height*depth*bpp/8;
ImageMip mip;

Просмотреть файл

@ -1587,7 +1587,14 @@ namespace bgfx
;
const bool convert = m_textureFormat != m_requestedFormat;
const bool compressed = isCompressed(TextureFormat::Enum(m_textureFormat) );
const uint32_t min = convert && compressed ? 4 : 1;
uint32_t blockWidth = 1;
uint32_t blockHeight = 1;
if (convert && compressed)
{
blockWidth = blockInfo.blockWidth;
blockHeight = blockInfo.blockHeight;
}
BX_WARN(!swizzle && !convert, "Texture %s%s%s from %s to %s."
, swizzle ? "swizzle" : ""
@ -1611,8 +1618,8 @@ namespace bgfx
for (uint32_t lod = 0, num = numMips; lod < num; ++lod)
{
width = bx::uint32_max(min, width);
height = bx::uint32_max(min, height);
width = bx::uint32_max(blockWidth, width);
height = bx::uint32_max(blockHeight, height);
depth = bx::uint32_max(1, depth);
ImageMip mip;