Bug fixed...

This commit is contained in:
Federico Ponchio 2004-10-19 16:52:01 +00:00
parent 65814f4a2b
commit c583e7b914
2 changed files with 14 additions and 14 deletions

View File

@ -192,7 +192,7 @@ void PatchServer::Flush() {
while(ram_used > ram_size) { while(ram_used > ram_size) {
pop_heap(lru.begin(), lru.end()); pop_heap(lru.begin(), lru.end());
PTime &ptime = lru.back(); PTime &ptime = lru.back();
Flush(ptime.npatch); Flush(ptime);
lru.pop_back(); lru.pop_back();
} }
for(unsigned int i = 0; i < lru.size(); i++) for(unsigned int i = 0; i < lru.size(); i++)
@ -202,15 +202,15 @@ void PatchServer::Flush() {
void PatchServer::FlushAll() { void PatchServer::FlushAll() {
for(unsigned int i = 0; i < lru.size(); i++) { for(unsigned int i = 0; i < lru.size(); i++) {
PTime &ptime = lru[i]; PTime &ptime = lru[i];
Flush(ptime.npatch); Flush(ptime);
} }
assert(ram_used == 0); assert(ram_used == 0);
lru.clear(); lru.clear();
} }
void PatchServer::Flush(unsigned int patch) { void PatchServer::Flush(PTime &ptime) {
PatchEntry &entry = patches[patch]; PatchEntry &entry = patches[ptime.npatch];
PTime &ptime = lru[entry.lru_pos]; assert(ptime.patch);
if(!readonly) { //write back patch if(!readonly) { //write back patch
@ -245,29 +245,29 @@ void PatchServer::Flush(unsigned int patch) {
exit(0);*/ exit(0);*/
} }
if(FlushVbo(ptime))
vbo_used -= entry.ram_size;
delete [](ptime.patch->start); delete [](ptime.patch->start);
delete ptime.patch; delete ptime.patch;
ptime.patch = NULL; ptime.patch = NULL;
if(FlushVbo(patch))
vbo_used -= entry.ram_size;
entry.lru_pos = 0xffffffff; entry.lru_pos = 0xffffffff;
ram_used -= entry.ram_size; ram_used -= entry.ram_size;
ram_flushed += entry.ram_size; ram_flushed += entry.ram_size;
} }
bool PatchServer::FlushVbo(unsigned int patch) { bool PatchServer::FlushVbo(PTime &ptime) {
//TODO //TODO
//cerr << "Flushing vbo: " << patch << endl; //cerr << "Flushing vbo: " << patch << endl;
PatchEntry &entry = patches[patch];
assert(entry.lru_pos != 0xffffffff);
PTime &ptime = lru[entry.lru_pos];
if(!ptime.vbo_element) return false; if(!ptime.vbo_element) return false;
glDeleteBuffersARB(1, &ptime.vbo_element); glDeleteBuffersARB(1, &ptime.vbo_element);
glDeleteBuffersARB(1, &ptime.vbo_array); glDeleteBuffersARB(1, &ptime.vbo_array);
assert(!ptime.vbo_element); ptime.vbo_element = 0;
ptime.vbo_array = 0;
return true; return true;
} }

View File

@ -67,9 +67,9 @@ class PatchServer: public File {
void GetVbo(unsigned int patch, unsigned int &element, unsigned int &array); void GetVbo(unsigned int patch, unsigned int &element, unsigned int &array);
void Flush(unsigned int patch); void Flush(PTime &ptime);
//return false if was not allocated. //return false if was not allocated.
bool FlushVbo(unsigned int patch); bool FlushVbo(PTime &ptime);
void Flush(); void Flush();
void FlushAll(); void FlushAll();