2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2003 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.
26 /* Private fragment program types and constants only used by files
27 * related to fragment programs.
29 * XXX TO-DO: Rename this file "fragprog.h" since it's not NV-specific.
39 /* Fragment input registers / attributes */
40 #define FRAG_ATTRIB_WPOS 0
41 #define FRAG_ATTRIB_COL0 1
42 #define FRAG_ATTRIB_COL1 2
43 #define FRAG_ATTRIB_FOGC 3
44 #define FRAG_ATTRIB_TEX0 4
45 #define FRAG_ATTRIB_TEX1 5
46 #define FRAG_ATTRIB_TEX2 6
47 #define FRAG_ATTRIB_TEX3 7
48 #define FRAG_ATTRIB_TEX4 8
49 #define FRAG_ATTRIB_TEX5 9
50 #define FRAG_ATTRIB_TEX6 10
51 #define FRAG_ATTRIB_TEX7 11
53 /* Bitmasks for the above */
54 #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
55 #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
56 #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
57 #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
58 #define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
59 #define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
60 #define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
61 #define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
62 #define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
63 #define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
64 #define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
65 #define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
67 #define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
76 /* output registers */
77 #define FRAG_OUTPUT_COLR 0
78 #define FRAG_OUTPUT_COLH 1
79 #define FRAG_OUTPUT_DEPR 2
83 #define COND_GT 1 /* greater than zero */
84 #define COND_EQ 2 /* equal to zero */
85 #define COND_LT 3 /* less than zero */
86 #define COND_UN 4 /* unordered (NaN) */
87 #define COND_GE 5 /* greater then or equal to zero */
88 #define COND_LE 6 /* less then or equal to zero */
89 #define COND_NE 7 /* not equal to zero */
90 #define COND_TR 8 /* always true */
91 #define COND_FL 9 /* always false */
94 /* instruction precision */
100 /* Fragment program instruction opcodes */
102 FP_OPCODE_ABS
= 1000, /* ARB_f_p only */
104 FP_OPCODE_CMP
, /* ARB_f_p only */
106 FP_OPCODE_DDX
, /* NV_f_p only */
107 FP_OPCODE_DDY
, /* NV_f_p only */
110 FP_OPCODE_DPH
, /* ARB_f_p only */
124 FP_OPCODE_PK2H
, /* NV_f_p only */
125 FP_OPCODE_PK2US
, /* NV_f_p only */
126 FP_OPCODE_PK4B
, /* NV_f_p only */
127 FP_OPCODE_PK4UB
, /* NV_f_p only */
130 FP_OPCODE_RFL
, /* NV_f_p only */
132 FP_OPCODE_SCS
, /* ARB_f_p only */
133 FP_OPCODE_SEQ
, /* NV_f_p only */
134 FP_OPCODE_SFL
, /* NV_f_p only */
135 FP_OPCODE_SGE
, /* NV_f_p only */
136 FP_OPCODE_SGT
, /* NV_f_p only */
138 FP_OPCODE_SLE
, /* NV_f_p only */
140 FP_OPCODE_SNE
, /* NV_f_p only */
141 FP_OPCODE_STR
, /* NV_f_p only */
143 FP_OPCODE_SWZ
, /* ARB_f_p only */
145 FP_OPCODE_TXB
, /* ARB_f_p only */
146 FP_OPCODE_TXD
, /* NV_f_p only */
148 FP_OPCODE_UP2H
, /* NV_f_p only */
149 FP_OPCODE_UP2US
, /* NV_f_p only */
150 FP_OPCODE_UP4B
, /* NV_f_p only */
151 FP_OPCODE_UP4UB
, /* NV_f_p only */
152 FP_OPCODE_X2D
, /* XPD in ARB_f_p */
153 FP_OPCODE_END
/* private opcode */
157 /* Instruction source register */
158 struct fp_src_register
160 enum register_file File
;
163 GLboolean NegateBase
; /* negate before absolute value? */
164 GLboolean Abs
; /* take absolute value? */
165 GLboolean NegateAbs
; /* negate after absolute value? */
169 /* Instruction destination register */
170 struct fp_dst_register
172 enum register_file File
;
174 GLboolean WriteMask
[4];
176 GLuint CondSwizzle
[4];
180 /* Fragment program instruction */
181 struct fp_instruction
183 enum fp_opcode Opcode
;
184 struct fp_src_register SrcReg
[3];
185 struct fp_dst_register DstReg
;
187 GLboolean UpdateCondRegister
;
188 GLubyte Precision
; /* FLOAT32, FLOAT16 or FIXED12 */
189 GLubyte TexSrcUnit
; /* texture unit for TEX, TXD, TXP instructions */
190 GLubyte TexSrcBit
; /* TEXTURE_1D,2D,3D,CUBE,RECT_BIT source target */
191 #if FEATURE_MESA_program_debug