Re-org of register files for vertex/fragment programs. Will be easier to
[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
30
31 #ifndef NVFRAGPROG_H
32 #define NVFRAGPROG_H
33
34 #include "config.h"
35
36
37 /* Fragment input registers / attributes */
38 #define FRAG_ATTRIB_WPOS 0
39 #define FRAG_ATTRIB_COL0 1
40 #define FRAG_ATTRIB_COL1 2
41 #define FRAG_ATTRIB_FOGC 3
42 #define FRAG_ATTRIB_TEX0 4
43 #define FRAG_ATTRIB_TEX1 5
44 #define FRAG_ATTRIB_TEX2 6
45 #define FRAG_ATTRIB_TEX3 7
46 #define FRAG_ATTRIB_TEX4 8
47 #define FRAG_ATTRIB_TEX5 9
48 #define FRAG_ATTRIB_TEX6 10
49 #define FRAG_ATTRIB_TEX7 11
50
51 #define FRAG_OUTPUT_COLR 0
52 #define FRAG_OUTPUT_COLH 1
53 #define FRAG_OUTPUT_DEPR 2
54
55
56 /* condition codes */
57 #define COND_GT 1 /* greater than zero */
58 #define COND_EQ 2 /* equal to zero */
59 #define COND_LT 3 /* less than zero */
60 #define COND_UN 4 /* unordered (NaN) */
61 #define COND_GE 5 /* greater then or equal to zero */
62 #define COND_LE 6 /* less then or equal to zero */
63 #define COND_NE 7 /* not equal to zero */
64 #define COND_TR 8 /* always true */
65 #define COND_FL 9 /* always false */
66
67
68 /* instruction precision */
69 #define FLOAT32 0x1
70 #define FLOAT16 0x2
71 #define FIXED12 0x4
72
73
74 /* Fragment program instruction opcodes */
75 enum fp_opcode {
76 FP_OPCODE_ADD = 1000,
77 FP_OPCODE_COS,
78 FP_OPCODE_DDX,
79 FP_OPCODE_DDY,
80 FP_OPCODE_DP3,
81 FP_OPCODE_DP4,
82 FP_OPCODE_DST,
83 FP_OPCODE_EX2,
84 FP_OPCODE_FLR,
85 FP_OPCODE_FRC,
86 FP_OPCODE_KIL,
87 FP_OPCODE_LG2,
88 FP_OPCODE_LIT,
89 FP_OPCODE_LRP,
90 FP_OPCODE_MAD,
91 FP_OPCODE_MAX,
92 FP_OPCODE_MIN,
93 FP_OPCODE_MOV,
94 FP_OPCODE_MUL,
95 FP_OPCODE_PK2H,
96 FP_OPCODE_PK2US,
97 FP_OPCODE_PK4B,
98 FP_OPCODE_PK4UB,
99 FP_OPCODE_POW,
100 FP_OPCODE_RCP,
101 FP_OPCODE_RFL,
102 FP_OPCODE_RSQ,
103 FP_OPCODE_SEQ,
104 FP_OPCODE_SFL,
105 FP_OPCODE_SGE,
106 FP_OPCODE_SGT,
107 FP_OPCODE_SIN,
108 FP_OPCODE_SLE,
109 FP_OPCODE_SLT,
110 FP_OPCODE_SNE,
111 FP_OPCODE_STR,
112 FP_OPCODE_SUB,
113 FP_OPCODE_TEX,
114 FP_OPCODE_TXD,
115 FP_OPCODE_TXP,
116 FP_OPCODE_UP2H,
117 FP_OPCODE_UP2US,
118 FP_OPCODE_UP4B,
119 FP_OPCODE_UP4UB,
120 FP_OPCODE_X2D,
121 FP_OPCODE_END /* private opcode */
122 };
123
124
125 /* Instruction source register */
126 struct fp_src_register
127 {
128 enum register_file File;
129 GLint Index;
130 GLuint Swizzle[4];
131 GLboolean NegateBase; /* negate before absolute value? */
132 GLboolean Abs; /* take absolute value? */
133 GLboolean NegateAbs; /* negate after absolute value? */
134 };
135
136
137 /* Instruction destination register */
138 struct fp_dst_register
139 {
140 enum register_file File;
141 GLint Index;
142 GLboolean WriteMask[4];
143 GLuint CondMask;
144 GLuint CondSwizzle[4];
145 };
146
147
148 /* Fragment program instruction */
149 struct fp_instruction
150 {
151 enum fp_opcode Opcode;
152 struct fp_src_register SrcReg[3];
153 struct fp_dst_register DstReg;
154 GLboolean Saturate;
155 GLboolean UpdateCondRegister;
156 GLubyte Precision; /* FLOAT32, FLOAT16 or FIXED12 */
157 GLubyte TexSrcUnit; /* texture unit for TEX, TXD, TXP instructions */
158 GLubyte TexSrcBit; /* TEXTURE_1D,2D,3D,CUBE,RECT_BIT source target */
159 #if FEATURE_MESA_program_debug
160 GLint StringPos;
161 #endif
162 };
163
164
165 #endif