diff options
author | Chris Forbes <[email protected]> | 2014-04-12 21:20:42 +1200 |
---|---|---|
committer | Chris Forbes <[email protected]> | 2014-04-13 19:26:56 +1200 |
commit | ca5c8d6cd435948af7ea0c70118e4d3e5ee66a32 (patch) | |
tree | 33d45eef94959bb7c8bb8262463b20fa35e82c2a /src/mesa | |
parent | aeb03f8aea2ee542c78f444c49647ecea92bced7 (diff) |
mesa: Extract is_active_attrib() in shaderapi
The rules are about to get a bit more complex to account for
gl_InstanceID and gl_VertexID, which are system values.
Extracting this first avoids introducing duplication.
Signed-off-by: Chris Forbes <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/shader_query.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index e1afe5315f4..1c3c8e9a4db 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -76,6 +76,21 @@ _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; + + default: + return false; + } +} + void GLAPIENTRY _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index, GLsizei maxLength, GLsizei * length, GLint * size, @@ -105,10 +120,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 +209,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++; } |