opengl renderer: added option to dump GL stream to file.

This is a debugging tool which enables to dump the guest
command stream to a file which can be later be examined
and "played" using a seperate tool.

Change-Id: I3fec19c1a651f0ed4394c33a0c0cd9ba54384355
This commit is contained in:
Guy Zadickario
2011-07-04 22:42:21 +03:00
parent ee85667135
commit 64f8ae0369

View File

@@ -56,6 +56,22 @@ int RenderThread::Main()
int stats_totalBytes = 0;
long long stats_t0 = GetCurrentTimeMS();
//
// open dump file if RENDER_DUMP_DIR is defined
//
const char *dump_dir = getenv("RENDERER_DUMP_DIR");
FILE *dumpFP = NULL;
if (dump_dir) {
size_t bsize = strlen(dump_dir) + 32;
char *fname = new char[bsize];
snprintf(fname,bsize,"%s/stream_%p", dump_dir, this);
dumpFP = fopen(fname, "wb");
if (!dumpFP) {
fprintf(stderr,"Warning: stream dump failed to open file %s\n",fname);
}
delete [] fname;
}
while (1) {
int stat = readBuf.getData();
@@ -76,6 +92,15 @@ int RenderThread::Main()
stats_t0 = GetCurrentTimeMS();
}
//
// dump stream to file if needed
//
if (dumpFP) {
int skip = readBuf.validData() - stat;
fwrite(readBuf.buf()+skip, 1, readBuf.validData()-skip, dumpFP);
fflush(dumpFP);
}
bool progress;
do {
progress = false;
@@ -112,5 +137,9 @@ int RenderThread::Main()
}
if (dumpFP) {
fclose(dumpFP);
}
return 0;
}