Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ArbInst.hpp

00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory 00004 // Project administrator: Michael D. McCool 00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa, 00006 // Michael D. McCool 00007 // 00008 // This software is provided 'as-is', without any express or implied 00009 // warranty. In no event will the authors be held liable for any damages 00010 // arising from the use of this software. 00011 // 00012 // Permission is granted to anyone to use this software for any purpose, 00013 // including commercial applications, and to alter it and redistribute it 00014 // freely, subject to the following restrictions: 00015 // 00016 // 1. The origin of this software must not be misrepresented; you must 00017 // not claim that you wrote the original software. If you use this 00018 // software in a product, an acknowledgment in the product documentation 00019 // would be appreciated but is not required. 00020 // 00021 // 2. Altered source versions must be plainly marked as such, and must 00022 // not be misrepresented as being the original software. 00023 // 00024 // 3. This notice may not be removed or altered from any source 00025 // distribution. 00027 #ifndef ARBINST_HPP 00028 #define ARBINST_HPP 00029 00030 #include "ShVariable.hpp" 00031 00032 namespace shgl { 00033 00036 enum ArbOp { 00037 // VERTEX AND FRAGMENT 00038 00039 // Vector 00040 SH_ARB_ABS, 00041 SH_ARB_FLR, 00042 SH_ARB_FRC, 00043 SH_ARB_LIT, 00044 SH_ARB_MOV, 00045 00046 // Scalar 00047 SH_ARB_EX2, 00048 SH_ARB_LG2, 00049 SH_ARB_RCP, 00050 SH_ARB_RSQ, 00051 00052 // Binary scalar 00053 SH_ARB_POW, 00054 00055 // Binary vector 00056 SH_ARB_ADD, 00057 SH_ARB_DP3, 00058 SH_ARB_DP4, 00059 SH_ARB_DPH, 00060 SH_ARB_DST, 00061 SH_ARB_MAX, 00062 SH_ARB_MIN, 00063 SH_ARB_MUL, 00064 SH_ARB_SGE, 00065 SH_ARB_SLT, 00066 SH_ARB_SUB, 00067 SH_ARB_XPD, 00068 00069 // Trinary 00070 SH_ARB_MAD, 00071 00072 // Swizzling 00073 SH_ARB_SWZ, 00074 00075 // VERTEX ONLY 00076 // Scalar 00077 SH_ARB_EXP, 00078 SH_ARB_LOG, 00079 00080 // Weird, 00081 SH_ARB_ARL, 00082 SH_ARB_ARRAYMOV, // Kind of hacky but works. 00083 00084 // FRAGMENT ONLY 00085 // Scalar 00086 SH_ARB_COS, 00087 SH_ARB_SIN, 00088 SH_ARB_SCS, 00089 00090 // Trinary 00091 SH_ARB_CMP, 00092 SH_ARB_LRP, 00093 00094 // Sampling 00095 SH_ARB_TEX, 00096 SH_ARB_TXP, 00097 SH_ARB_TXB, 00098 00099 // KIL 00100 SH_ARB_KIL, 00101 00102 // NV_vertex_program2/NV_fragment_program 00103 SH_ARB_SEQ, 00104 SH_ARB_SGT, 00105 SH_ARB_SLE, 00106 SH_ARB_SNE, 00107 SH_ARB_SFL, 00108 SH_ARB_STR, 00109 00110 // NV_fragment_program 00111 SH_ARB_DDX, 00112 SH_ARB_DDY, 00113 SH_ARB_RFL, 00114 SH_ARB_TXD, 00115 00116 // NV_vertex_program2 00117 SH_ARB_SSG, 00118 SH_ARB_BRA, 00119 SH_ARB_LABEL, // Special label "instruction" 00120 00121 // NV_fragment_program2 00122 SH_ARB_DIV, 00123 SH_ARB_DP2, 00124 SH_ARB_NRM, 00125 SH_ARB_IF, 00126 SH_ARB_ELSE, 00127 SH_ARB_ENDIF, 00128 SH_ARB_REP, 00129 SH_ARB_ENDREP, 00130 SH_ARB_BRK, 00131 00132 // Special "operations" for emit 00133 SH_ARB_FUN 00134 }; 00135 00138 struct ArbOpInfo { 00139 char* name; 00140 int arity; 00141 bool collectingOp; 00142 }; 00143 00144 extern ArbOpInfo arbOpInfo[]; 00145 00148 struct ArbInst { 00149 static const int max_num_sources = 4; 00150 00151 ArbInst(ArbOp op, int label) 00152 : op(op), label(label), invert(false), 00153 update_cc(false), ccode(NOCC) 00154 { 00155 } 00156 00157 ArbInst(ArbOp op, int label, const SH::ShVariable& condition) 00158 : op(op), label(label), invert(false), 00159 update_cc(false), ccode(NOCC) 00160 { 00161 src[0] = condition; 00162 } 00163 00164 ArbInst(ArbOp op, const SH::ShVariable& dest) 00165 : op(op), dest(dest), invert(false), 00166 update_cc(false), ccode(NOCC) 00167 { 00168 } 00169 00170 ArbInst(ArbOp op, const SH::ShVariable& dest, const SH::ShVariable& src0) 00171 : op(op), dest(dest), invert(false), 00172 update_cc(false), ccode(NOCC) 00173 { 00174 src[0] = src0; 00175 } 00176 00177 ArbInst(ArbOp op, const SH::ShVariable& dest, const SH::ShVariable& src0, 00178 const SH::ShVariable& src1) 00179 : op(op), dest(dest), invert(false), 00180 update_cc(false), ccode(NOCC) 00181 { 00182 src[0] = src0; 00183 src[1] = src1; 00184 } 00185 ArbInst(ArbOp op, const SH::ShVariable& dest, const SH::ShVariable& src0, 00186 const SH::ShVariable& src1, const SH::ShVariable& src2) 00187 : op(op), dest(dest), invert(false), 00188 update_cc(false), ccode(NOCC) 00189 { 00190 src[0] = src0; 00191 src[1] = src1; 00192 src[2] = src2; 00193 } 00194 ArbInst(ArbOp op, const SH::ShVariable& dest, const SH::ShVariable& src0, 00195 const SH::ShVariable& src1, const SH::ShVariable& src2, 00196 const SH::ShVariable& src3) 00197 : op(op), dest(dest), invert(false), 00198 update_cc(false), ccode(NOCC) 00199 { 00200 src[0] = src0; 00201 src[1] = src1; 00202 src[2] = src2; 00203 src[3] = src3; 00204 } 00205 00206 ArbOp op; 00207 SH::ShVariable dest; 00208 00209 SH::ShVariable src[max_num_sources]; 00210 00211 int label; // For branching instructions and labels 00212 bool invert; // Invert the sense of a break condition. 00213 00214 // NV specific stuff for condition codes 00215 bool update_cc; 00216 00217 enum CCode { 00218 NOCC, 00219 EQ, 00220 GE, 00221 GT, 00222 LE, 00223 LT, 00224 NE, 00225 TR, 00226 FL 00227 } ccode; 00228 00229 SH::ShSwizzle ccswiz; 00230 00231 }; 00232 00233 extern char* arbCCnames[]; 00234 00235 } 00236 00237 #endif

Generated on Fri Nov 5 16:51:18 2004 for Sh by doxygen 1.3.7