mesa: Add support for glGetProgramiv pnames for UBOs.
authorEric Anholt <eric@anholt.net>
Thu, 14 Jun 2012 15:57:04 +0000 (08:57 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 31 Jul 2012 19:06:19 +0000 (12:06 -0700)
Fixes piglit ARB_uniform_buffer_object/getprogramiv.

v2: Add extension checks.
v3: Appease MSVC.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/shaderapi.c

index 7c97a63593f5f0cc52debe0d1a54213cca13fa1d..caeb9657e4ca50f78917a8b3ddde6bd44df24f6e 100644 (file)
@@ -544,6 +544,35 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
       *params = shProg->Geom.OutputType;
       break;
 #endif
+   case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: {
+      unsigned i;
+      GLint max_len = 0;
+
+      if (!ctx->Extensions.ARB_uniform_buffer_object) {
+         _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
+         return;
+      }
+
+      for (i = 0; i < shProg->NumUniformBlocks; i++) {
+        /* Add one for the terminating NUL character.
+         */
+        const GLint len = strlen(shProg->UniformBlocks[i].Name) + 1;
+
+        if (len > max_len)
+           max_len = len;
+      }
+
+      *params = max_len;
+      break;
+   }
+   case GL_ACTIVE_UNIFORM_BLOCKS:
+      if (!ctx->Extensions.ARB_uniform_buffer_object) {
+         _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
+         return;
+      }
+
+      *params = shProg->NumUniformBlocks;
+      break;
    default:
       _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
       return;