1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Mesa 3-D graphics library
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
12bf215546Sopenharmony_ci *
13bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included
14bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
15bf215546Sopenharmony_ci *
16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci/*
26bf215546Sopenharmony_ci * New (3.1) transformation code written by Keith Whitwell.
27bf215546Sopenharmony_ci */
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci#ifndef _M_VECTOR_H_
31bf215546Sopenharmony_ci#define _M_VECTOR_H_
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#include "main/glheader.h"
34bf215546Sopenharmony_ci#define MATH_ASM_PTR_SIZE sizeof(void *)
35bf215546Sopenharmony_ci#include "math/m_vector_asm.h"
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_ci#define VEC_MALLOC         0x10 /* storage field points to self-allocated mem*/
38bf215546Sopenharmony_ci#define VEC_NOT_WRITEABLE  0x40	/* writable elements to hold clipped data */
39bf215546Sopenharmony_ci#define VEC_BAD_STRIDE     0x100 /* matches tnl's prefered stride */
40bf215546Sopenharmony_ci
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci/**
46bf215546Sopenharmony_ci * Wrap all the information about vectors up in a struct.  Has
47bf215546Sopenharmony_ci * additional fields compared to the other vectors to help us track
48bf215546Sopenharmony_ci * different vertex sizes, and whether we need to clean columns out
49bf215546Sopenharmony_ci * because they contain non-(0,0,0,1) values.
50bf215546Sopenharmony_ci *
51bf215546Sopenharmony_ci * The start field is used to reserve data for copied vertices at the
52bf215546Sopenharmony_ci * end of _mesa_transform_vb, and avoids the need for a multiplication in
53bf215546Sopenharmony_ci * the transformation routines.
54bf215546Sopenharmony_ci */
55bf215546Sopenharmony_citypedef struct {
56bf215546Sopenharmony_ci   GLfloat (*data)[4];	/**< may be malloc'd or point to client data */
57bf215546Sopenharmony_ci   GLfloat *start;	/**< points somewhere inside of GLvector4f::data */
58bf215546Sopenharmony_ci   GLuint count;	/**< size of the vector (in elements) */
59bf215546Sopenharmony_ci   GLuint stride;	/**< stride from one element to the next (in bytes) */
60bf215546Sopenharmony_ci   GLuint size;		/**< 2-4 for vertices and 1-4 for texcoords */
61bf215546Sopenharmony_ci   GLbitfield flags;	/**< bitmask of VEC_x flags */
62bf215546Sopenharmony_ci   void *storage;	/**< self-allocated storage */
63bf215546Sopenharmony_ci   GLuint storage_count; /**< storage size in elements */
64bf215546Sopenharmony_ci} GLvector4f;
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ciextern void _mesa_vector4f_init( GLvector4f *v, GLbitfield flags,
68bf215546Sopenharmony_ci			      GLfloat (*storage)[4] );
69bf215546Sopenharmony_ciextern void _mesa_vector4f_alloc( GLvector4f *v, GLbitfield flags,
70bf215546Sopenharmony_ci			       GLuint count, GLuint alignment );
71bf215546Sopenharmony_ciextern void _mesa_vector4f_free( GLvector4f *v );
72bf215546Sopenharmony_ciextern void _mesa_vector4f_print( const GLvector4f *v, const GLubyte *, GLboolean );
73bf215546Sopenharmony_ciextern void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint nr, GLuint elt );
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci/**
77bf215546Sopenharmony_ci * Given vector <v>, return a pointer (cast to <type *> to the <i>-th element.
78bf215546Sopenharmony_ci *
79bf215546Sopenharmony_ci * End up doing a lot of slow imuls if not careful.
80bf215546Sopenharmony_ci */
81bf215546Sopenharmony_ci#define VEC_ELT( v, type, i ) \
82bf215546Sopenharmony_ci       ( (type *)  ( ((GLbyte *) ((v)->data)) + (i) * (v)->stride) )
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_ci
85bf215546Sopenharmony_ci#endif
86