added a cast
[mesa.git] / src / mesa / main / nvfragprog.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 5.1
4 *
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 */
24
25
26 /* Private fragment program types and constants only used by files
27 * related to fragment programs.
28 *
29 * XXX TO-DO: Rename this file "fragprog.h" since it's not NV-specific.
30 */
31
32
33 #ifndef NVFRAGPROG_H
34 #define NVFRAGPROG_H
35
36 #include "config.h"
37
38
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
52
53 #define FRAG_OUTPUT_COLR 0
54 #define FRAG_OUTPUT_COLH 1
55 #define FRAG_OUTPUT_DEPR 2
56
57
58 /* condition codes */
59 #define COND_GT 1 /* greater than zero */
60 #define COND_EQ 2 /* equal to zero */
61 #define COND_LT 3 /* less than zero */
62 #define COND_UN 4 /* unordered (NaN) */
63 #define COND_GE 5 /* greater then or equal to zero */
64 #define COND_LE 6 /* less then or equal to zero */
65 #define COND_NE 7 /* not equal to zero */
66 #define COND_TR 8 /* always true */
67 #define COND_FL 9 /* always false */
68
69
70 /* instruction precision */
71 #define FLOAT32 0x1
72 #define FLOAT16 0x2
73 #define FIXED12 0x4
74
75
76 /* Fragment program instruction opcodes */
77 enum fp_opcode {
78 FP_OPCODE_ABS = 1000, /* ARB_f_p only */
79 FP_OPCODE_ADD,
80 FP_OPCODE_CMP, /* ARB_f_p only */
81 FP_OPCODE_COS,
82 FP_OPCODE_DDX, /* NV_f_p only */
83 FP_OPCODE_DDY, /* NV_f_p only */
84 FP_OPCODE_DP3,
85 FP_OPCODE_DP4,
86 FP_OPCODE_DPH, /* ARB_f_p only */
87 FP_OPCODE_DST,
88 FP_OPCODE_EX2,
89 FP_OPCODE_FLR,
90 FP_OPCODE_FRC,
91 FP_OPCODE_KIL,
92 FP_OPCODE_LG2,
93 FP_OPCODE_LIT,
94 FP_OPCODE_LRP,
95 FP_OPCODE_MAD,
96 FP_OPCODE_MAX,
97 FP_OPCODE_MIN,
98 FP_OPCODE_MOV,
99 FP_OPCODE_MUL,
100 FP_OPCODE_PK2H, /* NV_f_p only */
101 FP_OPCODE_PK2US, /* NV_f_p only */
102 FP_OPCODE_PK4B, /* NV_f_p only */
103 FP_OPCODE_PK4UB, /* NV_f_p only */
104 FP_OPCODE_POW,
105 FP_OPCODE_RCP,
106 FP_OPCODE_RFL, /* NV_f_p only */
107 FP_OPCODE_RSQ,
108 FP_OPCODE_SCS, /* ARB_f_p only */
109 FP_OPCODE_SEQ, /* NV_f_p only */
110 FP_OPCODE_SFL, /* NV_f_p only */
111 FP_OPCODE_SGE, /* NV_f_p only */
112 FP_OPCODE_SGT, /* NV_f_p only */
113 FP_OPCODE_SIN,
114 FP_OPCODE_SLE, /* NV_f_p only */
115 FP_OPCODE_SLT,
116 FP_OPCODE_SNE, /* NV_f_p only */
117 FP_OPCODE_STR, /* NV_f_p only */
118 FP_OPCODE_SUB,
119 FP_OPCODE_SWZ, /* ARB_f_p only */
120 FP_OPCODE_TEX,
121 FP_OPCODE_TXB, /* ARB_f_p only */
122 FP_OPCODE_TXD, /* NV_f_p only */
123 FP_OPCODE_TXP,
124 FP_OPCODE_UP2H, /* NV_f_p only */
125 FP_OPCODE_UP2US, /* NV_f_p only */
126 FP_OPCODE_UP4B, /* NV_f_p only */
127 FP_OPCODE_UP4UB, /* NV_f_p only */
128 FP_OPCODE_X2D, /* XPD in ARB_f_p */
129 FP_OPCODE_END /* private opcode */
130 };
131
132
133 /* Instruction source register */
134 struct fp_src_register
135 {
136 enum register_file File;
137 GLint Index;
138 GLuint Swizzle[4];
139 GLboolean NegateBase; /* negate before absolute value? */
140 GLboolean Abs; /* take absolute value? */
141 GLboolean NegateAbs; /* negate after absolute value? */
142 };
143
144
145 /* Instruction destination register */
146 struct fp_dst_register
147 {
148 enum register_file File;
149 GLint Index;
150 GLboolean WriteMask[4];
151 GLuint CondMask;
152 GLuint CondSwizzle[4];
153 };
154
155
156 /* Fragment program instruction */
157 struct fp_instruction
158 {
159 enum fp_opcode Opcode;
160 struct fp_src_register SrcReg[3];
161 struct fp_dst_register DstReg;
162 GLboolean Saturate;
163 GLboolean UpdateCondRegister;
164 GLubyte Precision; /* FLOAT32, FLOAT16 or FIXED12 */
165 GLubyte TexSrcUnit; /* texture unit for TEX, TXD, TXP instructions */
166 GLubyte TexSrcBit; /* TEXTURE_1D,2D,3D,CUBE,RECT_BIT source target */
167 #if FEATURE_MESA_program_debug
168 GLint StringPos;
169 #endif
170 };
171
172
173 #endif