]> git.cworth.org Git - apitrace/commitdiff
trim: Fix bug linking incorrect programs to shaders through samplers.
authorCarl Worth <cworth@cworth.org>
Tue, 4 Sep 2012 18:49:13 +0000 (11:49 -0700)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Thu, 22 Nov 2012 08:03:14 +0000 (08:03 +0000)
Previously, the code was mapping locations returned by
glGetUniformLocation and looking in the location map to try ot
determine which program to link in a glUniform1i call. This was
entirely bogus, as distinct programs do not have distinct location
spaces.

The correct answer is to simply track the currently active program and
link it to textures being bound to shaders.

cli/cli_trim.cpp

index abcae0a0b34ec10ea7dc546838e43b74636a2e44..22cdcd13367d3c0760bc88db5cc189d2f733a912 100644 (file)
@@ -149,7 +149,6 @@ class TraceAnalyzer {
 
     /* Maps for tracking OpenGL state. */
     std::map<GLenum, unsigned> texture_map;
-    std::map<GLint, GLuint> location_program_map;
 
     /* The final set of calls required. This consists of calls added
      * explicitly with the require() method as well as all calls
@@ -159,6 +158,7 @@ class TraceAnalyzer {
     bool transformFeedbackActive;
     bool framebufferObjectActive;
     bool insideBeginEnd;
+    GLuint activeProgram;
 
     /* Rendering often has no side effects, but it can in some cases,
      * (such as when transform feedback is active, or when rendering
@@ -278,6 +278,10 @@ class TraceAnalyzer {
             return;
         }
 
+        if (strcmp(name, "glUseProgram") == 0) {
+            activeProgram = call->arg(0).toUInt();
+        }
+
         if (strcmp(name, "glBindFramebuffer") == 0) {
             GLenum target;
             GLuint framebuffer;
@@ -573,13 +577,9 @@ class TraceAnalyzer {
             strcmp(name, "glGetVaryingLocationNV") == 0) {
 
             GLuint program;
-            GLint location;
             std::stringstream ss;
 
             program = call->arg(0).toUInt();
-            location = call->ret->toSInt();
-
-            location_program_map[location] = program;
 
             ss << "program-" << program;
 
@@ -594,15 +594,9 @@ class TraceAnalyzer {
         if (call->sig->num_args > 0 &&
             strcmp(call->sig->arg_names[0], "location") == 0) {
 
-            GLuint program;
-            GLint location;
             std::stringstream ss;
 
-            location = call->arg(0).toSInt();
-
-            program = location_program_map[location];
-
-            ss << "program-" << program;
+            ss << "program-" << activeProgram;
 
             provide(ss.str(), call->no);