blob: 99ec20bb8284e1201ab51b3486ba54fb8c04a72f [file] [log] [blame]
Michal Krol2861e732004-03-29 11:09:34 +00001/*
2 * Mesa 3-D graphics library
Brian Paul7aebaf32005-10-30 21:23:23 +00003 * Version: 6.5
Michal Krol2861e732004-03-29 11:09:34 +00004 *
Brian Paul7aebaf32005-10-30 21:23:23 +00005 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
Michal Krol2861e732004-03-29 11:09:34 +00006 *
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 Whitwell7c26b612005-04-21 14:46:57 +000037#include "mtypes.h"
Michal Krol2861e732004-03-29 11:09:34 +000038
Brian Paul7aebaf32005-10-30 21:23:23 +000039
40/**
41 * Fragment program output registers.
42 * Note: when we fully suppport GL_ARB_draw_buffers we'll have more than
43 * one output color.
44 */
45#define FRAG_OUTPUT_COLR 0 /* fragment color */
46#define FRAG_OUTPUT_COLH 1 /* fragment color, half precision (NV) */
47#define FRAG_OUTPUT_DEPR 2 /* depth/Z */
Michal Krol2861e732004-03-29 11:09:34 +000048
49
50/* condition codes */
51#define COND_GT 1 /* greater than zero */
52#define COND_EQ 2 /* equal to zero */
53#define COND_LT 3 /* less than zero */
54#define COND_UN 4 /* unordered (NaN) */
55#define COND_GE 5 /* greater then or equal to zero */
56#define COND_LE 6 /* less then or equal to zero */
57#define COND_NE 7 /* not equal to zero */
58#define COND_TR 8 /* always true */
59#define COND_FL 9 /* always false */
60
61
62/* instruction precision */
63#define FLOAT32 0x1
64#define FLOAT16 0x2
65#define FIXED12 0x4
66
67
68/* Fragment program instruction opcodes */
69enum fp_opcode {
Keith Whitwellc3f764f2005-05-04 11:21:46 +000070 FP_OPCODE_ABS, /* ARB_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +000071 FP_OPCODE_ADD,
Keith Whitwellc3f764f2005-05-04 11:21:46 +000072 FP_OPCODE_CMP, /* ARB_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +000073 FP_OPCODE_COS,
Keith Whitwellc3f764f2005-05-04 11:21:46 +000074 FP_OPCODE_DDX, /* NV_f_p only */
75 FP_OPCODE_DDY, /* NV_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +000076 FP_OPCODE_DP3,
77 FP_OPCODE_DP4,
Keith Whitwellc3f764f2005-05-04 11:21:46 +000078 FP_OPCODE_DPH, /* ARB_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +000079 FP_OPCODE_DST,
Keith Whitwellc3f764f2005-05-04 11:21:46 +000080 FP_OPCODE_END, /* private opcode */
Michal Krol2861e732004-03-29 11:09:34 +000081 FP_OPCODE_EX2,
82 FP_OPCODE_FLR,
83 FP_OPCODE_FRC,
Keith Whitwellc3f764f2005-05-04 11:21:46 +000084 FP_OPCODE_KIL, /* ARB_f_p only */
85 FP_OPCODE_KIL_NV, /* NV_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +000086 FP_OPCODE_LG2,
87 FP_OPCODE_LIT,
88 FP_OPCODE_LRP,
89 FP_OPCODE_MAD,
90 FP_OPCODE_MAX,
91 FP_OPCODE_MIN,
92 FP_OPCODE_MOV,
93 FP_OPCODE_MUL,
Keith Whitwellc3f764f2005-05-04 11:21:46 +000094 FP_OPCODE_PK2H, /* NV_f_p only */
95 FP_OPCODE_PK2US, /* NV_f_p only */
96 FP_OPCODE_PK4B, /* NV_f_p only */
97 FP_OPCODE_PK4UB, /* NV_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +000098 FP_OPCODE_POW,
Keith Whitwellc3f764f2005-05-04 11:21:46 +000099 FP_OPCODE_PRINT, /* Mesa only */
Michal Krol2861e732004-03-29 11:09:34 +0000100 FP_OPCODE_RCP,
Keith Whitwellc3f764f2005-05-04 11:21:46 +0000101 FP_OPCODE_RFL, /* NV_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +0000102 FP_OPCODE_RSQ,
Keith Whitwellc3f764f2005-05-04 11:21:46 +0000103 FP_OPCODE_SCS, /* ARB_f_p only */
104 FP_OPCODE_SEQ, /* NV_f_p only */
105 FP_OPCODE_SFL, /* NV_f_p only */
106 FP_OPCODE_SGE, /* NV_f_p only */
107 FP_OPCODE_SGT, /* NV_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +0000108 FP_OPCODE_SIN,
Keith Whitwellc3f764f2005-05-04 11:21:46 +0000109 FP_OPCODE_SLE, /* NV_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +0000110 FP_OPCODE_SLT,
Keith Whitwellc3f764f2005-05-04 11:21:46 +0000111 FP_OPCODE_SNE, /* NV_f_p only */
112 FP_OPCODE_STR, /* NV_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +0000113 FP_OPCODE_SUB,
Keith Whitwellc3f764f2005-05-04 11:21:46 +0000114 FP_OPCODE_SWZ, /* ARB_f_p only */
Michal Krol2861e732004-03-29 11:09:34 +0000115 FP_OPCODE_TEX,
Keith Whitwellc3f764f2005-05-04 11:21:46 +0000116 FP_OPCODE_TXB, /* ARB_f_p only */
117 FP_OPCODE_TXD, /* NV_f_p only */
118 FP_OPCODE_TXP, /* ARB_f_p only */
119 FP_OPCODE_TXP_NV, /* NV_f_p only */
120 FP_OPCODE_UP2H, /* NV_f_p only */
121 FP_OPCODE_UP2US, /* NV_f_p only */
122 FP_OPCODE_UP4B, /* NV_f_p only */
123 FP_OPCODE_UP4UB, /* NV_f_p only */
124 FP_OPCODE_X2D, /* NV_f_p only - 2d mat mul */
125 FP_OPCODE_XPD /* ARB_f_p only - cross product */
Michal Krol2861e732004-03-29 11:09:34 +0000126};
127
128
129/* Instruction source register */
130struct fp_src_register
131{
Keith Whitwell7c26b612005-04-21 14:46:57 +0000132 GLuint File:4;
133 GLuint Index:8;
134 GLuint Swizzle:12;
135 GLuint NegateBase:4; /* ARB: negate/extended negate.
136 NV: negate before absolute value? */
137 GLuint Abs:1; /* NV: take absolute value? */
138 GLuint NegateAbs:1; /* NV: negate after absolute value? */
Michal Krol2861e732004-03-29 11:09:34 +0000139};
140
141
142/* Instruction destination register */
143struct fp_dst_register
144{
Keith Whitwell7c26b612005-04-21 14:46:57 +0000145 GLuint File:4;
146 GLuint Index:8;
147 GLuint WriteMask:4;
148 GLuint CondMask:4; /* NV: enough bits? */
149 GLuint CondSwizzle:12; /* NV: enough bits? */
Michal Krol2861e732004-03-29 11:09:34 +0000150};
151
152
153/* Fragment program instruction */
154struct fp_instruction
155{
Keith Whitwell7c26b612005-04-21 14:46:57 +0000156 GLuint Opcode:6;
157 GLuint Saturate:1;
158 GLuint UpdateCondRegister:1; /* NV */
159 GLuint Precision:2; /* NV: unused/unneeded? */
160 GLuint TexSrcUnit:4; /* texture unit for TEX, TXD, TXP instructions */
161 GLuint TexSrcIdx:3; /* TEXTURE_1D,2D,3D,CUBE,RECT_INDEX source target */
162
163#if FEATURE_MESA_program_debug
164 GLint StringPos:15; /* enough bits? */
165#endif
166
167 void *Data; /* some arbitrary data, only used for PRINT instruction now */
Michal Krol2861e732004-03-29 11:09:34 +0000168 struct fp_src_register SrcReg[3];
169 struct fp_dst_register DstReg;
Michal Krol2861e732004-03-29 11:09:34 +0000170};
171
172
Brian Paul7aebaf32005-10-30 21:23:23 +0000173extern void
174_mesa_init_fp_instruction(struct fp_instruction *inst);
175
176
Michal Krol2861e732004-03-29 11:09:34 +0000177#endif