mirror of
https://github.com/bkaradzic/bimg.git
synced 2026-02-17 12:42:35 +01:00
Added bx::Location, and removed allocator macros.
This commit is contained in:
@@ -3299,7 +3299,7 @@ namespace bimg
|
||||
const uint8_t numMips = _hasMips ? imageGetNumMips(_format, _width, _height, _depth) : 1;
|
||||
uint32_t size = imageGetSize(NULL, _width, _height, _depth, _cubeMap, _hasMips, _numLayers, _format);
|
||||
|
||||
ImageContainer* imageContainer = (ImageContainer*)BX_ALIGNED_ALLOC(_allocator, size + bx::alignUp(sizeof(ImageContainer), 16), 16);
|
||||
ImageContainer* imageContainer = (ImageContainer*)bx::alignedAlloc(_allocator, size + bx::alignUp(sizeof(ImageContainer), 16), 16);
|
||||
|
||||
imageContainer->m_allocator = _allocator;
|
||||
imageContainer->m_data = bx::alignPtr(imageContainer + 1, 0, 16);
|
||||
@@ -3330,7 +3330,7 @@ namespace bimg
|
||||
|
||||
void imageFree(ImageContainer* _imageContainer)
|
||||
{
|
||||
BX_ALIGNED_FREE(_imageContainer->m_allocator, _imageContainer, 16);
|
||||
bx::alignedFree(_imageContainer->m_allocator, _imageContainer, 16);
|
||||
}
|
||||
|
||||
// DDS
|
||||
@@ -4459,10 +4459,10 @@ namespace bimg
|
||||
if (isCompressed(_srcFormat))
|
||||
{
|
||||
uint32_t size = imageGetSize(NULL, uint16_t(_width), uint16_t(_height), 0, false, false, 1, TextureFormat::RGBA8);
|
||||
void* temp = BX_ALLOC(_allocator, size);
|
||||
void* temp = bx::alloc(_allocator, size);
|
||||
imageDecodeToRgba8(_allocator, temp, _src, _width, _height, _width*4, _srcFormat);
|
||||
imageConvert(_allocator, dst, TextureFormat::R8, temp, TextureFormat::RGBA8, _width, _height, 1, _width*4, _dstPitch);
|
||||
BX_FREE(_allocator, temp);
|
||||
bx::free(_allocator, temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5149,10 +5149,10 @@ namespace bimg
|
||||
if (isCompressed(_srcFormat) )
|
||||
{
|
||||
uint32_t size = imageGetSize(NULL, uint16_t(_width), uint16_t(_height), 0, false, false, 1, TextureFormat::RGBA8);
|
||||
void* temp = BX_ALLOC(_allocator, size);
|
||||
void* temp = bx::alloc(_allocator, size);
|
||||
imageDecodeToRgba8(_allocator, temp, src, _width, _height, _width*4, _srcFormat);
|
||||
imageRgba8ToRgba32f(dst, _width, _height, _width*4, temp);
|
||||
BX_FREE(_allocator, temp);
|
||||
bx::free(_allocator, temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -519,7 +519,7 @@ namespace bimg
|
||||
stepA = 1;
|
||||
}
|
||||
|
||||
data = (uint8_t*)BX_ALLOC(_allocator, exrImage.width * exrImage.height * dstBpp/8);
|
||||
data = (uint8_t*)bx::alloc(_allocator, exrImage.width * exrImage.height * dstBpp/8);
|
||||
width = exrImage.width;
|
||||
height = exrImage.height;
|
||||
|
||||
@@ -627,7 +627,7 @@ namespace bimg
|
||||
, false
|
||||
, data
|
||||
);
|
||||
BX_FREE(_allocator, data);
|
||||
bx::free(_allocator, data);
|
||||
output->m_hasAlpha = hasAlpha;
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace bimg
|
||||
default:
|
||||
if (!imageConvert(_allocator, _dst, _dstFormat, _src, TextureFormat::RGBA32F, _width, _height, _depth) )
|
||||
{
|
||||
uint8_t* temp = (uint8_t*)BX_ALLOC(_allocator, _width*_height*_depth*4);
|
||||
uint8_t* temp = (uint8_t*)bx::alloc(_allocator, _width*_height*_depth*4);
|
||||
if (imageConvert(_allocator, temp, TextureFormat::RGBA8, _src, TextureFormat::RGBA32F, _width, _height, _depth) )
|
||||
{
|
||||
for (uint32_t zz = 0; zz < _depth; ++zz)
|
||||
@@ -310,7 +310,7 @@ namespace bimg
|
||||
BX_ERROR_SET(_err, BIMG_ERROR, "Unable to convert between input/output formats!");
|
||||
}
|
||||
|
||||
BX_FREE(_allocator, temp);
|
||||
bx::free(_allocator, temp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -344,20 +344,20 @@ namespace bimg
|
||||
case TextureFormat::ASTC12x10:
|
||||
case TextureFormat::ASTC12x12:
|
||||
{
|
||||
uint8_t* temp = (uint8_t*)BX_ALLOC(_allocator, _width*_height*_depth*4);
|
||||
uint8_t* temp = (uint8_t*)bx::alloc(_allocator, _width*_height*_depth*4);
|
||||
imageDecodeToRgba8(_allocator, temp, _src, _width, _height, _width*4, _srcFormat);
|
||||
imageEncodeFromRgba8(_allocator, _dst, temp, _width, _height, _depth, _dstFormat, _quality, _err);
|
||||
BX_FREE(_allocator, temp);
|
||||
bx::free(_allocator, temp);
|
||||
}
|
||||
break;
|
||||
|
||||
case bimg::TextureFormat::BC6H:
|
||||
case bimg::TextureFormat::BC7:
|
||||
{
|
||||
uint8_t* temp = (uint8_t*)BX_ALLOC(_allocator, _width*_height*_depth*16);
|
||||
uint8_t* temp = (uint8_t*)bx::alloc(_allocator, _width*_height*_depth*16);
|
||||
imageDecodeToRgba32f(_allocator, temp, _src, _width, _height, _depth, _width*16, _srcFormat);
|
||||
imageEncodeFromRgba32f(_allocator, _dst, temp, _width, _height, _depth, _dstFormat, _quality, _err);
|
||||
BX_FREE(_allocator, temp);
|
||||
bx::free(_allocator, temp);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -449,10 +449,10 @@ namespace bimg
|
||||
{
|
||||
const uint32_t numPixels = _width*_height;
|
||||
|
||||
short* xdist = (short *)BX_ALLOC(_allocator, numPixels*sizeof(short) );
|
||||
short* ydist = (short *)BX_ALLOC(_allocator, numPixels*sizeof(short) );
|
||||
double* gx = (double*)BX_ALLOC(_allocator, numPixels*sizeof(double) );
|
||||
double* gy = (double*)BX_ALLOC(_allocator, numPixels*sizeof(double) );
|
||||
short* xdist = (short *)bx::alloc(_allocator, numPixels*sizeof(short) );
|
||||
short* ydist = (short *)bx::alloc(_allocator, numPixels*sizeof(short) );
|
||||
double* gx = (double*)bx::alloc(_allocator, numPixels*sizeof(double) );
|
||||
double* gy = (double*)bx::alloc(_allocator, numPixels*sizeof(double) );
|
||||
|
||||
::computegradient(_src, _width, _height, gx, gy);
|
||||
::edtaa3(_src, gx, gy, _width, _height, xdist, ydist, _dst);
|
||||
@@ -465,19 +465,19 @@ namespace bimg
|
||||
}
|
||||
}
|
||||
|
||||
BX_FREE(_allocator, xdist);
|
||||
BX_FREE(_allocator, ydist);
|
||||
BX_FREE(_allocator, gx);
|
||||
BX_FREE(_allocator, gy);
|
||||
bx::free(_allocator, xdist);
|
||||
bx::free(_allocator, ydist);
|
||||
bx::free(_allocator, gx);
|
||||
bx::free(_allocator, gy);
|
||||
}
|
||||
|
||||
void imageMakeDist(bx::AllocatorI* _allocator, void* _dst, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src)
|
||||
{
|
||||
const uint32_t numPixels = _width*_height;
|
||||
|
||||
double* imgIn = (double*)BX_ALLOC(_allocator, numPixels*sizeof(double) );
|
||||
double* outside = (double*)BX_ALLOC(_allocator, numPixels*sizeof(double) );
|
||||
double* inside = (double*)BX_ALLOC(_allocator, numPixels*sizeof(double) );
|
||||
double* imgIn = (double*)bx::alloc(_allocator, numPixels*sizeof(double) );
|
||||
double* outside = (double*)bx::alloc(_allocator, numPixels*sizeof(double) );
|
||||
double* inside = (double*)bx::alloc(_allocator, numPixels*sizeof(double) );
|
||||
|
||||
for (uint32_t yy = 0; yy < _height; ++yy)
|
||||
{
|
||||
@@ -498,7 +498,7 @@ namespace bimg
|
||||
|
||||
edtaa3(_allocator, inside, _width, _height, imgIn);
|
||||
|
||||
BX_FREE(_allocator, imgIn);
|
||||
bx::free(_allocator, imgIn);
|
||||
|
||||
uint8_t* dst = (uint8_t*)_dst;
|
||||
|
||||
@@ -508,8 +508,8 @@ namespace bimg
|
||||
dst[ii] = 255-uint8_t(dist * 255.0);
|
||||
}
|
||||
|
||||
BX_FREE(_allocator, inside);
|
||||
BX_FREE(_allocator, outside);
|
||||
bx::free(_allocator, inside);
|
||||
bx::free(_allocator, outside);
|
||||
}
|
||||
|
||||
static const iqa_ssim_args s_iqaArgs =
|
||||
|
||||
@@ -403,9 +403,9 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
, 1
|
||||
, bimg::TextureFormat::RGBA32F
|
||||
);
|
||||
temp = BX_ALLOC(_allocator, size);
|
||||
temp = bx::alloc(_allocator, size);
|
||||
float* rgba32f = (float*)temp;
|
||||
float* rgbaDst = (float*)BX_ALLOC(_allocator, size);
|
||||
float* rgbaDst = (float*)bx::alloc(_allocator, size);
|
||||
|
||||
bimg::imageDecodeToRgba32f(_allocator
|
||||
, rgba32f
|
||||
@@ -499,7 +499,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
);
|
||||
}
|
||||
|
||||
BX_FREE(_allocator, rgbaDst);
|
||||
bx::free(_allocator, rgbaDst);
|
||||
}
|
||||
// HDR
|
||||
else if ( (!bimg::isCompressed(inputFormat) && 8 != inputBlockInfo.rBits)
|
||||
@@ -517,9 +517,9 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
, 1
|
||||
, bimg::TextureFormat::RGBA32F
|
||||
);
|
||||
temp = BX_ALLOC(_allocator, size);
|
||||
temp = bx::alloc(_allocator, size);
|
||||
float* rgba32f = (float*)temp;
|
||||
float* rgbaDst = (float*)BX_ALLOC(_allocator, size);
|
||||
float* rgbaDst = (float*)bx::alloc(_allocator, size);
|
||||
|
||||
bimg::imageDecodeToRgba32f(
|
||||
_allocator
|
||||
@@ -614,7 +614,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
}
|
||||
}
|
||||
|
||||
BX_FREE(_allocator, rgbaDst);
|
||||
bx::free(_allocator, rgbaDst);
|
||||
}
|
||||
// SDF
|
||||
else if (_options.sdf)
|
||||
@@ -629,7 +629,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
, 1
|
||||
, bimg::TextureFormat::R8
|
||||
);
|
||||
temp = BX_ALLOC(_allocator, size);
|
||||
temp = bx::alloc(_allocator, size);
|
||||
uint8_t* r8 = (uint8_t*)temp;
|
||||
|
||||
bimg::imageDecodeToR8(
|
||||
@@ -675,7 +675,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
, 1
|
||||
, bimg::TextureFormat::RGBA8
|
||||
);
|
||||
void* rgbaTemp = BX_ALLOC(_allocator, size);
|
||||
void* rgbaTemp = bx::alloc(_allocator, size);
|
||||
uint8_t* rgba = (uint8_t*)rgbaTemp;
|
||||
|
||||
bimg::imageDecodeToRgba8(
|
||||
@@ -731,7 +731,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
);
|
||||
}
|
||||
|
||||
BX_FREE(_allocator, rgbaTemp);
|
||||
bx::free(_allocator, rgbaTemp);
|
||||
}
|
||||
}
|
||||
// RGBA8
|
||||
@@ -747,7 +747,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
, 1
|
||||
, bimg::TextureFormat::RGBA8
|
||||
);
|
||||
temp = BX_ALLOC(_allocator, size);
|
||||
temp = bx::alloc(_allocator, size);
|
||||
uint8_t* rgba = (uint8_t*)temp;
|
||||
|
||||
bimg::imageDecodeToRgba8(
|
||||
@@ -775,7 +775,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
void* ref = NULL;
|
||||
if (_options.iqa)
|
||||
{
|
||||
ref = BX_ALLOC(_allocator, size);
|
||||
ref = bx::alloc(_allocator, size);
|
||||
bx::memCopy(ref, rgba, size);
|
||||
}
|
||||
|
||||
@@ -876,11 +876,11 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
|
||||
bx::printf("%f\n", result);
|
||||
|
||||
BX_FREE(_allocator, ref);
|
||||
bx::free(_allocator, ref);
|
||||
}
|
||||
}
|
||||
|
||||
BX_FREE(_allocator, temp);
|
||||
bx::free(_allocator, temp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1218,7 +1218,7 @@ int main(int _argc, const char* _argv[])
|
||||
bx::DefaultAllocator defaultAllocator;
|
||||
AlignedAllocator allocator(&defaultAllocator, 16);
|
||||
|
||||
uint8_t* inputData = (uint8_t*)BX_ALLOC(&allocator, inputSize);
|
||||
uint8_t* inputData = (uint8_t*)bx::alloc(&allocator, inputSize);
|
||||
|
||||
bx::read(&reader, inputData, inputSize, &err);
|
||||
bx::close(&reader);
|
||||
@@ -1231,7 +1231,7 @@ int main(int _argc, const char* _argv[])
|
||||
|
||||
bimg::ImageContainer* output = convert(&allocator, inputData, inputSize, options, &err);
|
||||
|
||||
BX_FREE(&allocator, inputData);
|
||||
bx::free(&allocator, inputData);
|
||||
|
||||
if (NULL != output)
|
||||
{
|
||||
@@ -1326,7 +1326,7 @@ int main(int _argc, const char* _argv[])
|
||||
return bx::kExitFailure;
|
||||
}
|
||||
|
||||
inputData = (uint8_t*)BX_ALLOC(&allocator, inputSize);
|
||||
inputData = (uint8_t*)bx::alloc(&allocator, inputSize);
|
||||
bx::read(&reader, inputData, inputSize, &err);
|
||||
bx::close(&reader);
|
||||
|
||||
@@ -1385,7 +1385,7 @@ int main(int _argc, const char* _argv[])
|
||||
}
|
||||
}
|
||||
|
||||
BX_FREE(&allocator, inputData);
|
||||
bx::free(&allocator, inputData);
|
||||
}
|
||||
|
||||
bimg::imageFree(output);
|
||||
|
||||
Reference in New Issue
Block a user