Mercurial > hg > Members > kono > Cerium
annotate Renderer/Engine/task/DrawSpan.cc @ 616:f21603a335aa
Rendering not yet worked.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 14 Nov 2009 20:17:37 +0900 |
parents | f7d78b3c1106 |
children | 0decff4e867b |
rev | line source |
---|---|
507 | 1 #include <stdlib.h> |
2 #include <string.h> | |
3 #include "DrawSpan.h" | |
4 #include "polygon_pack.h" | |
5 #include "texture.h" | |
6 #include "viewer_types.h" | |
7 #include "Func.h" | |
8 #include "sys.h" | |
9 #include "global_alloc.h" | |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
10 #include "SchedTask.h" |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
11 #include "Tapestry.h" |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
12 #include "SpanPack.h" |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
13 |
507 | 14 |
15 SchedDefineTask(DrawSpan); | |
16 | |
17 #define TEX_LOAD1 0 | |
18 #define TEX_LOAD2 1 | |
19 #define SPAN_PACK_LOAD 2 | |
20 #define FB_STORE 3 | |
21 | |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
22 typedef struct { |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
23 int **linebuf; |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
24 float *zRow; |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
25 TileListPtr tileList; |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
26 int doneWrite; |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
27 } G, *Gptr; |
603
42c94f85c779
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
28 |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
29 static int** linebuf_init(SchedTask *smanager, int width, int height, int rgb); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
30 static float* zRow_init(SchedTask *smanager, int width, int height); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
31 // static TilePtr set_rgb(memaddr addr, int wait_tag); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
32 // static void set_rgbs(memaddr addr, uint32 *max_addr, int wait_tag); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
33 static uint32 get_rgb(int tx, int ty, TilePtr tile); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
34 // static TilePtr isAvailableTile(memaddr addr); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
35 static memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
36 static int getTexBlock(int tx, int ty, int twidth); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
37 static void updateBuffer(Gptr g, float zpos, int rangex, int x, int y, |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
38 int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z, TilePtr tile); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
39 |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
40 |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
41 // static void reboot(SpanPackPtr spack, int cur_span_x); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
42 |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
43 static int drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
44 //static void drawDot2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
45 static int drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
46 // static void drawLine2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
47 static int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
48 |
507 | 49 |
50 /** | |
51 * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する | |
52 * | |
53 * +---+---+---+---+---+---+ | |
54 * | 0 | 1 | 2 | 3 | 4 | 5 | | |
55 * +---+---+---+---+---+---+ | |
56 * | | | | | |11 | | |
57 * +---+---+---+---+---+---+ | |
58 * | | | | | |17 | | |
59 * +---+---+---+---+---+---+ | |
60 * | | | | | |23 | | |
61 * +---+---+---+---+---+---+ | |
62 * | | | | | |29 | | |
63 * +---+---+---+---+---+---+ | |
64 * | | | | | |35 | | |
65 * +---+---+---+---+---+---+ | |
66 * | |
67 * 一辺を TEXTURE_SPLIT とする | |
68 * 各ブロックの数字がブロックIDとなる。 | |
69 */ | |
70 | |
71 /** | |
72 * テクスチャの座標から、 | |
73 * テクスチャのどのブロックかを求める | |
74 * | |
75 * @param[in] tx X coordinates of texture | |
76 * @param[in] tx Y coordinates of texture | |
77 * @param[in] twidth Width of texture | |
78 * @return block ID | |
79 */ | |
80 static int | |
81 getTexBlock(int tx, int ty, int twidth) | |
82 { | |
83 int blockX, blockY; | |
84 | |
85 blockX = tx / TEXTURE_SPLIT_PIXEL; | |
86 blockY = ty / TEXTURE_SPLIT_PIXEL; | |
87 | |
88 return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY; | |
89 } | |
90 | |
91 /** | |
92 * block ID と、テクスチャの TOP address から | |
93 * (tx,ty) で使われるテクスチャの Tile addres を求める | |
94 * | |
95 * @param[in] tx X coordinates of texture | |
96 * @param[in] tx Y coordinates of texture | |
97 * @param[in] tw Width of texture | |
98 * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address | |
99 * @return block ID | |
100 */ | |
101 static memaddr | |
102 getTile(int tx, int ty, int tw, memaddr tex_addr_top) | |
103 { | |
104 int block = getTexBlock(tx, ty, tw); | |
105 return tex_addr_top + block * TEXTURE_BLOCK_SIZE * sizeof(uint32); | |
106 } | |
107 | |
108 /** | |
109 * FrameBuffer に書き込む rgb の領域初期化 | |
110 * | |
111 * @param width Width of Buffer | |
112 * @param height Height of Buffer | |
113 * @param rgb Initial value of RGB at Buffer | |
114 * @return Buffer | |
115 */ | |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
116 static int ** |
507 | 117 linebuf_init(SchedTask *smanager, int width, int height, int rgb) |
118 { | |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
119 int **linebuf = (int**)smanager->allocate(height*sizeof(int*)); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
120 for(int h = 0;h<height;h++) { |
616
f21603a335aa
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
121 int *buf = linebuf[h] = (int*)smanager->get_output(h); |
f21603a335aa
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
122 for (int i = 0; i < width; i++) { |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
123 buf[i] = rgb; |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
124 } |
507 | 125 } |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
126 return linebuf; |
507 | 127 } |
128 | |
129 /** | |
130 * Z-Buffer の初期化 | |
131 * | |
132 * @param width Width of Z-Buffer | |
133 * @param height Height of Z-Buffer | |
134 * @return Z-Buffer | |
135 */ | |
136 static float* | |
137 zRow_init(SchedTask *smanager, int width, int height) | |
138 { | |
139 float *buf = (float*)smanager->allocate(sizeof(float)*width*height); | |
140 float def = 65535.0f; | |
141 | |
142 for (int i = 0; i < width*height; i++) { | |
143 buf[i] = def; | |
144 } | |
145 | |
146 return buf; | |
147 } | |
148 | |
149 | |
150 static uint32 | |
151 get_rgb(int tx, int ty, TilePtr tile) | |
152 { | |
153 uint32 *data = (uint32 *)tile->data; | |
154 return data[(TEXTURE_SPLIT_PIXEL)*ty+tx]; | |
155 } | |
156 | |
157 | |
158 | |
159 /** | |
160 * zRow と Linebuf を更新する | |
161 * | |
162 * @param zpos 更新する pixel のZ座標 | |
163 * @param rangex このタスクが処理する描画領域の x の長さ | |
164 * @param x pixel の、描画領域内での x 座標 | |
165 * @param y 〃 の、y 座標 | |
166 * @param tex_x pixel が使用するテクスチャの、Tile (8x8) 内での x 座標 | |
167 * @param tex_y 〃 の y 座標 | |
168 * @param tex_addr テクスチャのアドレス(MainMemory) | |
169 */ | |
170 static void | |
171 updateBuffer(Gptr g, float zpos, int rangex, int x, int y, int tex_x, int tex_y, | |
172 float normal_x, float normal_y, float normal_z, TilePtr tile) | |
173 { | |
174 | |
175 int color = get_rgb(tex_x, tex_y, tile); | |
176 /*下位4bitを抽出*/ | |
599 | 177 int alpha = color & 0x000000ff; |
507 | 178 /*完全に透けているか判断*/ |
179 int flag = (alpha != 0); | |
180 | |
181 color = infinity_light_calc(color,normal_x,normal_y,normal_z); | |
182 | |
183 g->zRow[x + (rangex*y)] = zpos*flag + g->zRow[x + (rangex*y)]*(1-flag); | |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
184 int *point = &g->linebuf[y][x] ; |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
185 *point = color*flag + *point *(1-flag); |
507 | 186 |
187 } | |
188 | |
189 /** | |
190 * 長さが 1 の Span の描画 (要するに 1 pixel) | |
191 * | |
192 * @param span Span | |
193 * @param startx 描画開始範囲 | |
194 * @param endx 描画終了範囲 | |
195 */ | |
196 static int | |
197 drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag) | |
198 { | |
199 int rangex = endx - startx + 1; | |
200 | |
201 float normal_x = span->normal_x; | |
202 float normal_y = span->normal_y; | |
203 float normal_z = span->normal_z; | |
204 | |
205 | |
206 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */ | |
207 int tex_xpos, tex_ypos; | |
208 | |
209 // span の始点に対応する Texture の座標 (tex1, tey1) | |
210 float tex = span->tex_x1; | |
211 float tey = span->tex_y1; | |
212 | |
213 // span の始点に対応する z 座標 | |
214 float zpos = span->start_z; | |
215 | |
216 /* Tile 内での座標 */ | |
217 int localx = getLocalX(span->x-1); | |
218 int localy = getLocalY(span->y-1); | |
219 | |
220 /** | |
221 * (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と | |
222 * そのブロックのアドレス(MainMemory) | |
223 */ | |
224 int tex_localx; | |
225 int tex_localy; | |
226 memaddr tex_addr; | |
227 | |
228 if (span->x < startx || endx < span->x) { | |
229 return -1; | |
230 } | |
231 | |
232 tex_xpos = (int)((span->tex_width-1) * tex); | |
233 tex_ypos = (int)((span->tex_height-1) * tey); | |
234 | |
235 if (zpos < g->zRow[localx + (rangex*localy)]) { | |
236 tex_addr = getTile(tex_xpos, tex_ypos, | |
237 span->tex_width, (memaddr)span->tex_addr); | |
238 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; | |
239 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; | |
240 | |
241 TilePtr tile = smanager->get_segment(tex_addr,g->tileList); | |
242 smanager->wait_segment(tile); | |
243 | |
244 updateBuffer(g, zpos, rangex, localx, localy, | |
245 tex_localx, tex_localy, | |
246 normal_x,normal_y,normal_z,tile); | |
247 } | |
248 | |
249 return -1; | |
250 } | |
251 | |
252 #if 0 | |
253 static void | |
254 drawDot2(SchedTask *smanager, SpanPtr span, int startx, int end, int js, int wait_tag) | |
255 { | |
256 //printf("%d\n", js); | |
257 } | |
258 #endif | |
259 | |
260 /** | |
261 * 長さが 1 より大きい Span の描画 | |
262 * | |
263 * 本来の目的として、この関数(drawLine1) では | |
264 * : 既に SPE 上に Tile のある pixel だけ描画 | |
265 * : それ以外は、ここで予め DMA load しておき、 | |
266 * : drawLine2 で一気に描画する | |
267 * ってものだったんだけど、どうも上手く行かなかったので | |
268 * 今は drawLine1 で load -> wait -> rendering を全部やってます | |
269 * (rendering といっても、rendering buffer に書き込むだけで | |
270 * まだ main memory (frame buffer) に dma store してるわけではない) | |
271 * | |
272 * @param span Span | |
273 * @param startx 描画開始範囲 | |
274 * @param endx 描画終了範囲 | |
275 * @return 「span のどの位置まで rendering が終わったか」の x 座標 | |
276 */ | |
277 static int | |
278 drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag) | |
279 { | |
280 int x = span->x; | |
281 int rangex = endx - startx + 1; | |
282 int x_len = span->length_x; | |
283 | |
284 float normal_x = span->normal_x; | |
285 float normal_y = span->normal_y; | |
286 float normal_z = span->normal_z; | |
287 | |
288 | |
289 int js = (x < startx) ? startx - x : 0; | |
290 int je = (x + x_len > endx) ? endx - x : x_len; | |
291 | |
292 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */ | |
293 int tex_xpos, tex_ypos; | |
294 | |
295 // span の始点に対応する座標 (tex1, tey1) | |
296 float tex1 = span->tex_x1; | |
297 float tey1 = span->tex_y1; | |
298 | |
299 // span の終点に対応する座標 (tex2, tey2) | |
300 float tex2 = span->tex_x2; | |
301 float tey2 = span->tex_y2; | |
302 | |
303 // span の始点、終点に対応する z 座標 | |
304 float zpos1 = span->start_z; | |
305 float zpos2 = span->end_z; | |
306 | |
307 // Tile 内での座標 | |
308 int localx, localy = getLocalY(span->y-1); | |
309 | |
310 int ret = je+1; | |
311 | |
312 //for (int j = js; j <= je; j++) { | |
313 for (int j = je; j >= js; j--) { | |
314 float tex_x, tex_y, tex_z; | |
315 | |
316 localx = getLocalX(x-1+j); | |
317 | |
318 tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1); | |
319 | |
320 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); | |
321 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1); | |
322 if (tex_x > 1) tex_x = 1; | |
323 if (tex_x < 0) tex_x = 0; | |
324 if (tex_y > 1) tex_y = 1; | |
325 if (tex_y < 0) tex_y = 0; | |
326 tex_xpos = (int)((span->tex_width-1) * tex_x); | |
327 tex_ypos = (int)((span->tex_height-1) * tex_y); | |
328 | |
329 if (tex_z < g->zRow[localx + (rangex*localy)]) { | |
330 // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と | |
331 // そのブロックのアドレス(MainMemory) | |
332 memaddr tex_addr; | |
333 int tex_localx; | |
334 int tex_localy; | |
335 | |
336 tex_addr = getTile(tex_xpos, tex_ypos, | |
337 span->tex_width, (memaddr)span->tex_addr); | |
338 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; | |
339 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; | |
340 TilePtr tile = smanager->get_segment(tex_addr,g->tileList); | |
341 smanager->wait_segment(tile); | |
342 | |
343 updateBuffer(g, tex_z, rangex, localx, localy, | |
344 tex_localx, tex_localy, | |
345 normal_x, normal_y, normal_z, tile); | |
346 } | |
347 } | |
348 | |
349 return ret; | |
350 } | |
351 | |
352 static int | |
353 infinity_light_calc(int color,float normal_x, float normal_y, float normal_z) | |
354 { | |
355 unsigned char rgb[4]; | |
356 int light_rgb; | |
357 int flag; | |
358 float normal_vector[4] = {normal_x,normal_y,normal_z,0}; | |
359 // 光のベクトル,きめうちしちゃった。どうにかする | |
360 float light_vector[4] = {0,0,-1,0}; | |
361 float inner_product; | |
362 | |
363 // 引数で受け取った color の rgb 情報の抜き出し | |
364 rgb[0] = (color & 0xff000000) >> 24; | |
365 rgb[1] = (color & 0x00ff0000) >> 16; | |
366 rgb[2] = (color & 0x0000ff00) >> 8; | |
367 rgb[3] = (color & 0x000000ff); | |
368 | |
369 // 法線ベクトルと光源ベクトルとの内積をとる | |
370 inner_product = innerProduct(normal_vector,light_vector); | |
371 // 内積がマイナスの場合は色がない。 | |
372 flag = (inner_product > 0); | |
373 | |
374 // 内積を rgb にかけていく | |
375 rgb[0] = (unsigned char)(rgb[0]*inner_product*flag); | |
376 rgb[1] = (unsigned char)(rgb[1]*inner_product*flag); | |
377 rgb[2] = (unsigned char)(rgb[2]*inner_product*flag); | |
378 | |
379 //計算した rgb を light_rgb にまとめる。 | |
380 light_rgb = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 8) + (rgb[3]); | |
381 | |
382 return light_rgb; | |
383 } | |
384 | |
385 | |
386 static int | |
387 run(SchedTask *smanager, void *rbuf, void *wbuf) | |
388 { | |
389 Gptr g = (Gptr)smanager->allocate(sizeof(G)); | |
390 | |
391 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0); | |
392 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); | |
393 SpanPackPtr free_spack = next_spack; // next_spack の free() 用 | |
394 Span *span; | |
395 | |
396 Span nop_span; | |
397 nop_span.length_x = 1; | |
398 | |
399 int (*drawFunc1[2])(SchedTask *, Gptr, SpanPtr, int, int, int) = { | |
400 &drawDot1, &drawLine1 | |
401 }; | |
402 | |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
403 // uint32 display = smanager->get_param(0); |
507 | 404 int screen_width = smanager->get_param(1); |
405 int rangex_start = smanager->get_param(2); | |
406 int rangex_end = smanager->get_param(3); | |
407 | |
408 // このタスクが担当する x の範囲 | |
409 int rangex = rangex_end - rangex_start + 1; | |
410 | |
411 // y の範囲 | |
412 int rangey = smanager->get_param(4); | |
413 g->tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST); | |
414 | |
415 g->zRow = zRow_init(smanager, rangex, rangey); | |
416 g->linebuf = linebuf_init(smanager, rangex, rangey, 0); | |
417 | |
418 int tl_tag[2] = {TEX_LOAD1, TEX_LOAD2}; | |
419 int tl_tag_flg1 = 0; | |
420 int tl_tag_flg2 = 1; | |
421 | |
422 do { | |
423 /** | |
424 * SpanPack->next が存在する場合、 | |
425 * 現在の SpanPack を処理してる間に | |
426 * 次の SpanPack の DMA 転送を行う | |
427 */ | |
428 if (spack->next != NULL) { | |
603
42c94f85c779
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
429 smanager->dma_load(next_spack, (memaddr)spack->next, |
507 | 430 sizeof(SpanPack), SPAN_PACK_LOAD); |
431 } else { | |
432 next_spack = NULL; | |
433 } | |
434 | |
435 SpanPtr resume_span = &nop_span; | |
436 int resume_span_x = 0; | |
437 | |
438 for (int t = 0; t < spack->info.size; t++) { | |
439 SpanPtr next_span; | |
440 int next_span_x; | |
441 | |
442 span = &spack->span[t]; | |
443 | |
444 /** | |
445 * span の長さによって、drawLine か drawDot を選択している | |
446 */ | |
447 next_span_x | |
448 = (*drawFunc1[(span->length_x != 1)])( | |
449 smanager, g, | |
450 span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]); | |
451 next_span = span; | |
452 | |
453 resume_span = next_span; | |
454 resume_span_x = next_span_x; | |
455 | |
456 //smanager->dma_wait(tl_tag[tl_tag_flg1]); | |
457 | |
458 tl_tag_flg1 ^= 1; | |
459 tl_tag_flg2 ^= 1; | |
460 } | |
461 | |
462 // 現在 drawLine2、drawDot2 は機能してないので | |
463 //(this->*drawFunc2[(resume_span->length_x != 1)])( | |
464 //resume_span, rangex_start, rangex_end, resume_span_x, | |
465 //tl_tag[tl_tag_flg1]); | |
466 | |
467 smanager->dma_wait(SPAN_PACK_LOAD); | |
468 | |
469 SpanPackPtr tmp_spack = spack; | |
470 spack = next_spack; | |
471 next_spack = tmp_spack; | |
472 } while (spack); | |
473 | |
474 | |
475 free(g->zRow); | |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
476 free(g->linebuf); |
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
477 free(g); |
507 | 478 |
479 //FINISH: | |
480 /** | |
481 * goto FINISH; の時は reboot なので | |
482 * linebuf, zRow は free() しない | |
483 */ | |
484 | |
485 free(free_spack); | |
486 | |
487 | |
488 return 0; | |
489 } | |
490 | |
491 /* end */ |