[Video] Revert some of the changes to TextureEnhancer code

This commit is contained in:
zilmar 2017-04-26 21:37:05 +10:00
parent b50c8b1fdd
commit 344253af5b
7 changed files with 150 additions and 134 deletions

View File

@ -64,6 +64,29 @@
#define LET_TEXARTISTS_FLY 0x40000000 /* a little freedom for texture artists */
#define DUMP_TEX 0x80000000
#ifndef __GLIDE_H__ /* GLIDE3 */
/* from 3Dfx Interactive Inc. glide.h */
#define GR_TEXFMT_ALPHA_8 0x2
#define GR_TEXFMT_INTENSITY_8 0x3
#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4
#define GR_TEXFMT_P_8 0x5
#define GR_TEXFMT_RGB_565 0xa
#define GR_TEXFMT_ARGB_1555 0xb
#define GR_TEXFMT_ARGB_4444 0xc
#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd
/* from 3Dfx Interactive Inc. g3ext.h */
#define GR_TEXFMT_ARGB_CMP_FXT1 0x11
#define GR_TEXFMT_ARGB_8888 0x12
#define GR_TEXFMT_ARGB_CMP_DXT1 0x16
#define GR_TEXFMT_ARGB_CMP_DXT3 0x18
#define GR_TEXFMT_ARGB_CMP_DXT5 0x1A
#endif /* GLIDE3 */
struct GHQTexInfo {
unsigned char *data;
int width;

View File

@ -24,7 +24,6 @@
#include <zlib/zlib.h>
#include <Common/path.h>
#include <Common/StdString.h>
#include <Project64-video/Renderer/types.h>
TxCache::~TxCache()
{
@ -104,7 +103,7 @@ TxCache::add(uint64_t checksum, GHQTexInfo *info, int dataSize)
{
DBG_INFO(80, "zlib compressed: %.02fkb->%.02fkb\n", (float)dataSize / 1000, (float)destLen / 1000);
dataSize = destLen;
format |= GFX_TEXFMT_GZ;
format |= GR_TEXFMT_GZ;
}
}
}
@ -226,7 +225,7 @@ TxCache::get(uint64_t checksum, GHQTexInfo *info)
}
/* zlib decompress it */
if (info->format & GFX_TEXFMT_GZ)
if (info->format & GR_TEXFMT_GZ)
{
uLongf destLen = _gzdestLen;
uint8 *dest = (_gzdest0 == info->data) ? _gzdest1 : _gzdest0;
@ -236,7 +235,7 @@ TxCache::get(uint64_t checksum, GHQTexInfo *info)
return 0;
}
info->data = dest;
info->format &= ~GFX_TEXFMT_GZ;
info->format &= ~GR_TEXFMT_GZ;
DBG_INFO(80, "zlib decompressed: %.02fkb->%.02fkb\n", (float)(((*itMap).second)->size) / 1000, (float)destLen / 1000);
}
return 1;
@ -269,7 +268,7 @@ bool TxCache::save(const char *path, const char *filename, int config)
* texture data in a zlib compressed state. if the GZ_TEXCACHE or GZ_HIRESTEXCACHE
* option is toggled, the cache will need to be rebuilt.
*/
/*if (format & GFX_TEXFMT_GZ) {
/*if (format & GR_TEXFMT_GZ) {
dest = _gzdest0;
destLen = _gzdestLen;
if (dest && destLen) {
@ -277,7 +276,7 @@ bool TxCache::save(const char *path, const char *filename, int config)
dest = NULL;
destLen = 0;
}
format &= ~GFX_TEXFMT_GZ;
format &= ~GR_TEXFMT_GZ;
}
}*/
@ -364,7 +363,7 @@ bool TxCache::load(const char *path, const char *filename, int config)
gzread(gzfp, tmpInfo.data, dataSize);
/* add to memory cache */
add(checksum, &tmpInfo, (tmpInfo.format & GFX_TEXFMT_GZ) ? dataSize : 0);
add(checksum, &tmpInfo, (tmpInfo.format & GR_TEXFMT_GZ) ? dataSize : 0);
free(tmpInfo.data);
}

View File

@ -17,7 +17,6 @@
#include <Common/path.h>
#include <Common/StdString.h>
#include <Project64-video/Renderer/types.h>
#include "TxFilter.h"
#include "TextureFilters.h"
#include "TxDbg.h"
@ -199,25 +198,25 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
*/
if ((srcwidth >= 4 && srcheight >= 4) &&
((_options & (FILTER_MASK | ENHANCEMENT_MASK | COMPRESSION_MASK)) ||
(srcformat == GFX_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)))) {
(srcformat == GR_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)))) {
#if !_16BPP_HACK
/* convert textures to a format that the compressor accepts (ARGB8888) */
if (_options & COMPRESSION_MASK) {
#endif
if (srcformat != GFX_TEXFMT_ARGB_8888) {
if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, srcformat, GFX_TEXFMT_ARGB_8888)) {
if (srcformat != GR_TEXFMT_ARGB_8888) {
if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, srcformat, GR_TEXFMT_ARGB_8888)) {
DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", srcformat);
return 0;
}
texture = tmptex;
destformat = GFX_TEXFMT_ARGB_8888;
destformat = GR_TEXFMT_ARGB_8888;
}
#if !_16BPP_HACK
}
#endif
switch (destformat) {
case GFX_TEXFMT_ARGB_8888:
case GR_TEXFMT_ARGB_8888:
/*
* prepare texture enhancements (x2, x4 scalers)
@ -302,9 +301,9 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
/* XXX: textures that use 8bit alpha channel look bad with the current
* fxt1 library, so we substitute it with dxtn for now. afaik all gfx
* cards that support fxt1 also support dxtn. (3dfx and Intel) */
if ((destformat == GFX_TEXFMT_ALPHA_INTENSITY_88) ||
(destformat == GFX_TEXFMT_ARGB_8888) ||
(destformat == GFX_TEXFMT_ALPHA_8)) {
if ((destformat == GR_TEXFMT_ALPHA_INTENSITY_88) ||
(destformat == GR_TEXFMT_ARGB_8888) ||
(destformat == GR_TEXFMT_ALPHA_8)) {
compressionType = S3TC_COMPRESSION;
}
tmptex = (texture == _tex1) ? _tex2 : _tex1;
@ -322,11 +321,11 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
/*
* texture (re)conversions
*/
if (destformat == GFX_TEXFMT_ARGB_8888) {
if (srcformat == GFX_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)) srcformat = GFX_TEXFMT_ARGB_4444;
if (srcformat != GFX_TEXFMT_ARGB_8888) {
if (destformat == GR_TEXFMT_ARGB_8888) {
if (srcformat == GR_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)) srcformat = GR_TEXFMT_ARGB_4444;
if (srcformat != GR_TEXFMT_ARGB_8888) {
tmptex = (texture == _tex1) ? _tex2 : _tex1;
if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, GFX_TEXFMT_ARGB_8888, srcformat)) {
if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, GR_TEXFMT_ARGB_8888, srcformat)) {
DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", srcformat);
return 0;
}
@ -337,7 +336,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
break;
#if !_16BPP_HACK
case GFX_TEXFMT_ARGB_4444:
case GR_TEXFMT_ARGB_4444:
int scale_shift = 0;
tmptex = (texture == _tex1) ? _tex2 : _tex1;
@ -406,11 +405,11 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
}
break;
case GFX_TEXFMT_ARGB_1555:
case GR_TEXFMT_ARGB_1555:
break;
case GFX_TEXFMT_RGB_565:
case GR_TEXFMT_RGB_565:
break;
case GFX_TEXFMT_ALPHA_8:
case GR_TEXFMT_ALPHA_8:
break;
#endif /* _16BPP_HACK */
}
@ -493,8 +492,8 @@ TxFilter::hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInf
* NOTE: the pre-converted palette from Glide64 is in RGBA5551 format.
* A comp comes before RGB comp.
*/
if (palette && info->format == GFX_TEXFMT_P_8) {
DBG_INFO(80, "found GFX_TEXFMT_P_8 format. Need conversion!!\n");
if (palette && info->format == GR_TEXFMT_P_8) {
DBG_INFO(80, "found GR_TEXFMT_P_8 format. Need conversion!!\n");
int width = info->width;
int height = info->height;
@ -506,31 +505,31 @@ TxFilter::hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInf
/* use palette and convert to 16bit format */
_txQuantize->P8_16BPP((uint32*)texture, (uint32*)tmptex, info->width, info->height, (uint32*)palette);
texture = tmptex;
format = GFX_TEXFMT_ARGB_1555;
format = GR_TEXFMT_ARGB_1555;
#if 1
/* XXX: compressed if memory cache compression is ON */
if (_options & COMPRESSION_MASK) {
tmptex = (texture == _tex1) ? _tex2 : _tex1;
if (_txQuantize->quantize(texture, tmptex, info->width, info->height, format, GFX_TEXFMT_ARGB_8888)) {
if (_txQuantize->quantize(texture, tmptex, info->width, info->height, format, GR_TEXFMT_ARGB_8888)) {
texture = tmptex;
format = GFX_TEXFMT_ARGB_8888;
format = GR_TEXFMT_ARGB_8888;
}
if (format == GFX_TEXFMT_ARGB_8888) {
if (format == GR_TEXFMT_ARGB_8888) {
tmptex = (texture == _tex1) ? _tex2 : _tex1;
if (_txQuantize->compress(texture, tmptex,
info->width, info->height, GFX_TEXFMT_ARGB_1555,
info->width, info->height, GR_TEXFMT_ARGB_1555,
&width, &height, &format,
_options & COMPRESSION_MASK)) {
texture = tmptex;
}
else {
/*if (!_txQuantize->quantize(texture, tmptex, info->width, info->height, GFX_TEXFMT_ARGB_8888, GFX_TEXFMT_ARGB_1555)) {
/*if (!_txQuantize->quantize(texture, tmptex, info->width, info->height, GR_TEXFMT_ARGB_8888, GR_TEXFMT_ARGB_1555)) {
DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", format);
return 0;
}*/
texture = tmptex;
format = GFX_TEXFMT_ARGB_1555;
format = GR_TEXFMT_ARGB_1555;
}
}
}
@ -549,7 +548,7 @@ TxFilter::hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInf
/* XXX: add to hires texture cache!!! */
_txHiResCache->add(r_crc64, info);
DBG_INFO(80, "GFX_TEXFMT_P_8 loaded as gfmt:%x!\n", format);
DBG_INFO(80, "GR_TEXFMT_P_8 loaded as gfmt:%x!\n", format);
}
return 1;
@ -597,7 +596,7 @@ TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gf
DBG_INFO(80, "hirestex: r_crc64:%08X %08X\n",
(uint32)(r_crc64 >> 32), (uint32)(r_crc64 & 0xffffffff));
if (!_txQuantize->quantize(src, _tex1, rowStridePixel, height, (gfmt & 0x00ff), GFX_TEXFMT_ARGB_8888))
if (!_txQuantize->quantize(src, _tex1, rowStridePixel, height, (gfmt & 0x00ff), GR_TEXFMT_ARGB_8888))
{
return 0;
}

View File

@ -51,7 +51,6 @@
#include <string>
#include <Common/path.h>
#include <Common/StdString.h>
#include <Project64-video/Renderer/types.h>
#ifdef _WIN32
#include <io.h>
#endif
@ -366,7 +365,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
if (tmptex) {
/* check if _rgb.* and _a.* have matching size and format. */
if (!tex || width != tmpwidth || height != tmpheight ||
format != GFX_TEXFMT_ARGB_8888 || tmpformat != GFX_TEXFMT_ARGB_8888) {
format != GR_TEXFMT_ARGB_8888 || tmpformat != GR_TEXFMT_ARGB_8888) {
#if !DEBUG
INFO(80, "-----\n");
INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
@ -378,7 +377,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
else if (width != tmpwidth || height != tmpheight) {
INFO(80, "Error: _rgb.* and _a.* have mismatched width or height!\n");
}
else if (format != GFX_TEXFMT_ARGB_8888 || tmpformat != GFX_TEXFMT_ARGB_8888) {
else if (format != GR_TEXFMT_ARGB_8888 || tmpformat != GR_TEXFMT_ARGB_8888) {
INFO(80, "Error: _rgb.* or _a.* not in 32bit color!\n");
}
if (tex) free(tex);
@ -507,11 +506,11 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
DBG_INFO(80, "read in as %d x %d gfmt:%x\n", tmpwidth, tmpheight, tmpformat);
/* check if size and format are OK */
if (!(format == GFX_TEXFMT_ARGB_8888 ||
format == GFX_TEXFMT_P_8 ||
format == GFX_TEXFMT_ARGB_CMP_DXT1 ||
format == GFX_TEXFMT_ARGB_CMP_DXT3 ||
format == GFX_TEXFMT_ARGB_CMP_DXT5) ||
if (!(format == GR_TEXFMT_ARGB_8888 ||
format == GR_TEXFMT_P_8 ||
format == GR_TEXFMT_ARGB_CMP_DXT1 ||
format == GR_TEXFMT_ARGB_CMP_DXT3 ||
format == GR_TEXFMT_ARGB_CMP_DXT5) ||
(width * height) < 4) { /* TxQuantize requirement: width * height must be 4 or larger. */
free(tex);
tex = NULL;
@ -525,7 +524,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
}
/* analyze and determine best format to quantize */
if (format == GFX_TEXFMT_ARGB_8888) {
if (format == GR_TEXFMT_ARGB_8888) {
int i;
int alphabits = 0;
int fullalpha = 0;
@ -633,17 +632,17 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
#if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & (FORCE16BPP_HIRESTEX | COMPRESSION_MASK)) {
#endif
if (alphabits == 0) destformat = GFX_TEXFMT_RGB_565;
else if (alphabits == 1) destformat = GFX_TEXFMT_ARGB_1555;
else destformat = GFX_TEXFMT_ARGB_8888;
if (alphabits == 0) destformat = GR_TEXFMT_RGB_565;
else if (alphabits == 1) destformat = GR_TEXFMT_ARGB_1555;
else destformat = GR_TEXFMT_ARGB_8888;
#if !REDUCE_TEXTURE_FOOTPRINT
}
else {
destformat = GFX_TEXFMT_ARGB_8888;
destformat = GR_TEXFMT_ARGB_8888;
}
#endif
if (fmt == 4 && alphabits == 0) {
destformat = GFX_TEXFMT_ARGB_8888;
destformat = GR_TEXFMT_ARGB_8888;
/* Rice I format; I = (R + G + B) / 3 */
for (i = 0; i < height * width; i++) {
uint32 texel = ((uint32*)tex)[i];
@ -655,11 +654,11 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
}
if (intensity) {
if (alphabits == 0) {
if (fmt == 4) destformat = GFX_TEXFMT_ALPHA_8;
else destformat = GFX_TEXFMT_INTENSITY_8;
if (fmt == 4) destformat = GR_TEXFMT_ALPHA_8;
else destformat = GR_TEXFMT_INTENSITY_8;
}
else {
destformat = GFX_TEXFMT_ALPHA_INTENSITY_88;
destformat = GR_TEXFMT_ALPHA_INTENSITY_88;
}
}
@ -669,7 +668,7 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
* Rice hi-res textures: end */
/* XXX: only ARGB8888 for now. comeback to this later... */
if (format == GFX_TEXFMT_ARGB_8888) {
if (format == GR_TEXFMT_ARGB_8888) {
#if TEXTURE_TILING
/* Glide64 style texture tiling */
@ -865,40 +864,40 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
switch (_options & COMPRESSION_MASK) {
case S3TC_COMPRESSION:
switch (destformat) {
case GFX_TEXFMT_ARGB_8888:
case GR_TEXFMT_ARGB_8888:
#if GLIDE64_DXTN
case GFX_TEXFMT_ARGB_1555: /* for ARGB1555 use DXT5 instead of DXT1 */
case GR_TEXFMT_ARGB_1555: /* for ARGB1555 use DXT5 instead of DXT1 */
#endif
case GFX_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_ALPHA_INTENSITY_88:
dataSize = width * height;
break;
#if !GLIDE64_DXTN
case GFX_TEXFMT_ARGB_1555:
case GR_TEXFMT_ARGB_1555:
#endif
case GFX_TEXFMT_RGB_565:
case GFX_TEXFMT_INTENSITY_8:
case GR_TEXFMT_RGB_565:
case GR_TEXFMT_INTENSITY_8:
dataSize = (width * height) >> 1;
break;
case GFX_TEXFMT_ALPHA_8: /* no size benefit with dxtn */
case GR_TEXFMT_ALPHA_8: /* no size benefit with dxtn */
;
}
break;
case FXT1_COMPRESSION:
switch (destformat) {
case GFX_TEXFMT_ARGB_1555:
case GFX_TEXFMT_RGB_565:
case GFX_TEXFMT_INTENSITY_8:
case GR_TEXFMT_ARGB_1555:
case GR_TEXFMT_RGB_565:
case GR_TEXFMT_INTENSITY_8:
dataSize = (width * height) >> 1;
break;
/* XXX: textures that use 8bit alpha channel look bad with the current
* fxt1 library, so we substitute it with dxtn for now. afaik all gfx
* cards that support fxt1 also support dxtn. (3dfx and Intel) */
case GFX_TEXFMT_ALPHA_INTENSITY_88:
case GFX_TEXFMT_ARGB_8888:
case GR_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_ARGB_8888:
compressionType = S3TC_COMPRESSION;
dataSize = width * height;
break;
case GFX_TEXFMT_ALPHA_8: /* no size benefit with dxtn */
case GR_TEXFMT_ALPHA_8: /* no size benefit with dxtn */
;
}
}
@ -907,8 +906,8 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
#if 0 /* TEST: dither before compression for better results with gradients */
tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat));
if (tmptex) {
if (_txQuantize->quantize(tex, tmptex, width, height, GFX_TEXFMT_ARGB_8888, destformat, 0))
_txQuantize->quantize(tmptex, tex, width, height, destformat, GFX_TEXFMT_ARGB_8888, 0);
if (_txQuantize->quantize(tex, tmptex, width, height, GR_TEXFMT_ARGB_8888, destformat, 0))
_txQuantize->quantize(tmptex, tex, width, height, destformat, GR_TEXFMT_ARGB_8888, 0);
free(tmptex);
}
#endif
@ -952,40 +951,40 @@ bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace)
tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat));
if (tmptex) {
switch (destformat) {
case GFX_TEXFMT_ARGB_8888:
case GFX_TEXFMT_ARGB_4444:
case GR_TEXFMT_ARGB_8888:
case GR_TEXFMT_ARGB_4444:
#if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX)
#endif
destformat = GFX_TEXFMT_ARGB_4444;
destformat = GR_TEXFMT_ARGB_4444;
break;
case GFX_TEXFMT_ARGB_1555:
case GR_TEXFMT_ARGB_1555:
#if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX)
#endif
destformat = GFX_TEXFMT_ARGB_1555;
destformat = GR_TEXFMT_ARGB_1555;
break;
case GFX_TEXFMT_RGB_565:
case GR_TEXFMT_RGB_565:
#if !REDUCE_TEXTURE_FOOTPRINT
if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX)
#endif
destformat = GFX_TEXFMT_RGB_565;
destformat = GR_TEXFMT_RGB_565;
break;
case GFX_TEXFMT_ALPHA_INTENSITY_88:
case GFX_TEXFMT_ALPHA_INTENSITY_44:
case GR_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_ALPHA_INTENSITY_44:
#if !REDUCE_TEXTURE_FOOTPRINT
destformat = GFX_TEXFMT_ALPHA_INTENSITY_88;
destformat = GR_TEXFMT_ALPHA_INTENSITY_88;
#else
destformat = GFX_TEXFMT_ALPHA_INTENSITY_44;
destformat = GR_TEXFMT_ALPHA_INTENSITY_44;
#endif
break;
case GFX_TEXFMT_ALPHA_8:
destformat = GFX_TEXFMT_ALPHA_8; /* yes, this is correct. ALPHA_8 instead of INTENSITY_8 */
case GR_TEXFMT_ALPHA_8:
destformat = GR_TEXFMT_ALPHA_8; /* yes, this is correct. ALPHA_8 instead of INTENSITY_8 */
break;
case GFX_TEXFMT_INTENSITY_8:
destformat = GFX_TEXFMT_INTENSITY_8;
case GR_TEXFMT_INTENSITY_8:
destformat = GR_TEXFMT_INTENSITY_8;
}
if (_txQuantize->quantize(tex, tmptex, width, height, GFX_TEXFMT_ARGB_8888, destformat, 0)) {
if (_txQuantize->quantize(tex, tmptex, width, height, GR_TEXFMT_ARGB_8888, destformat, 0)) {
format = destformat;
free(tex);
tex = tmptex;

View File

@ -23,7 +23,6 @@
#include "TxReSample.h"
#include "TxDbg.h"
#include <stdlib.h>
#include <Project64-video/Renderer/types.h>
bool TxImage::getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr)
{
@ -67,7 +66,7 @@ bool TxImage::getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr)
uint8*
TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format)
{
/* NOTE: returned image format is GFX_TEXFMT_ARGB_8888 */
/* NOTE: returned image format is GR_TEXFMT_ARGB_8888 */
png_structp png_ptr;
png_infop info_ptr;
@ -194,7 +193,7 @@ TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format)
*width = (row_bytes >> 2);
*height = o_height;
*format = GFX_TEXFMT_ARGB_8888;
*format = GR_TEXFMT_ARGB_8888;
#if POW2_TEXTURES
/* next power of 2 size conversions */
@ -481,8 +480,8 @@ uint8*
TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format)
{
/* NOTE: returned image format;
* 4, 8bit palette bmp -> GFX_TEXFMT_P_8
* 24, 32bit bmp -> GFX_TEXFMT_ARGB_8888
* 4, 8bit palette bmp -> GR_TEXFMT_P_8
* 24, 32bit bmp -> GR_TEXFMT_ARGB_8888
*/
uint8 *image = NULL;
@ -605,11 +604,11 @@ TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format)
switch (bmp_ihdr.biBitCount) {
case 8:
case 4:
*format = GFX_TEXFMT_P_8;
*format = GR_TEXFMT_P_8;
break;
case 32:
case 24:
*format = GFX_TEXFMT_ARGB_8888;
*format = GR_TEXFMT_ARGB_8888;
}
#if POW2_TEXTURES
@ -765,17 +764,17 @@ TxImage::readDDS(FILE* fp, int* width, int* height, uint16* format)
DBG_INFO(80, "DXT1 format\n");
/* compensate for missing LinearSize */
dds_fhdr.dwLinearSize = (dds_fhdr.dwWidth * dds_fhdr.dwHeight) >> 1;
tmpformat = GFX_TEXFMT_ARGB_CMP_DXT1;
tmpformat = GR_TEXFMT_ARGB_CMP_DXT1;
}
else if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT3", 4) == 0) {
DBG_INFO(80, "DXT3 format\n");
dds_fhdr.dwLinearSize = dds_fhdr.dwWidth * dds_fhdr.dwHeight;
tmpformat = GFX_TEXFMT_ARGB_CMP_DXT3;
tmpformat = GR_TEXFMT_ARGB_CMP_DXT3;
}
else if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT5", 4) == 0) {
DBG_INFO(80, "DXT5 format\n");
dds_fhdr.dwLinearSize = dds_fhdr.dwWidth * dds_fhdr.dwHeight;
tmpformat = GFX_TEXFMT_ARGB_CMP_DXT5;
tmpformat = GR_TEXFMT_ARGB_CMP_DXT5;
}
else {
DBG_INFO(80, "Error: not DXT1 or DXT3 or DXT5 format!\n");

View File

@ -19,7 +19,6 @@
/* NOTE: The codes are not optimized. They can be made faster. */
#include "TxQuantize.h"
#include <Project64-video/Renderer/types.h>
TxQuantize::TxQuantize()
{
@ -1730,29 +1729,29 @@ TxQuantize::quantize(uint8* src, uint8* dest, int width, int height, uint16 srcf
quantizerFunc quantizer;
int bpp_shift = 0;
if (destformat == GFX_TEXFMT_ARGB_8888) {
if (destformat == GR_TEXFMT_ARGB_8888) {
switch (srcformat) {
case GFX_TEXFMT_ARGB_1555:
case GR_TEXFMT_ARGB_1555:
quantizer = &TxQuantize::ARGB1555_ARGB8888;
bpp_shift = 1;
break;
case GFX_TEXFMT_ARGB_4444:
case GR_TEXFMT_ARGB_4444:
quantizer = &TxQuantize::ARGB4444_ARGB8888;
bpp_shift = 1;
break;
case GFX_TEXFMT_RGB_565:
case GR_TEXFMT_RGB_565:
quantizer = &TxQuantize::RGB565_ARGB8888;
bpp_shift = 1;
break;
case GFX_TEXFMT_ALPHA_8:
case GR_TEXFMT_ALPHA_8:
quantizer = &TxQuantize::A8_ARGB8888;
bpp_shift = 2;
break;
case GFX_TEXFMT_ALPHA_INTENSITY_44:
case GR_TEXFMT_ALPHA_INTENSITY_44:
quantizer = &TxQuantize::AI44_ARGB8888;
bpp_shift = 2;
break;
case GFX_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_ALPHA_INTENSITY_88:
quantizer = &TxQuantize::AI88_ARGB8888;
bpp_shift = 1;
break;
@ -1768,30 +1767,30 @@ TxQuantize::quantize(uint8* src, uint8* dest, int width, int height, uint16 srcf
}
(*this.*quantizer)((uint32*)src, (uint32*)dest, width, height);
}
else if (srcformat == GFX_TEXFMT_ARGB_8888) {
else if (srcformat == GR_TEXFMT_ARGB_8888) {
switch (destformat) {
case GFX_TEXFMT_ARGB_1555:
case GR_TEXFMT_ARGB_1555:
quantizer = fastQuantizer ? &TxQuantize::ARGB8888_ARGB1555 : &TxQuantize::ARGB8888_ARGB1555_ErrD;
bpp_shift = 1;
break;
case GFX_TEXFMT_ARGB_4444:
case GR_TEXFMT_ARGB_4444:
quantizer = fastQuantizer ? &TxQuantize::ARGB8888_ARGB4444 : &TxQuantize::ARGB8888_ARGB4444_ErrD;
bpp_shift = 1;
break;
case GFX_TEXFMT_RGB_565:
case GR_TEXFMT_RGB_565:
quantizer = fastQuantizer ? &TxQuantize::ARGB8888_RGB565 : &TxQuantize::ARGB8888_RGB565_ErrD;
bpp_shift = 1;
break;
case GFX_TEXFMT_ALPHA_8:
case GFX_TEXFMT_INTENSITY_8:
case GR_TEXFMT_ALPHA_8:
case GR_TEXFMT_INTENSITY_8:
quantizer = fastQuantizer ? &TxQuantize::ARGB8888_A8 : &TxQuantize::ARGB8888_I8_Slow;
bpp_shift = 2;
break;
case GFX_TEXFMT_ALPHA_INTENSITY_44:
case GR_TEXFMT_ALPHA_INTENSITY_44:
quantizer = fastQuantizer ? &TxQuantize::ARGB8888_AI44 : &TxQuantize::ARGB8888_AI44_ErrD;
bpp_shift = 2;
break;
case GFX_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_ALPHA_INTENSITY_88:
quantizer = fastQuantizer ? &TxQuantize::ARGB8888_AI88 : &TxQuantize::ARGB8888_AI88_Slow;
bpp_shift = 1;
break;
@ -1847,7 +1846,7 @@ TxQuantize::FXT1(uint8 *src, uint8 *dest,
/* dxtn adjusts width and height to M8 and M4 respectively by replication */
*destwidth = (srcwidth + 7) & ~7;
*destheight = (srcheight + 3) & ~3;
*destformat = GFX_TEXFMT_ARGB_CMP_FXT1;
*destformat = GR_TEXFMT_ARGB_CMP_FXT1;
bRet = 1;
}
@ -1877,33 +1876,33 @@ TxQuantize::DXTn(uint8 *src, uint8 *dest,
*/
/* skip formats that DXTn won't help in size. */
if (srcformat == GFX_TEXFMT_ALPHA_8 ||
srcformat == GFX_TEXFMT_ALPHA_INTENSITY_44) {
if (srcformat == GR_TEXFMT_ALPHA_8 ||
srcformat == GR_TEXFMT_ALPHA_INTENSITY_44) {
; /* shutup compiler */
}
else {
int dstRowStride = ((srcwidth + 3) & ~3) << 2;
int compression = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
*destformat = GFX_TEXFMT_ARGB_CMP_DXT5;
*destformat = GR_TEXFMT_ARGB_CMP_DXT5;
#if !GLIDE64_DXTN
/* okay... we are going to disable DXT1 with 1bit alpha
* for Glide64. some textures have all 0 alpha values.
* see "N64 Kobe Bryant in NBA Courtside"
*/
if (srcformat == GFX_TEXFMT_ARGB_1555) {
if (srcformat == GR_TEXFMT_ARGB_1555) {
dstRowStride >>= 1;
compression = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
*destformat = GFX_TEXFMT_ARGB_CMP_DXT1;
*destformat = GR_TEXFMT_ARGB_CMP_DXT1;
}
else
#endif
if (srcformat == GFX_TEXFMT_RGB_565 ||
srcformat == GFX_TEXFMT_INTENSITY_8) {
if (srcformat == GR_TEXFMT_RGB_565 ||
srcformat == GR_TEXFMT_INTENSITY_8) {
dstRowStride >>= 1;
compression = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
*destformat = GFX_TEXFMT_ARGB_CMP_DXT1;
*destformat = GR_TEXFMT_ARGB_CMP_DXT1;
}
unsigned int numcore = _numcore;

View File

@ -18,8 +18,6 @@
#include <malloc.h>
#include <stdlib.h>
#include <Common/stdtypes.h>
#include <Project64-video/Renderer/types.h>
#include <windows.h>
/*
@ -67,29 +65,29 @@ int TxUtil::sizeofTx(int width, int height, uint16 format)
/* a lookup table for the shifts would be better */
switch (format) {
case GFX_TEXFMT_ARGB_CMP_FXT1:
case GR_TEXFMT_ARGB_CMP_FXT1:
dataSize = (((width + 0x7) & ~0x7) * ((height + 0x3) & ~0x3)) >> 1;
break;
case GFX_TEXFMT_ARGB_CMP_DXT1:
case GR_TEXFMT_ARGB_CMP_DXT1:
dataSize = (((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3)) >> 1;
break;
case GFX_TEXFMT_ARGB_CMP_DXT3:
case GFX_TEXFMT_ARGB_CMP_DXT5:
case GR_TEXFMT_ARGB_CMP_DXT3:
case GR_TEXFMT_ARGB_CMP_DXT5:
dataSize = ((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3);
break;
case GFX_TEXFMT_ALPHA_INTENSITY_44:
case GFX_TEXFMT_ALPHA_8:
case GFX_TEXFMT_INTENSITY_8:
case GFX_TEXFMT_P_8:
case GR_TEXFMT_ALPHA_INTENSITY_44:
case GR_TEXFMT_ALPHA_8:
case GR_TEXFMT_INTENSITY_8:
case GR_TEXFMT_P_8:
dataSize = width * height;
break;
case GFX_TEXFMT_ARGB_4444:
case GFX_TEXFMT_ARGB_1555:
case GFX_TEXFMT_RGB_565:
case GFX_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_ARGB_4444:
case GR_TEXFMT_ARGB_1555:
case GR_TEXFMT_RGB_565:
case GR_TEXFMT_ALPHA_INTENSITY_88:
dataSize = (width * height) << 1;
break;
case GFX_TEXFMT_ARGB_8888:
case GR_TEXFMT_ARGB_8888:
dataSize = (width * height) << 2;
break;
default: