[vtkusers] vtkRenderer vs vtkRenderWindow performance

M W sonomw at yahoo.com
Thu Aug 29 03:10:15 EDT 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130829/ce6a7734/attachment.htm>


More information about the vtkusers mailing list