From 5ff3857d42008bc7fde6ebae56710ecd311fef64 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 4 Sep 2012 11:49:13 -0700 Subject: [PATCH] trim: Fix bug linking incorrect programs to shaders through samplers. 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 | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/cli/cli_trim.cpp b/cli/cli_trim.cpp index abcae0a..22cdcd1 100644 --- a/cli/cli_trim.cpp +++ b/cli/cli_trim.cpp @@ -149,7 +149,6 @@ class TraceAnalyzer { /* Maps for tracking OpenGL state. */ std::map texture_map; - std::map 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); -- 2.43.0