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;
+}
static void
get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *params)
{
- const struct gl_program_parameter_list *attribs;
struct gl_shader_program *shProg
= _mesa_lookup_shader_program(ctx, program);
return;
}
- if (shProg->VertexProgram)
- attribs = shProg->VertexProgram->Base.Attributes;
- else
- attribs = NULL;
-
switch (pname) {
case GL_DELETE_STATUS:
*params = shProg->DeletePending;
*params = _mesa_count_active_attribs(shProg);
break;
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
- *params = _mesa_longest_parameter_name(attribs, PROGRAM_INPUT) + 1;
+ *params = _mesa_longest_attribute_name_length(shProg);
break;
case GL_ACTIVE_UNIFORMS:
*params = shProg->Uniforms ? shProg->Uniforms->NumUniforms : 0;
extern unsigned
_mesa_count_active_attribs(struct gl_shader_program *shProg);
+extern size_t
+_mesa_longest_attribute_name_length(struct gl_shader_program *shProg);
extern void GLAPIENTRY
_mesa_AttachObjectARB(GLhandleARB, GLhandleARB);
}
-
-/**
- * Find longest name of all uniform parameters in list.
- */
-GLuint
-_mesa_longest_parameter_name(const struct gl_program_parameter_list *list,
- gl_register_file type)
-{
- GLuint i, maxLen = 0;
- if (!list)
- return 0;
- for (i = 0; i < list->NumParameters; i++) {
- if (list->Parameters[i].Type == type) {
- GLuint len = strlen(list->Parameters[i].Name);
- if (len > maxLen)
- maxLen = len;
- }
- }
- return maxLen;
-}
-
-
/**
* Count the number of parameters in the last that match the given type.
*/
const gl_constant_value v[], GLuint vSize,
GLint *posOut, GLuint *swizzleOut);
-extern GLuint
-_mesa_longest_parameter_name(const struct gl_program_parameter_list *list,
- gl_register_file type);
-
extern GLuint
_mesa_num_parameters_of_type(const struct gl_program_parameter_list *list,
gl_register_file type);