From c87535af15b463a939edcdc4996381d67c1e8665 Mon Sep 17 00:00:00 2001 From: isz Date: Sat, 18 Apr 2015 11:58:51 +0300 Subject: [PATCH] 0025372: Visualization, TKOpenGl - suppress annoying verbose messages from NVIDIA OpenGL driver OpenGl_GlCore42 - drop functions unrelated to OpenGL 4.2 core functionality --- src/OpenGl/OpenGl_Caps.cxx | 7 +- src/OpenGl/OpenGl_Caps.hxx | 16 +++ src/OpenGl/OpenGl_Context.cxx | 53 +++++-- src/OpenGl/OpenGl_Context.hxx | 9 ++ src/OpenGl/OpenGl_GlCore42.hxx | 3 - src/OpenGl/OpenGl_GlFunctions.hxx | 3 - src/ViewerTest/ViewerTest_ViewerCommands.cxx | 137 ++++++++++++++++--- 7 files changed, 197 insertions(+), 31 deletions(-) diff --git a/src/OpenGl/OpenGl_Caps.cxx b/src/OpenGl/OpenGl_Caps.cxx index cc18b6e1c2..16ca279835 100755 --- a/src/OpenGl/OpenGl_Caps.cxx +++ b/src/OpenGl/OpenGl_Caps.cxx @@ -37,8 +37,10 @@ OpenGl_Caps::OpenGl_Caps() contextStereo (Standard_False), #ifdef OCCT_DEBUG contextDebug (Standard_True), + contextSyncDebug (Standard_True), #else contextDebug (Standard_False), + contextSyncDebug (Standard_False), #endif contextNoAccel (Standard_False), #if !defined(GL_ES_VERSION_2_0) @@ -46,7 +48,8 @@ OpenGl_Caps::OpenGl_Caps() #else contextCompatible (Standard_False), #endif - glslWarnings (Standard_False) + glslWarnings (Standard_False), + suppressExtraMsg (Standard_True) { // } @@ -64,9 +67,11 @@ OpenGl_Caps& OpenGl_Caps::operator= (const OpenGl_Caps& theCopy) buffersNoSwap = theCopy.buffersNoSwap; contextStereo = theCopy.contextStereo; contextDebug = theCopy.contextDebug; + contextSyncDebug = theCopy.contextSyncDebug; contextNoAccel = theCopy.contextNoAccel; contextCompatible = theCopy.contextCompatible; glslWarnings = theCopy.glslWarnings; + suppressExtraMsg = theCopy.suppressExtraMsg; return *this; } diff --git a/src/OpenGl/OpenGl_Caps.hxx b/src/OpenGl/OpenGl_Caps.hxx index 8078e2ebbb..fa60482a49 100755 --- a/src/OpenGl/OpenGl_Caps.hxx +++ b/src/OpenGl/OpenGl_Caps.hxx @@ -61,6 +61,19 @@ public: //! @name context creation parameters */ Standard_Boolean contextDebug; + /** + * Request debug GL context to emit messages within main thread (when contextDebug is specified!). + * + * Some implementations performs GL rendering within dedicated thread(s), + * in this case debug messages will be pushed from unknown thread making call stack useless, + * since it does not interconnected to application calls. + * This option asks GL driver to switch into synchronized implementation. + * Affects performance - thus should not be turned on by products in released state. + * + * OFF by default. + */ + Standard_Boolean contextSyncDebug; + /** * Disable hardware acceleration. * @@ -96,6 +109,9 @@ public: //! @name flags to activate verbose output //! Print GLSL program compilation/linkage warnings, if any. OFF by default. Standard_Boolean glslWarnings; + //! Suppress redundant messages from debug GL context. ON by default. + Standard_Boolean suppressExtraMsg; + public: //! @name class methods //! Default constructor - initialize with most optimal values. diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index 0cf70394ce..10e7a42836 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -899,7 +899,14 @@ void OpenGl_Context::PushMessage (const unsigned int theSource, const unsigned int theSeverity, const TCollection_ExtendedString& theMessage) { - //OpenGl_Context* aCtx = (OpenGl_Context* )theUserParam; + if (caps->suppressExtraMsg + && theSource >= GL_DEBUG_SOURCE_API_ARB + && theSource <= GL_DEBUG_SOURCE_OTHER_ARB + && myFilters[theSource - GL_DEBUG_SOURCE_API_ARB].Contains (theId)) + { + return; + } + Standard_CString& aSrc = (theSource >= GL_DEBUG_SOURCE_API_ARB && theSource <= GL_DEBUG_SOURCE_OTHER_ARB) ? THE_DBGMSG_SOURCES[theSource - GL_DEBUG_SOURCE_API_ARB] @@ -929,6 +936,30 @@ void OpenGl_Context::PushMessage (const unsigned int theSource, Messenger()->Send (aMsg, aGrav); } +// ======================================================================= +// function : ExcludeMessage +// purpose : +// ====================================================================== +Standard_Boolean OpenGl_Context::ExcludeMessage (const unsigned int theSource, + const unsigned int theId) +{ + return theSource >= GL_DEBUG_SOURCE_API_ARB + && theSource <= GL_DEBUG_SOURCE_OTHER_ARB + && myFilters[theSource - GL_DEBUG_SOURCE_API_ARB].Add (theId); +} + +// ======================================================================= +// function : IncludeMessage +// purpose : +// ====================================================================== +Standard_Boolean OpenGl_Context::IncludeMessage (const unsigned int theSource, + const unsigned int theId) +{ + return theSource >= GL_DEBUG_SOURCE_API_ARB + && theSource <= GL_DEBUG_SOURCE_OTHER_ARB + && myFilters[theSource - GL_DEBUG_SOURCE_API_ARB].Remove (theId); +} + // ======================================================================= // function : checkWrongVersion // purpose : @@ -963,11 +994,19 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) myGlVerMajor = 0; myGlVerMinor = 0; ReadGlVersion (myGlVerMajor, myGlVerMinor); + myVendor = (const char* )::glGetString (GL_VENDOR); #if defined(GL_ES_VERSION_2_0) (void )theIsCoreProfile; const bool isCoreProfile = false; #else + + if (myVendor.Search ("NVIDIA") != -1) + { + // Buffer detailed info: Buffer object 1 (bound to GL_ARRAY_BUFFER_ARB, usage hint is GL_STATIC_DRAW) + // will use VIDEO memory as the source for buffer object operations. + ExcludeMessage (GL_DEBUG_SOURCE_API_ARB, 131185); + } if (IsGlGreaterEqual (3, 0)) { // retrieve auxiliary function in advance @@ -1157,9 +1196,10 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) // setup default callback myIsGlDebugCtx = Standard_True; arbDbg->glDebugMessageCallbackARB (debugCallbackWrap, this); - #ifdef OCCT_DEBUG - glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); - #endif + if (caps->contextSyncDebug) + { + ::glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + } } } @@ -1820,10 +1860,7 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) const bool hasTextureStorage = (IsGlGreaterEqual (4, 2) || CheckExtension ("GL_ARB_texture_storage")) && FindProcShort (glTexStorage1D) && FindProcShort (glTexStorage2D) - && FindProcShort (glTexStorage3D) - && FindProcShort (glTextureStorage1DEXT) - && FindProcShort (glTextureStorage2DEXT) - && FindProcShort (glTextureStorage3DEXT); + && FindProcShort (glTexStorage3D); has42 = IsGlGreaterEqual (4, 2) && hasBaseInstance diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index 84785a614f..7a8a58c24c 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -465,7 +466,13 @@ public: const unsigned int theSeverity, const TCollection_ExtendedString& theMessage); + //! Adds a filter for messages with theId and theSource (GL_DEBUG_SOURCE_) + Standard_EXPORT Standard_Boolean ExcludeMessage (const unsigned int theSource, + const unsigned int theId); + //! Removes a filter for messages with theId and theSource (GL_DEBUG_SOURCE_) + Standard_EXPORT Standard_Boolean IncludeMessage (const unsigned int theSource, + const unsigned int theId); //! @return true if OpenGl context supports left and //! right rendering buffers. @@ -663,6 +670,8 @@ private: //! @name fields tracking current state Standard_Integer myDrawBuffer; //!< current draw buffer unsigned int myDefaultVao; //!< default Vertex Array Object Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state + TCollection_AsciiString myVendor; //!< Graphics Driver's vendor + TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB) public: diff --git a/src/OpenGl/OpenGl_GlCore42.hxx b/src/OpenGl/OpenGl_GlCore42.hxx index 884d2b73bd..c239009867 100644 --- a/src/OpenGl/OpenGl_GlCore42.hxx +++ b/src/OpenGl/OpenGl_GlCore42.hxx @@ -54,9 +54,6 @@ public: //! @name GL_ARB_texture_storage (added to OpenGL 4.2 core) using theBaseClass_t::glTexStorage1D; using theBaseClass_t::glTexStorage2D; using theBaseClass_t::glTexStorage3D; - using theBaseClass_t::glTextureStorage1DEXT; - using theBaseClass_t::glTextureStorage2DEXT; - using theBaseClass_t::glTextureStorage3DEXT; #endif diff --git a/src/OpenGl/OpenGl_GlFunctions.hxx b/src/OpenGl/OpenGl_GlFunctions.hxx index 40a539c4c6..c036cbf0da 100644 --- a/src/OpenGl/OpenGl_GlFunctions.hxx +++ b/src/OpenGl/OpenGl_GlFunctions.hxx @@ -1329,9 +1329,6 @@ public: //! @name GL_ARB_texture_storage (added to OpenGL 4.2 core) PFNGLTEXSTORAGE1DPROC glTexStorage1D; PFNGLTEXSTORAGE2DPROC glTexStorage2D; PFNGLTEXSTORAGE3DPROC glTexStorage3D; - PFNGLTEXTURESTORAGE1DEXTPROC glTextureStorage1DEXT; - PFNGLTEXTURESTORAGE2DEXTPROC glTextureStorage2DEXT; - PFNGLTEXTURESTORAGE3DEXTPROC glTextureStorage3DEXT; public: //! @name OpenGL 4.2 diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index ed99269971..a0e414d06c 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -5211,30 +5211,128 @@ static int VGlDebug (Draw_Interpretor& theDI, { aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver()); } + OpenGl_Caps* aDefCaps = &ViewerTest_myDefaultCaps; + OpenGl_Caps* aCaps = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL; + if (theArgNb < 2) { - if (aDriver.IsNull()) + TCollection_AsciiString aDebActive, aSyncActive; + if (aCaps == NULL) { - std::cerr << "No active view. Please call vinit.\n"; - return 0; + aCaps = aDefCaps; + } + else + { + Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS), + "GL_ARB_debug_output"); + aDebActive = isActive ? " (active)" : " (inactive)"; + if (isActive) + { + // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB + aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)"; + } } - Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )glGetString (GL_EXTENSIONS), - "GL_ARB_debug_output"); - std::cout << "Active graphic driver: debug " << (isActive ? "ON" : "OFF") << "\n"; - theDI << (isActive ? "1" : "0"); + theDI << "debug: " << (aCaps->contextDebug ? "1" : "0") << aDebActive << "\n" + << "sync: " << (aCaps->contextSyncDebug ? "1" : "0") << aSyncActive << "\n" + << "glslWarn:" << (aCaps->glslWarnings ? "1" : "0") << "\n" + << "extraMsg:" << (aCaps->suppressExtraMsg ? "0" : "1") << "\n"; return 0; } - const Standard_Boolean toEnableDebug = Draw::Atoi (theArgVec[1]) != 0; - ViewerTest_myDefaultCaps.contextDebug = toEnableDebug; - ViewerTest_myDefaultCaps.glslWarnings = toEnableDebug; - if (aDriver.IsNull()) + for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter) { - return 0; + Standard_CString anArg = theArgVec[anArgIter]; + TCollection_AsciiString anArgCase (anArg); + anArgCase.LowerCase(); + Standard_Boolean toEnableDebug = Standard_True; + if (anArgCase == "-glsl" + || anArgCase == "-glslwarn" + || anArgCase == "-glslwarns" + || anArgCase == "-glslwarnings") + { + Standard_Boolean toShowWarns = Standard_True; + if (++anArgIter < theArgNb + && !parseOnOff (theArgVec[anArgIter], toShowWarns)) + { + --anArgIter; + } + aDefCaps->glslWarnings = toShowWarns; + if (aCaps != NULL) + { + aCaps->glslWarnings = toShowWarns; + } + } + else if (anArgCase == "-extra" + || anArgCase == "-extramsg" + || anArgCase == "-extramessages") + { + Standard_Boolean toShow = Standard_True; + if (++anArgIter < theArgNb + && !parseOnOff (theArgVec[anArgIter], toShow)) + { + --anArgIter; + } + aDefCaps->suppressExtraMsg = !toShow; + if (aCaps != NULL) + { + aCaps->suppressExtraMsg = !toShow; + } + } + else if (anArgCase == "-noextra" + || anArgCase == "-noextramsg" + || anArgCase == "-noextramessages") + { + Standard_Boolean toSuppress = Standard_True; + if (++anArgIter < theArgNb + && !parseOnOff (theArgVec[anArgIter], toSuppress)) + { + --anArgIter; + } + aDefCaps->suppressExtraMsg = toSuppress; + if (aCaps != NULL) + { + aCaps->suppressExtraMsg = toSuppress; + } + } + else if (anArgCase == "-sync") + { + Standard_Boolean toSync = Standard_True; + if (++anArgIter < theArgNb + && !parseOnOff (theArgVec[anArgIter], toSync)) + { + --anArgIter; + } + aDefCaps->contextSyncDebug = toSync; + if (toSync) + { + aDefCaps->contextDebug = Standard_True; + } + } + else if (anArgCase == "-debug") + { + if (++anArgIter < theArgNb + && !parseOnOff (theArgVec[anArgIter], toEnableDebug)) + { + --anArgIter; + } + aDefCaps->contextDebug = toEnableDebug; + } + else if (parseOnOff (anArg, toEnableDebug) + && (anArgIter + 1 == theArgNb)) + { + // simple alias to turn on almost everything + aDefCaps->contextDebug = toEnableDebug; + aDefCaps->contextSyncDebug = toEnableDebug; + aDefCaps->glslWarnings = toEnableDebug; + } + else + { + std::cout << "Error: wrong syntax at '" << anArg << "'\n"; + return 1; + } } - aDriver->ChangeOptions().glslWarnings = toEnableDebug; return 0; } @@ -8480,9 +8578,16 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) "vfps [framesNb=100] : estimate average frame rate for active view", __FILE__, VFps, group); theCommands.Add ("vgldebug", - "vgldebug [{0|1}] : request debug GL context, should be called before vinit\n" - " : this function is implemented only for Windows\n" - " : GL_ARB_debug_output extension should be exported by OpenGL driver!", + "vgldebug [-sync {0|1}] [-debug {0|1}] [-glslWarn {0|1}]" + "\n\t\t: [-extraMsg {0|1}] [{0|1}]" + "\n\t\t: Request debug GL context. Should be called BEFORE vinit." + "\n\t\t: Debug context can be requested only on Windows" + "\n\t\t: with GL_ARB_debug_output extension implemented by GL driver!" + "\n\t\t: -sync - request synchronized debug GL context" + "\n\t\t: -glslWarn - log GLSL compiler/linker warnings," + "\n\t\t: which are suppressed by default," + "\n\t\t: -extraMsg - log extra diagnostic messages from GL context," + "\n\t\t: which are suppressed by default", __FILE__, VGlDebug, group); theCommands.Add ("vvbo", "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects", -- 2.39.5