1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0025372: Visualization, TKOpenGl - suppress annoying verbose messages from NVIDIA OpenGL driver

OpenGl_GlCore42 - drop functions unrelated to OpenGL 4.2 core functionality
This commit is contained in:
isz
2015-04-18 11:58:51 +03:00
committed by bugmaster
parent 57c718c4b9
commit c87535af15
7 changed files with 197 additions and 31 deletions

View File

@@ -37,8 +37,10 @@ OpenGl_Caps::OpenGl_Caps()
contextStereo (Standard_False), contextStereo (Standard_False),
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
contextDebug (Standard_True), contextDebug (Standard_True),
contextSyncDebug (Standard_True),
#else #else
contextDebug (Standard_False), contextDebug (Standard_False),
contextSyncDebug (Standard_False),
#endif #endif
contextNoAccel (Standard_False), contextNoAccel (Standard_False),
#if !defined(GL_ES_VERSION_2_0) #if !defined(GL_ES_VERSION_2_0)
@@ -46,7 +48,8 @@ OpenGl_Caps::OpenGl_Caps()
#else #else
contextCompatible (Standard_False), contextCompatible (Standard_False),
#endif #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; buffersNoSwap = theCopy.buffersNoSwap;
contextStereo = theCopy.contextStereo; contextStereo = theCopy.contextStereo;
contextDebug = theCopy.contextDebug; contextDebug = theCopy.contextDebug;
contextSyncDebug = theCopy.contextSyncDebug;
contextNoAccel = theCopy.contextNoAccel; contextNoAccel = theCopy.contextNoAccel;
contextCompatible = theCopy.contextCompatible; contextCompatible = theCopy.contextCompatible;
glslWarnings = theCopy.glslWarnings; glslWarnings = theCopy.glslWarnings;
suppressExtraMsg = theCopy.suppressExtraMsg;
return *this; return *this;
} }

View File

@@ -61,6 +61,19 @@ public: //! @name context creation parameters
*/ */
Standard_Boolean contextDebug; 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. * 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. //! Print GLSL program compilation/linkage warnings, if any. OFF by default.
Standard_Boolean glslWarnings; Standard_Boolean glslWarnings;
//! Suppress redundant messages from debug GL context. ON by default.
Standard_Boolean suppressExtraMsg;
public: //! @name class methods public: //! @name class methods
//! Default constructor - initialize with most optimal values. //! Default constructor - initialize with most optimal values.

View File

@@ -899,7 +899,14 @@ void OpenGl_Context::PushMessage (const unsigned int theSource,
const unsigned int theSeverity, const unsigned int theSeverity,
const TCollection_ExtendedString& theMessage) 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 Standard_CString& aSrc = (theSource >= GL_DEBUG_SOURCE_API_ARB
&& theSource <= GL_DEBUG_SOURCE_OTHER_ARB) && theSource <= GL_DEBUG_SOURCE_OTHER_ARB)
? THE_DBGMSG_SOURCES[theSource - GL_DEBUG_SOURCE_API_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); 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 // function : checkWrongVersion
// purpose : // purpose :
@@ -963,11 +994,19 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
myGlVerMajor = 0; myGlVerMajor = 0;
myGlVerMinor = 0; myGlVerMinor = 0;
ReadGlVersion (myGlVerMajor, myGlVerMinor); ReadGlVersion (myGlVerMajor, myGlVerMinor);
myVendor = (const char* )::glGetString (GL_VENDOR);
#if defined(GL_ES_VERSION_2_0) #if defined(GL_ES_VERSION_2_0)
(void )theIsCoreProfile; (void )theIsCoreProfile;
const bool isCoreProfile = false; const bool isCoreProfile = false;
#else #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)) if (IsGlGreaterEqual (3, 0))
{ {
// retrieve auxiliary function in advance // retrieve auxiliary function in advance
@@ -1157,9 +1196,10 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
// setup default callback // setup default callback
myIsGlDebugCtx = Standard_True; myIsGlDebugCtx = Standard_True;
arbDbg->glDebugMessageCallbackARB (debugCallbackWrap, this); arbDbg->glDebugMessageCallbackARB (debugCallbackWrap, this);
#ifdef OCCT_DEBUG if (caps->contextSyncDebug)
glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); {
#endif ::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")) const bool hasTextureStorage = (IsGlGreaterEqual (4, 2) || CheckExtension ("GL_ARB_texture_storage"))
&& FindProcShort (glTexStorage1D) && FindProcShort (glTexStorage1D)
&& FindProcShort (glTexStorage2D) && FindProcShort (glTexStorage2D)
&& FindProcShort (glTexStorage3D) && FindProcShort (glTexStorage3D);
&& FindProcShort (glTextureStorage1DEXT)
&& FindProcShort (glTextureStorage2DEXT)
&& FindProcShort (glTextureStorage3DEXT);
has42 = IsGlGreaterEqual (4, 2) has42 = IsGlGreaterEqual (4, 2)
&& hasBaseInstance && hasBaseInstance

View File

@@ -35,6 +35,7 @@
#include <OpenGl_Resource.hxx> #include <OpenGl_Resource.hxx>
#include <Standard_Transient.hxx> #include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <TColStd_PackedMapOfInteger.hxx>
#include <OpenGl_Clipping.hxx> #include <OpenGl_Clipping.hxx>
#include <OpenGl_GlCore11.hxx> #include <OpenGl_GlCore11.hxx>
#include <OpenGl_Utils.hxx> #include <OpenGl_Utils.hxx>
@@ -465,7 +466,13 @@ public:
const unsigned int theSeverity, const unsigned int theSeverity,
const TCollection_ExtendedString& theMessage); 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 //! @return true if OpenGl context supports left and
//! right rendering buffers. //! right rendering buffers.
@@ -663,6 +670,8 @@ private: //! @name fields tracking current state
Standard_Integer myDrawBuffer; //!< current draw buffer Standard_Integer myDrawBuffer; //!< current draw buffer
unsigned int myDefaultVao; //!< default Vertex Array Object unsigned int myDefaultVao; //!< default Vertex Array Object
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state 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: public:

View File

@@ -54,9 +54,6 @@ public: //! @name GL_ARB_texture_storage (added to OpenGL 4.2 core)
using theBaseClass_t::glTexStorage1D; using theBaseClass_t::glTexStorage1D;
using theBaseClass_t::glTexStorage2D; using theBaseClass_t::glTexStorage2D;
using theBaseClass_t::glTexStorage3D; using theBaseClass_t::glTexStorage3D;
using theBaseClass_t::glTextureStorage1DEXT;
using theBaseClass_t::glTextureStorage2DEXT;
using theBaseClass_t::glTextureStorage3DEXT;
#endif #endif

View File

@@ -1329,9 +1329,6 @@ public: //! @name GL_ARB_texture_storage (added to OpenGL 4.2 core)
PFNGLTEXSTORAGE1DPROC glTexStorage1D; PFNGLTEXSTORAGE1DPROC glTexStorage1D;
PFNGLTEXSTORAGE2DPROC glTexStorage2D; PFNGLTEXSTORAGE2DPROC glTexStorage2D;
PFNGLTEXSTORAGE3DPROC glTexStorage3D; PFNGLTEXSTORAGE3DPROC glTexStorage3D;
PFNGLTEXTURESTORAGE1DEXTPROC glTextureStorage1DEXT;
PFNGLTEXTURESTORAGE2DEXTPROC glTextureStorage2DEXT;
PFNGLTEXTURESTORAGE3DEXTPROC glTextureStorage3DEXT;
public: //! @name OpenGL 4.2 public: //! @name OpenGL 4.2

View File

@@ -5211,30 +5211,128 @@ static int VGlDebug (Draw_Interpretor& theDI,
{ {
aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver()); 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 (theArgNb < 2)
{ {
if (aDriver.IsNull()) TCollection_AsciiString aDebActive, aSyncActive;
if (aCaps == NULL)
{ {
std::cerr << "No active view. Please call vinit.\n"; aCaps = aDefCaps;
return 0; }
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), theDI << "debug: " << (aCaps->contextDebug ? "1" : "0") << aDebActive << "\n"
"GL_ARB_debug_output"); << "sync: " << (aCaps->contextSyncDebug ? "1" : "0") << aSyncActive << "\n"
std::cout << "Active graphic driver: debug " << (isActive ? "ON" : "OFF") << "\n"; << "glslWarn:" << (aCaps->glslWarnings ? "1" : "0") << "\n"
theDI << (isActive ? "1" : "0"); << "extraMsg:" << (aCaps->suppressExtraMsg ? "0" : "1") << "\n";
return 0; return 0;
} }
const Standard_Boolean toEnableDebug = Draw::Atoi (theArgVec[1]) != 0; for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
ViewerTest_myDefaultCaps.contextDebug = toEnableDebug;
ViewerTest_myDefaultCaps.glslWarnings = toEnableDebug;
if (aDriver.IsNull())
{ {
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; return 0;
} }
@@ -8480,9 +8578,16 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"vfps [framesNb=100] : estimate average frame rate for active view", "vfps [framesNb=100] : estimate average frame rate for active view",
__FILE__, VFps, group); __FILE__, VFps, group);
theCommands.Add ("vgldebug", theCommands.Add ("vgldebug",
"vgldebug [{0|1}] : request debug GL context, should be called before vinit\n" "vgldebug [-sync {0|1}] [-debug {0|1}] [-glslWarn {0|1}]"
" : this function is implemented only for Windows\n" "\n\t\t: [-extraMsg {0|1}] [{0|1}]"
" : GL_ARB_debug_output extension should be exported by OpenGL driver!", "\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); __FILE__, VGlDebug, group);
theCommands.Add ("vvbo", theCommands.Add ("vvbo",
"vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects", "vvbo [{0|1}] : turn VBO usage On/Off; affects only newly displayed objects",