Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenprog_instruction.c
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 7.3 00004 * 00005 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 00006 * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved. 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining a 00009 * copy of this software and associated documentation files (the "Software"), 00010 * to deal in the Software without restriction, including without limitation 00011 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00012 * and/or sell copies of the Software, and to permit persons to whom the 00013 * Software is furnished to do so, subject to the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be included 00016 * in all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00019 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00020 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00021 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00022 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00023 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00024 */ 00025 00026 00027 #include "main/glheader.h" 00028 #include "main/imports.h" 00029 #include "main/mtypes.h" 00030 #include "prog_instruction.h" 00031 00032 00038 void 00039 _mesa_init_instructions(struct prog_instruction *inst, GLuint count) 00040 { 00041 GLuint i; 00042 00043 _mesa_bzero(inst, count * sizeof(struct prog_instruction)); 00044 00045 for (i = 0; i < count; i++) { 00046 inst[i].SrcReg[0].File = PROGRAM_UNDEFINED; 00047 inst[i].SrcReg[0].Swizzle = SWIZZLE_NOOP; 00048 inst[i].SrcReg[1].File = PROGRAM_UNDEFINED; 00049 inst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP; 00050 inst[i].SrcReg[2].File = PROGRAM_UNDEFINED; 00051 inst[i].SrcReg[2].Swizzle = SWIZZLE_NOOP; 00052 00053 inst[i].DstReg.File = PROGRAM_UNDEFINED; 00054 inst[i].DstReg.WriteMask = WRITEMASK_XYZW; 00055 inst[i].DstReg.CondMask = COND_TR; 00056 inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP; 00057 00058 inst[i].SaturateMode = SATURATE_OFF; 00059 inst[i].Precision = FLOAT32; 00060 } 00061 } 00062 00063 00069 struct prog_instruction * 00070 _mesa_alloc_instructions(GLuint numInst) 00071 { 00072 return (struct prog_instruction *) 00073 _mesa_calloc(numInst * sizeof(struct prog_instruction)); 00074 } 00075 00076 00086 struct prog_instruction * 00087 _mesa_realloc_instructions(struct prog_instruction *oldInst, 00088 GLuint numOldInst, GLuint numNewInst) 00089 { 00090 struct prog_instruction *newInst; 00091 00092 newInst = (struct prog_instruction *) 00093 _mesa_realloc(oldInst, 00094 numOldInst * sizeof(struct prog_instruction), 00095 numNewInst * sizeof(struct prog_instruction)); 00096 00097 return newInst; 00098 } 00099 00100 00108 struct prog_instruction * 00109 _mesa_copy_instructions(struct prog_instruction *dest, 00110 const struct prog_instruction *src, GLuint n) 00111 { 00112 GLuint i; 00113 _mesa_memcpy(dest, src, n * sizeof(struct prog_instruction)); 00114 for (i = 0; i < n; i++) { 00115 if (src[i].Comment) 00116 dest[i].Comment = _mesa_strdup(src[i].Comment); 00117 } 00118 return dest; 00119 } 00120 00121 00125 void 00126 _mesa_free_instructions(struct prog_instruction *inst, GLuint count) 00127 { 00128 GLuint i; 00129 for (i = 0; i < count; i++) { 00130 if (inst[i].Data) 00131 _mesa_free(inst[i].Data); 00132 if (inst[i].Comment) 00133 _mesa_free((char *) inst[i].Comment); 00134 } 00135 _mesa_free(inst); 00136 } 00137 00138 00142 struct instruction_info 00143 { 00144 gl_inst_opcode Opcode; 00145 const char *Name; 00146 GLuint NumSrcRegs; 00147 GLuint NumDstRegs; 00148 }; 00149 00154 static const struct instruction_info InstInfo[MAX_OPCODE] = { 00155 { OPCODE_NOP, "NOP", 0, 0 }, 00156 { OPCODE_ABS, "ABS", 1, 1 }, 00157 { OPCODE_ADD, "ADD", 2, 1 }, 00158 { OPCODE_AND, "AND", 2, 1 }, 00159 { OPCODE_ARA, "ARA", 1, 1 }, 00160 { OPCODE_ARL, "ARL", 1, 1 }, 00161 { OPCODE_ARL_NV, "ARL_NV", 1, 1 }, 00162 { OPCODE_ARR, "ARL", 1, 1 }, 00163 { OPCODE_BGNLOOP,"BGNLOOP", 0, 0 }, 00164 { OPCODE_BGNSUB, "BGNSUB", 0, 0 }, 00165 { OPCODE_BRA, "BRA", 0, 0 }, 00166 { OPCODE_BRK, "BRK", 0, 0 }, 00167 { OPCODE_CAL, "CAL", 0, 0 }, 00168 { OPCODE_CMP, "CMP", 3, 1 }, 00169 { OPCODE_CONT, "CONT", 0, 0 }, 00170 { OPCODE_COS, "COS", 1, 1 }, 00171 { OPCODE_DDX, "DDX", 1, 1 }, 00172 { OPCODE_DDY, "DDY", 1, 1 }, 00173 { OPCODE_DP2, "DP2", 2, 1 }, 00174 { OPCODE_DP2A, "DP2A", 3, 1 }, 00175 { OPCODE_DP3, "DP3", 2, 1 }, 00176 { OPCODE_DP4, "DP4", 2, 1 }, 00177 { OPCODE_DPH, "DPH", 2, 1 }, 00178 { OPCODE_DST, "DST", 2, 1 }, 00179 { OPCODE_ELSE, "ELSE", 0, 0 }, 00180 { OPCODE_END, "END", 0, 0 }, 00181 { OPCODE_ENDIF, "ENDIF", 0, 0 }, 00182 { OPCODE_ENDLOOP,"ENDLOOP", 0, 0 }, 00183 { OPCODE_ENDSUB, "ENDSUB", 0, 0 }, 00184 { OPCODE_EX2, "EX2", 1, 1 }, 00185 { OPCODE_EXP, "EXP", 1, 1 }, 00186 { OPCODE_FLR, "FLR", 1, 1 }, 00187 { OPCODE_FRC, "FRC", 1, 1 }, 00188 { OPCODE_IF, "IF", 1, 0 }, 00189 { OPCODE_KIL, "KIL", 1, 0 }, 00190 { OPCODE_KIL_NV, "KIL_NV", 0, 0 }, 00191 { OPCODE_LG2, "LG2", 1, 1 }, 00192 { OPCODE_LIT, "LIT", 1, 1 }, 00193 { OPCODE_LOG, "LOG", 1, 1 }, 00194 { OPCODE_LRP, "LRP", 3, 1 }, 00195 { OPCODE_MAD, "MAD", 3, 1 }, 00196 { OPCODE_MAX, "MAX", 2, 1 }, 00197 { OPCODE_MIN, "MIN", 2, 1 }, 00198 { OPCODE_MOV, "MOV", 1, 1 }, 00199 { OPCODE_MUL, "MUL", 2, 1 }, 00200 { OPCODE_NOISE1, "NOISE1", 1, 1 }, 00201 { OPCODE_NOISE2, "NOISE2", 1, 1 }, 00202 { OPCODE_NOISE3, "NOISE3", 1, 1 }, 00203 { OPCODE_NOISE4, "NOISE4", 1, 1 }, 00204 { OPCODE_NOT, "NOT", 1, 1 }, 00205 { OPCODE_NRM3, "NRM3", 1, 1 }, 00206 { OPCODE_NRM4, "NRM4", 1, 1 }, 00207 { OPCODE_OR, "OR", 2, 1 }, 00208 { OPCODE_PK2H, "PK2H", 1, 1 }, 00209 { OPCODE_PK2US, "PK2US", 1, 1 }, 00210 { OPCODE_PK4B, "PK4B", 1, 1 }, 00211 { OPCODE_PK4UB, "PK4UB", 1, 1 }, 00212 { OPCODE_POW, "POW", 2, 1 }, 00213 { OPCODE_POPA, "POPA", 0, 0 }, 00214 { OPCODE_PRINT, "PRINT", 1, 0 }, 00215 { OPCODE_PUSHA, "PUSHA", 0, 0 }, 00216 { OPCODE_RCC, "RCC", 1, 1 }, 00217 { OPCODE_RCP, "RCP", 1, 1 }, 00218 { OPCODE_RET, "RET", 0, 0 }, 00219 { OPCODE_RFL, "RFL", 1, 1 }, 00220 { OPCODE_RSQ, "RSQ", 1, 1 }, 00221 { OPCODE_SCS, "SCS", 1, 1 }, 00222 { OPCODE_SEQ, "SEQ", 2, 1 }, 00223 { OPCODE_SFL, "SFL", 0, 1 }, 00224 { OPCODE_SGE, "SGE", 2, 1 }, 00225 { OPCODE_SGT, "SGT", 2, 1 }, 00226 { OPCODE_SIN, "SIN", 1, 1 }, 00227 { OPCODE_SLE, "SLE", 2, 1 }, 00228 { OPCODE_SLT, "SLT", 2, 1 }, 00229 { OPCODE_SNE, "SNE", 2, 1 }, 00230 { OPCODE_SSG, "SSG", 1, 1 }, 00231 { OPCODE_STR, "STR", 0, 1 }, 00232 { OPCODE_SUB, "SUB", 2, 1 }, 00233 { OPCODE_SWZ, "SWZ", 1, 1 }, 00234 { OPCODE_TEX, "TEX", 1, 1 }, 00235 { OPCODE_TXB, "TXB", 1, 1 }, 00236 { OPCODE_TXD, "TXD", 3, 1 }, 00237 { OPCODE_TXL, "TXL", 1, 1 }, 00238 { OPCODE_TXP, "TXP", 1, 1 }, 00239 { OPCODE_TXP_NV, "TXP_NV", 1, 1 }, 00240 { OPCODE_TRUNC, "TRUNC", 1, 1 }, 00241 { OPCODE_UP2H, "UP2H", 1, 1 }, 00242 { OPCODE_UP2US, "UP2US", 1, 1 }, 00243 { OPCODE_UP4B, "UP4B", 1, 1 }, 00244 { OPCODE_UP4UB, "UP4UB", 1, 1 }, 00245 { OPCODE_X2D, "X2D", 3, 1 }, 00246 { OPCODE_XOR, "XOR", 2, 1 }, 00247 { OPCODE_XPD, "XPD", 2, 1 } 00248 }; 00249 00250 00254 GLuint 00255 _mesa_num_inst_src_regs(gl_inst_opcode opcode) 00256 { 00257 ASSERT(opcode == InstInfo[opcode].Opcode); 00258 ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); 00259 return InstInfo[opcode].NumSrcRegs; 00260 } 00261 00262 00266 GLuint 00267 _mesa_num_inst_dst_regs(gl_inst_opcode opcode) 00268 { 00269 ASSERT(opcode == InstInfo[opcode].Opcode); 00270 ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); 00271 return InstInfo[opcode].NumDstRegs; 00272 } 00273 00274 00275 GLboolean 00276 _mesa_is_tex_instruction(gl_inst_opcode opcode) 00277 { 00278 return (opcode == OPCODE_TEX || 00279 opcode == OPCODE_TXB || 00280 opcode == OPCODE_TXD || 00281 opcode == OPCODE_TXL || 00282 opcode == OPCODE_TXP); 00283 } 00284 00285 00289 const char * 00290 _mesa_opcode_string(gl_inst_opcode opcode) 00291 { 00292 ASSERT(opcode < MAX_OPCODE); 00293 return InstInfo[opcode].Name; 00294 } 00295 Generated on Sun May 27 2012 04:20:34 for ReactOS by
1.7.6.1
|