annotate Renderer/Engine/viewer.cc @ 857:2fa8943d989a draft

DrawSpan taskArray bug fix
author yutaka@localhost.localdomain
date Thu, 10 Jun 2010 23:21:51 +0900
parents 293fcceaac36
children 63a08f3a468a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <SDL.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include "viewer.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "viewer_types.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "SceneGraph.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include "SceneGraphRoot.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "scene_graph_pack.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "sys.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "Func.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "error.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "TaskManager.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include <wchar.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "Pad.h"
543
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 542
diff changeset
13 #include "Application.h"
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 572
diff changeset
14 #include "lindaapi.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
555
c5e09e9bbfa5 half finish for Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 550
diff changeset
16 static void post2runLoop(SchedTask *s,void *viewer,void *s1);
c5e09e9bbfa5 half finish for Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 550
diff changeset
17 static void post2runDraw(SchedTask *s,void *viewer,void *s1);
c5e09e9bbfa5 half finish for Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 550
diff changeset
18 static void post2speRendering(SchedTask *s,void *viewer,void *s1);
c5e09e9bbfa5 half finish for Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 550
diff changeset
19 static void post2speDraw(SchedTask *s,void *viewer,void *s1);
c5e09e9bbfa5 half finish for Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 550
diff changeset
20 static void post2runMoveDrawLoop(SchedTask *s,void *viewer,void *s1);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 /* measure for FPS (Frame Per Second) */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 int start_time;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 int this_time;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 int frames;
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
26 // static void post2speRunLoop(void *viewer);
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
27 //static void post2runMove(void *viewer);
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
28 //static void post2exchange_sgroot(void *viewer);
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
29 //static void post2speRunLoop(void *viewer);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 //SceneGraphRootPtr sgroot_2;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 /* Data Pack sent to Other CPUs (ex. SPE) */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 SceneGraphPack *sgpack;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 PolygonPack *ppack;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 SpanPackPtr spackList;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 SpanPackPtr *spackList_ptr;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 int spackList_length;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 int spackList_length_align;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
46 Viewer::Viewer(TaskManager *m, ViewerDevice *vd, int b, int w, int h, int _num)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 bpp = b;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 width = w;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 height = h;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 spe_num = _num;
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
52 manager = m;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
53 dev = vd;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
54 pixels = dev->video_init(manager, b, w, h);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
55
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 Viewer::get_ticks(void)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 int time;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 time = SDL_GetTicks();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 return time;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 bool
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 Viewer::quit_check(void)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 SDL_Event event;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 while(SDL_PollEvent(&event)) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 if (event.type==SDL_QUIT) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 return true;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 Uint8 *keys=SDL_GetKeyState(NULL);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 if (keys[SDLK_q] == SDL_PRESSED) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 return true;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 return false;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 Viewer::quit(void)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 SDL_Quit();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 void
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
94 Viewer::run_init(TaskManager *manager, Application *app)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 this->manager = manager;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 start_time = get_ticks();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 this_time = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 frames = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
102 if (spe_num == 0) spe_num = 1;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
103
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 sgroot = new SceneGraphRoot(this->width, this->height);
572
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
105 sgroot->tmanager = manager;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
106
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
107
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
108 int light_num = 4;
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
109 int size = sizeof(float)*4*light_num; //xyz+alfa(4) * light_num(4)
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
110 int light_size = size / sizeof(float);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
111
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 747
diff changeset
112 light_xyz_stock = (float *)manager->allocate(size);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
113 light_xyz = (float *)manager->allocate(size);
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
114
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
115 for (int i = 0; i < light_size ; i++) {
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
116 light_xyz[i] = 0.0f;
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
117 }
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
118
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
119 for(int i = 0; i < spe_num; i++) {
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
120
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
121 HTaskPtr data_load = manager->create_task(DataLoad);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
122 data_load->set_param(0,(memaddr)size);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
123 data_load->set_param(1,(memaddr)Light);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
124 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
125 data_load->spawn();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
126 }
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
127
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
128 size = light_num * sizeof(int);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
129 light_switch = (int*)manager->allocate(size);
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
130
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
131 for (int i = 0; i < light_num; i++) {
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
132 light_switch[i] = 0;
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
133 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
134
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
135 for(int i = 0; i < spe_num; i++) {
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
136 HTaskPtr data_load = manager->create_task(DataLoad);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
137 data_load->set_param(0,(memaddr)size);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
138 data_load->set_param(1,(memaddr)LightSwitch);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
139 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
140 data_load->spawn();
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
141 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
142
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
143 size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
144
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
145 light_sysswitch = (int*)manager->allocate(size);
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
146
843
de64695a7f02 cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 842
diff changeset
147 for (unsigned int i = 0; i < size / sizeof(int); i++) {
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
148 light_sysswitch[i] = 0;
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
149 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
150
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
151 for(int i = 0; i < spe_num; i++) {
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
152 HTaskPtr data_load = manager->create_task(DataLoad);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
153 data_load->set_param(0,(memaddr)size);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
154 data_load->set_param(1,(memaddr)LightSysSwitch);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
155 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
156 data_load->spawn();
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
157 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
158
543
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 542
diff changeset
159 MainLoop *mainloop = app->init(this, this->width, this->height);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 542
diff changeset
160 mainloop->mainLoop();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 HTaskPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 Viewer::initLoop()
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 HTaskPtr task_next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 HTaskPtr task_tex;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 sgpack = (SceneGraphPack*)manager->allocate(sizeof(SceneGraphPack));
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 sgpack->init();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 ppack = (PolygonPack*)manager->allocate(sizeof(PolygonPack));
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 spackList_length = (this->height + split_screen_h - 1) / split_screen_h;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*spackList_length);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 * SPU に送る address list は 16 バイト倍数でないといけない。
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 * length_align を求めている。はみ出した部分は使われない
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 * (ex) spackList_length が 13 の場合
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 * spackList_length_align = 16;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 * 実際に送るデータは64バイトになるのでOK
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 * 14,15,16 の部分は何も入らない。
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 spackList_length_align = (spackList_length + 3)&(~3);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 /* 各 SPU が持つ、SpanPack の address list */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 spackList_ptr =
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 (SpanPack**)manager->allocate(sizeof(SpanPack*)*spackList_length_align);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 for (int i = 0; i < spackList_length; i++) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 spackList_ptr[i] = &spackList[i];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 for (int i = 1; i <= spackList_length; i++) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 spackList[i-1].init(i*split_screen_h);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
200 task_next = manager->create_task(Dummy,0,0,0,0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201
659
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
202 // ここは、Iterator を用意するべきだよね
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 for (int i = 0; i < spe_num; i++) {
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
204 task_tex = manager->create_task(LoadTexture,0,0,0,0);
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
205 task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + i));
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
206 task_next->wait_for(task_tex);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
207 task_tex->spawn();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
210
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 return task_next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 Viewer::getKey()
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 Pad *pad = sgroot->getController();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 if (pad->right.isHold()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 keyPtr->right = HOLD;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 } else if (pad->right.isPush()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 keyPtr->right = PUSH;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 keyPtr->right = NONE;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
226
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 if (pad->left.isHold()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 keyPtr->left = HOLD;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 } else if (pad->left.isPush()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 keyPtr->left = PUSH;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 keyPtr->left = NONE;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 if (pad->up.isHold()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 keyPtr->up = HOLD;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 } else if (pad->up.isPush()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 keyPtr->up = PUSH;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 keyPtr->up = NONE;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 if (pad->down.isHold()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 keyPtr->down = HOLD;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 } else if (pad->down.isPush()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 keyPtr->down = PUSH;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 keyPtr->down = NONE;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 if (pad->circle.isHold()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 keyPtr->circle = HOLD;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 } else if (pad->circle.isPush()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 keyPtr->circle = PUSH;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 keyPtr->circle = NONE;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 static void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
261 post2runMoveDrawLoop(SchedTask *m, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 Viewer *viewer = (Viewer*)viewer_;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
265 // 同じ PPE 上なので sgroot(ポインタ) を set_param で送る。
615
184d6d3f0cd9 remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
266 //HTaskPtr send_key_task = viewer->manager->create_task(SendKey);
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
267 //send_key_task->set_param((int)sgroot);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 // set input data -> viewer keyPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 viewer->getKey();
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
270 //HTaskPtr update_key = viewer->manager->create_task(UpdateKey,viewer->keyPtr, sizeof(key_stat),0,0);
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
271 HTaskPtr update_key = viewer->manager->create_task(UpdateKey,0,0,0,0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 update_key->add_inData(viewer->keyPtr, sizeof(key_stat));
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
273 //update_key->set_cpu(SPE_0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 update_key->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 /* TASK_MOVE は外から引数で取ってくるべき */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 //HTaskPtr move_task = viewer->manager->create_task(viewer->app->move_taskid);
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
278 HTaskPtr move_task = viewer->manager->create_task(Move,0,0,0,0);
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
279 //move_task->set_param(sgroot);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280
615
184d6d3f0cd9 remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
281 //HTaskPtr draw_task = viewer->manager->create_task(Draw);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 /* rendering task test */
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
284 HTaskPtr draw_task = viewer->manager->create_task(Dummy,0,0,0,0);
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
285 HTaskPtr draw_dummy = viewer->manager->create_task(Dummy,0,0,0,0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
287 HTaskPtr switch_task = viewer->manager->create_task(Switch,0,0,0,0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 viewer->draw_dummy = draw_dummy;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 switch_task->wait_for(draw_dummy);
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
290 draw_task->set_post(post2speRendering, (void*)viewer, 0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 switch_task->wait_for(move_task);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 switch_task->wait_for(draw_task);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 move_task->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 draw_task->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
297 switch_task->set_post(post2runMoveDrawLoop, (void*)viewer, 0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 switch_task->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
299
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 Viewer::mainLoop()
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 HTaskPtr task_next = initLoop();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
307 task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 task_next->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
310
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 void
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
312 Viewer::run_loop(HTaskPtr task_next)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 {
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
314 dev->clear_screen();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
315
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
316 bool quit_flg;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
317 quit_flg = quit_check();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
318 if (quit_flg == true) {
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
319 this_time = get_ticks();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
320 run_finish();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
321 return;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
322 }
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
323
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
324 dev->clean_pixels();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
325
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
326 for (int i = 1; i <= spackList_length; i++) {
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
327 spackList[i-1].reinit(i*split_screen_h);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
328 }
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
329
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
330 sgroot->updateControllerState();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
331 sgroot->allExecute(width, height);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
332 light_xyz_stock = sgroot->getLightVector();
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
333 light_switch_stock = sgroot->getLightSwitch();
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
334 light_sysswitch_stock = sgroot->getLightSysSwitch();
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
335 //sgroot->checkRemove();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
336
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
337 // ここから下は Rendering という関数にする
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
338 rendering(task_next);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
340
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
341
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
342
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 Viewer::run_collision()
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
347
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
349 post2rendering(SchedTask *s, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 Viewer *viewer = (Viewer *)viewer_;
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
352 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 viewer->rendering(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
355
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 Viewer::rendering(HTaskPtr task_next)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 {
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
359 common_rendering(task_next, sgroot);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
360
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 // Barrier 同期
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 // run_draw() を呼ぶ post2runDraw
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
363 task_next->set_post(post2runDraw, (void*)this, 0); // set_post(function(this->run_draw()), NULL)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 task_next->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
365
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 // TASK_CREATE_SPAN が全て終わったら DUMMY_TASK が Viewer::run_draw() を呼ぶ
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
368
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 static void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
370 post2runLoop(SchedTask *s, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 Viewer *viewer = (Viewer*)viewer_;
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
373 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 viewer->run_loop(task_next);
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 572
diff changeset
375 psx_sync_n();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 static void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
379 post2runDraw(SchedTask *s, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 Viewer *viewer = (Viewer*)viewer_;
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
382 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 viewer->run_draw(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
384
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 common_draw(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
391
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
392 task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 task_next->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
395
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 frames++;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
398
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
399
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 static void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
401 post2speRendering(SchedTask *s, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 Viewer *viewer = (Viewer*)viewer_;
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
404 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 viewer->spe_rendering(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
407
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 Viewer::spe_rendering(HTaskPtr task_next)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 {
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
411 common_rendering(task_next, sgroot);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
412
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 this->draw_dummy->wait_for(task_next);
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
414 task_next->set_post(post2speDraw, (void*)this, 0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 task_next->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
418
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 static void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
420 post2speDraw(SchedTask *s, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 Viewer *viewer = (Viewer*)viewer_;
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
423 HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 viewer->spe_draw(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
426
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 Viewer::spe_draw(HTaskPtr task_next)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 common_draw(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 this->draw_dummy->wait_for(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 task_next->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 this->draw_dummy->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 frames++;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
438
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 void
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
440 Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 {
615
184d6d3f0cd9 remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
442 HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 // SceneGraph(木構造) -> PolygonPack
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
445
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
446 task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph());
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
447 task_create_pp->set_param(1,(memaddr)ppack);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
448
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 task_next->wait_for(task_create_pp);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
450
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
451 int range_base = spe_num;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
452
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 // 切り上げのつもり
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 int range = (spackList_length + range_base - 1) / range_base;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
455
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 for (int i = 0; i < range_base; i++) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 int index_start = range*i;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 int index_end = (index_start + range >= spackList_length)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 ? spackList_length : index_start + range;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
460
659
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
461 HTaskPtr task_create_sp = manager->create_task(CreateSpan);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
462
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
463 task_create_sp->set_param(0,index_start);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
464
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
467 * [ 1.. 80] [ 81..160] [161..240]
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 * [241..320] [321..400] [401..480]
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 * ex. screen_height が 1080, spenum が 5 の場合、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 * [ 1..216] [217..432] [433..648]
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 * [649..864] [865..1080]
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 */
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
474
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
475 task_create_sp->set_param(1,index_start*split_screen_h + 1);
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
476 task_create_sp->set_param(2,index_end*split_screen_h);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
477
659
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
478 task_create_sp->add_inData(ppack, sizeof(PolygonPack));
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
479 task_create_sp->add_inData(spackList_ptr,
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
480 sizeof(SpanPack*)*spackList_length_align);
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
481 task_create_sp->add_inData(&spackList[index_start], sizeof(SpanPack));
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
482
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 task_next->wait_for(task_create_sp);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 task_create_sp->wait_for(task_create_pp);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
485
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
486 task_create_sp->set_cpu(SPE_ANY);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 task_create_sp->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
489
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
490
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 task_create_pp->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
493
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
494 HTaskPtr
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
495 Viewer::update_task_create(void *data, int size,
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
496 int load_id, int spe_id, HTaskPtr wait)
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
497 {
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
498
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
499 HTaskPtr data_update = manager->create_task(DataUpdate);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
500 data_update->add_inData(data,size);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
501 data_update->set_param(0,size);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
502 data_update->set_param(1,load_id);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
503 data_update->set_cpu((CPU_TYPE)(spe_id));
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
504 if (wait != NULL) {
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
505 wait->wait_for(data_update);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
506 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
507 data_update->spawn();
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
508
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
509 return data_update;
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
510
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
511 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
512
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 Viewer::common_draw(HTaskPtr task_next)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
516
615
184d6d3f0cd9 remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
517 //task_next = manager->create_task(Dummy);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 //task_next->set_post(post2runLoop, (void*)this);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
519
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
520 //Light info update
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
521
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
522 //HTaskPtr data_update;
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
523 HTaskPtr data_update_wait;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
524 int light_num = 4;
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
525 int size = sizeof(float)*4*light_num; //xyz+alpha(4) * light_num(4)
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
526 int light_size = size / sizeof(float);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
527
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
528 for (int i = 0; i < light_size; i++) {
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
529 light_xyz[i] = light_xyz_stock[i];
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
530 }
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
531
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
532 for (int i = 0; i < light_num; i++) {
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
533 light_switch[i] = light_switch_stock[i];
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
534 }
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
535
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
536 light_sysswitch[0] = light_sysswitch_stock;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
537
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
538 data_update_wait = manager->create_task(DataUpdate);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
539 data_update_wait->add_inData(light_xyz,size);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
540 data_update_wait->set_param(0,size);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
541 data_update_wait->set_param(1,Light);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
542 data_update_wait->set_cpu((CPU_TYPE)((int)SPE_0));
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
543
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
544 for (int i = 1; i < spe_num; i++) {
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
545 update_task_create(light_xyz,size,Light,(int)SPE_0+i,data_update_wait);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
546 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
547
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
548 size = light_num * sizeof(int);
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
549
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
550 for (int i = 0; i < spe_num; i++) {
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
551 update_task_create(light_switch,size,LightSwitch,(int)SPE_0+i,data_update_wait);
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
552 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
553
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
554 size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
555
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
556 for (int i = 0; i < spe_num; i++) {
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
557 update_task_create(light_sysswitch,size,LightSysSwitch,(int)SPE_0+i,data_update_wait);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
558 }
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
559
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 ppack->clear();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 for (int i = 0; i < spackList_length; i++) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 SpanPack *spack = &spackList[i];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 int startx = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 int endx = split_screen_w;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
565
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 int starty = spack->info.y_top - split_screen_h + 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 //int endy = spack->info.y_top;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 int rangey = (starty + split_screen_h - 1 > this->height)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 ? this->height - starty + 1 : split_screen_h;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
570
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
571 #if 1
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
572
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
573 if(spack->info.size > 0) {
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
574
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
575 int array_task_num = (this->width + split_screen_w - 1) / split_screen_w;
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
576 HTaskPtr task_draw_array = manager->create_task_array(DrawSpan, array_task_num, 6, 1, rangey);
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
577 Task *task_draw = 0;
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
578
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
579 while (startx < this->width) {
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
580
839
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
581 // Draw SpanPack
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
582
839
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
583 task_draw = task_draw_array->next_task_array(DrawSpan,task_draw);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
584 task_draw->set_param(0,(memaddr)&pixels[(startx-1) + this->width*(starty-1)]);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
585 task_draw->set_param(1,this->width);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
586 task_draw->set_param(2,startx);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
587 task_draw->set_param(3,endx);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
588 task_draw->set_param(4,rangey);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
589 task_draw->set_param(5,spack->info.size);
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
590
839
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
591 task_draw->set_inData(0,spack, sizeof(SpanPack));
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
592
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
593 for (int i = 0; i < rangey; i++) {
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
594 task_draw->set_outData(i,
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
595 &pixels[(startx-1) + this->width*(starty-1 + i) ],
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
596 (endx-startx+1)*sizeof(int));
839
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
597 }
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
598
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
599 startx += split_screen_w;
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
600 endx += split_screen_w;
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
601
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
602 if (endx > this->width) {
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
603 endx = this->width;
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
604 }
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
605
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
606 }
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
607
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
608 task_draw_array->spawn_task_array(task_draw->next());
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
609 task_draw_array->set_cpu(SPE_ANY);
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
610 task_next->wait_for(task_draw_array);
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
611 task_draw_array->wait_for(data_update_wait);
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
612 task_draw_array->spawn();
854
293fcceaac36 may be need ppeManager
yutaka@localhost.localdomain
parents: 843
diff changeset
613
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
614 } else {
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
615
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
616 memset(&pixels[(startx-1)+this->width*(starty-1)],
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
617 0, (this->width)*sizeof(int)*rangey);
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
618
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
619 }
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
620
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
621 #else
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
622
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
623 HTaskPtr task_draw;
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
624
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 while (startx < this->width) {
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
626 if (spack->info.size > 0) {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
627 // Draw SpanPack
615
184d6d3f0cd9 remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
628 task_draw = manager->create_task(DrawSpan);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
629
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
630 task_draw->set_param(0,
603
57ec231bc8ac long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 602
diff changeset
631 (memaddr)&pixels[(startx-1) + this->width*(starty-1)]);
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
632 task_draw->set_param(1,this->width);
659
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
633 task_draw->set_param(2,startx);
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
634 task_draw->set_param(3,endx);
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
635 task_draw->set_param(4,rangey);
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
636 task_draw->set_param(5,spack->info.size);
659
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
637
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
638 task_draw->add_inData(spack, sizeof(SpanPack));
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
639
617
df618a956eb9 Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
640 for (int i = 0; i < rangey; i++) {
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
641 task_draw->add_outData(
617
df618a956eb9 Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
642 &pixels[(startx-1) + this->width*(starty-1 + i) ],
df618a956eb9 Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
643 (endx-startx+1)*sizeof(int));
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
644 }
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
645
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
646 } else {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 // 7.7.3 SL1 Data Cache Range Set to Zero コマンド
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 // を使って、DMAでclearするべき... ということは、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 // それもSPEでやる方が良い?
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
650 memset(&pixels[(startx-1)+this->width*(starty-1)],
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
651 0, (this->width)*sizeof(int)*rangey);
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
652 break;
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
653 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
654
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
655 task_draw->set_cpu(SPE_ANY);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 task_next->wait_for(task_draw);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
657 task_draw->wait_for(data_update_wait);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
658 task_draw->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
659
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 startx += split_screen_w;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
661 endx += split_screen_w;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
662
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 if (endx > this->width) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 endx = this->width;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 }
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
667 #endif
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
668
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
669 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
670
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
671 data_update_wait->spawn();
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
672
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
673 }
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
674
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
675 void
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
676 Viewer::run_finish()
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
677 {
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
678 dev->free_device();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
679 if (this_time != start_time) {
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
680 printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
681 }
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
682
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
683 delete sgroot;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
684 // delete sgroot_2;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
685 quit();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
687
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 /* end */