|
|
@@ -1420,7 +1420,7 @@ namespace bgfx
|
|
|
UnpackFn unpack;
|
|
|
};
|
|
|
|
|
|
- static PackUnpack s_packUnpack[] =
|
|
|
+ static const PackUnpack s_packUnpack[] =
|
|
|
{
|
|
|
{ NULL, NULL }, // BC1
|
|
|
{ NULL, NULL }, // BC2
|
|
|
@@ -2498,7 +2498,7 @@ namespace bgfx
|
|
|
bool m_srgb;
|
|
|
};
|
|
|
|
|
|
- static TranslateDdsFormat s_translateDdsFourccFormat[] =
|
|
|
+ static const TranslateDdsFormat s_translateDdsFourccFormat[] =
|
|
|
{
|
|
|
{ DDS_DXT1, TextureFormat::BC1, false },
|
|
|
{ DDS_DXT2, TextureFormat::BC2, false },
|
|
|
@@ -2531,7 +2531,7 @@ namespace bgfx
|
|
|
{ DDS_A2B10G10R10, TextureFormat::RGB10A2, false },
|
|
|
};
|
|
|
|
|
|
- static TranslateDdsFormat s_translateDxgiFormat[] =
|
|
|
+ static const TranslateDdsFormat s_translateDxgiFormat[] =
|
|
|
{
|
|
|
{ DDS_FORMAT_BC1_UNORM, TextureFormat::BC1, false },
|
|
|
{ DDS_FORMAT_BC1_UNORM_SRGB, TextureFormat::BC1, true },
|
|
|
@@ -2578,7 +2578,7 @@ namespace bgfx
|
|
|
TextureFormat::Enum m_textureFormat;
|
|
|
};
|
|
|
|
|
|
- static TranslateDdsPixelFormat s_translateDdsPixelFormat[] =
|
|
|
+ static const TranslateDdsPixelFormat s_translateDdsPixelFormat[] =
|
|
|
{
|
|
|
{ 8, { 0x000000ff, 0x00000000, 0x00000000, 0x00000000 }, TextureFormat::R8 },
|
|
|
{ 16, { 0x0000ffff, 0x00000000, 0x00000000, 0x00000000 }, TextureFormat::R16U },
|
|
|
@@ -2872,7 +2872,7 @@ namespace bgfx
|
|
|
uint32_t m_type;
|
|
|
};
|
|
|
|
|
|
- static KtxFormatInfo s_translateKtxFormat[] =
|
|
|
+ static const KtxFormatInfo s_translateKtxFormat[] =
|
|
|
{
|
|
|
{ KTX_COMPRESSED_RGBA_S3TC_DXT1_EXT, KTX_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, KTX_COMPRESSED_RGBA_S3TC_DXT1_EXT, KTX_ZERO, }, // BC1
|
|
|
{ KTX_COMPRESSED_RGBA_S3TC_DXT3_EXT, KTX_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, KTX_COMPRESSED_RGBA_S3TC_DXT3_EXT, KTX_ZERO, }, // BC2
|
|
|
@@ -2944,6 +2944,18 @@ namespace bgfx
|
|
|
};
|
|
|
BX_STATIC_ASSERT(TextureFormat::UnknownDepth == BX_COUNTOF(s_translateKtxFormat) );
|
|
|
|
|
|
+ struct KtxFormatInfo2
|
|
|
+ {
|
|
|
+ uint32_t m_internalFmt;
|
|
|
+ TextureFormat::Enum m_format;
|
|
|
+ };
|
|
|
+
|
|
|
+ static const KtxFormatInfo2 s_translateKtxFormat2[] =
|
|
|
+ {
|
|
|
+ { KTX_RED, TextureFormat::R8 },
|
|
|
+ { KTX_RGB, TextureFormat::RGB8 },
|
|
|
+ };
|
|
|
+
|
|
|
bool imageParseKtx(ImageContainer& _imageContainer, bx::ReaderSeekerI* _reader)
|
|
|
{
|
|
|
uint8_t identifier[8];
|
|
|
@@ -3011,6 +3023,18 @@ namespace bgfx
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (TextureFormat::Unknown == format)
|
|
|
+ {
|
|
|
+ for (uint32_t ii = 0; ii < BX_COUNTOF(s_translateKtxFormat2); ++ii)
|
|
|
+ {
|
|
|
+ if (s_translateKtxFormat2[ii].m_internalFmt == glInternalFormat)
|
|
|
+ {
|
|
|
+ format = s_translateKtxFormat2[ii].m_format;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
_imageContainer.m_data = NULL;
|
|
|
_imageContainer.m_size = 0;
|
|
|
_imageContainer.m_offset = (uint32_t)offset;
|
|
|
@@ -3018,7 +3042,7 @@ namespace bgfx
|
|
|
_imageContainer.m_height = height;
|
|
|
_imageContainer.m_depth = depth;
|
|
|
_imageContainer.m_format = format;
|
|
|
- _imageContainer.m_numMips = uint8_t(numMips);
|
|
|
+ _imageContainer.m_numMips = uint8_t(bx::uint32_max(numMips, 1) );
|
|
|
_imageContainer.m_hasAlpha = hasAlpha;
|
|
|
_imageContainer.m_cubeMap = numFaces > 1;
|
|
|
_imageContainer.m_ktx = true;
|
|
|
@@ -3065,13 +3089,14 @@ namespace bgfx
|
|
|
#define PVR3_CHANNEL_TYPE_ANY UINT32_MAX
|
|
|
#define PVR3_CHANNEL_TYPE_FLOAT UINT32_C(12)
|
|
|
|
|
|
- static struct TranslatePvr3Format
|
|
|
+ struct TranslatePvr3Format
|
|
|
{
|
|
|
uint64_t m_format;
|
|
|
uint32_t m_channelTypeMask;
|
|
|
TextureFormat::Enum m_textureFormat;
|
|
|
+ };
|
|
|
|
|
|
- } s_translatePvr3Format[] =
|
|
|
+ static const TranslatePvr3Format s_translatePvr3Format[] =
|
|
|
{
|
|
|
{ PVR3_PVRTC1_2BPP_RGB, PVR3_CHANNEL_TYPE_ANY, TextureFormat::PTC12 },
|
|
|
{ PVR3_PVRTC1_2BPP_RGBA, PVR3_CHANNEL_TYPE_ANY, TextureFormat::PTC12A },
|