Commit b8b9c329 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Cleanup to get collaboration renders working.

parent a8100e8b
......@@ -30,11 +30,9 @@
#include "vtkOverlappingAMR.h"
#include "vtkPKdTree.h"
#include "vtkPointData.h"
#include "vtkProcessModule.h"
#include "vtkPVDataRepresentation.h"
#include "vtkPVDataRepresentationPipeline.h"
#include "vtkPVRenderView.h"
#include "vtkPVSession.h"
#include "vtkPVTrivialProducer.h"
#include "vtkRenderer.h"
#include "vtkSmartPointer.h"
......@@ -483,16 +481,6 @@ bool vtkPVDataDeliveryManager::NeedsDelivery(
void vtkPVDataDeliveryManager::Deliver(int use_lod, unsigned int size, unsigned int *values)
{
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
vtkPVSession* activeSession = vtkPVSession::SafeDownCast(pm->GetActiveSession());
if (activeSession && activeSession->IsMultiClients())
{
if (!this->RenderView->SynchronizeForCollaboration())
{
return;
}
}
// This method gets called on all processes with the list of representations
// to "deliver". We check with the view what mode we're operating in and
// decide where the data needs to be delivered.
......
......@@ -663,12 +663,15 @@ void vtkPVRenderView::ResetCamera(double bounds[6])
}
//----------------------------------------------------------------------------
bool vtkPVRenderView::SynchronizeForCollaboration()
bool vtkPVRenderView::TestCollaborationCounter()
{
bool counterSynchronizedSuccessfully = false;
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
vtkPVSession* activeSession = vtkPVSession::SafeDownCast(pm->GetActiveSession());
if (!activeSession || !activeSession->IsMultiClients())
{
return true;
}
// Also, can we optimize this further? This happens on every render in
// collaborative mode.
vtkMultiProcessController* p_controller =
this->SynchronizedWindows->GetParallelController();
vtkMultiProcessController* d_controller =
......@@ -678,28 +681,25 @@ bool vtkPVRenderView::SynchronizeForCollaboration()
if (d_controller != NULL)
{
vtkErrorMacro("RenderServer-DataServer configuration is not supported in "
"collabortion mode.");
"multi-clients mode. Please restart ParaView in the right mode. "
"Aborting since this could cause deadlocks and other issues.");
abort();
}
if (this->SynchronizedWindows->GetMode() == vtkPVSynchronizedRenderWindows::CLIENT)
{
vtkMultiProcessStream stream;
stream << this->SynchronizationCounter << this->RemoteRenderingThreshold;
r_controller->Send(stream, 1, 41000);
int server_sync_counter;
r_controller->Send(&this->SynchronizationCounter, 1, 1, 41000);
unsigned int server_sync_counter;
r_controller->Receive(&server_sync_counter, 1, 1, 41001);
counterSynchronizedSuccessfully =
(server_sync_counter == this->SynchronizationCounter);
return (server_sync_counter == this->SynchronizationCounter);
}
else
{
bool counterSynchronizedSuccessfully = false;
if (r_controller)
{
vtkMultiProcessStream stream;
r_controller->Receive(stream, 1, 41000);
int client_sync_counter;
stream >> client_sync_counter >> this->RemoteRenderingThreshold;
unsigned int client_sync_counter;
r_controller->Receive(&client_sync_counter, 1, 1, 41000);
r_controller->Send(&this->SynchronizationCounter, 1, 1, 41001 );
counterSynchronizedSuccessfully =
(client_sync_counter == this->SynchronizationCounter);
......@@ -712,8 +712,61 @@ bool vtkPVRenderView::SynchronizeForCollaboration()
p_controller->Broadcast(&temp, 1, 0);
counterSynchronizedSuccessfully = (temp == 1);
}
return counterSynchronizedSuccessfully;
}
}
//----------------------------------------------------------------------------
void vtkPVRenderView::SynchronizeForCollaboration()
{
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
vtkPVSession* activeSession = vtkPVSession::SafeDownCast(pm->GetActiveSession());
if (!activeSession || !activeSession->IsMultiClients())
{
return;
}
// Update decisions about lod-rendering and remote-rendering.
vtkMultiProcessController* p_controller =
this->SynchronizedWindows->GetParallelController();
vtkMultiProcessController* r_controller =
this->SynchronizedWindows->GetClientServerController();
if (this->SynchronizedWindows->GetMode() == vtkPVSynchronizedRenderWindows::CLIENT)
{
vtkMultiProcessStream stream;
stream << (this->UseLODForInteractiveRender? 1 : 0)
<< (this->UseDistributedRenderingForStillRender? 1 : 0)
<< (this->UseDistributedRenderingForInteractiveRender? 1 :0)
<< (this->UseOutlineForInteractiveRender? 1 : 0)
<< this->StillRenderProcesses
<< this->InteractiveRenderProcesses;
r_controller->Send(stream, 1, 42000);
}
else
{
vtkMultiProcessStream stream;
if (r_controller && r_controller->Receive(stream, 1, 42000))
{
if (p_controller)
{
p_controller->Broadcast(stream, 0);
}
int arg1, arg2, arg3, arg4;
stream >> arg1
>> arg2
>> arg3
>> arg4
>> this->StillRenderProcesses
>> this->InteractiveRenderProcesses;
this->UseLODForInteractiveRender = (arg1 == 1);
this->UseDistributedRenderingForStillRender = (arg2 == 1);
this->UseDistributedRenderingForInteractiveRender = (arg3 == 1);
this->UseOutlineForInteractiveRender = (arg4 == 1);
}
}
return counterSynchronizedSuccessfully;
}
//----------------------------------------------------------------------------
......@@ -879,6 +932,19 @@ void vtkPVRenderView::StreamingUpdate()
//----------------------------------------------------------------------------
void vtkPVRenderView::Render(bool interactive, bool skip_rendering)
{
if (this->SynchronizedWindows->GetMode() !=
vtkPVSynchronizedRenderWindows::CLIENT ||
(!interactive && this->UseDistributedRenderingForStillRender) ||
(interactive && this->UseDistributedRenderingForInteractiveRender))
{
// in multi-client modes, Render() will be called on client always. Now the
// client need to coordinate with server only when we are remote rendering.
// if Render() is called on server side, then we are indeed remote
// rendering, irrespective of what the local flags tell us and we need to
// coordinate with the client to update the local flags correctly.
this->SynchronizeForCollaboration();
}
bool in_tile_display_mode = this->InTileDisplayMode();
bool in_cave_mode = this->SynchronizedWindows->GetIsInCave();
if (in_cave_mode && !this->RemoteRenderingAvailable)
......@@ -974,6 +1040,25 @@ void vtkPVRenderView::Render(bool interactive, bool skip_rendering)
}
}
//----------------------------------------------------------------------------
void vtkPVRenderView::Deliver(int use_lod,
unsigned int size, unsigned int *representation_ids)
{
// if in multi-clients mode, ensure that processes are in the same "state"
// before doing the data delivery or we may end up with dead-locks due to
// mismatched representations.
if (!this->TestCollaborationCounter())
{
return;
}
// in multi-clients mode, for every Deliver() and Render() call, we obtain the
// remote-rendering related ivars from the client.
this->SynchronizeForCollaboration();
this->GetDeliveryManager()->Deliver(use_lod, size, representation_ids);
}
//----------------------------------------------------------------------------
int vtkPVRenderView::GetDataDistributionMode(bool use_remote_rendering)
{
......
......@@ -462,6 +462,13 @@ public:
// Provides access to the geometry storage for this view.
vtkPVDataDeliveryManager* GetDeliveryManager();
// Description:
// Called on all processes to request data-delivery for the list of
// representations. Note this method has to be called on all processes or it
// may lead to deadlock.
void Deliver(int use_lod,
unsigned int size, unsigned int *representation_ids);
// Description:
// Returns true when ordered compositing is needed on the current group of
// processes. Note that unlike most other functions, this may return different
......@@ -471,15 +478,6 @@ public:
// false
bool GetUseOrderedCompositing();
// Description:
// Synchronizes core ivars for multi-client setups.
bool SynchronizeForCollaboration();
// Description:
// SynchronizationCounter is used in multi-clients mode to ensure that the
// views on two different clients are in the same state as the server side.
vtkGetMacro(SynchronizationCounter, int);
//BTX
protected:
vtkPVRenderView();
......@@ -534,6 +532,21 @@ protected:
// displaying an image in a viewport.
bool GetLocalProcessDoesRendering(bool using_distributed_rendering);
// Description:
// In multi-clients mode, ensures that all processes are in the same "state"
// as far as the view is concerned. Returns false if that's not the case.
bool TestCollaborationCounter();
// Description:
// Synchronizes remote-rendering related parameters for collaborative
// rendering in multi-clients mode.
void SynchronizeForCollaboration();
// Description:
// SynchronizationCounter is used in multi-clients mode to ensure that the
// views on two different clients are in the same state as the server side.
vtkGetMacro(SynchronizationCounter, unsigned int);
vtkLight* Light;
vtkLightKit* LightKit;
vtkRenderViewBase* RenderView;
......@@ -560,7 +573,7 @@ protected:
// Used in collaboration mode to ensure that views are in the same state
// (as far as representations added/removed goes) before rendering.
int SynchronizationCounter;
unsigned int SynchronizationCounter;
// In mega-bytes.
double RemoteRenderingThreshold;
......
......@@ -82,10 +82,6 @@ void vtkSMDataDeliveryManager::Deliver(bool interactive)
vtkClientServerStream stream;
stream << vtkClientServerStream::Invoke
<< VTKOBJECT(this->ViewProxy)
<< "GetDeliveryManager"
<< vtkClientServerStream::End;
stream << vtkClientServerStream::Invoke
<< vtkClientServerStream::LastResult
<< "Deliver"
<< static_cast<int>(use_lod)
<< static_cast<unsigned int>(keys_to_deliver.size())
......
......@@ -17,7 +17,13 @@
// .SECTION Description
// vtkSMDataDeliveryManager is the server-manager wrapper for
// vtkPVDataDeliveryManager. It manages calling on methods on instances of
// vtkPVDataDeliveryManager.
// vtkPVDataDeliveryManager. Before every render call, vtkSMRenderViewProxy
// calls vtkSMDataDeliveryManager::Deliver() to ensure that any geometries that
// need to be delivered are explicitly delivered. This separating into
// Update-Deliver-Render calls ensures makes it possible to extend the framework
// for streaming, in future.
//
// The streaming components of this class are experimental and will be changed.
#ifndef __vtkSMDataDeliveryManager_h
#define __vtkSMDataDeliveryManager_h
......@@ -38,7 +44,9 @@ public:
void SetViewProxy(vtkSMViewProxy*);
// Description:
// Called to request delivery of the geometry.
// Called to request delivery of the geometry. This checks the client-side
// vtkPVDataDeliveryManager instance to see if any geometries need to be
// delivered and then requests delivery for those.
void Deliver(bool interactive);
// Description:
......
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