diff options
author | Brian Paul <[email protected]> | 2010-03-30 19:54:02 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-03-30 20:04:04 -0600 |
commit | e5c69647b0b1e7a2f1e1af75bf02d1bb0b8aac2b (patch) | |
tree | c8a5a98aa0fd9cfc651080d784e1b9bb97080b60 /src | |
parent | 4e9f07544821fbf7e7b079871c83555042073848 (diff) |
mesa: add transform feedback queries
And make _mesa_copy_string() non-static.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/shader/shader_api.c | 54 | ||||
-rw-r--r-- | src/mesa/shader/shader_api.h | 6 |
2 files changed, 53 insertions, 7 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 940fe2d03ce..36fe0a1bb72 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -123,6 +123,14 @@ _mesa_free_shader_program_data(GLcontext *ctx, free(shProg->InfoLog); shProg->InfoLog = NULL; } + + /* Transform feedback varying vars */ + for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { + free(shProg->TransformFeedback.VaryingNames[i]); + } + free(shProg->TransformFeedback.VaryingNames); + shProg->TransformFeedback.VaryingNames = NULL; + shProg->TransformFeedback.NumVarying = 0; } @@ -397,6 +405,25 @@ get_shader_flags(void) /** + * Find the length of the longest transform feedback varying name + * which was specified with glTransformFeedbackVaryings(). + */ +static GLint +longest_feedback_varying_name(const struct gl_shader_program *shProg) +{ + GLuint i; + GLint max = 0; + for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { + GLint len = strlen(shProg->TransformFeedback.VaryingNames[i]); + if (len > max) + max = len; + } + return max; +} + + + +/** * Initialize context's shader state. */ void @@ -437,8 +464,9 @@ _mesa_free_shader_state(GLcontext *ctx) * \param length returns number of chars copied * \param dst the string destination */ -static void -copy_string(GLchar *dst, GLsizei maxLength, GLsizei *length, const GLchar *src) +void +_mesa_copy_string(GLchar *dst, GLsizei maxLength, + GLsizei *length, const GLchar *src) { GLsizei len; for (len = 0; len < maxLength - 1 && src && src[len]; len++) @@ -879,7 +907,8 @@ _mesa_get_active_attrib(GLcontext *ctx, GLuint program, GLuint index, return; } - copy_string(nameOut, maxLength, length, attribs->Parameters[index].Name); + _mesa_copy_string(nameOut, maxLength, length, + attribs->Parameters[index].Name); if (size) *size = attribs->Parameters[index].Size @@ -954,7 +983,7 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index, param = &prog->Parameters->Parameters[progPos]; if (nameOut) { - copy_string(nameOut, maxLength, length, param->Name); + _mesa_copy_string(nameOut, maxLength, length, param->Name); } if (size) { @@ -1063,6 +1092,17 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program, case GL_PROGRAM_BINARY_LENGTH_OES: *params = 0; break; +#if FEATURE_EXT_transform_feedback + case GL_TRANSFORM_FEEDBACK_VARYINGS: + *params = shProg->TransformFeedback.NumVarying; + break; + case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: + *params = longest_feedback_varying_name(shProg) + 1; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: + *params = shProg->TransformFeedback.BufferMode; + break; +#endif default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); return; @@ -1112,7 +1152,7 @@ _mesa_get_program_info_log(GLcontext *ctx, GLuint program, GLsizei bufSize, _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)"); return; } - copy_string(infoLog, bufSize, length, shProg->InfoLog); + _mesa_copy_string(infoLog, bufSize, length, shProg->InfoLog); } @@ -1125,7 +1165,7 @@ _mesa_get_shader_info_log(GLcontext *ctx, GLuint shader, GLsizei bufSize, _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)"); return; } - copy_string(infoLog, bufSize, length, sh->InfoLog); + _mesa_copy_string(infoLog, bufSize, length, sh->InfoLog); } @@ -1141,7 +1181,7 @@ _mesa_get_shader_source(GLcontext *ctx, GLuint shader, GLsizei maxLength, if (!sh) { return; } - copy_string(sourceOut, maxLength, length, sh->Source); + _mesa_copy_string(sourceOut, maxLength, length, sh->Source); } diff --git a/src/mesa/shader/shader_api.h b/src/mesa/shader/shader_api.h index d08d47373e1..3ed52747cdb 100644 --- a/src/mesa/shader/shader_api.h +++ b/src/mesa/shader/shader_api.h @@ -42,6 +42,12 @@ _mesa_init_shader_state(GLcontext * ctx); extern void _mesa_free_shader_state(GLcontext *ctx); + +extern void +_mesa_copy_string(GLchar *dst, GLsizei maxLength, + GLsizei *length, const GLchar *src); + + /* extern struct gl_shader_program * _mesa_new_shader_program(GLcontext *ctx, GLuint name); |