1 /* $Id: t_imm_alloc.c,v 1.4 2001/03/07 05:06:13 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Keith Whitwell <keithw@valinux.com>
34 #include "t_imm_alloc.h"
39 struct immediate
*_tnl_alloc_immediate( GLcontext
*ctx
)
41 struct immediate
*IM
= ALIGN_MALLOC_STRUCT( immediate
, 32 );
51 IM
->LastPrimitive
= IMM_MAX_COPIED_VERTS
;
52 IM
->Count
= IMM_MAX_COPIED_VERTS
;
53 IM
->Start
= IMM_MAX_COPIED_VERTS
;
56 IM
->MaxTextureUnits
= ctx
->Const
.MaxTextureUnits
;
60 IM
->CopyStart
= IM
->Start
;
63 /* TexCoord0 is special.
65 IM
->TexCoord
[0] = IM
->TexCoord0
;
67 for (j
= 1; j
< ctx
->Const
.MaxTextureUnits
; j
++) {
68 IM
->TexCoord
[j
] = (GLfloat (*)[4])
69 ALIGN_MALLOC( IMM_SIZE
* sizeof(GLfloat
) * 4, 32 );
72 /* KW: Removed initialization of normals as these are now treated
73 * identically to all other data types.
76 MEMSET(IM
->Flag
, 0, sizeof(IM
->Flag
));
82 void _tnl_free_immediate( struct immediate
*IM
)
89 FREE( IM
->MaterialMask
);
94 for (j
= 1; j
< IM
->MaxTextureUnits
; j
++)
95 ALIGN_FREE( IM
->TexCoord
[j
] );
100 /* printf("outstanding %d\n", id - freed); */