Skip to content

Commit

Permalink
fix_GPU_resource_handling
Browse files Browse the repository at this point in the history
Change-Id: I4fdb88c0700e5ca73fd6eba087a230c3cbacdba8
  • Loading branch information
Shinya Onogi committed Aug 15, 2014
1 parent c6200b3 commit 313b647
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Accelerators/Piston/vtkPistonDataWrangling.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
#ifndef __vtkPistonDataWrangling_h
#define __vtkPistonDataWrangling_h

#define SPACE thrust::detail::default_device_space_tag
#include <thrust/version.h>
#if THRUST_VERSION >= 100600
# define SPACE thrust::device_space_tag
#else
# define SPACE thrust::detail::default_device_space_tag
#endif

namespace vtkpiston {

Expand Down
11 changes: 11 additions & 0 deletions Accelerators/Piston/vtkPistonMapper.cu
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ void CudaRegisterBuffer(struct cudaGraphicsResource **vboResource,
}
}

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

//------------------------------------------------------------------------------
void CudaTransferToGL(vtkPistonDataObject *id, unsigned long dataObjectMTimeCache,
vtkPistonScalarsColors *psc,
Expand Down
4 changes: 4 additions & 0 deletions Accelerators/Piston/vtkPistonMapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace vtkpiston {
int QueryVertsPer(vtkPistonDataObject *id);
void CudaRegisterBuffer(struct cudaGraphicsResource **vboResource,
GLuint vboBuffer);
void CudaUnregisterResource(struct cudaGraphicsResource* vboResource);
void CudaTransferToGL(vtkPistonDataObject *id, unsigned long dataObjectMTimeCache,
vtkPistonScalarsColors *psc,
struct cudaGraphicsResource **vboResources,
Expand Down Expand Up @@ -148,6 +149,9 @@ void vtkPistonMapper::PrepareDirectRenderBuffers(int nPoints)
if (this->Internal->BufferSize != 0)
{
// Release old buffer
vtkpiston::CudaUnregisterResource(this->Internal->vboResources[0]);
vtkpiston::CudaUnregisterResource(this->Internal->vboResources[1]);
vtkpiston::CudaUnregisterResource(this->Internal->vboResources[2]);
vtkgl::DeleteBuffers(3, this->Internal->vboBuffers);
vtkOpenGLCheckErrorMacro("failed at glDeleteBuffers");
}
Expand Down

0 comments on commit 313b647

Please sign in to comment.