diff options
author | Eric Anholt <[email protected]> | 2012-01-02 17:08:13 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2012-01-05 09:11:29 -0800 |
commit | 9d36c96d6ec9f2c05c8e0b9ef18c5462cddee8c1 (patch) | |
tree | bbf6423de5fc0064dc86ca35f8b81978d2177eb9 /src/mesa/main | |
parent | cc1d8a466a52ae89080f5dec06c1859235643532 (diff) |
mesa: Fix glGetTransformFeedbackVarying().
The current implementation was totally broken -- it was looking in an
unpopulated structure for varyings, and trying to do so using the
current list of varying names, not the list used at link time.
v2: Fix leaking of memory into the program per re-link.
Reviewed-by: Paul Berry <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/mtypes.h | 21 | ||||
-rw-r--r-- | src/mesa/main/transformfeedback.c | 37 |
2 files changed, 31 insertions, 27 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 35458e396ad..50d7e341f56 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1817,6 +1817,12 @@ struct prog_instruction; struct gl_program_parameter_list; struct gl_uniform_list; +struct gl_transform_feedback_varying_info { + char *Name; + GLenum Type; + GLint Size; +}; + /** Post-link transform feedback info. */ struct gl_transform_feedback_info { unsigned NumOutputs; @@ -1835,6 +1841,13 @@ struct gl_transform_feedback_info { unsigned DstOffset; } Outputs[MAX_PROGRAM_OUTPUTS]; + /** Transform feedback varyings used for the linking of this shader program. + * + * Use for glGetTransformFeedbackVarying(). + */ + struct gl_transform_feedback_varying_info *Varyings; + GLint NumVarying; + /** * Total number of components stored in each buffer. This may be used by * hardware back-ends to determine the correct stride when interleaving @@ -2227,7 +2240,13 @@ struct gl_shader_program */ struct string_to_uint_map *FragDataBindings; - /** Transform feedback varyings */ + /** + * Transform feedback varyings last specified by + * glTransformFeedbackVaryings(). + * + * For the current set of transform feeedback varyings used for transform + * feedback output, see LinkedTransformFeedback. + */ struct { GLenum BufferMode; GLuint NumVarying; diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 02681c61583..c2114c22766 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -694,8 +694,7 @@ _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei *size, GLenum *type, GLchar *name) { const struct gl_shader_program *shProg; - const GLchar *varyingName; - GLint v; + const struct gl_transform_feedback_info *linked_xfb_info; GET_CURRENT_CONTEXT(ctx); shProg = _mesa_lookup_shader_program(ctx, program); @@ -705,36 +704,22 @@ _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, return; } - if (index >= shProg->TransformFeedback.NumVarying) { + linked_xfb_info = &shProg->LinkedTransformFeedback; + if (index >= linked_xfb_info->NumVarying) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetTransformFeedbackVaryings(index=%u)", index); return; } - varyingName = shProg->TransformFeedback.VaryingNames[index]; + /* return the varying's name and length */ + _mesa_copy_string(name, bufSize, length, + linked_xfb_info->Varyings[index].Name); - v = _mesa_lookup_parameter_index(shProg->Varying, -1, varyingName); - if (v >= 0) { - struct gl_program_parameter *param = &shProg->Varying->Parameters[v]; - - /* return the varying's name and length */ - _mesa_copy_string(name, bufSize, length, varyingName); - - /* return the datatype and value's size (in datatype units) */ - if (type) - *type = param->DataType; - if (size) - *size = param->Size; - } - else { - name[0] = 0; - if (length) - *length = 0; - if (type) - *type = 0; - if (size) - *size = 0; - } + /* return the datatype and value's size (in datatype units) */ + if (type) + *type = linked_xfb_info->Varyings[index].Type; + if (size) + *size = linked_xfb_info->Varyings[index].Size; } |