Benchmark option to disable video rendering fully

This commit is contained in:
Jeffrey Pfau 2014-07-24 03:23:41 -07:00
parent 8e49360ffd
commit a701a6d9dd
1 changed files with 14 additions and 6 deletions

View File

@ -7,18 +7,20 @@
#include <signal.h> #include <signal.h>
#include <sys/time.h> #include <sys/time.h>
#define PERF_OPTIONS "S:" #define PERF_OPTIONS "NS:"
#define PERF_USAGE \ #define PERF_USAGE \
"\nBenchmark options:\n" \ "\nBenchmark options:\n" \
" -N Disable video rendering entirely" \
" -S SEC Run for SEC in-game seconds before exiting" " -S SEC Run for SEC in-game seconds before exiting"
struct PerfOpts { struct PerfOpts {
bool noVideo;
int duration; int duration;
}; };
static void _GBAPerfRunloop(struct GBAThread* context, int* frames); static void _GBAPerfRunloop(struct GBAThread* context, int* frames);
static void _GBAPerfShutdown(int signal); static void _GBAPerfShutdown(int signal);
static int _parsePerfOpts(struct SubParser* parser, int option, const char* arg); static bool _parsePerfOpts(struct SubParser* parser, int option, const char* arg);
static struct GBAThread* _thread; static struct GBAThread* _thread;
@ -28,7 +30,7 @@ int main(int argc, char** argv) {
struct GBAVideoSoftwareRenderer renderer; struct GBAVideoSoftwareRenderer renderer;
GBAVideoSoftwareRendererCreate(&renderer); GBAVideoSoftwareRendererCreate(&renderer);
struct PerfOpts perfOpts = { 0 }; struct PerfOpts perfOpts = { false, 0 };
struct SubParser subparser = { struct SubParser subparser = {
.usage = PERF_USAGE, .usage = PERF_USAGE,
.parse = _parsePerfOpts, .parse = _parsePerfOpts,
@ -46,12 +48,15 @@ int main(int argc, char** argv) {
renderer.outputBufferStride = 256; renderer.outputBufferStride = 256;
struct GBAThread context = { struct GBAThread context = {
.renderer = &renderer.d,
.sync.videoFrameWait = 0, .sync.videoFrameWait = 0,
.sync.audioWait = 0 .sync.audioWait = 0
}; };
_thread = &context; _thread = &context;
if (!perfOpts.noVideo) {
context.renderer = &renderer.d;
}
context.debugger = createDebugger(&opts); context.debugger = createDebugger(&opts);
GBAMapOptionsToContext(&opts, &context); GBAMapOptionsToContext(&opts, &context);
@ -113,13 +118,16 @@ static void _GBAPerfShutdown(int signal) {
pthread_mutex_unlock(&_thread->stateMutex); pthread_mutex_unlock(&_thread->stateMutex);
} }
static int _parsePerfOpts(struct SubParser* parser, int option, const char* arg) { static bool _parsePerfOpts(struct SubParser* parser, int option, const char* arg) {
struct PerfOpts* opts = parser->opts; struct PerfOpts* opts = parser->opts;
switch (option) { switch (option) {
case 'N':
opts->noVideo = true;
return true;
case 'S': case 'S':
opts->duration = strtol(arg, 0, 10); opts->duration = strtol(arg, 0, 10);
return !errno; return !errno;
default: default:
return 0; return false;
} }
} }