1 // all allocations need to use hieralloc 2 #include "prog_parameter.h" 3 4 #include "src/glsl/ir.h" 5 6 extern GLint _mesa_add_parameter(struct gl_program_parameter_list * paramList, 7 const char * name) 8 { 9 int index = _mesa_get_parameter(paramList, name); 10 if (index >= 0) 11 return index; 12 13 paramList->NumParameters++; 14 if (paramList->NumParameters > paramList->Size) { 15 paramList->Size = paramList->NumParameters + 4; 16 paramList->Parameters = hieralloc_realloc(paramList, paramList->Parameters, 17 gl_program_parameter, paramList->Size); 18 } 19 20 gl_program_parameter * param = paramList->Parameters + paramList->NumParameters - 1; 21 memset(param, 0, sizeof(*param)); 22 param->Name = hieralloc_strdup(paramList, name); 23 param->BindLocation = -1; 24 param->Location = -1; 25 26 return paramList->NumParameters - 1; 27 } 28 29 extern GLint _mesa_get_parameter(const struct gl_program_parameter_list * paramList, 30 const char * name) 31 { 32 for (unsigned i = 0; i < paramList->NumParameters; i++) 33 if (!strcmp(name, paramList->Parameters[i].Name)) 34 return i; 35 return -1; 36 } 37