diff options
author | Ian Romanick <[email protected]> | 2011-08-18 15:27:18 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2011-10-04 13:17:48 -0700 |
commit | 24409ba1968cc49cbde6a111464c91271babc68a (patch) | |
tree | 00859ebec7bf3a7d117c98674135e879029b1874 /src/mesa/main/shader_query.cpp | |
parent | c097c63aa880e2b84e6b1d78a8808d42864f72fc (diff) |
mesa: Determine GL_ACTIVE_ATTRIBUTE_MAX_LENGTH by walking the GLSL IR.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main/shader_query.cpp')
-rw-r--r-- | src/mesa/main/shader_query.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
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; +} |