[vtkusers] Big performance hit when window size gets too big.

David Edwards dedwards at msc.com
Wed Sep 8 19:17:08 EDT 2004


Hi,

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;
}


 






More information about the vtkusers mailing list