Commit d7c4a728 authored by fogal1's avatar fogal1

Do ad hoc memoization of the transparency calculation.

In some SR mode configurations, we have the issue that rendering
will involve global communication due to the need to sort
transparent geometry.  This is undesirable because 1) we don't
know the sort order until rendering is underway, thus preventing
us from using that knowledge for more intelligent compositing, and
2) certain compositors, such as IceT, do not call our render
method synchronously in all cases, leading to deadlock in the
worst case.

This commit changes the transparency actor so that it keeps an
internal cache of the transparency calculation.  Clients are now
expected to clear ("Invalidate") the cache periodically.  In SR
mode we'll do that once per render.  In standard rendering modes,
we'll invalidate the cache every time we add a plot to the window.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@7402 18c085ea-50e0-402c-830e-de6fd14e8384
parent 6b981360
......@@ -109,9 +109,14 @@ using std::vector;
// Brad Whitlock, Fri Jan 23 15:27:34 PST 2009
// Pass the communicator to vtkParallelImageSpaceRedistributor.
//
// Tom Fogal, Sun May 24 21:31:20 MDT 2009
// Initialize transparenciesExist && cachedTransparencies.
//
// ****************************************************************************
avtTransparencyActor::avtTransparencyActor()
avtTransparencyActor::avtTransparencyActor() :
transparenciesExist(false),
cachedTransparencies(false)
{
appender = vtkAppendPolyData::New();
myMapper = vtkPolyDataMapper::New();
......@@ -1317,25 +1322,57 @@ avtTransparencyActor::ScaleByVector(const double vec[3])
// Creation: December 3, 2003
//
// Modifications:
//
// Tom Fogal, Mon May 25 14:04:56 MDT 2009
// Changed interface; this method checks the memo'd cache.
//
// ****************************************************************************
bool
avtTransparencyActor::TransparenciesExist()
{
if(!cachedTransparencies)
{
debug3 << "Unknown if transparencies exist; recalculating "
<< "(this requires global communication)." << std::endl;
DetermineTransparencies();
}
return transparenciesExist;
}
// ****************************************************************************
// Method: avtTransparencyActor::DetermineTransparencies
//
// Purpose:
// Returns true if this actor is active (appender has inputs).
//
// Programmer: Kathleen Bonnell
// Creation: December 3, 2003
//
// Modifications:
// Jeremy Meredith and Hank Childs, Thu Oct 21 15:27:44 PDT 2004
// This method was not getting updated soon enough for calls to
// it to return the correct value. We took the key pieces
// from PrepareDataset to get the right answer here, and I
// added code to enforce that all processors have the same answer.
//
// Tom Fogal, Mon May 25 14:06:37 MDT 2009
// Renamed from `TransparenciesExist'. Use member variable to store the
// result, and note that the result is cached.
//
// ****************************************************************************
bool
avtTransparencyActor::TransparenciesExist()
void
avtTransparencyActor::DetermineTransparencies()
{
bool has_stuff = false;
transparenciesExist = false;
int numActors = datasets.size();
for (int i = 0 ; i < numActors && !has_stuff ; i++)
for (int i = 0 ; i < numActors && !transparenciesExist; i++)
{
if (useActor[i] && visibility[i] == true)
{
int numParts = datasets[i].size();
for (int j = 0 ; j < numParts && !has_stuff ; j++)
for (int j = 0 ; j < numParts && !transparenciesExist; j++)
{
vtkDataSet *in_ds = datasets[i][j];
vtkActor *actor = actors[i][j];
......@@ -1344,16 +1381,17 @@ avtTransparencyActor::TransparenciesExist()
actor->GetProperty()->GetOpacity() > 0. &&
actor->GetProperty()->GetOpacity() < 1.)
{
has_stuff = true;
transparenciesExist = true;
}
}
}
}
// We need all processors to agree!
has_stuff = UnifyMaximumValue(has_stuff);
transparenciesExist = UnifyMaximumValue(transparenciesExist);
return has_stuff;
// Note that we've memo'ized this value.
cachedTransparencies = true;
}
......
......@@ -108,6 +108,9 @@ class vtkParallelImageSpaceRedistributor;
// Tom Fogal, Sun May 24 19:34:25 MDT 2009
// Added const to method.
//
// Tom Fogal, Mon May 25 14:03:14 MDT 2009
// Added caching for transparency calculation.
//
// ****************************************************************************
class PLOTTER_API avtTransparencyActor
......@@ -137,6 +140,9 @@ class PLOTTER_API avtTransparencyActor
bool TransparenciesExist(void);
bool TransparenciesMightExist(void) const;
void InvalidateTransparencyCache() {
cachedTransparencies = false;
}
void AddToRenderer(vtkRenderer *);
void RemoveFromRenderer(vtkRenderer *);
......@@ -175,8 +181,11 @@ class PLOTTER_API avtTransparencyActor
vtkMatrix4x4 *lastCamera;
bool renderingSuspended;
bool transparenciesExist;
bool cachedTransparencies;
void SetUpActor(void);
void PrepareDataset(int, int);
void DetermineTransparencies();
};
#endif
......@@ -91,6 +91,7 @@
#include <avtParallel.h>
#include <avtPickByNodeQuery.h>
#include <avtPickByZoneQuery.h>
#include <avtTransparencyActor.h>
#include <avtZonePickQuery.h>
#include <avtCurvePickQuery.h>
#include <avtSoftwareShader.h>
......@@ -5152,6 +5153,8 @@ NetworkManager::SetUpWindowContents(int windowID, const intVector &plotIds,
}
// see if there are any non-mesh plots in the list
// If there's both mesh and non-mesh plots, we don't make the mesh opaque
// (since it'd block other plots).
bool hasNonMeshPlots = HasNonMeshPlots(plotIds);
// see if we need the z-buffer to composite correctly in 2D.
......@@ -5363,6 +5366,11 @@ NetworkManager::SetUpWindowContents(int windowID, const intVector &plotIds,
// When initializing state, make sure to erase whatever memoization we had
// from the last frame.
//
// Tom Fogal, Mon May 25 18:36:19 MDT 2009
// Force transparency calculation here, so the value we get cached for later
// rendering. This prevents us from doing global comm while doing the
// rendering proper.
//
// ****************************************************************************
void
......@@ -5572,6 +5580,13 @@ NetworkManager::RenderSetup(intVector& plotIds, bool getZBuffer,
(viswin->GetWindowMode() == WINMODE_2D) ||
(viswin->GetWindowMode() == WINMODE_CURVE) ||
(viswin->GetWindowMode() == WINMODE_AXISARRAY);
{ // Force transparency calculation early for SR mode.
debug3 << "Forcing early calculation of transparency..." << std::endl;
avtTransparencyActor* trans = viswin->GetTransparencyActor();
trans->InvalidateTransparencyCache();
bool t = trans->TransparenciesExist();
}
}
// ****************************************************************************
......
......@@ -54,6 +54,7 @@ using std::string;
#include <avtDataObjectReader.h>
#include <avtWholeImageCompositerWithZ.h>
#include <avtToolInterface.h>
#include <avtTransparencyActor.h>
#include <AnimationAttributes.h>
#include <AnnotationAttributes.h>
......@@ -2315,11 +2316,18 @@ ViewerWindow::CopyGeneralAttributes(const ViewerWindow *source)
// Programmer: Eric Brugger
// Creation: February 20, 2001
//
// Modifications:
//
// Tom Fogal, Mon May 25 18:05:11 MDT 2009
// Invalidate the transparency cache to ensure it'll get recalculated later.
//
// ****************************************************************************
void
ViewerWindow::AddPlot(avtActor_p &actor)
{
avtTransparencyActor* trans = visWindow->GetTransparencyActor();
trans->InvalidateTransparencyCache();
visWindow->AddPlot(actor);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment