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