On 3 January 2012 19:19, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></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->is_array) {<br>
linker_error(prog, "Transform feedback varying %s found, "<br>
- "but it's not an array ([] not expected).",<br>
- this->orig_name);<br>
+ "but array dereference required for varying %s[%d]).",<br>
+ this->orig_name,<br>
+ output_var->name, output_var->type->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->location = output_var->location + this->array_index * matrix_cols;<br>
this->vector_elements = output_var->type->fields.<u></u>array->vector_elements;<br>
this->matrix_columns = matrix_cols;<br>
+ this->type = GL_NONE;<br>
} else {<br>
/* Regular variable (scalar, vector, or matrix) */<br>
if (this->is_array) {<br>
@@ -1549,6 +1555,7 @@ tfeedback_decl::assign_<u></u>location(struct gl_context *ctx,<br>
this->location = output_var->location;<br>
this->vector_elements = output_var->type->vector_<u></u>elements;<br>
this->matrix_columns = output_var->type->matrix_<u></u>columns;<br>
+ this->type = output_var->type->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->is_assigned()) {<br>
/* From GL_EXT_transform_feedback:<br>
@@ -1602,6 +1609,16 @@ tfeedback_decl::store(struct gl_shader_program *prog,<br>
++info->NumOutputs;<br>
info->BufferStride[buffer] += this->vector_elements;<br>
}<br>
+<br>
+ info->Varyings[varying].Name = ralloc_strdup(prog, this->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->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 <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>><br></div></div>