|
|
@@ -8,47 +8,51 @@
|
|
|
#include <string.h>
|
|
|
#include <bx/uint32_t.h>
|
|
|
|
|
|
+BX_PRAGMA_DIAGNOSTIC_PUSH();
|
|
|
+BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4458) // warning C4458: declaration of 'x' hides class member
|
|
|
#include "bc6h/zoh.h"
|
|
|
#include "bc7/avpcl.h"
|
|
|
#include "nvmath/vector.inl"
|
|
|
+BX_PRAGMA_DIAGNOSTIC_POP();
|
|
|
|
|
|
+BX_PRAGMA_DIAGNOSTIC_PUSH();
|
|
|
+BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4702) // warning C4702: unreachable code
|
|
|
NVCORE_API int nvAbort(const char *, const char *, int , const char *, const char *, ...)
|
|
|
{
|
|
|
abort();
|
|
|
return 0;
|
|
|
}
|
|
|
+BX_PRAGMA_DIAGNOSTIC_POP();
|
|
|
|
|
|
namespace nvtt
|
|
|
{
|
|
|
- using namespace nv;
|
|
|
-
|
|
|
void compressBC6H(const void* _input, uint32_t _width, uint32_t _height, uint32_t _srcStride, void* _output)
|
|
|
{
|
|
|
const uint8_t* src = (const uint8_t*)_input;
|
|
|
char* dst = (char*)_output;
|
|
|
|
|
|
- for (uint32_t yy = 0; yy < _height; yy += 4)
|
|
|
+ for (uint32_t yy = 0; yy < _height; yy += ZOH::Tile::TILE_H)
|
|
|
{
|
|
|
- for (uint32_t xx = 0; xx < _width; xx += 4)
|
|
|
+ for (uint32_t xx = 0; xx < _width; xx += ZOH::Tile::TILE_H)
|
|
|
{
|
|
|
const uint32_t bytesPerPixel = sizeof(float)*4;
|
|
|
- const Vector4* srcRgba = (const Vector4*)&src[yy*_srcStride + xx*bytesPerPixel];
|
|
|
+ const nv::Vector4* srcRgba = (const nv::Vector4*)&src[yy*_srcStride + xx*bytesPerPixel];
|
|
|
const uint32_t srcRgbaStride = _srcStride/bytesPerPixel;
|
|
|
|
|
|
ZOH::Utils::FORMAT = ZOH::SIGNED_F16;
|
|
|
- ZOH::Tile zohTile(4, 4);
|
|
|
+ ZOH::Tile zohTile(ZOH::Tile::TILE_H, ZOH::Tile::TILE_H);
|
|
|
|
|
|
bx::memSet(zohTile.data, 0, sizeof(zohTile.data) );
|
|
|
bx::memSet(zohTile.importance_map, 0, sizeof(zohTile.importance_map) );
|
|
|
|
|
|
- for (uint32_t blockY = 0; blockY < 4; ++blockY)
|
|
|
+ for (uint32_t blockY = 0; blockY < ZOH::Tile::TILE_H; ++blockY)
|
|
|
{
|
|
|
- for (uint32_t blockX = 0; blockX < 4; ++blockX)
|
|
|
+ for (uint32_t blockX = 0; blockX < ZOH::Tile::TILE_W; ++blockX)
|
|
|
{
|
|
|
- Vector4 color = srcRgba[blockY*srcRgbaStride + blockX];
|
|
|
- zohTile.data[blockY][blockX].x = color.x;
|
|
|
- zohTile.data[blockY][blockX].y = color.y;
|
|
|
- zohTile.data[blockY][blockX].z = color.z;
|
|
|
+ nv::Vector4 color = srcRgba[blockY*srcRgbaStride + blockX];
|
|
|
+ zohTile.data[blockY][blockX].x = float(int16_t(bx::halfFromFloat(color.x) ) );
|
|
|
+ zohTile.data[blockY][blockX].y = float(int16_t(bx::halfFromFloat(color.y) ) );
|
|
|
+ zohTile.data[blockY][blockX].z = float(int16_t(bx::halfFromFloat(color.z) ) );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -69,7 +73,7 @@ namespace nvtt
|
|
|
for (uint32_t xx = 0; xx < _width; xx += 4)
|
|
|
{
|
|
|
const uint32_t bytesPerPixel = sizeof(float) * 4;
|
|
|
- const Vector4* srcRgba = (const Vector4*)&src[yy*_srcStride + xx*bytesPerPixel];
|
|
|
+ const nv::Vector4* srcRgba = (const nv::Vector4*)&src[yy*_srcStride + xx*bytesPerPixel];
|
|
|
const uint32_t srcRgbaStride = _srcStride / bytesPerPixel;
|
|
|
|
|
|
AVPCL::mode_rgb = false;
|
|
|
@@ -83,7 +87,7 @@ namespace nvtt
|
|
|
{
|
|
|
for (uint32_t blockX = 0; blockX < 4; ++blockX)
|
|
|
{
|
|
|
- Vector4 color = srcRgba[blockY*srcRgbaStride + blockX];
|
|
|
+ nv::Vector4 color = srcRgba[blockY*srcRgbaStride + blockX];
|
|
|
avpclTile.data[blockY][blockX] = color * 255.0f;
|
|
|
avpclTile.importance_map[blockY][blockX] = 1.0f;
|
|
|
}
|