Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
Brian Paul | 2a5afe3 | 2004-12-18 16:18:00 +0000 | [diff] [blame] | 3 | * Version: 6.3 |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 4 | * |
Brian Paul | 2a5afe3 | 2004-12-18 16:18:00 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 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" |
Keith Whitwell | 7c26b61 | 2005-04-21 14:46:57 +0000 | [diff] [blame] | 37 | #include "mtypes.h" |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 38 | |
| 39 | /* output registers */ |
| 40 | #define FRAG_OUTPUT_COLR 0 |
| 41 | #define FRAG_OUTPUT_COLH 1 |
| 42 | #define FRAG_OUTPUT_DEPR 2 |
| 43 | |
| 44 | |
| 45 | /* condition codes */ |
| 46 | #define COND_GT 1 /* greater than zero */ |
| 47 | #define COND_EQ 2 /* equal to zero */ |
| 48 | #define COND_LT 3 /* less than zero */ |
| 49 | #define COND_UN 4 /* unordered (NaN) */ |
| 50 | #define COND_GE 5 /* greater then or equal to zero */ |
| 51 | #define COND_LE 6 /* less then or equal to zero */ |
| 52 | #define COND_NE 7 /* not equal to zero */ |
| 53 | #define COND_TR 8 /* always true */ |
| 54 | #define COND_FL 9 /* always false */ |
| 55 | |
| 56 | |
| 57 | /* instruction precision */ |
| 58 | #define FLOAT32 0x1 |
| 59 | #define FLOAT16 0x2 |
| 60 | #define FIXED12 0x4 |
| 61 | |
| 62 | |
| 63 | /* Fragment program instruction opcodes */ |
| 64 | enum fp_opcode { |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 65 | FP_OPCODE_ABS, /* ARB_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 66 | FP_OPCODE_ADD, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 67 | FP_OPCODE_CMP, /* ARB_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 68 | FP_OPCODE_COS, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 69 | FP_OPCODE_DDX, /* NV_f_p only */ |
| 70 | FP_OPCODE_DDY, /* NV_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 71 | FP_OPCODE_DP3, |
| 72 | FP_OPCODE_DP4, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 73 | FP_OPCODE_DPH, /* ARB_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 74 | FP_OPCODE_DST, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 75 | FP_OPCODE_END, /* private opcode */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 76 | FP_OPCODE_EX2, |
| 77 | FP_OPCODE_FLR, |
| 78 | FP_OPCODE_FRC, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 79 | FP_OPCODE_KIL, /* ARB_f_p only */ |
| 80 | FP_OPCODE_KIL_NV, /* NV_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 81 | FP_OPCODE_LG2, |
| 82 | FP_OPCODE_LIT, |
| 83 | FP_OPCODE_LRP, |
| 84 | FP_OPCODE_MAD, |
| 85 | FP_OPCODE_MAX, |
| 86 | FP_OPCODE_MIN, |
| 87 | FP_OPCODE_MOV, |
| 88 | FP_OPCODE_MUL, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 89 | FP_OPCODE_PK2H, /* NV_f_p only */ |
| 90 | FP_OPCODE_PK2US, /* NV_f_p only */ |
| 91 | FP_OPCODE_PK4B, /* NV_f_p only */ |
| 92 | FP_OPCODE_PK4UB, /* NV_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 93 | FP_OPCODE_POW, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 94 | FP_OPCODE_PRINT, /* Mesa only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 95 | FP_OPCODE_RCP, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 96 | FP_OPCODE_RFL, /* NV_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 97 | FP_OPCODE_RSQ, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 98 | FP_OPCODE_SCS, /* ARB_f_p only */ |
| 99 | FP_OPCODE_SEQ, /* NV_f_p only */ |
| 100 | FP_OPCODE_SFL, /* NV_f_p only */ |
| 101 | FP_OPCODE_SGE, /* NV_f_p only */ |
| 102 | FP_OPCODE_SGT, /* NV_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 103 | FP_OPCODE_SIN, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 104 | FP_OPCODE_SLE, /* NV_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 105 | FP_OPCODE_SLT, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 106 | FP_OPCODE_SNE, /* NV_f_p only */ |
| 107 | FP_OPCODE_STR, /* NV_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 108 | FP_OPCODE_SUB, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 109 | FP_OPCODE_SWZ, /* ARB_f_p only */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 110 | FP_OPCODE_TEX, |
Keith Whitwell | c3f764f | 2005-05-04 11:21:46 +0000 | [diff] [blame^] | 111 | FP_OPCODE_TXB, /* ARB_f_p only */ |
| 112 | FP_OPCODE_TXD, /* NV_f_p only */ |
| 113 | FP_OPCODE_TXP, /* ARB_f_p only */ |
| 114 | FP_OPCODE_TXP_NV, /* NV_f_p only */ |
| 115 | FP_OPCODE_UP2H, /* NV_f_p only */ |
| 116 | FP_OPCODE_UP2US, /* NV_f_p only */ |
| 117 | FP_OPCODE_UP4B, /* NV_f_p only */ |
| 118 | FP_OPCODE_UP4UB, /* NV_f_p only */ |
| 119 | FP_OPCODE_X2D, /* NV_f_p only - 2d mat mul */ |
| 120 | FP_OPCODE_XPD /* ARB_f_p only - cross product */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | |
| 124 | /* Instruction source register */ |
| 125 | struct fp_src_register |
| 126 | { |
Keith Whitwell | 7c26b61 | 2005-04-21 14:46:57 +0000 | [diff] [blame] | 127 | GLuint File:4; |
| 128 | GLuint Index:8; |
| 129 | GLuint Swizzle:12; |
| 130 | GLuint NegateBase:4; /* ARB: negate/extended negate. |
| 131 | NV: negate before absolute value? */ |
| 132 | GLuint Abs:1; /* NV: take absolute value? */ |
| 133 | GLuint NegateAbs:1; /* NV: negate after absolute value? */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | |
| 137 | /* Instruction destination register */ |
| 138 | struct fp_dst_register |
| 139 | { |
Keith Whitwell | 7c26b61 | 2005-04-21 14:46:57 +0000 | [diff] [blame] | 140 | GLuint File:4; |
| 141 | GLuint Index:8; |
| 142 | GLuint WriteMask:4; |
| 143 | GLuint CondMask:4; /* NV: enough bits? */ |
| 144 | GLuint CondSwizzle:12; /* NV: enough bits? */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | |
| 148 | /* Fragment program instruction */ |
| 149 | struct fp_instruction |
| 150 | { |
Keith Whitwell | 7c26b61 | 2005-04-21 14:46:57 +0000 | [diff] [blame] | 151 | GLuint Opcode:6; |
| 152 | GLuint Saturate:1; |
| 153 | GLuint UpdateCondRegister:1; /* NV */ |
| 154 | GLuint Precision:2; /* NV: unused/unneeded? */ |
| 155 | GLuint TexSrcUnit:4; /* texture unit for TEX, TXD, TXP instructions */ |
| 156 | GLuint TexSrcIdx:3; /* TEXTURE_1D,2D,3D,CUBE,RECT_INDEX source target */ |
| 157 | |
| 158 | #if FEATURE_MESA_program_debug |
| 159 | GLint StringPos:15; /* enough bits? */ |
| 160 | #endif |
| 161 | |
| 162 | void *Data; /* some arbitrary data, only used for PRINT instruction now */ |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 163 | struct fp_src_register SrcReg[3]; |
| 164 | struct fp_dst_register DstReg; |
Michal Krol | 2861e73 | 2004-03-29 11:09:34 +0000 | [diff] [blame] | 165 | }; |
| 166 | |
| 167 | |
| 168 | #endif |