17117f1b4Smrg/* 27117f1b4Smrg * Mesa 3-D graphics library 37117f1b4Smrg * 4c1f859d4Smrg * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 57117f1b4Smrg * 67117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 77117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 87117f1b4Smrg * to deal in the Software without restriction, including without limitation 97117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 107117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 117117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 127117f1b4Smrg * 137117f1b4Smrg * The above copyright notice and this permission notice shall be included 147117f1b4Smrg * in all copies or substantial portions of the Software. 157117f1b4Smrg * 167117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 177117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 187117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 237117f1b4Smrg */ 247117f1b4Smrg 257117f1b4Smrg/* 267117f1b4Smrg * New (3.1) transformation code written by Keith Whitwell. 277117f1b4Smrg */ 287117f1b4Smrg 297117f1b4Smrg 307117f1b4Smrg#ifndef _M_VECTOR_H_ 317117f1b4Smrg#define _M_VECTOR_H_ 327117f1b4Smrg 33c1f859d4Smrg#include "main/glheader.h" 347ec681f3Smrg#define MATH_ASM_PTR_SIZE sizeof(void *) 357ec681f3Smrg#include "math/m_vector_asm.h" 367117f1b4Smrg 377117f1b4Smrg#define VEC_MALLOC 0x10 /* storage field points to self-allocated mem*/ 387117f1b4Smrg#define VEC_NOT_WRITEABLE 0x40 /* writable elements to hold clipped data */ 397117f1b4Smrg#define VEC_BAD_STRIDE 0x100 /* matches tnl's prefered stride */ 407117f1b4Smrg 417117f1b4Smrg 427117f1b4Smrg 437117f1b4Smrg 447117f1b4Smrg 454a49301eSmrg/** 464a49301eSmrg * Wrap all the information about vectors up in a struct. Has 4701e04c3fSmrg * additional fields compared to the other vectors to help us track 487117f1b4Smrg * different vertex sizes, and whether we need to clean columns out 497117f1b4Smrg * because they contain non-(0,0,0,1) values. 507117f1b4Smrg * 517117f1b4Smrg * The start field is used to reserve data for copied vertices at the 527117f1b4Smrg * end of _mesa_transform_vb, and avoids the need for a multiplication in 537117f1b4Smrg * the transformation routines. 547117f1b4Smrg */ 557117f1b4Smrgtypedef struct { 564a49301eSmrg GLfloat (*data)[4]; /**< may be malloc'd or point to client data */ 5701e04c3fSmrg GLfloat *start; /**< points somewhere inside of GLvector4f::data */ 584a49301eSmrg GLuint count; /**< size of the vector (in elements) */ 594a49301eSmrg GLuint stride; /**< stride from one element to the next (in bytes) */ 604a49301eSmrg GLuint size; /**< 2-4 for vertices and 1-4 for texcoords */ 614a49301eSmrg GLbitfield flags; /**< bitmask of VEC_x flags */ 624a49301eSmrg void *storage; /**< self-allocated storage */ 634a49301eSmrg GLuint storage_count; /**< storage size in elements */ 647117f1b4Smrg} GLvector4f; 657117f1b4Smrg 667117f1b4Smrg 674a49301eSmrgextern void _mesa_vector4f_init( GLvector4f *v, GLbitfield flags, 687117f1b4Smrg GLfloat (*storage)[4] ); 694a49301eSmrgextern void _mesa_vector4f_alloc( GLvector4f *v, GLbitfield flags, 707117f1b4Smrg GLuint count, GLuint alignment ); 717117f1b4Smrgextern void _mesa_vector4f_free( GLvector4f *v ); 724a49301eSmrgextern void _mesa_vector4f_print( const GLvector4f *v, const GLubyte *, GLboolean ); 737117f1b4Smrgextern void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint nr, GLuint elt ); 747117f1b4Smrg 757117f1b4Smrg 764a49301eSmrg/** 777117f1b4Smrg * Given vector <v>, return a pointer (cast to <type *> to the <i>-th element. 787117f1b4Smrg * 797117f1b4Smrg * End up doing a lot of slow imuls if not careful. 807117f1b4Smrg */ 817117f1b4Smrg#define VEC_ELT( v, type, i ) \ 827117f1b4Smrg ( (type *) ( ((GLbyte *) ((v)->data)) + (i) * (v)->stride) ) 837117f1b4Smrg 847117f1b4Smrg 857117f1b4Smrg#endif 86