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