[vtk-developers] revision of rendering process

John Shalf jshalf at lbl.gov
Tue Jul 17 03:38:45 EDT 2001


Hi all,
Lisa mentioned you were going to meet about the vtk/OpenGL
performance issues on the 17th.  I wanted to at least
provide some sample code representing the approach I've been
pursuing.  I've tried to clean up the GL_CACHEing code that
Roger Brown had been benching so that it is presentable in
mixed company.  Rather than having the caching strewn
throughout the code, it now caches the state changes by
simply surrounding the OpenGL call with
	GL_CACHE(<your gl call>);
Such as
	GL_CACHE(glMatrixMode(GL_MODELVIEW));
This makes it much simpler to eliminate the redundant state
changes.  It also has the side benefit of permitting a very
simple means of tracing the GL API calls in lieu of
ogldebug.  The next iteration of this would simply use some
additional C-preprocessor magic to eliminate the need to
even surround these calls with the GL_CACHE() instructions,
but this will do for now...

I've posted what I have so far at
	http://dit.lbl.gov/VTK/GlCache/
Unfortunately, I'm not back to the sort of performance I got
from the custom-hacked version of vtk3.1.  I need to get
back to SGI and work that out.  The SphereBench.cxx program 
(included in the source) roughly duplicates the TCL/TK
Sphere benchmarker in order to test these things out.

Caching
Modes----------------------------------------------------
The following cache modes are currently
demonstrated/implemented in this code

PassThru:  Just pass the redirected calls directly through
to the OpenGL API.  This is simply to make sure the caching
architecture doesn't have overhead.

Trace: This intercepts the GL calls and prints them to a
file so that you can analyze what state changes are
occuring.  (basically a poor-man's 'ogldebug').

Cache: This checks for and eliminates redundant state
changes.

Defer: This version performs the same functions as the
"Cache" mode, but also tries to reorder some of the
state-change calls to improve performance.

Strict: I didn't include this one, but it checks to catch
errors in GL code.  This simply involves a huge number of
conditional statements.

The files posted on the web are as
follows;----------------------
	http://dit.lbl.gov/VTK/GlCache/

vtk.cache.tar.gz : I had to make a snapshot of the vtk
source tree in order to have some stability while finishing
this up.

GraphicsInlines.tar.gz : These are the files in the
vtk/graphics directory that I had to change in order to add
the caching.  Most of the files simply needed the gl calls
surrounded by GL_CACHE() in order to redirect them to the
caching engine.  It also has the vtkOpenGLStateCache.h which
is where all of the caching classes are defined.

GraphicsInlines2.tar.gz : This is a fancier version of the
vtkOpenGLStateCache in GraphicsInlines that allows runtime
selection of the caching technique.  Unfortunately, although
this only makes weak use of C++ inheritance, its enough to
mess up the method inlining for some compiler
implementations. The contents of vtkOpenGLStateCache.h is
broken into separate files 'GLStateCache_<cachetype>.cxx'
and 'GLStateCache_<cachetype>.h'.  The C-preprocessor has
been royally abused here.

Also, I have untarred versions of these files posted there.

Building
it---------------------------------------------------
Here's the quick version;

# untar (if you don't necessarily use gnu tar)
	cat vtk.cache.tar.gz | gunzip | tar xvf -
	cd vtk.cache
# don't need much to test this thing
	./configure --with-patented --prefix=`pwd`
# copy the version of graphics inlines you want into place
# choices are 
#	GraphicsOrig:	original version of the source files
# 	GraphicsInlines:fully inlined version of cache classes
#	GraphicsInlines2: Not fully inlined, but can cache at
runtime
	cp GraphicsInlines2/*.cxx GraphicsInlines2/*.h graphics
# build it
	make
# build the test programs after fixing the paths in the
makefile
	vi makefile.tst
	make -f makefile.tst

Programs:-------------------------------------------------
ConeTest: Just see if the damn thing works at all
SphereBench: A simple benchmarking program modeled after
Sebastian Barre's
	now famous TCL/TK program.  Use SphereBench -help to get a
list of
	options.

Documentation:--------------------------------------------
OK, there is really no decent documentation of this source
code (its not even "self documenting code").  I'll try to
improve the comments in the code later this week, but this
is what I have to offer at this moment.  Your best bet is to
look at ConeTest.cxx and SphereBench.cxx just to see what
cache  options are available.  The actual caching mechanics
are in vtkOpenGLStateCache.h for GraphicsInlines and in
GLStateCache_<cachetype>.h for the GraphicsInlines2.  

I'm interested in how your meeting goes.  In the meantime,
I'll try to get this version back to the performance of the
custom-coded version.

-john

Will Schroeder wrote:
> 
> Along these same lines, the Simmetrix folks and John Shalf at LLNL have
> identified several changes to the rendering process that give large
> performance improvements. Since the Simmetrix guys are local and have been
> in communication with John Shalf, we might consider getting together for a
> design meeting sometime in the near future.
> Will
> 
> At 07:22 AM 6/27/2001 -0400, Lorensen, William E (CRD) wrote:
> >Perhaps this is a time to address performance issues in the rendering
> >process. Also, I think the vtk
> >developers should be involed in some sort of a review process of this
> >significant change.
> >
> >Bill
> 
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at public.kitware.com
> http://public.kitware.com/mailman/listinfo/vtk-developers




More information about the vtk-developers mailing list