1405
|
1 #include "Light.h"
|
1406
|
2 #include "Func.h"
|
1405
|
3
|
|
4 void
|
|
5 Light::init()
|
|
6 {
|
|
7 int light_num = 4;
|
|
8 int size = sizeof(float)*4*light_num; //xyz+alfa(4) * light_num(4)
|
|
9 int light_size = size / sizeof(float);
|
|
10
|
|
11 light_xyz = (float *)manager->allocate(size);
|
|
12
|
|
13 for (int i = 0; i < light_size ; i++) {
|
|
14 light_xyz[i] = 0.0f;
|
|
15 }
|
|
16
|
|
17
|
1411
|
18 for(int i = 0;i<SPE_0+spe_num;) { // including CPU_PPE==0
|
1405
|
19 HTaskPtr data_load = manager->create_task(DataAllocate);
|
|
20 data_load->set_param(0,(memaddr)3); // num of allocate block
|
|
21 data_load->set_param(1,(memaddr)(sizeof(float)*4*light_num)); // 1st allocate size
|
1406
|
22 data_load->set_param(2,(memaddr)LightData); // 1st id
|
1405
|
23 data_load->set_param(3,(memaddr)(light_num * sizeof(int))); // 2nd size
|
|
24 data_load->set_param(4,(memaddr)LightSwitch); // 2nd id
|
|
25 data_load->set_param(5,(memaddr)16); // 3rd size
|
|
26 data_load->set_param(6,(memaddr)LightSysSwitch); // 3rd id
|
1410
|
27 data_load->set_cpu((CPU_TYPE)i);
|
1405
|
28 data_load->spawn();
|
1411
|
29 if (i==0) i=SPE_0; else i++;
|
1405
|
30 }
|
|
31
|
|
32 light_switch = (int*)manager->allocate(size);
|
|
33
|
|
34 for (int i = 0; i < light_num; i++) {
|
|
35 light_switch[i] = 0;
|
|
36 }
|
|
37
|
|
38 int light_sw_size = 16; // LightSysSwitch は 4byte. 残り 12byte は DMA転送の為のパディング
|
|
39
|
|
40 light_sysswitch = (int*)manager->allocate(light_sw_size);
|
|
41
|
|
42 for (unsigned int i = 0; i < light_sw_size / sizeof(int); i++) {
|
|
43 light_sysswitch[i] = 0;
|
|
44 }
|
|
45
|
|
46 }
|
|
47
|
|
48
|
|
49 bool
|
|
50 Light::exec(HTaskPtr task_next)
|
|
51 {
|
|
52 light_xyz_stock = sgroot->getLightVector();
|
|
53
|
|
54
|
|
55 light_switch_stock = sgroot->getLightSwitch();
|
|
56 light_sysswitch_stock = sgroot->getLightSysSwitch();
|
|
57
|
|
58 return true;
|
|
59 }
|
|
60
|
1406
|
61 HTaskPtr
|
1405
|
62 Light::update(HTaskPtr task_next)
|
|
63 {
|
|
64
|
|
65 //task_next = manager->create_task(Dummy);
|
|
66 //task_next->set_post(post2runLoop, (void*)this);
|
|
67
|
|
68 //Light info update
|
|
69
|
|
70 int light_num = 4;
|
|
71 int size = sizeof(float)*4*light_num; //xyz+alpha(4) * light_num(4)
|
|
72 int light_size = size / sizeof(float);
|
|
73
|
|
74 for (int i = 0; i < light_size; i++) {
|
|
75 light_xyz[i] = light_xyz_stock[i];
|
|
76 }
|
|
77
|
|
78 for (int i = 0; i < light_num; i++) {
|
|
79 light_switch[i] = light_switch_stock[i];
|
|
80 }
|
|
81
|
|
82 light_sysswitch[0] = light_sysswitch_stock;
|
|
83
|
|
84
|
|
85 HTask *data_update_wait = manager->create_task(Dummy);
|
1411
|
86 for(int i = 0;i<SPE_0+spe_num;) { // including CPU_PPE==0
|
1405
|
87 HTaskPtr data_update = manager->create_task(DataUpdate);
|
|
88 data_update->set_param(0,3);
|
1406
|
89 data_update->set_param(1,LightData); // GlobalSet ID base
|
1405
|
90 data_update->set_inData(0,light_xyz,size); // Light
|
|
91 data_update->set_inData(1,light_switch,light_num * sizeof(int)); // LightSwitch = Light+1
|
|
92 data_update->set_inData(2,light_sysswitch,16); // LightSysSwitch = Light+2
|
1410
|
93 data_update->set_cpu((CPU_TYPE)i);
|
1405
|
94 data_update_wait->wait_for(data_update);
|
|
95 data_update->spawn();
|
1411
|
96 if (i==0) i=SPE_0; else i++;
|
1405
|
97 }
|
1406
|
98 return data_update_wait;
|
1405
|
99 }
|