summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-05-05 11:11:25 -0600
committerBrian Paul <brianp@vmware.com>2009-05-07 10:12:32 -0600
commit424507953ca9d41e0dbfcc0399f50315b5671776 (patch)
treeb7033d2e91ac11ff0307d82d95f3f22ae9e58973 /src
parent134ac52decf020e6ffb2da8d641cdb3cda9ac0f2 (diff)
mesa: reformatting, updated comments, const-correctness
Diffstat (limited to 'src')
-rw-r--r--src/mesa/math/m_vector.c84
-rw-r--r--src/mesa/math/m_vector.h25
2 files changed, 50 insertions, 59 deletions
diff --git a/src/mesa/math/m_vector.c b/src/mesa/math/m_vector.c
index c5e2fd1de1..dd631376d0 100644
--- a/src/mesa/math/m_vector.c
+++ b/src/mesa/math/m_vector.c
@@ -1,4 +1,3 @@
-
/*
* Mesa 3-D graphics library
* Version: 3.5
@@ -37,11 +36,12 @@
-/*
+/**
* Given a vector [count][4] of floats, set all the [][elt] values
* to 0 (if elt = 0, 1, 2) or 1.0 (if elt = 3).
*/
-void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint count, GLuint elt )
+void
+_mesa_vector4f_clean_elem( GLvector4f *vec, GLuint count, GLuint elt )
{
static const GLubyte elem_bits[4] = {
VEC_DIRTY_0,
@@ -54,12 +54,13 @@ void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint count, GLuint elt )
GLfloat (*data)[4] = (GLfloat (*)[4])vec->start;
GLuint i;
- for (i = 0 ; i < count ; i++)
+ for (i = 0; i < count; i++)
data[i][elt] = v;
vec->flags &= ~elem_bits[elt];
}
+
static const GLubyte size_bits[5] = {
0,
VEC_SIZE_1,
@@ -69,40 +70,34 @@ static const GLubyte size_bits[5] = {
};
-
-/*
+/**
* Initialize GLvector objects.
- * Input: v - the vector object to initialize.
- * flags - bitwise-OR of VEC_* flags
- * storage - pointer to storage for the vector's data
+ * \param v the vector object to initialize.
+ * \param flags bitwise-OR of VEC_* flags
+ * \param storage pointer to storage for the vector's data
*/
-
-
-void _mesa_vector4f_init( GLvector4f *v, GLuint flags, GLfloat (*storage)[4] )
+void
+_mesa_vector4f_init( GLvector4f *v, GLuint flags, GLfloat (*storage)[4] )
{
v->stride = 4 * sizeof(GLfloat);
v->size = 2; /* may change: 2-4 for vertices and 1-4 for texcoords */
v->data = storage;
v->start = (GLfloat *) storage;
v->count = 0;
- v->flags = size_bits[4] | flags ;
+ v->flags = size_bits[4] | flags;
}
-
-
-/*
+/**
* Initialize GLvector objects and allocate storage.
- * Input: v - the vector object
- * sz - unused????
- * flags - bitwise-OR of VEC_* flags
- * count - number of elements to allocate in vector
- * alignment - desired memory alignment for the data (in bytes)
+ * \param v the vector object
+ * \param flags bitwise-OR of VEC_* flags
+ * \param count number of elements to allocate in vector
+ * \param alignment desired memory alignment for the data (in bytes)
*/
-
-
-void _mesa_vector4f_alloc( GLvector4f *v, GLuint flags, GLuint count,
- GLuint alignment )
+void
+_mesa_vector4f_alloc( GLvector4f *v, GLuint flags, GLuint count,
+ GLuint alignment )
{
v->stride = 4 * sizeof(GLfloat);
v->size = 2;
@@ -110,20 +105,17 @@ void _mesa_vector4f_alloc( GLvector4f *v, GLuint flags, GLuint count,
v->start = (GLfloat *) v->storage;
v->data = (GLfloat (*)[4]) v->storage;
v->count = 0;
- v->flags = size_bits[4] | flags | VEC_MALLOC ;
+ v->flags = size_bits[4] | flags | VEC_MALLOC;
}
-
-
-/*
+/**
* Vector deallocation. Free whatever memory is pointed to by the
* vector's storage field if the VEC_MALLOC flag is set.
* DO NOT free the GLvector object itself, though.
*/
-
-
-void _mesa_vector4f_free( GLvector4f *v )
+void
+_mesa_vector4f_free( GLvector4f *v )
{
if (v->flags & VEC_MALLOC) {
ALIGN_FREE( v->storage );
@@ -135,13 +127,15 @@ void _mesa_vector4f_free( GLvector4f *v )
}
-/*
+/**
* For debugging
*/
-void _mesa_vector4f_print( GLvector4f *v, GLubyte *cullmask, GLboolean culling )
+void
+_mesa_vector4f_print( const GLvector4f *v, const GLubyte *cullmask,
+ GLboolean culling )
{
- GLfloat c[4] = { 0, 0, 0, 1 };
- const char *templates[5] = {
+ static const GLfloat c[4] = { 0, 0, 0, 1 };
+ static const char *templates[5] = {
"%d:\t0, 0, 0, 1\n",
"%d:\t%f, 0, 0, 1\n",
"%d:\t%f, %f, 0, 1\n",
@@ -154,30 +148,32 @@ void _mesa_vector4f_print( GLvector4f *v, GLubyte *cullmask, GLboolean culling )
GLuint j, i = 0, count;
_mesa_printf("data-start\n");
- for ( ; d != v->start ; STRIDE_F(d, v->stride), i++)
+ for (; d != v->start; STRIDE_F(d, v->stride), i++)
_mesa_printf(t, i, d[0], d[1], d[2], d[3]);
_mesa_printf("start-count(%u)\n", v->count);
count = i + v->count;
if (culling) {
- for ( ; i < count ; STRIDE_F(d, v->stride), i++)
+ for (; i < count; STRIDE_F(d, v->stride), i++)
if (cullmask[i])
_mesa_printf(t, i, d[0], d[1], d[2], d[3]);
}
else {
- for ( ; i < count ; STRIDE_F(d, v->stride), i++)
+ for (; i < count; STRIDE_F(d, v->stride), i++)
_mesa_printf(t, i, d[0], d[1], d[2], d[3]);
}
- for (j = v->size ; j < 4; j++) {
+ for (j = v->size; j < 4; j++) {
if ((v->flags & (1<<j)) == 0) {
_mesa_printf("checking col %u is clean as advertised ", j);
- for (i = 0, d = (GLfloat *) v->data ;
- i < count && d[j] == c[j] ;
- i++, STRIDE_F(d, v->stride)) {};
+ for (i = 0, d = (GLfloat *) v->data;
+ i < count && d[j] == c[j];
+ i++, STRIDE_F(d, v->stride)) {
+ /* no-op */
+ }
if (i == count)
_mesa_printf(" --> ok\n");
@@ -186,5 +182,3 @@ void _mesa_vector4f_print( GLvector4f *v, GLubyte *cullmask, GLboolean culling )
}
}
}
-
-
diff --git a/src/mesa/math/m_vector.h b/src/mesa/math/m_vector.h
index 647388ac7d..9112a2b5d5 100644
--- a/src/mesa/math/m_vector.h
+++ b/src/mesa/math/m_vector.h
@@ -31,7 +31,6 @@
#define _M_VECTOR_H_
#include "main/glheader.h"
-#include "main/mtypes.h" /* hack for GLchan */
#define VEC_DIRTY_0 0x1
@@ -50,7 +49,8 @@
-/* Wrap all the information about vectors up in a struct. Has
+/**
+ * Wrap all the information about vectors up in a struct. Has
* additional fields compared to the other vectors to help us track of
* different vertex sizes, and whether we need to clean columns out
* because they contain non-(0,0,0,1) values.
@@ -60,13 +60,13 @@
* the transformation routines.
*/
typedef struct {
- GLfloat (*data)[4]; /* may be malloc'd or point to client data */
- GLfloat *start; /* points somewhere inside of <data> */
- GLuint count; /* size of the vector (in elements) */
- GLuint stride; /* stride from one element to the next (in bytes) */
- GLuint size; /* 2-4 for vertices and 1-4 for texcoords */
- GLuint flags; /* which columns are dirty */
- void *storage; /* self-allocated storage */
+ GLfloat (*data)[4]; /**< may be malloc'd or point to client data */
+ GLfloat *start; /**< points somewhere inside of <data> */
+ GLuint count; /**< size of the vector (in elements) */
+ GLuint stride; /**< stride from one element to the next (in bytes) */
+ GLuint size; /**< 2-4 for vertices and 1-4 for texcoords */
+ GLuint flags; /**< which columns are dirty */
+ void *storage; /**< self-allocated storage */
} GLvector4f;
@@ -75,14 +75,11 @@ extern void _mesa_vector4f_init( GLvector4f *v, GLuint flags,
extern void _mesa_vector4f_alloc( GLvector4f *v, GLuint flags,
GLuint count, GLuint alignment );
extern void _mesa_vector4f_free( GLvector4f *v );
-extern void _mesa_vector4f_print( GLvector4f *v, GLubyte *, GLboolean );
+extern void _mesa_vector4f_print( const GLvector4f *v, const GLubyte *, GLboolean );
extern void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint nr, GLuint elt );
-
-
-
-/*
+/**
* Given vector <v>, return a pointer (cast to <type *> to the <i>-th element.
*
* End up doing a lot of slow imuls if not careful.