Ignore:
Timestamp:
10/23/06 20:24:14 (18 years ago)
Author:
mattausch
Message:

updated priority meaurement: taking total cost and memory into account

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1666 r1667  
    358358        // hack: assume that object space can be seen from view space 
    359359        mHierarchyStats.mTotalCost = (float)objects.size(); 
     360        // only one entry for start 
    360361        mHierarchyStats.mPvsEntries = 1; 
    361  
    362         const int entrySize = sizeof(PvsData) + sizeof(Intersectable *); 
    363         mHierarchyStats.mMemory = entrySize / (1024.0f * 1024.0f); 
     362        mHierarchyStats.mMemory = (float)ObjectPvs::GetEntrySizeByte(); 
    364363 
    365364        EvalSubdivisionStats(); 
     
    396395        // for first round, use sah splits. Once view space partition 
    397396        // has started, use render cost heuristics instead 
    398         const int ospSteps =  
    399                 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, minSteps); 
     397        const int ospSteps = RunConstruction(objectSpaceQueue, dirtyVspList, NULL, minSteps); 
    400398 
    401399        cout << "\n" << ospSteps << " object space partition steps taken" << endl; 
    402400 
    403401        // create view space 
    404         SubdivisionCandidate *vsc =  
    405                         PrepareViewSpaceSubdivision(sampleRays, objects); 
     402        SubdivisionCandidate *vsc = PrepareViewSpaceSubdivision(sampleRays, objects); 
    406403 
    407404        viewSpaceQueue.Push(vsc); 
     
    414411        // account so we can compare to view space splits 
    415412        ResetQueue(objectSpaceQueue, false); 
    416  
    417         //minSteps = 1; 
    418413 
    419414        // This method subdivides view space / object space  
     
    425420        while (!(viewSpaceQueue.Empty() && objectSpaceQueue.Empty())) 
    426421        { 
    427                 float vspPriority; 
     422                // decide upon next split type 
     423                const float vspPriority =  viewSpaceQueue.Top() ? viewSpaceQueue.Top()->GetPriority() : -1e20; 
     424                const float ospPriority =  viewSpaceQueue.Top() ? objectSpaceQueue.Top()->GetPriority() : -1e20; 
    428425                 
    429                 // decide upon next split type 
    430                 if (!viewSpaceQueue.Empty()) 
    431                 { 
    432                         vspPriority = viewSpaceQueue.Top()->GetPriority(); 
    433  
    434                         // rather take this into account directly when computing priority 
    435                         if (0 && mConsiderMemory) 
    436                                 vspPriority /= ((float)viewSpaceQueue.Top()->GetPvsEntriesIncr() + Limits::Small); 
    437                 } 
    438                 else 
    439                 { 
    440                         vspPriority = 0; 
    441                 } 
    442  
    443                 float ospPriority; 
    444                  
    445                 if (!objectSpaceQueue.Empty()) 
    446                 { 
    447                         ospPriority = objectSpaceQueue.Top()->GetPriority(); 
    448                          
    449                         // rather take this into account directly when computing priority 
    450                         if (0 && mConsiderMemory) 
    451                                 ospPriority /= ((float)objectSpaceQueue.Top()->GetPvsEntriesIncr() + Limits::Small); 
    452                 } 
    453                 else 
    454                 { 
    455                         ospPriority = 0; 
    456                 } 
    457  
    458426                cout << "new decicion, vsp: " << vspPriority << ", osp: " << ospPriority << endl; 
    459427 
     
    471439                        // has started, use render cost heuristics instead 
    472440                        const int ospSteps =  
    473                                 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, minSteps); 
     441                                RunConstruction(objectSpaceQueue, dirtyVspList, viewSpaceQueue.Top(), minSteps); 
    474442 
    475443                        cout << "\n" << ospSteps << " object space partition steps taken" << endl; 
     
    493461                        // process view space candidates 
    494462                        const int vspSteps =  
    495                                 RunConstruction(viewSpaceQueue, dirtyOspList, renderCostDecr, minSteps); 
     463                                RunConstruction(viewSpaceQueue, dirtyOspList, objectSpaceQueue.Top(), minSteps); 
    496464 
    497465                        cout << "\n" << vspSteps << " view space partition steps taken" << endl; 
     
    526494        mHierarchyStats.mNodes = 2;  
    527495        mHierarchyStats.mPvsEntries = 1; 
    528         mHierarchyStats.mMemory = sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 
     496        mHierarchyStats.mMemory = (float)ObjectPvs::GetEntrySizeByte(); 
    529497        mHierarchyStats.mTotalCost = (float)objects.size(); 
    530498 
     
    570538 
    571539        // begin subdivision 
    572         RunConstruction(mRepairQueue,  
    573                                         sampleRays,  
    574                                         objects,  
    575                                         forcedViewSpace); 
     540        RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace); 
    576541         
    577542        cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     
    734699        //cout << "pvs entries: " << pvsEntriesIncr << " " << mHierarchyStats.pvsEntries << endl; 
    735700 
    736         const int sizeOfEntry = sizeof(PvsData) + sizeof(Intersectable *); 
    737701        // memory size in byte 
    738         mHierarchyStats.mMemory += float(pvsEntriesIncr * sizeOfEntry); 
     702        mHierarchyStats.mMemory += (float)ObjectPvs::GetEntrySizeByte(); 
    739703        mHierarchyStats.mRenderCostDecrease = sc->GetRenderCostDecrease(); 
    740704 
     
    744708        { 
    745709                memoryCount += 100000; 
    746                 cout << "\nstorage cost: " << mHierarchyStats.mMemory / (1024.0f * 1024.0f) << ", steps: " << mHierarchyStats.Leaves() << endl; 
     710                cout << "\nstorage cost: " << mHierarchyStats.mMemory / float(1024 * 1024) << " MB, steps: " << mHierarchyStats.Leaves() << endl; 
    747711        } 
    748712 
     
    930894int HierarchyManager::RunConstruction(SplitQueue &splitQueue, 
    931895                                                                          SubdivisionCandidateContainer &dirtyCandidates, 
    932                                                                           const float minRenderCostDecr, 
     896                                                                          SubdivisionCandidate *oldCandidate, 
    933897                                                                          const int minSteps) 
    934898{ 
     
    939903        while (!splitQueue.Empty()) 
    940904        { 
     905                const float threshold = oldCandidate ? oldCandidate->GetPriority() : 1e20; 
    941906                SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue);  
    942                  
     907                //cout << "here2 " << sc->GetPriority() << " " << threshold << endl; 
     908 
    943909                // minimum slope reached 
    944                 if ((sc->GetRenderCostDecrease() < minRenderCostDecr) && 
    945                         !(steps < minSteps)) 
    946                 { 
    947                         //cout << "breaking on " << sc->GetRenderCostDecrease() << " smaller than " << minRenderCostDecr << endl; 
     910                if ((sc->GetPriority() < threshold) && !(steps < minSteps)) 
     911                { 
     912                        cout << "**************** breaking on " << sc->GetPriority() << " smaller than " << threshold << endl; 
    948913                        break; 
    949914                } 
     915 
    950916                //////// 
    951917                //-- subdivide leaf node of either type 
     
    993959                        mHierarchyStats.mPvsEntries = mBvHierarchy->CountViewCells(objects); 
    994960 
    995                         mHierarchyStats.mMemory = mHierarchyStats.mPvsEntries * 
    996                                 sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 
     961                        mHierarchyStats.mMemory =  
     962                                (float)mHierarchyStats.mPvsEntries * ObjectPvs::GetEntrySizeByte(); 
    997963 
    998964                        mHierarchyStats.mRenderCostDecrease = 0; 
     
    10381004        mHierarchyStats.mRenderCostDecrease = 0; 
    10391005 
    1040         mHierarchyStats.mMemory = mHierarchyStats.mPvsEntries *  
    1041                 sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 
     1006        mHierarchyStats.mMemory = (float)mHierarchyStats.mPvsEntries * ObjectPvs::GetEntrySizeByte(); 
    10421007 
    10431008        // evaluate new stats before first subdivsiion 
     
    13091274                const float rcd = sc->GetRenderCostDecrease(); 
    13101275                 
    1311                 splitQueue.Erase(sc); // erase from queue 
    1312                 sc->EvalPriority(recomputeSplitPlaneOnRepair); // reevaluate 
    1313                  
     1276                // erase from queue 
     1277                splitQueue.Erase(sc); 
     1278                // reevaluate candidate 
     1279                sc->EvalCandidate(recomputeSplitPlaneOnRepair); 
     1280                 // reinsert 
     1281                splitQueue.Push(sc); 
     1282 
     1283                cout << "."; 
     1284 
    13141285#ifdef _DEBUG 
    13151286                Debug << "candidate " << sc << " reevaluated\n"  
     
    13171288                          << " old: " << rcd << " new " << sc->GetRenderCostDecrease() << endl; 
    13181289#endif   
    1319                 splitQueue.Push(sc); // reinsert 
    1320                 cout << "."; 
    13211290        } 
    13221291 
     
    13391308                SubdivisionCandidate *candidate = NextSubdivisionCandidate(splitQueue); 
    13401309                 // reevaluate local split plane and priority 
    1341                 candidate->EvalPriority(recomputeSplitPlane); 
     1310                candidate->EvalCandidate(recomputeSplitPlane); 
    13421311                cout << "."; 
    13431312                mCandidateBuffer.push_back(candidate); 
Note: See TracChangeset for help on using the changeset viewer.