Merge branch 'arb_half_float_vertex'
[mesa.git] / src / mesa / main / varray.c
index 3d5b8faecff91b1759b05c8c7e19de945e6b72c7..0b6295d5e162b44bdc0e56cda7d54b508354ca01 100644 (file)
@@ -51,9 +51,8 @@
  * \param stride  stride between elements, in elements
  * \param normalized  are integer types converted to floats in [-1, 1]?
  * \param ptr  the address (or offset inside VBO) of the array data
- * \return GL_TRUE if no error, GL_FALSE if error
  */
-static GLboolean
+static void
 update_array(GLcontext *ctx, struct gl_client_array *array,
              GLbitfield dirtyBit, GLsizei elementSize,
              GLint size, GLenum type, GLenum format,
@@ -68,7 +67,7 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
        */
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "glVertex/Normal/EtcPointer(non-VBO array)");
-      return GL_FALSE;
+      return;
    }
 
    array->Size = size;
@@ -85,8 +84,6 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
 
    ctx->NewState |= _NEW_ARRAY;
    ctx->Array.NewState |= dirtyBit;
-
-   return GL_TRUE;
 }
 
 
@@ -124,6 +121,9 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
       case GL_DOUBLE:
          elementSize = size * sizeof(GLdouble);
          break;
+      case GL_HALF_FLOAT:
+         elementSize = size * sizeof(GLhalfARB);
+         break;
 #if FEATURE_fixedpt
       case GL_FIXED:
          elementSize = size * sizeof(GLfixed);
@@ -135,16 +135,13 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
          break;
 #endif
       default:
-         _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type)" );
+         _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type=%s)",
+                      _mesa_lookup_enum_by_nr(type));
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX,
-                     elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr))
-      return;
-
-   if (ctx->Driver.VertexPointer)
-      ctx->Driver.VertexPointer( ctx, size, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX,
+                elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr);
 }
 
 
@@ -180,22 +177,22 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
       case GL_DOUBLE:
          elementSize = 3 * sizeof(GLdouble);
          break;
+      case GL_HALF_FLOAT:
+         elementSize = 3 * sizeof(GLhalfARB);
+         break;
 #if FEATURE_fixedpt
       case GL_FIXED:
          elementSize = 3 * sizeof(GLfixed);
          break;
 #endif
       default:
-         _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" );
+         _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type=%s)",
+                      _mesa_lookup_enum_by_nr(type));
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL,
-                     elementSize, 3, type, GL_RGBA, stride, GL_TRUE, ptr))
-      return;
-
-   if (ctx->Driver.NormalPointer)
-      ctx->Driver.NormalPointer( ctx, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL,
+                elementSize, 3, type, GL_RGBA, stride, GL_TRUE, ptr);
 }
 
 
@@ -259,22 +256,22 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
       case GL_DOUBLE:
          elementSize = size * sizeof(GLdouble);
          break;
+      case GL_HALF_FLOAT:
+         elementSize = size * sizeof(GLhalfARB);
+         break;
 #if FEATURE_fixedpt
       case GL_FIXED:
          elementSize = size * sizeof(GLfixed);
          break;
 #endif
       default:
-         _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" );
+         _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type=%s)",
+                      _mesa_lookup_enum_by_nr(type));
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0,
-                     elementSize, size, type, format, stride, GL_TRUE, ptr))
-      return;
-
-   if (ctx->Driver.ColorPointer)
-      ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0,
+                elementSize, size, type, format, stride, GL_TRUE, ptr);
 }
 
 
@@ -297,17 +294,16 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
       case GL_DOUBLE:
          elementSize = sizeof(GLdouble);
          break;
+      case GL_HALF_FLOAT:
+         elementSize = sizeof(GLhalfARB);
+         break;
       default:
          _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" );
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD,
-                     elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr))
-      return;
-
-   if (ctx->Driver.FogCoordPointer)
-      ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD,
+                elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr);
 }
 
 
@@ -344,12 +340,8 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX,
-                     elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr))
-      return;
-
-   if (ctx->Driver.IndexPointer)
-      ctx->Driver.IndexPointer( ctx, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX,
+                elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr);
 }
 
 
@@ -414,18 +406,17 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
       case GL_DOUBLE:
          elementSize = size * sizeof(GLdouble);
          break;
+      case GL_HALF_FLOAT:
+         elementSize = size * sizeof(GLhalfARB);
+         break;
       default:
-         _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type)" );
+         _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type=%s)",
+                      _mesa_lookup_enum_by_nr(type));
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor,
-                     _NEW_ARRAY_COLOR1, elementSize, size, type,
-                     format, stride, GL_TRUE, ptr))
-      return;
-
-   if (ctx->Driver.SecondaryColorPointer)
-      ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1,
+                elementSize, size, type, format, stride, GL_TRUE, ptr);
 }
 
 
@@ -465,6 +456,9 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
       case GL_DOUBLE:
          elementSize = size * sizeof(GLdouble);
          break;
+      case GL_HALF_FLOAT:
+         elementSize = size * sizeof(GLhalfARB);
+         break;
 #if FEATURE_fixedpt
       case GL_FIXED:
          elementSize = size * sizeof(GLfixed);
@@ -476,17 +470,14 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
          break;
 #endif
       default:
-         _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" );
+         _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type=%s)",
+                      _mesa_lookup_enum_by_nr(type));
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit],
-                     _NEW_ARRAY_TEXCOORD(unit),
-                     elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr))
-      return;
-
-   if (ctx->Driver.TexCoordPointer)
-      ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit],
+                _NEW_ARRAY_TEXCOORD(unit),
+                elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr);
 }
 
 
@@ -501,13 +492,9 @@ _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
       return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG,
-                     sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, GL_RGBA,
-                     stride, GL_FALSE, ptr))
-      return;
-
-   if (ctx->Driver.EdgeFlagPointer)
-      ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG,
+                sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, GL_RGBA,
+                stride, GL_FALSE, ptr);
 }
 
 
@@ -610,17 +597,14 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
          elementSize = size * sizeof(GLdouble);
          break;
       default:
-         _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type)" );
+         _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type=%s)",
+                      _mesa_lookup_enum_by_nr(type));
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
-                     _NEW_ARRAY_ATTRIB(index),
-                     elementSize, size, type, format, stride, normalized, ptr))
-      return;
-
-   if (ctx->Driver.VertexAttribPointer)
-      ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
+   update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
+                _NEW_ARRAY_ATTRIB(index),
+                elementSize, size, type, format, stride, normalized, ptr);
 }
 #endif
 
@@ -704,6 +688,9 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
       case GL_DOUBLE:
          elementSize = size * sizeof(GLdouble);
          break;
+      case GL_HALF_FLOAT:
+         elementSize = size * sizeof(GLhalfARB);
+         break;
 #if FEATURE_fixedpt
       case GL_FIXED:
          elementSize = size * sizeof(GLfixed);
@@ -714,13 +701,9 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
          return;
    }
 
-   if (!update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
-                     _NEW_ARRAY_ATTRIB(index),
-                     elementSize, size, type, format, stride, normalized, ptr))
-      return;
-
-   if (ctx->Driver.VertexAttribPointer)
-      ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr);
+   update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
+                _NEW_ARRAY_ATTRIB(index),
+                elementSize, size, type, format, stride, normalized, ptr);
 }
 #endif
 
@@ -983,9 +966,6 @@ _mesa_LockArraysEXT(GLint first, GLsizei count)
 
    ctx->NewState |= _NEW_ARRAY;
    ctx->Array.NewState |= _NEW_ARRAY_ALL;
-
-   if (ctx->Driver.LockArraysEXT)
-      ctx->Driver.LockArraysEXT( ctx, first, count );
 }
 
 
@@ -1007,9 +987,6 @@ _mesa_UnlockArraysEXT( void )
    ctx->Array.LockCount = 0;
    ctx->NewState |= _NEW_ARRAY;
    ctx->Array.NewState |= _NEW_ARRAY_ALL;
-
-   if (ctx->Driver.UnlockArraysEXT)
-      ctx->Driver.UnlockArraysEXT( ctx );
 }
 
 
@@ -1032,24 +1009,6 @@ _mesa_MultiDrawArraysEXT( GLenum mode, GLint *first,
 }
 
 
-/* GL_EXT_multi_draw_arrays */
-void GLAPIENTRY
-_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
-                            const GLvoid **indices, GLsizei primcount )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   GLint i;
-
-   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
-   for (i = 0; i < primcount; i++) {
-      if (count[i] > 0) {
-         CALL_DrawElements(ctx->Exec, (mode, count[i], type, indices[i]));
-      }
-   }
-}
-
-
 /* GL_IBM_multimode_draw_arrays */
 void GLAPIENTRY
 _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
@@ -1092,6 +1051,29 @@ _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
 }
 
 
+/**
+ * Copy one client vertex array to another.
+ */
+void
+_mesa_copy_client_array(GLcontext *ctx,
+                        struct gl_client_array *dst,
+                        struct gl_client_array *src)
+{
+   dst->Size = src->Size;
+   dst->Type = src->Type;
+   dst->Format = src->Format;
+   dst->Stride = src->Stride;
+   dst->StrideB = src->StrideB;
+   dst->Ptr = src->Ptr;
+   dst->Enabled = src->Enabled;
+   dst->Normalized = src->Normalized;
+   dst->_ElementSize = src->_ElementSize;
+   _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
+   dst->_MaxElement = src->_MaxElement;
+}
+
+
+
 /**
  * Print vertex array's fields.
  */