Commit cca3d092 authored by David E. DeMarle's avatar David E. DeMarle Committed by Kitware Robot

Merge topic 'plug-more-v2osp-memory-leaks'

6af94ebb suppress and fix comp warnings
6a91019c use osp release not delete with osp volumes to prevent crashes
7e72778b don't leak ospray buffer either
fc779976 dont leak the light either
d67f69e2 Fix a huge memory leak.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Ken Martin's avatarKen Martin <ken.martin@kitware.com>
Merge-request: !4331
parents ade4e46b 6af94ebb
......@@ -30,8 +30,18 @@
#include "vtkVolumeNode.h"
#include "vtkVolumeProperty.h"
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
#include "ospcommon/box.h"
#include "ospcommon/vec.h"
// Undo disabling of warning.
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#include "ospray/ospray.h"
#include "ospray/version.h"
......@@ -152,9 +162,9 @@ void vtkOSPRayAMRVolumeMapperNode::Render(bool prepass)
}
else
{
if (this->OSPRayVolume && this->Cache->GetSize() == 0)
if (this->Cache->GetSize() == 0)
{
delete this->OSPRayVolume;
ospRelease(this->OSPRayVolume);
}
this->OSPRayVolume = ospNewVolume("amr_volume");
this->Cache->AddToCache(tstep, this->OSPRayVolume);
......@@ -173,7 +183,10 @@ void vtkOSPRayAMRVolumeMapperNode::Render(bool prepass)
iter->GoToNextItem())
{
unsigned int level = iter->GetCurrentLevel();
assert(level >= lastLevel); //ospray requires level info be ordered lowest to highest
if (!(level >= lastLevel))
{
vtkErrorMacro("ospray requires level info be ordered lowest to highest");
};
lastLevel = level;
unsigned int index = iter->GetCurrentIndex();
......
......@@ -38,11 +38,13 @@ vtkStandardNewMacro(vtkOSPRayLightNode);
//----------------------------------------------------------------------------
vtkOSPRayLightNode::vtkOSPRayLightNode()
{
this->OLight = nullptr;
}
//----------------------------------------------------------------------------
vtkOSPRayLightNode::~vtkOSPRayLightNode()
{
ospRelease((OSPLight)this->OLight);
}
//----------------------------------------------------------------------------
......@@ -120,6 +122,9 @@ void vtkOSPRayLightNode::Render(bool prepass)
{
if (prepass)
{
ospRelease((OSPLight)this->OLight);
OSPLight ospLight;
vtkOSPRayRendererNode *orn =
static_cast<vtkOSPRayRendererNode *>(
this->GetFirstAncestorOfType("vtkOSPRayRendererNode"));
......@@ -136,7 +141,7 @@ void vtkOSPRayLightNode::Render(bool prepass)
}
if (vtkOSPRayLightNode::GetIsAmbient(light))
{
OSPLight ospLight = ospNewLight(oRenderer, "ambient");
ospLight = ospNewLight(oRenderer, "ambient");
color[0] = static_cast<float>(light->GetDiffuseColor()[0]);
color[1] = static_cast<float>(light->GetDiffuseColor()[1]);
color[2] = static_cast<float>(light->GetDiffuseColor()[2]);
......@@ -163,7 +168,6 @@ void vtkOSPRayLightNode::Render(bool prepass)
pz = p[2];
}
float coneAngle = static_cast<float>(light->GetConeAngle());
OSPLight ospLight;
if (coneAngle <= 0.0)
{
ospLight = ospNewLight(oRenderer, "PointLight");
......@@ -225,7 +229,7 @@ void vtkOSPRayLightNode::Render(bool prepass)
direction[0] = fx - px;
direction[1] = fy - py;
direction[2] = fz - pz;
OSPLight ospLight = ospNewLight(oRenderer, "DirectionalLight");
ospLight = ospNewLight(oRenderer, "DirectionalLight");
ospSet3f(ospLight, "color", color[0], color[1], color[2]);
float fI = static_cast<float>
(vtkOSPRayLightNode::LightScale*
......@@ -240,5 +244,6 @@ void vtkOSPRayLightNode::Render(bool prepass)
ospCommit(ospLight);
orn->AddLight(ospLight);
}
this->OLight = ospLight;
}
}
......@@ -91,6 +91,7 @@ private:
void operator=(const vtkOSPRayLightNode&) = delete;
static double LightScale;
void *OLight;
};
#endif
......@@ -445,18 +445,9 @@ vtkOSPRayRendererNode::~vtkOSPRayRendererNode()
delete[] this->Buffer;
delete[] this->ZBuffer;
delete[] this->ODepthBuffer;
if (this->OModel)
{
ospRelease((OSPModel)this->OModel);
}
if (this->ORenderer)
{
ospRelease((OSPRenderer)this->ORenderer);
}
if (this->OFrameBuffer)
{
ospRelease(this->OFrameBuffer);
}
ospRelease((OSPModel)this->OModel);
ospRelease((OSPRenderer)this->ORenderer);
ospRelease(this->OFrameBuffer);
this->AccumulateMatrix->Delete();
delete this->Internal;
}
......@@ -837,7 +828,7 @@ void vtkOSPRayRendererNode::Traverse(int operation)
(numAct != this->NumActors))
{
this->NumActors = numAct;
//ospRelease((OSPModel)this->OModel);
ospRelease((OSPModel)this->OModel);
oModel = ospNewModel();
this->OModel = oModel;
it->InitTraversal();
......@@ -996,6 +987,7 @@ void vtkOSPRayRendererNode::Render(bool prepass)
{
this->ImageX = this->Size[0];
this->ImageY = this->Size[1];
ospRelease(this->OFrameBuffer);
this->OFrameBuffer = ospNewFrameBuffer
(isize,
OSP_FB_RGBA8,
......
......@@ -51,9 +51,9 @@ vtkOSPRayTetrahedraMapperNode::vtkOSPRayTetrahedraMapperNode()
vtkOSPRayTetrahedraMapperNode::~vtkOSPRayTetrahedraMapperNode()
{
ospRelease(this->TransferFunction);
if (this->OSPRayVolume && this->Cache->GetSize() == 0)
if (this->Cache->GetSize() == 0)
{
delete this->OSPRayVolume;
ospRelease(this->OSPRayVolume);
}
delete this->Cache;
}
......@@ -150,7 +150,7 @@ void vtkOSPRayTetrahedraMapperNode::Render(bool prepass)
{
if (this->OSPRayVolume && this->Cache->GetSize() == 0)
{
delete this->OSPRayVolume;
ospRelease(this->OSPRayVolume);
}
#if OSPRAY_VERSION_MAJOR == 1 && OSPRAY_VERSION_MINOR >= 5
this->OSPRayVolume = ospNewVolume("unstructured_volume");
......
......@@ -37,10 +37,7 @@ void vtkOSPRayVolumeCache::AddToCache(double tstep, osp::Volume *payload)
return;
}
osp::Volume *content = this->GetFromCache(tstep);
if (content)
{
delete content;
}
ospRelease(content);
this->Contents[tstep] = payload;
}
......@@ -60,7 +57,7 @@ void vtkOSPRayVolumeCache::Empty()
{
for (auto itr : this->Contents)
{
delete itr.second;
ospRelease(itr.second);
}
this->Contents.clear();
this->Size = 0;
......
......@@ -51,9 +51,9 @@ vtkOSPRayVolumeMapperNode::vtkOSPRayVolumeMapperNode()
vtkOSPRayVolumeMapperNode::~vtkOSPRayVolumeMapperNode()
{
ospRelease(this->TransferFunction);
if (this->OSPRayVolume && this->Cache->GetSize() == 0)
if (this->Cache->GetSize() == 0)
{
delete this->OSPRayVolume;
ospRelease(this->OSPRayVolume);
}
delete this->Cache;
}
......@@ -181,9 +181,9 @@ void vtkOSPRayVolumeMapperNode::Render(bool prepass)
return;
}
if (this->OSPRayVolume && this->Cache->GetSize() == 0)
if (this->Cache->GetSize() == 0)
{
delete this->OSPRayVolume;
ospRelease(this->OSPRayVolume);
}
this->OSPRayVolume = ospNewVolume("block_bricked_volume");
this->Cache->AddToCache(tstep, this->OSPRayVolume);
......
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