Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit 79d15a2c authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Bringing back support for ordered compositing.

parent c18a9cba
......@@ -202,8 +202,13 @@ int vtkGeometryRepresentation::ProcessViewRequest(
// When this process doesn't have any valid input, the cache-keeper is setup
// to provide a place-holder dataset of the right type.
vtkPVRenderView::SetPiece(inInfo, this,
this->CacheKeeper->GetOutputDataObject(0));
vtkPVRenderView::SetPiece(
inInfo, this, this->CacheKeeper->GetOutputDataObject(0));
vtkPVRenderView::MarkAsRedistributable(inInfo, this);
if (this->Actor->GetProperty()->GetOpacity() < 1.0)
{
outInfo->Set(vtkPVRenderView::NEED_ORDERED_COMPOSITING(), 1);
}
}
else if (request_type == vtkPVView::REQUEST_UPDATE_LOD())
{
......
......@@ -100,6 +100,8 @@ int vtkImageVolumeRepresentation::ProcessViewRequest(
// vtkPVRenderView::SetPiece(inInfo, this, this->Cache);
vtkPVRenderView::SetPiece(inInfo, this,
this->OutlineSource->GetOutputDataObject(0));
outInfo->Set(vtkPVRenderView::NEED_ORDERED_COMPOSITING(), 1);
}
else if (request_type == vtkPVView::REQUEST_RENDER())
{
......
......@@ -17,7 +17,6 @@
#include "vtk3DWidgetRepresentation.h"
#include "vtkAlgorithmOutput.h"
#include "vtkBoundingBox.h"
#include "vtkBSPCutsGenerator.h"
#include "vtkCamera.h"
#include "vtkCommand.h"
#include "vtkDataRepresentation.h"
......@@ -154,6 +153,7 @@ vtkPVRenderView::vtkPVRenderView()
this->Selector = vtkPVHardwareSelector::New();
this->SynchronizationCounter = 0;
this->PreviousParallelProjectionStatus = 0;
this->NeedsOrderedCompositing = false;
this->LastComputedBounds[0] = this->LastComputedBounds[2] =
this->LastComputedBounds[4] = -1.0;
......@@ -208,8 +208,6 @@ vtkPVRenderView::vtkPVRenderView()
this->GetRenderer()->AddLight(this->Light);
this->GetRenderer()->SetAutomaticLightCreation(0);
this->OrderedCompositingBSPCutsSource = vtkBSPCutsGenerator::New();
if (this->Interactor)
{
this->InteractorStyle = // Default one will be the 3D
......@@ -310,9 +308,6 @@ vtkPVRenderView::~vtkPVRenderView()
this->RubberBandZoom = 0;
}
this->OrderedCompositingBSPCutsSource->Delete();
this->OrderedCompositingBSPCutsSource = NULL;
delete this->Internals;
this->Internals = NULL;
}
......@@ -798,6 +793,21 @@ void vtkPVRenderView::Update()
this->Superclass::Update();
// check if any representation told us that it needed ordered compositing.
this->NeedsOrderedCompositing = false;
int num_reprs = this->ReplyInformationVector->GetNumberOfInformationObjects();
for (int cc=0; cc < num_reprs; cc++)
{
vtkInformation* info =
this->ReplyInformationVector->GetInformationObject(cc);
if (info->Has(NEED_ORDERED_COMPOSITING()) &&
info->Get(NEED_ORDERED_COMPOSITING()) != 0)
{
this->NeedsOrderedCompositing= true;
break;
}
}
// Gather information about geometry sizes from all representations.
double local_size = this->GetGeometryStore()->GetVisibleDataSize(false) / 1024.0;
this->SynchronizedWindows->SynchronizeSize(local_size);
......@@ -980,6 +990,9 @@ void vtkPVRenderView::Render(bool interactive, bool skip_rendering)
in_cave_mode ||
(!use_distributed_rendering && in_tile_display_mode));
this->SynchronizedRenderers->SetKdTree(
this->Internals->GeometryStore->GetKdTree());
// When in batch mode, we are using the same render window for all views. That
// makes it impossible for vtkPVSynchronizedRenderWindows to identify which
// view is being rendered. We explicitly mark the view being rendered using
......@@ -1092,6 +1105,21 @@ vtkAlgorithmOutput* vtkPVRenderView::GetPieceProducerLOD(vtkInformation* info,
return storage->GetProducer(repr, true);
}
//----------------------------------------------------------------------------
void vtkPVRenderView::MarkAsRedistributable(
vtkInformation* info, vtkPVDataRepresentation* repr)
{
vtkRepresentedDataStorage* storage =
vtkRepresentedDataStorage::SafeDownCast(
info->Get(REPRESENTED_DATA_STORE()));
if (!storage)
{
vtkGenericWarningMacro("Missing REPRESENTED_DATA_STORE().");
return;
}
storage->MarkAsRedistributable(repr);
}
//----------------------------------------------------------------------------
void vtkPVRenderView::SetDeliverToAllProcesses(vtkInformation* info,
vtkPVDataRepresentation* repr, bool clone)
......@@ -1160,6 +1188,11 @@ bool vtkPVRenderView::GetUseOrderedCompositing()
return false;
}
if (!this->NeedsOrderedCompositing)
{
return false;
}
switch (vtkProcessModule::GetProcessType())
{
case vtkProcessModule::PROCESS_SERVER:
......
......@@ -38,7 +38,6 @@
#include "vtkPVView.h"
class vtkAlgorithmOutput;
class vtkBSPCutsGenerator;
class vtkCamera;
class vtkCameraManipulator;
class vtkInformationDoubleKey;
......@@ -385,6 +384,8 @@ public:
vtkInformation* info, vtkPVDataRepresentation* repr, bool clone);
static void SetDeliverLODToAllProcesses(
vtkInformation* info, vtkPVDataRepresentation* repr, bool clone);
static void MarkAsRedistributable(
vtkInformation* info, vtkPVDataRepresentation* repr);
public:
//*****************************************************************
......@@ -520,6 +521,16 @@ public:
// Provides access to the geometry storage for this view.
vtkRepresentedDataStorage* GetGeometryStore();
// Description:
// Returns true when ordered compositing is needed on the current group of
// processes. Note that unlike most other functions, this may return different
// values on different processes e.g.
// \li always false on client and dataserver
// \li true on pvserver or renderserver if opacity < 1 or volume present, else
// false
bool GetUseOrderedCompositing();
//BTX
protected:
vtkPVRenderView();
......@@ -560,15 +571,6 @@ protected:
// @CallOnAllProcessess
void GatherBoundsInformation(bool using_remote_rendering);
// Description:
// Returns true when ordered compositing is needed on the current group of
// processes. Note that unlike most other functions, this may return different
// values on different processes e.g.
// \li always false on client and dataserver
// \li true on pvserver or renderserver if opacity < 1 or volume present, else
// false
bool GetUseOrderedCompositing();
// Description:
// Set the last selection object.
void SetLastSelection(vtkSelection*);
......@@ -624,6 +626,7 @@ protected:
bool UseOffscreenRendering;
bool UseOffscreenRenderingForScreenshots;
bool UseInteractiveRenderingForSceenshots;
bool NeedsOrderedCompositing;
double LODResolution;
bool UseLightKit;
......@@ -636,8 +639,6 @@ protected:
static bool RemoteRenderingAllowed;
vtkBSPCutsGenerator* OrderedCompositingBSPCutsSource;
vtkTimeStamp UpdateTime;
vtkTimeStamp StillRenderTime;
vtkTimeStamp InteractiveRenderTime;
......
......@@ -15,11 +15,16 @@
#include "vtkRepresentedDataStorage.h"
#include "vtkRepresentedDataStorageInternals.h"
#include "vtkObjectFactory.h"
#include "vtkAlgorithmOutput.h"
#include "vtkPVRenderView.h"
#include "vtkNew.h"
#include "vtkBSPCutsGenerator.h"
#include "vtkMPIMoveData.h"
#include "vtkMultiProcessController.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkOrderedCompositeDistributor.h"
#include "vtkPKdTree.h"
#include "vtkPVRenderView.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkTimerLog.h"
vtkStandardNewMacro(vtkRepresentedDataStorage);
......@@ -93,6 +98,22 @@ void vtkRepresentedDataStorage::SetDeliverToAllProcesses(
}
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::MarkAsRedistributable(
vtkPVDataRepresentation* repr)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(repr, false);
vtkInternals::vtkItem* low_item = this->Internals->GetItem(repr, true);
if (item)
{
item->Redistributable = true;
low_item->Redistributable = true;
}
else
{
vtkErrorMacro("Invalid argument.");
}
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::SetPiece(
......@@ -196,6 +217,7 @@ void vtkRepresentedDataStorage::Deliver(int use_lod, unsigned int size, int *val
this->View->GetUseDistributedRenderingForStillRender();
int mode = this->View->GetDataDistributionMode(using_remote_rendering);
for (unsigned int cc=0; cc < size; cc++)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(values[cc], use_lod !=0);
......@@ -214,10 +236,82 @@ void vtkRepresentedDataStorage::Deliver(int use_lod, unsigned int size, int *val
dataMover->Update();
item->SetDataObject(dataMover->GetOutputDataObject(0));
}
// There's a possibility that we'd need to do ordered compositing.
// Ask the view if we need to redistribute the data for ordered compositing.
bool use_ordered_compositing = using_remote_rendering &&
this->View->GetUseOrderedCompositing();
if (use_ordered_compositing && !use_lod)
{
vtkNew<vtkBSPCutsGenerator> cutsGenerator;
vtkInternals::ItemsMapType::iterator iter;
for (iter = this->Internals->ItemsMap.begin();
iter != this->Internals->ItemsMap.end(); ++iter)
{
vtkInternals::vtkItem& item = iter->second.first;
if (item.Representation &&
item.Representation->GetVisibility() &&
item.Redistributable)
{
cutsGenerator->AddInputData(item.GetDataObject());
}
}
vtkMultiProcessController* controller =
vtkMultiProcessController::GetGlobalController();
vtkStreamingDemandDrivenPipeline *sddp = vtkStreamingDemandDrivenPipeline::
SafeDownCast(cutsGenerator->GetExecutive());
sddp->SetUpdateExtent
(0,controller->GetLocalProcessId(),controller->GetNumberOfProcesses(),0);
sddp->Update(0);
this->KdTree = cutsGenerator->GetPKdTree();
}
else if (!use_lod)
{
this->KdTree = NULL;
}
// FIXME:STREAMING
// 1. Fix code to avoid recomputing of KdTree unless really necessary.
// 2. If KdTree is recomputed and is indeed different, then we need to
// redistribute all the visible "redistributable" datasets, not just the
// ones being requested.
if (this->KdTree)
{
vtkTimerLog::MarkStartEvent("Redistributing Data for Ordered Compositing");
for (unsigned int cc=0; cc < size; cc++)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(values[cc], use_lod !=0);
if (!item->Redistributable)
{
continue;
}
vtkDataObject* data = item->GetDataObject();
vtkNew<vtkOrderedCompositeDistributor> redistributor;
redistributor->SetController(vtkMultiProcessController::GetGlobalController());
redistributor->SetInputData(data);
redistributor->SetPKdTree(this->KdTree);
redistributor->SetPassThrough(0);
redistributor->Update();
item->SetDataObject(redistributor->GetOutputDataObject(0));
}
vtkTimerLog::MarkEndEvent("Redistributing Data for Ordered Compositing");
}
vtkTimerLog::MarkEndEvent(use_lod?
"LowRes Data Migration" : "FullRes Data Migration");
}
//----------------------------------------------------------------------------
vtkPKdTree* vtkRepresentedDataStorage::GetKdTree()
{
return this->KdTree;
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -25,11 +25,13 @@
#include "vtkObject.h"
#include "vtkWeakPointer.h"
#include "vtkSmartPointer.h"
class vtkAlgorithmOutput;
class vtkDataObject;
class vtkPVDataRepresentation;
class vtkPVRenderView;
class vtkPKdTree;
//BTX
#include <vector>
......@@ -66,6 +68,13 @@ public:
void SetView(vtkPVRenderView*);
// Description:
// Render-view specific API to mark a piece as "re-distributable" i.e. it
// needs to be "moved around" when ordered compositing is needed.
void MarkAsRedistributable(vtkPVDataRepresentation*);
vtkPKdTree* GetKdTree();
//BTX
bool NeedsDelivery(unsigned long timestamp,
std::vector<int>& keys_to_deliver, bool use_low_res);
......@@ -75,6 +84,7 @@ protected:
~vtkRepresentedDataStorage();
vtkWeakPointer<vtkPVRenderView> View;
vtkSmartPointer<vtkPKdTree> KdTree;
private:
vtkRepresentedDataStorage(const vtkRepresentedDataStorage&); // Not implemented
......
......@@ -40,12 +40,14 @@ public:
public:
vtkWeakPointer<vtkPVDataRepresentation> Representation;
bool AlwaysClone;
bool Redistributable;
vtkItem() :
Producer(vtkSmartPointer<vtkPVTrivialProducer>::New()),
TimeStamp(0),
ActualMemorySize(0),
AlwaysClone(false)
AlwaysClone(false),
Redistributable(false)
{ }
void SetDataObject(vtkDataObject* data)
......
......@@ -189,8 +189,11 @@ int vtkUnstructuredGridVolumeRepresentation::ProcessViewRequest(
if (request_type == vtkPVView::REQUEST_UPDATE())
{
outInfo->Set(vtkPVRenderView::NEED_ORDERED_COMPOSITING(), 1);
vtkPVRenderView::SetPiece(inInfo, this,
this->CacheKeeper->GetOutputDataObject(0));
vtkPVRenderView::MarkAsRedistributable(inInfo, this);
}
else if (request_type == vtkPVView::REQUEST_UPDATE_LOD())
{
......
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