Commit 59b539a0 authored by Ken Martin's avatar Ken Martin

A few dashboard fixes as described below

GPUVolume rendering was activating texture units and never
deactivating them.  The TextureUnitManager was allowing this
when it should not have been.

GenericCompoistePolyDataMapper was not releasing graphics
resources on its helper.

Added in some opengl error reporting logic that someone had added
to only the old backend.

DepthPeeling was not releasing all of its graphics resources.

Removed a couple extra includes.

Added a MakeCurrent in TextureObject when it releases its
graphics resources. Sometimes this happens when another window
is current as a side effect.
parent cb77ffae
......@@ -302,7 +302,10 @@ vtk_object_factory_configure("${vtk_module_overrides}")
# Detect and clear OpenGL errors. If not then other classes/user code
# may detect VTK's OpenGL errors and vice-versa.
set(VTK_REPORT_OPENGL_ERRORS ON CACHE BOOL "Enable OpenGL error check and report")
mark_as_advanced(VTK_REPORT_OPENGL_ERRORS)
cmake_dependent_option(VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS
"Enable OpenGL error check and reporting in non-debug builds." OFF
VTK_REPORT_OPENGL_ERRORS OFF)
mark_as_advanced(VTK_REPORT_OPENGL_ERRORS VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/vtkOpenGLError.h.in
${CMAKE_CURRENT_BINARY_DIR}/vtkOpenGLError.h)
......
......@@ -128,10 +128,25 @@ void vtkDepthPeelingPass::ReleaseGraphicsResources(vtkWindow *w)
{
this->TranslucentPass->ReleaseGraphicsResources(w);
}
if(this->TranslucentPass)
if (this->OpaqueZTexture)
{
this->TranslucentPass->ReleaseGraphicsResources(w);
this->OpaqueZTexture->ReleaseGraphicsResources(w);
}
if (this->TranslucentZTexture)
{
this->TranslucentZTexture->ReleaseGraphicsResources(w);
}
if (this->OpaqueRGBATexture)
{
this->OpaqueRGBATexture->ReleaseGraphicsResources(w);
}
if (this->TranslucentRGBATexture)
{
this->TranslucentRGBATexture->ReleaseGraphicsResources(w);
}
if (this->CurrentRGBATexture)
{
this->CurrentRGBATexture->ReleaseGraphicsResources(w);
}
}
......
......@@ -21,7 +21,6 @@
#include "vtkFrameBufferObject.h"
#include "vtkTextureObject.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkTextureUnitManager.h"
#include "vtkOpenGLError.h"
#include "vtkShaderProgram.h"
#include "vtkOpenGLShaderCache.h"
......
......@@ -621,6 +621,13 @@ void vtkGenericCompositePolyDataMapper2::FreeGenericStructures()
this->ShadersInitialized.clear();
}
//-----------------------------------------------------------------------------
void vtkGenericCompositePolyDataMapper2::ReleaseGraphicsResources(vtkWindow* win)
{
this->FreeGenericStructures();
this->Superclass::ReleaseGraphicsResources(win);
}
// ---------------------------------------------------------------------------
// Description:
// Method initiates the mapping process. Generally sent by the actor
......
......@@ -82,6 +82,12 @@ public:
void RemoveBlockOpacity(unsigned int index);
void RemoveBlockOpacities();
// Description:
// Release any graphics resources that are being consumed by this mapper.
// The parameter window could be used to determine which graphic
// resources to release.
void ReleaseGraphicsResources(vtkWindow *);
//BTX
protected:
vtkGenericCompositePolyDataMapper2();
......
......@@ -21,7 +21,6 @@
#include "vtkFrameBufferObject.h"
#include "vtkTextureObject.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkTextureUnitManager.h"
// to be able to dump intermediate passes into png files for debugging.
// only for vtkImageProcessingPass developers.
......
......@@ -18,7 +18,16 @@
#include "vtkSetGet.h"
#include "vtk_glew.h"
#ifndef NDEBUG
// debug build.
#cmakedefine VTK_REPORT_OPENGL_ERRORS
#else // NDEBUG
// release build
#cmakedefine VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS
#if defined(VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS)
#cmakedefine VTK_REPORT_OPENGL_ERRORS
#endif // defined(VTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS)
#endif // NDEBUG
// Description:
// The following functions can be used to detect and report, and/or
......
......@@ -719,6 +719,7 @@ void vtkOpenGLPolyDataMapper::UpdateShader(vtkgl::CellBO &cellBO, vtkRenderer* r
cellBO.vao.Bind();
this->LastBoundBO = &cellBO;
vtkOpenGLCheckErrorMacro("failed after UpdateShader");
}
void vtkOpenGLPolyDataMapper::SetMapperShaderParameters(vtkgl::CellBO &cellBO,
......@@ -1693,6 +1694,7 @@ void vtkOpenGLPolyDataMapper::BuildBufferObjects(vtkRenderer *ren, vtkActor *act
prims[primType]->UnRegister(this);
}
}
vtkOpenGLCheckErrorMacro("failed after BuildBufferObjects");
}
//-----------------------------------------------------------------------------
......
......@@ -475,6 +475,7 @@ void vtkTextureObject::ReleaseGraphicsResources(vtkWindow *win)
{
vtkOpenGLRenderWindow *rwin =
vtkOpenGLRenderWindow::SafeDownCast(win);
rwin->MakeCurrent();
// 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
......
......@@ -50,7 +50,7 @@ void vtkTextureUnitManager::DeleteTable()
bool valid=true;
while(valid && i<c)
{
valid = this->TextureUnits[i] > 0 ? false : true;
valid = !this->TextureUnits[i];
++i;
}
if(!valid)
......@@ -78,12 +78,12 @@ void vtkTextureUnitManager::SetContext(vtkOpenGLRenderWindow *context)
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &this->NumberOfTextureUnits);
if(this->NumberOfTextureUnits > 0)
{
this->TextureUnits = new unsigned int[this->NumberOfTextureUnits];
this->TextureUnits = new bool [this->NumberOfTextureUnits];
size_t i=0;
size_t c=this->NumberOfTextureUnits;
while(i<c)
{
this->TextureUnits[i]=0;
this->TextureUnits[i]=false;
++i;
}
}
......@@ -114,7 +114,7 @@ int vtkTextureUnitManager::Allocate()
size_t c=this->NumberOfTextureUnits;
while(!found && i<c)
{
found = (this->TextureUnits[i] > 0 ? false : true);
found = !this->TextureUnits[i];
++i;
}
......@@ -122,20 +122,11 @@ int vtkTextureUnitManager::Allocate()
if(found)
{
result=static_cast<int>(i-1);
this->TextureUnits[result] += 1;
this->TextureUnits[result] = true;
}
else
{
int leastUsed = 0;
for (int j = 0; j < this->NumberOfTextureUnits; ++j)
{
if (this->TextureUnits[j] < this->TextureUnits[leastUsed])
{
leastUsed = j;
}
}
this->TextureUnits[leastUsed] += 1;
result = leastUsed;
result = -1;
}
assert("post: valid_result" && (result==-1 || (result>=0 && result<this->GetNumberOfTextureUnits())));
......@@ -150,7 +141,7 @@ int vtkTextureUnitManager::Allocate()
bool vtkTextureUnitManager::IsAllocated(int textureUnitId)
{
assert("pre: valid_textureUnitId_range" && textureUnitId>=0 && textureUnitId<this->GetNumberOfTextureUnits());
return (this->TextureUnits[textureUnitId] > 0 ? true : false);
return (this->TextureUnits[textureUnitId] ? true : false);
}
// ----------------------------------------------------------------------------
......@@ -163,14 +154,7 @@ void vtkTextureUnitManager::Free(int textureUnitId)
assert("pre: valid_textureUnitId" && (textureUnitId>=0 && textureUnitId<this->GetNumberOfTextureUnits()));
// assert("pre: allocated_textureUnitId" && this->IsAllocated(textureUnitId));
if (this->TextureUnits[textureUnitId] >= 1)
{
this->TextureUnits[textureUnitId] -= 1;
}
else
{
this->TextureUnits[textureUnitId] = 0;
}
this->TextureUnits[textureUnitId] = false;
}
// ----------------------------------------------------------------------------
......
......@@ -89,7 +89,7 @@ protected:
vtkOpenGLRenderWindow *Context;
int NumberOfTextureUnits;
unsigned int *TextureUnits;
bool *TextureUnits;
private:
vtkTextureUnitManager(const vtkTextureUnitManager&); // Not implemented.
......
......@@ -739,6 +739,9 @@ bool vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::LoadVolume(vtkRenderer* ren,
}
sliceArray->Delete();
}
// do not tie up the texture unit unless we are activly using it
// textures can exist without being active
this->VolumeTextureObject->Deactivate();
return 1;
}
......@@ -1111,7 +1114,6 @@ void vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::UpdateNoiseTexture(
this->NoiseTextureObject->SetMagnificationFilter(vtkTextureObject::Nearest);
this->NoiseTextureObject->SetMinificationFilter(vtkTextureObject::Nearest);
this->NoiseTextureObject->SetBorderColor(0.0f, 0.0f, 0.0f, 0.0f);
this->NoiseTextureObject->Activate();
}
}
......@@ -2714,6 +2716,11 @@ void vtkOpenGLGPUVolumeRayCastMapper::GPURender(vtkRenderer* ren,
this->Impl->BBoxPolyData->GetNumberOfCells() * 3,
GL_UNSIGNED_INT, 0);
// relase the texture units we were using
this->Impl->VolumeTextureObject->Deactivate();
this->Impl->NoiseTextureObject->Deactivate();
this->Impl->DepthTextureObject->Deactivate();
if (volumeModified)
{
this->Impl->InputUpdateTime.Modified();
......
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