From 24409ba1968cc49cbde6a111464c91271babc68a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 18 Aug 2011 15:27:18 -0700 Subject: mesa: Determine GL_ACTIVE_ATTRIBUTE_MAX_LENGTH by walking the GLSL IR. Signed-off-by: Ian Romanick Reviewed-by: Kenneth Graunke --- src/mesa/main/shader_query.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/mesa/main/shader_query.cpp') diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index e9e6dbf7122..e532a29e1cf 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -212,3 +212,32 @@ _mesa_count_active_attribs(struct gl_shader_program *shProg) return i; } + + +size_t +_mesa_longest_attribute_name_length(struct gl_shader_program *shProg) +{ + if (!shProg->LinkStatus + || shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) { + return 0; + } + + exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir; + size_t longest = 0; + + foreach_list(node, ir) { + const ir_variable *const var = ((ir_instruction *) node)->as_variable(); + + if (var == NULL + || var->mode != ir_var_in + || var->location == -1 + || var->location < VERT_ATTRIB_GENERIC0) + continue; + + const size_t len = strlen(var->name); + if (len >= longest) + longest = len + 1; + } + + return longest; +} -- cgit v1.2.3