Optimizing realtime vis.
This commit is contained in:
parent
b2f3d4f49e
commit
45154f0716
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include "pserver.h"
|
||||
|
||||
namespace nxs {
|
||||
|
|
@ -29,8 +30,9 @@ class LruPServer: public PServer {
|
|||
return *((*i).second);
|
||||
} else {
|
||||
while(ram_used > ram_max) {
|
||||
index.erase(items.back().first);
|
||||
FlushPatch(patch, items.back().second);
|
||||
Item item = items.back();
|
||||
index.erase(item.first);
|
||||
FlushPatch(item.first, item.second);
|
||||
items.pop_back();
|
||||
}
|
||||
Item item;
|
||||
|
|
|
|||
|
|
@ -65,8 +65,11 @@ bool NexusMt::Expand(TNode &tnode) {
|
|||
//expand if node error > target error
|
||||
if(extraction_used >= extraction_max) return false;
|
||||
if(draw_used >= draw_max) return false;
|
||||
if(disk_used >= disk_max) return false;
|
||||
|
||||
if(disk_used >= disk_max) {
|
||||
float ratio = disk_max / (float)disk_used;
|
||||
float error = tnode.error * ratio;
|
||||
return error > target_error;
|
||||
}
|
||||
return tnode.error > target_error;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.26 2004/12/15 13:50:32 ponchio
|
||||
Optimizing realtime vis.
|
||||
|
||||
Revision 1.25 2004/12/15 08:46:16 ponchio
|
||||
Optimizing realtime vis.
|
||||
|
||||
|
|
@ -459,8 +462,9 @@ int main(int argc, char *argv[]) {
|
|||
nexus.patches.ram_used * nexus.chunk_size/(float)(1<<20));
|
||||
gl_print(0.03, 0.09, buffer);
|
||||
|
||||
sprintf(buffer, "Vbo size : %.3fMb(cur)",
|
||||
nexus.patches.vbo_used * nexus.chunk_size/(float)(1<<20));
|
||||
sprintf(buffer, "Vbo size : %.3fMb(cur) Load: %.4fK Pref: %.4fK",
|
||||
nexus.patches.vbo_used * nexus.chunk_size/(float)(1<<20),
|
||||
nexus.prefetch.loading, nexus.prefetch.prefetching);
|
||||
gl_print(0.03, 0.06, buffer);
|
||||
|
||||
sprintf(buffer, "Triangles: %.2fK (tot) %.2fK (vis) "
|
||||
|
|
|
|||
|
|
@ -211,11 +211,12 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
|
||||
Nexus nexus;
|
||||
nexus.MaxRamBuffer(ram_size);
|
||||
|
||||
if(!nexus.Load(input, true)) {
|
||||
cerr << "Could not open nexus file: " << input << "\n";
|
||||
return -1;
|
||||
}
|
||||
nexus.MaxRamBuffer(ram_size);
|
||||
|
||||
|
||||
//Sanity tests
|
||||
|
|
@ -312,7 +313,7 @@ int main(int argc, char *argv[]) {
|
|||
cout << "Writing to nexus: " << output << endl;
|
||||
|
||||
Nexus out;
|
||||
out.MaxRamBuffer(ram_size);
|
||||
|
||||
if(!chunk_size)
|
||||
chunk_size = nexus.patches.chunk_size;
|
||||
|
||||
|
|
@ -320,6 +321,7 @@ int main(int argc, char *argv[]) {
|
|||
cerr << "Could not open output: " << output << endl;
|
||||
return -1;
|
||||
}
|
||||
out.MaxRamBuffer(ram_size);
|
||||
|
||||
//TODO set rambuffer low (or even direct access!)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ void Prefetch::init(NexusMt *m, std::vector<unsigned int> &selected,
|
|||
mt = m;
|
||||
missing.clear();
|
||||
mt->todraw.clear();
|
||||
|
||||
float loaded = 0;
|
||||
unsigned int notloaded = 0;
|
||||
set<unsigned int> tmp;
|
||||
//std::map<unsigned int, float> tmp;
|
||||
|
|
@ -24,11 +24,11 @@ void Prefetch::init(NexusMt *m, std::vector<unsigned int> &selected,
|
|||
for(unsigned int i = 0; i < selected.size(); i++) {
|
||||
unsigned int patch = selected[i];
|
||||
tmp.insert(patch);
|
||||
//tmp[patch] = 0.0f;
|
||||
|
||||
if(!mt->patches.entries[patch].patch) {
|
||||
//cerr << "miss: " << patch << endl;
|
||||
PServer::Entry &entry = mt->patches.entries[patch];
|
||||
load.post(patch);
|
||||
notloaded++;
|
||||
loaded += entry.disk_size;
|
||||
} else {
|
||||
PatchInfo &info = mt->index[patch];
|
||||
//WORKING QueuePServer::Data &data = mt->patches.Lookup(patch, info.nvert, info.nface, 0.0f, flush);
|
||||
|
|
@ -46,8 +46,7 @@ void Prefetch::init(NexusMt *m, std::vector<unsigned int> &selected,
|
|||
}
|
||||
//missing.push_back(PServer::Item(patch, 0.0f));
|
||||
}
|
||||
if(notloaded)
|
||||
cerr << "Patches to load: " << notloaded << endl;
|
||||
loading = 0.2 * loaded + 0.8 * loading;
|
||||
|
||||
for(unsigned int i = 0; i < visited.size(); i++) {
|
||||
PServer::Item &item = visited[i];
|
||||
|
|
@ -79,21 +78,22 @@ void Prefetch::init(NexusMt *m, std::vector<unsigned int> &selected,
|
|||
}
|
||||
|
||||
void Prefetch::execute() {
|
||||
unsigned int prefetched = 0;
|
||||
|
||||
float prefetch;
|
||||
prefetching = 0;
|
||||
loading = 0;
|
||||
while(1) {
|
||||
if(get_signaled()) return;
|
||||
vector<QueuePServer::Data> flush;
|
||||
|
||||
if(load.get_count() || missing.size() == 0) {
|
||||
if(prefetched)
|
||||
cerr << "Prefetched: " << prefetched << endl;
|
||||
prefetched = 0;
|
||||
|
||||
prefetch = 0;
|
||||
pt::message *msg = load.getmessage();
|
||||
if(msg->id != 0xffffffff) {
|
||||
safety.lock();
|
||||
PatchInfo &info = mt->index[msg->id];
|
||||
|
||||
PServer::Entry &entry = mt->patches.entries[msg->id];
|
||||
loading += entry.disk_size;
|
||||
//posting draw message
|
||||
//WORKING QueuePServer::Data &data = mt->patches.Lookup(msg->id, info.nvert, info.nface, 0.0f, flush);
|
||||
QueuePServer::Data &data = mt->patches.Lookup(msg->id, info.nvert, info.nface, flush);
|
||||
|
|
@ -108,6 +108,8 @@ void Prefetch::execute() {
|
|||
draw.post(QueuePServer::FLUSH, (unsigned int)data);
|
||||
}
|
||||
safety.unlock();
|
||||
} else {
|
||||
prefetching = 0.2 * prefetch + 0.8 * prefetching;
|
||||
}
|
||||
delete msg;
|
||||
} else {
|
||||
|
|
@ -124,8 +126,10 @@ void Prefetch::execute() {
|
|||
//cerr << "prefetching: " << item.patch << endl;
|
||||
//WORKING mt->patches.Lookup(item.patch, info.nvert, info.nface, item.priority, flush);
|
||||
if(!mt->patches.entries[item.patch].patch) {
|
||||
PServer::Entry &entry = mt->patches.entries[item.patch];
|
||||
prefetch += entry.disk_size;
|
||||
|
||||
mt->patches.Lookup(item.patch, info.nvert, info.nface, flush);
|
||||
prefetched++;
|
||||
for(unsigned int i = 0; i < flush.size(); i++) {
|
||||
QueuePServer::Data *data = new QueuePServer::Data;
|
||||
*data = flush[i];
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ class Prefetch: public pt::thread{
|
|||
std::vector<PServer::Item> missing;
|
||||
pt::jobqueue draw;
|
||||
pt::jobqueue load;
|
||||
float prefetching;
|
||||
float loading;
|
||||
|
||||
Prefetch(): thread(false), draw(20000), load(64000) {}
|
||||
~Prefetch() {
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ void PServer::FlushPatch(unsigned int id, Patch *patch) {
|
|||
//TODO move this into an assert!!!!
|
||||
if(!patch) return;
|
||||
Entry &entry = entries[id];
|
||||
assert(entry.patch == patch);
|
||||
// cerr << "entry: " << (void *)(entry.patch) << " patch: " << (void *)patch << endl;
|
||||
entry.patch = NULL;
|
||||
|
||||
if(!readonly) { //write back patch
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ class PServer: public MFile {
|
|||
ram_max(128000000),
|
||||
ram_used(0) {}
|
||||
virtual ~PServer() {
|
||||
std::cerr << "Closing pserver" << std::endl;
|
||||
MFile::Close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class QueuePServer: public PServer {
|
|||
Data &data = items.back().second;
|
||||
//TODO i should not flush current extraction!
|
||||
index.erase(items.back().first);
|
||||
FlushPatch(patch, data.patch);
|
||||
FlushPatch(items.back().first, data.patch);
|
||||
flush.push_back(data);
|
||||
items.pop_back();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue