project64/Source/Project64-video/TextureEnhancer/TxUtil.h

101 lines
2.8 KiB
C
Raw Normal View History

2021-03-02 02:13:17 +00:00
// Project64 - A Nintendo 64 emulator
// https://www.pj64-emu.com/
2021-03-02 02:13:17 +00:00
// Copyright(C) 2001-2021 Project64
// Copyright(C) 2007 Hiroshi Morii
// Copyright(C) 2003 Rice1964
// GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html
2013-04-17 10:30:38 +00:00
#ifndef __TXUTIL_H__
#define __TXUTIL_H__
// Maximum number of CPU cores allowed
2013-04-17 10:30:38 +00:00
#define MAX_NUMCORE 8
#include "TxInternal.h"
#include <string>
#ifdef __cplusplus
2017-04-26 10:23:36 +00:00
extern "C" {
2013-04-17 10:30:38 +00:00
#endif
2017-04-26 10:23:36 +00:00
void tx_compress_dxtn(int srccomps, int width, int height,
const void *source, int destformat, void *dest,
int destRowStride);
2013-04-17 10:30:38 +00:00
2017-04-26 10:23:36 +00:00
int fxt1_encode(int width, int height, int comps,
const void *source, int srcRowStride,
void *dest, int destRowStride);
2013-04-17 10:30:38 +00:00
#ifdef __cplusplus
}
#endif
2017-04-26 10:23:36 +00:00
typedef void(*dxtCompressTexFuncExt)(int srccomps, int width,
int height, const void *srcPixData,
int destformat, void *dest,
int dstRowStride);
2013-04-17 10:30:38 +00:00
2017-04-26 10:23:36 +00:00
typedef int(*fxtCompressTexFuncExt)(int width, int height, int comps,
const void *source, int srcRowStride,
void *dest, int destRowStride);
2013-04-17 10:30:38 +00:00
class TxLoadLib
{
private:
2017-04-26 10:23:36 +00:00
fxtCompressTexFuncExt _tx_compress_fxt1;
dxtCompressTexFuncExt _tx_compress_dxtn;
TxLoadLib();
2013-04-17 10:30:38 +00:00
public:
2017-04-26 10:23:36 +00:00
static TxLoadLib* getInstance() {
static TxLoadLib txLoadLib;
return &txLoadLib;
}
~TxLoadLib();
fxtCompressTexFuncExt getfxtCompressTexFuncExt();
dxtCompressTexFuncExt getdxtCompressTexFuncExt();
2013-04-17 10:30:38 +00:00
};
class TxUtil
{
private:
2017-04-26 10:23:36 +00:00
uint32 Adler32(const uint8* data, int Len, uint32 Adler);
uint32 Adler32(const uint8* src, int width, int height, int size, int rowStride);
uint32 RiceCRC32(const uint8* src, int width, int height, int size, int rowStride);
bool RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride,
uint32* crc32, uint32* cimax);
bool RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride,
uint32* crc32, uint32* cimax);
int log2(int num);
2013-04-17 10:30:38 +00:00
public:
2017-04-26 10:23:36 +00:00
TxUtil() { }
~TxUtil() { }
int sizeofTx(int width, int height, uint16 format);
uint32 checksumTx(uint8 *data, int width, int height, uint16 format);
2013-04-17 10:30:38 +00:00
#if 0 /* unused */
2017-04-26 10:23:36 +00:00
uint32 chkAlpha(uint32* src, int width, int height);
2013-04-17 10:30:38 +00:00
#endif
2017-04-26 10:23:36 +00:00
uint32 checksum(uint8 *src, int width, int height, int size, int rowStride);
uint64_t checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette);
int grLodLog2(int w, int h);
int grAspectRatioLog2(int w, int h);
int getNumberofProcessors();
2013-04-17 10:30:38 +00:00
};
class TxMemBuf
{
private:
2017-04-26 10:23:36 +00:00
uint8 *_tex[2];
uint32 _size[2];
TxMemBuf();
2013-04-17 10:30:38 +00:00
public:
2017-04-26 10:23:36 +00:00
static TxMemBuf* getInstance() {
static TxMemBuf txMemBuf;
return &txMemBuf;
}
~TxMemBuf();
bool init(int maxwidth, int maxheight);
void shutdown(void);
uint8 *get(unsigned int num);
uint32 size_of(unsigned int num);
2013-04-17 10:30:38 +00:00
};
#endif // __TXUTIL_H__