Mercurial > hg > Game > Cerium
annotate TaskManager/Test/test_render/viewer.cc @ 421:6094dfd1f08c draft
comment
author | game@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Thu, 24 Sep 2009 12:35:32 +0900 |
parents | a3ef5c15edac |
children | 217258e3d148 |
rev | line source |
---|---|
140 | 1 #include <SDL.h> |
109 | 2 #include "viewer.h" |
120 | 3 #include "viewer_types.h" |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
133
diff
changeset
|
4 #include "SceneGraph.h" |
195 | 5 #include "SceneGraphRoot.h" |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
133
diff
changeset
|
6 #include "scene_graph_pack.h" |
109 | 7 #include "sys.h" |
8 #include "Func.h" | |
9 #include "error.h" | |
10 #include "TaskManager.h" | |
212 | 11 #include <wchar.h> |
221 | 12 #include "Pad.h" |
212 | 13 |
408 | 14 static void post2runLoop(void *viewer); |
15 static void post2runDraw(void *viewer); | |
16 static void post2speRunLoop(void *viewer); | |
399 | 17 //static void post2runMove(void *viewer); |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
18 //static void post2exchange_sgroot(void *viewer); |
408 | 19 static void post2speRunLoop(void *viewer); |
20 static void post2runMoveDrawLoop(void *viewer); | |
109 | 21 |
22 /* measure for FPS (Frame Per Second) */ | |
23 int start_time; | |
24 int this_time; | |
25 int frames; | |
26 | |
198
b832e6cff83e
rename snake_bg to panel
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
195
diff
changeset
|
27 SceneGraphRootPtr sgroot; |
415 | 28 SceneGraphRootPtr sgroot_2; |
109 | 29 |
176 | 30 /* Data Pack sent to Other CPUs (ex. SPE) */ |
109 | 31 SceneGraphPack *sgpack; |
32 PolygonPack *ppack; | |
33 SpanPackPtr spackList; | |
34 SpanPackPtr *spackList_ptr; | |
210 | 35 |
109 | 36 int spackList_length; |
37 int spackList_length_align; | |
38 | |
140 | 39 /** |
176 | 40 * |
41 */ | |
42 | |
109 | 43 Viewer::Viewer(int b, int w, int h, int _num) |
44 { | |
45 bpp = b; | |
46 width = w; | |
47 height = h; | |
48 spe_num = _num; | |
49 } | |
50 | |
51 int | |
229 | 52 Viewer::get_ticks(void) |
109 | 53 { |
54 int time; | |
55 time = SDL_GetTicks(); | |
56 return time; | |
57 } | |
58 | |
59 bool | |
229 | 60 Viewer::quit_check(void) |
109 | 61 { |
62 SDL_Event event; | |
63 | |
64 while(SDL_PollEvent(&event)) { | |
374 | 65 if (event.type==SDL_QUIT) { |
66 return true; | |
67 } | |
109 | 68 } |
69 | |
70 Uint8 *keys=SDL_GetKeyState(NULL); | |
71 | |
72 if (keys[SDLK_q] == SDL_PRESSED) { | |
374 | 73 return true; |
109 | 74 } |
75 | |
76 return false; | |
77 } | |
78 | |
79 void | |
229 | 80 Viewer::quit(void) |
109 | 81 { |
82 SDL_Quit(); | |
83 } | |
84 | |
85 void | |
229 | 86 Viewer::swap_buffers(void) |
109 | 87 { |
88 SDL_GL_SwapBuffers(); | |
89 } | |
90 | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
91 extern void node_init(TaskManager *manager); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
92 extern void create_cube_split(TaskManager *manager, int); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
93 extern void panel_init(TaskManager *manager, int bg); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
94 extern void universe_init(TaskManager *manager); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
95 extern void ieshoot_init(TaskManager *manager); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
96 extern void ball_bound_init(TaskManager *manager, int, int); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
97 extern void lcube_init(TaskManager *manager, int, int); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
98 extern void direction_init(TaskManager *manager); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
99 extern void init_position(TaskManager *manager, int, int); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
100 extern void vacuum_init(TaskManager *manager, int w, int h); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
101 extern void untitled_init(TaskManager *manager); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
102 extern void chain_init(TaskManager *manager, int w, int h); |
412
dbd70772322c
chain_old.cc add (Application/)
tkaito@henri.cr.ie.u-ryukyu.ac.jp
parents:
408
diff
changeset
|
103 extern void chain_old_init(TaskManager *manager, int w, int h); |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
104 extern void boss1_init(TaskManager *manager, int w, int h); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
105 extern void init_gaplant(TaskManager *manager, int w, int h); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
106 extern void vacuum_init2(TaskManager *manager, int w, int h); |
323 | 107 |
109 | 108 void |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
109 Viewer::run_init(TaskManager *manager, const char *xml, int sg_number) |
109 | 110 { |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
111 this->manager = manager; |
109 | 112 |
113 start_time = get_ticks(); | |
114 this_time = 0; | |
115 frames = 0; | |
116 | |
221 | 117 sgroot = new SceneGraphRoot(this->width, this->height); |
415 | 118 sgroot_2 = new SceneGraphRoot(this->width, this->height); |
195 | 119 //sgroot->createFromXMLFile(xml); |
421 | 120 // ここの switch は application->init(this, manager, sg_no); になるべき |
144 | 121 switch (sg_number) { |
122 case 0: | |
123 case 1: | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
124 create_cube_split(manager, sg_number); |
374 | 125 break; |
144 | 126 case 2: |
153
70146cdec3d4
画像のサイズテストを加える -sg = [2,3,4]
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
150
diff
changeset
|
127 case 3: |
70146cdec3d4
画像のサイズテストを加える -sg = [2,3,4]
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
150
diff
changeset
|
128 case 4: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
129 panel_init(manager, sg_number); |
374 | 130 break; |
153
70146cdec3d4
画像のサイズテストを加える -sg = [2,3,4]
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
150
diff
changeset
|
131 case 5: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
132 universe_init(manager); |
374 | 133 break; |
158 | 134 case 6: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
135 ieshoot_init(manager); |
374 | 136 break; |
210 | 137 case 7: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
138 ball_bound_init(manager, this->width, this->height); |
374 | 139 break; |
212 | 140 case 8: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
141 lcube_init(manager, this->width, this->height); |
374 | 142 break; |
212 | 143 case 9: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
144 direction_init(manager); |
374 | 145 break; |
213
8ac35507094d
add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents:
212
diff
changeset
|
146 case 10: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
147 init_position(manager, this->width, this->height); |
374 | 148 break; |
222 | 149 case 11: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
150 // vacuum_init(manager, this->width, this->height); |
374 | 151 break; |
231
5ae15a5d3dc5
test program add (-sg 12)
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents:
229
diff
changeset
|
152 case 12: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
153 untitled_init(manager); |
231
5ae15a5d3dc5
test program add (-sg 12)
tkaito@nw0534.st.ie.u-ryukyu.ac.jp
parents:
229
diff
changeset
|
154 break; |
321 | 155 case 13: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
156 boss1_init(manager, this->width, this->height); |
378 | 157 break; |
158 case 14: | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
159 init_gaplant(manager, this->width, this->height); |
378 | 160 break; |
161 case 15: | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
162 vacuum_init2(manager, this->width, this->height); |
378 | 163 break; |
164 case 16: | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
165 chain_init(manager, this->width, this-> height); |
398 | 166 speLoop(); |
399 | 167 return; |
374 | 168 break; |
412
dbd70772322c
chain_old.cc add (Application/)
tkaito@henri.cr.ie.u-ryukyu.ac.jp
parents:
408
diff
changeset
|
169 case 17: |
dbd70772322c
chain_old.cc add (Application/)
tkaito@henri.cr.ie.u-ryukyu.ac.jp
parents:
408
diff
changeset
|
170 chain_old_init(manager, this->width, this-> height); |
dbd70772322c
chain_old.cc add (Application/)
tkaito@henri.cr.ie.u-ryukyu.ac.jp
parents:
408
diff
changeset
|
171 break; |
144 | 172 default: |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
173 node_init(manager); |
374 | 174 break; |
398 | 175 } |
176 | |
177 mainLoop(); | |
178 } | |
179 | |
180 | |
399 | 181 HTaskPtr |
398 | 182 Viewer::initLoop() |
183 { | |
184 HTaskPtr task_next; | |
185 HTaskPtr task_tex; | |
142 | 186 |
217 | 187 sgpack = (SceneGraphPack*)manager->allocate(sizeof(SceneGraphPack)); |
109 | 188 sgpack->init(); |
217 | 189 ppack = (PolygonPack*)manager->allocate(sizeof(PolygonPack)); |
109 | 190 |
191 spackList_length = (this->height + split_screen_h - 1) / split_screen_h; | |
217 | 192 spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*spackList_length); |
109 | 193 |
176 | 194 /** |
195 * SPU に送る address list は 16 バイト倍数でないといけない。 | |
196 * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような | |
197 * length_align を求めている。はみ出した部分は使われない | |
198 * (ex) spackList_length が 13 の場合 | |
199 * spackList_length_align = 16; | |
200 * 実際に送るデータは64バイトになるのでOK | |
201 * 14,15,16 の部分は何も入らない。 | |
202 */ | |
109 | 203 spackList_length_align = (spackList_length + 3)&(~3); |
204 | |
205 /* 各 SPU が持つ、SpanPack の address list */ | |
167
508beb59e0eb
DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
158
diff
changeset
|
206 spackList_ptr = |
374 | 207 (SpanPack**)manager->allocate(sizeof(SpanPack*)*spackList_length_align); |
109 | 208 |
209 for (int i = 0; i < spackList_length; i++) { | |
374 | 210 spackList_ptr[i] = &spackList[i]; |
109 | 211 } |
212 | |
126
74d0a70f60e9
fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
123
diff
changeset
|
213 for (int i = 1; i <= spackList_length; i++) { |
374 | 214 spackList[i-1].init(i*split_screen_h); |
126
74d0a70f60e9
fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
123
diff
changeset
|
215 } |
74d0a70f60e9
fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents:
123
diff
changeset
|
216 |
109 | 217 task_next = manager->create_task(TASK_DUMMY); |
399 | 218 |
167
508beb59e0eb
DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents:
158
diff
changeset
|
219 for (int i = 0; i < spe_num; i++) { |
374 | 220 task_tex = manager->create_task(TASK_INIT_TEXTURE); |
378 | 221 /* |
222 * ここはもう少しわかりやすい使い方がいいかもしれぬ。こんなもん? | |
223 */ | |
374 | 224 task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + i)); |
225 task_next->wait_for(task_tex); | |
226 task_tex->spawn(); | |
120 | 227 } |
399 | 228 |
229 return task_next; | |
398 | 230 } |
231 | |
417 | 232 /* Loop って言っても1回しか実行されない */ |
399 | 233 void |
398 | 234 Viewer::speLoop() |
235 { | |
399 | 236 HTaskPtr task_next = initLoop(); |
417 | 237 // key の情報を格納する領域を確保する (global_alloc(KEY_STATUS)) |
238 HTaskPtr init_key_task = manager->create_task(INIT_KEY_TASK); | |
239 init_key_task->spawn(); | |
240 | |
241 // SPE に送信する KEY_STATUS の領域確保 | |
242 key_stat *key = (key_stat*)manager->allocate(sizeof(key_stat)); | |
243 this->keyPtr = key; | |
398 | 244 |
406 | 245 // post2runLoop は旧バージョン用なので post2speRunLoop の様なものを別につくるべき |
421 | 246 //task_next->set_post(post2speRunLoop, (void*)this); // set_post(function(this->run_loop()), NULL) |
247 //task_next->spawn(); | |
398 | 248 // TASK_INIT_TEXTURE が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ |
406 | 249 |
250 /* test */ | |
415 | 251 |
406 | 252 HTaskPtr task_switch = manager->create_task(TASK_SWITCH); |
253 task_switch->wait_for(task_next); | |
254 task_switch->set_post(post2runMoveDrawLoop, (void*)this); | |
415 | 255 task_switch->spawn(); |
406 | 256 } |
257 | |
417 | 258 void |
259 Viewer::getKey() | |
260 { | |
261 Pad *pad = sgroot->getController(); | |
262 if (pad->right.isHold()) { | |
263 keyPtr->right = HOLD; | |
264 } else if (pad->right.isPush()) { | |
265 keyPtr->right = PUSH; | |
266 } else { | |
267 keyPtr->right = NONE; | |
268 } | |
269 | |
270 if (pad->left.isHold()) { | |
271 keyPtr->left = HOLD; | |
272 } else if (pad->left.isPush()) { | |
273 keyPtr->left = PUSH; | |
274 } else { | |
275 keyPtr->left = NONE; | |
276 } | |
277 | |
278 if (pad->up.isHold()) { | |
279 keyPtr->up = HOLD; | |
280 } else if (pad->up.isPush()) { | |
281 keyPtr->up = PUSH; | |
282 } else { | |
283 keyPtr->up = NONE; | |
284 } | |
285 | |
286 if (pad->down.isHold()) { | |
287 keyPtr->down = HOLD; | |
288 } else if (pad->down.isPush()) { | |
289 keyPtr->down = PUSH; | |
290 } else { | |
291 keyPtr->down = NONE; | |
292 } | |
293 | |
294 if (pad->circle.isHold()) { | |
295 keyPtr->circle = HOLD; | |
296 } else if (pad->circle.isPush()) { | |
297 keyPtr->circle = PUSH; | |
298 } else { | |
299 keyPtr->circle = NONE; | |
300 } | |
301 } | |
406 | 302 |
303 static void | |
304 post2runMoveDrawLoop(void *viewer_) | |
305 { | |
306 Viewer *viewer = (Viewer*)viewer_; | |
417 | 307 |
308 // 同じ PPE 上なので sgroot(ポインタ) を add_param で送る。 | |
309 //HTaskPtr send_key_task = viewer->manager->create_task(SEND_KEY); | |
310 //send_key_task->add_param((int)sgroot); | |
311 // set input data -> viewer keyPtr | |
312 viewer->getKey(); | |
313 HTaskPtr update_key = viewer->manager->create_task(UPDATE_KEY); | |
314 update_key->add_inData(viewer->keyPtr, sizeof(key_stat)); | |
315 update_key->spawn(); | |
406 | 316 |
421 | 317 /* TASK_MOVE は外から引数で取ってくるべき */ |
318 HTaskPtr move_task = viewer->manager->create_task(viewer->move_taskid); | |
408 | 319 //move_task->add_param(sgroot); |
406 | 320 |
408 | 321 HTaskPtr draw_task = viewer->manager->create_task(TASK_DRAW); |
406 | 322 |
408 | 323 HTaskPtr switch_task = viewer->manager->create_task(TASK_SWITCH); |
421 | 324 |
406 | 325 switch_task->wait_for(move_task); |
326 switch_task->wait_for(draw_task); | |
327 move_task->spawn(); | |
328 draw_task->spawn(); | |
329 | |
330 switch_task->set_post(post2runMoveDrawLoop, (void*)viewer); | |
331 switch_task->spawn(); | |
332 | |
333 } | |
334 | |
335 static void | |
336 post2speRunLoop(void *viewer_) | |
337 { | |
408 | 338 Viewer *viewer = (Viewer *)viewer_; |
406 | 339 HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); |
340 viewer->run_move(task_next); | |
341 } | |
342 | |
399 | 343 void |
398 | 344 Viewer::mainLoop() |
345 { | |
399 | 346 HTaskPtr task_next = initLoop(); |
120 | 347 |
401 | 348 task_next->set_post(&post2runLoop, (void *)this); // set_post(function(this->run_loop()), NULL) |
378 | 349 task_next->spawn(); |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
350 } |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
351 |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
352 static void |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
353 post2runMove(void *viewer_) |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
354 { |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
355 Viewer *viewer = (Viewer*)viewer_; |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
356 HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
357 viewer->run_move(task_next); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
358 } |
109 | 359 |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
360 void |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
361 Viewer::run_move(HTaskPtr task_next) |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
362 { |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
363 sgroot->updateControllerState(); |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
364 sgroot->allExecute(width, height); |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
365 } |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
366 |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
367 void |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
368 Viewer::run_collision() |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
369 { |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
370 } |
109 | 371 |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
372 void |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
373 Viewer::rendering(HTaskPtr task_next) |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
374 { |
401 | 375 HTaskPtr task_create_pp = manager->create_task(TASK_CREATE_PP2); |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
376 |
157 | 377 // SceneGraph(木構造) -> PolygonPack |
401 | 378 |
399 | 379 task_create_pp->add_param((uint32)sgroot->getDrawSceneGraph()); |
137
91c74dbc32e4
SceneGraphPack の代わりに、今は SceneGraph をそのまま使う様に設定。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents:
133
diff
changeset
|
380 task_create_pp->add_param((uint32)ppack); |
109 | 381 |
399 | 382 task_next->wait_for(task_create_pp); |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
383 |
109 | 384 int range_base = spe_num; |
385 // 切り上げのつもり | |
386 int range = (spackList_length + range_base - 1) / range_base; | |
387 | |
388 for (int i = 0; i < range_base; i++) { | |
374 | 389 int index_start = range*i; |
390 int index_end = (index_start + range >= spackList_length) | |
391 ? spackList_length : index_start + range; | |
109 | 392 |
401 | 393 HTaskPtr task_create_sp = manager->create_task(TASK_CREATE_SPAN); |
374 | 394 task_create_sp->add_inData(ppack, sizeof(PolygonPack)); |
395 task_create_sp->add_inData(spackList_ptr, | |
396 sizeof(SpanPack*)*spackList_length_align); | |
397 task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack)); | |
109 | 398 |
374 | 399 task_create_sp->add_param(index_start); |
109 | 400 |
374 | 401 /** |
402 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲 | |
403 * [ 1.. 80] [ 81..160] [161..240] | |
404 * [241..320] [321..400] [401..480] | |
405 * | |
406 * ex. screen_height が 1080, spenum が 5 の場合、 | |
407 * [ 1..216] [217..432] [433..648] | |
408 * [649..864] [865..1080] | |
409 */ | |
410 task_create_sp->add_param(index_start*split_screen_h + 1); | |
411 task_create_sp->add_param(index_end*split_screen_h); | |
109 | 412 |
374 | 413 task_next->wait_for(task_create_sp); |
414 task_create_sp->wait_for(task_create_pp); | |
109 | 415 |
374 | 416 task_create_sp->set_cpu(SPE_ANY); |
417 task_create_sp->spawn(); | |
109 | 418 } |
419 | |
420 task_create_pp->spawn(); | |
378 | 421 |
244 | 422 // Barrier 同期 |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
423 // run_draw() を呼ぶ post2runDraw |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
424 task_next->set_post(post2runDraw, (void*)this); // set_post(function(this->run_draw()), NULL) |
109 | 425 task_next->spawn(); |
401 | 426 |
378 | 427 // TASK_CREATE_SPAN が全て終わったら DUMMY_TASK が Viewer::run_draw() を呼ぶ |
109 | 428 } |
429 | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
430 static void |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
431 post2runLoop(void *viewer_) |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
432 { |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
433 Viewer *viewer = (Viewer*)viewer_; |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
434 HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
435 viewer->run_loop(task_next); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
436 |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
437 } |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
438 |
109 | 439 void |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
440 Viewer::run_loop(HTaskPtr task_next) |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
441 { |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
442 bool quit_flg; |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
443 quit_flg = quit_check(); |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
444 if (quit_flg == true) { |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
445 this_time = get_ticks(); |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
446 run_finish(); |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
447 return; |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
448 } |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
449 |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
450 clean_pixels(); |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
451 |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
452 for (int i = 1; i <= spackList_length; i++) { |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
453 spackList[i-1].reinit(i*split_screen_h); |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
454 } |
398 | 455 |
399 | 456 //run_move(task_next); |
457 sgroot->updateControllerState(); | |
458 sgroot->allExecute(width, height); | |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
459 //sgroot->checkRemove(); |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
460 |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
461 // ここから下は Rendering という関数にする |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
462 rendering(task_next); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
463 } |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
464 |
399 | 465 static void |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
466 post2runDraw(void *viewer_) |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
467 { |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
468 Viewer *viewer = (Viewer*)viewer_; |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
469 HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
470 viewer->run_draw(task_next); |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
471 |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
472 } |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
473 |
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
474 void |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
475 Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする |
109 | 476 { |
477 HTaskPtr task_draw; | |
374 | 478 |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
479 //task_next = manager->create_task(TASK_DUMMY); |
399 | 480 //task_next->set_post(post2runLoop, (void*)this); |
374 | 481 |
109 | 482 ppack->clear(); |
483 for (int i = 0; i < spackList_length; i++) { | |
374 | 484 SpanPack *spack = &spackList[i]; |
485 int startx = 1; | |
486 int endx = split_screen_w; | |
109 | 487 |
374 | 488 int starty = spack->info.y_top - split_screen_h + 1; |
489 //int endy = spack->info.y_top; | |
490 int rangey = (starty + split_screen_h - 1 > this->height) | |
491 ? this->height - starty + 1 : split_screen_h; | |
109 | 492 |
374 | 493 while (startx < this->width) { |
494 if (spack->info.size > 0) { | |
495 // Draw SpanPack | |
496 task_draw = manager->create_task(TASK_DRAW_SPAN); | |
497 task_draw->add_inData(spack, sizeof(SpanPack)); | |
498 | |
499 task_draw->add_param( | |
500 (uint32)&pixels[(startx-1) + this->width*(starty-1)]); | |
501 task_draw->add_param(this->width); | |
502 } else { | |
503 memset(&pixels[(startx-1)+this->width*(starty-1)], | |
504 0, (this->width)*sizeof(int)*rangey); | |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
505 break; |
374 | 506 } |
109 | 507 |
374 | 508 task_draw->add_param(startx); |
509 task_draw->add_param(endx); | |
510 task_draw->add_param(rangey); | |
511 task_draw->set_cpu(SPE_ANY); | |
512 task_next->wait_for(task_draw); | |
513 task_draw->spawn(); | |
109 | 514 |
374 | 515 startx += split_screen_w; |
516 endx += split_screen_w; | |
109 | 517 |
374 | 518 if (endx > this->width) { |
519 endx = this->width; | |
520 } | |
521 } | |
109 | 522 } |
396
0b623693e6ec
don't move. separate allExecute from run_loop
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
378
diff
changeset
|
523 |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
524 |
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
396
diff
changeset
|
525 task_next->set_post(post2runLoop, (void*)this); // set_post(function(this->run_loop()), NULL) |
399 | 526 task_next->spawn(); |
527 // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ | |
109 | 528 |
529 frames++; | |
530 } | |
531 | |
532 void | |
533 Viewer::run_finish(void) | |
534 { | |
535 if (this_time != start_time) { | |
374 | 536 printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0); |
109 | 537 } |
538 | |
219
335ea3665fcd
allExecute する度に SceneGraph をコピーしていく様に変更
gongo@gendarme.local
parents:
217
diff
changeset
|
539 delete sgroot; |
415 | 540 delete sgroot_2; |
109 | 541 quit(); |
542 } | |
421 | 543 |
544 /* end */ |