1 /* $Id: t_imm_alloc.c,v 1.2 2000/12/28 22:11:05 keithw 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 );
50 IM
->NormalLengths
= 0;
52 IM
->LastPrimitive
= IMM_MAX_COPIED_VERTS
;
53 IM
->Count
= IMM_MAX_COPIED_VERTS
;
54 IM
->Start
= IMM_MAX_COPIED_VERTS
;
57 IM
->MaxTextureUnits
= ctx
->Const
.MaxTextureUnits
;
61 IM
->CopyStart
= IM
->Start
;
64 /* TexCoord0 is special.
66 IM
->TexCoord
[0] = IM
->TexCoord0
;
68 for (j
= 1; j
< ctx
->Const
.MaxTextureUnits
; j
++)
69 IM
->TexCoord
[j
] = ALIGN_MALLOC( IMM_SIZE
* sizeof(GLfloat
) * 4, 32 );
71 /* KW: Removed initialization of normals as these are now treated
72 * identically to all other data types.
75 MEMSET(IM
->Flag
, 0, sizeof(IM
->Flag
));
81 void _tnl_free_immediate( struct immediate
*IM
)
86 if (IM
->NormalLengths
) {
87 FREE( IM
->NormalLengths
);
88 IM
->NormalLengths
= 0;
93 FREE( IM
->MaterialMask
);
98 for (j
= 1; j
< IM
->MaxTextureUnits
; j
++)
99 ALIGN_FREE( IM
->TexCoord
[j
] );
104 /* printf("outstanding %d\n", id - freed); */