summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-05-25 21:42:13 -0600
committerBrian Paul <brianp@vmware.com>2010-05-25 21:42:13 -0600
commitd3f598a506d911e7cbbe561a798d284a154da3cd (patch)
treebe072e258a2960585d13a0d3a7f369bfcc648445
parenta830eef8c28370dc28f6df22d831ff2f22055d48 (diff)
mesa: move all vertex array functions into varray.c
-rw-r--r--src/mesa/main/varray.c242
-rw-r--r--src/mesa/main/varray.h32
-rw-r--r--src/mesa/shader/arbprogram.c241
-rw-r--r--src/mesa/shader/arbprogram.h32
4 files changed, 274 insertions, 273 deletions
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 853ec17772..da374acb5c 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -31,6 +31,7 @@
#include "enable.h"
#include "enums.h"
#include "hash.h"
+#include "macros.h"
#include "mtypes.h"
#include "varray.h"
#include "arrayobj.h"
@@ -730,6 +731,247 @@ _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
void GLAPIENTRY
+_mesa_EnableVertexAttribArrayARB(GLuint index)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glEnableVertexAttribArrayARB(index)");
+ return;
+ }
+
+ ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_TRUE;
+ ctx->Array.ArrayObj->_Enabled |= _NEW_ARRAY_ATTRIB(index);
+ ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
+}
+
+
+void GLAPIENTRY
+_mesa_DisableVertexAttribArrayARB(GLuint index)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glEnableVertexAttribArrayARB(index)");
+ return;
+ }
+
+ ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_FALSE;
+ ctx->Array.ArrayObj->_Enabled &= ~_NEW_ARRAY_ATTRIB(index);
+ ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
+}
+
+
+/**
+ * Return info for a vertex attribute array (no alias with legacy
+ * vertex attributes (pos, normal, color, etc)). This function does
+ * not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query.
+ */
+static GLuint
+get_vertex_array_attrib(GLcontext *ctx, GLuint index, GLenum pname,
+ const char *caller)
+{
+ const struct gl_client_array *array;
+
+ if (index >= MAX_VERTEX_GENERIC_ATTRIBS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", caller, index);
+ return 0;
+ }
+
+ ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
+ array = &ctx->Array.ArrayObj->VertexAttrib[index];
+
+ switch (pname) {
+ case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
+ return array->Enabled;
+ case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
+ return array->Size;
+ case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
+ return array->Stride;
+ case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
+ return array->Type;
+ case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB:
+ return array->Normalized;
+ case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
+ return array->BufferObj->Name;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", caller, pname);
+ return 0;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
+ if (index == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexAttribfv(index==0)");
+ }
+ else {
+ const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
+ FLUSH_CURRENT(ctx, 0);
+ COPY_4V(params, v);
+ }
+ }
+ else {
+ params[0] = (GLfloat) get_vertex_array_attrib(ctx, index, pname,
+ "glGetVertexAttribfv");
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
+ if (index == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexAttribdv(index==0)");
+ }
+ else {
+ const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = (GLdouble) v[0];
+ params[1] = (GLdouble) v[1];
+ params[2] = (GLdouble) v[2];
+ params[3] = (GLdouble) v[3];
+ }
+ }
+ else {
+ params[0] = (GLdouble) get_vertex_array_attrib(ctx, index, pname,
+ "glGetVertexAttribdv");
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
+ if (index == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexAttribiv(index==0)");
+ }
+ else {
+ const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
+ FLUSH_CURRENT(ctx, 0);
+ /* XXX should floats in[0,1] be scaled to full int range? */
+ params[0] = (GLint) v[0];
+ params[1] = (GLint) v[1];
+ params[2] = (GLint) v[2];
+ params[3] = (GLint) v[3];
+ }
+ }
+ else {
+ params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname,
+ "glGetVertexAttribiv");
+ }
+}
+
+
+/** GL 3.0 */
+void GLAPIENTRY
+_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
+ if (index == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexAttribIiv(index==0)");
+ }
+ else {
+ const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
+ FLUSH_CURRENT(ctx, 0);
+ /* XXX we don't have true integer-valued vertex attribs yet */
+ params[0] = (GLint) v[0];
+ params[1] = (GLint) v[1];
+ params[2] = (GLint) v[2];
+ params[3] = (GLint) v[3];
+ }
+ }
+ else {
+ params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname,
+ "glGetVertexAttribIiv");
+ }
+}
+
+
+/** GL 3.0 */
+void GLAPIENTRY
+_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
+ if (index == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexAttribIuiv(index==0)");
+ }
+ else {
+ const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
+ FLUSH_CURRENT(ctx, 0);
+ /* XXX we don't have true integer-valued vertex attribs yet */
+ params[0] = (GLuint) v[0];
+ params[1] = (GLuint) v[1];
+ params[2] = (GLuint) v[2];
+ params[3] = (GLuint) v[3];
+ }
+ }
+ else {
+ params[0] = get_vertex_array_attrib(ctx, index, pname,
+ "glGetVertexAttribIuiv");
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)");
+ return;
+ }
+
+ if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerARB(pname)");
+ return;
+ }
+
+ ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
+ *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr;
+}
+
+
+void GLAPIENTRY
_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
GLsizei count, const GLvoid *ptr)
{
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 66122b7630..26889f5ad4 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -123,6 +123,38 @@ _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
extern void GLAPIENTRY
+_mesa_EnableVertexAttribArrayARB(GLuint index);
+
+
+extern void GLAPIENTRY
+_mesa_DisableVertexAttribArrayARB(GLuint index);
+
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer);
+
+
+extern void GLAPIENTRY
_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c
index 76a673b634..8c0b94488e 100644
--- a/src/mesa/shader/arbprogram.c
+++ b/src/mesa/shader/arbprogram.c
@@ -245,247 +245,6 @@ _mesa_GenPrograms(GLsizei n, GLuint *ids)
}
-void GLAPIENTRY
-_mesa_EnableVertexAttribArrayARB(GLuint index)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glEnableVertexAttribArrayARB(index)");
- return;
- }
-
- ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
-
- FLUSH_VERTICES(ctx, _NEW_ARRAY);
- ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_TRUE;
- ctx->Array.ArrayObj->_Enabled |= _NEW_ARRAY_ATTRIB(index);
- ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
-}
-
-
-void GLAPIENTRY
-_mesa_DisableVertexAttribArrayARB(GLuint index)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glEnableVertexAttribArrayARB(index)");
- return;
- }
-
- ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
-
- FLUSH_VERTICES(ctx, _NEW_ARRAY);
- ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_FALSE;
- ctx->Array.ArrayObj->_Enabled &= ~_NEW_ARRAY_ATTRIB(index);
- ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
-}
-
-
-/**
- * Return info for a vertex attribute array (no alias with legacy
- * vertex attributes (pos, normal, color, etc)). This function does
- * not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query.
- */
-static GLuint
-get_vertex_array_attrib(GLcontext *ctx, GLuint index, GLenum pname,
- const char *caller)
-{
- const struct gl_client_array *array;
-
- if (index >= MAX_VERTEX_GENERIC_ATTRIBS) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", caller, index);
- return 0;
- }
-
- ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
-
- array = &ctx->Array.ArrayObj->VertexAttrib[index];
-
- switch (pname) {
- case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
- return array->Enabled;
- case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
- return array->Size;
- case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
- return array->Stride;
- case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
- return array->Type;
- case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB:
- return array->Normalized;
- case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
- return array->BufferObj->Name;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", caller, pname);
- return 0;
- }
-}
-
-
-void GLAPIENTRY
-_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
- if (index == 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetVertexAttribfv(index==0)");
- }
- else {
- const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
- FLUSH_CURRENT(ctx, 0);
- COPY_4V(params, v);
- }
- }
- else {
- params[0] = (GLfloat) get_vertex_array_attrib(ctx, index, pname,
- "glGetVertexAttribfv");
- }
-}
-
-
-void GLAPIENTRY
-_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
- if (index == 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetVertexAttribdv(index==0)");
- }
- else {
- const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
- FLUSH_CURRENT(ctx, 0);
- params[0] = (GLdouble) v[0];
- params[1] = (GLdouble) v[1];
- params[2] = (GLdouble) v[2];
- params[3] = (GLdouble) v[3];
- }
- }
- else {
- params[0] = (GLdouble) get_vertex_array_attrib(ctx, index, pname,
- "glGetVertexAttribdv");
- }
-}
-
-
-void GLAPIENTRY
-_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
- if (index == 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetVertexAttribiv(index==0)");
- }
- else {
- const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
- FLUSH_CURRENT(ctx, 0);
- /* XXX should floats in[0,1] be scaled to full int range? */
- params[0] = (GLint) v[0];
- params[1] = (GLint) v[1];
- params[2] = (GLint) v[2];
- params[3] = (GLint) v[3];
- }
- }
- else {
- params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname,
- "glGetVertexAttribiv");
- }
-}
-
-
-/** GL 3.0 */
-void GLAPIENTRY
-_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
- if (index == 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetVertexAttribIiv(index==0)");
- }
- else {
- const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
- FLUSH_CURRENT(ctx, 0);
- /* XXX we don't have true integer-valued vertex attribs yet */
- params[0] = (GLint) v[0];
- params[1] = (GLint) v[1];
- params[2] = (GLint) v[2];
- params[3] = (GLint) v[3];
- }
- }
- else {
- params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname,
- "glGetVertexAttribIiv");
- }
-}
-
-
-/** GL 3.0 */
-void GLAPIENTRY
-_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
- if (index == 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetVertexAttribIuiv(index==0)");
- }
- else {
- const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
- FLUSH_CURRENT(ctx, 0);
- /* XXX we don't have true integer-valued vertex attribs yet */
- params[0] = (GLuint) v[0];
- params[1] = (GLuint) v[1];
- params[2] = (GLuint) v[2];
- params[3] = (GLuint) v[3];
- }
- }
- else {
- params[0] = get_vertex_array_attrib(ctx, index, pname,
- "glGetVertexAttribIuiv");
- }
-}
-
-
-void GLAPIENTRY
-_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)");
- return;
- }
-
- if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerARB(pname)");
- return;
- }
-
- ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
-
- *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr;
-}
-
-
/**
* Determine if id names a vertex or fragment program.
* \note Not compiled into display lists.
diff --git a/src/mesa/shader/arbprogram.h b/src/mesa/shader/arbprogram.h
index d7f553c08e..df16513e39 100644
--- a/src/mesa/shader/arbprogram.h
+++ b/src/mesa/shader/arbprogram.h
@@ -37,38 +37,6 @@ extern void GLAPIENTRY
_mesa_GenPrograms(GLsizei n, GLuint *ids);
-extern void GLAPIENTRY
-_mesa_EnableVertexAttribArrayARB(GLuint index);
-
-
-extern void GLAPIENTRY
-_mesa_DisableVertexAttribArrayARB(GLuint index);
-
-
-extern void GLAPIENTRY
-_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params);
-
-
-extern void GLAPIENTRY
-_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params);
-
-
-extern void GLAPIENTRY
-_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params);
-
-
-extern void GLAPIENTRY
-_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params);
-
-
-extern void GLAPIENTRY
-_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params);
-
-
-extern void GLAPIENTRY
-_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer);
-
-
extern GLboolean GLAPIENTRY
_mesa_IsProgramARB(GLuint id);