Added minimum number of blocks for PTC textures. Issue #250.

This commit is contained in:
Branimir Karadžić 2015-02-01 21:38:47 -08:00
parent de81071969
commit c2e100d65d
2 changed files with 54 additions and 50 deletions

View file

@ -12,54 +12,54 @@ namespace bgfx
{
static const ImageBlockInfo s_imageBlockInfo[] =
{
{ 4, 4, 4, 8 }, // BC1
{ 8, 4, 4, 16 }, // BC2
{ 8, 4, 4, 16 }, // BC3
{ 4, 4, 4, 8 }, // BC4
{ 8, 4, 4, 16 }, // BC5
{ 8, 4, 4, 16 }, // BC6H
{ 8, 4, 4, 16 }, // BC7
{ 4, 4, 4, 8 }, // ETC1
{ 4, 4, 4, 8 }, // ETC2
{ 8, 4, 4, 16 }, // ETC2A
{ 4, 4, 4, 8 }, // ETC2A1
{ 2, 8, 4, 8 }, // PTC12
{ 4, 4, 4, 8 }, // PTC14
{ 2, 8, 4, 8 }, // PTC12A
{ 4, 4, 4, 8 }, // PTC14A
{ 2, 8, 4, 8 }, // PTC22
{ 4, 4, 4, 8 }, // PTC24
{ 0, 0, 0, 0 }, // Unknown
{ 1, 8, 1, 1 }, // R1
{ 8, 1, 1, 1 }, // R8
{ 16, 1, 1, 2 }, // R16
{ 16, 1, 1, 2 }, // R16F
{ 32, 1, 1, 4 }, // R32
{ 32, 1, 1, 4 }, // R32F
{ 16, 1, 1, 2 }, // RG8
{ 32, 1, 1, 4 }, // RG16
{ 32, 1, 1, 4 }, // RG16F
{ 64, 1, 1, 8 }, // RG32
{ 64, 1, 1, 8 }, // RG32F
{ 32, 1, 1, 4 }, // BGRA8
{ 64, 1, 1, 8 }, // RGBA16
{ 64, 1, 1, 8 }, // RGBA16F
{ 128, 1, 1, 16 }, // RGBA32
{ 128, 1, 1, 16 }, // RGBA32F
{ 16, 1, 1, 2 }, // R5G6B5
{ 16, 1, 1, 2 }, // RGBA4
{ 16, 1, 1, 2 }, // RGB5A1
{ 32, 1, 1, 4 }, // RGB10A2
{ 32, 1, 1, 4 }, // R11G11B10F
{ 0, 0, 0, 0 }, // UnknownDepth
{ 16, 1, 1, 2 }, // D16
{ 24, 1, 1, 3 }, // D24
{ 32, 1, 1, 4 }, // D24S8
{ 32, 1, 1, 4 }, // D32
{ 16, 1, 1, 2 }, // D16F
{ 24, 1, 1, 3 }, // D24F
{ 32, 1, 1, 4 }, // D32F
{ 8, 1, 1, 1 }, // D0S8
{ 4, 4, 4, 8, 1, 1 }, // BC1
{ 8, 4, 4, 16, 1, 1 }, // BC2
{ 8, 4, 4, 16, 1, 1 }, // BC3
{ 4, 4, 4, 8, 1, 1 }, // BC4
{ 8, 4, 4, 16, 1, 1 }, // BC5
{ 8, 4, 4, 16, 1, 1 }, // BC6H
{ 8, 4, 4, 16, 1, 1 }, // BC7
{ 4, 4, 4, 8, 1, 1 }, // ETC1
{ 4, 4, 4, 8, 1, 1 }, // ETC2
{ 8, 4, 4, 16, 1, 1 }, // ETC2A
{ 4, 4, 4, 8, 1, 1 }, // ETC2A1
{ 2, 8, 4, 8, 2, 2 }, // PTC12
{ 4, 4, 4, 8, 2, 2 }, // PTC14
{ 2, 8, 4, 8, 2, 2 }, // PTC12A
{ 4, 4, 4, 8, 2, 2 }, // PTC14A
{ 2, 8, 4, 8, 2, 2 }, // PTC22
{ 4, 4, 4, 8, 2, 2 }, // PTC24
{ 0, 0, 0, 0, 1, 1 }, // Unknown
{ 1, 8, 1, 1, 1, 1 }, // R1
{ 8, 1, 1, 1, 1, 1 }, // R8
{ 16, 1, 1, 2, 1, 1 }, // R16
{ 16, 1, 1, 2, 1, 1 }, // R16F
{ 32, 1, 1, 4, 1, 1 }, // R32
{ 32, 1, 1, 4, 1, 1 }, // R32F
{ 16, 1, 1, 2, 1, 1 }, // RG8
{ 32, 1, 1, 4, 1, 1 }, // RG16
{ 32, 1, 1, 4, 1, 1 }, // RG16F
{ 64, 1, 1, 8, 1, 1 }, // RG32
{ 64, 1, 1, 8, 1, 1 }, // RG32F
{ 32, 1, 1, 4, 1, 1 }, // BGRA8
{ 64, 1, 1, 8, 1, 1 }, // RGBA16
{ 64, 1, 1, 8, 1, 1 }, // RGBA16F
{ 128, 1, 1, 16, 1, 1 }, // RGBA32
{ 128, 1, 1, 16, 1, 1 }, // RGBA32F
{ 16, 1, 1, 2, 1, 1 }, // R5G6B5
{ 16, 1, 1, 2, 1, 1 }, // RGBA4
{ 16, 1, 1, 2, 1, 1 }, // RGB5A1
{ 32, 1, 1, 4, 1, 1 }, // RGB10A2
{ 32, 1, 1, 4, 1, 1 }, // R11G11B10F
{ 0, 0, 0, 0, 1, 1 }, // UnknownDepth
{ 16, 1, 1, 2, 1, 1 }, // D16
{ 24, 1, 1, 3, 1, 1 }, // D24
{ 32, 1, 1, 4, 1, 1 }, // D24S8
{ 32, 1, 1, 4, 1, 1 }, // D32
{ 16, 1, 1, 2, 1, 1 }, // D16F
{ 24, 1, 1, 3, 1, 1 }, // D24F
{ 32, 1, 1, 4, 1, 1 }, // D32F
{ 8, 1, 1, 1, 1, 1 }, // D0S8
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_imageBlockInfo) );
@ -2103,6 +2103,8 @@ namespace bgfx
const uint32_t blockSize = blockInfo.blockSize;
const uint32_t blockWidth = blockInfo.blockWidth;
const uint32_t blockHeight = blockInfo.blockHeight;
const uint32_t minBlockX = blockInfo.minBlockX;
const uint32_t minBlockY = blockInfo.minBlockY;
if (UINT32_MAX == _imageContainer.m_offset)
{
@ -2127,8 +2129,8 @@ namespace bgfx
// skip imageSize in KTX format.
offset += _imageContainer.m_ktx ? sizeof(uint32_t) : 0;
width = bx::uint32_max(blockWidth, ( (width +blockWidth -1)/blockWidth )*blockWidth);
height = bx::uint32_max(blockHeight, ( (height+blockHeight-1)/blockHeight)*blockHeight);
width = bx::uint32_max(blockWidth * minBlockX, ( (width + blockWidth - 1) / blockWidth )*blockWidth);
height = bx::uint32_max(blockHeight * minBlockY, ( (height + blockHeight - 1) / blockHeight)*blockHeight);
depth = bx::uint32_max(1, depth);
uint32_t size = width*height*depth*bpp/8;

View file

@ -43,6 +43,8 @@ namespace bgfx
uint8_t blockWidth;
uint8_t blockHeight;
uint8_t blockSize;
uint8_t minBlockX;
uint8_t minBlockY;
};
///