f4dae76de0df7c0d2d1f2ff32723944c5ce907b1
2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #include "prog_instruction.h"
33 * Initialize program instruction fields to defaults.
34 * \param inst first instruction to initialize
35 * \param count number of instructions to initialize
38 _mesa_init_instructions(struct prog_instruction
*inst
, GLuint count
)
42 _mesa_bzero(inst
, count
* sizeof(struct prog_instruction
));
44 for (i
= 0; i
< count
; i
++) {
45 inst
[i
].SrcReg
[0].File
= PROGRAM_UNDEFINED
;
46 inst
[i
].SrcReg
[0].Swizzle
= SWIZZLE_NOOP
;
47 inst
[i
].SrcReg
[1].File
= PROGRAM_UNDEFINED
;
48 inst
[i
].SrcReg
[1].Swizzle
= SWIZZLE_NOOP
;
49 inst
[i
].SrcReg
[2].File
= PROGRAM_UNDEFINED
;
50 inst
[i
].SrcReg
[2].Swizzle
= SWIZZLE_NOOP
;
52 inst
[i
].DstReg
.File
= PROGRAM_UNDEFINED
;
53 inst
[i
].DstReg
.WriteMask
= WRITEMASK_XYZW
;
54 inst
[i
].DstReg
.CondMask
= COND_TR
;
55 inst
[i
].DstReg
.CondSwizzle
= SWIZZLE_NOOP
;
57 inst
[i
].SaturateMode
= SATURATE_OFF
;
58 inst
[i
].Precision
= FLOAT32
;
64 * Allocate an array of program instructions.
65 * \param numInst number of instructions
66 * \return pointer to instruction memory
68 struct prog_instruction
*
69 _mesa_alloc_instructions(GLuint numInst
)
71 return (struct prog_instruction
*)
72 _mesa_calloc(numInst
* sizeof(struct prog_instruction
));
77 * Reallocate memory storing an array of program instructions.
78 * This is used when we need to append additional instructions onto an
80 * \param oldInst pointer to first of old/src instructions
81 * \param numOldInst number of instructions at <oldInst>
82 * \param numNewInst desired size of new instruction array.
83 * \return pointer to start of new instruction array.
85 struct prog_instruction
*
86 _mesa_realloc_instructions(struct prog_instruction
*oldInst
,
87 GLuint numOldInst
, GLuint numNewInst
)
89 struct prog_instruction
*newInst
;
91 newInst
= (struct prog_instruction
*)
92 _mesa_realloc(oldInst
,
93 numOldInst
* sizeof(struct prog_instruction
),
94 numNewInst
* sizeof(struct prog_instruction
));