Show
Ignore:
Timestamp:
10/21/06 13:50:48 (2 years ago)
Author:
dirk
Message:

Added Tri and occed tri stats
added NVPerfKitSDK demo stats in testOcclusionCulling.cpp. These should become core stats later…

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/testOcclusionCulling.cpp

    r299 r342  
    3030 
    3131 
    32 StatElemDesc<StatStringElem> GPUIdleStat("GPUIdle","GPUIdle"); 
    33 StatElemDesc<StatStringElem> PSBusyStat("PSBusyStat","PSBusyStat"); 
    34 StatElemDesc<StatStringElem> VSBusyStat("VSBusyStat","VSBusyStat"); 
    35 StatElemDesc<StatStringElem> TextureWaitStat("TextureWait","TextureWait"); 
     32StatElemDesc<StatStringElem> GPUIdleStat("GPUIdle","GPUIdle", 
     33            StatElemDescBase::RESET_NEVER); 
     34StatElemDesc<StatStringElem> PSBusyStat("PSBusyStat","PSBusyStat", 
     35            StatElemDescBase::RESET_NEVER); 
     36StatElemDesc<StatStringElem> VSBusyStat("VSBusyStat","VSBusyStat", 
     37            StatElemDescBase::RESET_NEVER); 
     38StatElemDesc<StatStringElem> TextureWaitStat("TextureWait","TextureWait", 
     39            StatElemDescBase::RESET_NEVER); 
     40StatElemDesc<StatStringElem> OGLFPSStat("OGL FPS","OGL FPS", 
     41            StatElemDescBase::RESET_NEVER); 
    3642 
    3743StatElemDesc<StatStringElem> *nvStatElems[] =  
    38     { &GPUIdleStat, &PSBusyStat, &VSBusyStat, &TextureWaitStat }; 
     44    { &GPUIdleStat, &PSBusyStat, &VSBusyStat, &TextureWaitStat, &OGLFPSStat, 
     45      NULL }; 
    3946 
    4047#endif 
     
    6067#ifdef OSG_WITH_NVPERFSDK 
    6168const GLuint counterEntryCount = 10; 
    62 const GLuint bufferEntryCount = 10
     69const GLuint bufferEntryCount = 100
    6370 
    6471// A simple class to manage counters, sampling, and display of the information 
     
    163170 
    164171NVDataProvider *nvDataProvider = &g_nvDataProvider; 
     172 
     173bool runExperiment = false; 
     174 
    165175#endif 
    166176 
     
    177187            Char8 str[40]; 
    178188             
    179             for(int i = 0; i < 4; ++i) 
     189            for(int i = 0; nvStatElems[i] != NULL; ++i) 
    180190            { 
    181191                sprintf(str, "%s: %f", nvStatElems[i]->getDescription().str(), 
     
    186196            } 
    187197        } 
     198         
     199        if(runExperiment) 
     200        { 
     201            int nCount; 
     202             
     203            char *expCounters[] = {  
     204                "2D Bottleneck", "2D SOL",  
     205                "IDX Bottleneck", "IDX SOL",  
     206                "GEOM Bottleneck", "GEOM SOL",  
     207                "ZCULL Bottleneck", "ZCULL SOL",  
     208                "TEX Bottleneck", "TEX SOL",  
     209                "ROP Bottleneck", "ROP SOL",  
     210                "SHD Bottleneck", "SHD SOL",  
     211                "FB Bottleneck", "FB SOL",  
     212                "GPU Bottleneck", // Needs to be last  
     213                NULL }; 
     214             
     215            for(int i = 0; expCounters[i] != NULL; ++i) 
     216            { 
     217                NVPMAddCounterByName(expCounters[i]); 
     218            } 
     219             
     220            NVPMBeginExperiment(&nCount); 
     221             
     222            FLOG(("NVPerfKitSDK: Running %d passes\n", nCount)); 
     223             
     224            for(int i = 0; i < nCount; i++) 
     225            { 
     226                NVPMBeginPass(i); 
     227                mgr->redraw(); 
     228                NVPMEndPass(i); 
     229            } 
     230            NVPMEndExperiment(); 
     231             
     232            UINT64 value, cycles; 
     233             
     234            for(int i = 0; expCounters[i] != NULL; ++i) 
     235            { 
     236                NVPMGetCounterValueByName(expCounters[i], 0, &value, &cycles); 
     237                FLOG(("%s: %lld value, %lld cycles (%.4f%%)\n",  
     238                        expCounters[i], value, cycles, value * 100. / cycles)); 
     239            } 
     240             
     241            char buffer[1000] = ""; 
     242             
     243            NVPMGetGPUBottleneckName(value, buffer); 
     244 
     245            FLOG(("GPU Bottleneck: '%s'\n", buffer)); 
     246 
     247            for(int i = 0; expCounters[i] != NULL; ++i) 
     248            { 
     249                //NVPMRemoveCounterByName(expCounters[i]);                
     250            } 
     251             
     252            runExperiment = false; 
     253        } 
    188254#endif 
    189255        mgr->redraw(); 
     
    206272        glutPostRedisplay(); 
    207273    } 
     274} 
     275 
     276void idle(void) 
     277{    
     278    redisplay(); 
    208279} 
    209280 
     
    404475        break; 
    405476 
     477        case 'e': 
     478            runExperiment = true; 
     479            break; 
     480 
    406481    } 
    407482 
     
    464539    glutReshapeFunc(reshape); 
    465540    glutDisplayFunc(display); 
    466     glutIdleFunc(display); 
     541    glutIdleFunc(idle); 
    467542    glutMouseFunc(mouse); 
    468543    glutMotionFunc(motion); 
     
    545620    statfg->setColor(Color4f(0,1,0,0.7)); 
    546621 
    547     statfg->addElement(RenderTraversalAction::statDrawTime, "Draw FPS: %r.3f"); 
     622    statfg->addElement(RenderTraversalAction::statDrawTime,  
     623                       "Draw FPS: %r.3f"); 
    548624    statfg->addElement(RenderTraversalAction::statNMatrices,  
    549                        "%d matrix changes"); 
     625                       "Matrix Changes: %d"); 
    550626    statfg->addElement(RenderTraversalAction::statNGeometries,  
    551                        "%d Geometries drawn"); 
     627                       "Geometries drawn: %d"); 
    552628    statfg->addElement(RenderTraversalAction::statNStates,  
    553                        "%d state changes"); 
     629                       "State Changes: %d"); 
    554630    statfg->addElement(RenderTraversalAction::statNShaders,  
    555                        "%d shader changes"); 
     631                       "Shader Changes: %d"); 
    556632    statfg->addElement(RenderTraversalAction::statNShaderParams,  
    557                        "%d shader param changes"); 
     633                       "Shader Param Changes: %d"); 
     634    statfg->addElement(RenderTraversalAction::statNTriangles,  
     635                       "Triangles: %d"); 
     636                        
     637    statfg->addElement(RenderPartition::statCullTestedNodes,  
     638                       "Cull-tested Nodes: %d"); 
     639    statfg->addElement(RenderPartition::statCulledNodes,  
     640                       "Culled Nodes: %d"); 
    558641 
    559642    statfg->addElement(OcclusionCullingTreeBuilder::statNOccNodes,  
    560                        "%d nodes in draw tree"); 
     643                       "Nodes in DrawTree: %d"); 
    561644    statfg->addElement(OcclusionCullingTreeBuilder::statNOccTests,  
    562                        "%d occ tests"); 
     645                       "Occ Tests: %d"); 
    563646    statfg->addElement(OcclusionCullingTreeBuilder::statNOccInvisible,  
    564                        "%d invisible nodes"); 
     647                       "Invisible Nodes: %d"); 
    565648    statfg->addElement(OcclusionCullingTreeBuilder::statNOccSuccessTestPer,  
    566                        "%per%% success rate"); 
     649                       "Success rate: %per%%"); 
     650    statfg->addElement(OcclusionCullingTreeBuilder::statNOccTriangles,  
     651                       "Triangles culled: %d"); 
    567652    
    568653    collector = &statfg->editCollector(); 
     
    592677        nvDataProvider->add("vertex_shader_busy"); 
    593678        nvDataProvider->add("shader_waits_for_texture"); 
     679        if (!nvDataProvider->add("OGL FPS"))  
     680            FLOG(("nvDataProvider::add: 'OGL FPS' failed!\n")); 
    594681         
    595682        statfg->addElement(GPUIdleStat); 
     
    597684        statfg->addElement(VSBusyStat); 
    598685        statfg->addElement(TextureWaitStat); 
    599          
     686        statfg->addElement(OGLFPSStat);         
    600687    } 
    601688#endif