Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / gallium / drivers / nvc0 / nvc0_graph_macros.h
1
2 #ifndef __NVC0_PGRAPH_MACROS_H__
3 #define __NVC0_PGRAPH_MACROS_H__
4
5 /* extrinsrt r1, r2, src, size, dst: replace bits [dst:dst+size) in r1
6  *  with bits [src:src+size) in r2
7  *
8  * bra(n)z annul: no delay slot
9  */
10
11 /* The comments above the macros describe what they *should* be doing,
12  * but we use less functionality for now.
13  */
14
15 /*
16  * for (i = 0; i < 8; ++i)
17  *    [NVC0_3D_BLEND_ENABLE(i)] = BIT(i of arg);
18  *
19  * [3428] = arg;
20  *
21  * if (arg == 0 || [NVC0_3D_MULTISAMPLE_ENABLE] == 0)
22  *    [0d9c] = 0;
23  * else
24  *    [0d9c] = [342c];
25  */
26 static const uint32_t nvc0_9097_blend_enables[] =
27 {
28    0x05360021, /* 0x00: maddr [NVC0_3D_BLEND_ENABLE(0), increment = 4] */
29    0x00404042, /* 0x01: send extrinsrt 0 $r1 0 0x1 0 */
30    0x00424042, /* 0x02: send extrinsrt 0 $r1 0x1 0x1 0 */
31    0x00444042, /* 0x03: send extrinsrt 0 $r1 0x2 0x1 0 */
32    0x00464042, /* 0x04: send extrinsrt 0 $r1 0x3 0x1 0 */
33    0x00484042, /* 0x05: send extrinsrt 0 $r1 0x4 0x1 0 */
34    0x004a4042, /* 0x06: send extrinsrt 0 $r1 0x5 0x1 0 */
35    0x004c40c2, /* 0x07: exit send extrinsrt 0 $r1 0x6 0x1 0 */
36    0x004e4042, /* 0x08: send extrinsrt 0 $r1 0x7 0x1 0 */
37 };
38
39 /*
40  * uint64 limit = (parm(0) << 32) | parm(1);
41  * uint64 start = (parm(2) << 32);
42  *
43  * if (limit) {
44  *    start |= parm(3);
45  *    --limit;
46  * } else {
47  *    start |= 1;
48  * }
49  *
50  * [0x1c04 + (arg & 0xf) * 16 + 0] = (start >> 32) & 0xff;
51  * [0x1c04 + (arg & 0xf) * 16 + 4] = start & 0xffffffff;
52  * [0x1f00 + (arg & 0xf) * 8 + 0] = (limit >> 32) & 0xff;
53  * [0x1f00 + (arg & 0xf) * 8 + 4] = limit & 0xffffffff;
54  */
55 static const uint32_t nvc0_9097_vertex_array_select[] =
56 {
57    0x00000201, /* 0x00: parm $r2 */
58    0x00000301, /* 0x01: parm $r3 */
59    0x00000401, /* 0x02: parm $r4 */
60    0x00000501, /* 0x03: parm $r5 */
61    0x11004612, /* 0x04: mov $r6 extrinsrt 0 $r1 0 4 2 */
62    0x09004712, /* 0x05: mov $r7 extrinsrt 0 $r1 0 4 1 */
63    0x05c07621, /* 0x06: maddr $r6 add $6 0x1701 */
64    0x00002041, /* 0x07: send $r4 */
65    0x00002841, /* 0x08: send $r5 */
66    0x05f03f21, /* 0x09: maddr $r7 add $7 0x17c0 */
67    0x000010c1, /* 0x0a: exit send $r2 */
68    0x00001841, /* 0x0b: send $r3 */
69 };
70
71 /*
72  * [GL_POLYGON_MODE_FRONT] = arg;
73  *
74  * if (BIT(31 of [0x3410]))
75  *    [1a24] = 0x7353;
76  *
77  * if ([NVC0_3D_SP_SELECT(3)] == 0x31 || [NVC0_3D_SP_SELECT(4)] == 0x41)
78  *    [02ec] = 0;
79  * else
80  * if ([GL_POLYGON_MODE_BACK] == GL_LINE || arg == GL_LINE)
81  *    [02ec] = BYTE(1 of [0x3410]) << 4;
82  * else
83  *    [02ec] = BYTE(0 of [0x3410]) << 4;
84  */
85 static const uint32_t nvc0_9097_poly_mode_front[] =
86 {
87    0x00db0215, /* 0x00: read $r2 [NVC0_3D_POLYGON_MODE_BACK] */
88    0x020c0315, /* 0x01: read $r3 [NVC0_3D_SP_SELECT(3)] */
89    0x00128f10, /* 0x02: mov $r7 or $r1 $r2 */
90    0x02100415, /* 0x03: read $r4 [NVC0_3D_SP_SELECT(4)] */
91    0x00004211, /* 0x04: mov $r2 0x1 */
92    0x00180611, /* 0x05: mov $r6 0x60 */
93    0x0014bf10, /* 0x06: mov $r7 and $r7 $r2 */
94    0x0000f807, /* 0x07: braz $r7 0xa */
95    0x00dac021, /* 0x08: maddr 0x36b */
96    0x00800611, /* 0x09: mov $r6 0x200 */
97    0x00131f10, /* 0x0a: mov $r7 or $r3 $r4 */
98    0x0014bf10, /* 0x0b: mov $r7 and $r7 $r2 */
99    0x0000f807, /* 0x0c: braz $r7 0xf */
100    0x00000841, /* 0x0d: send $r1 */
101    0x00000611, /* 0x0e: mov $r6 0 */
102    0x002ec0a1, /* 0x0f: exit maddr [02ec] */
103    0x00003041  /* 0x10: send $r6 */
104 };
105
106 /*
107  * [GL_POLYGON_MODE_BACK] = arg;
108  *
109  * if (BIT(31 of [0x3410]))
110  *    [1a24] = 0x7353;
111  *
112  * if ([NVC0_3D_SP_SELECT(3)] == 0x31 || [NVC0_3D_SP_SELECT(4)] == 0x41)
113  *    [02ec] = 0;
114  * else
115  * if ([GL_POLYGON_MODE_FRONT] == GL_LINE || arg == GL_LINE)
116  *    [02ec] = BYTE(1 of [0x3410]) << 4;
117  * else
118  *    [02ec] = BYTE(0 of [0x3410]) << 4;
119  */
120 /* NOTE: 0x3410 = 0x80002006 by default,
121  *  POLYGON_MODE == GL_LINE check replaced by (MODE & 1)
122  *  SP_SELECT(i) == (i << 4) | 1 check replaced by SP_SELECT(i) & 1
123  */
124 static const uint32_t nvc0_9097_poly_mode_back[] =
125 {
126    0x00dac215, /* 0x00: read $r2 [NVC0_3D_POLYGON_MODE_FRONT] */
127    0x020c0315, /* 0x01: read $r3 [NVC0_3D_SP_SELECT(3)] */
128    0x00128f10, /* 0x02: mov $r7 or $r1 $r2 */
129    0x02100415, /* 0x03: read $r4 [NVC0_3D_SP_SELECT(4)] */
130    0x00004211, /* 0x04: mov $r2 0x1 */
131    0x00180611, /* 0x05: mov $r6 0x60 */
132    0x0014bf10, /* 0x06: mov $r7 and $r7 $r2 */
133    0x0000f807, /* 0x07: braz $r7 0xa */
134    0x00db0021, /* 0x08: maddr 0x36c */
135    0x00800611, /* 0x09: mov $r6 0x200 */
136    0x00131f10, /* 0x0a: mov $r7 or $r3 $r4 */
137    0x0014bf10, /* 0x0b: mov $r7 and $r7 $r2 */
138    0x0000f807, /* 0x0c: braz $r7 0xf */
139    0x00000841, /* 0x0d: send $r1 */
140    0x00000611, /* 0x0e: mov $r6 0 */
141    0x002ec0a1, /* 0x0f: exit maddr [02ec] */
142    0x00003041  /* 0x10: send $r6 */
143 };
144
145 /*
146  * [NVC0_3D_SP_SELECT(4)] = arg
147  *
148  * if BIT(31 of [0x3410]) == 0
149  *    [1a24] = 0x7353;
150  *
151  * if ([NVC0_3D_SP_SELECT(3)] == 0x31 || arg == 0x41)
152  *    [02ec] = 0
153  * else
154  * if (any POLYGON MODE == LINE)
155  *    [02ec] = BYTE(1 of [3410]) << 4;
156  * else
157  *    [02ec] = BYTE(0 of [3410]) << 4; // 02ec valid bits are 0xff1
158  */
159 static const uint32_t nvc0_9097_gp_select[] = /* 0x0f */
160 {
161    0x00dac215, /* 0x00: read $r2 0x36b */
162    0x00db0315, /* 0x01: read $r3 0x36c */
163    0x0012d710, /* 0x02: mov $r7 or $r2 $r3 */
164    0x020c0415, /* 0x03: read $r4 0x830 */
165    0x00004211, /* 0x04: mov $r2 0x1 */
166    0x00180611, /* 0x05: mov $r6 0x60 */
167    0x0014bf10, /* 0x06: mov $r7 and $r7 $r2 */
168    0x0000f807, /* 0x07: braz $r7 0xa */
169    0x02100021, /* 0x08: maddr 0x840 */
170    0x00800611, /* 0x09: mov $r6 0x200 */
171    0x00130f10, /* 0x0a: mov $r7 or $r1 $r4 */
172    0x0014bf10, /* 0x0b: mov $r7 and $r7 $r2 */
173    0x0000f807, /* 0x0c: braz $r7 0xf */
174    0x00000841, /* 0x0d: send $r1 */
175    0x00000611, /* 0x0e: mov $r6 0 */
176    0x002ec0a1, /* 0x0f: exit maddr 0xbb */
177    0x00003041, /* 0x10: send $r6 */
178 };
179
180 /*
181  * [NVC0_3D_SP_SELECT(3)] = arg
182  *
183  * if BIT(31 of [0x3410]) == 0
184  *    [1a24] = 0x7353;
185  *
186  * if (arg == 0x31) {
187  *    if (BIT(2 of [0x3430])) {
188  *       int i = 15; do { --i; } while(i);
189  *       [0x1a2c] = 0;
190  *    }
191  * }
192  *
193  * if ([NVC0_3D_SP_SELECT(4)] == 0x41 || arg == 0x31)
194  *    [02ec] = 0
195  * else
196  * if ([any POLYGON_MODE] == GL_LINE)
197  *    [02ec] = BYTE(1 of [3410]) << 4;
198  * else
199  *    [02ec] = BYTE(0 of [3410]) << 4;
200  */
201 static const uint32_t nvc0_9097_tep_select[] = /* 0x10 */
202 {
203    0x00dac215, /* 0x00: read $r2 0x36b */
204    0x00db0315, /* 0x01: read $r3 0x36c */
205    0x0012d710, /* 0x02: mov $r7 or $r2 $r3 */
206    0x02100415, /* 0x03: read $r4 0x840 */
207    0x00004211, /* 0x04: mov $r2 0x1 */
208    0x00180611, /* 0x05: mov $r6 0x60 */
209    0x0014bf10, /* 0x06: mov $r7 and $r7 $r2 */
210    0x0000f807, /* 0x07: braz $r7 0xa */
211    0x020c0021, /* 0x08: maddr 0x830 */
212    0x00800611, /* 0x09: mov $r6 0x200 */
213    0x00130f10, /* 0x0a: mov $r7 or $r1 $r4 */
214    0x0014bf10, /* 0x0b: mov $r7 and $r7 $r2 */
215    0x0000f807, /* 0x0c: braz $r7 0xf */
216    0x00000841, /* 0x0d: send $r1 */
217    0x00000611, /* 0x0e: mov $r6 0 */
218    0x002ec0a1, /* 0x0f: exit maddr 0xbb */
219    0x00003041, /* 0x10: send $r6 */
220 };
221
222 #endif