Mesa (master): mesa: Fold _mesa_uniform_merge_location_offset into its only caller

Ian Romanick idr at kemper.freedesktop.org
Thu Aug 7 23:18:24 UTC 2014


Module: Mesa
Branch: master
Commit: 89d92fc00e52ac0f9d5bb1edf81660ab93816f1b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=89d92fc00e52ac0f9d5bb1edf81660ab93816f1b

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Aug  1 18:53:09 2014 -0700

mesa: Fold _mesa_uniform_merge_location_offset into its only caller

Also delete the comment before that function.  Everything in that
comment was either stale, wrong, or captured elsewhere.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/main/uniform_query.cpp |    4 +---
 src/mesa/main/uniforms.c        |    3 ++-
 src/mesa/main/uniforms.h        |   44 ---------------------------------------
 3 files changed, 3 insertions(+), 48 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 5989364..7e630e6 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -993,9 +993,7 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
  *
  * 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).
+ * array offset in *offset, or GL_INVALID_INDEX (-1).
  */
 extern "C" unsigned
 _mesa_get_uniform_location(struct gl_context *ctx,
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index b6512fe..0d0cbf5 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -932,7 +932,8 @@ _mesa_GetUniformLocation(GLuint programObj, const GLcharARB *name)
        shProg->UniformStorage[index].atomic_buffer_index != -1)
       return -1;
 
-   return _mesa_uniform_merge_location_offset(shProg, index, offset);
+   /* location in remap table + array element offset */
+   return shProg->UniformStorage[index].remap_location + offset;
 }
 
 GLuint GLAPIENTRY
diff --git a/src/mesa/main/uniforms.h b/src/mesa/main/uniforms.h
index 3e16483..e7a370e 100644
--- a/src/mesa/main/uniforms.h
+++ b/src/mesa/main/uniforms.h
@@ -323,50 +323,6 @@ struct gl_builtin_uniform_desc {
    unsigned int num_elements;
 };
 
-/**
- * \name GLSL uniform arrays and structs require special handling.
- *
- * The GL_ARB_shader_objects spec says that if you use
- * glGetUniformLocation to get the location of an array, you CANNOT
- * access other elements of the array by adding an offset to the
- * returned location.  For example, you must call
- * glGetUniformLocation("foo[16]") if you want to set the 16th element
- * of the array with glUniform().
- *
- * HOWEVER, some other OpenGL drivers allow accessing array elements
- * by adding an offset to the returned array location.  And some apps
- * seem to depend on that behaviour.
- *
- * Mesa's gl_uniform_list doesn't directly support this since each
- * entry in the list describes one uniform variable, not one uniform
- * element.  We could insert dummy entries in the list for each array
- * element after [0] but that causes complications elsewhere.
- *
- * We solve this problem by creating multiple entries for uniform arrays
- * in the UniformRemapTable so that their elements get sequential locations.
- *
- * Utility functions below offer functionality to split UniformRemapTable
- * location in to location of the uniform in UniformStorage + offset to the
- * array element (0 if not an array) and also merge it back again as the
- * UniformRemapTable location.
- *
- */
-/*@{*/
-/**
- * Combine the uniform's storage index and the array index
- */
-static inline GLint
-_mesa_uniform_merge_location_offset(const struct gl_shader_program *prog,
-                                    unsigned storage_index,
-                                    unsigned uniform_array_index)
-{
-   /* location in remap table + array element offset */
-   return prog->UniformStorage[storage_index].remap_location +
-      uniform_array_index;
-}
-/*@}*/
-
-
 #ifdef __cplusplus
 }
 #endif




More information about the mesa-commit mailing list