diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index dcb835f5..2d70dbb8 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -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 { diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index 43dcaea9..83269878 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -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; diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 00c14657..fd871081 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -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;