[vtkusers] Invalidating the OpenGL2 shader cache
Benjamin Schleimer
BSchleimer at vytronus.com
Tue Oct 16 21:21:41 EDT 2018
Hi,
I have come across an interesting problem with VTK and I wanted to ask if there is another way to work around it.
Using the OpenGL2 backend, we have discovered that if another system renders to the same opengl context as VTK,
then the shader cache is put into an invalidated state.
The root problem is that in Rendering/OpenGL2/vtkOpenGLShaderCache.cxx, in vtkOpenGLShaderCache::BindShader(), the lastShaderBound is assumed to not change. VTK assumes that it's the only system setting glUseProgram() for the opengl context.
So if another system clears the GL_CURRENT_PROGRAM value, then VTK doesn't know about it and the following calls to set program uniforms fails with an opengl error.
A suggested is to add a call to glGetIntegerv(GL_CURRENT_PROGRAM, ...) and compare it against this->Handle before returning.
I worked around this problem by clearing the shader cache before invoking vtkRenderWindow::Render() but this required knowing that the shader cache was invalid.
Sincerely,
Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20181017/d995d575/attachment.html>
More information about the vtkusers
mailing list