Add state queries for uniform buffer object count and alignment, and enforce a large alignment.

This will allow us to force the app to bind uniform buffers with zero offset. Zero offset allows us to map
uniform blocks one-to-one to uniform buffers, then subsequently map UBOs to constant buffers.

TRAC #22852

Signed-off-by: Geoff Lang
Signed-off-by: Nicolas Capens
Author: Jamie Madill

git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2285 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index c456330..c4b79eb 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -8676,6 +8676,13 @@
                 break;
 
               case GL_UNIFORM_BUFFER:
+
+                // it is an error to bind an offset not a multiple of the alignment
+                if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0)
+                {
+                    return gl::error(GL_INVALID_VALUE);
+                }
+
                 context->bindIndexedUniformBuffer(buffer, index, offset, size);
                 context->bindGenericUniformBuffer(buffer);
                 break;