Commit 26079f9a authored by Aashish Chaudhary's avatar Aashish Chaudhary
Browse files

Query device id instead of using a fixed number

Change-Id: I6e2889fe130a27e6bf67583ac547bce180607d67
parent 5a629edc
...@@ -177,7 +177,7 @@ void MyProcess::Execute() ...@@ -177,7 +177,7 @@ void MyProcess::Execute()
renWin->Render(); renWin->Render();
// TODO: Add an argument to decide if use interop or not // TODO: Add an argument to decide if use interop or not
vtkPistonMapper::InitCUDAGL(renWin); vtkPistonMapper::InitCudaGL(renWin);
this->CreatePipeline(renderer); this->CreatePipeline(renderer);
prm->SetRenderWindow(renWin); prm->SetRenderWindow(renWin);
......
...@@ -41,7 +41,7 @@ int TestUsePiston( int argc, char *argv[] ) ...@@ -41,7 +41,7 @@ int TestUsePiston( int argc, char *argv[] )
// Initialize interop rendering using that context // Initialize interop rendering using that context
// TODO: Add an argument to decide if use interop or not // TODO: Add an argument to decide if use interop or not
vtkPistonMapper::InitCUDAGL(renwin); vtkPistonMapper::InitCudaGL(renwin);
vtkImageMandelbrotSource *src = vtkImageMandelbrotSource::New(); vtkImageMandelbrotSource *src = vtkImageMandelbrotSource::New();
src->SetWholeExtent(0,20,0,20,0,20); src->SetWholeExtent(0,20,0,20,0,20);
......
...@@ -23,7 +23,7 @@ class TestRendering(Testing.vtkTest): ...@@ -23,7 +23,7 @@ class TestRendering(Testing.vtkTest):
if "GPURender" in args: if "GPURender" in args:
print "Testing GPU direct render path" print "Testing GPU direct render path"
vtk.vtkPistonMapper.InitCUDAGL(renwin) vtk.vtkPistonMapper.InitCudaGL(renwin)
else: else:
print "Testing CPU indirect render path" print "Testing CPU indirect render path"
......
...@@ -97,12 +97,24 @@ struct color_map : thrust::unary_function<ValueType, float3> ...@@ -97,12 +97,24 @@ struct color_map : thrust::unary_function<ValueType, float3>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void CudaGLInit() void CudaGLInit()
{ {
cudaError_t res = cudaGLSetGLDevice(0); cudaDeviceProp prop;
int dev;
// Fill it with zeros
memset(&prop,0,sizeof(cudaDeviceProp));
// Pick a GPU capable of 1.0 or better
prop.major=1; prop.minor=0;
cudaChooseDevice(&dev,&prop);
// Set OpenGL device
cudaError_t res = cudaGLSetGLDevice(dev);
if (res != cudaSuccess) if (res != cudaSuccess)
{ {
cerr << "Set device failed ... " << cudaGetErrorString(res) << endl; cerr << "Set device failed ... " << cudaGetErrorString(res) << endl;
return; return;
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -88,7 +88,7 @@ vtkStandardNewMacro(vtkPistonMapper); ...@@ -88,7 +88,7 @@ vtkStandardNewMacro(vtkPistonMapper);
bool vtkPistonMapper::CudaGLInitted = false; bool vtkPistonMapper::CudaGLInitted = false;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void vtkPistonMapper::InitCUDAGL(vtkRenderWindow *rw) void vtkPistonMapper::InitCudaGL(vtkRenderWindow *rw)
{ {
if (!vtkPistonMapper::CudaGLInitted) if (!vtkPistonMapper::CudaGLInitted)
{ {
......
...@@ -41,7 +41,14 @@ public: ...@@ -41,7 +41,14 @@ public:
// Description: // Description:
// Manually call this before any cuda filters are created // Manually call this before any cuda filters are created
// to use direct GPU rendering. // to use direct GPU rendering.
static void InitCUDAGL(vtkRenderWindow *rw); static void InitCudaGL(vtkRenderWindow *rw);
// Description:
// Return true if using cuda interop feature otherwise false.
inline static bool IsEnabledCudaGL()
{
return CudaGLInitted;
}
// Description: // Description:
// A convenience method to reduce code duplication that gets // A convenience method to reduce code duplication that gets
......
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