GlideHQ: fix up to not use boost

This commit is contained in:
zilmar 2013-04-26 19:31:09 +10:00
parent c26a70f549
commit 87f96afeee
8 changed files with 203 additions and 418 deletions

View File

@ -39,6 +39,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
AdditionalIncludeDirectories="src\zlib" AdditionalIncludeDirectories="src\zlib"
PreprocessorDefinitions="_LIB" PreprocessorDefinitions="_LIB"
SmallerTypeCheck="false"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
/> />

View File

@ -329,10 +329,6 @@ void UseUnregisteredSetting (int /*SettingID*/)
void ReadSettings () void ReadSettings ()
{ {
//Config.h
//PluginLoaded
settings.card_id = GetSetting(Set_CardId); settings.card_id = GetSetting(Set_CardId);
settings.res_data = (wxUint32)GetSetting(Set_Resolution); settings.res_data = (wxUint32)GetSetting(Set_Resolution);
if (settings.res_data >= 24) settings.res_data = 12; if (settings.res_data >= 24) settings.res_data = 12;
@ -484,7 +480,7 @@ void ReadSpecialSettings (const char * name)
settings.pal230 = GetSetting(Set_pal230) == 1 ? 1 : 0; settings.pal230 = GetSetting(Set_pal230) == 1 ? 1 : 0;
settings.stipple_mode = GetSetting(Set_stipple_mode); settings.stipple_mode = GetSetting(Set_stipple_mode);
int stipple_pattern = GetSetting(Set_stipple_pattern); int stipple_pattern = GetSetting(Set_stipple_pattern);
if (stipple_pattern > 0) settings.stipple_pattern = (wxUint32)stipple_pattern; settings.stipple_pattern = stipple_pattern > 0 ? (wxUint32)stipple_pattern : 0x3E0F83E0;
settings.force_microcheck = GetSetting(Set_force_microcheck); settings.force_microcheck = GetSetting(Set_force_microcheck);
settings.force_quad3d = GetSetting(Set_force_quad3d); settings.force_quad3d = GetSetting(Set_force_quad3d);
settings.clip_zmin = GetSetting(Set_clip_zmin); settings.clip_zmin = GetSetting(Set_clip_zmin);
@ -1201,6 +1197,12 @@ void wxDLLApp::CleanUp()
delete mutexProcessDList; delete mutexProcessDList;
mutexProcessDList = NULL; mutexProcessDList = NULL;
} }
if (GFXWindow)
{
GFXWindow->SetHWND(NULL);
delete GFXWindow;
GFXWindow = NULL;
}
} }
#ifndef __WINDOWS__ #ifndef __WINDOWS__
@ -1619,8 +1621,8 @@ void CALL PluginLoaded (void)
SetModuleName("Glide64"); SetModuleName("Glide64");
RegisterSetting(Set_CardId, Data_DWORD_General,"card_id",NULL,0l,NULL); RegisterSetting(Set_CardId, Data_DWORD_General,"card_id",NULL,0l,NULL);
RegisterSetting(Set_Resolution, Data_DWORD_General,"resolution",NULL,7,NULL); RegisterSetting(Set_Resolution, Data_DWORD_General,"resolution",NULL,7,NULL);
RegisterSetting(Set_vsync, Data_DWORD_General,"vsync",NULL,0l,NULL); RegisterSetting(Set_vsync, Data_DWORD_General,"vsync",NULL,1,NULL);
RegisterSetting(Set_ssformat, Data_DWORD_General,"ssformat",NULL,0l,NULL); RegisterSetting(Set_ssformat, Data_DWORD_General,"ssformat",NULL,1,NULL);
RegisterSetting(Set_ShowFps, Data_DWORD_General,"show_fps",NULL,0l,NULL); RegisterSetting(Set_ShowFps, Data_DWORD_General,"show_fps",NULL,0l,NULL);
RegisterSetting(Set_clock, Data_DWORD_General,"clock",NULL,0l,NULL); RegisterSetting(Set_clock, Data_DWORD_General,"clock",NULL,0l,NULL);
RegisterSetting(Set_clock_24_hr, Data_DWORD_General,"clock_24_hr",NULL,0l,NULL); RegisterSetting(Set_clock_24_hr, Data_DWORD_General,"clock_24_hr",NULL,0l,NULL);
@ -1688,7 +1690,7 @@ void CALL PluginLoaded (void)
RegisterSetting(Set_useless_is_useless,Data_DWORD_Game,"useless_is_useless",NULL,(unsigned int)-1,NULL); RegisterSetting(Set_useless_is_useless,Data_DWORD_Game,"useless_is_useless",NULL,(unsigned int)-1,NULL);
RegisterSetting(Set_fb_crc_mode,Data_DWORD_Game,"fb_crc_mode",NULL,1,NULL); RegisterSetting(Set_fb_crc_mode,Data_DWORD_Game,"fb_crc_mode",NULL,1,NULL);
RegisterSetting(Set_filtering,Data_DWORD_Game,"filtering",NULL,0l,NULL); RegisterSetting(Set_filtering,Data_DWORD_Game,"filtering",NULL,0l,NULL);
RegisterSetting(Set_fog,Data_DWORD_Game,"fog",NULL,0l,NULL); RegisterSetting(Set_fog,Data_DWORD_Game,"fog",NULL,1,NULL);
RegisterSetting(Set_buff_clear,Data_DWORD_Game,"buff_clear",NULL,1,NULL); RegisterSetting(Set_buff_clear,Data_DWORD_Game,"buff_clear",NULL,1,NULL);
RegisterSetting(Set_swapmode,Data_DWORD_Game,"swapmode",NULL,1,NULL); RegisterSetting(Set_swapmode,Data_DWORD_Game,"swapmode",NULL,1,NULL);
RegisterSetting(Set_aspect,Data_DWORD_Game,"aspect",NULL,0l,NULL); RegisterSetting(Set_aspect,Data_DWORD_Game,"aspect",NULL,0l,NULL);

View File

@ -1,27 +0,0 @@
/*
* Texture Filtering
* Version: 1.0
*
* Copyright (C) 2007 Hiroshi Morii All Rights Reserved.
* Email koolsmoky(at)users.sourceforge.net
* Web http://www.3dfxzone.it/koolsmoky
*
* this is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* this is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <memory.h>
#include <stdlib.h>
#include "Ext_TxFilter.h"

View File

@ -130,10 +130,6 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
> >
<File
RelativePath="Ext_TxFilter.cpp"
>
</File>
<File <File
RelativePath="TextureFilters.cpp" RelativePath="TextureFilters.cpp"
> >

View File

@ -247,7 +247,6 @@ TxCache::save(const wchar_t *path, const wchar_t *filename, int config)
CHDIR(cbuf); CHDIR(cbuf);
#endif #endif
#ifdef tofix
wcstombs(cbuf, filename, MAX_PATH); wcstombs(cbuf, filename, MAX_PATH);
gzFile gzfp = gzopen(cbuf, "wb1"); gzFile gzfp = gzopen(cbuf, "wb1");
@ -312,7 +311,6 @@ TxCache::save(const wchar_t *path, const wchar_t *filename, int config)
} }
CHDIR(curpath); CHDIR(curpath);
#endif
} }
return _cache.empty(); return _cache.empty();
} }

View File

@ -273,37 +273,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint
blkrow = (srcheight >> 2) / numcore; blkrow = (srcheight >> 2) / numcore;
numcore--; numcore--;
} }
if (blkrow > 0 && numcore > 1) {
#ifdef tofix
boost::thread *thrd[MAX_NUMCORE];
unsigned int i;
int blkheight = blkrow << 2;
unsigned int srcStride = (srcwidth * blkheight) << 2;
unsigned int destStride = srcStride << scale_shift << scale_shift;
for (i = 0; i < numcore - 1; i++) {
thrd[i] = new boost::thread(boost::bind(filter_8888,
(uint32*)_texture,
srcwidth,
blkheight,
(uint32*)_tmptex,
filter));
_texture += srcStride;
_tmptex += destStride;
}
thrd[i] = new boost::thread(boost::bind(filter_8888,
(uint32*)_texture,
srcwidth,
srcheight - blkheight * i,
(uint32*)_tmptex,
filter));
for (i = 0; i < numcore; i++) {
thrd[i]->join();
delete thrd[i];
}
#endif
} else {
filter_8888((uint32*)_texture, srcwidth, srcheight, (uint32*)_tmptex, filter); filter_8888((uint32*)_texture, srcwidth, srcheight, (uint32*)_tmptex, filter);
}
if (filter & ENHANCEMENT_MASK) { if (filter & ENHANCEMENT_MASK) {
srcwidth <<= scale_shift; srcwidth <<= scale_shift;

View File

@ -167,224 +167,211 @@ TxHiResCache::load(boolean replace) /* 0 : reload, 1 : replace partial */
return 0; return 0;
} }
boolean boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
{ {
DBG_INFO(80, L"-----\n"); DBG_INFO(80, L"-----\n");
DBG_INFO(80, L"path: %s\n", dir_path); DBG_INFO(80, L"path: %s\n", stdstr(dir_path).ToUTF16().c_str());
// _asm int 3 CPath TextureDir(dir_path,"");
#ifdef tofix
/* find it on disk */
if (!boost::filesystem::exists(dir_path)) {
INFO(80, L"Error: path not found!\n");
return 0;
}
/* XXX: deal with UNICODE fiasco! /* find it on disk */
* stupidity flows forth beneath this... if (!TextureDir.DirectoryExists())
* {
* I opted to use chdir in order to use fopen() for windows 9x. INFO(80, L"Error: path not found!\n");
*/ return 0;
#ifdef WIN32 }
wchar_t curpath[MAX_PATH];
GETCWD(MAX_PATH, curpath);
CHDIR(dir_path.string().c_str());
#else
char curpath[MAX_PATH];
char cbuf[MAX_PATH];
wcstombs(cbuf, dir_path.string().c_str(), MAX_PATH);
GETCWD(MAX_PATH, curpath);
CHDIR(cbuf);
#endif
/* NOTE: I could use the boost::wdirectory_iterator and boost::wpath /* recursive read into sub-directory */
* to resolve UNICODE file names and paths. But then, _wfopen() is TextureDir.SetNameExtension("*.*");
* required to get the file descriptor for MS Windows to pass into if (TextureDir.FindFirst(_A_SUBDIR))
* libpng, which is incompatible with Win9x. Win9x's fopen() cannot {
* handle UNICODE names. UNICODE capable boost::filesystem is available do
* with Boost1.34.1 built with VC8.0 (bjam --toolset=msvc-8.0 stage). {
* loadHiResTextures(TextureDir, replace);
* RULE OF THUMB: NEVER save texture packs in NON-ASCII names!! } while (TextureDir.FindNext());
*/ }
boost::filesystem::wdirectory_iterator it(dir_path);
boost::filesystem::wdirectory_iterator end_it; /* default construction yields past-the-end */
for (; it != end_it; ++it) { TextureDir.SetNameExtension("*.*");
if (TextureDir.FindFirst())
{
do
{
if (KBHIT(0x1B)) {
_abortLoad = 1;
if (_callback) (*_callback)(L"Aborted loading hiresolution texture!\n");
INFO(80, L"Error: aborted loading hiresolution texture!\n");
}
if (_abortLoad) break;
if (KBHIT(0x1B)) { DBG_INFO(80, L"-----\n");
_abortLoad = 1; DBG_INFO(80, L"file: %ls\n", stdstr(TextureDir.GetNameExtension().c_str()).ToUTF16().c_str());
if (_callback) (*_callback)(L"Aborted loading hiresolution texture!\n");
INFO(80, L"Error: aborted loading hiresolution texture!\n");
}
if (_abortLoad) break;
/* recursive read into sub-directory */ int width = 0, height = 0;
if (boost::filesystem::is_directory(it->status())) { uint16 format = 0;
loadHiResTextures(it->path(), replace); uint8 *tex = NULL;
continue; int tmpwidth = 0, tmpheight = 0;
} uint16 tmpformat = 0;
uint8 *tmptex= NULL;
int untiled_width = 0, untiled_height = 0;
uint16 destformat = 0;
DBG_INFO(80, L"-----\n"); /* Rice hi-res textures: begin
DBG_INFO(80, L"file: %ls\n", it->path().leaf().c_str()); */
uint32 chksum = 0, fmt = 0, siz = 0, palchksum = 0;
char *pfname = NULL, fname[MAX_PATH];
std::string ident;
FILE *fp = NULL;
int width = 0, height = 0; wcstombs(fname, _ident.c_str(), MAX_PATH);
uint16 format = 0; /* XXX case sensitivity fiasco!
uint8 *tex = NULL; * files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci
int tmpwidth = 0, tmpheight = 0; * and file extensions must be in lower case letters! */
uint16 tmpformat = 0; #ifdef WIN32
uint8 *tmptex= NULL; {
int untiled_width = 0, untiled_height = 0; unsigned int i;
uint16 destformat = 0; for (i = 0; i < strlen(fname); i++) fname[i] = (char)tolower(fname[i]);
}
#endif
ident.assign(fname);
/* Rice hi-res textures: begin /* read in Rice's file naming convention */
*/ #define CRCFMTSIZ_LEN 13
uint32 chksum = 0, fmt = 0, siz = 0, palchksum = 0; #define PALCRC_LEN 9
char *pfname = NULL, fname[MAX_PATH]; wcstombs(fname, TextureDir.GetNameExtension().ToUTF16().c_str(), MAX_PATH);
std::string ident; /* XXX case sensitivity fiasco!
FILE *fp = NULL; * files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci
* and file extensions must be in lower case letters! */
#ifdef WIN32
{
unsigned int i;
for (i = 0; i < strlen(fname); i++) fname[i] = (char)tolower(fname[i]);
}
#endif
pfname = fname + strlen(fname) - 4;
if (!(pfname == strstr(fname, ".png") ||
pfname == strstr(fname, ".bmp") ||
pfname == strstr(fname, ".dds")))
{
#if !DEBUG
INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif
INFO(80, L"Error: not png or bmp or dds!\n");
continue;
}
pfname = strstr(fname, ident.c_str());
if (pfname != fname) pfname = 0;
if (pfname) {
if (sscanf(pfname + ident.size(), "#%08X#%01X#%01X#%08X", &chksum, &fmt, &siz, &palchksum) == 4)
pfname += (ident.size() + CRCFMTSIZ_LEN + PALCRC_LEN);
else if (sscanf(pfname + ident.size(), "#%08X#%01X#%01X", &chksum, &fmt, &siz) == 3)
pfname += (ident.size() + CRCFMTSIZ_LEN);
else
pfname = 0;
}
if (!pfname) {
#if !DEBUG
INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif
INFO(80, L"Error: not Rice texture naming convention!\n");
continue;
}
if (!chksum) {
#if !DEBUG
INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif
INFO(80, L"Error: crc32 = 0!\n");
continue;
}
wcstombs(fname, _ident.c_str(), MAX_PATH); /* check if we already have it in hires texture cache */
/* XXX case sensitivity fiasco! if (!replace) {
* files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci uint64 chksum64 = (uint64)palchksum;
* and file extensions must be in lower case letters! */ chksum64 <<= 32;
#ifdef WIN32 chksum64 |= (uint64)chksum;
{ if (TxCache::is_cached(chksum64)) {
unsigned int i; #if !DEBUG
for (i = 0; i < strlen(fname); i++) fname[i] = tolower(fname[i]); INFO(80, L"-----\n");
} INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
#endif INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
ident.assign(fname); #endif
INFO(80, L"Error: already cached! duplicate texture!\n");
continue;
}
}
/* read in Rice's file naming convention */ DBG_INFO(80, L"rom: %ls chksum:%08X %08X fmt:%x size:%x\n", _ident.c_str(), chksum, palchksum, fmt, siz);
#define CRCFMTSIZ_LEN 13
#define PALCRC_LEN 9
wcstombs(fname, it->path().leaf().c_str(), MAX_PATH);
/* XXX case sensitivity fiasco!
* files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci
* and file extensions must be in lower case letters! */
#ifdef WIN32
{
unsigned int i;
for (i = 0; i < strlen(fname); i++) fname[i] = tolower(fname[i]);
}
#endif
pfname = fname + strlen(fname) - 4;
if (!(pfname == strstr(fname, ".png") ||
pfname == strstr(fname, ".bmp") ||
pfname == strstr(fname, ".dds"))) {
#if !DEBUG
INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str());
#endif
INFO(80, L"Error: not png or bmp or dds!\n");
continue;
}
pfname = strstr(fname, ident.c_str());
if (pfname != fname) pfname = 0;
if (pfname) {
if (sscanf(pfname + ident.size(), "#%08X#%01X#%01X#%08X", &chksum, &fmt, &siz, &palchksum) == 4)
pfname += (ident.size() + CRCFMTSIZ_LEN + PALCRC_LEN);
else if (sscanf(pfname + ident.size(), "#%08X#%01X#%01X", &chksum, &fmt, &siz) == 3)
pfname += (ident.size() + CRCFMTSIZ_LEN);
else
pfname = 0;
}
if (!pfname) {
#if !DEBUG
INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str());
#endif
INFO(80, L"Error: not Rice texture naming convention!\n");
continue;
}
if (!chksum) {
#if !DEBUG
INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str());
#endif
INFO(80, L"Error: crc32 = 0!\n");
continue;
}
/* check if we already have it in hires texture cache */ /* Deal with the wackiness some texture packs utilize Rice format.
if (!replace) { * Read in the following order: _a.* + _rgb.*, _all.png _ciByRGBA.png,
uint64 chksum64 = (uint64)palchksum; * _allciByRGBA.png, and _ci.bmp. PNG are prefered over BMP.
chksum64 <<= 32; *
chksum64 |= (uint64)chksum; * For some reason there are texture packs that include them all. Some
if (TxCache::is_cached(chksum64)) { * even have RGB textures named as _all.* and ARGB textures named as
#if !DEBUG * _rgb.*... Someone pleeeez write a GOOD guideline for the texture
INFO(80, L"-----\n"); * designers!!!
INFO(80, L"path: %ls\n", dir_path.string().c_str()); *
INFO(80, L"file: %ls\n", it->path().leaf().c_str()); * We allow hires textures to have higher bpp than the N64 originals.
#endif */
INFO(80, L"Error: already cached! duplicate texture!\n"); /* N64 formats
continue; * Format: 0 - RGBA, 1 - YUV, 2 - CI, 3 - IA, 4 - I
} * Size: 0 - 4bit, 1 - 8bit, 2 - 16bit, 3 - 32 bit
} */
DBG_INFO(80, L"rom: %ls chksum:%08X %08X fmt:%x size:%x\n", _ident.c_str(), chksum, palchksum, fmt, siz); /*
* read in _rgb.* and _a.*
/* Deal with the wackiness some texture packs utilize Rice format. */
* Read in the following order: _a.* + _rgb.*, _all.png _ciByRGBA.png, if (pfname == strstr(fname, "_rgb.") || pfname == strstr(fname, "_a.")) {
* _allciByRGBA.png, and _ci.bmp. PNG are prefered over BMP. strcpy(pfname, "_rgb.png");
* CPath TargetFile(dir_path,fname);
* For some reason there are texture packs that include them all. Some if (!TargetFile.Exists())
* even have RGB textures named as _all.* and ARGB textures named as {
* _rgb.*... Someone pleeeez write a GOOD guideline for the texture strcpy(pfname, "_rgb.bmp");
* designers!!! TargetFile = CPath(dir_path,fname);
* if (!TargetFile.Exists())
* We allow hires textures to have higher bpp than the N64 originals. {
*/ #if !DEBUG
/* N64 formats INFO(80, L"-----\n");
* Format: 0 - RGBA, 1 - YUV, 2 - CI, 3 - IA, 4 - I INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
* Size: 0 - 4bit, 1 - 8bit, 2 - 16bit, 3 - 32 bit INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
*/ #endif
INFO(80, L"Error: missing _rgb.*! _a.* must be paired with _rgb.*!\n");
/* continue;
* read in _rgb.* and _a.* }
*/ }
if (pfname == strstr(fname, "_rgb.") || pfname == strstr(fname, "_a.")) { /* _a.png */
strcpy(pfname, "_rgb.png"); strcpy(pfname, "_a.png");
if (!boost::filesystem::exists(fname)) { TargetFile = CPath(dir_path,fname);
strcpy(pfname, "_rgb.bmp"); if ((fp = fopen(TargetFile, "rb")) != NULL) {
if (!boost::filesystem::exists(fname)) {
#if !DEBUG
INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str());
#endif
INFO(80, L"Error: missing _rgb.*! _a.* must be paired with _rgb.*!\n");
continue;
}
}
/* _a.png */
strcpy(pfname, "_a.png");
if ((fp = fopen(fname, "rb")) != NULL) {
tmptex = _txImage->readPNG(fp, &tmpwidth, &tmpheight, &tmpformat); tmptex = _txImage->readPNG(fp, &tmpwidth, &tmpheight, &tmpformat);
fclose(fp); fclose(fp);
} }
if (!tmptex) { if (!tmptex) {
/* _a.bmp */ /* _a.bmp */
strcpy(pfname, "_a.bmp"); strcpy(pfname, "_a.bmp");
if ((fp = fopen(fname, "rb")) != NULL) { TargetFile = CPath(dir_path,fname);
if ((fp = fopen(TargetFile, "rb")) != NULL) {
tmptex = _txImage->readBMP(fp, &tmpwidth, &tmpheight, &tmpformat); tmptex = _txImage->readBMP(fp, &tmpwidth, &tmpheight, &tmpformat);
fclose(fp); fclose(fp);
} }
} }
/* _rgb.png */ /* _rgb.png */
strcpy(pfname, "_rgb.png"); strcpy(pfname, "_rgb.png");
if ((fp = fopen(fname, "rb")) != NULL) { TargetFile = CPath(dir_path,fname);
if ((fp = fopen(TargetFile, "rb")) != NULL) {
tex = _txImage->readPNG(fp, &width, &height, &format); tex = _txImage->readPNG(fp, &width, &height, &format);
fclose(fp); fclose(fp);
} }
if (!tex) { if (!tex) {
/* _rgb.bmp */ /* _rgb.bmp */
strcpy(pfname, "_rgb.bmp"); strcpy(pfname, "_rgb.bmp");
if ((fp = fopen(fname, "rb")) != NULL) { TargetFile = CPath(dir_path,fname);
if ((fp = fopen(TargetFile, "rb")) != NULL) {
tex = _txImage->readBMP(fp, &width, &height, &format); tex = _txImage->readBMP(fp, &width, &height, &format);
fclose(fp); fclose(fp);
} }
@ -395,8 +382,8 @@ TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
format != GR_TEXFMT_ARGB_8888 || tmpformat != GR_TEXFMT_ARGB_8888) { format != GR_TEXFMT_ARGB_8888 || tmpformat != GR_TEXFMT_ARGB_8888) {
#if !DEBUG #if !DEBUG
INFO(80, L"-----\n"); INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str()); INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str()); INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif #endif
if (!tex) { if (!tex) {
INFO(80, L"Error: missing _rgb.*!\n"); INFO(80, L"Error: missing _rgb.*!\n");
@ -447,8 +434,8 @@ TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
/* clobber A comp. never a question of alpha. only RGB used. */ /* clobber A comp. never a question of alpha. only RGB used. */
#if !DEBUG #if !DEBUG
INFO(80, L"-----\n"); INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str()); INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str()); INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif #endif
INFO(80, L"Warning: missing _a.*! only using _rgb.*. treat as opaque texture.\n"); INFO(80, L"Warning: missing _a.*! only using _rgb.*. treat as opaque texture.\n");
int i; int i;
@ -477,7 +464,8 @@ TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
pfname == strstr(fname, "_ciByRGBA.dds") || pfname == strstr(fname, "_ciByRGBA.dds") ||
#endif #endif
pfname == strstr(fname, "_ci.bmp")) { pfname == strstr(fname, "_ci.bmp")) {
if ((fp = fopen(fname, "rb")) != NULL) { CPath TargetFile(dir_path,fname);
if ((fp = fopen(TargetFile, "rb")) != NULL) {
if (strstr(fname, ".png")) tex = _txImage->readPNG(fp, &width, &height, &format); if (strstr(fname, ".png")) tex = _txImage->readPNG(fp, &width, &height, &format);
else if (strstr(fname, ".dds")) tex = _txImage->readDDS(fp, &width, &height, &format); else if (strstr(fname, ".dds")) tex = _txImage->readDDS(fp, &width, &height, &format);
else tex = _txImage->readBMP(fp, &width, &height, &format); else tex = _txImage->readBMP(fp, &width, &height, &format);
@ -494,8 +482,8 @@ TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
tex = NULL; tex = NULL;
#if !DEBUG #if !DEBUG
INFO(80, L"-----\n"); INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str()); INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str()); INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif #endif
INFO(80, L"Error: W:H aspect ratio range not 8:1 - 1:8!\n"); INFO(80, L"Error: W:H aspect ratio range not 8:1 - 1:8!\n");
continue; continue;
@ -506,8 +494,8 @@ TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
tex = NULL; tex = NULL;
#if !DEBUG #if !DEBUG
INFO(80, L"-----\n"); INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str()); INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str()); INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif #endif
INFO(80, L"Error: not power of 2 size!\n"); INFO(80, L"Error: not power of 2 size!\n");
continue; continue;
@ -519,8 +507,8 @@ TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
if (!tex) { if (!tex) {
#if !DEBUG #if !DEBUG
INFO(80, L"-----\n"); INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str()); INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str()); INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif #endif
INFO(80, L"Error: load failed!\n"); INFO(80, L"Error: load failed!\n");
continue; continue;
@ -538,8 +526,8 @@ TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
tex = NULL; tex = NULL;
#if !DEBUG #if !DEBUG
INFO(80, L"-----\n"); INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str()); INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str()); INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif #endif
INFO(80, L"Error: not width * height > 4 or 8bit palette color or 32bpp or dxt1 or dxt3 or dxt5!\n"); INFO(80, L"Error: not width * height > 4 or 8bit palette color or 32bpp or dxt1 or dxt3 or dxt5!\n");
continue; continue;
@ -860,7 +848,6 @@ TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
* NOTE: texture size must be checked before expanding to pow2 size. * NOTE: texture size must be checked before expanding to pow2 size.
*/ */
) { ) {
uint32 alpha = 0;
int dataSize = 0; int dataSize = 0;
int compressionType = _options & COMPRESSION_MASK; int compressionType = _options & COMPRESSION_MASK;
@ -1017,8 +1004,8 @@ TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
if (!tex || !chksum || !width || !height || !format || width > _maxwidth || height > _maxheight) { if (!tex || !chksum || !width || !height || !format || width > _maxwidth || height > _maxheight) {
#if !DEBUG #if !DEBUG
INFO(80, L"-----\n"); INFO(80, L"-----\n");
INFO(80, L"path: %ls\n", dir_path.string().c_str()); INFO(80, L"path: %ls\n", stdstr(dir_path).ToUTF16().c_str());
INFO(80, L"file: %ls\n", it->path().leaf().c_str()); INFO(80, L"file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str());
#endif #endif
if (tex) { if (tex) {
free(tex); free(tex);
@ -1076,9 +1063,7 @@ TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
free(tex); free(tex);
} }
} } while (TextureDir.FindNext());
}
CHDIR(curpath);
#endif
return 1; return 1;
} }

View File

@ -1774,39 +1774,7 @@ TxQuantize::quantize(uint8* src, uint8* dest, int width, int height, uint16 srcf
blkrow = (height >> 2) / numcore; blkrow = (height >> 2) / numcore;
numcore--; numcore--;
} }
numcore = 1;
if (blkrow > 0 && numcore > 1) {
_asm int 3
#ifdef tofix
boost::thread *thrd[MAX_NUMCORE];
unsigned int i;
int blkheight = blkrow << 2;
unsigned int srcStride = (width * blkheight) << (2 - bpp_shift);
unsigned int destStride = srcStride << bpp_shift;
for (i = 0; i < numcore - 1; i++) {
thrd[i] = new boost::thread(boost::bind(quantizer,
this,
(uint32*)src,
(uint32*)dest,
width,
blkheight));
src += srcStride;
dest += destStride;
}
thrd[i] = new boost::thread(boost::bind(quantizer,
this,
(uint32*)src,
(uint32*)dest,
width,
height - blkheight * i));
for (i = 0; i < numcore; i++) {
thrd[i]->join();
delete thrd[i];
}
#endif
} else {
(*this.*quantizer)((uint32*)src, (uint32*)dest, width, height); (*this.*quantizer)((uint32*)src, (uint32*)dest, width, height);
}
} else if (srcformat == GR_TEXFMT_ARGB_8888) { } else if (srcformat == GR_TEXFMT_ARGB_8888) {
switch (destformat) { switch (destformat) {
@ -1838,45 +1806,7 @@ _asm int 3
default: default:
return 0; return 0;
} }
(*this.*quantizer)((uint32*)src, (uint32*)dest, width, height);
unsigned int numcore = _numcore;
unsigned int blkrow = 0;
while (numcore > 1 && blkrow == 0) {
blkrow = (height >> 2) / numcore;
numcore--;
}
if (blkrow > 0 && numcore > 1) {
_asm int 3
#ifdef tofix
boost::thread *thrd[MAX_NUMCORE];
unsigned int i;
int blkheight = blkrow << 2;
unsigned int srcStride = (width * blkheight) << 2;
unsigned int destStride = srcStride >> bpp_shift;
for (i = 0; i < numcore - 1; i++) {
thrd[i] = new boost::thread(boost::bind(quantizer,
this,
(uint32*)src,
(uint32*)dest,
width,
blkheight));
src += srcStride;
dest += destStride;
}
thrd[i] = new boost::thread(boost::bind(quantizer,
this,
(uint32*)src,
(uint32*)dest,
width,
height - blkheight * i));
for (i = 0; i < numcore; i++) {
thrd[i]->join();
delete thrd[i];
}
#endif
} else {
(*this.*quantizer)((uint32*)src, (uint32*)dest, width, height);
}
} else { } else {
return 0; return 0;
@ -1914,40 +1844,6 @@ TxQuantize::FXT1(uint8 *src, uint8 *dest,
blkrow = (srcheight >> 2) / numcore; blkrow = (srcheight >> 2) / numcore;
numcore--; numcore--;
} }
if (blkrow > 0 && numcore > 1) {
_asm int 3
#ifdef tofix
boost::thread *thrd[MAX_NUMCORE];
unsigned int i;
int blkheight = blkrow << 2;
unsigned int srcStride = (srcwidth * blkheight) << 2;
unsigned int destStride = dstRowStride * blkrow;
for (i = 0; i < numcore - 1; i++) {
thrd[i] = new boost::thread(boost::bind(_tx_compress_fxt1,
srcwidth,
blkheight,
4,
src,
srcRowStride,
dest,
dstRowStride));
src += srcStride;
dest += destStride;
}
thrd[i] = new boost::thread(boost::bind(_tx_compress_fxt1,
srcwidth,
srcheight - blkheight * i,
4,
src,
srcRowStride,
dest,
dstRowStride));
for (i = 0; i < numcore; i++) {
thrd[i]->join();
delete thrd[i];
}
#endif
} else {
(*_tx_compress_fxt1)(srcwidth, /* width */ (*_tx_compress_fxt1)(srcwidth, /* width */
srcheight, /* height */ srcheight, /* height */
4, /* comps: ARGB8888=4, RGB888=3 */ 4, /* comps: ARGB8888=4, RGB888=3 */
@ -1955,7 +1851,6 @@ _asm int 3
srcRowStride, /* width*comps */ srcRowStride, /* width*comps */
dest, /* destination */ dest, /* destination */
dstRowStride); /* 16 bytes per 8x4 texel */ dstRowStride); /* 16 bytes per 8x4 texel */
}
/* dxtn adjusts width and height to M8 and M4 respectively by replication */ /* dxtn adjusts width and height to M8 and M4 respectively by replication */
*destwidth = (srcwidth + 7) & ~7; *destwidth = (srcwidth + 7) & ~7;
@ -2023,40 +1918,6 @@ TxQuantize::DXTn(uint8 *src, uint8 *dest,
blkrow = (srcheight >> 2) / numcore; blkrow = (srcheight >> 2) / numcore;
numcore--; numcore--;
} }
if (blkrow > 0 && numcore > 1) {
_asm int 3
#ifdef tofix
boost::thread *thrd[MAX_NUMCORE];
unsigned int i;
int blkheight = blkrow << 2;
unsigned int srcStride = (srcwidth * blkheight) << 2;
unsigned int destStride = dstRowStride * blkrow;
for (i = 0; i < numcore - 1; i++) {
thrd[i] = new boost::thread(boost::bind(_tx_compress_dxtn,
4,
srcwidth,
blkheight,
src,
compression,
dest,
dstRowStride));
src += srcStride;
dest += destStride;
}
thrd[i] = new boost::thread(boost::bind(_tx_compress_dxtn,
4,
srcwidth,
srcheight - blkheight * i,
src,
compression,
dest,
dstRowStride));
for (i = 0; i < numcore; i++) {
thrd[i]->join();
delete thrd[i];
}
#endif
} else {
(*_tx_compress_dxtn)(4, /* comps: ARGB8888=4, RGB888=3 */ (*_tx_compress_dxtn)(4, /* comps: ARGB8888=4, RGB888=3 */
srcwidth, /* width */ srcwidth, /* width */
srcheight, /* height */ srcheight, /* height */
@ -2065,7 +1926,6 @@ _asm int 3
dest, /* destination */ dest, /* destination */
dstRowStride); /* DXT1 = 8 bytes per 4x4 texel dstRowStride); /* DXT1 = 8 bytes per 4x4 texel
* others = 16 bytes per 4x4 texel */ * others = 16 bytes per 4x4 texel */
}
/* dxtn adjusts width and height to M4 by replication */ /* dxtn adjusts width and height to M4 by replication */
*destwidth = (srcwidth + 3) & ~3; *destwidth = (srcwidth + 3) & ~3;