• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __VERTEX_SHADER_H__
2 #define __VERTEX_SHADER_H__
3 
4 #include "r200_reg.h"
5 
6 typedef struct {
7    uint32_t op;
8    uint32_t src0;
9    uint32_t src1;
10    uint32_t src2;
11 } VERTEX_SHADER_INSTRUCTION;
12 
13 extern void r200InitShaderFuncs(struct dd_function_table *functions);
14 extern void r200SetupVertexProg( struct gl_context *ctx );
15 
16 #define VSF_FLAG_X	1
17 #define VSF_FLAG_Y	2
18 #define VSF_FLAG_Z	4
19 #define VSF_FLAG_W	8
20 #define VSF_FLAG_XYZ	(VSF_FLAG_X | VSF_FLAG_Y | VSF_FLAG_Z)
21 #define VSF_FLAG_ALL	0xf
22 #define VSF_FLAG_NONE	0
23 
24 #define R200_VSF_MAX_INST	128
25 #define R200_VSF_MAX_PARAM	192
26 #define R200_VSF_MAX_TEMPS	12
27 
28 #define R200_VPI_OUT_REG_INDEX_SHIFT            13
29 #define R200_VPI_OUT_REG_INDEX_MASK             (31 << 13) /* GUESS based on fglrx native limits */
30 
31 #define R200_VPI_OUT_WRITE_X                    (1 << 20)
32 #define R200_VPI_OUT_WRITE_Y                    (1 << 21)
33 #define R200_VPI_OUT_WRITE_Z                    (1 << 22)
34 #define R200_VPI_OUT_WRITE_W                    (1 << 23)
35 
36 #define R200_VPI_IN_REG_CLASS_TEMPORARY         (0 << 0)
37 #define R200_VPI_IN_REG_CLASS_ATTRIBUTE         (1 << 0)
38 #define R200_VPI_IN_REG_CLASS_PARAMETER         (2 << 0)
39 #define R200_VPI_IN_REG_CLASS_NONE              (9 << 0)
40 #define R200_VPI_IN_REG_CLASS_MASK              (31 << 0) /* GUESS */
41 
42 #define R200_VPI_IN_REG_INDEX_SHIFT             5
43 #define R200_VPI_IN_REG_INDEX_MASK              (255 << 5) /* GUESS based on fglrx native limits */
44 
45 /* The R200 can select components from the input register arbitrarily.
46 // Use the following constants, shifted by the component shift you
47 // want to select */
48 #define R200_VPI_IN_SELECT_X    0
49 #define R200_VPI_IN_SELECT_Y    1
50 #define R200_VPI_IN_SELECT_Z    2
51 #define R200_VPI_IN_SELECT_W    3
52 #define R200_VPI_IN_SELECT_ZERO 4
53 #define R200_VPI_IN_SELECT_ONE  5
54 #define R200_VPI_IN_SELECT_MASK 7
55 
56 #define R200_VPI_IN_X_SHIFT                     13
57 #define R200_VPI_IN_Y_SHIFT                     16
58 #define R200_VPI_IN_Z_SHIFT                     19
59 #define R200_VPI_IN_W_SHIFT                     22
60 
61 #define R200_VPI_IN_NEG_X                       (1 << 25)
62 #define R200_VPI_IN_NEG_Y                       (1 << 26)
63 #define R200_VPI_IN_NEG_Z                       (1 << 27)
64 #define R200_VPI_IN_NEG_W                       (1 << 28)
65 
66 #define R200_VSF_OUT_CLASS_TMP			(0 << 8)
67 #define R200_VSF_OUT_CLASS_ADDR			(3 << 8)
68 #define R200_VSF_OUT_CLASS_RESULT_POS		(4 << 8)
69 #define R200_VSF_OUT_CLASS_RESULT_COLOR		(5 << 8)
70 #define R200_VSF_OUT_CLASS_RESULT_TEXC		(6 << 8)
71 #define R200_VSF_OUT_CLASS_RESULT_FOGC		(7 << 8)
72 #define R200_VSF_OUT_CLASS_RESULT_POINTSIZE	(8 << 8)
73 #define R200_VSF_OUT_CLASS_MASK			(31 << 8)
74 
75 /* opcodes - they all are the same as on r300 it seems, however
76    LIT and POW require different setup */
77 #define R200_VPI_OUT_OP_DOT                     (1 << 0)
78 #define R200_VPI_OUT_OP_MUL                     (2 << 0)
79 #define R200_VPI_OUT_OP_ADD                     (3 << 0)
80 #define R200_VPI_OUT_OP_MAD                     (4 << 0)
81 #define R200_VPI_OUT_OP_DST                     (5 << 0)
82 #define R200_VPI_OUT_OP_FRC                     (6 << 0)
83 #define R200_VPI_OUT_OP_MAX                     (7 << 0)
84 #define R200_VPI_OUT_OP_MIN                     (8 << 0)
85 #define R200_VPI_OUT_OP_SGE                     (9 << 0)
86 #define R200_VPI_OUT_OP_SLT                     (10 << 0)
87 
88 #define R200_VPI_OUT_OP_ARL                     (13 << 0)
89 
90 #define R200_VPI_OUT_OP_EXP                     (65 << 0)
91 #define R200_VPI_OUT_OP_LOG                     (66 << 0)
92 /* base e exp. Useful for fog. */
93 #define R200_VPI_OUT_OP_EXP_E                   (67 << 0)
94 
95 #define R200_VPI_OUT_OP_LIT                     (68 << 0)
96 #define R200_VPI_OUT_OP_POW                     (69 << 0)
97 #define R200_VPI_OUT_OP_RCP                     (70 << 0)
98 #define R200_VPI_OUT_OP_RSQ                     (72 << 0)
99 
100 #define R200_VPI_OUT_OP_EX2                     (75 << 0)
101 #define R200_VPI_OUT_OP_LG2                     (76 << 0)
102 
103 #define R200_VPI_OUT_OP_MAD_2                   (128 << 0)
104 
105 /* first CARD32 of an instruction */
106 
107 /* possible operations:
108     DOT, MUL, ADD, MAD, FRC, MAX, MIN, SGE, SLT, EXP, LOG, LIT, POW, RCP, RSQ, EX2,
109     LG2, MAD_2, ARL */
110 
111 #define MAKE_VSF_OP(op, out_reg, out_reg_fields) \
112    ((op) | (out_reg) | ((out_reg_fields) << 20) )
113 
114 #define VSF_IN_CLASS_TMP	0
115 #define VSF_IN_CLASS_ATTR	1
116 #define VSF_IN_CLASS_PARAM	2
117 #define VSF_IN_CLASS_NONE	9
118 
119 #define VSF_IN_COMPONENT_X	0
120 #define VSF_IN_COMPONENT_Y	1
121 #define VSF_IN_COMPONENT_Z	2
122 #define VSF_IN_COMPONENT_W	3
123 #define VSF_IN_COMPONENT_ZERO	4
124 #define VSF_IN_COMPONENT_ONE	5
125 
126 #define MAKE_VSF_SOURCE(in_reg_index, comp_x, comp_y, comp_z, comp_w, class, negate) \
127 	( ((in_reg_index)<<R200_VPI_IN_REG_INDEX_SHIFT) \
128 	   | ((comp_x)<<R200_VPI_IN_X_SHIFT) \
129 	   | ((comp_y)<<R200_VPI_IN_Y_SHIFT) \
130 	   | ((comp_z)<<R200_VPI_IN_Z_SHIFT) \
131 	   | ((comp_w)<<R200_VPI_IN_W_SHIFT) \
132 	   | ((negate)<<25) | ((class)))
133 
134 #define EASY_VSF_SOURCE(in_reg_index, comp_x, comp_y, comp_z, comp_w, class, negate) \
135 	MAKE_VSF_SOURCE(in_reg_index, \
136 		VSF_IN_COMPONENT_##comp_x, \
137 		VSF_IN_COMPONENT_##comp_y, \
138 		VSF_IN_COMPONENT_##comp_z, \
139 		VSF_IN_COMPONENT_##comp_w, \
140 		VSF_IN_CLASS_##class, VSF_FLAG_##negate)
141 
142 /* special sources: */
143 
144 /* (1.0,1.0,1.0,1.0) vector (ATTR, plain ) */
145 #define VSF_ATTR_UNITY(reg) 	EASY_VSF_SOURCE(reg, ONE, ONE, ONE, ONE, ATTR, NONE)
146 #define VSF_UNITY(reg) 	EASY_VSF_SOURCE(reg, ONE, ONE, ONE, ONE, NONE, NONE)
147 
148 /* contents of unmodified register */
149 #define VSF_REG(reg) 	EASY_VSF_SOURCE(reg, X, Y, Z, W, ATTR, NONE)
150 
151 /* contents of unmodified parameter */
152 #define VSF_PARAM(reg) 	EASY_VSF_SOURCE(reg, X, Y, Z, W, PARAM, NONE)
153 
154 /* contents of unmodified temporary register */
155 #define VSF_TMP(reg) 	EASY_VSF_SOURCE(reg, X, Y, Z, W, TMP, NONE)
156 
157 /* components of ATTR register */
158 #define VSF_ATTR_X(reg) EASY_VSF_SOURCE(reg, X, X, X, X, ATTR, NONE)
159 #define VSF_ATTR_Y(reg) EASY_VSF_SOURCE(reg, Y, Y, Y, Y, ATTR, NONE)
160 #define VSF_ATTR_Z(reg) EASY_VSF_SOURCE(reg, Z, Z, Z, Z, ATTR, NONE)
161 #define VSF_ATTR_W(reg) EASY_VSF_SOURCE(reg, W, W, W, W, ATTR, NONE)
162 
163 #endif
164