Hello Enrico,

On 01/20/2011 04:40 AM, Enrico Borrione wrote:
Hello, OpenSG users,
        i am writing an application that uses several FBOViewports to
calculate the ambient occlusion of a model.
Since I am doing lots of renderings to retrieve the necessary informations,
I am profiling the function calls inside my app to optimize it wherever it's
possible.
During the profiling I've noticed that the FBOViewport does a lot of
glGetError queries, actually breaking the OpenGL pipeline. Looking inside
the source code, I've noticed that the queries are enabled both in debug and
release. While I understand that these queries are advisable in debug, I
think that they are pointless when using the release libraries.
Is this correct or maybe I should check my compilation files to disable the
unnecessary queries when in release?

we usually only do OpenGL error checking in debug builds (normally through OpenSG's glErr macro), but the FBOViewport used a local function that did the checking unconditionally. I just committed a fix for that (patch attached as well).

        Cheers,
                Carsten
Index: Source/Base/Base/OSGGL.h
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/Base/Base/OSGGL.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Source/Base/Base/OSGGL.h    16 Aug 2008 11:40:50 -0000      1.11
+++ Source/Base/Base/OSGGL.h    20 Jan 2011 17:20:54 -0000      1.12
@@ -61,24 +61,20 @@
 
 #include <OSGGLU.h>
 
+OSG_BEGIN_NAMESPACE
+
+bool osgGlCheckError(const char *file, int line, const char *msg);
+
 #ifdef OSG_DEBUG
-#define glErr(text)                                 \
-{                                                   \
-    GLenum glerr;                                   \
-                                                    \
-    while((glerr = glGetError()) != GL_NO_ERROR)    \
-    {                                               \
-        FWARNING(("(%s,%d): %s failed: %s (%#x)\n", \
-                __FILE__, __LINE__,                 \
-                (text),                             \
-                gluErrorString(glerr),              \
-                glerr));                            \
-    }                                               \
-}
+#define glErr(text)                                     \
+  {                                                     \
+    osgGlCheckError(__FILE__, __LINE__, (text));        \
+  }
 #else
 #define glErr(text)
 #endif
 
+OSG_END_NAMESPACE
 
 #define OSGGL_HEADER_CVSID "@(#)$Id: $"
 
Index: Source/System/Window/OSGFBOViewport.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGFBOViewport.cpp,v
retrieving revision 1.25
diff -u -r1.25 OSGFBOViewport.cpp
--- Source/System/Window/OSGFBOViewport.cpp     24 Aug 2009 10:40:24 -0000      
1.25
+++ Source/System/Window/OSGFBOViewport.cpp     20 Jan 2011 17:23:50 -0000
@@ -226,22 +226,6 @@
 typedef void (OSG_APIENTRY * OSGGLRENDERBUFFERSTORAGEEXTPROC)
     (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
 
-
-namespace
-{
-  bool checkGLError(const char* where)
-  {
-    GLenum errCode = 0;
-    if ((errCode = glGetError()) != GL_NO_ERROR)
-    {
-        const GLubyte *errString = gluErrorString(errCode);
-        FNOTICE(("%s OpenGL Error: %s!\n", where, errString));
-    }
-
-    return errCode == GL_NO_ERROR;
-  }
-}
-
 /***************************************************************************\
  *                           Class methods                                 *
 \***************************************************************************/
@@ -404,7 +388,7 @@
     if (width <= 0 || height <= 0)
         return false;
 
-    checkGLError("FBO initalize pre");
+    glErr("FBO initizlize pre");
     
     if (getFrameBufferIndex() && !getDirty())
         return true;
@@ -461,7 +445,7 @@
                      (format & FBO_STENCIL_8 ) ? GL_STENCIL_INDEX8_EXT  :
                      (format & FBO_STENCIL_16) ? GL_STENCIL_INDEX16_EXT : 0;
 
-    checkGLError("FBO initalize pre depth");
+    glErr("FBO initialize pre depth");
            
     if (depth)
     {
@@ -474,7 +458,7 @@
                                      GL_RENDERBUFFER_EXT, dbIndex);
     }
 
-    checkGLError("FBO initalize pre stencil");
+    glErr("FBO initalize pre stencil");
     
     if (stencil)
     {
@@ -487,7 +471,7 @@
                                      GL_RENDERBUFFER_EXT, sbIndex);
     }
     
-    checkGLError("FBO initalize post stencil");
+    glErr("FBO initalize post stencil");
     
     endEditCP(thisP);
     
@@ -496,7 +480,7 @@
     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
     glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
 
-    checkGLError("FBO initalize post");
+    glErr("FBO initalize post");
     
     return result;
 }
@@ -524,7 +508,7 @@
             glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, target, 
id, 0);
         }
         
-        if (!checkGLError("setTarget post"))
+        if (!osgGlCheckError(__FILE__, __LINE__, "setTarget post"))
         {
             SWARNING << "Error with attachment: " << attachment
                      << ", id: " << id << ", target: " << target
@@ -884,7 +868,7 @@
                             
                             glCopyTexSubImage2D(targets[j], 0, x1, y1, 0, 0, 
tw, th);
                             
-                            checkGLError("Cube-Texture-Creation");
+                            glErr("Cube-Texture-Creation");
                             
                             glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);
                         }
@@ -1008,7 +992,7 @@
                             else
                                 glCopyTexSubImage2D(target, 0, x1, y1, 0, 0, 
tw, th);
                                                        
-                            checkGLError("Texture-Creation");
+                            glErr("Texture-Creation");
                             
                             if(getReadBuffer())
                             {
@@ -1095,7 +1079,7 @@
                 else
                     glCopyTexSubImage2D(target, 0, 0, 0, 0, 0, imgWidth, 
imgHeight);           
                 
-                checkGLError("Texture-Creation special mode");
+                glErr("Texture-Creation special mode");
                 
                 glBindTexture(target, 0);
             }
@@ -1213,7 +1197,7 @@
             if ( !initialize(win, format) )
                 assert(0);
 
-            checkGLError("FBO render pre\n");
+            glErr("FBO render pre\n");
             
             bind(win);
             
@@ -1478,7 +1462,7 @@
             
             stop(win);
 
-            checkGLError("FBO render post");
+            glErr("FBO render post");
         
             if (buffers)
                 delete [] buffers;
@@ -1626,7 +1610,7 @@
 
 namespace
 {
-    static Char8 cvsid_cpp       [] = "@(#)$Id: OSGFBOViewport.cpp,v 1.25 
2009/08/24 10:40:24 pdaehne Exp $";
+    static Char8 cvsid_cpp       [] = "@(#)$Id: OSGFBOViewport.cpp,v 1.26 
2011/01/20 17:20:54 neumannc Exp $";
     static Char8 cvsid_hpp       [] = OSGFBOVIEWPORTBASE_HEADER_CVSID;
     static Char8 cvsid_inl       [] = OSGFBOVIEWPORTBASE_INLINE_CVSID;
 
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to