On 3 January 2012 19:19, Ian Romanick <span dir="ltr">&lt;<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div>On 01/03/2012 06:52 PM, Eric Anholt wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The current implementation was totally broken -- it was looking in an<br>
unpopulated structure for varyings, and trying to do so using the<br>
current list of varying names, not the list used at link time.<br>
---<br>
  src/glsl/linker.cpp               |   37 ++++++++++++++++++++++++++++++<u></u>+------<br>
  src/mesa/main/mtypes.h            |   21 ++++++++++++++++++++-<br>
  src/mesa/main/<u></u>transformfeedback.c |   37 +++++++++++-------------------<u></u>-------<br>
  3 files changed, 62 insertions(+), 33 deletions(-)<br>
<br>
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp<br>
index 6587008..bf72a55 100644<br>
--- a/src/glsl/linker.cpp<br>
+++ b/src/glsl/linker.cpp<br>
@@ -1382,7 +1382,8 @@ public:<br>
     bool assign_location(struct gl_context *ctx, struct gl_shader_program *prog,<br>
                          ir_variable *output_var);<br>
     bool store(struct gl_shader_program *prog,<br>
-              struct gl_transform_feedback_info *info, unsigned buffer) const;<br>
+              struct gl_transform_feedback_info *info, unsigned buffer,<br>
+             unsigned varying) const;<br>
<br>
<br>
     /**<br>
@@ -1413,7 +1414,7 @@ public:<br>
  private:<br>
     /**<br>
      * The name that was supplied to glTransformFeedbackVaryings.  Used for<br>
-    * error reporting.<br>
+    * error reporting and glGetTransformFeedbackVarying(<u></u>).<br>
      */<br>
     const char *orig_name;<br>
<br>
@@ -1449,6 +1450,9 @@ private:<br>
      * if this variable is not a matrix.<br>
      */<br>
     unsigned matrix_columns;<br>
+<br>
+   /** Type of the varying returned by glGetTransformFeedbackVarying(<u></u>) */<br>
+   GLenum type;<br>
  };<br>
<br>
<br>
@@ -1520,8 +1524,9 @@ tfeedback_decl::assign_<u></u>location(struct gl_context *ctx,<br>
        /* Array variable */<br>
        if (!this-&gt;is_array) {<br>
           linker_error(prog, &quot;Transform feedback varying %s found, &quot;<br>
-                      &quot;but it&#39;s not an array ([] not expected).&quot;,<br>
-                      this-&gt;orig_name);<br>
+                      &quot;but array dereference required for varying %s[%d]).&quot;,<br>
+                      this-&gt;orig_name,<br>
+                     output_var-&gt;name, output_var-&gt;type-&gt;length);<br>
           return false;<br>
        }<br>
        /* Check array bounds. */<br>
@@ -1538,6 +1543,7 @@ tfeedback_decl::assign_<u></u>location(struct gl_context *ctx,<br>
        this-&gt;location = output_var-&gt;location + this-&gt;array_index * matrix_cols;<br>
        this-&gt;vector_elements = output_var-&gt;type-&gt;fields.<u></u>array-&gt;vector_elements;<br>
        this-&gt;matrix_columns = matrix_cols;<br>
+      this-&gt;type = GL_NONE;<br>
     } else {<br>
        /* Regular variable (scalar, vector, or matrix) */<br>
        if (this-&gt;is_array) {<br>
@@ -1549,6 +1555,7 @@ tfeedback_decl::assign_<u></u>location(struct gl_context *ctx,<br>
        this-&gt;location = output_var-&gt;location;<br>
        this-&gt;vector_elements = output_var-&gt;type-&gt;vector_<u></u>elements;<br>
        this-&gt;matrix_columns = output_var-&gt;type-&gt;matrix_<u></u>columns;<br>
+      this-&gt;type = output_var-&gt;type-&gt;gl_type;<br>
     }<br>
     /* From GL_EXT_transform_feedback:<br>
      *   A program will fail to link if:<br>
@@ -1580,7 +1587,7 @@ tfeedback_decl::assign_<u></u>location(struct gl_context *ctx,<br>
  bool<br>
  tfeedback_decl::store(struct gl_shader_program *prog,<br>
                        struct gl_transform_feedback_info *info,<br>
-                      unsigned buffer) const<br>
+                      unsigned buffer, unsigned varying) const<br>
  {<br>
     if (!this-&gt;is_assigned()) {<br>
        /* From GL_EXT_transform_feedback:<br>
@@ -1602,6 +1609,16 @@ tfeedback_decl::store(struct gl_shader_program *prog,<br>
        ++info-&gt;NumOutputs;<br>
        info-&gt;BufferStride[buffer] += this-&gt;vector_elements;<br>
     }<br>
+<br>
+   info-&gt;Varyings[varying].Name = ralloc_strdup(prog, this-&gt;orig_name);<br>
</blockquote>
<br></div></div>
Judging from the ralloc_free in the next hunk, is prog the right context?  It seems like info-&gt;Varyings is better.<br></blockquote><div><br>I was just about to make a similar comment.  With that change, these two patches are<br>

<br>Reviewed-by: Paul Berry &lt;<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>&gt;<br></div></div>