Mercurial > hg > Game > Cerium
annotate Renderer/Engine/viewer.cc @ 1808:c25aa7edd1ba draft
fix conditional branch in fileread
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 11 Dec 2013 17:42:09 +0900 |
parents | 3778a1eda68d |
children | 363b7c401c79 |
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 | |
1421
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
145 void |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
146 Viewer::reinit_spackList() { |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
147 spi ^= 1; |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
148 for (int i = 0; i < r[spi].spackList_length; i++) { |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
149 for( SpanPack *p = &r[spi].spackList[i];p;p = p->next) { |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
150 if (p->pad[0]==1) |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
151 fprintf(stderr,"clearing non drawing r[spi].spackList %8lx\n", (long)p); |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
152 } |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
153 r[spi].spackList[i].reinit((i-1)*split_screen_h); |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
154 } |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
155 } |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
156 |
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
157 |
539 | 158 |
159 void | |
160 Viewer::getKey() | |
161 { | |
162 Pad *pad = sgroot->getController(); | |
163 if (pad->right.isHold()) { | |
164 keyPtr->right = HOLD; | |
165 } else if (pad->right.isPush()) { | |
166 keyPtr->right = PUSH; | |
167 } else { | |
168 keyPtr->right = NONE; | |
169 } | |
170 | |
171 if (pad->left.isHold()) { | |
172 keyPtr->left = HOLD; | |
173 } else if (pad->left.isPush()) { | |
174 keyPtr->left = PUSH; | |
175 } else { | |
176 keyPtr->left = NONE; | |
177 } | |
178 | |
179 if (pad->up.isHold()) { | |
180 keyPtr->up = HOLD; | |
181 } else if (pad->up.isPush()) { | |
182 keyPtr->up = PUSH; | |
183 } else { | |
184 keyPtr->up = NONE; | |
185 } | |
186 | |
187 if (pad->down.isHold()) { | |
188 keyPtr->down = HOLD; | |
189 } else if (pad->down.isPush()) { | |
190 keyPtr->down = PUSH; | |
191 } else { | |
192 keyPtr->down = NONE; | |
193 } | |
194 | |
195 if (pad->circle.isHold()) { | |
196 keyPtr->circle = HOLD; | |
197 } else if (pad->circle.isPush()) { | |
198 keyPtr->circle = PUSH; | |
199 } else { | |
200 keyPtr->circle = NONE; | |
201 } | |
202 } | |
203 | |
204 | |
205 void | |
206 Viewer::mainLoop() | |
207 { | |
1112 | 208 if (pixels) { |
209 initLoop(); | |
210 } else { | |
211 HTaskPtr task_next = manager->create_task(EXEC_ONLY_TASK, 0, 0, 0, 0); | |
212 task_next->set_param(0, (void*)this); | |
213 | |
214 task_next->spawn(); | |
215 } | |
539 | 216 } |
217 | |
1112 | 218 bool |
219 Viewer::main_exec(HTaskPtr task_next) | |
539 | 220 { |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
221 psx_sync_n(); |
1112 | 222 |
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
|
223 task_next = app->application_task(task_next, this); |
747 | 224 dev->clear_screen(); |
1112 | 225 |
747 | 226 bool quit_flg; |
227 quit_flg = quit_check(); | |
228 if (quit_flg == true) { | |
229 this_time = get_ticks(); | |
230 run_finish(); | |
1112 | 231 return false; |
747 | 232 } |
233 | |
234 dev->clean_pixels(); | |
1112 | 235 pixels = dev->flip_screen(pixels); |
994 | 236 |
747 | 237 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
|
238 if (app->app_loop(this)) { |
1042
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
239 //TaskArray を使うか使わないか |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
240 if (sgroot->gtask_array != NULL) { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
241 sgroot->create_task_array(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
242 sgroot->allExecute(width, height); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
243 sgroot->task_array_finish(); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
244 } else { |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
245 sgroot->allExecute(width, height); |
d0bb27bf985b
AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1035
diff
changeset
|
246 } |
1254 | 247 } else { |
248 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
|
249 } |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
250 |
1405 | 251 light->exec(task_next); |
1112 | 252 |
253 return true; | |
254 } | |
747 | 255 |
1112 | 256 void |
257 Viewer::run_loop(HTaskPtr task_next) | |
258 { | |
259 if (main_exec(task_next)) { | |
1118 | 260 //rendering(task_next); |
261 task_next->spawn(); | |
1111 | 262 } |
539 | 263 } |
747 | 264 |
1112 | 265 SchedDefineTask1(EXEC_ONLY_TASK,exec_only_task); |
266 | |
267 static int | |
268 exec_only_task(SchedTask *smanager, void *rbuf, void *wbuf) | |
269 { | |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
270 |
1112 | 271 Viewer *viewer = (Viewer*)smanager->get_param(0); |
272 HTaskPtr task_next = smanager->create_task(EXEC_ONLY_TASK, 0, 0, 0, 0); | |
273 task_next->set_param(0, (void*)viewer); | |
274 | |
275 if (viewer->main_exec(task_next)) { | |
276 task_next->spawn(); | |
277 } | |
278 return 0; | |
1096
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 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
281 SchedDefineTask1(RUN_LOOP_TASK,run_loop_task); |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
282 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
283 static int |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
284 run_loop_task(SchedTask *smanager, void *rbuf, void *wbuf) |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
285 { |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
286 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
287 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
|
288 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
|
289 task_next->set_param(0, (void*)viewer); |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
290 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
291 viewer->run_loop(task_next); |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
292 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
293 return 0; |
539 | 294 } |
295 | |
296 | |
297 | |
298 void | |
299 Viewer::run_collision() | |
300 { | |
301 } | |
302 | |
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
|
303 SchedDefineTask1(CREATE_PP_TASK, create_pp_task); |
1118 | 304 |
305 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
|
306 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
|
307 { |
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 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
|
310 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
|
311 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
|
312 |
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 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
|
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 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
|
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 |
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 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
|
320 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
|
321 |
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
|
322 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
|
323 |
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
|
324 // 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
|
325 // 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
|
326 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
|
327 |
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 } |
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
|
329 |
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
|
330 |
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
|
331 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
|
332 |
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
|
333 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
|
334 create_sp_task(SchedTask* smanager, void* rbuf, void* wbuf) |
1118 | 335 { |
336 | |
337 Viewer *viewer = (Viewer*)smanager->get_param(0); | |
338 HTaskPtr task_next = smanager->create_task(DRAW_TASK, 0, 0, 0, 0); | |
339 task_next->set_param(0, (void*)viewer); | |
340 | |
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 viewer->create_sp(task_next); |
1118 | 342 |
343 return 0; | |
344 | |
345 } | |
539 | 346 |
347 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
|
348 Viewer::create_sp(HTaskPtr task_next) { |
1129 | 349 |
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
|
350 rendering_sp(task_next, sgroot); |
539 | 351 |
352 // Barrier 同期 | |
353 // 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
|
354 task_next->spawn(); // draw_task |
539 | 355 |
356 } | |
1152 | 357 |
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
|
358 |
1118 | 359 SchedDefineTask1(DRAW_TASK, draw_task); |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
360 |
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
361 static int |
1118 | 362 draw_task(SchedTask* smanager, void* rbuf, void* wbuf) |
539 | 363 { |
994 | 364 |
1097 | 365 Viewer* viewer = (Viewer*)smanager->get_param(0); |
1107 | 366 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
|
367 task_next->set_param(0, (void*)viewer); |
1097 | 368 viewer->run_draw(task_next); |
1122 | 369 |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
370 return 0; |
539 | 371 |
372 } | |
373 | |
374 void | |
375 Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする | |
376 { | |
377 common_draw(task_next); | |
1096
d18b605e431f
add task, run_loop, run_draw, rendering, ...
yutaka@localhost.localdomain
parents:
1095
diff
changeset
|
378 |
1118 | 379 task_next->spawn(); // run_loop_task |
539 | 380 // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ |
381 | |
382 frames++; | |
383 } | |
384 | |
385 | |
860 | 386 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
|
387 Viewer::rendering_pp(HTaskPtr task_next, SceneGraphRoot *sgroot) |
539 | 388 { |
1160 | 389 |
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
|
390 |
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 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
|
394 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
395 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
|
396 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
397 (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
|
398 (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
|
399 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
400 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
|
401 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
|
402 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
403 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
|
404 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
405 */ |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1160
diff
changeset
|
406 |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
407 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
|
408 |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
409 /* GameTask の処理の終了を待ってからポリゴンを作る */ |
37842bbd35f0
game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1002
diff
changeset
|
410 if (sgroot->gtask_array != NULL) { |
1127
c4287bf771a0
CreatePolygonFromSceneGraph can work on Mac OSX.
Yutaka_Kinjyo
parents:
1126
diff
changeset
|
411 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
|
412 } |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1122
diff
changeset
|
413 |
1128 | 414 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
|
415 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
|
416 |
ab9b7d21b32b
removed real_matrix. sparated screen matrix from camera matrix.
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
1292
diff
changeset
|
417 CameraPtr camera = sgroot->getCamera(); |
1130 | 418 |
1136 | 419 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
|
420 if (t->size > 0) { |
1160 | 421 pp_sum_num += t->pp_num; |
422 for (int i = 0; i < t->pp_num; i++) { | |
423 | |
1138 | 424 HTaskPtr create_pp = manager->create_task(CreatePolygonFromSceneGraph); |
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_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
|
427 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
|
428 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
|
429 create_pp->set_inData(3,t->texture_info, sizeof(texture_list)); |
1138 | 430 |
431 if ( (unsigned long)t->matrix % 16) { | |
432 printf("marix not aligned\n"); | |
433 } | |
434 | |
435 if ((unsigned long)t->texture_info % 16) { | |
436 printf("texture_info not aligned\n"); | |
437 } | |
438 | |
1412
f40558ec00a8
remove duplicated spe task code source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1406
diff
changeset
|
439 create_pp->set_outData(0,out_pp, sizeof(PolygonPack)); |
1138 | 440 |
441 if (game_task_array != NULL) { | |
442 create_pp->wait_for(game_task_array); | |
443 } | |
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
|
444 |
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
|
445 PolygonPackPtr tmp_pp = (PolygonPackPtr)manager->allocate(sizeof(PolygonPack)); |
1129 | 446 |
1138 | 447 tmp_pp->init(); |
448 create_pp->set_param(0, (memaddr)tmp_pp); | |
449 out_pp = tmp_pp; | |
450 | |
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
|
451 //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
|
452 create_pp->set_cpu(CPU_PPE); |
1138 | 453 task_next->wait_for(create_pp); |
454 create_pp->spawn(); | |
455 } | |
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
|
456 } |
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
|
457 } |
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
|
458 } |
1126
6043da6e48f1
complete compile but not work yet.
yutaka@localhost.localdomain
parents:
1122
diff
changeset
|
459 |
1139 | 460 |
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
|
461 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
|
462 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
|
463 { |
1160 | 464 |
1421
3778a1eda68d
debuging spanpack destruction during DrawSpan
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
465 reinit_spackList() ; |
747 | 466 int range_base = spe_num; |
467 | |
539 | 468 // 切り上げのつもり |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
469 int range = (r[spi].spackList_length + range_base - 1) / range_base; |
539 | 470 |
471 for (int i = 0; i < range_base; i++) { | |
472 int index_start = range*i; | |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
473 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
|
474 ? 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
|
475 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
|
476 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
|
477 if (starty<=0) starty = 1; |
4955cedb17e5
endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
478 if (endy>height) endy = height; |
539 | 479 |
659 | 480 HTaskPtr task_create_sp = manager->create_task(CreateSpan); |
539 | 481 |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
617
diff
changeset
|
482 task_create_sp->set_param(0,index_start); |
747 | 483 |
539 | 484 /** |
485 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲 | |
486 * [ 1.. 80] [ 81..160] [161..240] | |
487 * [241..320] [321..400] [401..480] | |
488 * | |
489 * ex. screen_height が 1080, spenum が 5 の場合、 | |
490 * [ 1..216] [217..432] [433..648] | |
491 * [649..864] [865..1080] | |
492 */ | |
747 | 493 |
1056
4955cedb17e5
endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1050
diff
changeset
|
494 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
|
495 task_create_sp->set_param(2,endy); |
539 | 496 |
1412
f40558ec00a8
remove duplicated spe task code source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1406
diff
changeset
|
497 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
|
498 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
|
499 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
|
500 task_create_sp->set_inData(2,&r[spi].spackList[index_start], sizeof(SpanPack)); |
659 | 501 |
1107 | 502 task_next->wait_for(task_create_sp); |
539 | 503 |
747 | 504 task_create_sp->set_cpu(SPE_ANY); |
539 | 505 task_create_sp->spawn(); |
506 } | |
507 | |
508 } | |
509 | |
510 void | |
511 Viewer::common_draw(HTaskPtr task_next) | |
512 { | |
513 | |
615
184d6d3f0cd9
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
514 //task_next = manager->create_task(Dummy); |
539 | 515 //task_next->set_post(post2runLoop, (void*)this); |
516 | |
792 | 517 //Light info update |
1406 | 518 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
|
519 ppi ^= 1; |
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
520 r[ppi].ppack->clear(); |
914 | 521 |
986
b3a8545eb2fa
double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
985
diff
changeset
|
522 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
|
523 SpanPack *spack = &r[spi].spackList[i]; |
539 | 524 int startx = 1; |
525 int endx = split_screen_w; | |
526 | |
527 int starty = spack->info.y_top - split_screen_h + 1; | |
528 //int endy = spack->info.y_top; | |
529 int rangey = (starty + split_screen_h - 1 > this->height) | |
530 ? this->height - starty + 1 : split_screen_h; | |
531 | |
1152 | 532 #ifdef USE_TASKARRAY |
857 | 533 |
1157 | 534 int array_task_num = (this->width + split_screen_w - 1) / split_screen_w; |
535 HTaskPtr task_draw_array = manager->create_task_array(DrawSpan, array_task_num, 6, 1, rangey); | |
536 Task *task_draw = 0; | |
537 | |
857 | 538 while (startx < this->width) { |
539 | |
839 | 540 // Draw SpanPack |
857 | 541 |
839 | 542 task_draw = task_draw_array->next_task_array(DrawSpan,task_draw); |
543 task_draw->set_param(0,(memaddr)&pixels[(startx-1) + this->width*(starty-1)]); | |
544 task_draw->set_param(1,this->width); | |
545 task_draw->set_param(2,startx); | |
546 task_draw->set_param(3,endx); | |
547 task_draw->set_param(4,rangey); | |
548 task_draw->set_param(5,spack->info.size); | |
838 | 549 |
839 | 550 task_draw->set_inData(0,spack, sizeof(SpanPack)); |
551 | |
552 for (int i = 0; i < rangey; i++) { | |
857 | 553 task_draw->set_outData(i, |
554 &pixels[(startx-1) + this->width*(starty-1 + i) ], | |
555 (endx-startx+1)*sizeof(int)); | |
839 | 556 } |
557 | |
558 startx += split_screen_w; | |
559 endx += split_screen_w; | |
560 | |
561 if (endx > this->width) { | |
562 endx = this->width; | |
563 } | |
564 | |
857 | 565 } |
566 | |
567 task_draw_array->spawn_task_array(task_draw->next()); | |
568 task_draw_array->set_cpu(SPE_ANY); | |
1393 | 569 task_draw_array->wait_for(data_update_wait); |
1152 | 570 #ifndef USE_PIPELINE |
571 task_next->wait_for(task_draw_array); | |
572 #endif | |
857 | 573 task_draw_array->spawn(); |
574 #else | |
838 | 575 |
576 HTaskPtr task_draw; | |
577 | |
539 | 578 while (startx < this->width) { |
1154 | 579 if (spack->info.size > 0 || mem_flag == 1) { |
539 | 580 // Draw SpanPack |
615
184d6d3f0cd9
remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
603
diff
changeset
|
581 task_draw = manager->create_task(DrawSpan); |
539 | 582 |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
617
diff
changeset
|
583 task_draw->set_param(0, |
603
57ec231bc8ac
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
584 (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
|
585 task_draw->set_param(1,this->width); |
659 | 586 task_draw->set_param(2,startx); |
587 task_draw->set_param(3,endx); | |
588 task_draw->set_param(4,rangey); | |
838 | 589 task_draw->set_param(5,spack->info.size); |
659 | 590 |
1412
f40558ec00a8
remove duplicated spe task code source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1406
diff
changeset
|
591 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
|
592 |
617
df618a956eb9
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
593 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
|
594 task_draw->set_outData(i, |
617
df618a956eb9
Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
595 &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
|
596 (endx-startx+1)*sizeof(int)); |
616
350b9b8c985f
First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
615
diff
changeset
|
597 } |
838 | 598 |
857 | 599 } else { |
539 | 600 // 7.7.3 SL1 Data Cache Range Set to Zero コマンド |
601 // を使って、DMAでclearするべき... ということは、 | |
602 // それもSPEでやる方が良い? | |
857 | 603 memset(&pixels[(startx-1)+this->width*(starty-1)], |
604 0, (this->width)*sizeof(int)*rangey); | |
605 break; | |
606 } | |
539 | 607 |
747 | 608 task_draw->set_cpu(SPE_ANY); |
1152 | 609 #ifndef USE_PIPELINE |
539 | 610 task_next->wait_for(task_draw); |
1152 | 611 #endif |
539 | 612 task_draw->spawn(); |
613 | |
614 startx += split_screen_w; | |
615 endx += split_screen_w; | |
616 | |
617 if (endx > this->width) { | |
618 endx = this->width; | |
619 } | |
620 } | |
838 | 621 #endif |
622 | |
1145 | 623 } |
624 | |
1393 | 625 data_update_wait->spawn(); |
1145 | 626 |
925
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
627 if (profile) { |
983 | 628 if (frames % 50 == 49) { |
998 | 629 manager->show_profile(); |
983 | 630 this_time = get_ticks(); |
631 if (this_time != start_time) { | |
984 | 632 printf("\n%f FPS\n", ((((float)frames)*1000.0)/(this_time-start_time))); |
983 | 633 start_time = this_time; frames = 0; |
634 } | |
982
9f5e6bfb1c09
avoid WAIT in virtual console
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
981
diff
changeset
|
635 } |
925
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
636 } |
747 | 637 } |
638 | |
639 void | |
640 Viewer::run_finish() | |
641 { | |
642 dev->free_device(); | |
643 if (this_time != start_time) { | |
644 printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0); | |
645 } | |
925
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
646 if (profile) { |
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
647 manager->show_profile(); |
292bb8c79cdb
add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
918
diff
changeset
|
648 } |
747 | 649 |
650 delete sgroot; | |
651 // delete sgroot_2; | |
652 quit(); | |
539 | 653 } |
654 | |
655 /* end */ |