annotate Renderer/Engine/viewer.cc @ 1087:20f09564c586 draft

fix (not yet tested)
author root@localhost.localdomain
date Fri, 17 Dec 2010 18:34:29 +0900
parents 9061d19b8550
children 652791a4a324 c9d0683c9b39
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"
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1045
diff changeset
7 #include "matrix_calc.h"
539
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) */
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
23 static int start_time;
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
24 static int this_time;
539
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
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
35 RederingData r[2];
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
994
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 989
diff changeset
37 int ppi, spi = 0;
907
03e60cf2e4c2 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
38
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 *
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
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
43 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
44 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 spe_num = _num;
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
46 manager = m;
895
b662e9dd26b0 add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 891
diff changeset
47
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
48 dev = vd;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
49 pixels = dev->video_init(manager, b, w, h);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
50
895
b662e9dd26b0 add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 891
diff changeset
51 width = dev->width;
b662e9dd26b0 add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 891
diff changeset
52 height = dev->height;
b662e9dd26b0 add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 891
diff changeset
53 bpp = dev->bpp;
b662e9dd26b0 add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 891
diff changeset
54
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 }
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 int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 Viewer::get_ticks(void)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 int time;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 time = SDL_GetTicks();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 return time;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 }
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 bool
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 Viewer::quit_check(void)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 SDL_Event event;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 while(SDL_PollEvent(&event)) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 if (event.type==SDL_QUIT) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 return true;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 }
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 Uint8 *keys=SDL_GetKeyState(NULL);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 if (keys[SDLK_q] == SDL_PRESSED) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 return true;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 }
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 return false;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 }
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 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 Viewer::quit(void)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 SDL_Quit();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 }
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 void
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
93 Viewer::run_init(TaskManager *manager, Application *app)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 this->manager = manager;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
97 if (spe_num == 0) spe_num = 1;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
98
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 sgroot = new SceneGraphRoot(this->width, this->height);
572
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 565
diff changeset
100 sgroot->tmanager = manager;
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
101
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
102 int light_num = 4;
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
103 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
104 int light_size = size / sizeof(float);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
105
759
45f7ab7101ea first of all commit, not work Rendering/Test/create_task
hiroki
parents: 747
diff changeset
106 light_xyz_stock = (float *)manager->allocate(size);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
107 light_xyz = (float *)manager->allocate(size);
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
108
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
109 for (int i = 0; i < light_size ; i++) {
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
110 light_xyz[i] = 0.0f;
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
111 }
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
112
907
03e60cf2e4c2 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
113
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
114 for(int i = 0; i < spe_num; i++) {
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
115 HTaskPtr data_load = manager->create_task(DataAllocate);
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
116 data_load->set_param(0,(memaddr)3); // num of allocate block
988
da1cec21f0c9 fix for double buffer
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 986
diff changeset
117 data_load->set_param(1,(memaddr)(sizeof(float)*4*light_num)); // 1st allocate size
da1cec21f0c9 fix for double buffer
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 986
diff changeset
118 data_load->set_param(2,(memaddr)Light); // 1st id
da1cec21f0c9 fix for double buffer
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 986
diff changeset
119 data_load->set_param(3,(memaddr)(light_num * sizeof(int))); // 2nd size
da1cec21f0c9 fix for double buffer
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 986
diff changeset
120 data_load->set_param(4,(memaddr)LightSwitch); // 2nd id
da1cec21f0c9 fix for double buffer
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 986
diff changeset
121 data_load->set_param(5,(memaddr)16); // 3rd size
da1cec21f0c9 fix for double buffer
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 986
diff changeset
122 data_load->set_param(6,(memaddr)LightSysSwitch); // 3rd id
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
123 data_load->set_cpu((CPU_TYPE)((int)SPE_0 + i));
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
124 data_load->spawn();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
125 }
541
1a31b8820a4d Cerium Rendering Library
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
126
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
127 light_switch = (int*)manager->allocate(size);
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
128
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
129 for (int i = 0; i < light_num; i++) {
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
130 light_switch[i] = 0;
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
131 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
132
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
133 size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
134
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
135 light_sysswitch = (int*)manager->allocate(size);
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
136
843
de64695a7f02 cleanup unused variables and fix warning.
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 842
diff changeset
137 for (unsigned int i = 0; i < size / sizeof(int); i++) {
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
138 light_sysswitch[i] = 0;
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
139 }
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
140
984
dbebc7afd08e minor fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 983
diff changeset
141 start_time = get_ticks();
dbebc7afd08e minor fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 983
diff changeset
142 this_time = 0;
dbebc7afd08e minor fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 983
diff changeset
143 frames = 0;
dbebc7afd08e minor fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 983
diff changeset
144
1033
a9581a9df440 add application main method and task.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1004
diff changeset
145 this->app = app;
543
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 542
diff changeset
146 MainLoop *mainloop = app->init(this, this->width, this->height);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 542
diff changeset
147 mainloop->mainLoop();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 HTaskPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 Viewer::initLoop()
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 HTaskPtr task_next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 HTaskPtr task_tex;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
157 for(int i=0;i<2;i++) {
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
158 r[i].ppack = (PolygonPack*)manager->allocate(sizeof(PolygonPack));
989
1ff34456944d ppack initialization fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 988
diff changeset
159 r[i].ppack->next = 0;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
161 r[i].spackList_length = (this->height + split_screen_h - 1) / split_screen_h;
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
162 r[i].spackList = (SpanPack*)manager->allocate(sizeof(SpanPack)*r[i].spackList_length);
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
163 // printf("spackList %0lx height %d\n",(unsigned long)r[i].spackList, this->height);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
165 /**
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
166 * SPU に送る address list は 16 バイト倍数でないといけない。
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
167 * spackList_length*sizeof(SpanPack*) が 16 バイト倍数になるような
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
168 * length_align を求めている。はみ出した部分は使われない
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
169 * (ex) spackList_length が 13 の場合
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
170 * spackList_length_align = 16;
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
171 * 実際に送るデータは64バイトになるのでOK
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
172 * 14,15,16 の部分は何も入らない。
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
173 */
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
174 r[i].spackList_length_align = (r[i].spackList_length + 3)&(~3);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
176 /* 各 SPU が持つ、SpanPack の address list */
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
177 r[i].spackList_ptr =
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
178 (SpanPack**)manager->allocate(sizeof(SpanPack*)*r[i].spackList_length_align);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179
988
da1cec21f0c9 fix for double buffer
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 986
diff changeset
180 for (int j = 0; j < r[i].spackList_length; j++) {
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
181 r[i].spackList_ptr[j] = &r[i].spackList[j];
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
182 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183
988
da1cec21f0c9 fix for double buffer
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 986
diff changeset
184 for (int j = 1; j <= r[i].spackList_length; j++) {
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
185 r[i].spackList[j-1].init(j*split_screen_h);
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
186 }
539
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
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
189 task_next = manager->create_task(Dummy,0,0,0,0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190
659
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
191 // ここは、Iterator を用意するべきだよね
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
192 for (int j = 0; j < spe_num; j++) {
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
193 task_tex = manager->create_task(LoadTexture,0,0,0,0);
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
194 task_tex->set_cpu((CPU_TYPE)((int)SPE_0 + j));
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
195 task_next->wait_for(task_tex);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
196 task_tex->spawn();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
199
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 return task_next;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 Viewer::getKey()
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 Pad *pad = sgroot->getController();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 if (pad->right.isHold()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 keyPtr->right = HOLD;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 } else if (pad->right.isPush()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 keyPtr->right = PUSH;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 keyPtr->right = NONE;
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
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 if (pad->left.isHold()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 keyPtr->left = HOLD;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 } else if (pad->left.isPush()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 keyPtr->left = PUSH;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 keyPtr->left = NONE;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 if (pad->up.isHold()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 keyPtr->up = HOLD;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 } else if (pad->up.isPush()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 keyPtr->up = PUSH;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 keyPtr->up = NONE;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 if (pad->down.isHold()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 keyPtr->down = HOLD;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 } else if (pad->down.isPush()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 keyPtr->down = PUSH;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 keyPtr->down = NONE;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 if (pad->circle.isHold()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 keyPtr->circle = HOLD;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 } else if (pad->circle.isPush()) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 keyPtr->circle = PUSH;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 keyPtr->circle = NONE;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 static void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
250 post2runMoveDrawLoop(SchedTask *m, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 Viewer *viewer = (Viewer*)viewer_;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
254 // 同じ PPE 上なので sgroot(ポインタ) を set_param で送る。
615
184d6d3f0cd9 remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
255 //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
256 //send_key_task->set_param((int)sgroot);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 // set input data -> viewer keyPtr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 viewer->getKey();
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
259 //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
260 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
261 update_key->add_inData(viewer->keyPtr, sizeof(key_stat));
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
262 //update_key->set_cpu(SPE_0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 update_key->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 /* TASK_MOVE は外から引数で取ってくるべき */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 //HTaskPtr move_task = viewer->manager->create_task(viewer->app->move_taskid);
965
e0427cdee770 removing user task from Renderer Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 926
diff changeset
267 // 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
268 //move_task->set_param(sgroot);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269
615
184d6d3f0cd9 remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
270 //HTaskPtr draw_task = viewer->manager->create_task(Draw);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 /* rendering task test */
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
273 HTaskPtr draw_task = viewer->manager->create_task(Dummy,0,0,0,0);
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
274 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
275
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
276 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
277 viewer->draw_dummy = draw_dummy;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 switch_task->wait_for(draw_dummy);
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
279 draw_task->set_post(post2speRendering, (void*)viewer, 0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280
965
e0427cdee770 removing user task from Renderer Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 926
diff changeset
281 // switch_task->wait_for(move_task);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 switch_task->wait_for(draw_task);
965
e0427cdee770 removing user task from Renderer Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 926
diff changeset
283 // move_task->spawn();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 draw_task->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
286 switch_task->set_post(post2runMoveDrawLoop, (void*)viewer, 0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 switch_task->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 Viewer::mainLoop()
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 HTaskPtr task_next = initLoop();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295
994
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 989
diff changeset
296 task_next->set_post(&post2runLoop, (void *)this, (void*)pixels); // set_post(function(this->run_loop()), NULL)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 task_next->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 }
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 void
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
301 Viewer::run_loop(HTaskPtr task_next)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 {
1045
11a9bc9928d0 mainLoop is not a part of mainLoop in viwer.... move application_task
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1043
diff changeset
303 task_next = app->application_task(task_next, this);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
304 dev->clear_screen();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
305
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
306 bool quit_flg;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
307 quit_flg = quit_check();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
308 if (quit_flg == true) {
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
309 this_time = get_ticks();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
310 run_finish();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
311 return;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
312 }
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
313
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
314 dev->clean_pixels();
994
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 989
diff changeset
315
981
fdb36a9c5030 add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 969
diff changeset
316 pixels = dev->flip_screen(pixels);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
317 sgroot->updateControllerState();
1043
3a49a0825963 Merged ( app_loop should return 1, if you want to use allExecute )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1042 1041
diff changeset
318 if (app->app_loop(this)) {
1042
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1035
diff changeset
319 //TaskArray を使うか使わないか
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1035
diff changeset
320 if (sgroot->gtask_array != NULL) {
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1035
diff changeset
321 sgroot->create_task_array();
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1035
diff changeset
322 sgroot->allExecute(width, height);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1035
diff changeset
323 sgroot->task_array_finish();
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1035
diff changeset
324 } else {
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1035
diff changeset
325 sgroot->allExecute(width, height);
d0bb27bf985b AllExecute speparation.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1035
diff changeset
326 }
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
327 }
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
328
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
329 light_xyz_stock = sgroot->getLightVector();
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
330 light_switch_stock = sgroot->getLightSwitch();
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
331 light_sysswitch_stock = sgroot->getLightSysSwitch();
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
332 //sgroot->checkRemove();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
333
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
334 // ここから下は Rendering という関数にする
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
335 rendering(task_next);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
337
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
338
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 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 Viewer::run_collision()
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 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
344
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
346 post2rendering(SchedTask *s, void *viewer_, void *arg)
539
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 Viewer *viewer = (Viewer *)viewer_;
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
349 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
350 viewer->rendering(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
352
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 Viewer::rendering(HTaskPtr task_next)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 {
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
356 common_rendering(task_next, sgroot);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
357
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 // Barrier 同期
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 // run_draw() を呼ぶ post2runDraw
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
360 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
361 task_next->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
362
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 // TASK_CREATE_SPAN が全て終わったら DUMMY_TASK が Viewer::run_draw() を呼ぶ
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 }
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 static void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
367 post2runLoop(SchedTask *s, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 {
994
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 989
diff changeset
369
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 989
diff changeset
370
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 Viewer *viewer = (Viewer*)viewer_;
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
372 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
373 viewer->run_loop(task_next);
575
341f1f881a9b Linda API worked. (slightly unreliable)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 572
diff changeset
374 psx_sync_n();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 }
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 static void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
378 post2runDraw(SchedTask *s, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 Viewer *viewer = (Viewer*)viewer_;
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
381 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
382 viewer->run_draw(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
383
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 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 Viewer::run_draw(HTaskPtr task_next) // 引数に post2runLoop を入れるようにする
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 common_draw(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
390
994
56c3b9dd37a7 SDL mode fix
yutaka@charles.cr.ie.u-ryukyu.ac.jp
parents: 989
diff changeset
391 task_next->set_post(post2runLoop, (void*)this, (void*)pixels); // set_post(function(this->run_loop()), NULL)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 task_next->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
394
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 frames++;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 }
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 static void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
400 post2speRendering(SchedTask *s, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 Viewer *viewer = (Viewer*)viewer_;
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
403 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
404 viewer->spe_rendering(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 }
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 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 Viewer::spe_rendering(HTaskPtr task_next)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 {
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
410 common_rendering(task_next, sgroot);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
411
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 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
413 task_next->set_post(post2speDraw, (void*)this, 0);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 task_next->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415
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 static void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 543
diff changeset
419 post2speDraw(SchedTask *s, void *viewer_, void *arg)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 Viewer *viewer = (Viewer*)viewer_;
826
d98371202f1d RenderingEngine's Task -> Simple Task
Yutaka_Kinjyo
parents: 801
diff changeset
422 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
423 viewer->spe_draw(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 }
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 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 Viewer::spe_draw(HTaskPtr task_next)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 common_draw(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 this->draw_dummy->wait_for(task_next);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 task_next->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 this->draw_dummy->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 frames++;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437
907
03e60cf2e4c2 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
438
915
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
439
908
Yutaka_Kinjyo
parents: 907
diff changeset
440 void
915
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
441 coord_allocate(int &cur_point, float *coord_pack, int spe_num,
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
442 int alloc_size, HTaskPtr alloc_wait, TaskManager *manager)
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
443 {
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
444
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
445 for (int i = 0; i < spe_num; i++) {
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
446
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
447 HTaskPtr data_alloc = manager->create_task(DataAllocate);
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
448 //data_alloc->set_inData(0, &coord_pack[cur_point], alloc_size);
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
449 data_alloc->set_param(0,(memaddr)alloc_size);
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
450 data_alloc->set_param(1,(memaddr)SG_COORD);
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
451 data_alloc->set_cpu((CPU_TYPE)((int)SPE_0 + i));
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
452 alloc_wait->wait_for(data_alloc);
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
453 data_alloc->spawn();
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
454
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
455 }
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
456
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
457 cur_point += alloc_size / sizeof(float);
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
458
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
459 }
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
460
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
461 void
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
462 coord_free(int spe_num, TaskManager *manager, HTaskPtr alloc_wait)
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
463 {
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
464
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
465 for (int i = 0; i < spe_num; i++) {
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
466
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
467 HTaskPtr data_free = manager->create_task(DataFree);
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
468 data_free->set_param(0,(memaddr)SG_COORD);
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
469 data_free->set_cpu((CPU_TYPE)((int)SPE_0 + i));
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
470 data_free->wait_for(alloc_wait);
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
471 data_free->spawn();
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
472
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
473 }
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
474
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
475 }
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
476
1018
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
477 /* flag_drawable な Scenegraph の総数を求める */
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
478 int
1020
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
479 sg_drawable_num(SceneGraphPtr scenegraph)
1018
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
480 {
1020
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
481 SceneGraphPtr sg = scenegraph;
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
482
1018
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
483 int sg_count = 0;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
484 while (sg) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
485 if (sg->flag_drawable) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
486 sg_count++;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
487 }
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
488 if (sg->children != NULL) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
489 sg = sg->children;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
490 } else if (sg->brother != NULL) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
491 sg = sg->brother;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
492 } else {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
493 while (sg) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
494 if (sg->brother != NULL) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
495 sg = sg->brother;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
496 break;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
497 } else {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
498 if (sg->parent == NULL) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
499 sg = NULL;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
500 break;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
501 } else {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
502 sg = sg->parent;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
503 }
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
504 }
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
505 }
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
506 }
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
507 }
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
508 return sg_count;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
509 }
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
510
915
aa9728394194 create_polygon_task ..not worked yet.
yutaka@localhost.localdomain
parents: 914
diff changeset
511 void
1028
cfec583ae7d3 spe/CreatePolygonFromSceneGraph not done.
tkaito@henri
parents: 1026
diff changeset
512 create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next, SceneGraphRootPtr sgroot)
907
03e60cf2e4c2 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
513 {
03e60cf2e4c2 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
514
1013
34bb008fab4d spe/CreatePolygonFromSceneGraph add. not done.
tkaito
parents: 1004
diff changeset
515 /*
34bb008fab4d spe/CreatePolygonFromSceneGraph add. not done.
tkaito
parents: 1004
diff changeset
516 * SceneGraph を辿って coord_xyz, coord_tex, normal, matrix, real_matrix 及び、
34bb008fab4d spe/CreatePolygonFromSceneGraph add. not done.
tkaito
parents: 1004
diff changeset
517 * PolygonPack の TrianglePack (空) を送る。pp->info.size の計算もここで。
34bb008fab4d spe/CreatePolygonFromSceneGraph add. not done.
tkaito
parents: 1004
diff changeset
518 *
34bb008fab4d spe/CreatePolygonFromSceneGraph add. not done.
tkaito
parents: 1004
diff changeset
519 */
1018
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
520
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
521 int sg_num = sg_drawable_num(sg);
1020
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
522 int sg_division = sg_num / spe_num;
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
523 int residue = sg_num % spe_num;
1018
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
524
1020
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
525 HTask **task_array = (HTask**)manager->allocate(sizeof(HTask*)*spe_num);
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
526 Task **pptask = (Task**)manager->allocate(sizeof(Task*)*spe_num);
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
527
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
528 for (int k = 0; k < spe_num-1; k++) {
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
529 task_array[k] = manager->create_task_array(CreatePolygonFromSceneGraph,sg_division,4,6,1);
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
530 pptask[k] = 0;
1018
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
531 }
1020
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
532
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
533 task_array[spe_num] = manager->create_task_array(CreatePolygonFromSceneGraph,
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
534 sg_division+residue,4,6,1);
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
535 pptask[spe_num] = 0;
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
536
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
537 int k = 0;
1018
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
538
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
539 while (sg) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
540 if (sg->flag_drawable) {
1028
cfec583ae7d3 spe/CreatePolygonFromSceneGraph not done.
tkaito@henri
parents: 1026
diff changeset
541 if(k < spe_num * sg_division) {
1020
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
542 k %= spe_num-1;
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
543 } else {
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
544 k = spe_num;
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
545 }
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
546 pptask[k] = task_array[k]->next_task_array(CreatePolygonFromSceneGraph,pptask[k]);
1035
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
547
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
548 pptask[k]->set_inData(0, &sg->coord_xyz, sizeof(float)*sg->size);
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
549 pptask[k]->set_inData(1, &sg->coord_tex, sizeof(float)*sg->size);
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
550 pptask[k]->set_inData(2, &sg->normal , sizeof(float)*sg->size);
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
551 pptask[k]->set_inData(3, &sg->matrix , sizeof(float)*16);
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
552 pptask[k]->set_inData(4, &sg->real_matrix, sizeof(float)*12);
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
553 pptask[k]->set_inData(5, &sg->texture_info.pixels, sizeof(uint32)); // 4 byte
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
554
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
555 // 4 byte * 4 = 16 byte
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
556 pptask[k]->set_param(0,(memaddr)sg->size); // 4byte
1020
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
557 pptask[k]->set_param(1,(memaddr)sg->texture_info.t_w);
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
558 pptask[k]->set_param(2,(memaddr)sg->texture_info.t_h);
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
559 pptask[k]->set_param(3,(memaddr)sg->texture_info.scale_max);
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
560
1018
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
561 }
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
562 if (sg->children != NULL) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
563 sg = sg->children;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
564 } else if (sg->brother != NULL) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
565 sg = sg->brother;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
566 } else {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
567 while (sg) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
568 if (sg->brother != NULL) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
569 sg = sg->brother;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
570 break;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
571 } else {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
572 if (sg->parent == NULL) {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
573 sg = NULL;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
574 break;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
575 } else {
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
576 sg = sg->parent;
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
577 }
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
578 }
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
579 }
1020
58b284d6506f create_pp_task fix. not done.
tkaito
parents: 1018
diff changeset
580 }
1026
9e19e988559c create_pp_task fix.
tkaito
parents: 1020
diff changeset
581 k++;
1018
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
582 }
1026
9e19e988559c create_pp_task fix.
tkaito
parents: 1020
diff changeset
583 for (int k = 0; k < spe_num; k++) {
9e19e988559c create_pp_task fix.
tkaito
parents: 1020
diff changeset
584 task_array[k]->spawn_task_array(pptask[k]->next());
9e19e988559c create_pp_task fix.
tkaito
parents: 1020
diff changeset
585 task_array[k]->set_cpu(SPE_ANY);
9e19e988559c create_pp_task fix.
tkaito
parents: 1020
diff changeset
586 task_array[k]->spawn();
9e19e988559c create_pp_task fix.
tkaito
parents: 1020
diff changeset
587 if (sgroot->gtask_array != NULL) {
9e19e988559c create_pp_task fix.
tkaito
parents: 1020
diff changeset
588 HTaskPtr game_task_array = sgroot->gtask_array->get_task_array();
1028
cfec583ae7d3 spe/CreatePolygonFromSceneGraph not done.
tkaito@henri
parents: 1026
diff changeset
589 task_array[k]->wait_for(game_task_array);
1026
9e19e988559c create_pp_task fix.
tkaito
parents: 1020
diff changeset
590 }
1028
cfec583ae7d3 spe/CreatePolygonFromSceneGraph not done.
tkaito@henri
parents: 1026
diff changeset
591 task_next->wait_for(task_array[k]);
1026
9e19e988559c create_pp_task fix.
tkaito
parents: 1020
diff changeset
592 }
907
03e60cf2e4c2 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
593 }
03e60cf2e4c2 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
594
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 857
diff changeset
595 void
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
596 Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 {
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 857
diff changeset
598
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 857
diff changeset
599 #if SPE_CREATE_POLYGON
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 857
diff changeset
600
907
03e60cf2e4c2 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
601 SceneGraphPtr sg = sgroot->getDrawSceneGraph();
03e60cf2e4c2 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
602
1028
cfec583ae7d3 spe/CreatePolygonFromSceneGraph not done.
tkaito@henri
parents: 1026
diff changeset
603 create_pp_task(sg, manager, spe_num, task_next, sgroot);
907
03e60cf2e4c2 collect matrix..
Yutaka_Kinjyo
parents: 900
diff changeset
604
908
Yutaka_Kinjyo
parents: 907
diff changeset
605 #if SPE_CREATE_POLYGON_CHECK
Yutaka_Kinjyo
parents: 907
diff changeset
606 check_matrix(matrix_info,sg);
Yutaka_Kinjyo
parents: 907
diff changeset
607 #endif
909
Yutaka_Kinjyo
parents: 908
diff changeset
608
Yutaka_Kinjyo
parents: 908
diff changeset
609 #else
1018
3a6766377905 sg_drawable_num add. CreatePolygonFromSceneGraph not done.
tkaito
parents: 1013
diff changeset
610 //SceneGraphPtr sg = sgroot->getDrawSceneGraph();
1035
2403d545abd8 bledenr script
tkaito
parents: 1034
diff changeset
611 //printf("sg->size = %lld\n", sizeof(pixels));
615
184d6d3f0cd9 remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
612 HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 // SceneGraph(木構造) -> PolygonPack
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
614
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
615 task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph());
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
616 task_create_pp->set_param(1,(memaddr)r[ppi].ppack);
1003
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
617
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
618 /* GameTask の処理の終了を待ってからポリゴンを作る */
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
619 if (sgroot->gtask_array != NULL) {
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
620 HTaskPtr game_task_array = sgroot->gtask_array->get_task_array();
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
621 task_create_pp->wait_for(game_task_array);
37842bbd35f0 game_task keep up with task_array.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents: 1002
diff changeset
622 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 task_next->wait_for(task_create_pp);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
624
909
Yutaka_Kinjyo
parents: 908
diff changeset
625 #endif
Yutaka_Kinjyo
parents: 908
diff changeset
626
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
627 int range_base = spe_num;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
628
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
629 // 切り上げのつもり
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
630 int range = (r[spi].spackList_length + range_base - 1) / range_base;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
631
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
632 for (int i = 0; i < range_base; i++) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 int index_start = range*i;
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
634 int index_end = (index_start + range >= r[spi].spackList_length)
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
635 ? r[spi].spackList_length : index_start + range;
1056
4955cedb17e5 endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
636 int starty = index_start*split_screen_h + 1;
4955cedb17e5 endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
637 int endy = index_end*split_screen_h;
4955cedb17e5 endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
638 if (starty<=0) starty = 1;
4955cedb17e5 endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
639 if (endy>height) endy = height;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
640
659
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
641 HTaskPtr task_create_sp = manager->create_task(CreateSpan);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
642
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
643 task_create_sp->set_param(0,index_start);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
644
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
646 * ex. screen_height が 480, spenum が 6 の場合、各SPEのy担当範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 * [ 1.. 80] [ 81..160] [161..240]
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 * [241..320] [321..400] [401..480]
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 * ex. screen_height が 1080, spenum が 5 の場合、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 * [ 1..216] [217..432] [433..648]
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 * [649..864] [865..1080]
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 */
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
654
1056
4955cedb17e5 endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
655 task_create_sp->set_param(1,starty);
4955cedb17e5 endy overflow in common rendering
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1050
diff changeset
656 task_create_sp->set_param(2,endy);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
657
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
658 task_create_sp->add_inData(r[ppi].ppack, sizeof(PolygonPack));
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
659 task_create_sp->add_inData(r[spi].spackList_ptr,
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
660 sizeof(SpanPack*)*r[spi].spackList_length_align);
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
661 task_create_sp->add_inData(&r[spi].spackList[index_start], sizeof(SpanPack));
659
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
662
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 task_next->wait_for(task_create_sp);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 task_create_sp->wait_for(task_create_pp);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
665
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
666 task_create_sp->set_cpu(SPE_ANY);
1085
tkaito@henri
parents: 1067
diff changeset
667 // task_create_sp->set_cpu(CPU_PPE);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
668 task_create_sp->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
670
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 857
diff changeset
671 task_create_pp->spawn();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
673
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
674
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 Viewer::common_draw(HTaskPtr task_next)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
677 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
678
615
184d6d3f0cd9 remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
679 //task_next = manager->create_task(Dummy);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 //task_next->set_post(post2runLoop, (void*)this);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
681
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
682 //Light info update
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
683
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
684 int light_num = 4;
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
685 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
686 int light_size = size / sizeof(float);
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
687
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
688 for (int i = 0; i < light_size; i++) {
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
689 light_xyz[i] = light_xyz_stock[i];
761
c0a8af52fa43 add lights
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 759
diff changeset
690 }
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
691
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
692 for (int i = 0; i < light_num; i++) {
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
693 light_switch[i] = light_switch_stock[i];
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
694 }
793
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
695
66497087393d add light switch api
yutaka@localhost.localdomain
parents: 792
diff changeset
696 light_sysswitch[0] = light_sysswitch_stock;
985
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
697
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
698
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
699 HTask *data_update_wait = 0;
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
700 for (int i = 0; i < spe_num; i++) {
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
701 data_update_wait = manager->create_task(DataUpdate);
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
702 data_update_wait->set_param(0,3);
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
703 data_update_wait->set_param(1,Light); // GlobalSet ID base
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
704 data_update_wait->set_inData(0,light_xyz,size); // Light
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
705 data_update_wait->set_inData(1,light_switch,light_num * sizeof(int)); // LightSwitch = Light+1
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
706 data_update_wait->set_inData(2,light_sysswitch,16); // LightSysSwitch = Light+2
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
707 data_update_wait->set_cpu((CPU_TYPE)(SPE_0+i));
37bd2b0694e2 fix light data update
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 984
diff changeset
708 data_update_wait->spawn();
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
709 }
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
710
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
711 ppi ^= 1;
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
712 r[ppi].ppack->clear();
914
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
713
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
714 for (int i = 0; i < r[spi].spackList_length; i++) {
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
715 SpanPack *spack = &r[spi].spackList[i];
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
716 int startx = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 int endx = split_screen_w;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
718
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
719 int starty = spack->info.y_top - split_screen_h + 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 //int endy = spack->info.y_top;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 int rangey = (starty + split_screen_h - 1 > this->height)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 ? this->height - starty + 1 : split_screen_h;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
723
889
5f5301028e29 minor fix. Redering Engine not worked yet.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 885
diff changeset
724 #if 1
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
725
914
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
726 // mem_flag は spe 側で黒い部分を 0 で埋めるフラグ
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
727 if(spack->info.size > 0 || mem_flag == 1) {
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
728
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
729 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
730 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
731 Task *task_draw = 0;
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
732
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
733 while (startx < this->width) {
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
734
839
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
735 // Draw SpanPack
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
736
839
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
737 task_draw = task_draw_array->next_task_array(DrawSpan,task_draw);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
738 task_draw->set_param(0,(memaddr)&pixels[(startx-1) + this->width*(starty-1)]);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
739 task_draw->set_param(1,this->width);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
740 task_draw->set_param(2,startx);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
741 task_draw->set_param(3,endx);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
742 task_draw->set_param(4,rangey);
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
743 task_draw->set_param(5,spack->info.size);
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
744
839
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
745 task_draw->set_inData(0,spack, sizeof(SpanPack));
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
746
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
747 for (int i = 0; i < rangey; i++) {
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
748 task_draw->set_outData(i,
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
749 &pixels[(startx-1) + this->width*(starty-1 + i) ],
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
750 (endx-startx+1)*sizeof(int));
839
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
751 }
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
752
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
753 startx += split_screen_w;
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
754 endx += split_screen_w;
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
755
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
756 if (endx > this->width) {
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
757 endx = this->width;
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
758 }
1001c4bea1a0 if unnecessary
Yutaka_Kinjyo
parents: 838
diff changeset
759
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
760 }
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
761
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
762 task_draw_array->spawn_task_array(task_draw->next());
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
763 task_draw_array->set_cpu(SPE_ANY);
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
764 task_next->wait_for(task_draw_array);
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
765 task_draw_array->spawn();
854
293fcceaac36 may be need ppeManager
yutaka@localhost.localdomain
parents: 843
diff changeset
766
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
767
914
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
768
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
769 } else {
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
770
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
771 memset(&pixels[(startx-1)+this->width*(starty-1)],
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
772 0, (this->width)*sizeof(int)*rangey);
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
773
914
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
774 }
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 913
diff changeset
775
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
776
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
777 #else
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
778
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
779 HTaskPtr task_draw;
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
780
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
781 while (startx < this->width) {
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
782 if (spack->info.size > 0) {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
783 // Draw SpanPack
615
184d6d3f0cd9 remove uncessary Task Name definision
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
784 task_draw = manager->create_task(DrawSpan);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
785
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
786 task_draw->set_param(0,
603
57ec231bc8ac long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 602
diff changeset
787 (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
788 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
789 task_draw->set_param(2,startx);
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
790 task_draw->set_param(3,endx);
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
791 task_draw->set_param(4,rangey);
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
792 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
793
c7199f162b64 bulk task list start.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 625
diff changeset
794 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
795
617
df618a956eb9 Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
796 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
797 task_draw->add_outData(
617
df618a956eb9 Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
798 &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
799 (endx-startx+1)*sizeof(int));
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
800 }
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
801
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
802 } else {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
803 // 7.7.3 SL1 Data Cache Range Set to Zero コマンド
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
804 // を使って、DMAでclearするべき... ということは、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
805 // それもSPEでやる方が良い?
857
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
806 memset(&pixels[(startx-1)+this->width*(starty-1)],
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
807 0, (this->width)*sizeof(int)*rangey);
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
808 break;
2fa8943d989a DrawSpan taskArray bug fix
yutaka@localhost.localdomain
parents: 854
diff changeset
809 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
810
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
811 task_draw->set_cpu(SPE_ANY);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
812 task_next->wait_for(task_draw);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
813 task_draw->spawn();
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
814
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
815 startx += split_screen_w;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
816 endx += split_screen_w;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
817
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
818 if (endx > this->width) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 endx = this->width;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
820 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
821 }
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
822 #endif
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 826
diff changeset
823
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
824 }
986
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
825 spi ^= 1;
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
826 for (int i = 1; i <= r[spi].spackList_length; i++) {
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
827 r[spi].spackList[i-1].reinit(i*split_screen_h);
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
828 }
b3a8545eb2fa double buffering of spanpack/polgonpack
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 985
diff changeset
829
792
b480fc04206f add light switch
yutaka@localhost.localdomain
parents: 779
diff changeset
830
925
292bb8c79cdb add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 918
diff changeset
831 if (profile) {
983
ad2bc8afc7b9 minor fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 982
diff changeset
832 if (frames % 50 == 49) {
998
c79bb1c5d9ce add fb_test, minor fix
yutaka@localhost.localdomain
parents: 994
diff changeset
833 manager->show_profile();
983
ad2bc8afc7b9 minor fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 982
diff changeset
834 this_time = get_ticks();
ad2bc8afc7b9 minor fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 982
diff changeset
835 if (this_time != start_time) {
984
dbebc7afd08e minor fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 983
diff changeset
836 printf("\n%f FPS\n", ((((float)frames)*1000.0)/(this_time-start_time)));
983
ad2bc8afc7b9 minor fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 982
diff changeset
837 start_time = this_time; frames = 0;
ad2bc8afc7b9 minor fix
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 982
diff changeset
838 }
982
9f5e6bfb1c09 avoid WAIT in virtual console
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 981
diff changeset
839 }
925
292bb8c79cdb add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 918
diff changeset
840 }
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
841 }
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
842
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
843 void
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
844 Viewer::run_finish()
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
845 {
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
846 dev->free_device();
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
847 if (this_time != start_time) {
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
848 printf("%f FPS\n", (((float)frames)/(this_time-start_time))*1000.0);
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
849 }
925
292bb8c79cdb add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 918
diff changeset
850 if (profile) {
292bb8c79cdb add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 918
diff changeset
851 manager->show_profile();
292bb8c79cdb add profile in Redering Engine
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 918
diff changeset
852 }
747
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
853
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
854 delete sgroot;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
855 // delete sgroot_2;
18d31d18a6b2 TaskManager changeset 683, Renderer changeset 746
hiroki
parents: 659
diff changeset
856 quit();
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
858
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 /* end */