2 Copyright (C) 2004 Nicolai Haehnle. All Rights Reserved.
4 Permission is hereby granted, free of charge, to any person obtaining
5 a copy of this software and associated documentation files (the
6 "Software"), to deal in the Software without restriction, including
7 without limitation the rights to use, copy, modify, merge, publish,
8 distribute, sublicense, and/or sell copies of the Software, and to
9 permit persons to whom the Software is furnished to do so, subject to
10 the following conditions:
12 The above copyright notice and this permission notice (including the
13 next paragraph) shall be included in all copies or substantial
14 portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
20 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 **************************************************************************/
28 * Nicolai Haehnle <prefect_@gmx.net>
31 #ifndef __R300_PROGRAM_H__
32 #define __R300_PROGRAM_H__
37 * Vertex program helper macros
40 /* Produce out dword */
41 #define VP_OUTCLASS_TMP R300_VPI_OUT_REG_CLASS_TEMPORARY
42 #define VP_OUTCLASS_OUT R300_VPI_OUT_REG_CLASS_RESULT
44 #define VP_OUTMASK_X R300_VPI_OUT_WRITE_X
45 #define VP_OUTMASK_Y R300_VPI_OUT_WRITE_Y
46 #define VP_OUTMASK_Z R300_VPI_OUT_WRITE_Z
47 #define VP_OUTMASK_W R300_VPI_OUT_WRITE_W
48 #define VP_OUTMASK_XY (VP_OUTMASK_X|VP_OUTMASK_Y)
49 #define VP_OUTMASK_XZ (VP_OUTMASK_X|VP_OUTMASK_Z)
50 #define VP_OUTMASK_XW (VP_OUTMASK_X|VP_OUTMASK_W)
51 #define VP_OUTMASK_XYZ (VP_OUTMASK_XY|VP_OUTMASK_Z)
52 #define VP_OUTMASK_XYW (VP_OUTMASK_XY|VP_OUTMASK_W)
53 #define VP_OUTMASK_XZW (VP_OUTMASK_XZ|VP_OUTMASK_W)
54 #define VP_OUTMASK_XYZW (VP_OUTMASK_XYZ|VP_OUTMASK_W)
55 #define VP_OUTMASK_YZ (VP_OUTMASK_Y|VP_OUTMASK_Z)
56 #define VP_OUTMASK_YW (VP_OUTMASK_Y|VP_OUTMASK_W)
57 #define VP_OUTMASK_YZW (VP_OUTMASK_YZ|VP_OUTMASK_W)
58 #define VP_OUTMASK_ZW (VP_OUTMASK_Z|VP_OUTMASK_W)
60 #define VP_OUT(instr,outclass,outidx,outmask) \
61 (R300_VPI_OUT_OP_##instr | \
62 ((outidx) << R300_VPI_OUT_REG_INDEX_SHIFT) | \
63 VP_OUTCLASS_##outclass | \
66 /* Produce in dword */
67 #define VP_INCLASS_TMP R300_VPI_IN_REG_CLASS_TEMPORARY
68 #define VP_INCLASS_IN R300_VPI_IN_REG_CLASS_ATTRIBUTE
69 #define VP_INCLASS_CONST R300_VPI_IN_REG_CLASS_PARAMETER
71 #define VP_IN(class,idx) \
72 (((idx) << R300_VPI_IN_REG_INDEX_SHIFT) | \
73 VP_INCLASS_##class | \
74 (R300_VPI_IN_SELECT_X << R300_VPI_IN_X_SHIFT) | \
75 (R300_VPI_IN_SELECT_Y << R300_VPI_IN_Y_SHIFT) | \
76 (R300_VPI_IN_SELECT_Z << R300_VPI_IN_Z_SHIFT) | \
77 (R300_VPI_IN_SELECT_W << R300_VPI_IN_W_SHIFT))
79 ((R300_VPI_IN_SELECT_ZERO << R300_VPI_IN_X_SHIFT) | \
80 (R300_VPI_IN_SELECT_ZERO << R300_VPI_IN_Y_SHIFT) | \
81 (R300_VPI_IN_SELECT_ZERO << R300_VPI_IN_Z_SHIFT) | \
82 (R300_VPI_IN_SELECT_ZERO << R300_VPI_IN_W_SHIFT))
84 ((R300_VPI_IN_SELECT_ONE << R300_VPI_IN_X_SHIFT) | \
85 (R300_VPI_IN_SELECT_ONE << R300_VPI_IN_Y_SHIFT) | \
86 (R300_VPI_IN_SELECT_ONE << R300_VPI_IN_Z_SHIFT) | \
87 (R300_VPI_IN_SELECT_ONE << R300_VPI_IN_W_SHIFT))
89 #define VP_NEG(in,comp) ((in) ^ (R300_VPI_IN_NEG_##comp))
90 #define VP_NEGALL(in,comp) VP_NEG(VP_NEG(VP_NEG(VP_NEG((in),X),Y),Z),W)
93 * Fragment program helper macros
96 /* Produce unshifted source selectors */
97 #define FP_TMP(idx) (idx)
98 #define FP_CONST(idx) ((idx) | (1 << 5))
100 /* Produce source/dest selector dword */
101 #define FP_SELC_MASK_NO 0
102 #define FP_SELC_MASK_X 1
103 #define FP_SELC_MASK_Y 2
104 #define FP_SELC_MASK_XY 3
105 #define FP_SELC_MASK_Z 4
106 #define FP_SELC_MASK_XZ 5
107 #define FP_SELC_MASK_YZ 6
108 #define FP_SELC_MASK_XYZ 7
110 #define FP_SELC(destidx,regmask,outmask,src0,src1,src2) \
111 (((destidx) << R300_FPI1_DSTC_SHIFT) | \
112 (FP_SELC_MASK_##regmask << 23) | \
113 (FP_SELC_MASK_##outmask << 26) | \
114 ((src0) << R300_FPI1_SRC0C_SHIFT) | \
115 ((src1) << R300_FPI1_SRC1C_SHIFT) | \
116 ((src2) << R300_FPI1_SRC2C_SHIFT))
118 #define FP_SELA_MASK_NO 0
119 #define FP_SELA_MASK_W 1
121 #define FP_SELA(destidx,regmask,outmask,src0,src1,src2) \
122 (((destidx) << R300_FPI3_DSTA_SHIFT) | \
123 (FP_SELA_MASK_##regmask << 23) | \
124 (FP_SELA_MASK_##outmask << 24) | \
125 ((src0) << R300_FPI3_SRC0A_SHIFT) | \
126 ((src1) << R300_FPI3_SRC1A_SHIFT) | \
127 ((src2) << R300_FPI3_SRC2A_SHIFT))
129 /* Produce unshifted argument selectors */
130 #define FP_ARGC(source) R300_FPI0_ARGC_##source
131 #define FP_ARGA(source) R300_FPI2_ARGA_##source
132 #define FP_ABS(arg) ((arg) | (1 << 6))
133 #define FP_NEG(arg) ((arg) ^ (1 << 5))
135 /* Produce instruction dword */
136 #define FP_INSTRC(opcode,arg0,arg1,arg2) \
137 (R300_FPI0_OUTC_##opcode | \
138 ((arg0) << R300_FPI0_ARG0C_SHIFT) | \
139 ((arg1) << R300_FPI0_ARG1C_SHIFT) | \
140 ((arg2) << R300_FPI0_ARG2C_SHIFT))
142 #define FP_INSTRA(opcode,arg0,arg1,arg2) \
143 (R300_FPI2_OUTA_##opcode | \
144 ((arg0) << R300_FPI2_ARG0A_SHIFT) | \
145 ((arg1) << R300_FPI2_ARG1A_SHIFT) | \
146 ((arg2) << R300_FPI2_ARG2A_SHIFT))
148 extern void debug_vp(GLcontext
* ctx
, struct gl_vertex_program
*vp
);
150 #endif /* __R300_PROGRAM_H__ */