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)
#else
contextCompatible (Standard_False),
#endif
- glslWarnings (Standard_False)
+ glslWarnings (Standard_False),
+ suppressExtraMsg (Standard_True)
{
//
}
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;
}
*/
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.
*
//! 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.
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]
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 :
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
// 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);
+ }
}
}
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
#include <OpenGl_Resource.hxx>
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
+#include <TColStd_PackedMapOfInteger.hxx>
#include <OpenGl_Clipping.hxx>
#include <OpenGl_GlCore11.hxx>
#include <OpenGl_Utils.hxx>
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.
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:
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
PFNGLTEXSTORAGE1DPROC glTexStorage1D;
PFNGLTEXSTORAGE2DPROC glTexStorage2D;
PFNGLTEXSTORAGE3DPROC glTexStorage3D;
- PFNGLTEXTURESTORAGE1DEXTPROC glTextureStorage1DEXT;
- PFNGLTEXTURESTORAGE2DEXTPROC glTextureStorage2DEXT;
- PFNGLTEXTURESTORAGE3DEXTPROC glTextureStorage3DEXT;
public: //! @name OpenGL 4.2
{
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;
}
"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",