[vtkusers] Second Try: Big performance hit when window gets too big

David Edwards dedwards at msc.com
Wed Sep 29 11:50:20 EDT 2004


Sean:

Thanks a lot for spending some time with this. Your analysis is very 
helpful, and points either to Windows itself (I was only using 
DirectDraw for video memory diagnostics) or my video card. Next planned 
step: Run the test on another Windows machine with a different card. I 
wish I could just move to Linux, but the old rules apply (customers' 
demands take precidence).

Thanks again,

- David Edwards
Applications Manager
Rigaku/MSC X-Ray products, Strategic Software Initiative


Sean McInerney wrote:

> Hi Dave,
>
>   I did a little testing with your included code on an old UltraSparc 
> running at 440MHz with only about 16M of video memory. I even added 
> some geometry to each window with about 32896 points each (with 
> normals) ...
>
> ... no problems ... (FYI modified code and CMakeLists.txt is attached)
>
> Blame DirectDraw and burn your Windows license.
>
> -Sean
>
> David Edwards wrote:
>
>> Hi,
>>
>> I really need to get an answer to this question, so I'm posting it 
>> again:
>> I've got a VTK-heavy commercial program we're trying to get out the 
>> door, but we've hit a show-stopper performance problem. When we open 
>> too many windows (sometimes as few as 3), the performance slows to a 
>> crawl.
>>
>> I've simplified the problem in the following code. This makes 6 
>> windows with single renderers and displays them. That's all. No actors.
>> * If you set SIZE to a small number like 100, you can grab and pan 
>> the windows with no performance hit.
>> * If you set SIZE to a larger number (for my system, it is 800), 
>> panning any window is VERY slow.
>>
>> Since this is directly related to the window size, I'm wondering if 
>> the video memory is filling up, causing page faults, but querying the 
>> video memory (using direct draw) shows there's plenty of memory left.
>>
>> Many thanks in advance for your help on this pressing problem.
>>
>> - David Edwards
>> Rigaku/MSC
>> Orem Utah
>>
>> Here's the example code:
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>>
>> // First include the required header files for the VTK classes we are 
>> using.
>> #include "vtkConeSource.h"
>> #include "vtkRenderWindow.h"
>> #include "vtkRenderer.h"
>> #include "vtkRenderWindowInteractor.h"
>> // DirectDraw include
>> // NOTE: Also must link ddraw.lib and dxguid.lib
>> #include "ddraw.h"
>>
>> #define SIZE 800
>>
>> vtkRenderWindow* NewRenderWindow()
>> {
>> vtkRenderer *ren= vtkRenderer::New();
>> ren->SetBackground( 0.1, 0.2, 0.4 );
>>
>>   vtkRenderWindow *renWin = vtkRenderWindow::New();
>> renWin->AddRenderer( ren );
>> renWin->SetSize( SIZE, SIZE );
>>   return renWin;
>> }
>>
>> void PrintVideoMemory()
>> {
>>   LPDIRECTDRAW lpDD  ;
>>   DirectDrawCreate(NULL, &lpDD, NULL);
>>   LPDIRECTDRAW2 lpDD2;
>>   DDSCAPS      ddsCaps;
>>   DWORD         dwTotal;
>>   DWORD         dwFree;
>>     lpDD->QueryInterface(IID_IDirectDraw2, (void**)&lpDD2);
>>   ZeroMemory(&ddsCaps, sizeof(ddsCaps)); // Initialize the structure
>>   ddsCaps.dwCaps = DDSCAPS_TEXTURE;
>>   lpDD2->GetAvailableVidMem(&ddsCaps, &dwTotal, &dwFree);
>>   // Print the free and total memory
>>   printf("FREE: %d TOTAL: %d\n",dwFree,dwTotal);
>> }
>>
>> // Make 6 render windows (with single renderers) to test performance hit
>> // when the windows get to be over a certain size.
>> int main( int argc, char *argv[] )
>> {
>>   PrintVideoMemory();
>>   vtkRenderWindow* renWin = NewRenderWindow();
>>   vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
>>   iren->SetRenderWindow(renWin);
>>
>>   for( int i=0; i<5; i++ ) {
>>       renWin = NewRenderWindow();
>>     renWin->Render();
>>       PrintVideoMemory();
>> }
>>
>>   iren->Initialize();
>>   iren->Start();
>>
>> return 0;
>> }
>>
>>
>>
>> _______________________________________________
>> This is the private VTK discussion list. Please keep messages 
>> on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>------------------------------------------------------------------------
>
>#
># $Id$
>#
># The name of our project is "VTK_TEST". CMakeLists files in this
># project can refer to the root source directory of the project as 
># ${VTK_TEST_SOURCE_DIR} and to the root binary directory of the
># project as ${VTK_TEST_BINARY_DIR}.
>#
>PROJECT (VTK_TEST)
>
>#-----------------------------------------------------------------------------
># Output directories.
>#
>SET (LIBRARY_OUTPUT_PATH ${VTK_TEST_BINARY_DIR}/bin CACHE PATH
>     "Output directory for building the vtkFLTK library.")
>SET (EXECUTABLE_OUTPUT_PATH ${VTK_TEST_BINARY_DIR}/bin CACHE PATH
>     "Single output directory for building all executables.")
>MARK_AS_ADVANCED (LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
>
>SET (VTK_TEST_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
>SET (VTK_TEST_EXECUTABLE_DIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
>SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
>
>#-----------------------------------------------------------------------------
># Dependencies
>#
>FIND_PACKAGE (VTK)
>IF (VTK_FOUND)
>  INCLUDE (${VTK_USE_FILE})
>ELSE (VTK_FOUND)
>  SET (CAN_BUILD 0)
>ENDIF (VTK_FOUND)
>
># -----------------------------------------------------------------------------
>#
>#
>IF (WIN32)
>  OPTION (USE_DDRAW "Use DirectDraw (where supported)." ON)
>ENDIF (WIN32)
>
>IF (${USE_DDRAW})
>  ADD_DEFINITIONS (-DUSE_DDRAW)
>ENDIF (${USE_DDRAW})
>
># -----------------------------------------------------------------------------
># Add the sources and targets
>#
>ADD_EXECUTABLE (vtktest vtktest.cxx)
>TARGET_LINK_LIBRARIES (vtktest vtkRendering vtkGraphics)
>
>IF (${USE_DDRAW})
>  TARGET_LINK_LIBRARIES (vtktest ddraw dxguid)
>ENDIF (${USE_DDRAW})
>
># -----------------------------------------------------------------------------
># Add build output and installation paths.
>#
>INSTALL_TARGETS (${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}
>                 vtktest
>)
>
>#
># End of: $Id$.
>#
>  
>
>------------------------------------------------------------------------
>
>// First include the required header files for the VTK classes we are using.
>#include "vtkPolyData.h"
>#include "vtkConeSource.h"
>#include "vtkPolyDataNormals.h"
>#include "vtkGlyph3D.h"
>#include "vtkPolyDataMapper.h"
>#include "vtkActor.h"
>#include "vtkRenderWindow.h"
>#include "vtkRenderer.h"
>#include "vtkRenderWindowInteractor.h"
>
>#ifdef USE_DDRAW
>// DirectDraw include
>// NOTE: Also must link ddraw.lib and dxguid.lib
>#include "ddraw.h"
>#endif /* USE_DDRAW */
>
>#define SIZE 800
>
>void
>AddTestGeometry (vtkRenderer* aRen)
>{
>  if (aRen != NULL)
>    {
>    vtkConeSource* coneSource = vtkConeSource::New();
>
>    coneSource->SetResolution(128);
>    coneSource->CappingOn();
>
>    vtkPolyDataNormals* normals = vtkPolyDataNormals::New();
>
>    normals->SetInput(coneSource->GetOutput());
>    coneSource->Delete();
>
>    vtkPolyDataMapper* mapper1 = vtkPolyDataMapper::New();
>
>    mapper1->SetInput(normals->GetOutput());
>
>    vtkActor* actor1 = vtkActor::New();
>
>    actor1->SetMapper(mapper1);
>    mapper1->Delete();
>
>    aRen->AddProp(actor1);
>    actor1->Delete();
>
>    vtkGlyph3D* glyphs = vtkGlyph3D::New();
>
>    glyphs->SetInput(normals->GetOutput());
>    glyphs->SetSource(normals->GetOutput());
>    glyphs->ScalingOn();
>    glyphs->SetScaleFactor(0.025);
>    glyphs->OrientOn();
>    glyphs->SetVectorModeToUseNormal();
>
>    vtkPolyDataMapper* mapper2 = vtkPolyDataMapper::New();
>
>    mapper2->SetInput(glyphs->GetOutput());
>
>    vtkActor* actor2 = vtkActor::New();
>
>    actor2->SetMapper(mapper2);
>    mapper2->Delete();
>
>    aRen->AddProp(actor2);
>    actor2->Delete();
>    }
>}
>
>vtkRenderWindowInteractor*
>NewRenderWindow (void)
>{
>  vtkRenderer* ren = vtkRenderer::New();
>  ren->SetBackground(0.1, 0.2, 0.4);
>
>  vtkRenderWindow* renWin = vtkRenderWindow::New();
>
>  renWin->AddRenderer(ren);
>  renWin->SetSize(SIZE, SIZE);
>  ren->Delete();
>
>  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
>
>  iren->SetRenderWindow(renWin);
>  iren->Initialize();
>  renWin->Delete();
>
>  AddTestGeometry(ren);
>
>  return iren;
>}
>
>void
>PrintVideoMemory (void)
>{
>#ifdef USE_DDRAW
>  LPDIRECTDRAW  lpDD;
>
>  DirectDrawCreate(NULL, &lpDD, NULL);
>
>  LPDIRECTDRAW2 lpDD2;
>  DDSCAPS       ddsCaps;
>  DWORD         dwTotal;
>  DWORD         dwFree;
>
>  lpDD->QueryInterface(IID_IDirectDraw2, (void **) &lpDD2);
>  ZeroMemory(&ddsCaps, sizeof(ddsCaps)); // Initialize the structure
>  ddsCaps.dwCaps = DDSCAPS_TEXTURE;
>  lpDD2->GetAvailableVidMem(&ddsCaps, &dwTotal, &dwFree);
>  // Print the free and total memory
>  printf("FREE: %d TOTAL: %d\n", dwFree, dwTotal);
>#endif /* USE_DDRAW */
>}
>
>// Make 6 render windows (with single renderers) to test performance hit
>// when the windows get to be over a certain size.
>int
>main (int argc, char* argv[])
>{
>  PrintVideoMemory();
>
>  vtkRenderWindowInteractor* iren = NewRenderWindow();
>
>  for (int i=0; i<5; i++)
>    {
>    iren = NewRenderWindow();
>    iren->Render();
>    PrintVideoMemory();
>    }
>
>  iren->Start();
>
>  return 0;
>}
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040929/d942a793/attachment.htm>


More information about the vtkusers mailing list