Mercurial > hg > Members > kono > Cerium
annotate Renderer/Engine/viewer.cc @ 918:49b3c753e209
add loadelf in tmp/old.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 25 Jul 2010 10:46:45 +0900 |
parents | ad10d6d39ca6 |
children | 9da903858400 |
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 | |
907 | 42 |
507 | 43 /** |
44 * | |
45 */ | |
46 | |
748 | 47 Viewer::Viewer(TaskManager *m, ViewerDevice *vd, int b, int w, int h, int _num) |
507 | 48 { |
49 spe_num = _num; | |
748 | 50 manager = m; |
895
bed529c55eda
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
891
diff
changeset
|
51 |
748 | 52 dev = vd; |
53 pixels = dev->video_init(manager, b, w, h); | |
54 | |
895
bed529c55eda
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
891
diff
changeset
|
55 width = dev->width; |
bed529c55eda
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
891
diff
changeset
|
56 height = dev->height; |
bed529c55eda
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
891
diff
changeset
|
57 bpp = dev->bpp; |
bed529c55eda
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
891
diff
changeset
|
58 |
507 | 59 } |
60 | |
61 int | |
62 Viewer::get_ticks(void) | |
63 { | |
64 int time; | |
65 time = SDL_GetTicks(); | |
66 return time; | |
67 } | |
68 | |
69 bool | |
70 Viewer::quit_check(void) | |
71 { | |
72 SDL_Event event; | |
73 | |
74 while(SDL_PollEvent(&event)) { | |
75 if (event.type==SDL_QUIT) { | |
76 return true; | |
77 } | |
78 } | |
79 | |
80 Uint8 *keys=SDL_GetKeyState(NULL); | |
81 | |
82 if (keys[SDLK_q] == SDL_PRESSED) { | |
83 return true; | |
84 } | |
85 | |
86 return false; | |
87 } | |
88 | |
89 void | |
90 Viewer::quit(void) | |
91 { | |
92 SDL_Quit(); | |
93 } | |
94 | |
95 | |
96 void | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
97 Viewer::run_init(TaskManager *manager, Application *app) |
507 | 98 { |
99 this->manager = manager; | |
100 | |
101 start_time = get_ticks(); | |
102 this_time = 0; | |
103 frames = 0; | |
104 | |
748 | 105 if (spe_num == 0) spe_num = 1; |
106 | |
507 | 107 sgroot = new SceneGraphRoot(this->width, this->height); |
572 | 108 sgroot->tmanager = manager; |
792 | 109 |
110 | |
111 int light_num = 4; | |
112 int size = sizeof(float)*4*light_num; //xyz+alfa(4) * light_num(4) | |
762 | 113 int light_size = size / sizeof(float); |
748 | 114 |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
748
diff
changeset
|
115 light_xyz_stock = (float *)manager->allocate(size); |
748 | 116 light_xyz = (float *)manager->allocate(size); |
762 | 117 |
118 for (int i = 0; i < light_size ; i++) { | |
119 light_xyz[i] = 0.0f; | |
120 } | |
748 | 121 |
907 | 122 |
792 | 123 for(int i = 0; i < spe_num; i++) { |
826 | 124 |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
125 HTaskPtr data_load = manager->create_task(DataAllocate); |
748 | 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 |
792 | 132 size = light_num * sizeof(int); |
133 light_switch = (int*)manager->allocate(size); | |
793 | 134 |
792 | 135 for (int i = 0; i < light_num; i++) { |
136 light_switch[i] = 0; | |
137 } | |
138 | |
139 for(int i = 0; i < spe_num; i++) { | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
140 HTaskPtr data_load = manager->create_task(DataAllocate); |
792 | 141 data_load->set_param(0,(memaddr)size); |
142 data_load->set_param(1,(memaddr)LightSwitch); | |
143 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); | |
144 data_load->spawn(); | |
145 } | |
146 | |
147 size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング | |
148 | |
793 | 149 light_sysswitch = (int*)manager->allocate(size); |
150 | |
843
0c7d885f0c92
cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
842
diff
changeset
|
151 for (unsigned int i = 0; i < size / sizeof(int); i++) { |
793 | 152 light_sysswitch[i] = 0; |
153 } | |
154 | |
792 | 155 for(int i = 0; i < spe_num; i++) { |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
156 HTaskPtr data_load = manager->create_task(DataAllocate); |
792 | 157 data_load->set_param(0,(memaddr)size); |
158 data_load->set_param(1,(memaddr)LightSysSwitch); | |
159 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); | |
160 data_load->spawn(); | |
161 } | |
162 | |
511 | 163 MainLoop *mainloop = app->init(this, this->width, this->height); |
164 mainloop->mainLoop(); | |
507 | 165 } |
166 | |
167 | |
168 HTaskPtr | |
169 Viewer::initLoop() | |
170 { | |
171 HTaskPtr task_next; | |
172 HTaskPtr task_tex; | |
173 | |
174 sgpack = (SceneGraphPack*)manager->allocate(sizeof(SceneGraphPack)); | |
175 sgpack->init(); | |
176 ppack = (PolygonPack*)manager->allocate(sizeof(PolygonPack)); | |
177 | |
178 spackList_length = (this->height + split_screen_h - 1) / split_screen_h; | |
179 spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*spackList_length); | |
918
49b3c753e209
add loadelf in tmp/old.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
915
diff
changeset
|
180 // printf("spackList %0lx height %d\n",(unsigned long)spackList, this->height); |
507 | 181 |
182 /** | |
183 * SPU に送る address list は 16 バイト倍数でないといけない。 | |
184 * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような | |
185 * length_align を求めている。はみ出した部分は使われない | |
186 * (ex) spackList_length が 13 の場合 | |
187 * spackList_length_align = 16; | |
188 * 実際に送るデータは64バイトになるのでOK | |
189 * 14,15,16 の部分は何も入らない。 | |
190 */ | |
191 spackList_length_align = (spackList_length + 3)&(~3); | |
192 | |
193 /* 各 SPU が持つ、SpanPack の address list */ | |
194 spackList_ptr = | |
195 (SpanPack**)manager->allocate(sizeof(SpanPack*)*spackList_length_align); | |
196 | |
197 for (int i = 0; i < spackList_length; i++) { | |
198 spackList_ptr[i] = &spackList[i]; | |
199 } | |
200 | |
201 for (int i = 1; i <= spackList_length; i++) { | |
202 spackList[i-1].init(i*split_screen_h); | |
203 } | |
204 | |
826 | 205 task_next = manager->create_task(Dummy,0,0,0,0); |
507 | 206 |
652 | 207 // ここは、Iterator を用意するべきだよね |
507 | 208 for (int i = 0; i < spe_num; i++) { |
826 | 209 task_tex = manager->create_task(LoadTexture,0,0,0,0); |
210 task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + i)); | |
211 task_next->wait_for(task_tex); | |
748 | 212 task_tex->spawn(); |
507 | 213 } |
214 | |
792 | 215 |
507 | 216 return task_next; |
217 } | |
218 | |
219 | |
220 void | |
221 Viewer::getKey() | |
222 { | |
223 Pad *pad = sgroot->getController(); | |
224 if (pad->right.isHold()) { | |
225 keyPtr->right = HOLD; | |
226 } else if (pad->right.isPush()) { | |
227 keyPtr->right = PUSH; | |
228 } else { | |
229 keyPtr->right = NONE; | |
230 } | |
231 | |
232 if (pad->left.isHold()) { | |
233 keyPtr->left = HOLD; | |
234 } else if (pad->left.isPush()) { | |
235 keyPtr->left = PUSH; | |
236 } else { | |
237 keyPtr->left = NONE; | |
238 } | |
239 | |
240 if (pad->up.isHold()) { | |
241 keyPtr->up = HOLD; | |
242 } else if (pad->up.isPush()) { | |
243 keyPtr->up = PUSH; | |
244 } else { | |
245 keyPtr->up = NONE; | |
246 } | |
247 | |
248 if (pad->down.isHold()) { | |
249 keyPtr->down = HOLD; | |
250 } else if (pad->down.isPush()) { | |
251 keyPtr->down = PUSH; | |
252 } else { | |
253 keyPtr->down = NONE; | |
254 } | |
255 | |
256 if (pad->circle.isHold()) { | |
257 keyPtr->circle = HOLD; | |
258 } else if (pad->circle.isPush()) { | |
259 keyPtr->circle = PUSH; | |
260 } else { | |
261 keyPtr->circle = NONE; | |
262 } | |
263 } | |
264 | |
265 static void | |
514 | 266 post2runMoveDrawLoop(SchedTask *m, void *viewer_, void *arg) |
507 | 267 { |
268 Viewer *viewer = (Viewer*)viewer_; | |
269 | |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
270 // 同じ PPE 上なので sgroot(ポインタ) を set_param で送る。 |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
271 //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
|
272 //send_key_task->set_param((int)sgroot); |
507 | 273 // set input data -> viewer keyPtr |
274 viewer->getKey(); | |
826 | 275 //HTaskPtr update_key = viewer->manager->create_task(UpdateKey,viewer->keyPtr, sizeof(key_stat),0,0); |
276 HTaskPtr update_key = viewer->manager->create_task(UpdateKey,0,0,0,0); | |
507 | 277 update_key->add_inData(viewer->keyPtr, sizeof(key_stat)); |
748 | 278 //update_key->set_cpu(SPE_0); |
507 | 279 update_key->spawn(); |
280 | |
281 /* TASK_MOVE は外から引数で取ってくるべき */ | |
282 //HTaskPtr move_task = viewer->manager->create_task(viewer->app->move_taskid); | |
826 | 283 HTaskPtr move_task = viewer->manager->create_task(Move,0,0,0,0); |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
284 //move_task->set_param(sgroot); |
507 | 285 |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
286 //HTaskPtr draw_task = viewer->manager->create_task(Draw); |
507 | 287 |
288 /* rendering task test */ | |
826 | 289 HTaskPtr draw_task = viewer->manager->create_task(Dummy,0,0,0,0); |
290 HTaskPtr draw_dummy = viewer->manager->create_task(Dummy,0,0,0,0); | |
507 | 291 |
826 | 292 HTaskPtr switch_task = viewer->manager->create_task(Switch,0,0,0,0); |
507 | 293 viewer->draw_dummy = draw_dummy; |
294 switch_task->wait_for(draw_dummy); | |
514 | 295 draw_task->set_post(post2speRendering, (void*)viewer, 0); |
507 | 296 |
297 switch_task->wait_for(move_task); | |
298 switch_task->wait_for(draw_task); | |
299 move_task->spawn(); | |
300 draw_task->spawn(); | |
301 | |
514 | 302 switch_task->set_post(post2runMoveDrawLoop, (void*)viewer, 0); |
507 | 303 switch_task->spawn(); |
304 | |
305 } | |
306 | |
307 void | |
308 Viewer::mainLoop() | |
309 { | |
310 HTaskPtr task_next = initLoop(); | |
311 | |
514 | 312 task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL) |
507 | 313 task_next->spawn(); |
314 } | |
315 | |
316 void | |
748 | 317 Viewer::run_loop(HTaskPtr task_next) |
507 | 318 { |
748 | 319 dev->clear_screen(); |
320 | |
321 bool quit_flg; | |
322 quit_flg = quit_check(); | |
323 if (quit_flg == true) { | |
324 this_time = get_ticks(); | |
325 run_finish(); | |
326 return; | |
327 } | |
328 | |
329 dev->clean_pixels(); | |
330 | |
331 for (int i = 1; i <= spackList_length; i++) { | |
332 spackList[i-1].reinit(i*split_screen_h); | |
333 } | |
334 | |
335 sgroot->updateControllerState(); | |
336 sgroot->allExecute(width, height); | |
337 light_xyz_stock = sgroot->getLightVector(); | |
792 | 338 light_switch_stock = sgroot->getLightSwitch(); |
793 | 339 light_sysswitch_stock = sgroot->getLightSysSwitch(); |
748 | 340 //sgroot->checkRemove(); |
341 | |
342 // ここから下は Rendering という関数にする | |
343 rendering(task_next); | |
507 | 344 } |
345 | |
346 | |
347 | |
348 void | |
349 Viewer::run_collision() | |
350 { | |
351 } | |
352 | |
353 void | |
514 | 354 post2rendering(SchedTask *s, void *viewer_, void *arg) |
507 | 355 { |
356 Viewer *viewer = (Viewer *)viewer_; | |
826 | 357 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); |
507 | 358 viewer->rendering(task_next); |
359 } | |
360 | |
361 void | |
362 Viewer::rendering(HTaskPtr task_next) | |
363 { | |
748 | 364 common_rendering(task_next, sgroot); |
507 | 365 |
366 // Barrier 同期 | |
367 // run_draw() を呼ぶ post2runDraw | |
514 | 368 task_next->set_post(post2runDraw, (void*)this, 0); // set_post(function(this->run_draw()), NULL) |
507 | 369 task_next->spawn(); |
370 | |
371 // TASK_CREATE_SPAN が全て終わったら DUMMY_TASK が Viewer::run_draw() を呼ぶ | |
372 } | |
373 | |
374 static void | |
514 | 375 post2runLoop(SchedTask *s, void *viewer_, void *arg) |
507 | 376 { |
377 Viewer *viewer = (Viewer*)viewer_; | |
826 | 378 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); |
507 | 379 viewer->run_loop(task_next); |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
572
diff
changeset
|
380 psx_sync_n(); |
507 | 381 } |
382 | |
383 static void | |
514 | 384 post2runDraw(SchedTask *s, void *viewer_, void *arg) |
507 | 385 { |
386 Viewer *viewer = (Viewer*)viewer_; | |
826 | 387 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); |
507 | 388 viewer->run_draw(task_next); |
389 | |
390 } | |
391 | |
392 void | |
393 Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする | |
394 { | |
395 common_draw(task_next); | |
396 | |
514 | 397 task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL) |
507 | 398 task_next->spawn(); |
399 // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ | |
400 | |
401 frames++; | |
402 } | |
403 | |
404 | |
405 static void | |
514 | 406 post2speRendering(SchedTask *s, void *viewer_, void *arg) |
507 | 407 { |
408 Viewer *viewer = (Viewer*)viewer_; | |
826 | 409 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); |
507 | 410 viewer->spe_rendering(task_next); |
411 } | |
412 | |
413 void | |
414 Viewer::spe_rendering(HTaskPtr task_next) | |
415 { | |
748 | 416 common_rendering(task_next, sgroot); |
507 | 417 |
418 this->draw_dummy->wait_for(task_next); | |
514 | 419 task_next->set_post(post2speDraw, (void*)this, 0); |
507 | 420 task_next->spawn(); |
421 | |
422 } | |
423 | |
424 static void | |
514 | 425 post2speDraw(SchedTask *s, void *viewer_, void *arg) |
507 | 426 { |
427 Viewer *viewer = (Viewer*)viewer_; | |
826 | 428 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); |
507 | 429 viewer->spe_draw(task_next); |
430 } | |
431 | |
432 void | |
433 Viewer::spe_draw(HTaskPtr task_next) | |
434 { | |
435 common_draw(task_next); | |
436 | |
437 this->draw_dummy->wait_for(task_next); | |
438 task_next->spawn(); | |
439 this->draw_dummy->spawn(); | |
440 | |
441 frames++; | |
442 } | |
443 | |
907 | 444 |
908 | 445 // 完全にMac仕様。。sg_matrix を allocate してやらないといけないよ。 |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
446 float* |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
447 copy_matrix(SceneGraphPtr sg, TaskManager *manager) { |
908 | 448 |
449 float *matrix = sg->matrix; | |
450 float *real_matrix = sg->real_matrix; | |
451 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
452 //変換行列は4x4 なんで、16。が二つで32.と言い訳を書いてみる。 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
453 float *sg_matrix = (float*)manager->allocate(sizeof(float)*32); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
454 |
908 | 455 for (int i = 0; i < 16; i++) { |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
456 sg_matrix[i] = matrix[i]; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
457 sg_matrix[i+16] = real_matrix[i]; |
908 | 458 } |
459 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
460 return sg_matrix; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
461 |
908 | 462 } |
463 | |
464 void | |
465 print_matrix(float *matrix) { | |
466 | |
467 for (int i = 0; i < 32; i++) { | |
468 printf("%f\n",matrix[i]); | |
469 } | |
470 | |
471 } | |
907 | 472 |
473 void | |
474 add_matrix_list(SceneGraphPtr sg, TaskManager *manager, MatrixListInfo* info) { | |
475 | |
476 MatrixList *matrix_list = (MatrixList*)manager->allocate(sizeof(MatrixList)); | |
908 | 477 |
478 #if SPE_CREATE_POLYGON_CHECK | |
479 print_matrix(sg->sg_matrix); | |
480 #endif | |
481 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
482 matrix_list->matrix = copy_matrix(sg, manager);; |
907 | 483 matrix_list->next = NULL; |
908 | 484 |
907 | 485 |
486 if (info->last != NULL) { | |
487 info->last->next = matrix_list; | |
488 } | |
489 | |
490 info->last = matrix_list; | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
491 info->list_length += 1; |
907 | 492 |
493 } | |
494 | |
495 void | |
496 new_matrix_info(SceneGraphPtr sg, TaskManager *manager, MatrixListInfo* info) { | |
497 | |
498 MatrixListInfo *next = NULL; | |
499 | |
500 if (info->id == -1) { | |
501 | |
502 info->id = sg->sgid; | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
503 info->list_length = 1; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
504 info->coord_pack = sg->coord_pack; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
505 info->coord_pack_size = sg->coord_pack_size; |
907 | 506 next = info; |
507 | |
508 } else { | |
509 | |
510 MatrixListInfo* t; | |
511 | |
512 for (t = info; t->next != NULL; t = t->next) { | |
513 } | |
514 | |
515 next = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo)); | |
516 next->id = sg->sgid; | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
517 next->list_length = 1; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
518 next->coord_pack = sg->coord_pack; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
519 next->coord_pack_size = sg->coord_pack_size; |
907 | 520 next->next = NULL; |
521 t->next = next; | |
522 | |
523 } | |
524 | |
525 MatrixList *new_list = (MatrixList*)manager->allocate(sizeof(MatrixList)); | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
526 new_list->matrix = copy_matrix(sg, manager); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
527 |
908 | 528 #if SPE_CREATE_POLYGON_CHECK |
529 print_matrix(sg->sg_matrix); | |
530 #endif | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
531 |
907 | 532 new_list->next = NULL; |
533 | |
534 next->first = new_list; | |
535 next->last = new_list; | |
536 | |
537 } | |
538 | |
539 void | |
540 collect_matrix(SceneGraphPtr sg, MatrixListInfo *matrix_info, TaskManager *manager) { | |
541 | |
542 matrix_info->id = -1; | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
543 matrix_info->list_length = 0; |
907 | 544 matrix_info->next = NULL; |
545 matrix_info->first = NULL; | |
546 matrix_info->last = NULL; | |
547 | |
548 while (sg) { | |
549 | |
550 if (sg->flag_drawable) { | |
551 | |
552 int flag = 0; | |
553 | |
554 for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) { | |
555 if (sg->sgid == t->id) { | |
556 add_matrix_list(sg, manager, t); | |
557 flag = 1; | |
558 } | |
559 } | |
560 | |
561 if (flag != 1) { | |
562 new_matrix_info(sg, manager, matrix_info); | |
563 } | |
564 | |
565 // search SceneGraph. でも、ただのリストがあったハズだから、あとでそれに直す。はず・・ | |
566 if (sg->children != NULL) { | |
567 sg = sg->children; | |
568 } else if (sg->brother != NULL) { | |
569 sg = sg->brother; | |
570 } else { | |
571 while (sg) { | |
572 if (sg->brother != NULL) { | |
573 sg = sg->brother; | |
574 break; | |
575 } else { | |
576 if (sg->parent == NULL) { | |
577 sg = NULL; | |
578 break; | |
579 } else { | |
580 sg = sg->parent; | |
581 } | |
582 } | |
583 } | |
584 } | |
585 } | |
586 } | |
587 } | |
588 | |
908 | 589 void |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
590 check_matrix(MatrixListInfo *matrix_info,SceneGraphPtr sg) { |
908 | 591 |
592 for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) { | |
593 for (MatrixList* u = t->first; u != NULL; u = u->next) { | |
594 print_matrix(u->matrix); | |
595 } | |
596 } | |
597 | |
598 } | |
599 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
600 |
908 | 601 void |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
602 coord_allocate(int &cur_point, float *coord_pack, int spe_num, |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
603 int alloc_size, HTaskPtr alloc_wait, TaskManager *manager) |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
604 { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
605 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
606 for (int i = 0; i < spe_num; i++) { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
607 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
608 HTaskPtr data_alloc = manager->create_task(DataAllocate); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
609 //data_alloc->set_inData(0, &coord_pack[cur_point], alloc_size); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
610 data_alloc->set_param(0,(memaddr)alloc_size); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
611 data_alloc->set_param(1,(memaddr)SG_COORD); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
612 data_alloc->set_cpu((CPU_TYPE)((int)SPE_0 + i)); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
613 alloc_wait->wait_for(data_alloc); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
614 data_alloc->spawn(); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
615 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
616 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
617 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
618 cur_point += alloc_size / sizeof(float); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
619 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
620 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
621 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
622 void |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
623 coord_free(int spe_num, TaskManager *manager, HTaskPtr alloc_wait) |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
624 { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
625 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
626 for (int i = 0; i < spe_num; i++) { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
627 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
628 HTaskPtr data_free = manager->create_task(DataFree); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
629 data_free->set_param(0,(memaddr)SG_COORD); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
630 data_free->set_cpu((CPU_TYPE)((int)SPE_0 + i)); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
631 data_free->wait_for(alloc_wait); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
632 data_free->spawn(); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
633 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
634 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
635 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
636 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
637 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
638 void |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
639 create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next) |
907 | 640 { |
641 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
642 MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo)); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
643 collect_matrix(sg, matrix_info, manager); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
644 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
645 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
646 //HTaskPtr phase_wait = manager->create_task(Dummy); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
647 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
648 for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
649 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
650 printf("list_length %d \n", t->list_length); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
651 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
652 int alloc_size = 16*1024; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
653 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
654 if (t->coord_pack_size < alloc_size) { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
655 alloc_size = t->coord_pack_size; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
656 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
657 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
658 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
659 int division_num = (t->coord_pack_size + alloc_size - 1) / alloc_size; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
660 int phase_num = (division_num + spe_num -1) / spe_num; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
661 int cur_point = 0; |
907 | 662 |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
663 for (int i = 0; i < phase_num; i++) { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
664 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
665 HTaskPtr alloc_wait = manager->create_task(Dummy); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
666 coord_allocate(cur_point, t->coord_pack, spe_num, |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
667 alloc_size, alloc_wait, manager); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
668 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
669 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
670 for (MatrixList* u = t->first; u != NULL; u = u->next) { |
907 | 671 |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
672 //HTaskPtr free_wait = manager->create_task(Dummy); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
673 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
674 //phase_wait = manager->create_task(Dummy); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
675 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
676 } |
907 | 677 |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
678 coord_free(spe_num, manager, alloc_wait); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
679 alloc_wait->spawn(); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
680 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
681 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
682 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
683 printf("-----------------------\n"); |
908 | 684 //return create_pp_wait; |
907 | 685 |
686 } | |
687 | |
860 | 688 void |
748 | 689 Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot) |
507 | 690 { |
860 | 691 |
692 #if SPE_CREATE_POLYGON | |
693 | |
907 | 694 SceneGraphPtr sg = sgroot->getDrawSceneGraph(); |
695 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
696 create_pp_task(sg, manager, spe_num, task_next); |
907 | 697 |
908 | 698 #if SPE_CREATE_POLYGON_CHECK |
699 check_matrix(matrix_info,sg); | |
700 #endif | |
701 | |
907 | 702 |
909 | 703 |
704 #else | |
907 | 705 |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
706 HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); |
507 | 707 |
708 // SceneGraph(木構造) -> PolygonPack | |
709 | |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
710 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
|
711 task_create_pp->set_param(1,(memaddr)ppack); |
507 | 712 |
713 task_next->wait_for(task_create_pp); | |
748 | 714 |
909 | 715 #endif |
716 | |
748 | 717 int range_base = spe_num; |
718 | |
507 | 719 // 切り上げのつもり |
720 int range = (spackList_length + range_base - 1) / range_base; | |
721 | |
722 for (int i = 0; i < range_base; i++) { | |
723 int index_start = range*i; | |
724 int index_end = (index_start + range >= spackList_length) | |
725 ? spackList_length : index_start + range; | |
726 | |
652 | 727 HTaskPtr task_create_sp = manager->create_task(CreateSpan); |
507 | 728 |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
729 task_create_sp->set_param(0,index_start); |
748 | 730 |
507 | 731 /** |
732 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲 | |
733 * [ 1.. 80] [ 81..160] [161..240] | |
734 * [241..320] [321..400] [401..480] | |
735 * | |
736 * ex. screen_height が 1080, spenum が 5 の場合、 | |
737 * [ 1..216] [217..432] [433..648] | |
738 * [649..864] [865..1080] | |
739 */ | |
748 | 740 |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
741 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
|
742 task_create_sp->set_param(2,index_end*split_screen_h); |
507 | 743 |
652 | 744 task_create_sp->add_inData(ppack, sizeof(PolygonPack)); |
745 task_create_sp->add_inData(spackList_ptr, | |
746 sizeof(SpanPack*)*spackList_length_align); | |
747 task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack)); | |
748 | |
507 | 749 task_next->wait_for(task_create_sp); |
750 task_create_sp->wait_for(task_create_pp); | |
751 | |
748 | 752 task_create_sp->set_cpu(SPE_ANY); |
507 | 753 task_create_sp->spawn(); |
754 } | |
755 | |
860 | 756 task_create_pp->spawn(); |
748 | 757 |
507 | 758 } |
759 | |
792 | 760 HTaskPtr |
761 Viewer::update_task_create(void *data, int size, | |
762 int load_id, int spe_id, HTaskPtr wait) | |
763 { | |
764 | |
765 HTaskPtr data_update = manager->create_task(DataUpdate); | |
766 data_update->add_inData(data,size); | |
767 data_update->set_param(0,size); | |
768 data_update->set_param(1,load_id); | |
769 data_update->set_cpu((CPU_TYPE)(spe_id)); | |
770 if (wait != NULL) { | |
771 wait->wait_for(data_update); | |
772 } | |
773 data_update->spawn(); | |
774 | |
775 return data_update; | |
776 | |
777 } | |
778 | |
507 | 779 void |
780 Viewer::common_draw(HTaskPtr task_next) | |
781 { | |
782 | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
783 //task_next = manager->create_task(Dummy); |
507 | 784 //task_next->set_post(post2runLoop, (void*)this); |
785 | |
792 | 786 //Light info update |
748 | 787 |
793 | 788 //HTaskPtr data_update; |
748 | 789 HTaskPtr data_update_wait; |
792 | 790 int light_num = 4; |
791 int size = sizeof(float)*4*light_num; //xyz+alpha(4) * light_num(4) | |
762 | 792 int light_size = size / sizeof(float); |
748 | 793 |
762 | 794 for (int i = 0; i < light_size; i++) { |
792 | 795 light_xyz[i] = light_xyz_stock[i]; |
762 | 796 } |
792 | 797 |
798 for (int i = 0; i < light_num; i++) { | |
799 light_switch[i] = light_switch_stock[i]; | |
800 } | |
793 | 801 |
802 light_sysswitch[0] = light_sysswitch_stock; | |
792 | 803 |
748 | 804 data_update_wait = manager->create_task(DataUpdate); |
805 data_update_wait->add_inData(light_xyz,size); | |
806 data_update_wait->set_param(0,size); | |
807 data_update_wait->set_param(1,Light); | |
808 data_update_wait->set_cpu((CPU_TYPE)((int)SPE_0)); | |
792 | 809 |
748 | 810 for (int i = 1; i < spe_num; i++) { |
792 | 811 update_task_create(light_xyz,size,Light,(int)SPE_0+i,data_update_wait); |
812 } | |
813 | |
814 size = light_num * sizeof(int); | |
815 | |
816 for (int i = 0; i < spe_num; i++) { | |
793 | 817 update_task_create(light_switch,size,LightSwitch,(int)SPE_0+i,data_update_wait); |
792 | 818 } |
819 | |
820 size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング | |
821 | |
822 for (int i = 0; i < spe_num; i++) { | |
793 | 823 update_task_create(light_sysswitch,size,LightSysSwitch,(int)SPE_0+i,data_update_wait); |
748 | 824 } |
825 | |
507 | 826 ppack->clear(); |
914 | 827 |
507 | 828 for (int i = 0; i < spackList_length; i++) { |
829 SpanPack *spack = &spackList[i]; | |
830 int startx = 1; | |
831 int endx = split_screen_w; | |
832 | |
833 int starty = spack->info.y_top - split_screen_h + 1; | |
834 //int endy = spack->info.y_top; | |
835 int rangey = (starty + split_screen_h - 1 > this->height) | |
836 ? this->height - starty + 1 : split_screen_h; | |
837 | |
889
b150914f5976
minor fix. Redering Engine not worked yet.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
885
diff
changeset
|
838 #if 1 |
857 | 839 |
914 | 840 // mem_flag は spe 側で黒い部分を 0 で埋めるフラグ |
841 if(spack->info.size > 0 || mem_flag == 1) { | |
838 | 842 |
857 | 843 int array_task_num = (this->width + split_screen_w - 1) / split_screen_w; |
844 HTaskPtr task_draw_array = manager->create_task_array(DrawSpan, array_task_num, 6, 1, rangey); | |
845 Task *task_draw = 0; | |
846 | |
847 while (startx < this->width) { | |
848 | |
839 | 849 // Draw SpanPack |
857 | 850 |
839 | 851 task_draw = task_draw_array->next_task_array(DrawSpan,task_draw); |
852 task_draw->set_param(0,(memaddr)&pixels[(startx-1) + this->width*(starty-1)]); | |
853 task_draw->set_param(1,this->width); | |
854 task_draw->set_param(2,startx); | |
855 task_draw->set_param(3,endx); | |
856 task_draw->set_param(4,rangey); | |
857 task_draw->set_param(5,spack->info.size); | |
838 | 858 |
839 | 859 task_draw->set_inData(0,spack, sizeof(SpanPack)); |
860 | |
861 for (int i = 0; i < rangey; i++) { | |
857 | 862 task_draw->set_outData(i, |
863 &pixels[(startx-1) + this->width*(starty-1 + i) ], | |
864 (endx-startx+1)*sizeof(int)); | |
839 | 865 } |
866 | |
867 startx += split_screen_w; | |
868 endx += split_screen_w; | |
869 | |
870 if (endx > this->width) { | |
871 endx = this->width; | |
872 } | |
873 | |
857 | 874 } |
875 | |
876 task_draw_array->spawn_task_array(task_draw->next()); | |
877 task_draw_array->set_cpu(SPE_ANY); | |
878 task_next->wait_for(task_draw_array); | |
879 task_draw_array->wait_for(data_update_wait); | |
880 task_draw_array->spawn(); | |
854 | 881 |
857 | 882 |
914 | 883 |
884 } else { | |
885 | |
857 | 886 memset(&pixels[(startx-1)+this->width*(starty-1)], |
887 0, (this->width)*sizeof(int)*rangey); | |
838 | 888 |
914 | 889 } |
890 | |
857 | 891 |
892 #else | |
838 | 893 |
894 HTaskPtr task_draw; | |
895 | |
507 | 896 while (startx < this->width) { |
857 | 897 if (spack->info.size > 0) { |
507 | 898 // Draw SpanPack |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
899 task_draw = manager->create_task(DrawSpan); |
507 | 900 |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
901 task_draw->set_param(0, |
603
42c94f85c779
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
902 (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
|
903 task_draw->set_param(1,this->width); |
652 | 904 task_draw->set_param(2,startx); |
905 task_draw->set_param(3,endx); | |
906 task_draw->set_param(4,rangey); | |
838 | 907 task_draw->set_param(5,spack->info.size); |
652 | 908 |
909 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
|
910 |
616
f21603a335aa
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
911 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
|
912 task_draw->add_outData( |
616
f21603a335aa
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
913 &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
|
914 (endx-startx+1)*sizeof(int)); |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
915 } |
838 | 916 |
857 | 917 } else { |
507 | 918 // 7.7.3 SL1 Data Cache Range Set to Zero コマンド |
919 // を使って、DMAでclearするべき... ということは、 | |
920 // それもSPEでやる方が良い? | |
857 | 921 memset(&pixels[(startx-1)+this->width*(starty-1)], |
922 0, (this->width)*sizeof(int)*rangey); | |
923 break; | |
924 } | |
507 | 925 |
748 | 926 task_draw->set_cpu(SPE_ANY); |
507 | 927 task_next->wait_for(task_draw); |
748 | 928 task_draw->wait_for(data_update_wait); |
507 | 929 task_draw->spawn(); |
930 | |
931 startx += split_screen_w; | |
932 endx += split_screen_w; | |
933 | |
934 if (endx > this->width) { | |
935 endx = this->width; | |
936 } | |
937 } | |
838 | 938 #endif |
939 | |
792 | 940 } |
941 | |
942 data_update_wait->spawn(); | |
748 | 943 |
944 } | |
945 | |
946 void | |
947 Viewer::run_finish() | |
948 { | |
949 dev->free_device(); | |
950 if (this_time != start_time) { | |
951 printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0); | |
952 } | |
953 | |
954 delete sgroot; | |
955 // delete sgroot_2; | |
956 quit(); | |
507 | 957 } |
958 | |
959 /* end */ |