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