Mercurial > hg > Members > kono > Cerium
annotate Renderer/Engine/viewer.cc @ 985:e40dd2384357
fix light data update
author | root@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Fri, 01 Oct 2010 02:49:38 +0900 |
parents | df5185513c2d |
children | ac437c3cf766 |
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 | |
748 | 101 if (spe_num == 0) spe_num = 1; |
102 | |
507 | 103 sgroot = new SceneGraphRoot(this->width, this->height); |
572 | 104 sgroot->tmanager = manager; |
792 | 105 |
106 | |
107 int light_num = 4; | |
108 int size = sizeof(float)*4*light_num; //xyz+alfa(4) * light_num(4) | |
762 | 109 int light_size = size / sizeof(float); |
748 | 110 |
760
24a37fe8419a
first of all commit, not work Rendering/Test/create_task
hiroki
parents:
748
diff
changeset
|
111 light_xyz_stock = (float *)manager->allocate(size); |
748 | 112 light_xyz = (float *)manager->allocate(size); |
762 | 113 |
114 for (int i = 0; i < light_size ; i++) { | |
115 light_xyz[i] = 0.0f; | |
116 } | |
748 | 117 |
907 | 118 |
792 | 119 for(int i = 0; i < spe_num; i++) { |
826 | 120 |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
121 HTaskPtr data_load = manager->create_task(DataAllocate); |
748 | 122 data_load->set_param(0,(memaddr)size); |
123 data_load->set_param(1,(memaddr)Light); | |
124 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); | |
125 data_load->spawn(); | |
126 } | |
509
8148c81d2660
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
507
diff
changeset
|
127 |
792 | 128 size = light_num * sizeof(int); |
129 light_switch = (int*)manager->allocate(size); | |
793 | 130 |
792 | 131 for (int i = 0; i < light_num; i++) { |
132 light_switch[i] = 0; | |
133 } | |
134 | |
135 for(int i = 0; i < spe_num; i++) { | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
136 HTaskPtr data_load = manager->create_task(DataAllocate); |
792 | 137 data_load->set_param(0,(memaddr)size); |
138 data_load->set_param(1,(memaddr)LightSwitch); | |
139 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); | |
140 data_load->spawn(); | |
141 } | |
142 | |
143 size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング | |
144 | |
793 | 145 light_sysswitch = (int*)manager->allocate(size); |
146 | |
843
0c7d885f0c92
cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
842
diff
changeset
|
147 for (unsigned int i = 0; i < size / sizeof(int); i++) { |
793 | 148 light_sysswitch[i] = 0; |
149 } | |
150 | |
792 | 151 for(int i = 0; i < spe_num; i++) { |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
152 HTaskPtr data_load = manager->create_task(DataAllocate); |
792 | 153 data_load->set_param(0,(memaddr)size); |
154 data_load->set_param(1,(memaddr)LightSysSwitch); | |
155 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); | |
156 data_load->spawn(); | |
157 } | |
158 | |
984 | 159 start_time = get_ticks(); |
160 this_time = 0; | |
161 frames = 0; | |
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); | |
965
1089f24bc86a
removing user task from Renderer Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
926
diff
changeset
|
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 |
965
1089f24bc86a
removing user task from Renderer Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
926
diff
changeset
|
297 // switch_task->wait_for(move_task); |
507 | 298 switch_task->wait_for(draw_task); |
965
1089f24bc86a
removing user task from Renderer Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
926
diff
changeset
|
299 // move_task->spawn(); |
507 | 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(); | |
981
a193a851b5e3
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
969
diff
changeset
|
330 pixels = dev->flip_screen(pixels); |
748 | 331 |
332 for (int i = 1; i <= spackList_length; i++) { | |
333 spackList[i-1].reinit(i*split_screen_h); | |
334 } | |
335 | |
969
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
965
diff
changeset
|
336 /* ここでGameTaskの終了を待つTaskを生成しておく */ |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
965
diff
changeset
|
337 sgroot->wait_game_task = manager->create_task(Dummy,0,0,0,0); |
748 | 338 sgroot->updateControllerState(); |
339 sgroot->allExecute(width, height); | |
340 light_xyz_stock = sgroot->getLightVector(); | |
792 | 341 light_switch_stock = sgroot->getLightSwitch(); |
793 | 342 light_sysswitch_stock = sgroot->getLightSysSwitch(); |
748 | 343 //sgroot->checkRemove(); |
344 | |
345 // ここから下は Rendering という関数にする | |
346 rendering(task_next); | |
507 | 347 } |
348 | |
349 | |
350 | |
351 void | |
352 Viewer::run_collision() | |
353 { | |
354 } | |
355 | |
356 void | |
514 | 357 post2rendering(SchedTask *s, void *viewer_, void *arg) |
507 | 358 { |
359 Viewer *viewer = (Viewer *)viewer_; | |
826 | 360 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); |
507 | 361 viewer->rendering(task_next); |
362 } | |
363 | |
364 void | |
365 Viewer::rendering(HTaskPtr task_next) | |
366 { | |
748 | 367 common_rendering(task_next, sgroot); |
507 | 368 |
369 // Barrier 同期 | |
370 // run_draw() を呼ぶ post2runDraw | |
514 | 371 task_next->set_post(post2runDraw, (void*)this, 0); // set_post(function(this->run_draw()), NULL) |
507 | 372 task_next->spawn(); |
373 | |
374 // TASK_CREATE_SPAN が全て終わったら DUMMY_TASK が Viewer::run_draw() を呼ぶ | |
375 } | |
376 | |
377 static void | |
514 | 378 post2runLoop(SchedTask *s, void *viewer_, void *arg) |
507 | 379 { |
380 Viewer *viewer = (Viewer*)viewer_; | |
826 | 381 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); |
507 | 382 viewer->run_loop(task_next); |
575
0f13810d4492
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
572
diff
changeset
|
383 psx_sync_n(); |
507 | 384 } |
385 | |
386 static void | |
514 | 387 post2runDraw(SchedTask *s, void *viewer_, void *arg) |
507 | 388 { |
389 Viewer *viewer = (Viewer*)viewer_; | |
826 | 390 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); |
507 | 391 viewer->run_draw(task_next); |
392 | |
393 } | |
394 | |
395 void | |
396 Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする | |
397 { | |
398 common_draw(task_next); | |
399 | |
514 | 400 task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL) |
507 | 401 task_next->spawn(); |
402 // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ | |
403 | |
404 frames++; | |
405 } | |
406 | |
407 | |
408 static void | |
514 | 409 post2speRendering(SchedTask *s, void *viewer_, void *arg) |
507 | 410 { |
411 Viewer *viewer = (Viewer*)viewer_; | |
826 | 412 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); |
507 | 413 viewer->spe_rendering(task_next); |
414 } | |
415 | |
416 void | |
417 Viewer::spe_rendering(HTaskPtr task_next) | |
418 { | |
748 | 419 common_rendering(task_next, sgroot); |
507 | 420 |
421 this->draw_dummy->wait_for(task_next); | |
514 | 422 task_next->set_post(post2speDraw, (void*)this, 0); |
507 | 423 task_next->spawn(); |
424 | |
425 } | |
426 | |
427 static void | |
514 | 428 post2speDraw(SchedTask *s, void *viewer_, void *arg) |
507 | 429 { |
430 Viewer *viewer = (Viewer*)viewer_; | |
826 | 431 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0); |
507 | 432 viewer->spe_draw(task_next); |
433 } | |
434 | |
435 void | |
436 Viewer::spe_draw(HTaskPtr task_next) | |
437 { | |
438 common_draw(task_next); | |
439 | |
440 this->draw_dummy->wait_for(task_next); | |
441 task_next->spawn(); | |
442 this->draw_dummy->spawn(); | |
443 | |
444 frames++; | |
445 } | |
446 | |
907 | 447 |
908 | 448 // 完全にMac仕様。。sg_matrix を allocate してやらないといけないよ。 |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
449 float* |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
450 copy_matrix(SceneGraphPtr sg, TaskManager *manager) { |
908 | 451 |
452 float *matrix = sg->matrix; | |
453 float *real_matrix = sg->real_matrix; | |
454 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
455 //変換行列は4x4 なんで、16。が二つで32.と言い訳を書いてみる。 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
456 float *sg_matrix = (float*)manager->allocate(sizeof(float)*32); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
457 |
908 | 458 for (int i = 0; i < 16; i++) { |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
459 sg_matrix[i] = matrix[i]; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
460 sg_matrix[i+16] = real_matrix[i]; |
908 | 461 } |
462 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
463 return sg_matrix; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
464 |
908 | 465 } |
466 | |
467 void | |
468 print_matrix(float *matrix) { | |
469 | |
470 for (int i = 0; i < 32; i++) { | |
471 printf("%f\n",matrix[i]); | |
472 } | |
473 | |
474 } | |
907 | 475 |
476 void | |
477 add_matrix_list(SceneGraphPtr sg, TaskManager *manager, MatrixListInfo* info) { | |
478 | |
479 MatrixList *matrix_list = (MatrixList*)manager->allocate(sizeof(MatrixList)); | |
908 | 480 |
481 #if SPE_CREATE_POLYGON_CHECK | |
482 print_matrix(sg->sg_matrix); | |
483 #endif | |
484 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
485 matrix_list->matrix = copy_matrix(sg, manager);; |
907 | 486 matrix_list->next = NULL; |
908 | 487 |
907 | 488 |
489 if (info->last != NULL) { | |
490 info->last->next = matrix_list; | |
491 } | |
492 | |
493 info->last = matrix_list; | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
494 info->list_length += 1; |
907 | 495 |
496 } | |
497 | |
498 void | |
499 new_matrix_info(SceneGraphPtr sg, TaskManager *manager, MatrixListInfo* info) { | |
500 | |
501 MatrixListInfo *next = NULL; | |
502 | |
503 if (info->id == -1) { | |
504 | |
505 info->id = sg->sgid; | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
506 info->list_length = 1; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
507 info->coord_pack = sg->coord_pack; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
508 info->coord_pack_size = sg->coord_pack_size; |
907 | 509 next = info; |
510 | |
511 } else { | |
512 | |
513 MatrixListInfo* t; | |
514 | |
515 for (t = info; t->next != NULL; t = t->next) { | |
516 } | |
517 | |
518 next = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo)); | |
519 next->id = sg->sgid; | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
520 next->list_length = 1; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
521 next->coord_pack = sg->coord_pack; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
522 next->coord_pack_size = sg->coord_pack_size; |
907 | 523 next->next = NULL; |
524 t->next = next; | |
525 | |
526 } | |
527 | |
528 MatrixList *new_list = (MatrixList*)manager->allocate(sizeof(MatrixList)); | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
529 new_list->matrix = copy_matrix(sg, manager); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
530 |
908 | 531 #if SPE_CREATE_POLYGON_CHECK |
532 print_matrix(sg->sg_matrix); | |
533 #endif | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
534 |
907 | 535 new_list->next = NULL; |
536 | |
537 next->first = new_list; | |
538 next->last = new_list; | |
539 | |
540 } | |
541 | |
542 void | |
543 collect_matrix(SceneGraphPtr sg, MatrixListInfo *matrix_info, TaskManager *manager) { | |
544 | |
545 matrix_info->id = -1; | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
546 matrix_info->list_length = 0; |
907 | 547 matrix_info->next = NULL; |
548 matrix_info->first = NULL; | |
549 matrix_info->last = NULL; | |
550 | |
551 while (sg) { | |
552 | |
553 if (sg->flag_drawable) { | |
554 | |
555 int flag = 0; | |
556 | |
557 for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) { | |
558 if (sg->sgid == t->id) { | |
559 add_matrix_list(sg, manager, t); | |
560 flag = 1; | |
561 } | |
562 } | |
563 | |
564 if (flag != 1) { | |
565 new_matrix_info(sg, manager, matrix_info); | |
566 } | |
567 | |
568 // search SceneGraph. でも、ただのリストがあったハズだから、あとでそれに直す。はず・・ | |
569 if (sg->children != NULL) { | |
570 sg = sg->children; | |
571 } else if (sg->brother != NULL) { | |
572 sg = sg->brother; | |
573 } else { | |
574 while (sg) { | |
575 if (sg->brother != NULL) { | |
576 sg = sg->brother; | |
577 break; | |
578 } else { | |
579 if (sg->parent == NULL) { | |
580 sg = NULL; | |
581 break; | |
582 } else { | |
583 sg = sg->parent; | |
584 } | |
585 } | |
586 } | |
587 } | |
588 } | |
589 } | |
590 } | |
591 | |
908 | 592 void |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
593 check_matrix(MatrixListInfo *matrix_info,SceneGraphPtr sg) { |
908 | 594 |
595 for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) { | |
596 for (MatrixList* u = t->first; u != NULL; u = u->next) { | |
597 print_matrix(u->matrix); | |
598 } | |
599 } | |
600 | |
601 } | |
602 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
603 |
908 | 604 void |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
605 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
|
606 int alloc_size, HTaskPtr alloc_wait, TaskManager *manager) |
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 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
609 for (int i = 0; i < spe_num; i++) { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
610 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
611 HTaskPtr data_alloc = manager->create_task(DataAllocate); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
612 //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
|
613 data_alloc->set_param(0,(memaddr)alloc_size); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
614 data_alloc->set_param(1,(memaddr)SG_COORD); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
615 data_alloc->set_cpu((CPU_TYPE)((int)SPE_0 + i)); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
616 alloc_wait->wait_for(data_alloc); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
617 data_alloc->spawn(); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
618 |
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 cur_point += alloc_size / sizeof(float); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
622 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
623 } |
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 void |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
626 coord_free(int spe_num, TaskManager *manager, HTaskPtr alloc_wait) |
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 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
629 for (int i = 0; i < spe_num; i++) { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
630 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
631 HTaskPtr data_free = manager->create_task(DataFree); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
632 data_free->set_param(0,(memaddr)SG_COORD); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
633 data_free->set_cpu((CPU_TYPE)((int)SPE_0 + i)); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
634 data_free->wait_for(alloc_wait); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
635 data_free->spawn(); |
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 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
639 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
640 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
641 void |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
642 create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next) |
907 | 643 { |
644 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
645 MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo)); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
646 collect_matrix(sg, matrix_info, manager); |
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 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
649 //HTaskPtr phase_wait = manager->create_task(Dummy); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
650 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
651 for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
652 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
653 printf("list_length %d \n", t->list_length); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
654 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
655 int alloc_size = 16*1024; |
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 if (t->coord_pack_size < alloc_size) { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
658 alloc_size = t->coord_pack_size; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
659 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
660 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
661 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
662 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
|
663 int phase_num = (division_num + spe_num -1) / spe_num; |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
664 int cur_point = 0; |
907 | 665 |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
666 for (int i = 0; i < phase_num; i++) { |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
667 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
668 HTaskPtr alloc_wait = manager->create_task(Dummy); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
669 coord_allocate(cur_point, t->coord_pack, spe_num, |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
670 alloc_size, alloc_wait, manager); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
671 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
672 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
673 for (MatrixList* u = t->first; u != NULL; u = u->next) { |
907 | 674 |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
675 //HTaskPtr free_wait = manager->create_task(Dummy); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
676 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
677 //phase_wait = manager->create_task(Dummy); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
678 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
679 } |
907 | 680 |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
681 coord_free(spe_num, manager, alloc_wait); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
682 alloc_wait->spawn(); |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
683 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
684 } |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
685 |
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
686 printf("-----------------------\n"); |
908 | 687 //return create_pp_wait; |
907 | 688 |
689 } | |
690 | |
860 | 691 void |
748 | 692 Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot) |
507 | 693 { |
860 | 694 |
695 #if SPE_CREATE_POLYGON | |
696 | |
907 | 697 SceneGraphPtr sg = sgroot->getDrawSceneGraph(); |
698 | |
915
ad10d6d39ca6
create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents:
914
diff
changeset
|
699 create_pp_task(sg, manager, spe_num, task_next); |
907 | 700 |
908 | 701 #if SPE_CREATE_POLYGON_CHECK |
702 check_matrix(matrix_info,sg); | |
703 #endif | |
704 | |
907 | 705 |
909 | 706 |
707 #else | |
907 | 708 |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
709 HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); |
969
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
965
diff
changeset
|
710 HTaskPtr game_task = sgroot->wait_game_task; |
507 | 711 // SceneGraph(木構造) -> PolygonPack |
712 | |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
713 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
|
714 task_create_pp->set_param(1,(memaddr)ppack); |
969
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
965
diff
changeset
|
715 /* GameTaskの終了を待ってからポリゴンを作る */ |
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
965
diff
changeset
|
716 task_create_pp->wait_for(game_task); |
507 | 717 |
718 task_next->wait_for(task_create_pp); | |
748 | 719 |
909 | 720 #endif |
721 | |
748 | 722 int range_base = spe_num; |
723 | |
507 | 724 // 切り上げのつもり |
725 int range = (spackList_length + range_base - 1) / range_base; | |
726 | |
727 for (int i = 0; i < range_base; i++) { | |
728 int index_start = range*i; | |
729 int index_end = (index_start + range >= spackList_length) | |
730 ? spackList_length : index_start + range; | |
731 | |
652 | 732 HTaskPtr task_create_sp = manager->create_task(CreateSpan); |
507 | 733 |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
734 task_create_sp->set_param(0,index_start); |
748 | 735 |
507 | 736 /** |
737 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲 | |
738 * [ 1.. 80] [ 81..160] [161..240] | |
739 * [241..320] [321..400] [401..480] | |
740 * | |
741 * ex. screen_height が 1080, spenum が 5 の場合、 | |
742 * [ 1..216] [217..432] [433..648] | |
743 * [649..864] [865..1080] | |
744 */ | |
748 | 745 |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
746 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
|
747 task_create_sp->set_param(2,index_end*split_screen_h); |
507 | 748 |
652 | 749 task_create_sp->add_inData(ppack, sizeof(PolygonPack)); |
750 task_create_sp->add_inData(spackList_ptr, | |
751 sizeof(SpanPack*)*spackList_length_align); | |
752 task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack)); | |
753 | |
507 | 754 task_next->wait_for(task_create_sp); |
755 task_create_sp->wait_for(task_create_pp); | |
756 | |
748 | 757 task_create_sp->set_cpu(SPE_ANY); |
507 | 758 task_create_sp->spawn(); |
759 } | |
760 | |
860 | 761 task_create_pp->spawn(); |
969
9a53faae88d8
add new function for dandy.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
965
diff
changeset
|
762 game_task->spawn(); |
507 | 763 } |
764 | |
792 | 765 |
507 | 766 void |
767 Viewer::common_draw(HTaskPtr task_next) | |
768 { | |
769 | |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
770 //task_next = manager->create_task(Dummy); |
507 | 771 //task_next->set_post(post2runLoop, (void*)this); |
772 | |
792 | 773 //Light info update |
748 | 774 |
792 | 775 int light_num = 4; |
776 int size = sizeof(float)*4*light_num; //xyz+alpha(4) * light_num(4) | |
762 | 777 int light_size = size / sizeof(float); |
748 | 778 |
762 | 779 for (int i = 0; i < light_size; i++) { |
792 | 780 light_xyz[i] = light_xyz_stock[i]; |
762 | 781 } |
792 | 782 |
783 for (int i = 0; i < light_num; i++) { | |
784 light_switch[i] = light_switch_stock[i]; | |
785 } | |
793 | 786 |
787 light_sysswitch[0] = light_sysswitch_stock; | |
985 | 788 |
789 | |
790 HTask *data_update_wait = 0; | |
791 for (int i = 0; i < spe_num; i++) { | |
792 data_update_wait = manager->create_task(DataUpdate); | |
793 data_update_wait->set_param(0,3); | |
794 data_update_wait->set_param(1,Light); // GlobalSet ID base | |
795 data_update_wait->set_inData(0,light_xyz,size); // Light | |
796 data_update_wait->set_inData(1,light_switch,light_num * sizeof(int)); // LightSwitch = Light+1 | |
797 data_update_wait->set_inData(2,light_sysswitch,16); // LightSysSwitch = Light+2 | |
798 data_update_wait->set_cpu((CPU_TYPE)(SPE_0+i)); | |
799 data_update_wait->spawn(); | |
792 | 800 } |
801 | |
748 | 802 |
507 | 803 ppack->clear(); |
914 | 804 |
507 | 805 for (int i = 0; i < spackList_length; i++) { |
806 SpanPack *spack = &spackList[i]; | |
807 int startx = 1; | |
808 int endx = split_screen_w; | |
809 | |
810 int starty = spack->info.y_top - split_screen_h + 1; | |
811 //int endy = spack->info.y_top; | |
812 int rangey = (starty + split_screen_h - 1 > this->height) | |
813 ? this->height - starty + 1 : split_screen_h; | |
814 | |
889
b150914f5976
minor fix. Redering Engine not worked yet.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
885
diff
changeset
|
815 #if 1 |
857 | 816 |
914 | 817 // mem_flag は spe 側で黒い部分を 0 で埋めるフラグ |
818 if(spack->info.size > 0 || mem_flag == 1) { | |
838 | 819 |
857 | 820 int array_task_num = (this->width + split_screen_w - 1) / split_screen_w; |
821 HTaskPtr task_draw_array = manager->create_task_array(DrawSpan, array_task_num, 6, 1, rangey); | |
822 Task *task_draw = 0; | |
823 | |
824 while (startx < this->width) { | |
825 | |
839 | 826 // Draw SpanPack |
857 | 827 |
839 | 828 task_draw = task_draw_array->next_task_array(DrawSpan,task_draw); |
829 task_draw->set_param(0,(memaddr)&pixels[(startx-1) + this->width*(starty-1)]); | |
830 task_draw->set_param(1,this->width); | |
831 task_draw->set_param(2,startx); | |
832 task_draw->set_param(3,endx); | |
833 task_draw->set_param(4,rangey); | |
834 task_draw->set_param(5,spack->info.size); | |
838 | 835 |
839 | 836 task_draw->set_inData(0,spack, sizeof(SpanPack)); |
837 | |
838 for (int i = 0; i < rangey; i++) { | |
857 | 839 task_draw->set_outData(i, |
840 &pixels[(startx-1) + this->width*(starty-1 + i) ], | |
841 (endx-startx+1)*sizeof(int)); | |
839 | 842 } |
843 | |
844 startx += split_screen_w; | |
845 endx += split_screen_w; | |
846 | |
847 if (endx > this->width) { | |
848 endx = this->width; | |
849 } | |
850 | |
857 | 851 } |
852 | |
853 task_draw_array->spawn_task_array(task_draw->next()); | |
854 task_draw_array->set_cpu(SPE_ANY); | |
855 task_next->wait_for(task_draw_array); | |
856 task_draw_array->spawn(); | |
854 | 857 |
857 | 858 |
914 | 859 |
860 } else { | |
861 | |
857 | 862 memset(&pixels[(startx-1)+this->width*(starty-1)], |
863 0, (this->width)*sizeof(int)*rangey); | |
838 | 864 |
914 | 865 } |
866 | |
857 | 867 |
868 #else | |
838 | 869 |
870 HTaskPtr task_draw; | |
871 | |
507 | 872 while (startx < this->width) { |
857 | 873 if (spack->info.size > 0) { |
507 | 874 // Draw SpanPack |
614
4e44147d78ee
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
875 task_draw = manager->create_task(DrawSpan); |
507 | 876 |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
877 task_draw->set_param(0, |
603
42c94f85c779
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
878 (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
|
879 task_draw->set_param(1,this->width); |
652 | 880 task_draw->set_param(2,startx); |
881 task_draw->set_param(3,endx); | |
882 task_draw->set_param(4,rangey); | |
838 | 883 task_draw->set_param(5,spack->info.size); |
652 | 884 |
885 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
|
886 |
616
f21603a335aa
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
887 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
|
888 task_draw->add_outData( |
616
f21603a335aa
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
889 &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
|
890 (endx-startx+1)*sizeof(int)); |
615
f7d78b3c1106
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
614
diff
changeset
|
891 } |
838 | 892 |
857 | 893 } else { |
507 | 894 // 7.7.3 SL1 Data Cache Range Set to Zero コマンド |
895 // を使って、DMAでclearするべき... ということは、 | |
896 // それもSPEでやる方が良い? | |
857 | 897 memset(&pixels[(startx-1)+this->width*(starty-1)], |
898 0, (this->width)*sizeof(int)*rangey); | |
899 break; | |
900 } | |
507 | 901 |
748 | 902 task_draw->set_cpu(SPE_ANY); |
507 | 903 task_next->wait_for(task_draw); |
904 task_draw->spawn(); | |
905 | |
906 startx += split_screen_w; | |
907 endx += split_screen_w; | |
908 | |
909 if (endx > this->width) { | |
910 endx = this->width; | |
911 } | |
912 } | |
838 | 913 #endif |
914 | |
792 | 915 } |
916 | |
925
9da903858400
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
917 if (profile) { |
983 | 918 if (frames % 50 == 49) { |
984 | 919 manager->show_profile(); |
983 | 920 this_time = get_ticks(); |
921 if (this_time != start_time) { | |
984 | 922 printf("\n%f FPS\n", ((((float)frames)*1000.0)/(this_time-start_time))); |
983 | 923 start_time = this_time; frames = 0; |
924 } | |
982
b29547a5b85b
avoid WAIT in virtual console
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
981
diff
changeset
|
925 } |
925
9da903858400
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
926 } |
748 | 927 } |
928 | |
929 void | |
930 Viewer::run_finish() | |
931 { | |
932 dev->free_device(); | |
933 if (this_time != start_time) { | |
934 printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0); | |
935 } | |
925
9da903858400
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
936 if (profile) { |
9da903858400
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
937 manager->show_profile(); |
9da903858400
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
938 } |
748 | 939 |
940 delete sgroot; | |
941 // delete sgroot_2; | |
942 quit(); | |
507 | 943 } |
944 | |
945 /* end */ |