mesa: add back glGetnUniform*v() overflow error reporting
authorDylan Noblesmith <nobled@dreamwidth.org>
Thu, 22 Dec 2011 21:05:38 +0000 (21:05 +0000)
committerDylan Noblesmith <nobled@dreamwidth.org>
Tue, 13 Mar 2012 15:59:24 +0000 (15:59 +0000)
The error was removed in:

commit 719909698c67c287a393d2380278e7b7495ae018
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Tue Oct 18 16:01:49 2011 -0700

    mesa: Rewrite the way uniforms are tracked and handled

The GL_ARB_robustness spec doesn't say the implementation
should truncate the output, so just return after setting
the required error like it did before the above commit.

Also fixup an old comment and add an assert.

NOTE: This is a candidate for the 8.0 branch.

src/mesa/main/uniform_query.cpp
src/mesa/main/uniforms.c

index 869f7d373ba9bdc55f9db06e8fcc3b4ee3a71b4b..991df7896b41fad6567a3c823a094144d30ccc09 100644 (file)
@@ -203,10 +203,18 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
       const union gl_constant_value *const src =
         &uni->storage[offset * elements];
 
-      unsigned bytes = sizeof(uni->storage[0]) * elements;
-      if (bytes > (unsigned) bufSize) {
-        elements = bufSize / sizeof(uni->storage[0]);
-        bytes = bufSize;
+      assert(returnType == GLSL_TYPE_FLOAT || returnType == GLSL_TYPE_INT ||
+             returnType == GLSL_TYPE_UINT);
+      /* The three (currently) supported types all have the same size,
+       * which is of course the same as their union. That'll change
+       * with glGetUniformdv()...
+       */
+      unsigned bytes = sizeof(src[0]) * elements;
+      if (bufSize < 0 || bytes > (unsigned) bufSize) {
+        _mesa_error( ctx, GL_INVALID_OPERATION,
+                    "glGetnUniform*vARB(out of bounds: bufSize is %d,"
+                    " but %u bytes are required)", bufSize, bytes );
+        return;
       }
 
       /* If the return type and the uniform's native type are "compatible,"
index e0214a88a7a76a3854262d8828f760ef0e81bf8c..be1e1728d305a4bac937c0441f5fbeadd6608fa7 100644 (file)
@@ -479,7 +479,7 @@ _mesa_GetnUniformdvARB(GLhandleARB program, GLint location,
    (void) params;
 
    /*
-   _mesa_get_uniform(ctx, program, location, bufSize, GL_DOUBLE, params);
+   _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_DOUBLE, params);
    */
    _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformdvARB"
                "(GL_ARB_gpu_shader_fp64 not implemented)");