Mercurial > hg > Members > kono > Cerium
annotate TaskManager/Test/test_render/spe/CreateSpan.cpp @ 147:3ecf43bd1a35
fix
author | gongo@charles.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 02 Dec 2008 15:47:25 +0900 |
parents | 2284efc89f63 |
children | 9642aeef298d |
rev | line source |
---|---|
109 | 1 #include "CreateSpan.h" |
2 #include "viewer_types.h" | |
3 | |
4 static const int SPAN_PACK_LOAD = 5; | |
5 static const int SPAN_PACK_STORE = 6; | |
6 static const int POLYGON_PACK_LOAD = 7; | |
141 | 7 static const int TILE_ALLOCATE = 8; |
8 static const int TILE_LOAD = 9; | |
9 static const int TILE_STORE = 10; | |
109 | 10 |
11 static SpanPackPtr spack = NULL; | |
12 static SpanPackPtr send_spack = NULL; | |
13 static int prev_index = 0; | |
14 | |
15 SchedDefineTask(CreateSpan); | |
16 | |
17 static float | |
18 calc(float f1, float f2,int i, float base) | |
19 { | |
20 float ans; | |
21 ans = f1/f2*i + base; | |
22 return ans; | |
23 } | |
24 | |
25 | |
26 /** | |
27 * TrianglePack から、vMin, vMid, vMax を求める | |
28 * | |
29 * @param [triPack] TrianglePack | |
30 * @param [vMin] [vMid] [vMax] | |
31 */ | |
32 static void | |
33 make_vertex(TrianglePack *triPack, | |
34 VertexPackPtr *vMin, VertexPackPtr *vMid, VertexPackPtr *vMax) | |
35 { | |
36 if (triPack->ver1.y <= triPack->ver2.y) { | |
37 if (triPack->ver2.y <= triPack->ver3.y) { | |
38 *vMin = &triPack->ver1; | |
39 *vMid = &triPack->ver2; | |
40 *vMax = &triPack->ver3; | |
41 } else if (triPack->ver3.y <= triPack->ver1.y) { | |
42 *vMin = &triPack->ver3; | |
43 *vMid = &triPack->ver1; | |
44 *vMax = &triPack->ver2; | |
45 } else { | |
46 *vMin = &triPack->ver1; | |
47 *vMid = &triPack->ver3; | |
48 *vMax = &triPack->ver2; | |
49 } | |
50 } else { | |
51 if (triPack->ver1.y <= triPack->ver3.y) { | |
52 *vMin = &triPack->ver2; | |
53 *vMid = &triPack->ver1; | |
54 *vMax = &triPack->ver3; | |
55 } else if (triPack->ver3.y <= triPack->ver2.y) { | |
56 *vMin = &triPack->ver3; | |
57 *vMid = &triPack->ver2; | |
58 *vMax = &triPack->ver1; | |
59 } else { | |
60 *vMin = &triPack->ver2; | |
61 *vMid = &triPack->ver3; | |
62 *vMax = &triPack->ver1; | |
63 } | |
64 } | |
65 } | |
66 | |
67 static void | |
68 make_vMid10(VertexPack *v, VertexPack *vMin, | |
69 VertexPack *vMid, VertexPack *vMax) | |
70 { | |
146 | 71 //int d, d1; |
72 float d; | |
73 int d1; | |
74 | |
75 d = vMax->y - vMin->y; | |
109 | 76 d1 = (int)(vMid->y - vMin->y); |
77 | |
78 v->tex_x = calc(vMax->tex_x - vMin->tex_x, d, d1, vMin->tex_x); | |
79 v->tex_y = calc(vMax->tex_y - vMin->tex_y, d, d1, vMin->tex_y); | |
80 v->x = calc(vMax->x - vMin->x, d, d1, vMin->x); | |
81 v->y = vMid->y; | |
82 v->z = calc(vMax->z - vMin->z, d, d1, vMin->z); | |
83 } | |
84 | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
85 |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
86 /** |
141 | 87 * Span の1ドットずつ、必要なテクスチャのブロック(Tile)を求めていく |
88 * | |
89 */ | |
90 void | |
91 CreateSpan::setTile(SpanPtr span) | |
92 { | |
93 TileInfoListPtr tilelist = | |
94 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); | |
95 TileInfoListPtr send_tilelist = | |
96 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); | |
97 TileInfoListPtr tilelist_addr; | |
98 TileInfoListPtr send_tilelist_addr; | |
99 TileInfoPtr tile; | |
100 | |
101 int cur_x = 0; | |
102 int len = 0; | |
103 | |
104 smanager->mainMem_wait(); | |
105 tilelist_addr = (TileInfoListPtr)smanager->mainMem_get(TILE_ALLOCATE); | |
106 span->tilelist = tilelist_addr; | |
107 | |
108 float tex1 = span->tex_x1; | |
109 float tex2 = span->tex_x2; | |
110 float tey1 = span->tex_y1; | |
111 float tey2 = span->tex_y2; | |
112 int tex_xpos; | |
113 int tex_ypos; | |
114 int end = span->length_x; | |
115 | |
116 if (span->length_x == 1) { | |
117 tilelist->init(); | |
118 tile = &tilelist->tileinfo[tilelist->size++]; | |
119 | |
120 tex_xpos = (int)((span->tex_width-1) * tex1); | |
121 tex_ypos = (int)((span->tex_height-1) * tey1); | |
122 | |
123 tile->tix = tex_xpos; | |
124 tile->tiy = tex_ypos; | |
125 } else { | |
126 while (cur_x < span->length_x) { | |
146 | 127 if (cur_x + MAX_TILE_LIST < span->length_x) { |
128 len = MAX_TILE_LIST; | |
147 | 129 smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); |
146 | 130 } else { |
131 len = span->length_x - cur_x; | |
132 } | |
141 | 133 |
134 float tex_x, tex_y; | |
135 | |
136 tilelist->init(); | |
137 | |
146 | 138 for (int i = cur_x; i < cur_x + len; i++) { |
141 | 139 tile = &tilelist->tileinfo[tilelist->size++]; |
140 | |
141 tex_x = tex1*(end-1-i)/(end-1) + tex2*i/(end-1); | |
142 tex_y = tey1*(end-1-i)/(end-1) + tey2*i/(end-1); | |
143 if (tex_x > 1) tex_x = 1; | |
144 if (tex_y > 1) tex_y = 1; | |
145 tex_xpos = (int)((span->tex_height-1) * tex_x); | |
146 tex_ypos = (int)((span->tex_width-1) * tex_y); | |
147 | |
148 tile->tix = tex_xpos; | |
149 tile->tiy = tex_ypos; | |
150 } | |
151 | |
152 if (cur_x + MAX_TILE_LIST < span->length_x) { | |
153 TileInfoListPtr tmp = tilelist; | |
154 tilelist = send_tilelist; | |
155 send_tilelist = tmp; | |
146 | 156 |
141 | 157 send_tilelist_addr = tilelist_addr; |
158 | |
159 smanager->mainMem_wait(); | |
160 tilelist_addr = | |
161 (TileInfoListPtr)smanager->mainMem_get(TILE_ALLOCATE); | |
162 | |
163 send_tilelist->next = tilelist_addr; | |
164 | |
165 smanager->dma_wait(TILE_STORE); | |
166 smanager->dma_store(send_tilelist, (uint32)send_tilelist_addr, | |
167 sizeof(TileInfoList), TILE_STORE); | |
146 | 168 |
169 tilelist->init(); | |
141 | 170 } |
171 | |
172 cur_x += MAX_TILE_LIST; | |
173 } | |
174 } | |
175 | |
176 smanager->dma_wait(TILE_STORE); | |
177 tilelist->next = 0; // ? | |
178 smanager->dma_store(tilelist, (uint32)tilelist_addr, | |
179 sizeof(TileInfoList), TILE_STORE); | |
180 free(send_tilelist); | |
181 | |
182 smanager->dma_wait(TILE_STORE); | |
183 | |
184 free(tilelist); | |
185 } | |
186 | |
187 /** | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
188 * x軸に水平な辺を持つ三角形ポリゴンから、 |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
189 * Span を抜き出す |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
190 */ |
109 | 191 void |
192 CreateSpan::half_triangle(SpanPackPtr *spackList, | |
193 int charge_y_top, int charge_y_end, | |
194 long *tex_addr, long tex_width, long tex_height, | |
195 VertexPack *vMin,VertexPack *vMid,VertexPack *vMid10) | |
196 { | |
197 float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2; | |
198 float tmp_xpos,tmp_end,tmp_zpos; | |
199 float start_z, end_z; | |
200 float start_tex_x, end_tex_x, start_tex_y, end_tex_y; | |
201 int x, y, length; | |
202 | |
137
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
203 #if 1 |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
204 // これじゃないと |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
205 // テクスチャの貼りに微妙に隙間が。謎だ |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
206 int start_y = (int)vMid->y; |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
207 int end_y = (int)vMin->y; |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
208 #else |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
209 float start_y = vMid->y; |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
210 float end_y = vMin->y; |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
211 #endif |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
212 float div_y = start_y - end_y; |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
213 int k = 0; |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
214 int l = 1; |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
215 |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
216 SpanPackPtr tmp_spack; |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
217 |
135 | 218 /** |
219 * 三角形ポリゴンをx軸に水平に二つに分けようとして | |
220 * ある一辺がすでに水平だった場合、つまり | |
221 * (環境によっては、back slash が 円マークかも) | |
222 * | |
223 * |\ | |
224 * | \ | |
225 * | \ | |
226 * ----- | |
227 * | |
228 * | |
229 * 上のようなポリゴンだった場合は、本来なら上の部分の三角形にだけ | |
230 * half_triangle の処理をするべきだが、現在の処理だと | |
231 * この half_triangle に「上の部分の三角形」と、 | |
232 * 「『下の部分の三角形と判断してしまった』直線」が来てしまう。 | |
233 * 直線の部分が来ると、calc() で 0 除算とかで、値不定で暴走するので | |
234 * 現在はこれで代用。 | |
235 * half_triangle 呼ぶ前にこれを判断できれば良いかもしれない。 | |
236 * てかこんなんでいいのかよ。。。 | |
237 * | |
238 */ | |
137
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
239 #if 1 |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
240 if ((int)div_y == 0) { |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
241 return; |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
242 } |
6cf991f28c6c
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
135
diff
changeset
|
243 #else |
135 | 244 if (vMid10->x == vMin->x && vMid10->y == vMin->y) { |
245 return; | |
246 } | |
247 #endif | |
109 | 248 |
249 if (div_y < 0) { | |
250 div_y = -div_y; | |
251 k = 1; | |
252 l = -1; | |
253 } | |
254 | |
135 | 255 for (int i = k; i < (int)div_y+1; i++) { |
109 | 256 y = (int)vMin->y + i*l; |
257 | |
258 /** | |
259 * 担当 y 範囲内 | |
260 */ | |
261 if (charge_y_top <= y && y <= charge_y_end) { | |
262 // 1..8 を index0, 9..16 を index1 にするために y を -1 | |
263 int index = (y-1) / split_screen_h; | |
264 | |
265 /** | |
266 * 違う SpanPack を扱う場合、 | |
267 * 現在の SpanPack をメインメモリに送り、 | |
268 * 新しい SpanPack を取ってくる | |
269 */ | |
270 if (index != prev_index) { | |
271 tmp_spack = spack; | |
272 spack = send_spack; | |
273 send_spack = tmp_spack; | |
274 | |
275 smanager->dma_wait(SPAN_PACK_STORE); | |
276 smanager->dma_store(send_spack, (uint32)spackList[prev_index], | |
277 sizeof(SpanPack), SPAN_PACK_STORE); | |
278 | |
279 smanager->dma_load(spack, (uint32)spackList[index], | |
280 sizeof(SpanPack), SPAN_PACK_LOAD); | |
281 prev_index = index; | |
282 smanager->dma_wait(SPAN_PACK_LOAD); | |
283 } | |
284 | |
285 /** | |
286 * 書き込む SpanPack が満杯だったら | |
287 * メインメモリで allocate した領域 (next) を持ってきて | |
288 * 現在の spack->next につなぎ、next を次の spack とする。 | |
289 */ | |
290 if (spack->info.size >= MAX_SIZE_SPAN) { | |
291 SpanPackPtr next; | |
292 | |
141 | 293 smanager->mainMem_alloc(0, sizeof(SpanPack)); |
294 smanager->mainMem_wait(); | |
295 next = (SpanPackPtr)smanager->mainMem_get(0); | |
109 | 296 |
297 spack->next = next; | |
298 | |
299 tmp_spack = spack; | |
300 spack = send_spack; | |
301 send_spack = tmp_spack; | |
302 | |
303 smanager->dma_wait(SPAN_PACK_STORE); | |
304 smanager->dma_store(send_spack, (uint32)spackList[index], | |
305 sizeof(SpanPack), SPAN_PACK_STORE); | |
306 | |
307 spackList[index] = next; | |
141 | 308 |
109 | 309 smanager->dma_load(spack, (uint32)spackList[index], |
310 sizeof(SpanPack), SPAN_PACK_LOAD); | |
311 smanager->dma_wait(SPAN_PACK_LOAD); | |
312 spack->init((index+1)*split_screen_h); | |
313 } | |
314 } else { | |
315 /** | |
316 * 担当範囲外だったら無視 | |
317 */ | |
318 continue; | |
319 } | |
146 | 320 |
321 tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x); | |
322 tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); | |
323 tmp_z = calc(vMid10->z - vMin->z ,div_y, i, vMin->z); | |
324 tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); | |
325 | |
326 length = (tmp_xpos > tmp_end) | |
327 ? (int)tmp_xpos - (int)tmp_end : (int)tmp_end - (int)tmp_xpos; | |
328 if (length == 0) { | |
329 continue; | |
330 } | |
109 | 331 |
141 | 332 /** |
333 * メインメモリに、Tile 用の領域確保をここで指定しておく | |
334 */ | |
335 // ちと仕様変更によりここでは使わない | |
336 // 予めやっておいて、その間に処理、だとちょっと動作が怪しいらしい | |
146 | 337 smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); |
338 | |
135 | 339 |
109 | 340 tmp_tex1 =((i/(div_y)) * vMid10->tex_x) + |
341 ( ((div_y - i)/(div_y)) * vMin->tex_x); | |
342 tmp_tex2 =( (i/(div_y)) * vMid->tex_x) + | |
343 ( ((div_y - i)/(div_y)) * vMin->tex_x); | |
344 | |
345 tmp_tey1 =( (i/(div_y)) * vMid10->tex_y) + | |
346 ( ((div_y - i)/(div_y)) * vMin->tex_y); | |
347 tmp_tey2 =( (i/(div_y)) * vMid->tex_y) + | |
348 ( ((div_y - i)/(div_y)) * vMin->tex_y); | |
349 | |
350 if (tmp_xpos > tmp_end) { | |
351 x = (int)tmp_end; | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
352 /** |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
353 * +1 は要らない気がする・・・ |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
354 */ |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
355 //length = (int)(tmp_xpos)-(int)(tmp_end)+1; |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
356 length = (int)(tmp_xpos)-(int)(tmp_end); |
109 | 357 start_z = tmp_zpos; |
358 end_z = tmp_z; | |
359 start_tex_x = tmp_tex2; | |
360 end_tex_x = tmp_tex1; | |
361 start_tex_y = tmp_tey2; | |
362 end_tex_y = tmp_tey1; | |
363 } else { | |
364 x = (int)tmp_xpos; | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
365 //length = (int)(tmp_end)-(int)(tmp_xpos)+1; |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
366 length = (int)(tmp_end)-(int)(tmp_xpos); |
109 | 367 start_z = tmp_z; |
368 end_z = tmp_zpos; | |
369 start_tex_x = tmp_tex1; | |
370 end_tex_x = tmp_tex2; | |
371 start_tex_y = tmp_tey1; | |
372 end_tex_y = tmp_tey2; | |
373 } | |
374 | |
375 smanager->dma_wait(SPAN_PACK_LOAD); | |
376 | |
377 Span *span = &spack->span[spack->info.size++]; | |
378 | |
379 span->tex_addr = tex_addr; | |
380 span->tex_width = tex_width; | |
381 span->tex_height = tex_height; | |
382 span->x = x; | |
383 span->y = y; | |
384 span->length_x = length; | |
385 span->start_z = start_z; | |
386 span->end_z = end_z; | |
387 span->tex_x1 = start_tex_x; | |
388 span->tex_x2 = end_tex_x; | |
389 span->tex_y1 = start_tex_y; | |
390 span->tex_y2 = end_tex_y; | |
113
6ba88fa28df6
Define New Texture Data Structure
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
109
diff
changeset
|
391 |
6ba88fa28df6
Define New Texture Data Structure
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
109
diff
changeset
|
392 // TilePtr の計算 |
6ba88fa28df6
Define New Texture Data Structure
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
109
diff
changeset
|
393 // tix, tiy (Tile 内での x, y) |
6ba88fa28df6
Define New Texture Data Structure
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
109
diff
changeset
|
394 // |
147 | 395 //smanager->mainMem_wait(); |
146 | 396 setTile(span); |
109 | 397 } |
398 } | |
399 | |
400 | |
401 int | |
402 CreateSpan::run(void *rbuf, void *wbuf) | |
403 { | |
404 PolygonPack *pp = (PolygonPack*)smanager->get_input(0); | |
405 PolygonPack *next_pp = | |
406 (PolygonPack*)smanager->allocate(sizeof(PolygonPack)); | |
407 PolygonPack *free_pp = next_pp; | |
408 PolygonPack *tmp_pp; | |
409 | |
410 TrianglePackPtr triPack; | |
411 VertexPackPtr vMin, vMid, vMax; | |
412 VertexPackPtr vMid10 | |
413 = (VertexPackPtr)smanager->allocate(sizeof(VertexPack)); | |
414 | |
415 SpanPackPtr *spackList = (SpanPackPtr*)smanager->get_input(1); | |
416 spack = (SpanPackPtr)smanager->get_input(2); | |
417 send_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); | |
418 prev_index = get_param(0); | |
419 | |
420 // spack と send_spack は swap しながら DMA を繰り返すので | |
421 // 自分で allocate した send_spack を覚えてないといけない | |
422 SpanPackPtr free_spack = send_spack; | |
423 | |
424 int charge_y_top = get_param(1); | |
425 int charge_y_end = get_param(2); | |
426 | |
427 do { | |
428 if (pp->next != NULL) { | |
429 smanager->dma_load(next_pp, (uint32)pp->next, | |
430 sizeof(PolygonPack), POLYGON_PACK_LOAD); | |
431 } else { | |
432 next_pp = NULL; | |
433 } | |
434 | |
435 for (int i = 0; i < pp->info.size; i++) { | |
436 triPack = &pp->tri[i]; | |
437 | |
438 #if 0 | |
439 make_vertex(triPack, &vMin, &vMid, &vMax); | |
440 #else | |
441 if (triPack->ver1.y <= triPack->ver2.y) { | |
442 if (triPack->ver2.y <= triPack->ver3.y) { | |
443 vMin = &triPack->ver1; | |
444 vMid = &triPack->ver2; | |
445 vMax = &triPack->ver3; | |
446 } else if (triPack->ver3.y <= triPack->ver1.y) { | |
447 vMin = &triPack->ver3; | |
448 vMid = &triPack->ver1; | |
449 vMax = &triPack->ver2; | |
450 } else { | |
451 vMin = &triPack->ver1; | |
452 vMid = &triPack->ver3; | |
453 vMax = &triPack->ver2; | |
454 } | |
455 } else { | |
456 if (triPack->ver1.y <= triPack->ver3.y) { | |
457 vMin = &triPack->ver2; | |
458 vMid = &triPack->ver1; | |
459 vMax = &triPack->ver3; | |
460 } else if (triPack->ver3.y <= triPack->ver2.y) { | |
461 vMin = &triPack->ver3; | |
462 vMid = &triPack->ver2; | |
463 vMax = &triPack->ver1; | |
464 } else { | |
465 vMin = &triPack->ver2; | |
466 vMid = &triPack->ver3; | |
467 vMax = &triPack->ver1; | |
468 } | |
469 } | |
470 #endif | |
471 make_vMid10(vMid10, vMin, vMid, vMax); | |
133
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
472 |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
473 /** |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
474 * ポリゴンを、x軸に水平に分割して二つの三角形を作り、 |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
475 * それぞれから Span を求める |
435e0d24db39
DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
113
diff
changeset
|
476 */ |
109 | 477 half_triangle(spackList, charge_y_top, charge_y_end, |
478 triPack->tex_addr, triPack->tex_width, | |
479 triPack->tex_height, vMin, vMid, vMid10); | |
480 half_triangle(spackList, charge_y_top, charge_y_end, | |
481 pp->tri[0].tex_addr, pp->tri[0].tex_width, | |
482 pp->tri[0].tex_height, vMax, vMid, vMid10); | |
483 } | |
484 | |
485 smanager->dma_wait(POLYGON_PACK_LOAD); | |
486 | |
487 tmp_pp = pp; | |
488 pp = next_pp; | |
489 next_pp = tmp_pp; | |
490 } while (pp); | |
491 | |
492 smanager->dma_wait(SPAN_PACK_STORE); | |
493 smanager->dma_store(spack, (uint32)spackList[prev_index], | |
494 sizeof(SpanPack), SPAN_PACK_STORE); | |
495 smanager->dma_wait(SPAN_PACK_STORE); | |
496 | |
497 free(free_pp); | |
498 free(free_spack); | |
499 free(vMid10); | |
500 | |
501 return 0; | |
502 } |