Commit 82dec7d1 authored by Allison Vacanti's avatar Allison Vacanti

Add RenderUtil function to annotate GL streams.

vtkOpenGLRenderUtilities::MarkDebugEvent(std::string) will insert
the passed string into the OpenGL command stream for debugging with
tools like apitrace.
parent c10ac459
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "vtkRenderState.h" #include "vtkRenderState.h"
#include "vtkOpenGLRenderer.h" #include "vtkOpenGLRenderer.h"
#include "vtkOpenGLRenderWindow.h" #include "vtkOpenGLRenderWindow.h"
#include "vtkOpenGLRenderUtilities.h"
#include "vtkMatrix4x4.h" #include "vtkMatrix4x4.h"
#include "vtkCamera.h" #include "vtkCamera.h"
#include "vtkOpenGLFramebufferObject.h" #include "vtkOpenGLFramebufferObject.h"
...@@ -223,7 +224,9 @@ void vtkCameraPass::Render(const vtkRenderState *s) ...@@ -223,7 +224,9 @@ void vtkCameraPass::Render(const vtkRenderState *s)
if(this->DelegatePass!=nullptr) if(this->DelegatePass!=nullptr)
{ {
vtkOpenGLRenderUtilities::MarkDebugEvent("Start vtkCameraPass delegate");
this->DelegatePass->Render(s); this->DelegatePass->Render(s);
vtkOpenGLRenderUtilities::MarkDebugEvent("End vtkCameraPass delegate");
this->NumberOfRenderedProps+= this->NumberOfRenderedProps+=
this->DelegatePass->GetNumberOfRenderedProps(); this->DelegatePass->GetNumberOfRenderedProps();
} }
......
...@@ -44,6 +44,7 @@ Ph.D. thesis of Christian BOUCHENY. ...@@ -44,6 +44,7 @@ Ph.D. thesis of Christian BOUCHENY.
#include "vtkOpenGLFramebufferObject.h" #include "vtkOpenGLFramebufferObject.h"
#include "vtkTextureObject.h" #include "vtkTextureObject.h"
#include "vtkOpenGLRenderWindow.h" #include "vtkOpenGLRenderWindow.h"
#include "vtkOpenGLRenderUtilities.h"
#include "vtkPixelBufferObject.h" #include "vtkPixelBufferObject.h"
#include "vtkCamera.h" #include "vtkCamera.h"
...@@ -151,7 +152,12 @@ void vtkDepthImageProcessingPass::RenderDelegate(const vtkRenderState *s, ...@@ -151,7 +152,12 @@ void vtkDepthImageProcessingPass::RenderDelegate(const vtkRenderState *s,
// 2. Delegate render in FBO // 2. Delegate render in FBO
//glEnable(GL_DEPTH_TEST); //glEnable(GL_DEPTH_TEST);
vtkOpenGLRenderUtilities::MarkDebugEvent(
"Start vtkDepthImageProcessingPass delegate render");
this->DelegatePass->Render(&s2); this->DelegatePass->Render(&s2);
vtkOpenGLRenderUtilities::MarkDebugEvent(
"End vtkDepthImageProcessingPass delegate render");
this->NumberOfRenderedProps+= this->NumberOfRenderedProps+=
this->DelegatePass->GetNumberOfRenderedProps(); this->DelegatePass->GetNumberOfRenderedProps();
......
...@@ -76,11 +76,7 @@ namespace ...@@ -76,11 +76,7 @@ namespace
void annotate(const std::string &str) void annotate(const std::string &str)
{ {
#ifdef ANNOTATE_STREAM #ifdef ANNOTATE_STREAM
vtkOpenGLStaticCheckErrorMacro("Error before glDebug.") vtkOpenGLRenderUtilities::MarkDebugEvent(str);
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER,
GL_DEBUG_SEVERITY_NOTIFICATION,
0, str.size(), str.c_str());
vtkOpenGLClearErrorMacro();
#else // ANNOTATE_STREAM #else // ANNOTATE_STREAM
(void)str; (void)str;
#endif // ANNOTATE_STREAM #endif // ANNOTATE_STREAM
......
...@@ -43,6 +43,7 @@ Ph.D. thesis of Christian BOUCHENY. ...@@ -43,6 +43,7 @@ Ph.D. thesis of Christian BOUCHENY.
#include "vtkMath.h" #include "vtkMath.h"
#include "vtkObjectFactory.h" #include "vtkObjectFactory.h"
#include "vtkOpenGLError.h" #include "vtkOpenGLError.h"
#include "vtkOpenGLRenderUtilities.h"
#include "vtkOpenGLRenderWindow.h" #include "vtkOpenGLRenderWindow.h"
#include "vtkOpenGLShaderCache.h" #include "vtkOpenGLShaderCache.h"
#include "vtkPropCollection.h" #include "vtkPropCollection.h"
...@@ -71,18 +72,13 @@ namespace ...@@ -71,18 +72,13 @@ namespace
void annotate(const std::string &str) void annotate(const std::string &str)
{ {
#ifdef ANNOTATE_STREAM #ifdef ANNOTATE_STREAM
vtkOpenGLStaticCheckErrorMacro("Error before glDebug.") vtkOpenGLRenderUtilities::MarkDebugEvent(str);
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER,
GL_DEBUG_SEVERITY_NOTIFICATION,
0, str.size(), str.c_str());
vtkOpenGLClearErrorMacro();
#else // ANNOTATE_STREAM #else // ANNOTATE_STREAM
(void)str; (void)str;
#endif // ANNOTATE_STREAM #endif // ANNOTATE_STREAM
} }
} }
vtkStandardNewMacro(vtkEDLShading); vtkStandardNewMacro(vtkEDLShading);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
...@@ -708,10 +704,12 @@ void vtkEDLShading::Render(const vtkRenderState *s) ...@@ -708,10 +704,12 @@ void vtkEDLShading::Render(const vtkRenderState *s)
// //
// FBOs // FBOs
// //
annotate("Start vtkEDLShading Initialization");
this->EDLInitializeFramebuffers(s2); this->EDLInitializeFramebuffers(s2);
// Shaders // Shaders
// //
this->EDLInitializeShaders(renWin); this->EDLInitializeShaders(renWin);
annotate("End vtkEDLShading Initialization");
if (this->EDLShadeProgram.Program == nullptr || if (this->EDLShadeProgram.Program == nullptr ||
this->EDLComposeProgram.Program == nullptr || this->EDLComposeProgram.Program == nullptr ||
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "vtkNew.h" #include "vtkNew.h"
#include "vtkOpenGLBufferObject.h" #include "vtkOpenGLBufferObject.h"
#include "vtkOpenGLError.h"
#include "vtkOpenGLVertexArrayObject.h" #include "vtkOpenGLVertexArrayObject.h"
#include "vtkShaderProgram.h" #include "vtkShaderProgram.h"
...@@ -192,3 +193,19 @@ void vtkOpenGLRenderUtilities::DrawFullScreenQuad() ...@@ -192,3 +193,19 @@ void vtkOpenGLRenderUtilities::DrawFullScreenQuad()
{ {
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
} }
//------------------------------------------------------------------------------
void vtkOpenGLRenderUtilities::MarkDebugEvent(const std::string &event)
{
static bool hasDebugging = (glDebugMessageInsert != nullptr);
if (!hasDebugging)
{
return;
}
vtkOpenGLStaticCheckErrorMacro("Error before glDebugMessageInsert.")
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER,
GL_DEBUG_SEVERITY_NOTIFICATION,
0, static_cast<GLsizei>(event.size()), event.c_str());
vtkOpenGLClearErrorMacro();
}
...@@ -110,6 +110,16 @@ public: ...@@ -110,6 +110,16 @@ public:
static void DrawFullScreenQuad(); static void DrawFullScreenQuad();
//@} //@}
/**
* Pass a debugging mark to the render engine to assist development via tools
* like apitrace. This calls glDebugMessageInsert to insert the event string
* into the OpenGL command stream.
*
* Note that this method only works when glDebugMessageInsert is bound, which
* it may not be on certain platforms.
*/
static void MarkDebugEvent(const std::string &event);
protected: protected:
vtkOpenGLRenderUtilities(); vtkOpenGLRenderUtilities();
~vtkOpenGLRenderUtilities() override; ~vtkOpenGLRenderUtilities() override;
......
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