mesa: refactor GetActiveAttrib

Instead of iterating IR, retrieve required information through
the new program resource functions.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
This commit is contained in:
Tapani Pälli
2015-03-11 09:05:47 +02:00
parent 41c230cd98
commit 26c0394a96

View File

@@ -147,16 +147,21 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
return; return;
} }
exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir; struct gl_program_resource *res =
unsigned current_index = 0; _mesa_program_resource_find_index(shProg, GL_PROGRAM_INPUT,
desired_index);
foreach_in_list(ir_instruction, node, ir) { /* User asked for index that does not exist. */
const ir_variable *const var = node->as_variable(); if (!res) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)");
return;
}
const ir_variable *const var = RESOURCE_VAR(res);
if (!is_active_attrib(var)) if (!is_active_attrib(var))
continue; return;
if (current_index == desired_index) {
const char *var_name = var->name; const char *var_name = var->name;
/* Since gl_VertexID may be lowered to gl_VertexIDMESA, we need to /* Since gl_VertexID may be lowered to gl_VertexIDMESA, we need to
@@ -171,21 +176,12 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
_mesa_copy_string(name, maxLength, length, var_name); _mesa_copy_string(name, maxLength, length, var_name);
if (size) if (size)
*size = (var->type->is_array()) ? var->type->length : 1; _mesa_program_resource_prop(shProg, res, desired_index, GL_ARRAY_SIZE,
size, "glGetActiveAttrib");
if (type) if (type)
*type = var->type->gl_type; _mesa_program_resource_prop(shProg, res, desired_index, GL_TYPE,
(GLint *) type, "glGetActiveAttrib");
return;
}
current_index++;
}
/* If the loop did not return early, the caller must have asked for
* an index that did not exit. Set an error.
*/
_mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)");
} }
/* Locations associated with shader variables (array or non-array) can be /* Locations associated with shader variables (array or non-array) can be