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