Reorderes statistics a bit.

This commit is contained in:
Federico Ponchio 2005-02-17 15:39:44 +00:00
parent 12258dcd25
commit 5fb9d84548
5 changed files with 185 additions and 111 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.29 2005/02/14 17:11:07 ponchio
aggiunta delle sphere
Revision 1.28 2005/02/08 12:43:03 ponchio Revision 1.28 2005/02/08 12:43:03 ponchio
Added copyright Added copyright
@ -47,15 +50,25 @@ using namespace nxs;
using namespace vcg; using namespace vcg;
using namespace std; using namespace std;
void Stats::Init() { void Stats::Start() {
ktri = 0; tri = extr = 0;
kdisk = 0; watch.Start();
if(count == 25) count = 0; }
if(!count) {
fps = 25/watch.Time(); void Stats::Disk(float _disk) {
watch.Start(); disk.push_front(_disk);
} if(disk.size() > log_size) disk.pop_back();
count++; }
void Stats::Error(float _error) {
error.push_front(_error);
if(error.size() > log_size) error.pop_back();
}
void Stats::Stop() {
time.push_front((float)watch.Time());
if(time.size() > log_size) time.pop_back();
fps = (7*fps + 1/time[0])/8.0f;
} }
NexusMt::NexusMt() { NexusMt::NexusMt() {
@ -117,7 +130,6 @@ void NexusMt::Render(DrawContest contest) {
void NexusMt::Render(Extraction &extraction, DrawContest &contest, void NexusMt::Render(Extraction &extraction, DrawContest &contest,
Stats *stats) { Stats *stats) {
static ::GLUquadricObj * spr = gluNewQuadric(); static ::GLUquadricObj * spr = gluNewQuadric();
if(stats) stats->Init();
for(unsigned int i = 0; i < heap.size(); i++) { for(unsigned int i = 0; i < heap.size(); i++) {
Item &item = heap[i]; Item &item = heap[i];
@ -142,20 +154,13 @@ void NexusMt::Render(Extraction &extraction, DrawContest &contest,
unsigned int patch = extraction.selected[i].id; unsigned int patch = extraction.selected[i].id;
Entry &entry = operator[](patch); Entry &entry = operator[](patch);
vcg::Sphere3f &sphere = entry.sphere; vcg::Sphere3f &sphere = entry.sphere;
if(stats) stats->extr += entry.nface;
if(extraction.frustum.IsOutside(sphere.Center(), sphere.Radius())) if(extraction.frustum.IsOutside(sphere.Center(), sphere.Radius()))
continue; continue;
if(contest.attrs & DrawContest::SPHERES){ if(stats) stats->tri += entry.nface;
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glPushMatrix();
glTranslatef(sphere.Center().X(),sphere.Center().Y(),sphere.Center().Z());
gluSphere(spr,sphere.Radius(),15,15);
glPopMatrix();
glPopAttrib();
}
if(stats) stats->ktri += entry.nface;
if(!entry.patch) { if(!entry.patch) {
skipped.push_back(extraction.selected[i]); skipped.push_back(extraction.selected[i]);
@ -168,13 +173,21 @@ void NexusMt::Render(Extraction &extraction, DrawContest &contest,
preload.trigger.reset(); preload.trigger.reset();
preload.lock.enter(); preload.lock.enter();
if(skipped.size()) cerr << "Skipped: " << skipped.size() << endl; // if(skipped.size()) cerr << "Skipped: " << skipped.size() << endl;
for(vector<Item>::iterator i = skipped.begin(); i != skipped.end(); i++) { for(vector<Item>::iterator i = skipped.begin(); i != skipped.end(); i++) {
GetPatch((*i).id, (*i).error); GetPatch((*i).id, (*i).error);
Draw((*i).id, contest); Draw((*i).id, contest);
} }
Flush(false); //in case there are no skipped... :P Flush(false); //in case there are no skipped... :P
if(stats) {
stats->Error(extraction.max_error);
stats->Disk(preload.disk);
preload.disk = 0;
}
preload.trigger.post(); preload.trigger.post();
preload.lock.leave(); preload.lock.leave();
@ -185,13 +198,27 @@ void NexusMt::Render(Extraction &extraction, DrawContest &contest,
glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_NORMAL_ARRAY);
} }
void NexusMt::Draw(unsigned int cell, DrawContest &contest) { void NexusMt::Draw(unsigned int cell, DrawContest &contest) {
static ::GLUquadricObj * spr = gluNewQuadric();
Entry &entry = operator[](cell); Entry &entry = operator[](cell);
Patch &patch = *(entry.patch); Patch &patch = *(entry.patch);
char *fstart; char *fstart;
char *vstart; char *vstart;
char *cstart; char *cstart;
char *nstart; char *nstart;
if(contest.attrs & DrawContest::SPHERES){
vcg::Sphere3f &sphere = entry.sphere;
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glPushMatrix();
glTranslatef(sphere.Center().X(),sphere.Center().Y(),sphere.Center().Z());
gluSphere(spr,sphere.Radius(),15,15);
glPopMatrix();
glPopAttrib();
}
if(use_vbo) { if(use_vbo) {
if(!entry.vbo_element) if(!entry.vbo_element)
@ -215,7 +242,9 @@ void NexusMt::Draw(unsigned int cell, DrawContest &contest) {
if(contest.attrs & DrawContest::COLOR) if(contest.attrs & DrawContest::COLOR)
glColorPointer(4, GL_UNSIGNED_BYTE, 0, cstart); glColorPointer(4, GL_UNSIGNED_BYTE, 0, cstart);
if(contest.attrs & DrawContest::NORMAL) if(contest.attrs & DrawContest::NORMAL)
glNormalPointer(GL_SHORT, 8, nstart); glNormalPointer(GL_SHORT, 8, nstart);
switch(contest.mode) { switch(contest.mode) {
case DrawContest::POINTS: case DrawContest::POINTS:

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.23 2005/02/14 17:11:07 ponchio
aggiunta delle sphere
Revision 1.22 2005/02/10 09:18:20 ponchio Revision 1.22 2005/02/10 09:18:20 ponchio
Statistics. Statistics.
@ -63,20 +66,25 @@ namespace nxs {
}; };
struct Stats { struct Stats {
float ktri; //k triangles rendered. //per frame data...
float kdisk; //k readed per frame (mean) float tri; //k triangles rendered.
float kdisk_peak; //k readed peak. float extr; //k triangles extracted
float fps;
float fps_peak; //low fps peaks
float error; //max error in extraction int log_size;
//double last_time;
unsigned int count; deque<float> error; //max error in extraction (push_front pop_back)
deque<float> time;
deque<float> disk; //kdisk readed per frame
float fps; //averaged over 8 frames
Watch watch; Watch watch;
Stats(): count(0) {} Stats(): log_size(48), fps(0.0f) {}
void Init(); void Start();
void Disk(float disk);
void Error(float error);
void Stop();
}; };
class NexusMt: public Nexus { class NexusMt: public Nexus {

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.39 2005/02/17 14:02:03 ponchio
Full screen options...
Revision 1.38 2005/02/16 15:52:09 ponchio Revision 1.38 2005/02/16 15:52:09 ponchio
qualche opzione in piu' , tolti i grafici qualche opzione in piu' , tolti i grafici
@ -242,13 +245,16 @@ int main(int argc, char *argv[]) {
if(argc < 2) { if(argc < 2) {
cerr << "Usage: " << argv[0] << " <nexus file> [options]\n"; cerr << "Usage: " << argv[0] << " <nexus file> [options]\n";
cerr << "-e <error>: set initial target error\n" cerr << "-e <error> : set initial target error\n"
<< "-m <ram>: max ram used\n" << "-m <ram> : max ram used\n"
<< "-x <ram>: max extraction size\n" << "-x <ram> : max extraction size\n"
<< "-r <ram>: max draw size\n" << "-r <ram> : max draw size\n"
<< "-d <ram>: max disk read per frame\n" << "-d <ram> : max disk read per frame\n"
<< "-p : no preload\n" << "-p : no preload\n"
<< "-o namefile: ouput stats"; << "-w <pixels>: window width\n"
<< "-h <pixels>: window height\n"
<< "-f : fullscreen mode\n"
<< "-o namefile: ouput stats";
return -1; return -1;
} }
@ -262,7 +268,7 @@ int main(int argc, char *argv[]) {
Extraction extraction; Extraction extraction;
DrawContest contest; DrawContest contest;
Stats stats; Stats stats;
stats.Start();
bool rotate = false; bool rotate = false;
@ -274,11 +280,13 @@ int main(int argc, char *argv[]) {
bool extract = true; bool extract = true;
bool realtime = true; bool realtime = true;
bool preload = true; bool preload = true;
bool step = true;
bool output_stats = false; bool output_stats = false;
char output_filename[100]; char output_filename[100];
char window_name [100]; char window_name [100];
sprintf(window_name,"%s", argv[1]); sprintf(window_name,"%s", argv[1]);
int option; int option;
while((option = getopt(argc, argv, "e:m:x:r:d:o:w:h:p:f")) != EOF) { while((option = getopt(argc, argv, "e:m:x:r:d:o:w:h:p:f")) != EOF) {
switch(option) { switch(option) {
@ -491,7 +499,7 @@ int main(int argc, char *argv[]) {
float r = nexus.sphere.Radius(); float r = nexus.sphere.Radius();
glColor3f(0.8f, 0.8f, 0.8f); glColor3f(0.8f, 0.8f, 0.8f);
if(extract) { if(extract) {
extraction.frustum.GetView(); extraction.frustum.GetView();
extraction.metric->GetView(); extraction.metric->GetView();
@ -501,11 +509,13 @@ int main(int argc, char *argv[]) {
extraction.Update(&nexus); extraction.Update(&nexus);
} }
} }
if(do_render) stats.Stop();
nexus.Render(extraction, contest, &stats); stats.Start();
else if(do_render)
stats.Init(); nexus.Render(extraction, contest, &stats);
/* if(show_borders) { /* if(show_borders) {
for(unsigned int i = 0; i < cells.size(); i++) { for(unsigned int i = 0; i < cells.size(); i++) {
Border &border = nexus.GetBorder(cells[i]); Border &border = nexus.GetBorder(cells[i]);
@ -525,7 +535,7 @@ int main(int argc, char *argv[]) {
tframe.push_front(watch.Time()); tframe.push_front(watch.Time());
if(tframe.size() > tlen) tframe.pop_back(); if(tframe.size() > tlen) tframe.pop_back();
terror.push_front(extraction.max_error); terror.push_front(extraction.max_error);
if(terror.size() > tlen) terror.pop_back(); if(terror.size() > tlen) terror.pop_back();
@ -541,39 +551,42 @@ int main(int argc, char *argv[]) {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
char buffer[1024];
//show frame and error graphics
if(false){ if(false){
glColor4f(0.6f, 0.6f, 0.6f, 0.5f); glColor4f(0.6f, 0.6f, 0.6f, 0.5f);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
for(unsigned int i = 0; i < tframe.size() -1; i++) { for(unsigned int i = 0; i < tframe.size() -1; i++) {
double diff = (tframe[i] - tframe[i+1]); double diff = (tframe[i] - tframe[i+1]);
//glVertex2f(i/1024.0f,0); //glVertex2f(i/1024.0f,0);
glVertex2f(i/1024.0f,2*diff); glVertex2f(i/1024.0f,2*diff);
}
glEnd();
glColor4f(0.0f, 0.6f, 0.2f, 0.5f);
glBegin(GL_LINE_STRIP);
for(unsigned int i = 0; i < terror.size() -1; i++) {
// glVertex2f(i/1024.0f,0);
glVertex2f(i/1024.0f,terror[i]/300);
}
glEnd();
} }
glEnd();
glColor4f(0.0f, 0.6f, 0.2f, 0.5f);
glBegin(GL_LINE_STRIP);
for(unsigned int i = 0; i < terror.size() -1; i++) {
// glVertex2f(i/1024.0f,0);
glVertex2f(i/1024.0f,terror[i]/300);
}
glEnd();
}
glColor3f(1.0f, 1.0f, 1.0f); glColor3f(1.0f, 1.0f, 1.0f);
char buffer[1024];
sprintf(buffer, "Ram size : %.2f / %.2f Mb", sprintf(buffer, "Ram size : %.2f / %.2f Mb",
nexus.ram_used * nexus.chunk_size/(float)(1<<20), nexus.ram_used * nexus.chunk_size/(float)(1<<20),
nexus.ram_max * nexus.chunk_size/(float)(1<<20)); nexus.ram_max * nexus.chunk_size/(float)(1<<20));
gl_print(0.03, 0.15, buffer); gl_print(0.03, 0.15, buffer);
sprintf(buffer, "Extr size: %.2f / %.2f Mb", sprintf(buffer, "Extr size: %.2f / %.2f Mb",
extraction.extr_used * nexus.chunk_size/(float)(1<<20), extraction.extr_used * nexus.chunk_size/(float)(1<<20),
extraction.extr_max * nexus.chunk_size/(float)(1<<20)); extraction.extr_max * nexus.chunk_size/(float)(1<<20));
gl_print(0.03, 0.12, buffer); gl_print(0.03, 0.12, buffer);
sprintf(buffer, "Draw size: %.2f / %.2f Mb", sprintf(buffer, "Draw size: %.2f / %.2f Mb",
extraction.draw_used * nexus.chunk_size/(float)(1<<20), extraction.draw_used * nexus.chunk_size/(float)(1<<20),
extraction.draw_max * nexus.chunk_size/(float)(1<<20)); extraction.draw_max * nexus.chunk_size/(float)(1<<20));
@ -585,8 +598,8 @@ int main(int argc, char *argv[]) {
gl_print(0.03, 0.06, buffer); gl_print(0.03, 0.06, buffer);
sprintf(buffer, "%.2f KTri %.2f FPS %.0f M/s", sprintf(buffer, "%.2f KTri %.2f FPS %.0f M/s",
stats.ktri/(float)(1<<10), stats.tri/(float)(1<<10),
stats.fps, stats.fps * stats.ktri/(float)(1<<20)); stats.fps, stats.fps * stats.tri/(float)(1<<20));
gl_print(0.03, 0.03, buffer); gl_print(0.03, 0.03, buffer);
@ -595,50 +608,53 @@ int main(int argc, char *argv[]) {
glPopMatrix(); glPopMatrix();
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPopMatrix(); glPopMatrix();
/* statistics: output on file
if(output_stats){ if(output_stats){
// statistics: output on file
static Stats statsAcc; static Stats statsAcc;
static float ram_used ,float extr_used, float draw_used ,float disk_used; static float ram_used;
static std::ofstream outf(output_filename); static float extr_used;
static bool first=true; static float draw_used;
if(first) { static float disk_used;
outf<< "ktri\t fps\t ram \t extr \t draw \t disk \n" static std::ofstream outf(output_filename);
<< " \t \t" << nexus.ram_max * nexus.chunk_size/(float)(1<<20) << "\t" static bool first=true;
if(first) {
outf<< "ktri\t fps\t ram \t extr \t draw \t disk \n"
<< " \t \t"
<< nexus.ram_max * nexus.chunk_size/(float)(1<<20) << "\t"
<< extraction.extr_max * nexus.chunk_size/(float)(1<<20) << "\t" << extraction.extr_max * nexus.chunk_size/(float)(1<<20) << "\t"
<< extraction.draw_max * nexus.chunk_size/(float)(1<<20)<<"\t" << extraction.draw_max * nexus.chunk_size/(float)(1<<20)<<"\t"
<< extraction.disk_max * nexus.chunk_size/(float)(1<<20)<< "\n"; << extraction.disk_max * nexus.chunk_size/(float)(1<<20)<< "\n";
first = false; first = false;
} }
statsAcc.count++ ;
if((statsAcc.count%30)==0) { statsAcc.count++ ;
outf if((statsAcc.count%30)==0) {
<< (statsAcc.ktri/(float)statsAcc.count)/(float)(1<<10) << "\t" outf
<< (statsAcc.fps/(float)statsAcc.count) << "\t" << (statsAcc.tri/(float)statsAcc.count)/(float)(1<<10) << "\t"
// << (statsAcc.kdisk/(float)statsAcc.count) << "\t" << (statsAcc.fps/(float)statsAcc.count) << "\t"
<< ram_used /(float)statsAcc.count * nexus.chunk_size/(float)(1<<20) << "\t" // << (statsAcc.kdisk/(float)statsAcc.count) << "\t"
<< extr_used/(float)statsAcc.count * nexus.chunk_size/(float)(1<<20) << "\t" << ram_used/(float)statsAcc.count*nexus.chunk_size/(float)(1<<20) << "\t"
<< draw_used/(float)statsAcc.count * nexus.chunk_size/(float)(1<<20) << "\t" << extr_used/(float)statsAcc.count*nexus.chunk_size/(float)(1<<20) << "\t"
<< disk_used/(float)statsAcc.count * nexus.chunk_size/(float)(1<<20) << "\t" << draw_used/(float)statsAcc.count*nexus.chunk_size/(float)(1<<20) << "\t"
<< "\n"; << disk_used/(float)statsAcc.count*nexus.chunk_size/(float)(1<<20) << "\t"
statsAcc.Init(); << "\n";
statsAcc.count=0; statsAcc.Init();
statsAcc.fps=0; statsAcc.count = 0;
ram_used = extr_used= draw_used = disk_used=0.0; statsAcc.fps = 0;
} ram_used = extr_used = draw_used = disk_used = 0.0;
else{ } else {
statsAcc.fps+=stats.fps; statsAcc.fps += stats.fps;
statsAcc.kdisk+=stats.kdisk; statsAcc.kdisk += stats.kdisk;
statsAcc.ktri+=stats.ktri; statsAcc.ktri += stats.ktri;
ram_used +=nexus.ram_used; ram_used += nexus.ram_used;
extr_used+=extraction.extr_used; extr_used += extraction.extr_used;
draw_used+=extraction.draw_used; draw_used += extraction.draw_used;
disk_used+=extraction.disk_used; disk_used += extraction.disk_used;
} }
}*/
}
} }
SDL_GL_SwapBuffers(); SDL_GL_SwapBuffers();

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.6 2005/02/08 12:43:03 ponchio
Added copyright
****************************************************************************/ ****************************************************************************/
@ -35,6 +38,10 @@ using namespace std;
using namespace nxs; using namespace nxs;
void Preload::execute() { void Preload::execute() {
total_disk = 0;
disk = 0;
assert(mt); assert(mt);
while(!get_signaled()) { while(!get_signaled()) {
trigger.wait(); trigger.wait();
@ -51,7 +58,16 @@ using namespace nxs;
if(item.error == 0 || mt->CanAdd(item)) { if(item.error == 0 || mt->CanAdd(item)) {
//we cannot flush since we are not in the openGL thread //we cannot flush since we are not in the openGL thread
//and flushing includes VBO buffer flushing also. //and flushing includes VBO buffer flushing also.
mt->GetPatch(item.id, item.error, false); Entry &entry = (*mt)[item.id];
if(!entry.patch)
disk += entry.disk_size;
Patch &patch = mt->GetPatch(item.id, item.error, false);
//test... make sure memory is in ram (if not on vbo that is.
if(!entry.vbo_array)
total_disk += patch.Face(0)[0];
queue.pop_back(); queue.pop_back();
} else } else
queue.clear(); queue.clear();

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.4 2005/02/08 12:43:03 ponchio
Added copyright
****************************************************************************/ ****************************************************************************/
@ -52,6 +55,8 @@ class Preload: public pt::thread{
std::vector<Item> queue; std::vector<Item> queue;
unsigned int disk; //kbytes readed from disk
unsigned int total_disk;
Preload(): thread(false), trigger(false, false) {} Preload(): thread(false), trigger(false, false) {}
~Preload() { ~Preload() {
waitfor(); waitfor();