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.
27 * \file prog_instruction.h
29 * Private vertex program types and constants only used by files
30 * related to vertex programs.
33 * \author Keith Whitwell
34 * \author Ian Romanick <idr@us.ibm.com>
38 #ifndef PROG_INSTRUCTION_H
39 #define PROG_INSTRUCTION_H
42 * Condition codes for GL_NV_fragment_program
45 #define COND_GT 1 /* greater than zero */
46 #define COND_EQ 2 /* equal to zero */
47 #define COND_LT 3 /* less than zero */
48 #define COND_UN 4 /* unordered (NaN) */
49 #define COND_GE 5 /* greater then or equal to zero */
50 #define COND_LE 6 /* less then or equal to zero */
51 #define COND_NE 7 /* not equal to zero */
52 #define COND_TR 8 /* always true */
53 #define COND_FL 9 /* always false */
58 * Instruction precision for GL_NV_fragment_program
68 * Saturation modes when storing values.
71 #define SATURATE_OFF 0
72 #define SATURATE_ZERO_ONE 1
73 #define SATURATE_PLUS_MINUS_ONE 2
78 * Per-component negation masks
85 #define NEGATE_XYZW 0xf
86 #define NEGATE_NONE 0x0
91 * Program instruction opcodes, for both vertex and fragment programs.
92 * \note changes to this opcode list must be reflected in t_vb_arbprogram.c
94 typedef enum prog_opcode
{
95 /* ARB_vp ARB_fp NV_vp NV_fp */
96 /*---------------------------------*/
98 OPCODE_ABS
, /* X X 1.1 */
99 OPCODE_ADD
, /* X X X X */
101 OPCODE_ARL
, /* X X */
102 OPCODE_ARL_NV
, /* 2 */
105 OPCODE_CAL
, /* 2 2 */
107 OPCODE_COS
, /* X 2 X */
110 OPCODE_DP3
, /* X X X X */
111 OPCODE_DP4
, /* X X X X */
112 OPCODE_DPH
, /* X X 1.1 */
113 OPCODE_DST
, /* X X X X */
114 OPCODE_END
, /* X X X X */
115 OPCODE_EX2
, /* X X 2 X */
116 OPCODE_EXP
, /* X X */
117 OPCODE_FLR
, /* X X 2 X */
118 OPCODE_FRC
, /* X X 2 X */
120 OPCODE_KIL_NV
, /* X */
121 OPCODE_LG2
, /* X X 2 X */
122 OPCODE_LIT
, /* X X X X */
123 OPCODE_LOG
, /* X X */
124 OPCODE_LRP
, /* X X */
125 OPCODE_MAD
, /* X X X X */
126 OPCODE_MAX
, /* X X X X */
127 OPCODE_MIN
, /* X X X X */
128 OPCODE_MOV
, /* X X X X */
129 OPCODE_MUL
, /* X X X X */
131 OPCODE_PK2US
, /* X */
133 OPCODE_PK4UB
, /* X */
134 OPCODE_POW
, /* X X X */
136 OPCODE_PRINT
, /* X X */
137 OPCODE_PUSHA
, /* 3 */
138 OPCODE_RCC
, /* 1.1 */
139 OPCODE_RCP
, /* X X X X */
140 OPCODE_RET
, /* 2 2 */
141 OPCODE_RFL
, /* X X */
142 OPCODE_RSQ
, /* X X X X */
144 OPCODE_SEQ
, /* 2 X */
145 OPCODE_SFL
, /* 2 X */
146 OPCODE_SGE
, /* X X X X */
147 OPCODE_SGT
, /* 2 X */
148 OPCODE_SIN
, /* X 2 X */
149 OPCODE_SLE
, /* 2 X */
150 OPCODE_SLT
, /* X X X X */
151 OPCODE_SNE
, /* 2 X */
153 OPCODE_STR
, /* 2 X */
154 OPCODE_SUB
, /* X X 1.1 X */
155 OPCODE_SWZ
, /* X X */
156 OPCODE_TEX
, /* X 3 X */
157 OPCODE_TXB
, /* X 3 */
159 OPCODE_TXL
, /* 3 2 */
161 OPCODE_TXP_NV
, /* 3 X */
163 OPCODE_UP2US
, /* X */
165 OPCODE_UP4UB
, /* X */
167 OPCODE_XPD
, /* X X */
173 * Instruction source register.
175 struct prog_src_register
177 GLuint File
:4; /**< One of the PROGRAM_* register file values. */
178 GLint Index
:9; /**< May be negative for relative addressing. */
183 * \name Source register "sign" control.
185 * The ARB and NV extensions allow varrying degrees of control over the
186 * sign of the source vector components. These values allow enough control
187 * for all flavors of the extensions.
191 * Per-component negation for the SWZ instruction. For non-SWZ
192 * instructions the only possible values are NEGATE_XYZW and NEGATE_NONE.
195 * ARB_vertex_program, ARB_fragment_program
200 * Take the component-wise absolute value.
203 * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
204 * NV_vertex_program2_option.
209 * Post-absolute value negation (all components).
217 * Instruction destination register.
219 struct prog_dst_register
222 * One of the PROGRAM_* register file values.
230 * \name Conditional destination update control.
233 * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
234 * NV_vertex_program2_option.
238 * Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT,
239 * NE, TR, or UN). Destination update is enabled if the matching
240 * (swizzled) condition code value passes. When a conditional update mask
241 * is not specified, this will be \c COND_TR.
246 * Condition code swizzle value.
248 GLuint CondSwizzle
:12;
251 * Selects the condition code register to use for conditional destination
252 * update masking. In NV_fragmnet_program or NV_vertex_program2 mode, only
253 * condition code register 0 is available. In NV_vertex_program3 mode,
254 * condition code registers 0 and 1 are available.
264 * Vertex/fragment program instruction.
266 struct prog_instruction
268 gl_inst_opcode Opcode
;
269 #if FEATURE_MESA_program_debug
273 * Arbitrary data. Used for the PRINT, CAL, and BRA instructions.
277 struct prog_src_register SrcReg
[3];
278 struct prog_dst_register DstReg
;
281 * Indicates that the instruction should update the condition code
285 * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
286 * NV_vertex_program2_option.
291 * If prog_instruction::CondUpdate is \c GL_TRUE, this value selects the
292 * condition code register that is to be updated.
294 * In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition
295 * code register 0 is available. In GL_NV_vertex_program3 mode, condition
296 * code registers 0 and 1 are available.
299 * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
300 * NV_vertex_program2_option.
305 * Saturate each value of the vectored result to the range [0,1] or the
306 * range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is
307 * only available in NV_fragment_program2 mode.
308 * Value is one of the SATURATE_* tokens.
311 * NV_fragment_program, NV_fragment_program_option, NV_vertex_program3.
313 GLuint SaturateMode
:2;
316 * Per-instruction selectable precision.
319 * NV_fragment_program, NV_fragment_program_option.
324 * \name Texture source controls.
326 * The texture source controls are only used with the \c TEX, \c TXD,
327 * \c TXL, and \c TXP instructions.
330 * ARB_fragment_program, NV_fragment_program, NV_vertex_program3.
334 * Source texture unit. OpenGL supports a maximum of 32 texture
340 * Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX.
342 GLuint TexSrcTarget
:3;
346 * For BRA and CAL instructions, the location to jump to.
355 _mesa_init_instructions(struct prog_instruction
*inst
, GLuint count
);
358 _mesa_num_inst_src_regs(gl_inst_opcode opcode
);
361 _mesa_opcode_string(gl_inst_opcode opcode
);
364 #endif /* PROG_INSTRUCTION_H */