aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/shader_query.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/shader_query.cpp')
-rw-r--r--mesalib/src/mesa/main/shader_query.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/mesalib/src/mesa/main/shader_query.cpp b/mesalib/src/mesa/main/shader_query.cpp
index e1afe5315..f66c11733 100644
--- a/mesalib/src/mesa/main/shader_query.cpp
+++ b/mesalib/src/mesa/main/shader_query.cpp
@@ -76,6 +76,30 @@ _mesa_BindAttribLocation(GLhandleARB program, GLuint index,
*/
}
+static bool
+is_active_attrib(const ir_variable *var)
+{
+ if (!var)
+ return false;
+
+ switch (var->data.mode) {
+ case ir_var_shader_in:
+ return var->data.location != -1;
+
+ case ir_var_system_value:
+ /* From GL 4.3 core spec, section 11.1.1 (Vertex Attributes):
+ * "For GetActiveAttrib, all active vertex shader input variables
+ * are enumerated, including the special built-in inputs gl_VertexID
+ * and gl_InstanceID."
+ */
+ return !strcmp(var->name, "gl_VertexID") ||
+ !strcmp(var->name, "gl_InstanceID");
+
+ default:
+ return false;
+ }
+}
+
void GLAPIENTRY
_mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
GLsizei maxLength, GLsizei * length, GLint * size,
@@ -105,10 +129,8 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
foreach_list(node, ir) {
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var == NULL
- || var->data.mode != ir_var_shader_in
- || var->data.location == -1)
- continue;
+ if (!is_active_attrib(var))
+ continue;
if (current_index == desired_index) {
_mesa_copy_string(name, maxLength, length, var->name);
@@ -196,10 +218,8 @@ _mesa_count_active_attribs(struct gl_shader_program *shProg)
foreach_list(node, ir) {
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var == NULL
- || var->data.mode != ir_var_shader_in
- || var->data.location == -1)
- continue;
+ if (!is_active_attrib(var))
+ continue;
i++;
}