- }
-
- uni->initialized = true;
-
- _mesa_propagate_uniforms_to_driver_storage(uni, offset, count);
-}
-
-
-/**
- * Called via glGetUniformLocation().
- *
- * Returns the uniform index into UniformStorage (also the
- * glGetActiveUniformsiv uniform index), and stores the referenced
- * array offset in *offset, or GL_INVALID_INDEX (-1). Those two
- * return values can be encoded into a uniform location for
- * glUniform* using _mesa_uniform_merge_location_offset(index, offset).
- */
-extern "C" unsigned
-_mesa_get_uniform_location(struct gl_context *ctx,
- struct gl_shader_program *shProg,
- const GLchar *name,
- unsigned *out_offset)
-{
- /* Page 80 (page 94 of the PDF) of the OpenGL 2.1 spec says:
- *
- * "The first element of a uniform array is identified using the
- * name of the uniform array appended with "[0]". Except if the last
- * part of the string name indicates a uniform array, then the
- * location of the first element of that array can be retrieved by
- * either using the name of the uniform array, or the name of the
- * uniform array appended with "[0]"."
- *
- * Note: since uniform names are not allowed to use whitespace, and array
- * indices within uniform names are not allowed to use "+", "-", or leading
- * zeros, it follows that each uniform has a unique name up to the possible
- * ambiguity with "[0]" noted above. Therefore we don't need to worry
- * about mal-formed inputs--they will properly fail when we try to look up
- * the uniform name in shProg->UniformHash.
- */
-
- const GLchar *base_name_end;
- long offset = parse_program_resource_name(name, &base_name_end);
- bool array_lookup = offset >= 0;
- char *name_copy;
-
- if (array_lookup) {
- name_copy = (char *) malloc(base_name_end - name + 1);
- memcpy(name_copy, name, base_name_end - name);
- name_copy[base_name_end - name] = '\0';