mesa: Set correct values for range/precision of shader integer types
[mesa.git] / src / mesa / main / varray.c
index 340c3fe1d39bfe9bd33f57dc51ab264b2cabcede..29d8a8827e385d78e35a5af0db259f13aab3082d 100644 (file)
@@ -33,6 +33,7 @@
 #include "hash.h"
 #include "image.h"
 #include "macros.h"
+#include "mfeatures.h"
 #include "mtypes.h"
 #include "varray.h"
 #include "arrayobj.h"
@@ -127,8 +128,8 @@ update_array(struct gl_context *ctx,
    GLsizei elementSize;
    GLenum format = GL_RGBA;
 
-   if (ctx->API != API_OPENGLES) {
-      /* fixed point arrays / data is only allowed with OpenGL ES 1.x */
+   if (ctx->API != API_OPENGLES && ctx->API != API_OPENGLES2) {
+      /* fixed point arrays / data is only allowed with OpenGL ES 1.x/2.0 */
       legalTypesMask &= ~FIXED_BIT;
    }
 
@@ -297,7 +298,8 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
                       const GLvoid *ptr)
 {
    GLbitfield legalTypes = (SHORT_BIT | INT_BIT |
-                            HALF_BIT | FLOAT_BIT | DOUBLE_BIT);
+                            HALF_BIT | FLOAT_BIT | DOUBLE_BIT |
+                            FIXED_BIT);
    GET_CURRENT_CONTEXT(ctx);
    const GLuint unit = ctx->Array.ActiveTexture;
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -532,11 +534,19 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname,
       if (ctx->Extensions.EXT_gpu_shader4) {
          return array->Integer;
       }
-      /* fall-through */
+      goto error;
+   case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB:
+      if (ctx->Extensions.ARB_instanced_arrays) {
+         return array->InstanceDivisor;
+      }
+      goto error;
    default:
-      _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", caller, pname);
-      return 0;
+      ; /* fall-through */
    }
+
+error:
+   _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", caller, pname);
+   return 0;
 }
 
 
@@ -1063,6 +1073,33 @@ _mesa_PrimitiveRestartIndex(GLuint index)
 }
 
 
+/**
+ * See GL_ARB_instanced_arrays.
+ * Note that the instance divisor only applies to generic arrays, not
+ * the legacy vertex arrays.
+ */
+void GLAPIENTRY
+_mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+   if (!ctx->Extensions.ARB_instanced_arrays) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glVertexAttribDivisor()");
+      return;
+   }
+
+   if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glVertexAttribDivisor(index = %u)",
+                  index);
+      return;
+   }
+
+   ctx->Array.ArrayObj->VertexAttrib[index].InstanceDivisor = divisor;
+}
+
+
+
 /**
  * Copy one client vertex array to another.
  */
@@ -1080,6 +1117,7 @@ _mesa_copy_client_array(struct gl_context *ctx,
    dst->Enabled = src->Enabled;
    dst->Normalized = src->Normalized;
    dst->Integer = src->Integer;
+   dst->InstanceDivisor = src->InstanceDivisor;
    dst->_ElementSize = src->_ElementSize;
    _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
    dst->_MaxElement = src->_MaxElement;