annotate Renderer/Engine/viewer.cc @ 914:05696567d1d2

0 is filled on the spe side.
author yutaka@localhost.localdomain
date Thu, 22 Jul 2010 00:23:37 +0900
parents b2ca394bbd50
children ad10d6d39ca6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <SDL.h>
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include "viewer.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "viewer_types.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "SceneGraph.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include "SceneGraphRoot.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "scene_graph_pack.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "sys.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "Func.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "error.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "TaskManager.h"
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include <wchar.h>
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "Pad.h"
511
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 510
diff changeset
13 #include "Application.h"
575
0f13810d4492 Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 572
diff changeset
14 #include "lindaapi.h"
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
523
b273767962b8 half finish for Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 514
diff changeset
16 static void post2runLoop(SchedTask *s,void *viewer,void *s1);
b273767962b8 half finish for Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 514
diff changeset
17 static void post2runDraw(SchedTask *s,void *viewer,void *s1);
b273767962b8 half finish for Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 514
diff changeset
18 static void post2speRendering(SchedTask *s,void *viewer,void *s1);
b273767962b8 half finish for Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 514
diff changeset
19 static void post2speDraw(SchedTask *s,void *viewer,void *s1);
b273767962b8 half finish for Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 514
diff changeset
20 static void post2runMoveDrawLoop(SchedTask *s,void *viewer,void *s1);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 /* measure for FPS (Frame Per Second) */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 int start_time;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 int this_time;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 int frames;
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
26 // static void post2speRunLoop(void *viewer);
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
27 //static void post2runMove(void *viewer);
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
28 //static void post2exchange_sgroot(void *viewer);
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
29 //static void post2speRunLoop(void *viewer);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 //SceneGraphRootPtr sgroot_2;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 /* Data Pack sent to Other CPUs (ex. SPE) */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 SceneGraphPack *sgpack;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 PolygonPack *ppack;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 SpanPackPtr spackList;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 SpanPackPtr *spackList_ptr;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 int spackList_length;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 int spackList_length_align;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
42
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
47 Viewer::Viewer(TaskManager *m, ViewerDevice *vd, int b, int w, int h, int _num)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 spe_num = _num;
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
50 manager = m;
895
bed529c55eda add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 891
diff changeset
51
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
52 dev = vd;
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
53 pixels = dev->video_init(manager, b, w, h);
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
54
895
bed529c55eda add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 891
diff changeset
55 width = dev->width;
bed529c55eda add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 891
diff changeset
56 height = dev->height;
bed529c55eda add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 891
diff changeset
57 bpp = dev->bpp;
bed529c55eda add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 891
diff changeset
58
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 int
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 Viewer::get_ticks(void)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 int time;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 time = SDL_GetTicks();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 return time;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 bool
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 Viewer::quit_check(void)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 SDL_Event event;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 while(SDL_PollEvent(&event)) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 if (event.type==SDL_QUIT) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 return true;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 Uint8 *keys=SDL_GetKeyState(NULL);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 if (keys[SDLK_q] == SDL_PRESSED) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 return true;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 return false;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 void
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 Viewer::quit(void)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 SDL_Quit();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 void
509
8148c81d2660 Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 507
diff changeset
97 Viewer::run_init(TaskManager *manager, Application *app)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 this->manager = manager;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 start_time = get_ticks();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 this_time = 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 frames = 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
105 if (spe_num == 0) spe_num = 1;
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
106
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 sgroot = new SceneGraphRoot(this->width, this->height);
572
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
108 sgroot->tmanager = manager;
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
109
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
110
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
111 int light_num = 4;
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
112 int size = sizeof(float)*4*light_num; //xyz+alfa(4) * light_num(4)
762
10a8a80c2ea7 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 760
diff changeset
113 int light_size = size / sizeof(float);
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
114
760
24a37fe8419a first of all commit, not work Rendering/Test/create_task
hiroki
parents: 748
diff changeset
115 light_xyz_stock = (float *)manager->allocate(size);
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
116 light_xyz = (float *)manager->allocate(size);
762
10a8a80c2ea7 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 760
diff changeset
117
10a8a80c2ea7 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 760
diff changeset
118 for (int i = 0; i < light_size ; i++) {
10a8a80c2ea7 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 760
diff changeset
119 light_xyz[i] = 0.0f;
10a8a80c2ea7 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 760
diff changeset
120 }
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
121
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
122
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
123 for(int i = 0; i < spe_num; i++) {
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
124
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
125 HTaskPtr data_load = manager->create_task(DataLoad);
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
126 data_load->set_param(0,(memaddr)size);
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
127 data_load->set_param(1,(memaddr)Light);
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
128 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
129 data_load->spawn();
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
130 }
509
8148c81d2660 Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 507
diff changeset
131
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
132 size = light_num * sizeof(int);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
133 light_switch = (int*)manager->allocate(size);
793
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
134
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
135 for (int i = 0; i < light_num; i++) {
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
136 light_switch[i] = 0;
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
137 }
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
138
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
139 for(int i = 0; i < spe_num; i++) {
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
140 HTaskPtr data_load = manager->create_task(DataLoad);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
141 data_load->set_param(0,(memaddr)size);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
142 data_load->set_param(1,(memaddr)LightSwitch);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
143 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
144 data_load->spawn();
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
145 }
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
146
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
147 size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
148
793
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
149 light_sysswitch = (int*)manager->allocate(size);
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
150
843
0c7d885f0c92 cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 842
diff changeset
151 for (unsigned int i = 0; i < size / sizeof(int); i++) {
793
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
152 light_sysswitch[i] = 0;
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
153 }
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
154
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
155 for(int i = 0; i < spe_num; i++) {
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
156 HTaskPtr data_load = manager->create_task(DataLoad);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
157 data_load->set_param(0,(memaddr)size);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
158 data_load->set_param(1,(memaddr)LightSysSwitch);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
159 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
160 data_load->spawn();
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
161 }
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
162
511
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 510
diff changeset
163 MainLoop *mainloop = app->init(this, this->width, this->height);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 510
diff changeset
164 mainloop->mainLoop();
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 HTaskPtr
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 Viewer::initLoop()
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 HTaskPtr task_next;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 HTaskPtr task_tex;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 sgpack = (SceneGraphPack*)manager->allocate(sizeof(SceneGraphPack));
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 sgpack->init();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 ppack = (PolygonPack*)manager->allocate(sizeof(PolygonPack));
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 spackList_length = (this->height + split_screen_h - 1) / split_screen_h;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*spackList_length);
913
b2ca394bbd50 set_game_task fix.
tkaito
parents: 909
diff changeset
180 printf("spackList %0x height %d\n",(unsigned long)spackList, this->height);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 * SPU に送る address list は 16 バイト倍数でないといけない。
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 * length_align を求めている。はみ出した部分は使われない
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 * (ex) spackList_length が 13 の場合
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 * spackList_length_align = 16;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 * 実際に送るデータは64バイトになるのでOK
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 * 14,15,16 の部分は何も入らない。
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 spackList_length_align = (spackList_length + 3)&(~3);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 /* 各 SPU が持つ、SpanPack の address list */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 spackList_ptr =
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 (SpanPack**)manager->allocate(sizeof(SpanPack*)*spackList_length_align);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 for (int i = 0; i < spackList_length; i++) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 spackList_ptr[i] = &spackList[i];
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 for (int i = 1; i <= spackList_length; i++) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 spackList[i-1].init(i*split_screen_h);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
205 task_next = manager->create_task(Dummy,0,0,0,0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206
652
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
207 // ここは、Iterator を用意するべきだよね
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 for (int i = 0; i < spe_num; i++) {
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
209 task_tex = manager->create_task(LoadTexture,0,0,0,0);
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
210 task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + i));
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
211 task_next->wait_for(task_tex);
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
212 task_tex->spawn();
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
215
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 return task_next;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 void
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 Viewer::getKey()
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 Pad *pad = sgroot->getController();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 if (pad->right.isHold()) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 keyPtr->right = HOLD;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 } else if (pad->right.isPush()) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 keyPtr->right = PUSH;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 } else {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 keyPtr->right = NONE;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 if (pad->left.isHold()) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 keyPtr->left = HOLD;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 } else if (pad->left.isPush()) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 keyPtr->left = PUSH;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 } else {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 keyPtr->left = NONE;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 if (pad->up.isHold()) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 keyPtr->up = HOLD;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 } else if (pad->up.isPush()) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 keyPtr->up = PUSH;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 } else {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 keyPtr->up = NONE;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 if (pad->down.isHold()) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 keyPtr->down = HOLD;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 } else if (pad->down.isPush()) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 keyPtr->down = PUSH;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 } else {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 keyPtr->down = NONE;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 if (pad->circle.isHold()) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 keyPtr->circle = HOLD;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 } else if (pad->circle.isPush()) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 keyPtr->circle = PUSH;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 } else {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 keyPtr->circle = NONE;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 static void
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
266 post2runMoveDrawLoop(SchedTask *m, void *viewer_, void *arg)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 Viewer *viewer = (Viewer*)viewer_;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269
625
60aa3f241b10 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
270 // 同じ PPE 上なので sgroot(ポインタ) を set_param で送る。
614
4e44147d78ee remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
271 //HTaskPtr send_key_task = viewer->manager->create_task(SendKey);
625
60aa3f241b10 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
272 //send_key_task->set_param((int)sgroot);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 // set input data -> viewer keyPtr
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 viewer->getKey();
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
275 //HTaskPtr update_key = viewer->manager->create_task(UpdateKey,viewer->keyPtr, sizeof(key_stat),0,0);
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
276 HTaskPtr update_key = viewer->manager->create_task(UpdateKey,0,0,0,0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 update_key->add_inData(viewer->keyPtr, sizeof(key_stat));
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
278 //update_key->set_cpu(SPE_0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 update_key->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 /* TASK_MOVE は外から引数で取ってくるべき */
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 //HTaskPtr move_task = viewer->manager->create_task(viewer->app->move_taskid);
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
283 HTaskPtr move_task = viewer->manager->create_task(Move,0,0,0,0);
625
60aa3f241b10 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
284 //move_task->set_param(sgroot);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285
614
4e44147d78ee remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
286 //HTaskPtr draw_task = viewer->manager->create_task(Draw);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 /* rendering task test */
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
289 HTaskPtr draw_task = viewer->manager->create_task(Dummy,0,0,0,0);
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
290 HTaskPtr draw_dummy = viewer->manager->create_task(Dummy,0,0,0,0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
292 HTaskPtr switch_task = viewer->manager->create_task(Switch,0,0,0,0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 viewer->draw_dummy = draw_dummy;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 switch_task->wait_for(draw_dummy);
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
295 draw_task->set_post(post2speRendering, (void*)viewer, 0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 switch_task->wait_for(move_task);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 switch_task->wait_for(draw_task);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 move_task->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 draw_task->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
302 switch_task->set_post(post2runMoveDrawLoop, (void*)viewer, 0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 switch_task->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 void
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 Viewer::mainLoop()
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 HTaskPtr task_next = initLoop();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
311
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
312 task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 task_next->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
315
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 void
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
317 Viewer::run_loop(HTaskPtr task_next)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 {
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
319 dev->clear_screen();
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
320
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
321 bool quit_flg;
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
322 quit_flg = quit_check();
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
323 if (quit_flg == true) {
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
324 this_time = get_ticks();
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
325 run_finish();
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
326 return;
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
327 }
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
328
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
329 dev->clean_pixels();
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
330
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
331 for (int i = 1; i <= spackList_length; i++) {
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
332 spackList[i-1].reinit(i*split_screen_h);
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
333 }
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
334
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
335 sgroot->updateControllerState();
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
336 sgroot->allExecute(width, height);
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
337 light_xyz_stock = sgroot->getLightVector();
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
338 light_switch_stock = sgroot->getLightSwitch();
793
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
339 light_sysswitch_stock = sgroot->getLightSysSwitch();
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
340 //sgroot->checkRemove();
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
341
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
342 // ここから下は Rendering という関数にする
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
343 rendering(task_next);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
345
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
346
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
347
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 void
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 Viewer::run_collision()
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
352
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 void
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
354 post2rendering(SchedTask *s, void *viewer_, void *arg)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 Viewer *viewer = (Viewer *)viewer_;
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
357 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 viewer->rendering(task_next);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
360
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 void
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 Viewer::rendering(HTaskPtr task_next)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 {
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
364 common_rendering(task_next, sgroot);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
365
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 // Barrier 同期
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 // run_draw() を呼ぶ post2runDraw
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
368 task_next->set_post(post2runDraw, (void*)this, 0); // set_post(function(this->run_draw()), NULL)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 task_next->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
370
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 // TASK_CREATE_SPAN が全て終わったら DUMMY_TASK が Viewer::run_draw() を呼ぶ
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
373
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 static void
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
375 post2runLoop(SchedTask *s, void *viewer_, void *arg)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 Viewer *viewer = (Viewer*)viewer_;
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
378 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 viewer->run_loop(task_next);
575
0f13810d4492 Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 572
diff changeset
380 psx_sync_n();
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
382
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 static void
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
384 post2runDraw(SchedTask *s, void *viewer_, void *arg)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 Viewer *viewer = (Viewer*)viewer_;
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
387 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 viewer->run_draw(task_next);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
391
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 void
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 common_draw(task_next);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
396
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
397 task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
398 task_next->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
400
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 frames++;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
403
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
404
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 static void
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
406 post2speRendering(SchedTask *s, void *viewer_, void *arg)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 Viewer *viewer = (Viewer*)viewer_;
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
409 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 viewer->spe_rendering(task_next);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
412
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 void
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 Viewer::spe_rendering(HTaskPtr task_next)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 {
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
416 common_rendering(task_next, sgroot);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
417
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 this->draw_dummy->wait_for(task_next);
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
419 task_next->set_post(post2speDraw, (void*)this, 0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 task_next->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
421
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
423
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 static void
514
2659376067e8 old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 511
diff changeset
425 post2speDraw(SchedTask *s, void *viewer_, void *arg)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 Viewer *viewer = (Viewer*)viewer_;
826
a6a6cd8d8499 RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 802
diff changeset
428 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 viewer->spe_draw(task_next);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 void
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 Viewer::spe_draw(HTaskPtr task_next)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 common_draw(task_next);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 this->draw_dummy->wait_for(task_next);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 task_next->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 this->draw_dummy->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
440
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 frames++;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
444
908
Yutaka_Kinjyo
parents: 907
diff changeset
445 // 完全にMac仕様。。sg_matrix を allocate してやらないといけないよ。
Yutaka_Kinjyo
parents: 907
diff changeset
446 void
Yutaka_Kinjyo
parents: 907
diff changeset
447 copy_matrix(SceneGraphPtr sg) {
Yutaka_Kinjyo
parents: 907
diff changeset
448
Yutaka_Kinjyo
parents: 907
diff changeset
449 float *matrix = sg->matrix;
Yutaka_Kinjyo
parents: 907
diff changeset
450 float *real_matrix = sg->real_matrix;
Yutaka_Kinjyo
parents: 907
diff changeset
451
Yutaka_Kinjyo
parents: 907
diff changeset
452 for (int i = 0; i < 16; i++) {
Yutaka_Kinjyo
parents: 907
diff changeset
453 sg->sg_matrix[i] = matrix[i];
Yutaka_Kinjyo
parents: 907
diff changeset
454 sg->sg_matrix[i+16] = real_matrix[i];
Yutaka_Kinjyo
parents: 907
diff changeset
455 }
Yutaka_Kinjyo
parents: 907
diff changeset
456
Yutaka_Kinjyo
parents: 907
diff changeset
457 }
Yutaka_Kinjyo
parents: 907
diff changeset
458
Yutaka_Kinjyo
parents: 907
diff changeset
459 void
Yutaka_Kinjyo
parents: 907
diff changeset
460 print_matrix(float *matrix) {
Yutaka_Kinjyo
parents: 907
diff changeset
461
Yutaka_Kinjyo
parents: 907
diff changeset
462 for (int i = 0; i < 32; i++) {
Yutaka_Kinjyo
parents: 907
diff changeset
463 printf("%f\n",matrix[i]);
Yutaka_Kinjyo
parents: 907
diff changeset
464 }
Yutaka_Kinjyo
parents: 907
diff changeset
465
Yutaka_Kinjyo
parents: 907
diff changeset
466 }
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
467
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
468 void
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
469 add_matrix_list(SceneGraphPtr sg, TaskManager *manager, MatrixListInfo* info) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
470
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
471 MatrixList *matrix_list = (MatrixList*)manager->allocate(sizeof(MatrixList));
908
Yutaka_Kinjyo
parents: 907
diff changeset
472
Yutaka_Kinjyo
parents: 907
diff changeset
473 copy_matrix(sg);
Yutaka_Kinjyo
parents: 907
diff changeset
474 #if SPE_CREATE_POLYGON_CHECK
Yutaka_Kinjyo
parents: 907
diff changeset
475 print_matrix(sg->sg_matrix);
Yutaka_Kinjyo
parents: 907
diff changeset
476 #endif
Yutaka_Kinjyo
parents: 907
diff changeset
477
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
478 matrix_list->matrix = sg->sg_matrix;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
479 matrix_list->next = NULL;
908
Yutaka_Kinjyo
parents: 907
diff changeset
480
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
481
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
482 if (info->last != NULL) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
483 info->last->next = matrix_list;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
484 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
485
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
486 info->last = matrix_list;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
487
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
488 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
489
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
490 void
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
491 new_matrix_info(SceneGraphPtr sg, TaskManager *manager, MatrixListInfo* info) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
492
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
493 MatrixListInfo *next = NULL;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
494
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
495 if (info->id == -1) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
496
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
497 info->id = sg->sgid;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
498 next = info;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
499
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
500 } else {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
501
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
502 MatrixListInfo* t;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
503
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
504 for (t = info; t->next != NULL; t = t->next) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
505 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
506
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
507 next = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo));
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
508 next->id = sg->sgid;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
509 next->next = NULL;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
510 t->next = next;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
511
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
512 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
513
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
514 MatrixList *new_list = (MatrixList*)manager->allocate(sizeof(MatrixList));
908
Yutaka_Kinjyo
parents: 907
diff changeset
515 copy_matrix(sg);
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
516 new_list->matrix = sg->sg_matrix;
908
Yutaka_Kinjyo
parents: 907
diff changeset
517 #if SPE_CREATE_POLYGON_CHECK
Yutaka_Kinjyo
parents: 907
diff changeset
518 print_matrix(sg->sg_matrix);
Yutaka_Kinjyo
parents: 907
diff changeset
519 #endif
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
520 new_list->next = NULL;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
521
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
522 next->first = new_list;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
523 next->last = new_list;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
524
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
525 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
526
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
527 void
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
528 collect_matrix(SceneGraphPtr sg, MatrixListInfo *matrix_info, TaskManager *manager) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
529
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
530 matrix_info->id = -1;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
531 matrix_info->next = NULL;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
532 matrix_info->first = NULL;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
533 matrix_info->last = NULL;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
534
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
535 while (sg) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
536
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
537 if (sg->flag_drawable) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
538
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
539 int flag = 0;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
540
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
541 for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
542 if (sg->sgid == t->id) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
543 add_matrix_list(sg, manager, t);
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
544 flag = 1;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
545 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
546 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
547
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
548 if (flag != 1) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
549 new_matrix_info(sg, manager, matrix_info);
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
550 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
551
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
552 // search SceneGraph. でも、ただのリストがあったハズだから、あとでそれに直す。はず・・
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
553 if (sg->children != NULL) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
554 sg = sg->children;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
555 } else if (sg->brother != NULL) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
556 sg = sg->brother;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
557 } else {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
558 while (sg) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
559 if (sg->brother != NULL) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
560 sg = sg->brother;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
561 break;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
562 } else {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
563 if (sg->parent == NULL) {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
564 sg = NULL;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
565 break;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
566 } else {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
567 sg = sg->parent;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
568 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
569 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
570 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
571 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
572 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
573 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
574 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
575
908
Yutaka_Kinjyo
parents: 907
diff changeset
576 void
909
Yutaka_Kinjyo
parents: 908
diff changeset
577 Viewer::check_matrix(MatrixListInfo *matrix_info,SceneGraphPtr sg) {
908
Yutaka_Kinjyo
parents: 907
diff changeset
578
Yutaka_Kinjyo
parents: 907
diff changeset
579 for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) {
Yutaka_Kinjyo
parents: 907
diff changeset
580 for (MatrixList* u = t->first; u != NULL; u = u->next) {
Yutaka_Kinjyo
parents: 907
diff changeset
581 print_matrix(u->matrix);
Yutaka_Kinjyo
parents: 907
diff changeset
582 }
Yutaka_Kinjyo
parents: 907
diff changeset
583 }
Yutaka_Kinjyo
parents: 907
diff changeset
584
Yutaka_Kinjyo
parents: 907
diff changeset
585 }
Yutaka_Kinjyo
parents: 907
diff changeset
586
Yutaka_Kinjyo
parents: 907
diff changeset
587 void
909
Yutaka_Kinjyo
parents: 908
diff changeset
588 Viewer::create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next,
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
589 MatrixListInfo *matrix_info)
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
590 {
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
591
908
Yutaka_Kinjyo
parents: 907
diff changeset
592 //HTaskPtr create_pp_wait = manager->create_task(Dummy);
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
593 // どれくらい allocate するかわ、よくわからないけど。
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
594 // とりあえず、16k ぐらいにしておく。
908
Yutaka_Kinjyo
parents: 907
diff changeset
595 // int sg_size = 16*1024;
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
596
908
Yutaka_Kinjyo
parents: 907
diff changeset
597 // for (int i = 0; i < spe_num; i++) {
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
598
908
Yutaka_Kinjyo
parents: 907
diff changeset
599 // HTaskPtr data_load = manager->create_task(DataLoad);
Yutaka_Kinjyo
parents: 907
diff changeset
600 // data_load->set_param(0,(memaddr)sg_size);
Yutaka_Kinjyo
parents: 907
diff changeset
601 // data_load->set_param(1,(memaddr)SG_COORD);
Yutaka_Kinjyo
parents: 907
diff changeset
602 // task_next->wait_for(data_load);
Yutaka_Kinjyo
parents: 907
diff changeset
603 // data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
Yutaka_Kinjyo
parents: 907
diff changeset
604 // data_load->spawn();
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
605
908
Yutaka_Kinjyo
parents: 907
diff changeset
606 // }
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
607
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
608 float *cur_coord_pack = sg->coord_pack;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
609 int coord_pack_size = sg->coord_pack_size;
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
610
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
611 collect_matrix(sg, matrix_info, manager);
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
612
908
Yutaka_Kinjyo
parents: 907
diff changeset
613 //return create_pp_wait;
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
614
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
615 }
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
616
860
649e4cb84683 Still on the way
yutaka@localhost.localdomain
parents: 857
diff changeset
617 void
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
618 Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
619 {
860
649e4cb84683 Still on the way
yutaka@localhost.localdomain
parents: 857
diff changeset
620
649e4cb84683 Still on the way
yutaka@localhost.localdomain
parents: 857
diff changeset
621 #if SPE_CREATE_POLYGON
649e4cb84683 Still on the way
yutaka@localhost.localdomain
parents: 857
diff changeset
622
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
623 SceneGraphPtr sg = sgroot->getDrawSceneGraph();
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
624
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
625 MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo));
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
626 create_pp_task(sg, manager, spe_num, task_next, matrix_info);
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
627
908
Yutaka_Kinjyo
parents: 907
diff changeset
628 #if SPE_CREATE_POLYGON_CHECK
Yutaka_Kinjyo
parents: 907
diff changeset
629 check_matrix(matrix_info,sg);
Yutaka_Kinjyo
parents: 907
diff changeset
630 #endif
Yutaka_Kinjyo
parents: 907
diff changeset
631
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
632
909
Yutaka_Kinjyo
parents: 908
diff changeset
633
Yutaka_Kinjyo
parents: 908
diff changeset
634 #else
907
62838c1cd4b0 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
635
614
4e44147d78ee remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
636 HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
637
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 // SceneGraph(木構造) -> PolygonPack
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
639
625
60aa3f241b10 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
640 task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph());
60aa3f241b10 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
641 task_create_pp->set_param(1,(memaddr)ppack);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
642
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 task_next->wait_for(task_create_pp);
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
644
909
Yutaka_Kinjyo
parents: 908
diff changeset
645 #endif
Yutaka_Kinjyo
parents: 908
diff changeset
646
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
647 int range_base = spe_num;
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
648
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 // 切り上げのつもり
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 int range = (spackList_length + range_base - 1) / range_base;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
651
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 for (int i = 0; i < range_base; i++) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 int index_start = range*i;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 int index_end = (index_start + range >= spackList_length)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 ? spackList_length : index_start + range;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
656
652
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
657 HTaskPtr task_create_sp = manager->create_task(CreateSpan);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
658
625
60aa3f241b10 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
659 task_create_sp->set_param(0,index_start);
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
660
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
661 /**
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
662 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 * [ 1.. 80] [ 81..160] [161..240]
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 * [241..320] [321..400] [401..480]
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 *
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 * ex. screen_height が 1080, spenum が 5 の場合、
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
667 * [ 1..216] [217..432] [433..648]
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
668 * [649..864] [865..1080]
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 */
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
670
625
60aa3f241b10 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
671 task_create_sp->set_param(1,index_start*split_screen_h + 1);
60aa3f241b10 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
672 task_create_sp->set_param(2,index_end*split_screen_h);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
673
652
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
674 task_create_sp->add_inData(ppack, sizeof(PolygonPack));
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
675 task_create_sp->add_inData(spackList_ptr,
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
676 sizeof(SpanPack*)*spackList_length_align);
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
677 task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack));
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
678
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
679 task_next->wait_for(task_create_sp);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 task_create_sp->wait_for(task_create_pp);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
681
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
682 task_create_sp->set_cpu(SPE_ANY);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 task_create_sp->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
685
860
649e4cb84683 Still on the way
yutaka@localhost.localdomain
parents: 857
diff changeset
686 task_create_pp->spawn();
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
687
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
689
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
690 HTaskPtr
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
691 Viewer::update_task_create(void *data, int size,
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
692 int load_id, int spe_id, HTaskPtr wait)
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
693 {
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
694
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
695 HTaskPtr data_update = manager->create_task(DataUpdate);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
696 data_update->add_inData(data,size);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
697 data_update->set_param(0,size);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
698 data_update->set_param(1,load_id);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
699 data_update->set_cpu((CPU_TYPE)(spe_id));
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
700 if (wait != NULL) {
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
701 wait->wait_for(data_update);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
702 }
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
703 data_update->spawn();
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
704
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
705 return data_update;
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
706
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
707 }
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
708
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
709 void
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 Viewer::common_draw(HTaskPtr task_next)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
712
614
4e44147d78ee remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
713 //task_next = manager->create_task(Dummy);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 //task_next->set_post(post2runLoop, (void*)this);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
715
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
716 //Light info update
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
717
793
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
718 //HTaskPtr data_update;
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
719 HTaskPtr data_update_wait;
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
720 int light_num = 4;
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
721 int size = sizeof(float)*4*light_num; //xyz+alpha(4) * light_num(4)
762
10a8a80c2ea7 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 760
diff changeset
722 int light_size = size / sizeof(float);
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
723
762
10a8a80c2ea7 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 760
diff changeset
724 for (int i = 0; i < light_size; i++) {
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
725 light_xyz[i] = light_xyz_stock[i];
762
10a8a80c2ea7 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 760
diff changeset
726 }
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
727
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
728 for (int i = 0; i < light_num; i++) {
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
729 light_switch[i] = light_switch_stock[i];
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
730 }
793
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
731
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
732 light_sysswitch[0] = light_sysswitch_stock;
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
733
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
734 data_update_wait = manager->create_task(DataUpdate);
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
735 data_update_wait->add_inData(light_xyz,size);
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
736 data_update_wait->set_param(0,size);
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
737 data_update_wait->set_param(1,Light);
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
738 data_update_wait->set_cpu((CPU_TYPE)((int)SPE_0));
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
739
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
740 for (int i = 1; i < spe_num; i++) {
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
741 update_task_create(light_xyz,size,Light,(int)SPE_0+i,data_update_wait);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
742 }
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
743
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
744 size = light_num * sizeof(int);
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
745
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
746 for (int i = 0; i < spe_num; i++) {
793
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
747 update_task_create(light_switch,size,LightSwitch,(int)SPE_0+i,data_update_wait);
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
748 }
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
749
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
750 size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
751
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
752 for (int i = 0; i < spe_num; i++) {
793
c260205d3185 add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
753 update_task_create(light_sysswitch,size,LightSysSwitch,(int)SPE_0+i,data_update_wait);
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
754 }
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
755
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
756 ppack->clear();
914
05696567d1d2 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
757
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 for (int i = 0; i < spackList_length; i++) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 SpanPack *spack = &spackList[i];
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
760 int startx = 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 int endx = split_screen_w;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
762
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
763 int starty = spack->info.y_top - split_screen_h + 1;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 //int endy = spack->info.y_top;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
765 int rangey = (starty + split_screen_h - 1 > this->height)
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 ? this->height - starty + 1 : split_screen_h;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
767
889
b150914f5976 minor fix. Redering Engine not worked yet.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 885
diff changeset
768 #if 1
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
769
914
05696567d1d2 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
770 // mem_flag は spe 側で黒い部分を 0 で埋めるフラグ
05696567d1d2 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
771 if(spack->info.size > 0 || mem_flag == 1) {
838
41302b72c895 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
772
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
773 int array_task_num = (this->width + split_screen_w - 1) / split_screen_w;
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
774 HTaskPtr task_draw_array = manager->create_task_array(DrawSpan, array_task_num, 6, 1, rangey);
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
775 Task *task_draw = 0;
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
776
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
777 while (startx < this->width) {
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
778
839
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
779 // Draw SpanPack
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
780
839
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
781 task_draw = task_draw_array->next_task_array(DrawSpan,task_draw);
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
782 task_draw->set_param(0,(memaddr)&pixels[(startx-1) + this->width*(starty-1)]);
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
783 task_draw->set_param(1,this->width);
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
784 task_draw->set_param(2,startx);
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
785 task_draw->set_param(3,endx);
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
786 task_draw->set_param(4,rangey);
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
787 task_draw->set_param(5,spack->info.size);
838
41302b72c895 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
788
839
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
789 task_draw->set_inData(0,spack, sizeof(SpanPack));
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
790
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
791 for (int i = 0; i < rangey; i++) {
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
792 task_draw->set_outData(i,
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
793 &pixels[(startx-1) + this->width*(starty-1 + i) ],
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
794 (endx-startx+1)*sizeof(int));
839
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
795 }
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
796
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
797 startx += split_screen_w;
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
798 endx += split_screen_w;
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
799
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
800 if (endx > this->width) {
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
801 endx = this->width;
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
802 }
71350a51c391 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
803
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
804 }
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
805
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
806 task_draw_array->spawn_task_array(task_draw->next());
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
807 task_draw_array->set_cpu(SPE_ANY);
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
808 task_next->wait_for(task_draw_array);
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
809 task_draw_array->wait_for(data_update_wait);
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
810 task_draw_array->spawn();
854
6aa20c0dd8f8 may be need ppeManager
yutaka@localhost.localdomain
parents: 843
diff changeset
811
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
812
914
05696567d1d2 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
813
05696567d1d2 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
814 } else {
05696567d1d2 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
815
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
816 memset(&pixels[(startx-1)+this->width*(starty-1)],
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
817 0, (this->width)*sizeof(int)*rangey);
838
41302b72c895 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
818
914
05696567d1d2 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
819 }
05696567d1d2 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
820
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
821
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
822 #else
838
41302b72c895 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
823
41302b72c895 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
824 HTaskPtr task_draw;
41302b72c895 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
825
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
826 while (startx < this->width) {
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
827 if (spack->info.size > 0) {
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
828 // Draw SpanPack
614
4e44147d78ee remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
829 task_draw = manager->create_task(DrawSpan);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
830
625
60aa3f241b10 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
831 task_draw->set_param(0,
603
42c94f85c779 long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 602
diff changeset
832 (memaddr)&pixels[(startx-1) + this->width*(starty-1)]);
625
60aa3f241b10 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
833 task_draw->set_param(1,this->width);
652
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
834 task_draw->set_param(2,startx);
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
835 task_draw->set_param(3,endx);
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
836 task_draw->set_param(4,rangey);
838
41302b72c895 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
837 task_draw->set_param(5,spack->info.size);
652
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
838
dbe137505f2e bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
839 task_draw->add_inData(spack, sizeof(SpanPack));
615
f7d78b3c1106 First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 614
diff changeset
840
616
f21603a335aa Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
841 for (int i = 0; i < rangey; i++) {
615
f7d78b3c1106 First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 614
diff changeset
842 task_draw->add_outData(
616
f21603a335aa Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
843 &pixels[(startx-1) + this->width*(starty-1 + i) ],
f21603a335aa Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
844 (endx-startx+1)*sizeof(int));
615
f7d78b3c1106 First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 614
diff changeset
845 }
838
41302b72c895 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
846
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
847 } else {
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
848 // 7.7.3 SL1 Data Cache Range Set to Zero コマンド
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 // を使って、DMAでclearするべき... ということは、
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 // それもSPEでやる方が良い?
857
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
851 memset(&pixels[(startx-1)+this->width*(starty-1)],
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
852 0, (this->width)*sizeof(int)*rangey);
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
853 break;
f7276b509710 DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
854 }
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
855
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
856 task_draw->set_cpu(SPE_ANY);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 task_next->wait_for(task_draw);
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
858 task_draw->wait_for(data_update_wait);
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 task_draw->spawn();
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
860
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
861 startx += split_screen_w;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 endx += split_screen_w;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
863
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 if (endx > this->width) {
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 endx = this->width;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 }
838
41302b72c895 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
868 #endif
41302b72c895 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
869
792
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
870 }
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
871
f2497e0ecd7c add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
872 data_update_wait->spawn();
748
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
873
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
874 }
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
875
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
876 void
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
877 Viewer::run_finish()
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
878 {
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
879 dev->free_device();
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
880 if (this_time != start_time) {
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
881 printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0);
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
882 }
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
883
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
884 delete sgroot;
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
885 // delete sgroot_2;
b7376415fa5f TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 652
diff changeset
886 quit();
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
887 }
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
888
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
889 /* end */