<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi All,<br>
<br>
I'm preparing to merge a patch(
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<a href="http://review.source.kitware.com/#/t/2980/">http://review.source.kitware.com/#/t/2980/</a>)
that implements OpenGL error checking and reporting in VTK and I'd
like to give you a heads up and also to know if you have any
comments or concerns before I make the merge. Here is the summary of
the work.<br>
<br>
OpenGL error hunt<br>
<br>
This patch implements OpenGL error checking in VTK.<br>
<br>
OpenGL's error handling implementation error is designed such<br>
that internal error flags remain set with the first error that<br>
occurred until they are explicitly checked. With this design<br>
it's important to check and clear the error flags regularly<br>
else they become unusable as code checking for errors ends<br>
up reporting earlier undetected unrelated errors.<br>
<br>
This patch takes the following approach:<br>
<br>
1) at public entry points into code that uses OpenGL clear the<br>
error flags without reporting errors. This guards against<br>
reportinig unrealted errors, such as those caused by code<br>
outside of VTK. See vtkOpenGLClearErrorMacro<br>
<br>
2) before returning from functions that made OpenGL calls
check<br>
for and report OpenGL errors. This detects Open GL errors in
the<br>
function/method where they occurred facilitating debugging and
it<br>
clears error flags so that user code doesn't detect errors
caused<br>
by VTK. See vtkOpenGLCheckErrorMacro<br>
<br>
This patch cleans up a number of bugs that were detected by<br>
the new error checking and reporting.<br>
<br>
This patch also contains improvements for OpenGL pixel
buffers, a<br>
renderbuffer object, and fast paths through framebuffer
objects,<br>
and texture objects, and fast path for setting uniform
variables,<br>
all of which are needed in vtkSurfaceLICPainter and<br>
vtkLineIntegralConvolution2D GPGPU code.<br>
<br>
After the merge you may see reports for previously undetected OpenGL
errors in your codes or ctest output. Also, on the Mac if you ask
VTK to render into an "invalid drawable" you will find that all
subsequent OpenGL calls fail (until the drawable becomes valid)
with INVALID_FRAMEBUFFER_OPERATION reported. The "invalid drawable"
issue is not new (<a
href="http://vtk.markmail.org/search/?q=invalid%20drawable">http://vtk.markmail.org/search/?q=invalid%20drawable</a>).
However, until now one could ignore this as OpenGL errors were not
detected and reported. Going forward you will need to fix your code
or disable new gl error detection and reporting. To fix your code
you can make use of the new vtkRenderWindow::IsDrawable method to
detect invalid drawable<a
href="http://vtk.markmail.org/search/?q=invalid%20drawable"></a>
and avoid asking VTK to render until the drawable is valid.
Alternatively you may disable OpenGL error detection via a cmake
variable allowing you to ignore the bug.<br>
<br>
My motivation for this patch comes from my experience debugging my
own VTK code and detecting errors that occurred elsewhere in VTK, in
some instances far away in space and time (measured in lines of
code). During this process I've noticed a good deal of variability
between OpenGL implementations, some are very robust and tolerant of
errors while others more strict/sensitive and can crash and burn on
the same code. The new error detection and reporting can help quite
a bit in tracking down cross platform/driver issues and ensures
errors are detected at their source.<br>
<br>
I think it would make sense going forward, that new code contributed
to VTK that makes use of OpenGL take the approach I described
above(with exception made for performance sensitive functions) so
that OpenGL error flags remain usable by all, allowing us to more
aggressively detect and fix bugs in our OpenGL codes.<br>
<br>
Please let me know if you have comments or concerns about this
patch.<br>
<br>
Thanks<br>
Burlen<br>
</body>
</html>