Commit 5c1c4b19 authored by Ken Martin's avatar Ken Martin

Fix some release graphics resource issues

ParaView IceT does a WindowRemap when using tile display. That
means everythgin has to work with a new window/context so it
identifies a bunch of release graphics resource issues. This
patch fixes a bunch of them. Mostly minor changes the one
large change is to make ReleaseGraphicsResources in Renderer
public like it is for every other class. This is the way it
should be and the original protected method was a mistake from
way way back.  Making it public save us from doing the

SetRenderWindow(NULL)
SetRenderWindow(this)

hack that we have been using to free up resources in the
renderer since we could nto call the protected method.

Change-Id: If31406fa9425417d240311aac110c82409637163
parent 6a3b4f53
......@@ -485,6 +485,9 @@ public:
vtkGetMacro(TexturedBackground,bool);
vtkBooleanMacro(TexturedBackground,bool);
// method to release graphics resources in any derived renderers.
virtual void ReleaseGraphicsResources(vtkWindow *) { }
//BTX
protected:
vtkRenderer();
......@@ -499,9 +502,6 @@ protected:
// frustum is used.
virtual void ExpandBounds(double bounds[6], vtkMatrix4x4 *matrix);
// Internal method to release graphics resources in any derived renderers.
virtual void ReleaseGraphicsResources(vtkWindow *) { }
vtkCamera *ActiveCamera;
vtkLight *CreatedLight;
......
......@@ -140,23 +140,29 @@ void vtkOpenGLRenderWindow::ReleaseGraphicsResources()
vtkRenderer *aren;
while ( (aren = this->Renderers->GetNextRenderer(rsit)) )
{
// the following has the effect of release the graphics resources since
// Renderer's ReleaseGraphicsResources call is protected
aren->SetRenderWindow(NULL);
aren->SetRenderWindow(this);
if (aren->GetRenderWindow() == this)
{
aren->ReleaseGraphicsResources(this);
}
}
this->ShaderCache->ReleaseGraphicsResources(this);
if(this->DrawPixelsTextureObject != 0)
{
this->DrawPixelsTextureObject->ReleaseGraphicsResources(this);
}
// if(this->TextureUnitManager!=0)
// {
// this->TextureUnitManager->ReleaseGraphicsResources(this);
// }
// this->ShaderCache->ReleaseGraphicsResources(this);
this->ShaderCache->ReleaseGraphicsResources(this);
if (this->TextureResourceIds.size())
{
vtkErrorMacro("There are still active textures when there should not be.");
typedef std::map<const vtkTextureObject *, int>::const_iterator TRIter;
TRIter found = this->TextureResourceIds.begin();
for ( ; found != this->TextureResourceIds.end(); found++)
{
vtkErrorMacro("Leaked for texture object: " << const_cast<vtkTextureObject *>(found->first));
}
}
}
......
......@@ -414,6 +414,10 @@ void vtkOpenGLRenderer::ReleaseGraphicsResources(vtkWindow *w)
{
this->Pass->ReleaseGraphicsResources(w);
}
if (w && this->DepthPeelingPass)
{
this->DepthPeelingPass->ReleaseGraphicsResources(w);
}
}
void vtkOpenGLRenderer::UpdatePickId()
......
......@@ -212,7 +212,7 @@ void vtkOpenGLShaderCache::ReleaseGraphicsResources(vtkWindow *win)
// have to loop over all the programs were in use and invoke
// release graphics resources individually.
this->LastShaderBound = NULL;
this->ReleaseCurrentShader();
typedef std::map<std::string,vtkShaderProgram*>::const_iterator SMapIter;
SMapIter iter = this->Internal->ShaderPrograms.begin();
......
......@@ -436,11 +436,20 @@ void vtkTextureObject::ReleaseGraphicsResources(vtkWindow *win)
// It is almost guarenteed that in case of valid handle, we will have
// value other than zero. A check like this may be required at other
// places as well.
if (this->Handle)
if (this->Handle && rwin)
{
rwin->ActivateTexture(this);
this->UnBind();
rwin->DeactivateTexture(this);
GLuint tex = this->Handle;
glDeleteTextures(1, &tex);
this->Handle = 0;
this->NumberOfDimensions = 0;
this->Target =0;
this->Format = 0;
this->Type = 0;
this->Components = 0;
this->Width = this->Height = this->Depth = 0;
}
if (this->ShaderProgram)
{
......@@ -468,8 +477,11 @@ void vtkTextureObject::Bind()
//----------------------------------------------------------------------------
void vtkTextureObject::UnBind()
{
glBindTexture(this->Target, 0);
vtkOpenGLCheckErrorMacro("failed at glBindTexture(0)");
if (this->Target)
{
glBindTexture(this->Target, 0);
vtkOpenGLCheckErrorMacro("failed at glBindTexture(0)");
}
}
//----------------------------------------------------------------------------
......
......@@ -115,6 +115,7 @@ void vtkWin32OpenGLRenderWindow::CleanUpRenderers()
{
ren->SetRenderWindow(NULL);
}
this->ReleaseGraphicsResources();
}
LRESULT APIENTRY vtkWin32OpenGLRenderWindow::WndProc(HWND hWnd, UINT message,
......
......@@ -25,5 +25,4 @@ uniform sampler2D depth;
void main(void)
{
gl_FragDepth = texture2D(depth,tcoordVC).x;
gl_FragColor = vec4(1.0,0.5,0.5,1.0);
}
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