Merge pull request #10559 from jherico/fix_compressed_ktx_loading

Fix compressed KTX loading
This commit is contained in:
Brad Davis 2017-05-26 12:46:11 -07:00 committed by GitHub
commit 952d3629ec
2 changed files with 4 additions and 3 deletions

View file

@ -212,10 +212,11 @@ namespace khronos {
template <uint32_t ALIGNMENT> template <uint32_t ALIGNMENT>
inline uint32_t evalAlignedCompressedBlockCount(uint32_t value) { inline uint32_t evalAlignedCompressedBlockCount(uint32_t value) {
// FIXME add static assert that ALIGNMENT is a power of 2 // FIXME add static assert that ALIGNMENT is a power of 2
return (value + (ALIGNMENT - 1) / ALIGNMENT); static uint32_t ALIGNMENT_REMAINDER = ALIGNMENT - 1;
return (value + ALIGNMENT_REMAINDER) / ALIGNMENT;
} }
inline uint8_t evalBlockAlignemnt(InternalFormat format, uint32_t value) { inline uint32_t evalCompressedBlockCount(InternalFormat format, uint32_t value) {
switch (format) { switch (format) {
case InternalFormat::COMPRESSED_SRGB_S3TC_DXT1_EXT: // BC1 case InternalFormat::COMPRESSED_SRGB_S3TC_DXT1_EXT: // BC1
case InternalFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: // BC1A case InternalFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: // BC1A

View file

@ -30,7 +30,7 @@ uint32_t Header::evalMaxDimension() const {
uint32_t Header::evalPixelOrBlockDimension(uint32_t pixelDimension) const { uint32_t Header::evalPixelOrBlockDimension(uint32_t pixelDimension) const {
if (isCompressed()) { if (isCompressed()) {
return khronos::gl::texture::evalBlockAlignemnt(getGLInternaFormat(), pixelDimension); return khronos::gl::texture::evalCompressedBlockCount(getGLInternaFormat(), pixelDimension);
} }
return pixelDimension; return pixelDimension;
} }