OpenArena Message Boards

OpenArena Contributions => Development => Topic started by: kanzaki on January 01, 2008, 03:12:00 AM

Title: Need a little help with rendering engine
Post by: kanzaki on January 01, 2008, 03:12:00 AM
Hey everyone,

I'm working on a school project that has got something to do with profiling performance of first person shooters.

What I've done so far is insert a few bits of code in the OpenArena engine rendering loop and output onto the console the number of cycles it takes to process a frame (or at least I hope that's what it does!)

snippet in tr_backend.c :
void RB_ExecuteRenderCommands( const void *data ) {
int t1, t2;
unsigned long long a,b;

t1 = ri.Milliseconds ();
a = rdtsc();                                   //this function is defined elsewhere

if ( !r_smp->integer || data == backEndData[0]->commands.cmds ) {
backEnd.smpFrame = 0;
        case RC_END_OF_LIST:
// stop rendering on this thread
b = rdtsc();                 //i assume this is where the processing ends
t2 = ri.Milliseconds ();
backEnd.pc.msec = t2 - t1;
ri.Printf( PRINT_ALL, "time: %llu\n", b - a ); //print difference

The next step is to some how output these numbers into a file for further analysis and I'm stuck on that. The idea is instead of printing it on the console we should write it to a file. I've tried a few of the FS_WriteFile methods but nothing seems to work. I'm not very familiar with C ("grew up" with java) and I'm not sure whether plain C file-write functions will work when it gets compiled into the qvm.

I've tried condumping but i think the console buffer is limited and can't capture the length of the entire demo I'm trying profile. One idea is to try and extend this buffersize but I'm still trying to locate where this variable is stored. Any help here would be appreciated.

So what I'm asking is can someone give me some idea where are some of inbuilt functions in the quake program that can help me accomplish what i'm trying to do. I've been looking through the source code for a while but it's quite mind-boggling, especially when I'm not familiar with the C paradigm. I noticed that the game logs some of the console commands and game information in a 'q3history' and 'games.log' file and I was hoping I could make use of that part of the code. But I can't seem to find which part of the source that handles this!

Any help would be appreciated. The deadline's coming up soon. -_-. Thanks and Happy new year.

Title: Re: Need a little help with rendering engine
Post by: dmn_clown on January 03, 2008, 12:44:04 PM
Use Beast's doxygen doc's:

Title: Re: Need a little help with rendering engine
Post by: kanzaki on January 04, 2008, 07:03:47 AM
oh yeah i've been using the doxygen as well as the hobbshouse lxr. Managed to get the printing done (used FS_printf. Didn't these methods were global, as in, i could use it like that in the rendering engine. Well, now it's printing, but somehow it conflicts with one of the engine's logging methods. Logging messages that are supposed to go to games.log go end up in my specified log file instead (and causing the game to hang when shutting down). But I hope I can figure that one out soon.