[vtkusers] vtkRenderer vs vtkRenderWindow performance

Bill Lorensen bill.lorensen at gmail.com
Thu Aug 29 19:25:44 EDT 2013


If you post a small compilable example that illustrates the performance
issues we might be able to help.



On Thu, Aug 29, 2013 at 6:09 PM, M W <sonomw at yahoo.com> wrote:

> Hi David,
>
> I'm setting the input to the vtkImageResliceMapper from a vtkImageImport
> object.  However since I'm using SetInput instead of SetInputConnection
> shouldn't the update not matter?  As I understand it, this would remove any
> reliance on the vtkImageImport object once its GetOutput method is
> invoked.  However I tried your suggestion and called the Update function on
> the vtkImageImport object before the for loop and did not observe any
> performance increase.
>
> Another thing I've noticed is that if I render two render windows
> simultaneously (one displaying the slice image, one displaying the full
> volume), the time is not simply the sum of the two separately.  That is, if
> it takes 5 seconds to run the for loop with just the slice render window,
> and 4 seconds to run the for loop with just the volume render window, the
> time to run the for loop with both is not 9 seconds, but more like 14
> seconds.  This is another reason I would like to really up the speed, since
> ultimately we'd like to be able to show both views simultaneously.  Maybe
> this new mystery sheds some light on the problem?
>
> Wasn't quite sure what you meant about the vblank, but it sounds like
> you're saying there might be some kind of sleep call?
>
> Thanks again for all the help, I'm at a loss here!
>
> --Matt
>
>
>   ------------------------------
>  *From:* David Gobbi <david.gobbi at gmail.com>
> *To:* M W <sonomw at yahoo.com>
> *Cc:* "vtkusers at vtk.org" <vtkusers at vtk.org>
> *Sent:* Thursday, August 29, 2013 5:47 AM
>
> *Subject:* Re: [vtkusers] vtkRenderer vs vtkRenderWindow performance
>
> Hi Matt,
>
> Are you using some kind of VTK image reader to load the image?
> Make sure that the whole image is cached in memory by doing this
> after you have set up the reader:
>
> reader.Update();
>
> Otherwise, it's possible that on each render, the reader is hitting
> the disk to load the slices that are needed for that render.  That
> would be a big performance killer.  Ideally, you should also call
> Update() on whatever filter immediately precedes the mapper.
>
> The fact that you get a max of 60fps after removing all actors
> suggests that it might be waiting for a vblank every time it renders,
> though I might be wrong about that.
>
> - David
>
> On Thu, Aug 29, 2013 at 1:10 AM, M W <sonomw at yahoo.com> wrote:
> > Hi David,
> >
> > Thanks for all the info!  I've reimplemented our system using
> > vtkImageResliceMapper, but unfortunately the performance seems about the
> > same.  Here's a (really) stripped-down version of what my test case looks
> > like now:
> >
> > mapper = vtk.vtkImageResliceMapper()
> > mapper.SetInput(input)
> > mapper.SetSlicePlane(plane)
> > actor.SetMapper(mapper)
> > renderer.AddActor(actor)
> >
> >
> > start_time = time.time()
> > for i in range(100)
> >      mapper.SetSlicePlane(new plane)
> >
> >      renderWindow.Render()
> > end_time = time.time()
> > print 'Elapsed time = ', end_time - start_time
> >
> > Currently I'm getting about 15 fps, which is better, but would be great
> to
> > get above 30.  An interesting thing I noticed is that even if I comment
> out
> > the AddActor line, the for loop still takes about 1.6 seconds to run.
> With
> > zero actors to render (I verify this before the loop by calling
> > VisibleActorCount) I would expect the loop to complete nearly
> > instantaneously.  Any additional thoughts?  Thanks again.
> >
> > --Matt
> >
> >
> > ________________________________
> > From: David Gobbi <david.gobbi at gmail.com>
> > To: M W <sonomw at yahoo.com>
> > Cc: "vtkusers at vtk.org" <vtkusers at vtk.org>
> > Sent: Tuesday, August 27, 2013 10:32 PM
> > Subject: Re: [vtkusers] vtkRenderer vs vtkRenderWindow performance
> >
> > Hi Matt,
> >
> > Are you reslicing the whole volume on each render?  For it to be going
> > that slow, the vtkImageReslice class must be producing 200 output
> > slices for each render, which doesn't make sense because the renderer
> > is (I'm guessing) only displaying one slice at a time.  In other
> > words, I think that if you reworked your pipeline you would probably
> > see things speed up by a factor of about 200.
> >
> > I recommend that you use vtkImageResliceMapper instead of
> > vtkImageReslice.  See this wiki page for details:
> > http://www.vtk.org/Wiki/VTK/Image_Rendering_Classes
> >
> > About the timings, please note that vtkRenderer::Render() is not a
> > user method and you should never, ever call it directly.  It is only
> > meant to be called from the vtkRenderWindow.  When you call it
> > directly as in your code example, it doesn't do what it is supposed to
> > do, so the time you are getting for it is invalid.  I won't explain
> > any further than that.
> >
> > David
> >
> > On Tue, Aug 27, 2013 at 10:55 PM, M W <sonomw at yahoo.com> wrote:
> >> Hi all, I'm relatively new to VTK and am having some issues with
> >> performance.  I am trying to achieve interactive slicing of a roughly
> >> 200x200x200 vtkVolume using vtkImageReslice, displayed through a 640x480
> >> wxVTKRenderWindow in Python.  This is all working great, but it's slow,
> >> maybe 5 - 10 frames per second, making the application difficult to use.
> >> I'm running this on a Windows 7 / Intel Core i7 / nVidia Geforce GTX
> >> laptop.
> >>
> >> The main bottleneck is the call to the wxVTKRenderWindow Render
> function.
> >> Out of curiosity, I timed the speed of the Render function of the
> >> vtkRenderer directly, and this was nearly an order of magnitude faster.
> >> Is
> >> this to be expected?  I figured the bulk of the work would be in the
> >> vtkRenderer.  I'm fairly new to all of this so I'm not quite clear on
> what
> >> work is performed by the
> >> renderer/rendercollection/renderwindow/interactor,
> >> but is there a way to get the vtkRenderWindow Render to better match the
> >> speed of the vtkRenderer Render?
> >>
> >> I get very smooth results rotating the entire volume within the
> >> wxVTKRenderWindow, so it seems somewhat unexpected that rendering a
> single
> >> slice is so much slower.
> >>
> >> My test case looks something like this:
> >>
> >> start_time = time.time()
> >> for i in range(100):
> >>      self.sliceRenderer.Render()
> >>      #self.sliceRenderWindow.Render()
> >> end_time = time.time()
> >> print 'Elapsed time = ', end_time - start_time
> >>
> >> Any ideas?  Thanks!
> >>
> >> --Matt
> >
> >
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>


-- 
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130829/bb4da760/attachment.htm>


More information about the vtkusers mailing list