Add command line flags to choose between whether or not to use PVRTexLib or FasTC

This commit is contained in:
Pavel Krajcevski 2013-09-30 12:46:23 -04:00
parent 219777687f
commit ce7bb8e891
4 changed files with 49 additions and 19 deletions

View File

@ -101,6 +101,7 @@ int main(int argc, char **argv) {
bool bUseSIMD = false;
bool bSaveLog = false;
bool bUseAtomics = false;
bool bUsePVRTexLib = false;
ECompressionFormat format = eCompressionFormat_BPTC;
bool knowArg = false;
@ -129,6 +130,9 @@ int main(int argc, char **argv) {
} else {
if(!strcmp(argv[fileArg], "PVRTC")) {
format = eCompressionFormat_PVRTC;
} else if(!strcmp(argv[fileArg], "PVRTCLib")) {
format = eCompressionFormat_PVRTC;
bUsePVRTexLib = true;
}
}
@ -235,6 +239,7 @@ int main(int argc, char **argv) {
settings.iQuality = quality;
settings.iNumCompressions = numCompressions;
settings.iJobSize = numJobs;
settings.bUsePVRTexLib = bUsePVRTexLib;
if(bSaveLog) {
settings.logStream = &logStream;
} else {

View File

@ -105,12 +105,26 @@ int _tmain(int argc, _TCHAR* argv[])
bool bUseSIMD = false;
bool bSaveLog = false;
bool bUseAtomics = false;
bool bUsePVRTexLib = false;
ECompressionFormat format = eCompressionFormat_BPTC;
bool knowArg = false;
do {
knowArg = false;
if(strcmp(argv[fileArg], "-n") == 0) {
fileArg++;
if(fileArg == argc || (numCompressions = atoi(argv[fileArg])) < 0) {
PrintUsage();
exit(1);
}
fileArg++;
knowArg = true;
continue;
}
if(strcmp(argv[fileArg], "-f") == 0) {
fileArg++;
@ -120,6 +134,9 @@ int _tmain(int argc, _TCHAR* argv[])
} else {
if(!strcmp(argv[fileArg], "PVRTC")) {
format = eCompressionFormat_PVRTC;
} else if(!strcmp(argv[fileArg], "PVRTCLib")) {
format = eCompressionFormat_PVRTC;
bUsePVRTexLib = true;
}
}
@ -128,19 +145,6 @@ int _tmain(int argc, _TCHAR* argv[])
continue;
}
if(strcmp(argv[fileArg], "-n") == 0) {
fileArg++;
if(fileArg == argc || (numCompressions = atoi(argv[fileArg])) < 0) {
PrintUsage();
exit(1);
}
fileArg++;
knowArg = true;
continue;
}
if(strcmp(argv[fileArg], "-l") == 0) {
fileArg++;
bSaveLog = true;
@ -200,6 +204,7 @@ int _tmain(int argc, _TCHAR* argv[])
knowArg = true;
continue;
}
} while(knowArg && fileArg < argc);
if(fileArg == argc) {
@ -238,10 +243,12 @@ int _tmain(int argc, _TCHAR* argv[])
settings.iQuality = quality;
settings.iNumCompressions = numCompressions;
settings.iJobSize = numJobs;
if(bSaveLog)
settings.bUsePVRTexLib = bUsePVRTexLib;
if(bSaveLog) {
settings.logStream = &logStream;
else
} else {
settings.logStream = NULL;
}
CompressedImage *ci = CompressImage(&img, settings);
if(NULL == ci) {
@ -268,8 +275,8 @@ int _tmain(int argc, _TCHAR* argv[])
// Cleanup
delete ci;
if(bSaveLog)
if(bSaveLog) {
logFile.close();
}
return 0;
}

View File

@ -86,6 +86,11 @@ struct SCompressionSettings {
// in the platform and compiler will provide synchronization.
bool bUseAtomics;
// This flag instructs the infrastructure to use the compression routine from
// PVRTexLib. If no such lib is found during configuration then this flag is
// ignored. The quality being used is the fastest compression quality.
bool bUsePVRTexLib;
// This is the output stream with which we should output the logs for the
// compression functions.
std::ostream *logStream;

View File

@ -73,6 +73,15 @@ static void CompressPVRTC(const CompressionJob &cj) {
PVRTCC::Compress(cj);
}
static void CompressPVRTCLib(const CompressionJob &cj) {
#ifdef PVRTEXLIB_FOUND
PVRTCC::CompressPVRLib(cj);
#else
fprintf(stderr, "WARNING: PVRTexLib not found, defaulting to FasTC implementation.\n");
PVRTCC::Compress(cj);
#endif
}
SCompressionSettings:: SCompressionSettings()
: format(eCompressionFormat_BPTC)
, bUseSIMD(false)
@ -122,8 +131,12 @@ static CompressionFunc ChooseFuncFromSettings(const SCompressionSettings &s) {
case eCompressionFormat_PVRTC:
{
if(s.bUsePVRTexLib) {
return CompressPVRTCLib;
} else {
return CompressPVRTC;
}
}
default:
{