vcglib/apps/nexus/preload.cpp

83 lines
3.1 KiB
C++
Raw Normal View History

2005-02-08 13:43:03 +01:00
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
$Log: not supported by cvs2svn $
2005-04-14 18:19:34 +02:00
Revision 1.7 2005/02/17 15:39:44 ponchio
Reorderes statistics a bit.
2005-02-17 16:39:44 +01:00
Revision 1.6 2005/02/08 12:43:03 ponchio
Added copyright
2005-02-08 13:43:03 +01:00
****************************************************************************/
2005-01-14 16:41:10 +01:00
#include "preload.h"
#include "nexusmt.h"
2005-02-01 17:42:30 +01:00
#include <iostream>
2005-01-14 16:41:10 +01:00
using namespace std;
using namespace nxs;
void Preload::execute() {
2005-02-17 16:39:44 +01:00
total_disk = 0;
disk = 0;
2005-02-01 17:42:30 +01:00
assert(mt);
while(!get_signaled()) {
2005-02-03 13:35:01 +01:00
trigger.wait();
2005-02-01 17:42:30 +01:00
lock.enter();
while(!queue.size()) {
2005-02-03 13:35:01 +01:00
trigger.reset();
2005-02-01 17:42:30 +01:00
lock.leave();
trigger.wait();
lock.enter();
}
//TODO check we are not loading too much memory!
assert(queue.size());
2005-02-03 13:35:01 +01:00
Item &item = queue.back();
if(item.error == 0 || mt->CanAdd(item)) {
//we cannot flush since we are not in the openGL thread
//and flushing includes VBO buffer flushing also.
2005-02-17 16:39:44 +01:00
Entry &entry = (*mt)[item.id];
2005-04-14 18:19:34 +02:00
if(!entry.patch) {
2005-02-17 16:39:44 +01:00
disk += entry.disk_size;
2005-04-14 18:19:34 +02:00
disk_tri += entry.nvert * 2;
}
2005-02-17 16:39:44 +01:00
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];
2005-02-03 13:35:01 +01:00
queue.pop_back();
} else
queue.clear();
2005-02-01 17:42:30 +01:00
lock.leave();
}
}
2005-01-14 16:41:10 +01:00