Added ETC2 encoding.

This commit is contained in:
Branimir Karadžić 2016-01-28 21:09:03 -08:00
parent 8ab0a4eea5
commit 6c68a79526
11 changed files with 1274 additions and 0 deletions

View file

@ -13,6 +13,7 @@
#include "image.h"
#include <libsquish/squish.h>
#include <etc1/etc1.h>
#include <etc2/ProcessRGB.hpp>
#include <nvtt/nvtt.h>
#include <pvrtc/PvrTcEncoder.h>
#include <tinyexr/tinyexr.h>
@ -86,6 +87,23 @@ namespace bgfx
etc1_encode_image( (const uint8_t*)_src, _width, _height, 4, _width*4, (uint8_t*)_dst);
return true;
case TextureFormat::ETC2:
{
const uint32_t pitch = _width*4;
const uint32_t width = _width/4;
const uint32_t height = _height/4;
const uint8_t* src = (const uint8_t*)_src;
uint64_t* dst = (uint64_t*)_dst;
for (uint32_t yy = 0; yy < height; ++yy)
{
for (uint32_t xx = 0; xx < width; ++xx)
{
*dst++ = ProcessRGB_ETC2(&src[(yy*pitch+xx)*4]);
}
}
}
return true;
case TextureFormat::PTC14:
{
using namespace Javelin;