diff options
author | Eric Anholt <[email protected]> | 2012-06-25 10:23:24 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2012-07-20 10:43:33 -0700 |
commit | abcdbdf9cce3c7520ee999fac3099d609960847d (patch) | |
tree | fd3c3bb8d17baff017aeea9819d04fd695c31a6b /src/mesa/main/uniform_query.cpp | |
parent | f609cf782ab5e90ddf045dc4b0da8cebf99be0d1 (diff) |
mesa: Move the _mesa_uniform_merge_location_offset to glGetUniformLocation().
With the upcoming GL_ARB_uniform_buffer_object changes, the only
other caller that will want the cooked value is state_tracker.
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main/uniform_query.cpp')
-rw-r--r-- | src/mesa/main/uniform_query.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index f5d998ffb22..25d887dbcdc 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -852,13 +852,17 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, /** * Called via glGetUniformLocation(). * - * The return value will encode two values, the uniform location and an - * offset (used for arrays, structs). + * 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" GLint +extern "C" unsigned _mesa_get_uniform_location(struct gl_context *ctx, struct gl_shader_program *shProg, - const GLchar *name) + const GLchar *name, + unsigned *out_offset) { const size_t len = strlen(name); long offset; @@ -901,13 +905,13 @@ _mesa_get_uniform_location(struct gl_context *ctx, * (or other non-digit characters) before the opening '['. */ if ((i == 0) || name[i-1] != '[') - return -1; + return GL_INVALID_INDEX; /* Return an error if there are no digits between the opening '[' to * match the closing ']'. */ if (i == (len - 1)) - return -1; + return GL_INVALID_INDEX; /* Make a new string that is a copy of the old string up to (but not * including) the '[' character. @@ -919,7 +923,7 @@ _mesa_get_uniform_location(struct gl_context *ctx, offset = strtol(&name[i], NULL, 10); if (offset < 0) { free(name_copy); - return -1; + return GL_INVALID_INDEX; } array_lookup = true; @@ -941,16 +945,17 @@ _mesa_get_uniform_location(struct gl_context *ctx, free(name_copy); if (!found) - return -1; + return GL_INVALID_INDEX; /* Since array_elements is 0 for non-arrays, this causes look-ups of 'a[0]' * to (correctly) fail if 'a' is not an array. */ if (array_lookup && shProg->UniformStorage[location].array_elements == 0) { - return -1; + return GL_INVALID_INDEX; } - return _mesa_uniform_merge_location_offset(location, offset); + *out_offset = offset; + return location; } extern "C" bool |