]> git.cworth.org Git - apitrace/blobdiff - glretrace.py
Merge branch 'master' into multi-context
[apitrace] / glretrace.py
index 9b461608485f993b3e4d62bc8853045fafb63ab8..706dbb44d78f3d9da5be6c41f99105e501404e44 100644 (file)
@@ -125,6 +125,15 @@ class GlRetracer(Retracer):
 
         Retracer.retrace_function_body(self, function)
 
+        if function.name in ('glFlush', 'glFinish'):
+            print '    if (!glretrace::double_buffer) {'
+            print '        glretrace::frame_complete(call.no);'
+            print '    }'
+
+        if function.name == 'glReadPixels':
+            print '    glFinish();'
+            print '    glretrace::frame_complete(call.no);'
+
     def call_function(self, function):
         if function.name == "glViewport":
             print '    if (glretrace::drawable) {'
@@ -147,10 +156,61 @@ class GlRetracer(Retracer):
             # glGetError is not allowed inside glBegin/glEnd
             print '    glretrace::checkGlError(call);'
 
-        if function.name == 'glFlush':
-            print '    if (!glretrace::double_buffer) {'
-            print '        glretrace::frame_complete(call.no);'
-            print '    }'
+        if function.name in ('glProgramStringARB', 'glProgramStringNV'):
+            print r'    GLint error_position = -1;'
+            print r'    glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_position);'
+            print r'    if (error_position != -1) {'
+            print r'        const char *error_string = (const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB);'
+            print r'        std::cerr << call.no << ": warning: " << error_string << "\n";'
+            print r'    }'
+
+        if function.name == 'glCompileShader':
+            print r'    GLint compile_status = 0;'
+            print r'    glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);'
+            print r'    if (!compile_status) {'
+            print r'         GLint info_log_length = 0;'
+            print r'         glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_length);'
+            print r'         GLchar *infoLog = new GLchar[info_log_length];'
+            print r'         glGetShaderInfoLog(shader, info_log_length, NULL, infoLog);'
+            print r'         std::cerr << call.no << ": warning: " << infoLog << "\n";'
+            print r'         delete [] infoLog;'
+            print r'    }'
+
+        if function.name == 'glLinkProgram':
+            print r'    GLint link_status = 0;'
+            print r'    glGetProgramiv(program, GL_LINK_STATUS, &link_status);'
+            print r'    if (!link_status) {'
+            print r'         GLint info_log_length = 0;'
+            print r'         glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);'
+            print r'         GLchar *infoLog = new GLchar[info_log_length];'
+            print r'         glGetProgramInfoLog(program, info_log_length, NULL, infoLog);'
+            print r'         std::cerr << call.no << ": warning: " << infoLog << "\n";'
+            print r'         delete [] infoLog;'
+            print r'    }'
+
+        if function.name == 'glCompileShaderARB':
+            print r'    GLint compile_status = 0;'
+            print r'    glGetObjectParameterivARB(shaderObj, GL_OBJECT_COMPILE_STATUS_ARB, &compile_status);'
+            print r'    if (!compile_status) {'
+            print r'         GLint info_log_length = 0;'
+            print r'         glGetObjectParameterivARB(shaderObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);'
+            print r'         GLchar *infoLog = new GLchar[info_log_length];'
+            print r'         glGetInfoLogARB(shaderObj, info_log_length, NULL, infoLog);'
+            print r'         std::cerr << call.no << ": warning: " << infoLog << "\n";'
+            print r'         delete [] infoLog;'
+            print r'    }'
+
+        if function.name == 'glLinkProgramARB':
+            print r'    GLint link_status = 0;'
+            print r'    glGetObjectParameterivARB(programObj, GL_OBJECT_LINK_STATUS_ARB, &link_status);'
+            print r'    if (!link_status) {'
+            print r'         GLint info_log_length = 0;'
+            print r'         glGetObjectParameterivARB(programObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);'
+            print r'         GLchar *infoLog = new GLchar[info_log_length];'
+            print r'         glGetInfoLogARB(programObj, info_log_length, NULL, infoLog);'
+            print r'         std::cerr << call.no << ": warning: " << infoLog << "\n";'
+            print r'         delete [] infoLog;'
+            print r'    }'
 
     def extract_arg(self, function, arg, arg_type, lvalue, rvalue):
         if function.name in self.array_pointer_function_names and arg.name == 'pointer':
@@ -161,12 +221,26 @@ class GlRetracer(Retracer):
             print '    %s = %s.toPointer();' % (lvalue, rvalue)
             return
 
-        if function.name.startswith('glUniform') and function.args[0].name == arg.name == 'location':
+        if arg.type is glapi.GLlocation \
+           and 'program' not in [arg.name for arg in function.args]:
             print '    GLint program = -1;'
             print '    glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
+        
+        if arg.type is glapi.GLlocationARB \
+           and 'programObj' not in [arg.name for arg in function.args]:
+            print '    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);'
 
         Retracer.extract_arg(self, function, arg, arg_type, lvalue, rvalue)
 
+        # Don't try to use more samples than the implementation supports
+        if arg.name == 'samples':
+            assert arg.type is glapi.GLsizei
+            print '    GLint max_samples = 0;'
+            print '    glGetIntegerv(GL_MAX_SAMPLES, &max_samples);'
+            print '    if (samples > max_samples) {'
+            print '        samples = max_samples;'
+            print '    }'
+
 
 if __name__ == '__main__':
     print r'''