Mercurial > hg > Members > kono > Cerium
annotate Renderer/Engine/viewer.cc @ 652:dbe137505f2e
bulk task list start.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 23 Nov 2009 12:01:45 +0900 |
parents | 60aa3f241b10 |
children | e201be3f6897 b7376415fa5f |
rev | line source |
---|---|
507 | 1 #include <SDL.h> |
2 #include "viewer.h" | |
3 #include "viewer_types.h" | |
4 #include "SceneGraph.h" | |
5 #include "SceneGraphRoot.h" | |
6 #include "scene_graph_pack.h" | |
7 #include "sys.h" | |
8 #include "Func.h" | |
9 #include "error.h" | |
10 #include "TaskManager.h" | |
11 #include <wchar.h> | |
12 #include "Pad.h" | |
511 | 13 #include "Application.h" |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
572
diff
changeset
|
14 #include "lindaapi.h" |
507 | 15 |
523 | 16 static void post2runLoop(SchedTask *s,void *viewer,void *s1); |
17 static void post2runDraw(SchedTask *s,void *viewer,void *s1); | |
18 static void post2speRendering(SchedTask *s,void *viewer,void *s1); | |
19 static void post2speDraw(SchedTask *s,void *viewer,void *s1); | |
20 static void post2runMoveDrawLoop(SchedTask *s,void *viewer,void *s1); | |
507 | 21 |
22 /* measure for FPS (Frame Per Second) */ | |
23 int start_time; | |
24 int this_time; | |
25 int frames; | |
514 | 26 // static void post2speRunLoop(void *viewer); |
27 //static void post2runMove(void *viewer); | |
28 //static void post2exchange_sgroot(void *viewer); | |
29 //static void post2speRunLoop(void *viewer); | |
507 | 30 |
31 //SceneGraphRootPtr sgroot_2; | |
32 | |
33 /* Data Pack sent to Other CPUs (ex. SPE) */ | |
34 SceneGraphPack *sgpack; | |
35 PolygonPack *ppack; | |
36 SpanPackPtr spackList; | |
37 SpanPackPtr *spackList_ptr; | |
38 | |
39 int spackList_length; | |
40 int spackList_length_align; | |
41 | |
42 /** | |
43 * | |
44 */ | |
45 | |
46 Viewer::Viewer(int b, int w, int h, int _num) | |
47 { | |
48 bpp = b; | |
49 width = w; | |
50 height = h; | |
51 spe_num = _num; | |
52 } | |
53 | |
54 int | |
55 Viewer::get_ticks(void) | |
56 { | |
57 int time; | |
58 time = SDL_GetTicks(); | |
59 return time; | |
60 } | |
61 | |
62 bool | |
63 Viewer::quit_check(void) | |
64 { | |
65 SDL_Event event; | |
66 | |
67 while(SDL_PollEvent(&event)) { | |
68 if (event.type==SDL_QUIT) { | |
69 return true; | |
70 } | |
71 } | |
72 | |
73 Uint8 *keys=SDL_GetKeyState(NULL); | |
74 | |
75 if (keys[SDLK_q] == SDL_PRESSED) { | |
76 return true; | |
77 } | |
78 | |
79 return false; | |
80 } | |
81 | |
82 void | |
83 Viewer::quit(void) | |
84 { | |
85 SDL_Quit(); | |
86 } | |
87 | |
88 void | |
89 Viewer::swap_buffers(void) | |
90 { | |
91 SDL_GL_SwapBuffers(); | |
92 } | |
93 | |
94 | |
95 void | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
96 Viewer::run_init(TaskManager *manager, Application *app) |
507 | 97 { |
98 this->manager = manager; | |
99 | |
100 start_time = get_ticks(); | |
101 this_time = 0; | |
102 frames = 0; | |
103 | |
104 sgroot = new SceneGraphRoot(this->width, this->height); | |
572 | 105 sgroot->tmanager = manager; |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
106 |
511 | 107 MainLoop *mainloop = app->init(this, this->width, this->height); |
507 | 108 |
511 | 109 mainloop->mainLoop(); |
507 | 110 } |
111 | |
112 | |
113 HTaskPtr | |
114 Viewer::initLoop() | |
115 { | |
116 HTaskPtr task_next; | |
117 HTaskPtr task_tex; | |
118 | |
119 sgpack = (SceneGraphPack*)manager->allocate(sizeof(SceneGraphPack)); | |
120 sgpack->init(); | |
121 ppack = (PolygonPack*)manager->allocate(sizeof(PolygonPack)); | |
122 | |
123 spackList_length = (this->height + split_screen_h - 1) / split_screen_h; | |
124 spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*spackList_length); | |
125 | |
126 /** | |
127 * SPU に送る address list は 16 バイト倍数でないといけない。 | |
128 * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような | |
129 * length_align を求めている。はみ出した部分は使われない | |
130 * (ex) spackList_length が 13 の場合 | |
131 * spackList_length_align = 16; | |
132 * 実際に送るデータは64バイトになるのでOK | |
133 * 14,15,16 の部分は何も入らない。 | |
134 */ | |
135 spackList_length_align = (spackList_length + 3)&(~3); | |
136 | |
137 /* 各 SPU が持つ、SpanPack の address list */ | |
138 spackList_ptr = | |
139 (SpanPack**)manager->allocate(sizeof(SpanPack*)*spackList_length_align); | |
140 | |
141 for (int i = 0; i < spackList_length; i++) { | |
142 spackList_ptr[i] = &spackList[i]; | |
143 } | |
144 | |
145 for (int i = 1; i <= spackList_length; i++) { | |
146 spackList[i-1].init(i*split_screen_h); | |
147 } | |
148 | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
149 task_next = manager->create_task(Dummy); |
507 | 150 |
652 | 151 // ここは、Iterator を用意するべきだよね |
507 | 152 for (int i = 0; i < spe_num; i++) { |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
153 task_tex = manager->create_task(LoadTexture); |
507 | 154 task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + i)); |
155 task_next->wait_for(task_tex); | |
156 task_tex->spawn(); | |
157 } | |
158 | |
159 return task_next; | |
160 } | |
161 | |
162 /* Loop って言っても1回しか実行されない */ | |
163 void | |
164 Viewer::speLoop() | |
165 { | |
166 HTaskPtr task_next = initLoop(); | |
167 // key の情報を格納する領域を確保する (global_alloc(KEY_STATUS)) | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
168 HTaskPtr init_key_task = manager->create_task(InitKey); |
507 | 169 init_key_task->set_cpu(SPE_0); |
170 init_key_task->spawn(); | |
171 | |
172 // SPE に送信する KEY_STATUS の領域確保 | |
173 key_stat *key = (key_stat*)manager->allocate(sizeof(key_stat)); | |
174 this->keyPtr = key; | |
175 | |
176 // post2runLoop は旧バージョン用なので post2speRunLoop の様なものを別につくるべき | |
177 //task_next->set_post(post2speRunLoop, (void*)this); // set_post(function(this->run_loop()), NULL) | |
178 //task_next->spawn(); | |
179 // TASK_INIT_TEXTURE が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ | |
180 | |
181 /* test */ | |
182 | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
183 HTaskPtr task_switch = manager->create_task(Switch); |
507 | 184 task_switch->wait_for(task_next); |
514 | 185 task_switch->set_post(post2runMoveDrawLoop, (void*)this, 0); |
507 | 186 task_switch->spawn(); |
187 } | |
188 | |
189 void | |
190 Viewer::getKey() | |
191 { | |
192 Pad *pad = sgroot->getController(); | |
193 if (pad->right.isHold()) { | |
194 keyPtr->right = HOLD; | |
195 } else if (pad->right.isPush()) { | |
196 keyPtr->right = PUSH; | |
197 } else { | |
198 keyPtr->right = NONE; | |
199 } | |
200 | |
201 if (pad->left.isHold()) { | |
202 keyPtr->left = HOLD; | |
203 } else if (pad->left.isPush()) { | |
204 keyPtr->left = PUSH; | |
205 } else { | |
206 keyPtr->left = NONE; | |
207 } | |
208 | |
209 if (pad->up.isHold()) { | |
210 keyPtr->up = HOLD; | |
211 } else if (pad->up.isPush()) { | |
212 keyPtr->up = PUSH; | |
213 } else { | |
214 keyPtr->up = NONE; | |
215 } | |
216 | |
217 if (pad->down.isHold()) { | |
218 keyPtr->down = HOLD; | |
219 } else if (pad->down.isPush()) { | |
220 keyPtr->down = PUSH; | |
221 } else { | |
222 keyPtr->down = NONE; | |
223 } | |
224 | |
225 if (pad->circle.isHold()) { | |
226 keyPtr->circle = HOLD; | |
227 } else if (pad->circle.isPush()) { | |
228 keyPtr->circle = PUSH; | |
229 } else { | |
230 keyPtr->circle = NONE; | |
231 } | |
232 } | |
233 | |
234 static void | |
514 | 235 post2runMoveDrawLoop(SchedTask *m, void *viewer_, void *arg) |
507 | 236 { |
237 Viewer *viewer = (Viewer*)viewer_; | |
238 | |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
239 // 同じ PPE 上なので sgroot(ポインタ) を set_param で送る。 |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
240 //HTaskPtr send_key_task = viewer->manager->create_task(SendKey); |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
241 //send_key_task->set_param((int)sgroot); |
507 | 242 // set input data -> viewer keyPtr |
243 viewer->getKey(); | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
244 HTaskPtr update_key = viewer->manager->create_task(UpdateKey); |
507 | 245 update_key->add_inData(viewer->keyPtr, sizeof(key_stat)); |
246 update_key->set_cpu(SPE_0); | |
247 update_key->spawn(); | |
248 | |
249 /* TASK_MOVE は外から引数で取ってくるべき */ | |
250 //HTaskPtr move_task = viewer->manager->create_task(viewer->app->move_taskid); | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
251 HTaskPtr move_task = viewer->manager->create_task(Move); |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
252 //move_task->set_param(sgroot); |
507 | 253 |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
254 //HTaskPtr draw_task = viewer->manager->create_task(Draw); |
507 | 255 |
256 /* rendering task test */ | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
257 HTaskPtr draw_task = viewer->manager->create_task(Dummy); |
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
258 HTaskPtr draw_dummy = viewer->manager->create_task(Dummy); |
507 | 259 |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
260 HTaskPtr switch_task = viewer->manager->create_task(Switch); |
507 | 261 viewer->draw_dummy = draw_dummy; |
262 switch_task->wait_for(draw_dummy); | |
514 | 263 draw_task->set_post(post2speRendering, (void*)viewer, 0); |
507 | 264 |
265 switch_task->wait_for(move_task); | |
266 switch_task->wait_for(draw_task); | |
267 move_task->spawn(); | |
268 draw_task->spawn(); | |
269 | |
514 | 270 switch_task->set_post(post2runMoveDrawLoop, (void*)viewer, 0); |
507 | 271 switch_task->spawn(); |
272 | |
273 } | |
274 | |
275 #if 0 | |
276 static void | |
277 post2speRunLoop(void *viewer_) | |
278 { | |
279 Viewer *viewer = (Viewer *)viewer_; | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
280 HTaskPtr task_next = viewer->manager->create_task(Dummy); |
507 | 281 viewer->run_move(task_next); |
282 } | |
283 #endif | |
284 | |
285 void | |
286 Viewer::mainLoop() | |
287 { | |
288 HTaskPtr task_next = initLoop(); | |
289 | |
514 | 290 task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL) |
507 | 291 task_next->spawn(); |
292 } | |
293 | |
294 #if 0 | |
295 void | |
296 post2runMove(void *viewer_) | |
297 { | |
298 Viewer *viewer = (Viewer*)viewer_; | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
299 HTaskPtr task_next = viewer->manager->create_task(Dummy); |
507 | 300 viewer->run_move(task_next); |
301 } | |
302 #endif | |
303 | |
304 | |
305 void | |
306 Viewer::run_move(HTaskPtr task_next) | |
307 { | |
308 sgroot->updateControllerState(); | |
309 sgroot->allExecute(width, height); | |
310 } | |
311 | |
312 void | |
313 Viewer::run_collision() | |
314 { | |
315 } | |
316 | |
317 void | |
514 | 318 post2rendering(SchedTask *s, void *viewer_, void *arg) |
507 | 319 { |
320 Viewer *viewer = (Viewer *)viewer_; | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
321 HTaskPtr task_next = viewer->manager->create_task(Dummy); |
507 | 322 viewer->rendering(task_next); |
323 } | |
324 | |
325 void | |
326 Viewer::rendering(HTaskPtr task_next) | |
327 { | |
328 common_rendering(task_next); | |
329 | |
330 // Barrier 同期 | |
331 // run_draw() を呼ぶ post2runDraw | |
514 | 332 task_next->set_post(post2runDraw, (void*)this, 0); // set_post(function(this->run_draw()), NULL) |
507 | 333 task_next->spawn(); |
334 | |
335 // TASK_CREATE_SPAN が全て終わったら DUMMY_TASK が Viewer::run_draw() を呼ぶ | |
336 } | |
337 | |
338 static void | |
514 | 339 post2runLoop(SchedTask *s, void *viewer_, void *arg) |
507 | 340 { |
341 Viewer *viewer = (Viewer*)viewer_; | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
342 HTaskPtr task_next = viewer->manager->create_task(Dummy); |
507 | 343 viewer->run_loop(task_next); |
344 | |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
572
diff
changeset
|
345 psx_sync_n(); |
507 | 346 } |
347 | |
348 void | |
349 Viewer::run_loop(HTaskPtr task_next) | |
350 { | |
351 bool quit_flg; | |
352 quit_flg = quit_check(); | |
353 if (quit_flg == true) { | |
354 this_time = get_ticks(); | |
355 run_finish(); | |
356 return; | |
357 } | |
358 | |
359 clean_pixels(); | |
360 | |
361 for (int i = 1; i <= spackList_length; i++) { | |
362 spackList[i-1].reinit(i*split_screen_h); | |
363 } | |
364 | |
365 //run_move(task_next); | |
366 sgroot->updateControllerState(); | |
367 sgroot->allExecute(width, height); | |
368 //sgroot->checkRemove(); | |
369 | |
370 // ここから下は Rendering という関数にする | |
371 rendering(task_next); | |
372 } | |
373 | |
374 static void | |
514 | 375 post2runDraw(SchedTask *s, void *viewer_, void *arg) |
507 | 376 { |
377 Viewer *viewer = (Viewer*)viewer_; | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
378 HTaskPtr task_next = viewer->manager->create_task(Dummy); |
507 | 379 viewer->run_draw(task_next); |
380 | |
381 } | |
382 | |
383 void | |
384 Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする | |
385 { | |
386 common_draw(task_next); | |
387 | |
514 | 388 task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL) |
507 | 389 task_next->spawn(); |
390 // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ | |
391 | |
392 frames++; | |
393 } | |
394 | |
395 void | |
396 Viewer::run_finish(void) | |
397 { | |
398 if (this_time != start_time) { | |
399 printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0); | |
400 } | |
401 | |
402 delete sgroot; | |
403 // delete sgroot_2; | |
404 quit(); | |
405 } | |
406 | |
407 static void | |
514 | 408 post2speRendering(SchedTask *s, void *viewer_, void *arg) |
507 | 409 { |
410 Viewer *viewer = (Viewer*)viewer_; | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
411 HTaskPtr task_next = viewer->manager->create_task(Dummy); |
507 | 412 viewer->spe_rendering(task_next); |
413 } | |
414 | |
415 void | |
416 Viewer::spe_rendering(HTaskPtr task_next) | |
417 { | |
418 common_rendering(task_next); | |
419 | |
420 this->draw_dummy->wait_for(task_next); | |
514 | 421 task_next->set_post(post2speDraw, (void*)this, 0); |
507 | 422 task_next->spawn(); |
423 | |
424 } | |
425 | |
426 static void | |
514 | 427 post2speDraw(SchedTask *s, void *viewer_, void *arg) |
507 | 428 { |
429 Viewer *viewer = (Viewer*)viewer_; | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
430 HTaskPtr task_next = viewer->manager->create_task(Dummy); |
507 | 431 viewer->spe_draw(task_next); |
432 } | |
433 | |
434 void | |
435 Viewer::spe_draw(HTaskPtr task_next) | |
436 { | |
437 common_draw(task_next); | |
438 | |
439 this->draw_dummy->wait_for(task_next); | |
440 task_next->spawn(); | |
441 this->draw_dummy->spawn(); | |
442 | |
443 frames++; | |
444 } | |
445 | |
446 void | |
447 Viewer::common_rendering(HTaskPtr task_next) | |
448 { | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
449 HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); |
507 | 450 |
451 // SceneGraph(木構造) -> PolygonPack | |
452 | |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
453 task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph()); |
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
454 task_create_pp->set_param(1,(memaddr)ppack); |
507 | 455 |
456 task_next->wait_for(task_create_pp); | |
457 | |
458 int range_base = spe_num; | |
459 // 切り上げのつもり | |
460 int range = (spackList_length + range_base - 1) / range_base; | |
461 | |
462 for (int i = 0; i < range_base; i++) { | |
463 int index_start = range*i; | |
464 int index_end = (index_start + range >= spackList_length) | |
465 ? spackList_length : index_start + range; | |
466 | |
652 | 467 HTaskPtr task_create_sp = manager->create_task(CreateSpan); |
507 | 468 |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
469 task_create_sp->set_param(0,index_start); |
507 | 470 |
471 /** | |
472 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲 | |
473 * [ 1.. 80] [ 81..160] [161..240] | |
474 * [241..320] [321..400] [401..480] | |
475 * | |
476 * ex. screen_height が 1080, spenum が 5 の場合、 | |
477 * [ 1..216] [217..432] [433..648] | |
478 * [649..864] [865..1080] | |
479 */ | |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
480 task_create_sp->set_param(1,index_start*split_screen_h + 1); |
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
481 task_create_sp->set_param(2,index_end*split_screen_h); |
507 | 482 |
652 | 483 task_create_sp->add_inData(ppack, sizeof(PolygonPack)); |
484 task_create_sp->add_inData(spackList_ptr, | |
485 sizeof(SpanPack*)*spackList_length_align); | |
486 task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack)); | |
487 | |
507 | 488 task_next->wait_for(task_create_sp); |
489 task_create_sp->wait_for(task_create_pp); | |
490 | |
491 task_create_sp->set_cpu(SPE_ANY); | |
492 task_create_sp->spawn(); | |
493 } | |
494 | |
495 task_create_pp->spawn(); | |
496 } | |
497 | |
498 void | |
499 Viewer::common_draw(HTaskPtr task_next) | |
500 { | |
501 HTaskPtr task_draw; | |
502 | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
503 //task_next = manager->create_task(Dummy); |
507 | 504 //task_next->set_post(post2runLoop, (void*)this); |
505 | |
506 ppack->clear(); | |
507 for (int i = 0; i < spackList_length; i++) { | |
508 SpanPack *spack = &spackList[i]; | |
509 int startx = 1; | |
510 int endx = split_screen_w; | |
511 | |
512 int starty = spack->info.y_top - split_screen_h + 1; | |
513 //int endy = spack->info.y_top; | |
514 int rangey = (starty + split_screen_h - 1 > this->height) | |
515 ? this->height - starty + 1 : split_screen_h; | |
516 | |
517 while (startx < this->width) { | |
518 if (spack->info.size > 0) { | |
519 // Draw SpanPack | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
520 task_draw = manager->create_task(DrawSpan); |
507 | 521 |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
522 task_draw->set_param(0, |
603
42c94f85c779
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
523 (memaddr)&pixels[(startx-1) + this->width*(starty-1)]); |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
524 task_draw->set_param(1,this->width); |
652 | 525 task_draw->set_param(2,startx); |
526 task_draw->set_param(3,endx); | |
527 task_draw->set_param(4,rangey); | |
528 | |
529 task_draw->add_inData(spack, sizeof(SpanPack)); | |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
530 |
616
f21603a335aa
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
531 for (int i = 0; i < rangey; i++) { |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
532 task_draw->add_outData( |
616
f21603a335aa
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
533 &pixels[(startx-1) + this->width*(starty-1 + i) ], |
f21603a335aa
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
534 (endx-startx+1)*sizeof(int)); |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
535 } |
507 | 536 } else { |
537 // 7.7.3 SL1 Data Cache Range Set to Zero コマンド | |
538 // を使って、DMAでclearするべき... ということは、 | |
539 // それもSPEでやる方が良い? | |
540 memset(&pixels[(startx-1)+this->width*(starty-1)], | |
541 0, (this->width)*sizeof(int)*rangey); | |
542 break; | |
543 } | |
544 | |
545 task_draw->set_cpu(SPE_ANY); | |
546 task_next->wait_for(task_draw); | |
547 task_draw->spawn(); | |
548 | |
549 startx += split_screen_w; | |
550 endx += split_screen_w; | |
551 | |
552 if (endx > this->width) { | |
553 endx = this->width; | |
554 } | |
555 } | |
556 } | |
557 } | |
558 | |
559 /* end */ |