Mercurial > hg > Game > Cerium
annotate Renderer/Engine/viewer.cc @ 1319:31455d34e502 draft
collada file reader minor changes.
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 18 Dec 2011 09:39:14 +0900 |
parents | ab9b7d21b32b |
children | e51127dbd63c |
rev | line source |
---|---|
539 | 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" | |
1050 | 7 #include "matrix_calc.h" |
539 | 8 #include "Func.h" |
9 #include "error.h" | |
10 #include "TaskManager.h" | |
11 #include <wchar.h> | |
12 #include "Pad.h" | |
543 | 13 #include "Application.h" |
575
341f1f881a9b
Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
572
diff
changeset
|
14 #include "lindaapi.h" |
1097 | 15 #include "SchedTask.h" |
539 | 16 |
17 /* measure for FPS (Frame Per Second) */ | |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
18 static int start_time; |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
19 static int this_time; |
539 | 20 int frames; |
550 | 21 // static void post2speRunLoop(void *viewer); |
22 //static void post2runMove(void *viewer); | |
23 //static void post2exchange_sgroot(void *viewer); | |
24 //static void post2speRunLoop(void *viewer); | |
539 | 25 |
26 //SceneGraphRootPtr sgroot_2; | |
27 | |
28 /* Data Pack sent to Other CPUs (ex. SPE) */ | |
29 | |
1160 | 30 RenderingData r[2]; |
539 | 31 |
994 | 32 int ppi, spi = 0; |
907 | 33 |
747 | 34 Viewer::Viewer(TaskManager *m, ViewerDevice *vd, int b, int w, int h, int _num) |
539 | 35 { |
36 spe_num = _num; | |
747 | 37 manager = m; |
895
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
891
diff
changeset
|
38 |
747 | 39 dev = vd; |
40 pixels = dev->video_init(manager, b, w, h); | |
41 | |
895
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
891
diff
changeset
|
42 width = dev->width; |
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
891
diff
changeset
|
43 height = dev->height; |
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
891
diff
changeset
|
44 bpp = dev->bpp; |
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
891
diff
changeset
|
45 |
539 | 46 } |
47 | |
48 int | |
49 Viewer::get_ticks(void) | |
50 { | |
51 int time; | |
52 time = SDL_GetTicks(); | |
53 return time; | |
54 } | |
55 | |
56 bool | |
57 Viewer::quit_check(void) | |
58 { | |
59 SDL_Event event; | |
60 | |
61 while(SDL_PollEvent(&event)) { | |
62 if (event.type==SDL_QUIT) { | |
63 return true; | |
64 } | |
65 } | |
66 | |
67 Uint8 *keys=SDL_GetKeyState(NULL); | |
68 | |
69 if (keys[SDLK_q] == SDL_PRESSED) { | |
70 return true; | |
71 } | |
72 | |
73 return false; | |
74 } | |
75 | |
76 void | |
77 Viewer::quit(void) | |
78 { | |
79 SDL_Quit(); | |
80 } | |
81 | |
82 | |
83 void | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
84 Viewer::run_init(TaskManager *manager, Application *app) |
539 | 85 { |
86 this->manager = manager; | |
87 | |
747 | 88 if (spe_num == 0) spe_num = 1; |
89 | |
1143 | 90 sgroot = new SceneGraphRoot(this->width, this->height, manager); |
792 | 91 |
92 int light_num = 4; | |
93 int size = sizeof(float)*4*light_num; //xyz+alfa(4) * light_num(4) | |
761 | 94 int light_size = size / sizeof(float); |
747 | 95 |
96 light_xyz = (float *)manager->allocate(size); | |
1129 | 97 |
761 | 98 for (int i = 0; i < light_size ; i++) { |
99 light_xyz[i] = 0.0f; | |
100 } | |
747 | 101 |
1160 | 102 |
792 | 103 for(int i = 0; i < spe_num; i++) { |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
104 HTaskPtr data_load = manager->create_task(DataAllocate); |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
105 data_load->set_param(0,(memaddr)3); // num of allocate block |
988 | 106 data_load->set_param(1,(memaddr)(sizeof(float)*4*light_num)); // 1st allocate size |
107 data_load->set_param(2,(memaddr)Light); // 1st id | |
108 data_load->set_param(3,(memaddr)(light_num * sizeof(int))); // 2nd size | |
109 data_load->set_param(4,(memaddr)LightSwitch); // 2nd id | |
110 data_load->set_param(5,(memaddr)16); // 3rd size | |
111 data_load->set_param(6,(memaddr)LightSysSwitch); // 3rd id | |
747 | 112 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i)); |
113 data_load->spawn(); | |
114 } | |
541
1a31b8820a4d
Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
115 |
792 | 116 light_switch = (int*)manager->allocate(size); |
793 | 117 |
792 | 118 for (int i = 0; i < light_num; i++) { |
119 light_switch[i] = 0; | |
120 } | |
121 | |
122 size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング | |
123 | |
793 | 124 light_sysswitch = (int*)manager->allocate(size); |
125 | |
843
de64695a7f02
cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
842
diff
changeset
|
126 for (unsigned int i = 0; i < size / sizeof(int); i++) { |
793 | 127 light_sysswitch[i] = 0; |
128 } | |
129 | |
984 | 130 start_time = get_ticks(); |
131 this_time = 0; | |
132 frames = 0; | |
1160 | 133 pp_sum_num = 0; |
984 | 134 |
1033
a9581a9df440
add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1004
diff
changeset
|
135 this->app = app; |
543 | 136 MainLoop *mainloop = app->init(this, this->width, this->height); |
137 mainloop->mainLoop(); | |
539 | 138 } |
139 | |
140 | |
141 HTaskPtr | |
142 Viewer::initLoop() | |
143 { | |
144 HTaskPtr task_next; | |
145 HTaskPtr task_tex; | |
146 | |
1163 | 147 /* |
148 | |
149 こうかな | |
150 | |
151 manager->createMemList(sizeof(SpanPack), POOL_SPANPACK); | |
152 | |
153 | |
154 */ | |
155 | |
1160 | 156 |
157 | |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
158 for(int i=0;i<2;i++) { |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
159 r[i].ppack = (PolygonPack*)manager->allocate(sizeof(PolygonPack)); |
989 | 160 r[i].ppack->next = 0; |
539 | 161 |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
162 r[i].spackList_length = (this->height + split_screen_h - 1) / split_screen_h; |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
163 r[i].spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*r[i].spackList_length); |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
164 // printf("spackList %0lx height %d\n",(unsigned long)r[i].spackList, this->height); |
539 | 165 |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
166 /** |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
167 * SPU に送る address list は 16 バイト倍数でないといけない。 |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
168 * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
169 * length_align を求めている。はみ出した部分は使われない |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
170 * (ex) spackList_length が 13 の場合 |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
171 * spackList_length_align = 16; |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
172 * 実際に送るデータは64バイトになるのでOK |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
173 * 14,15,16 の部分は何も入らない。 |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
174 */ |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
175 r[i].spackList_length_align = (r[i].spackList_length + 3)&(~3); |
539 | 176 |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
177 /* 各 SPU が持つ、SpanPack の address list */ |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
178 r[i].spackList_ptr = |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
179 (SpanPack**)manager->allocate(sizeof(SpanPack*)*r[i].spackList_length_align); |
539 | 180 |
988 | 181 for (int j = 0; j < r[i].spackList_length; j++) { |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
182 r[i].spackList_ptr[j] = &r[i].spackList[j]; |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
183 } |
539 | 184 |
988 | 185 for (int j = 1; j <= r[i].spackList_length; j++) { |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
186 r[i].spackList[j-1].init(j*split_screen_h); |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
187 } |
539 | 188 } |
189 | |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
190 task_next = manager->create_task(RUN_LOOP_TASK,0,0,0,0); |
1097 | 191 task_next->set_param(0, (void*)this); |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
192 |
659 | 193 // ここは、Iterator を用意するべきだよね |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
194 for (int j = 0; j < spe_num; j++) { |
1162 | 195 task_tex = manager->create_task(AllocateSegment,0,0,0,0); |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
196 task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + j)); |
826 | 197 task_next->wait_for(task_tex); |
747 | 198 task_tex->spawn(); |
539 | 199 } |
200 | |
792 | 201 |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
202 task_next->spawn(); |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
203 |
1097 | 204 return 0; |
539 | 205 } |
206 | |
207 | |
208 void | |
209 Viewer::getKey() | |
210 { | |
211 Pad *pad = sgroot->getController(); | |
212 if (pad->right.isHold()) { | |
213 keyPtr->right = HOLD; | |
214 } else if (pad->right.isPush()) { | |
215 keyPtr->right = PUSH; | |
216 } else { | |
217 keyPtr->right = NONE; | |
218 } | |
219 | |
220 if (pad->left.isHold()) { | |
221 keyPtr->left = HOLD; | |
222 } else if (pad->left.isPush()) { | |
223 keyPtr->left = PUSH; | |
224 } else { | |
225 keyPtr->left = NONE; | |
226 } | |
227 | |
228 if (pad->up.isHold()) { | |
229 keyPtr->up = HOLD; | |
230 } else if (pad->up.isPush()) { | |
231 keyPtr->up = PUSH; | |
232 } else { | |
233 keyPtr->up = NONE; | |
234 } | |
235 | |
236 if (pad->down.isHold()) { | |
237 keyPtr->down = HOLD; | |
238 } else if (pad->down.isPush()) { | |
239 keyPtr->down = PUSH; | |
240 } else { | |
241 keyPtr->down = NONE; | |
242 } | |
243 | |
244 if (pad->circle.isHold()) { | |
245 keyPtr->circle = HOLD; | |
246 } else if (pad->circle.isPush()) { | |
247 keyPtr->circle = PUSH; | |
248 } else { | |
249 keyPtr->circle = NONE; | |
250 } | |
251 } | |
252 | |
253 | |
254 void | |
255 Viewer::mainLoop() | |
256 { | |
1112 | 257 if (pixels) { |
258 initLoop(); | |
259 } else { | |
260 HTaskPtr task_next = manager->create_task(EXEC_ONLY_TASK, 0, 0, 0, 0); | |
261 task_next->set_param(0, (void*)this); | |
262 | |
263 task_next->spawn(); | |
264 } | |
539 | 265 } |
266 | |
1112 | 267 bool |
268 Viewer::main_exec(HTaskPtr task_next) | |
539 | 269 { |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
270 psx_sync_n(); |
1112 | 271 |
1045
11a9bc9928d0
mainLoop is not a part of mainLoop in viwer.... move application_task
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1043
diff
changeset
|
272 task_next = app->application_task(task_next, this); |
747 | 273 dev->clear_screen(); |
1112 | 274 |
747 | 275 bool quit_flg; |
276 quit_flg = quit_check(); | |
277 if (quit_flg == true) { | |
278 this_time = get_ticks(); | |
279 run_finish(); | |
1112 | 280 return false; |
747 | 281 } |
282 | |
283 dev->clean_pixels(); | |
1112 | 284 pixels = dev->flip_screen(pixels); |
994 | 285 |
747 | 286 sgroot->updateControllerState(); |
1043
3a49a0825963
Merged ( app_loop should return 1, if you want to use allExecute )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
diff
changeset
|
287 if (app->app_loop(this)) { |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
288 //TaskArray を使うか使わないか |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
289 if (sgroot->gtask_array != NULL) { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
290 sgroot->create_task_array(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
291 sgroot->allExecute(width, height); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
292 sgroot->task_array_finish(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
293 } else { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
294 sgroot->allExecute(width, height); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
295 } |
1254 | 296 } else { |
297 sgroot->treeApply(width, height); | |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
298 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
299 |
747 | 300 light_xyz_stock = sgroot->getLightVector(); |
1292
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1254
diff
changeset
|
301 |
90efd2aac2cb
add matrix test and debug light vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1254
diff
changeset
|
302 |
792 | 303 light_switch_stock = sgroot->getLightSwitch(); |
793 | 304 light_sysswitch_stock = sgroot->getLightSysSwitch(); |
1112 | 305 |
306 return true; | |
307 } | |
747 | 308 |
1112 | 309 void |
310 Viewer::run_loop(HTaskPtr task_next) | |
311 { | |
312 if (main_exec(task_next)) { | |
1118 | 313 //rendering(task_next); |
314 task_next->spawn(); | |
1111 | 315 } |
539 | 316 } |
747 | 317 |
1112 | 318 SchedDefineTask1(EXEC_ONLY_TASK,exec_only_task); |
319 | |
320 static int | |
321 exec_only_task(SchedTask *smanager, void *rbuf, void *wbuf) | |
322 { | |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
323 |
1112 | 324 Viewer *viewer = (Viewer*)smanager->get_param(0); |
325 HTaskPtr task_next = smanager->create_task(EXEC_ONLY_TASK, 0, 0, 0, 0); | |
326 task_next->set_param(0, (void*)viewer); | |
327 | |
328 if (viewer->main_exec(task_next)) { | |
329 task_next->spawn(); | |
330 } | |
331 return 0; | |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
332 } |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
333 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
334 SchedDefineTask1(RUN_LOOP_TASK,run_loop_task); |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
335 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
336 static int |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
337 run_loop_task(SchedTask *smanager, void *rbuf, void *wbuf) |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
338 { |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
339 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
340 Viewer *viewer = (Viewer*)smanager->get_param(0); |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
341 HTaskPtr task_next = smanager->create_task(CREATE_PP_TASK, 0, 0, 0, 0); |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
342 task_next->set_param(0, (void*)viewer); |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
343 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
344 viewer->run_loop(task_next); |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
345 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
346 return 0; |
539 | 347 } |
348 | |
349 | |
350 | |
351 void | |
352 Viewer::run_collision() | |
353 { | |
354 } | |
355 | |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
356 SchedDefineTask1(CREATE_PP_TASK, create_pp_task); |
1118 | 357 |
358 static int | |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
359 create_pp_task(SchedTask* smanager, void* rbuf, void* wbuf) |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
360 { |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
361 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
362 Viewer *viewer = (Viewer*)smanager->get_param(0); |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
363 HTaskPtr task_next = smanager->create_task(CREATE_SP_TASK, 0, 0, 0, 0); |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
364 task_next->set_param(0, (void*)viewer); |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
365 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
366 viewer->create_pp(task_next); |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
367 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
368 return 0; |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
369 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
370 } |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
371 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
372 void |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
373 Viewer::create_pp(HTaskPtr task_next) { |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
374 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
375 rendering_pp(task_next, sgroot); |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
376 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
377 // Barrier 同期 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
378 // run_draw() を呼ぶ post2runDraw |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
379 task_next->spawn(); // create_sp_task |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
380 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
381 } |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
382 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
383 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
384 SchedDefineTask1(CREATE_SP_TASK, create_sp_task); |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
385 |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
386 static int |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
387 create_sp_task(SchedTask* smanager, void* rbuf, void* wbuf) |
1118 | 388 { |
389 | |
390 Viewer *viewer = (Viewer*)smanager->get_param(0); | |
391 HTaskPtr task_next = smanager->create_task(DRAW_TASK, 0, 0, 0, 0); | |
392 task_next->set_param(0, (void*)viewer); | |
393 | |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
394 viewer->create_sp(task_next); |
1118 | 395 |
396 return 0; | |
397 | |
398 } | |
539 | 399 |
400 void | |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
401 Viewer::create_sp(HTaskPtr task_next) { |
1129 | 402 |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
403 rendering_sp(task_next, sgroot); |
539 | 404 |
405 // Barrier 同期 | |
406 // run_draw() を呼ぶ post2runDraw | |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
407 task_next->spawn(); // draw_task |
539 | 408 |
409 } | |
1152 | 410 |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
411 |
1118 | 412 SchedDefineTask1(DRAW_TASK, draw_task); |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
413 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
414 static int |
1118 | 415 draw_task(SchedTask* smanager, void* rbuf, void* wbuf) |
539 | 416 { |
994 | 417 |
1097 | 418 Viewer* viewer = (Viewer*)smanager->get_param(0); |
1107 | 419 HTaskPtr task_next = smanager->create_task(RUN_LOOP_TASK, 0, 0, 0, 0); |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
420 task_next->set_param(0, (void*)viewer); |
1097 | 421 viewer->run_draw(task_next); |
1122 | 422 |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
423 return 0; |
539 | 424 |
425 } | |
426 | |
427 void | |
428 Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする | |
429 { | |
430 common_draw(task_next); | |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
431 |
1118 | 432 task_next->spawn(); // run_loop_task |
539 | 433 // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ |
434 | |
435 frames++; | |
436 } | |
437 | |
438 | |
860 | 439 void |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
440 Viewer::rendering_pp(HTaskPtr task_next, SceneGraphRoot *sgroot) |
539 | 441 { |
1160 | 442 |
1161
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
443 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
444 /* |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
445 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
446 sg->pp をもっと細かく分けるか? |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
447 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
448 DataSegment seg1; |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
449 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
450 (ObjectPolygonPtr)seg1->in = (ObjectPolygonPtr)makeSegment(pp_sum_num); |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
451 (SpanPackPtr)seg1->out = (SpanPackPtr)makeSegment(pp_sum_num); |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
452 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
453 HTaskPtr create_pp = manager->create_task(CreatePolygon,seg1); |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
454 create_pp->spawn(); |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
455 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
456 DataSegment seg; |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
457 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
458 */ |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
459 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
460 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
461 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
462 HTaskPtr game_task_array = 0; |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
463 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
464 /* GameTask の処理の終了を待ってからポリゴンを作る */ |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
465 if (sgroot->gtask_array != NULL) { |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
466 game_task_array = sgroot->gtask_array->get_task_array(); |
1003
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
467 } |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1122
diff
changeset
|
468 |
1128 | 469 PolygonPackPtr out_pp = r[ppi].ppack; |
1140
3975c384ff93
SceneGraph initalize... can worked on Mac OS X. not check Cell arch.
Yutaka_Kinjyo
parents:
1139
diff
changeset
|
470 out_pp->init(); |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1292
diff
changeset
|
471 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1292
diff
changeset
|
472 CameraPtr camera = sgroot->getCamera(); |
1130 | 473 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
474 //多分このsg_remove_listであってる?。チェック対象かも |
1136 | 475 for (SceneGraphPtr t = sgroot->sg_remove_list; t != NULL; t = t->next) { |
1142
801d57ae1e29
cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents:
1140
diff
changeset
|
476 if (t->size > 0) { |
1160 | 477 pp_sum_num += t->pp_num; |
478 for (int i = 0; i < t->pp_num; i++) { | |
479 | |
1138 | 480 HTaskPtr create_pp = manager->create_task(CreatePolygonFromSceneGraph); |
481 | |
482 create_pp->add_inData(&t->pp[i], sizeof(PolygonPack)); | |
483 create_pp->add_inData(t->matrix, sizeof(float)*16); | |
1302
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1292
diff
changeset
|
484 create_pp->add_inData(camera->m_screen, sizeof(float)*16); |
1138 | 485 create_pp->add_inData(t->texture_info, sizeof(texture_list)); |
486 | |
487 if ( (unsigned long)t->matrix % 16) { | |
488 printf("marix not aligned\n"); | |
489 } | |
490 | |
491 if ((unsigned long)t->texture_info % 16) { | |
492 printf("texture_info not aligned\n"); | |
493 } | |
494 | |
495 create_pp->add_outData(out_pp, sizeof(PolygonPack)); | |
496 | |
497 if (game_task_array != NULL) { | |
498 create_pp->wait_for(game_task_array); | |
499 } | |
1142
801d57ae1e29
cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents:
1140
diff
changeset
|
500 |
801d57ae1e29
cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents:
1140
diff
changeset
|
501 PolygonPackPtr tmp_pp = (PolygonPackPtr)manager->allocate(sizeof(PolygonPack)); |
1129 | 502 |
1138 | 503 tmp_pp->init(); |
504 create_pp->set_param(0, (memaddr)tmp_pp); | |
505 out_pp = tmp_pp; | |
506 | |
1142
801d57ae1e29
cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents:
1140
diff
changeset
|
507 //create_pp->set_cpu(SPE_ANY); |
801d57ae1e29
cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents:
1140
diff
changeset
|
508 create_pp->set_cpu(CPU_PPE); |
1138 | 509 task_next->wait_for(create_pp); |
510 create_pp->spawn(); | |
511 } | |
1142
801d57ae1e29
cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents:
1140
diff
changeset
|
512 } |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
513 } |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
514 } |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1122
diff
changeset
|
515 |
1139 | 516 |
1131
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
517 void |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
518 Viewer::rendering_sp(HTaskPtr task_next, SceneGraphRoot *sgroot) |
220f9032d2d2
RENDERING_TASK was divided into CREATE_PP_TASK and CREATE_SP_TASK.
root@dolphins.cr.ie.u-ryukyu.ac.jp
parents:
1130
diff
changeset
|
519 { |
1160 | 520 |
521 #ifdef CreateSpanDivi | |
522 | |
523 /* | |
524 | |
525 CreateSpan -> SortSpan -> DrawSpan | |
526 | | | |
527 v v | |
528 Data Data | |
529 | |
530 Bestなデータ構造ってどういうのだろう。 | |
531 今のデータ構造は「良い」とは言えないだろうなぁ。 | |
532 間に wait_for もいまいち見たいだから、Taskで挟むのがいいか | |
533 | |
534 CreateSpan -> BridgeTask -> SortSpan -> BridgeTask -> DrawSpan | |
535 | |
536 みたいな感じ? この wait for は見づらいしね。んで上の図みたな依存性がみれたり、 | |
537 実行のガントチャートが見れたりすると嬉しいって話は前からある。 | |
538 | |
1161
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
539 以下妄想 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
540 |
1160 | 541 CreateSpan(SegID in) { |
542 | |
543 SpanPack out = makeSegment(); | |
544 PolygonPack pp = getSegment(in); | |
545 | |
546 --処理-- | |
547 | |
548 return SortTask(out); | |
549 | |
550 } | |
551 | |
552 SortSpan(SegID in) { | |
553 | |
554 SpanPack out = makeSegment(); | |
555 SpanPack sp = getSegment(in): | |
556 | |
557 --処理-- | |
558 | |
559 return DrawSpan(out); | |
560 | |
561 } | |
562 | |
563 DrawSpan() { | |
564 | |
565 | |
566 | |
567 return Start(); //Startは同期するん? | |
568 | |
569 } | |
570 | |
571 main() { | |
572 | |
573 --処理-- | |
574 | |
575 PolygonPack out = makeSegment(3); //個数なのか? | |
576 | |
577 out[0] = pp[0]; | |
578 out[1] = pp[1]; | |
579 out[2] = pp[2]; | |
580 | |
581 return CreateSpan(out); //3スレッドできるのか? | |
582 | |
583 } | |
584 | |
585 | |
586 下みたいにはもう書きたくないか・・・ | |
587 うーんだいぶ書きなおすか。 | |
588 | |
589 */ | |
590 | |
591 | |
592 PolygonPackPtr pp = r[ppi].ppack; | |
593 SpanPackPtr* spackList = (SpanPackPtr*)manager->allocate(sizeof(SpanPackPtr)*pp_sum_num); | |
594 | |
595 for (PolygonPackPtr t = pp; t->next != NULL; t = t->next) { | |
596 | |
597 int span_num = t->info.span_num; | |
598 int spack_num = (span_num + MAX_SIZE_SPAN -1) / MAX_SIZE_SPAN; | |
599 | |
600 SpanPackPtr spack = (SpanPackPtr)manager->allocate(sizeof(SpanPack)*spack_num); | |
601 spackList[i] = spack; | |
602 | |
603 for (int i = 0; i < spack_num; i++) { | |
604 HTaskPtr task_create_sp = manager->create_task(CreateSpan); | |
605 task_create_sp->set_inData(0, t, sizeof(PolygonPack)); | |
606 task_create_sp->set_outData(0, &spack[i], sizeof(SpanPack)); | |
607 | |
608 task_create_sp->spawn(); | |
609 task_next->wait_for(task_create_sp); | |
610 } | |
611 | |
612 } | |
613 | |
614 HTaskPtr sort_span = (SortSpanPtr)manager->allocate(sizeof(SortSpan)); | |
615 | |
616 /*まだ途中*/ | |
617 | |
618 #else | |
619 | |
747 | 620 int range_base = spe_num; |
621 | |
539 | 622 // 切り上げのつもり |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
623 int range = (r[spi].spackList_length + range_base - 1) / range_base; |
539 | 624 |
625 for (int i = 0; i < range_base; i++) { | |
626 int index_start = range*i; | |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
627 int index_end = (index_start + range >= r[spi].spackList_length) |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
628 ? r[spi].spackList_length : index_start + range; |
1056
4955cedb17e5
endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
629 int starty = index_start*split_screen_h + 1; |
4955cedb17e5
endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
630 int endy = index_end*split_screen_h; |
4955cedb17e5
endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
631 if (starty<=0) starty = 1; |
4955cedb17e5
endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
632 if (endy>height) endy = height; |
539 | 633 |
659 | 634 HTaskPtr task_create_sp = manager->create_task(CreateSpan); |
539 | 635 |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
617
diff
changeset
|
636 task_create_sp->set_param(0,index_start); |
747 | 637 |
539 | 638 /** |
639 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲 | |
640 * [ 1.. 80] [ 81..160] [161..240] | |
641 * [241..320] [321..400] [401..480] | |
642 * | |
643 * ex. screen_height が 1080, spenum が 5 の場合、 | |
644 * [ 1..216] [217..432] [433..648] | |
645 * [649..864] [865..1080] | |
646 */ | |
747 | 647 |
1056
4955cedb17e5
endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
648 task_create_sp->set_param(1,starty); |
4955cedb17e5
endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
649 task_create_sp->set_param(2,endy); |
539 | 650 |
1128 | 651 task_create_sp->add_inData(r[ppi].ppack, sizeof(PolygonPack)); |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
652 task_create_sp->add_inData(r[spi].spackList_ptr, |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
653 sizeof(SpanPack*)*r[spi].spackList_length_align); |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
654 task_create_sp->add_inData(&r[spi].spackList[index_start], sizeof(SpanPack)); |
659 | 655 |
1107 | 656 task_next->wait_for(task_create_sp); |
539 | 657 |
747 | 658 task_create_sp->set_cpu(SPE_ANY); |
539 | 659 task_create_sp->spawn(); |
660 } | |
661 | |
1160 | 662 #endif |
663 | |
539 | 664 } |
665 | |
666 void | |
667 Viewer::common_draw(HTaskPtr task_next) | |
668 { | |
669 | |
615
184d6d3f0cd9
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
670 //task_next = manager->create_task(Dummy); |
539 | 671 //task_next->set_post(post2runLoop, (void*)this); |
672 | |
792 | 673 //Light info update |
747 | 674 |
792 | 675 int light_num = 4; |
676 int size = sizeof(float)*4*light_num; //xyz+alpha(4) * light_num(4) | |
761 | 677 int light_size = size / sizeof(float); |
747 | 678 |
761 | 679 for (int i = 0; i < light_size; i++) { |
792 | 680 light_xyz[i] = light_xyz_stock[i]; |
761 | 681 } |
792 | 682 |
683 for (int i = 0; i < light_num; i++) { | |
684 light_switch[i] = light_switch_stock[i]; | |
685 } | |
793 | 686 |
687 light_sysswitch[0] = light_sysswitch_stock; | |
985 | 688 |
1147 | 689 #if 1 |
690 | |
985 | 691 HTask *data_update_wait = 0; |
692 for (int i = 0; i < spe_num; i++) { | |
693 data_update_wait = manager->create_task(DataUpdate); | |
694 data_update_wait->set_param(0,3); | |
695 data_update_wait->set_param(1,Light); // GlobalSet ID base | |
696 data_update_wait->set_inData(0,light_xyz,size); // Light | |
697 data_update_wait->set_inData(1,light_switch,light_num * sizeof(int)); // LightSwitch = Light+1 | |
698 data_update_wait->set_inData(2,light_sysswitch,16); // LightSysSwitch = Light+2 | |
699 data_update_wait->set_cpu((CPU_TYPE)(SPE_0+i)); | |
700 data_update_wait->spawn(); | |
1147 | 701 } |
702 | |
703 #else | |
1145 | 704 |
705 HTask *data_update_wait = manager->create_task(Dummy); | |
706 for (int i = 0; i < spe_num; i++) { | |
707 | |
708 HTaskPtr data_update = manager->create_task(DataUpdate); | |
709 data_update->set_param(0,3); | |
710 data_update->set_param(1,Light); // GlobalSet ID base | |
711 data_update->set_inData(0,light_xyz,size); // Light | |
712 data_update->set_inData(1,light_switch,light_num * sizeof(int)); // LightSwitch = Light+1 | |
713 data_update->set_inData(2,light_sysswitch,16); // LightSysSwitch = Light+2 | |
714 data_update->set_cpu((CPU_TYPE)(SPE_0+i)); | |
715 data_update->wait_for(data_update_wait); | |
716 data_update->spawn(); | |
1147 | 717 } |
718 | |
719 #endif | |
792 | 720 |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
721 ppi ^= 1; |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
722 r[ppi].ppack->clear(); |
914 | 723 |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
724 for (int i = 0; i < r[spi].spackList_length; i++) { |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
725 SpanPack *spack = &r[spi].spackList[i]; |
539 | 726 int startx = 1; |
727 int endx = split_screen_w; | |
728 | |
729 int starty = spack->info.y_top - split_screen_h + 1; | |
730 //int endy = spack->info.y_top; | |
731 int rangey = (starty + split_screen_h - 1 > this->height) | |
732 ? this->height - starty + 1 : split_screen_h; | |
733 | |
1152 | 734 #ifdef USE_TASKARRAY |
857 | 735 |
1157 | 736 int array_task_num = (this->width + split_screen_w - 1) / split_screen_w; |
737 HTaskPtr task_draw_array = manager->create_task_array(DrawSpan, array_task_num, 6, 1, rangey); | |
738 Task *task_draw = 0; | |
739 | |
857 | 740 while (startx < this->width) { |
741 | |
839 | 742 // Draw SpanPack |
857 | 743 |
839 | 744 task_draw = task_draw_array->next_task_array(DrawSpan,task_draw); |
745 task_draw->set_param(0,(memaddr)&pixels[(startx-1) + this->width*(starty-1)]); | |
746 task_draw->set_param(1,this->width); | |
747 task_draw->set_param(2,startx); | |
748 task_draw->set_param(3,endx); | |
749 task_draw->set_param(4,rangey); | |
750 task_draw->set_param(5,spack->info.size); | |
838 | 751 |
839 | 752 task_draw->set_inData(0,spack, sizeof(SpanPack)); |
753 | |
754 for (int i = 0; i < rangey; i++) { | |
857 | 755 task_draw->set_outData(i, |
756 &pixels[(startx-1) + this->width*(starty-1 + i) ], | |
757 (endx-startx+1)*sizeof(int)); | |
839 | 758 } |
759 | |
760 startx += split_screen_w; | |
761 endx += split_screen_w; | |
762 | |
763 if (endx > this->width) { | |
764 endx = this->width; | |
765 } | |
766 | |
857 | 767 } |
768 | |
769 task_draw_array->spawn_task_array(task_draw->next()); | |
770 task_draw_array->set_cpu(SPE_ANY); | |
1147 | 771 //task_draw_array->wait_for(data_update_wait); |
1152 | 772 #ifndef USE_PIPELINE |
773 task_next->wait_for(task_draw_array); | |
774 #endif | |
857 | 775 task_draw_array->spawn(); |
776 #else | |
838 | 777 |
778 HTaskPtr task_draw; | |
779 | |
539 | 780 while (startx < this->width) { |
1154 | 781 if (spack->info.size > 0 || mem_flag == 1) { |
539 | 782 // Draw SpanPack |
615
184d6d3f0cd9
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
783 task_draw = manager->create_task(DrawSpan); |
539 | 784 |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
617
diff
changeset
|
785 task_draw->set_param(0, |
603
57ec231bc8ac
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
786 (memaddr)&pixels[(startx-1) + this->width*(starty-1)]); |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
617
diff
changeset
|
787 task_draw->set_param(1,this->width); |
659 | 788 task_draw->set_param(2,startx); |
789 task_draw->set_param(3,endx); | |
790 task_draw->set_param(4,rangey); | |
838 | 791 task_draw->set_param(5,spack->info.size); |
659 | 792 |
793 task_draw->add_inData(spack, sizeof(SpanPack)); | |
616
350b9b8c985f
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
794 |
617
df618a956eb9
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
795 for (int i = 0; i < rangey; i++) { |
616
350b9b8c985f
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
796 task_draw->add_outData( |
617
df618a956eb9
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
797 &pixels[(startx-1) + this->width*(starty-1 + i) ], |
df618a956eb9
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
798 (endx-startx+1)*sizeof(int)); |
616
350b9b8c985f
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
799 } |
838 | 800 |
857 | 801 } else { |
539 | 802 // 7.7.3 SL1 Data Cache Range Set to Zero コマンド |
803 // を使って、DMAでclearするべき... ということは、 | |
804 // それもSPEでやる方が良い? | |
857 | 805 memset(&pixels[(startx-1)+this->width*(starty-1)], |
806 0, (this->width)*sizeof(int)*rangey); | |
807 break; | |
808 } | |
539 | 809 |
747 | 810 task_draw->set_cpu(SPE_ANY); |
1152 | 811 #ifndef USE_PIPELINE |
539 | 812 task_next->wait_for(task_draw); |
1152 | 813 #endif |
539 | 814 task_draw->spawn(); |
815 | |
816 startx += split_screen_w; | |
817 endx += split_screen_w; | |
818 | |
819 if (endx > this->width) { | |
820 endx = this->width; | |
821 } | |
822 } | |
838 | 823 #endif |
824 | |
1145 | 825 } |
826 | |
1147 | 827 //data_update_wait->spawn(); |
1145 | 828 |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
829 spi ^= 1; |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
830 for (int i = 1; i <= r[spi].spackList_length; i++) { |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
831 r[spi].spackList[i-1].reinit(i*split_screen_h); |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
832 } |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
833 |
925
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
834 if (profile) { |
983 | 835 if (frames % 50 == 49) { |
998 | 836 manager->show_profile(); |
983 | 837 this_time = get_ticks(); |
838 if (this_time != start_time) { | |
984 | 839 printf("\n%f FPS\n", ((((float)frames)*1000.0)/(this_time-start_time))); |
983 | 840 start_time = this_time; frames = 0; |
841 } | |
982
9f5e6bfb1c09
avoid WAIT in virtual console
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
981
diff
changeset
|
842 } |
925
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
843 } |
747 | 844 } |
845 | |
846 void | |
847 Viewer::run_finish() | |
848 { | |
849 dev->free_device(); | |
850 if (this_time != start_time) { | |
851 printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0); | |
852 } | |
925
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
853 if (profile) { |
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
854 manager->show_profile(); |
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
855 } |
747 | 856 |
857 delete sgroot; | |
858 // delete sgroot_2; | |
859 quit(); | |
539 | 860 } |
861 | |
862 /* end */ |