[vtk-developers] vtkPistonMapper bug

Onogi Shinya shinya.onogi at live.jp
Thu Aug 14 01:24:05 EDT 2014


Hi all:

vtkPistonMapper calls vtkpiston::CudaRegisterBuffer in every gpu rendering (in vtkPistonMapper.cxx; L181-L186); however, cudaGraphicsUnregisterResource is never called. It results in a gpu resource issue when vtkPistonAlgorithm is updated several times.

Quick solution I tested is followings:
vtkPistonMapper.cxx
43   void CudaRegisterBuffer(struct cudaGraphicsResource **vboResource,
44                           GLuint vboBuffer);
+    void CudaUnregisterBuffer(struct cudaGraphicsResource **vboResource);

148 if (this->Internal->BufferSize != 0)
149   {
150    // Release old buffer
+      vtkpiston::CudaUnregisterResource(this->Internal->vboResources[0]);
+      vtkpiston::CudaUnregisterResource(this->Internal->vboResources[1]);
+      vtkpiston::CudaUnregisterResource(this->Internal->vboResources[2]);
151    vtkgl::DeleteBuffers(3, this->Internal->vboBuffers);

vtkPistonMapper.cu
void CudaUnregisterResource(struct cudaGraphicsResource *vboResource)
{
  cudaError_t res = cudaGraphicsUnregisterResource(vboResource);
  if (res != cudaSuccess)
  {
    cerr << "Unregister buffer failed ... " << cudaGetErrorString(res) << endl;
    return;
  }
}

But, register/unregister in every rendering wouldn't be needed according to samples of gl interop with cuda.
Thnaks,
Shinya

 		 	   		  


More information about the vtk-developers mailing list