]> git.cworth.org Git - apitrace/commitdiff
Try active shader program before current program.
authorGregory Hainaut <gregory.hainaut@gmail.com>
Fri, 11 May 2012 13:49:10 +0000 (14:49 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 11 May 2012 13:49:10 +0000 (14:49 +0100)
With separate shader program, one can't query anymore current program
with glGetIntegerv(GL_CURRENT_PROGRAM, &program), so glUniform* fails to
store the correct location during retracing.

Technically glActiveShaderProgram must be used to set the active program
for Uniform. But on my system (AMD) it works without it, I don't know if
it is valid or not.

This change uses the active shader (would be 0 if the users don't call
glActiveShaderProgram) instead of current program (0 in pipeline mode)

Signed-off-by: José Fonseca <jose.r.fonseca@gmail.com>
retrace/glretrace.py

index af5e7d124562b133ef03d04806a4008a18293d26..857c1b5fa551493a9d258520b4935ce8cf0713dc 100644 (file)
@@ -278,6 +278,12 @@ class GlRetracer(Retracer):
             print r'        } else {'
             print r'            retrace::warning(call) << "no current context\n";'
             print r'        }'
+
+        if function.name in ('glBindProgramPipeline', 'glBindProgramPipelineEXT'):
+            # Note if glBindProgramPipeline has ever been called
+            print r'    if (pipeline) {'
+            print r'        _pipelineHasBeenBound = true;'
+            print r'    }'
         
         Retracer.invokeFunction(self, function)
 
@@ -399,9 +405,19 @@ class GlRetracer(Retracer):
 
         if arg.type is glapi.GLlocation \
            and 'program' not in function.argNames():
+            # Determine the active program for uniforms swizzling
             print '    GLint program = -1;'
-            print '    glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
-        
+            print '    GLint pipeline = 0;'
+            print '    if (_pipelineHasBeenBound) {'
+            print '        glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &pipeline);'
+            print '    }'
+            print '    if (pipeline) {'
+            print '        glGetProgramPipelineiv(pipeline, GL_ACTIVE_PROGRAM, &program);'
+            print '    } else {'
+            print '        glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
+            print '    }'
+            print
+
         if arg.type is glapi.GLlocationARB \
            and 'programObj' not in function.argNames():
             print '    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);'
@@ -433,6 +449,7 @@ if __name__ == '__main__':
 #include "glstate.hpp"
 
 
+static bool _pipelineHasBeenBound = false;
 '''
     api = glapi.glapi
     api.addApi(glesapi.glesapi)