summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shader_query.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/shader_query.cpp')
-rw-r--r--src/mesa/main/shader_query.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 636ab0f8d0b..e9e6dbf7122 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -185,3 +185,30 @@ _mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name)
return -1;
}
+
+
+unsigned
+_mesa_count_active_attribs(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;
+ unsigned i = 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;
+
+ i++;
+ }
+
+ return i;
+}