Path: blob/master/libmupen64plus/mupen64plus-video-glide64mk2/src/GlideHQ/TxUtil.h
2 views
/*1* Texture Filtering2* Version: 1.03*4* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.5* Email koolsmoky(at)users.sourceforge.net6* Web http://www.3dfxzone.it/koolsmoky7*8* this is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License as published by10* the Free Software Foundation; either version 2, or (at your option)11* any later version.12*13* this is distributed in the hope that it will be useful,14* but WITHOUT ANY WARRANTY; without even the implied warranty of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16* GNU General Public License for more details.17*18* You should have received a copy of the GNU General Public License19* along with GNU Make; see the file COPYING. If not, write to20* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.21*/2223#ifndef __TXUTIL_H__24#define __TXUTIL_H__2526/* maximum number of CPU cores allowed */27#define MAX_NUMCORE 82829#include "TxInternal.h"30#include <string>3132#ifndef DXTN_DLL33#ifdef __cplusplus34extern "C"{35#endif36void tx_compress_dxtn(int srccomps, int width, int height,37const void *source, int destformat, void *dest,38int destRowStride);3940int fxt1_encode(int width, int height, int comps,41const void *source, int srcRowStride,42void *dest, int destRowStride);43#ifdef __cplusplus44}45#endif46#endif /* DXTN_DLL */4748typedef void (*dxtCompressTexFuncExt)(int srccomps, int width,49int height, const void *srcPixData,50int destformat, void *dest,51int dstRowStride);5253typedef int (*fxtCompressTexFuncExt)(int width, int height, int comps,54const void *source, int srcRowStride,55void *dest, int destRowStride);5657class TxLoadLib58{59private:60#ifdef DXTN_DLL61HMODULE _dxtnlib;62#endif63fxtCompressTexFuncExt _tx_compress_fxt1;64dxtCompressTexFuncExt _tx_compress_dxtn;65TxLoadLib();66public:67static TxLoadLib* getInstance() {68static TxLoadLib txLoadLib;69return &txLoadLib;70}71~TxLoadLib();72fxtCompressTexFuncExt getfxtCompressTexFuncExt();73dxtCompressTexFuncExt getdxtCompressTexFuncExt();74};7576class TxUtil77{78private:79uint32 Adler32(const uint8* data, int Len, uint32 Adler);80uint32 Adler32(const uint8* src, int width, int height, int size, int rowStride);81uint32 RiceCRC32(const uint8* src, int width, int height, int size, int rowStride);82boolean RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride,83uint32* crc32, uint32* cimax);84boolean RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride,85uint32* crc32, uint32* cimax);86int log2(int num);87public:88TxUtil() { }89~TxUtil() { }90int sizeofTx(int width, int height, uint16 format);91uint32 checksumTx(uint8 *data, int width, int height, uint16 format);92#if 0 /* unused */93uint32 chkAlpha(uint32* src, int width, int height);94#endif95uint32 checksum(uint8 *src, int width, int height, int size, int rowStride);96uint64 checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette);97int grLodLog2(int w, int h);98int grAspectRatioLog2(int w, int h);99int getNumberofProcessors();100};101102class TxMemBuf103{104private:105uint8 *_tex[2];106uint32 _size[2];107TxMemBuf();108public:109static TxMemBuf* getInstance() {110static TxMemBuf txMemBuf;111return &txMemBuf;112}113~TxMemBuf();114boolean init(int maxwidth, int maxheight);115void shutdown(void);116uint8 *get(unsigned int num);117uint32 size_of(unsigned int num);118};119120#endif /* __TXUTIL_H__ */121122123