# HG changeset patch # User Shinji KONO # Date 1281092363 -32400 # Node ID 1089f24bc86ac7faeeff8054ce13bc71c168ef8a # Parent cf64bc1b8062d0d1ac548f0ba029e420808c2e70 removing user task from Renderer Engine diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/TODO --- a/Renderer/Engine/TODO Thu Aug 05 22:54:43 2010 +0900 +++ b/Renderer/Engine/TODO Fri Aug 06 19:59:23 2010 +0900 @@ -1,3 +1,17 @@ +Fri Aug 6 19:53:19 JST 2010 kono + + Renderer Engine の task の下に user task を置くのは反則だろ? + 問題は、User program の方で、どうやって、task_init するかだが、 + PPE側は自分でやって問題ない。SPE側が困る。 + + やはり、main memory 上のtask listをSPEが自分で読み出すと言う + 方式が合理的だと思われる。get_segment で良いしね。ただ、可変長 + にしないとダメだが... 2^n allocator with compaction が必要か? + + 必ず ppe/spe task があるわけだから、task_list はppe/speで一つ + でも良い。少なくとも設定は一ヶ所が望ましい。object search path + があれば良い。 + Tue Sep 22 21:32:17 JST 2009 * SceneGraph の中の Property をlenear array する :Done @@ -5,7 +19,7 @@ * spe 側で lenear array を move_task で update する :kazz * option (spe 側で衝突判定するデータを gloval alloc する) :TODO * spe 側で lenear array を collision 側で update する :TODO -* lenear array から SceneGraph を再構築する :yutaka +* linear array から SceneGraph を再構築する :yutaka * rendering_task と task_next で待ち合わせる :kaito * ダブルバッファリングされている Property、SceneGraph を入れ替える :kaito -* rendering_task と move_task の起動 :kaito \ No newline at end of file +* rendering_task と move_task の起動 :kaito diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/spe/ChainCal.cc --- a/Renderer/Engine/spe/ChainCal.cc Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -#include -#include -#include -#include "ChainCal.h" -#include "Func.h" -#include "types.h" - -/* これは必須 */ -SchedDefineTask(ChainCal); - -#define CHAIN_LEN 50 - -static const double m = 100.0; -static const double k = 7000.0; -static const double g = 9.8; -static const double dt = 0.003; -static const double chain_width = 10; -static const double safe = 0.995; - -typedef struct { - double x, y, next_x, next_y; - double vx, vy, next_vx, next_vy; - double angle[3]; - int can_move; - uint32 parent; - int id; - //int parent; -} ChainProperty, *ChainPropertyPtr; - -static int -run(SchedTask *s,void *rbuf, void *wbuf) -{ - ChainPropertyPtr property = (ChainPropertyPtr)s->get_input(rbuf, 0); - ChainPropertyPtr update_property = (ChainPropertyPtr)s->get_output(wbuf, 0); - -// ChainPropertyPtr property = (ChainPropertyPtr)rbuf; -// int id = get_param(0); - - //ChainPropertyPtr o_property = (ChainPropertyPtr)wbuf; - - for(int cnt = 0; cnt < 600; cnt++) { - for(int i = 0; i < CHAIN_LEN; i++) { - if(property[i].can_move) { - double dx = property[i-1].x - property[i].x; - double dy = property[i-1].y - property[i].y; - double l = sqrt(dx * dx + dy * dy); - double a = k * (l - chain_width) / m; - double ax = a * dx / l; - double ay = a * dy / l; - if(i < CHAIN_LEN - 1) { - dx = property[i+1].x - property[i].x; - dy = property[i+1].y - property[i].y; - l = sqrt(dx * dx + dy * dy); - a = k * (l - chain_width) / m; - ax += a * dx / l; - ay += a * dy / l; - } - ay += g; - property[i].vx *= safe; - property[i].vy *= safe; - property[i].next_vx = property[i].vx + ax * dt; - property[i].next_vy = property[i].vy + ay * dt; - property[i].next_x = property[i].x + property[i].vx * dt; - property[i].next_y = property[i].y + property[i].vy * dt; - } else { - property[i].next_x = property[i].x; - property[i].next_y = property[i].y; - } - } - for(int i = 0; i < CHAIN_LEN; i++) { - property[i].vx = property[i].next_vx; - property[i].vy = property[i].next_vy; - property[i].x = property[i].next_x; - property[i].y = property[i].next_y; - } - } - - for (int j = 0; j < CHAIN_LEN; j++) { - int p, n; - int id = property[j].id; - p = n = id; - if(p != 0) { - p--; - } - if(n != CHAIN_LEN - 1) { - n++; - } - property[j].angle[2-(id%2)*2] - = 90 + atan((property[p].next_y - property[n].next_y) / (property[p].next_x - property[n].next_x)) * 180 / M_PI; - } - - memcpy((void*)update_property, (void*)property, sizeof(ChainProperty) * CHAIN_LEN); - return 0; -} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/spe/ChainCal.h --- a/Renderer/Engine/spe/ChainCal.h Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#ifndef INCLUDED_TASK_CHAIN_CAL -#define INCLUDED_TASK_CHAIN_CAL - -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif - - -#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/spe/ChainInit.cc --- a/Renderer/Engine/spe/ChainInit.cc Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -#include -#include -#include "ChainInit.h" -#include "Func.h" - -/* これは必須 */ -SchedDefineTask(ChainInit); - -/* - spe の global 領域に MemList を生成する - */ - -typedef struct { - double x, y, next_x, next_y; - double vx, vy, next_vx, next_vy; - int can_move; - uint32 parent; -} CHAIN_VARS; - - -static int -run(SchedTask *s,void *rbuf, void *wbuf) -{ - /* - CHAIN_VARS* idata = (CHAIN_VARS*)s->get_input(rbuf, 0); - uint32 chain_len = (unsigned long)s->get_param(0); - - // property は spe 上で allocate している(global) - CHAIN_VARS *property = (CHAIN_VARS*)s->global_alloc(DATA_ID, sizeof(CHAIN_VARS)*chain_len); - memcpy(property, idata, sizeof(CHAIN_VARS)*chain_len); - */ - return 0; -} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/spe/ChainInit.h --- a/Renderer/Engine/spe/ChainInit.h Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -#ifndef INCLUDED_TASK_CHAIN_INIT -#define INCLUDED_TASK_CHAIN_INIT - -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif - - - -#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/spe/Property.cc --- a/Renderer/Engine/spe/Property.cc Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -#include -#include -#include -#include "Property.h" -#include "Func.h" -#include "types.h" - -/* これは必須 */ -SchedDefineTask(PropertyTask); - -typedef struct { - float xyz[3]; - const char *name; -} Property, *PropertyPtr; - -static int -run(SchedTask *s,void *rbuf, void *wbuf) -{ - PropertyPtr property = (PropertyPtr)s->get_input(rbuf, 0); - PropertyPtr update_property = (PropertyPtr)s->get_output(wbuf, 0); - - property->xyz[0] += 1.0f; - property->xyz[1] += 1.0f; - property->xyz[2] += 1.0f; - - memcpy((void*)update_property, (void*)property, sizeof(Property)); - - return 0; -} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/spe/Property.h --- a/Renderer/Engine/spe/Property.h Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#ifndef INCLUDED_TASK_PROPERTY -#define INCLUDED_TASK_PROPERTY - -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif - - -#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/spe/chain_move.cc --- a/Renderer/Engine/spe/chain_move.cc Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -#include -#include -#include -#include "chain_move.h" -#include "Func.h" -#include "types.h" - -/* これは必須 */ -SchedDefineTask(ChainTask); - -static const int PROPERTY_LENGTH = 50; -static float m = 100.0; -static float k = 7000.0; -static float g = 9.8; -static float dt = 0.003; -static float chain_width = 10; -static float safe = 0.995; - -typedef struct { - float xyz[3]; - float angle[3]; - float stack_xyz[3]; - float next_xyz[3]; - float v_xyz[3]; - float next_v_xyz[3]; - int property_index; - int parent_index; - int have_parent; - int can_move; - memaddr parent; - memaddr children; - memaddr node; - int sgid; -} *PropertyPtr, Property; - -static int -run(SchedTask *s,void *rbuf, void *wbuf) -{ - PropertyPtr property = (PropertyPtr)s->get_input(rbuf, 0); - PropertyPtr update_property = (PropertyPtr)s->get_output(wbuf, 0); - - property[0].can_move = 0; - //property[1].can_move = 0; - - for(int cnt = 0; cnt < 600; cnt++) { - for(int i = 0; i < PROPERTY_LENGTH; i++) { - if(property[i].can_move) { -#if 0 - vector float v_x1 __attribute__((aligned(16))) = { property[i-1].xyz[0], - property[i].xyz[0], - property[i+1].xyz[0], - property[i+2].xyz[0]}; - vector float v_x2 __attribute__((aligned(16))) = { property[i].xyz[0], - property[i+1].xyz[0], - property[i+2].xyz[0], - property[i+3].xyz[0]}; - vector float v_dx __attribute__((aligned(16))) = spu_sub(v_x1, v_x2); - - vector float v_y1 __attribute__((aligned(16))) = { property[i-1].xyz[1], - property[i].xyz[1], - property[i+1].xyz[1], - property[i+2].xyz[1]}; - vector float v_y2 __attribute__((aligned(16))) = { property[i].xyz[1], - property[i+1].xyz[1], - property[i+2].xyz[1], - property[i+3].xyz[1]}; - vector float v_dy __attribute__((aligned(16))) = spu_sub(v_x1, v_x2); - - dx = spu_mule(dx, dx); - dy = spu_mule(dy, dy); - vector float v_l __attribute__((aligned(16))); - -#else - float dx = property[i-1].xyz[0] - property[i].xyz[0]; - float dy = property[i-1].xyz[1] - property[i].xyz[1]; - float l = sqrt(dx * dx + dy * dy); - float a = k * (l - chain_width) / m; - float ax = a * dx / l; - float ay = a * dy / l; - if(i < PROPERTY_LENGTH - 1) { - dx = property[i+1].xyz[0] - property[i].xyz[0]; - dy = property[i+1].xyz[1] - property[i].xyz[1]; - l = sqrt(dx * dx + dy * dy); - a = k * (l - chain_width) / m; - ax += a * dx / l; - ay += a * dy / l; - } - ay += g; - property[i].v_xyz[0] *= safe; - property[i].v_xyz[1] *= safe; - property[i].next_v_xyz[0] = property[i].v_xyz[0] + ax * dt; - property[i].next_v_xyz[1] = property[i].v_xyz[1] + ay * dt; - property[i].next_xyz[0] = property[i].xyz[0] + property[i].v_xyz[0] * dt; - property[i].next_xyz[1] = property[i].xyz[1] + property[i].v_xyz[1] * dt; - } else { - property[i].next_xyz[0] = property[i].xyz[0]; - property[i].next_xyz[1] = property[i].xyz[1]; - } -#endif - } - - for(int i = 0; i < PROPERTY_LENGTH; i++) { - property[i].v_xyz[0] = property[i].next_v_xyz[0]; - property[i].v_xyz[1] = property[i].next_v_xyz[1]; - property[i].xyz[0] = property[i].next_xyz[0]; - property[i].xyz[1] = property[i].next_xyz[1]; - } - } - - for(int i = 0; i < PROPERTY_LENGTH; i++) { - int id = property[i].property_index; - int p, n; - p = n = id; - if(p != 0) { - p--; - } - if(n != PROPERTY_LENGTH - 1) { - n++; - } - property[i].angle[2-(id%2)*2] - = 90 + atan((property[p].next_xyz[1] - property[n].next_xyz[1]) - / (property[p].next_xyz[0] - property[n].next_xyz[0])) * 180 / M_PI; - } - - memcpy((void*)update_property, (void*)property, sizeof(Property)*PROPERTY_LENGTH); - - return 0; -} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/spe/chain_move.h --- a/Renderer/Engine/spe/chain_move.h Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#ifndef INCLUDED_TASK_CHAIN -#define INCLUDED_TASK_CHAIN - -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif - - -#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/spe/universe_move.cc --- a/Renderer/Engine/spe/universe_move.cc Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -#include -#include -#include -#include "universe_move.h" -#include "Func.h" -#include "types.h" - -/* これは必須 */ -SchedDefineTask(UniverseTask); - -typedef struct { - float xyz[3]; - float angle[3]; - float stack_xyz[3]; - int property_index; - int parent_index; - int have_parent; - memaddr parent; - memaddr children; - memaddr node; - const char *name; -} *PropertyPtr, Property; - -static int -run(SchedTask *s,void *rbuf, void *wbuf) -{ - PropertyPtr property = (PropertyPtr)s->get_input(rbuf, 0); - PropertyPtr update_property = (PropertyPtr)s->get_output(wbuf, 0); - int screen_w = 1920; - int screen_h = 1080; - - property[0].angle[1] += 1.0f; - if (property[0].angle[1] > 360.0f) { - property[0].angle[1] = 0.0f; - } - - property[0].xyz[0] += property[0].stack_xyz[0]; - if ((int)property[0].xyz[0] > screen_w || (int)property[0].xyz[0] < 0) { - property[0].stack_xyz[0] = -property[0].stack_xyz[0]; - } - - property[0].xyz[1] += property[0].stack_xyz[1]; - if ((int)property[0].xyz[1] > screen_h || (int)property[0].xyz[1] < 0) { - property[0].stack_xyz[1] = -property[0].stack_xyz[1]; - } - - memcpy((void*)update_property, (void*)property, sizeof(Property)*2); - - return 0; -} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/spe/universe_move.h --- a/Renderer/Engine/spe/universe_move.h Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#ifndef INCLUDED_TASK_UNIVERSE -#define INCLUDED_TASK_UNIVERSE - -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif - - -#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/task/ChainMove.cc --- a/Renderer/Engine/task/ChainMove.cc Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -#include -#include -#include "ChainMove.h" - - -SchedDefineTask(ChainMove); - -static int -run(SchedTask *s,void *rbuf, void *wbuf) -{ - return 0; -} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/task/ChainMove.h --- a/Renderer/Engine/task/ChainMove.h Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -#ifndef INCLUDED_TASK_CHAIN_MOVE -#define INCLUDED_TASK_CHAIN_MOVE - -#include "SchedTask.h" - - -#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/task/Move.cc --- a/Renderer/Engine/task/Move.cc Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -#include -#include -#include "Move.h" -#include "viewer_types.h" - -SchedDefineTask(Move); - -static int -run(SchedTask *s,void *rbuf, void *wbuf) -{ - //sgroot->updateControllerState(); - //sgroot->speExecute(width, height); - - return 0; -} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/task/Move.h --- a/Renderer/Engine/task/Move.h Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -#ifndef INCLUDED_TASK_MOVE -#define INCLUDED_TASK_MOVE - -#include "SchedTask.h" - - -#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/task/Property.cc --- a/Renderer/Engine/task/Property.cc Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -#include -#include -#include -#include "Property.h" -#include "Func.h" -#include "types.h" - -/* これは必須 */ -SchedDefineTask(PropertyTask); - -typedef struct { - float x, y, z; -} Property, *PropertyPtr; - -static int -run(SchedTask *s,void *rbuf, void *wbuf) -{ - PropertyPtr property = (PropertyPtr)s->get_input(rbuf, 0); - PropertyPtr update_property = (PropertyPtr)s->get_output(wbuf, 0); - - property->x += 1.0f; - property->y += 1.0f; - property->z += 1.0f; - - memcpy((void*)update_property, (void*)property, sizeof(Property)); - return 0; -} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/task/Property.h --- a/Renderer/Engine/task/Property.h Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#ifndef INCLUDED_TASK_PROPERTY -#define INCLUDED_TASK_PROPERTY - -#ifndef INCLUDED_SCHED_TASK -# include "SchedTask.h" -#endif - - -#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/task/RunMove.cc --- a/Renderer/Engine/task/RunMove.cc Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -#include -#include -#include "RunMove.h" -#include "SgChange.h" - -SchedDefineTask(RunMove); - -static int -run(SchedTask *smanager, void *rbuf , void *wbuf) -{ - //SceneGraphRoot *sgroot = (SceneGraphRoot *)smanager->get_param(0); - SgChange *sgchange = (SgChange *)smanager->get_param(0); - long width = (long)smanager->get_param(1); - long height = (long)smanager->get_param(2); - SceneGraphRoot *sgroot = sgchange->sgroot_A; - sgroot->updateControllerState(); - sgroot->oneExecute(width, height); - sgchange->viewer->light_xyz_stock = sgroot->getLightVector(); - - return 0; -} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/task/RunMove.h --- a/Renderer/Engine/task/RunMove.h Thu Aug 05 22:54:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -#ifndef INCLUDED_RUN_MOVE -#define INCLUDED_RUN_MOVE - -#include "SceneGraphRoot.h" -#include "SchedTask.h" - -#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/task/task_init.cc --- a/Renderer/Engine/task/task_init.cc Thu Aug 05 22:54:43 2010 +0900 +++ b/Renderer/Engine/task/task_init.cc Fri Aug 06 19:59:23 2010 +0900 @@ -17,13 +17,13 @@ SchedExternTask(LoadTexture); -SchedExternTask(Move); +// SchedExternTask(Move); SchedExternTask(Draw); // SchedExternTask(Dummy); SchedExternTask(ShowTime); -SchedExternTask(ChainMove); +// SchedExternTask(ChainMove); SchedExternTask(SendKey); SchedExternTask(UpdateKey); @@ -57,7 +57,7 @@ SchedRegister( LoadTexture); - SchedRegister( Move); +// SchedRegister( Move); SchedRegister( Draw); // SchedRegister( Dummy); @@ -68,10 +68,11 @@ //SchedRegister( ShowTime); SchedRegister( Switch); - // usr - SchedRegister( ChainMove); - SchedRegister( RunMove); - SchedRegister( PropertyTask); SchedRegister( ExecMove); + // usr +// SchedRegister( ChainMove); +// SchedRegister( RunMove); +// SchedRegister( PropertyTask); + } diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Engine/viewer.cc --- a/Renderer/Engine/viewer.cc Thu Aug 05 22:54:43 2010 +0900 +++ b/Renderer/Engine/viewer.cc Fri Aug 06 19:59:23 2010 +0900 @@ -280,7 +280,7 @@ /* TASK_MOVE は外から引数で取ってくるべき */ //HTaskPtr move_task = viewer->manager->create_task(viewer->app->move_taskid); - HTaskPtr move_task = viewer->manager->create_task(Move,0,0,0,0); + // HTaskPtr move_task = viewer->manager->create_task(Move,0,0,0,0); //move_task->set_param(sgroot); //HTaskPtr draw_task = viewer->manager->create_task(Draw); @@ -294,9 +294,9 @@ switch_task->wait_for(draw_dummy); draw_task->set_post(post2speRendering, (void*)viewer, 0); - switch_task->wait_for(move_task); + // switch_task->wait_for(move_task); switch_task->wait_for(draw_task); - move_task->spawn(); + // move_task->spawn(); draw_task->spawn(); switch_task->set_post(post2runMoveDrawLoop, (void*)viewer, 0); diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/ppe/ChainMove.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/ppe/ChainMove.cc Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,12 @@ +#include +#include +#include "ChainMove.h" + + +SchedDefineTask(ChainMove); + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + return 0; +} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/ppe/ChainMove.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/ppe/ChainMove.h Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,7 @@ +#ifndef INCLUDED_TASK_CHAIN_MOVE +#define INCLUDED_TASK_CHAIN_MOVE + +#include "SchedTask.h" + + +#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/ppe/Property.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/ppe/Property.cc Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,27 @@ +#include +#include +#include +#include "Property.h" +#include "Func.h" +#include "types.h" + +/* これは必須 */ +SchedDefineTask(PropertyTask); + +typedef struct { + float x, y, z; +} Property, *PropertyPtr; + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + PropertyPtr property = (PropertyPtr)s->get_input(rbuf, 0); + PropertyPtr update_property = (PropertyPtr)s->get_output(wbuf, 0); + + property->x += 1.0f; + property->y += 1.0f; + property->z += 1.0f; + + memcpy((void*)update_property, (void*)property, sizeof(Property)); + return 0; +} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/ppe/Property.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/ppe/Property.h Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_TASK_PROPERTY +#define INCLUDED_TASK_PROPERTY + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + +#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/spe/ChainCal.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/spe/ChainCal.cc Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,94 @@ +#include +#include +#include +#include "ChainCal.h" +#include "Func.h" +#include "types.h" + +/* これは必須 */ +SchedDefineTask(ChainCal); + +#define CHAIN_LEN 50 + +static const double m = 100.0; +static const double k = 7000.0; +static const double g = 9.8; +static const double dt = 0.003; +static const double chain_width = 10; +static const double safe = 0.995; + +typedef struct { + double x, y, next_x, next_y; + double vx, vy, next_vx, next_vy; + double angle[3]; + int can_move; + uint32 parent; + int id; + //int parent; +} ChainProperty, *ChainPropertyPtr; + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + ChainPropertyPtr property = (ChainPropertyPtr)s->get_input(rbuf, 0); + ChainPropertyPtr update_property = (ChainPropertyPtr)s->get_output(wbuf, 0); + +// ChainPropertyPtr property = (ChainPropertyPtr)rbuf; +// int id = get_param(0); + + //ChainPropertyPtr o_property = (ChainPropertyPtr)wbuf; + + for(int cnt = 0; cnt < 600; cnt++) { + for(int i = 0; i < CHAIN_LEN; i++) { + if(property[i].can_move) { + double dx = property[i-1].x - property[i].x; + double dy = property[i-1].y - property[i].y; + double l = sqrt(dx * dx + dy * dy); + double a = k * (l - chain_width) / m; + double ax = a * dx / l; + double ay = a * dy / l; + if(i < CHAIN_LEN - 1) { + dx = property[i+1].x - property[i].x; + dy = property[i+1].y - property[i].y; + l = sqrt(dx * dx + dy * dy); + a = k * (l - chain_width) / m; + ax += a * dx / l; + ay += a * dy / l; + } + ay += g; + property[i].vx *= safe; + property[i].vy *= safe; + property[i].next_vx = property[i].vx + ax * dt; + property[i].next_vy = property[i].vy + ay * dt; + property[i].next_x = property[i].x + property[i].vx * dt; + property[i].next_y = property[i].y + property[i].vy * dt; + } else { + property[i].next_x = property[i].x; + property[i].next_y = property[i].y; + } + } + for(int i = 0; i < CHAIN_LEN; i++) { + property[i].vx = property[i].next_vx; + property[i].vy = property[i].next_vy; + property[i].x = property[i].next_x; + property[i].y = property[i].next_y; + } + } + + for (int j = 0; j < CHAIN_LEN; j++) { + int p, n; + int id = property[j].id; + p = n = id; + if(p != 0) { + p--; + } + if(n != CHAIN_LEN - 1) { + n++; + } + property[j].angle[2-(id%2)*2] + = 90 + atan((property[p].next_y - property[n].next_y) / (property[p].next_x - property[n].next_x)) * 180 / M_PI; + } + + memcpy((void*)update_property, (void*)property, sizeof(ChainProperty) * CHAIN_LEN); + return 0; +} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/spe/ChainCal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/spe/ChainCal.h Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_TASK_CHAIN_CAL +#define INCLUDED_TASK_CHAIN_CAL + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + +#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/spe/ChainInit.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/spe/ChainInit.cc Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,33 @@ +#include +#include +#include "ChainInit.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask(ChainInit); + +/* + spe の global 領域に MemList を生成する + */ + +typedef struct { + double x, y, next_x, next_y; + double vx, vy, next_vx, next_vy; + int can_move; + uint32 parent; +} CHAIN_VARS; + + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + /* + CHAIN_VARS* idata = (CHAIN_VARS*)s->get_input(rbuf, 0); + uint32 chain_len = (unsigned long)s->get_param(0); + + // property は spe 上で allocate している(global) + CHAIN_VARS *property = (CHAIN_VARS*)s->global_alloc(DATA_ID, sizeof(CHAIN_VARS)*chain_len); + memcpy(property, idata, sizeof(CHAIN_VARS)*chain_len); + */ + return 0; +} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/spe/ChainInit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/spe/ChainInit.h Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,10 @@ +#ifndef INCLUDED_TASK_CHAIN_INIT +#define INCLUDED_TASK_CHAIN_INIT + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + + +#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/spe/Property.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/spe/Property.cc Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,29 @@ +#include +#include +#include +#include "Property.h" +#include "Func.h" +#include "types.h" + +/* これは必須 */ +SchedDefineTask(PropertyTask); + +typedef struct { + float xyz[3]; + const char *name; +} Property, *PropertyPtr; + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + PropertyPtr property = (PropertyPtr)s->get_input(rbuf, 0); + PropertyPtr update_property = (PropertyPtr)s->get_output(wbuf, 0); + + property->xyz[0] += 1.0f; + property->xyz[1] += 1.0f; + property->xyz[2] += 1.0f; + + memcpy((void*)update_property, (void*)property, sizeof(Property)); + + return 0; +} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/spe/Property.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/spe/Property.h Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_TASK_PROPERTY +#define INCLUDED_TASK_PROPERTY + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + +#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/spe/chain_move.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/spe/chain_move.cc Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,128 @@ +#include +#include +#include +#include "chain_move.h" +#include "Func.h" +#include "types.h" + +/* これは必須 */ +SchedDefineTask(ChainTask); + +static const int PROPERTY_LENGTH = 50; +static float m = 100.0; +static float k = 7000.0; +static float g = 9.8; +static float dt = 0.003; +static float chain_width = 10; +static float safe = 0.995; + +typedef struct { + float xyz[3]; + float angle[3]; + float stack_xyz[3]; + float next_xyz[3]; + float v_xyz[3]; + float next_v_xyz[3]; + int property_index; + int parent_index; + int have_parent; + int can_move; + memaddr parent; + memaddr children; + memaddr node; + int sgid; +} *PropertyPtr, Property; + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + PropertyPtr property = (PropertyPtr)s->get_input(rbuf, 0); + PropertyPtr update_property = (PropertyPtr)s->get_output(wbuf, 0); + + property[0].can_move = 0; + //property[1].can_move = 0; + + for(int cnt = 0; cnt < 600; cnt++) { + for(int i = 0; i < PROPERTY_LENGTH; i++) { + if(property[i].can_move) { +#if 0 + vector float v_x1 __attribute__((aligned(16))) = { property[i-1].xyz[0], + property[i].xyz[0], + property[i+1].xyz[0], + property[i+2].xyz[0]}; + vector float v_x2 __attribute__((aligned(16))) = { property[i].xyz[0], + property[i+1].xyz[0], + property[i+2].xyz[0], + property[i+3].xyz[0]}; + vector float v_dx __attribute__((aligned(16))) = spu_sub(v_x1, v_x2); + + vector float v_y1 __attribute__((aligned(16))) = { property[i-1].xyz[1], + property[i].xyz[1], + property[i+1].xyz[1], + property[i+2].xyz[1]}; + vector float v_y2 __attribute__((aligned(16))) = { property[i].xyz[1], + property[i+1].xyz[1], + property[i+2].xyz[1], + property[i+3].xyz[1]}; + vector float v_dy __attribute__((aligned(16))) = spu_sub(v_x1, v_x2); + + dx = spu_mule(dx, dx); + dy = spu_mule(dy, dy); + vector float v_l __attribute__((aligned(16))); + +#else + float dx = property[i-1].xyz[0] - property[i].xyz[0]; + float dy = property[i-1].xyz[1] - property[i].xyz[1]; + float l = sqrt(dx * dx + dy * dy); + float a = k * (l - chain_width) / m; + float ax = a * dx / l; + float ay = a * dy / l; + if(i < PROPERTY_LENGTH - 1) { + dx = property[i+1].xyz[0] - property[i].xyz[0]; + dy = property[i+1].xyz[1] - property[i].xyz[1]; + l = sqrt(dx * dx + dy * dy); + a = k * (l - chain_width) / m; + ax += a * dx / l; + ay += a * dy / l; + } + ay += g; + property[i].v_xyz[0] *= safe; + property[i].v_xyz[1] *= safe; + property[i].next_v_xyz[0] = property[i].v_xyz[0] + ax * dt; + property[i].next_v_xyz[1] = property[i].v_xyz[1] + ay * dt; + property[i].next_xyz[0] = property[i].xyz[0] + property[i].v_xyz[0] * dt; + property[i].next_xyz[1] = property[i].xyz[1] + property[i].v_xyz[1] * dt; + } else { + property[i].next_xyz[0] = property[i].xyz[0]; + property[i].next_xyz[1] = property[i].xyz[1]; + } +#endif + } + + for(int i = 0; i < PROPERTY_LENGTH; i++) { + property[i].v_xyz[0] = property[i].next_v_xyz[0]; + property[i].v_xyz[1] = property[i].next_v_xyz[1]; + property[i].xyz[0] = property[i].next_xyz[0]; + property[i].xyz[1] = property[i].next_xyz[1]; + } + } + + for(int i = 0; i < PROPERTY_LENGTH; i++) { + int id = property[i].property_index; + int p, n; + p = n = id; + if(p != 0) { + p--; + } + if(n != PROPERTY_LENGTH - 1) { + n++; + } + property[i].angle[2-(id%2)*2] + = 90 + atan((property[p].next_xyz[1] - property[n].next_xyz[1]) + / (property[p].next_xyz[0] - property[n].next_xyz[0])) * 180 / M_PI; + } + + memcpy((void*)update_property, (void*)property, sizeof(Property)*PROPERTY_LENGTH); + + return 0; +} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/spe/chain_move.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/spe/chain_move.h Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_TASK_CHAIN +#define INCLUDED_TASK_CHAIN + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + +#endif diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/spe/universe_move.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/spe/universe_move.cc Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,50 @@ +#include +#include +#include +#include "universe_move.h" +#include "Func.h" +#include "types.h" + +/* これは必須 */ +SchedDefineTask(UniverseTask); + +typedef struct { + float xyz[3]; + float angle[3]; + float stack_xyz[3]; + int property_index; + int parent_index; + int have_parent; + memaddr parent; + memaddr children; + memaddr node; + const char *name; +} *PropertyPtr, Property; + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + PropertyPtr property = (PropertyPtr)s->get_input(rbuf, 0); + PropertyPtr update_property = (PropertyPtr)s->get_output(wbuf, 0); + int screen_w = 1920; + int screen_h = 1080; + + property[0].angle[1] += 1.0f; + if (property[0].angle[1] > 360.0f) { + property[0].angle[1] = 0.0f; + } + + property[0].xyz[0] += property[0].stack_xyz[0]; + if ((int)property[0].xyz[0] > screen_w || (int)property[0].xyz[0] < 0) { + property[0].stack_xyz[0] = -property[0].stack_xyz[0]; + } + + property[0].xyz[1] += property[0].stack_xyz[1]; + if ((int)property[0].xyz[1] > screen_h || (int)property[0].xyz[1] < 0) { + property[0].stack_xyz[1] = -property[0].stack_xyz[1]; + } + + memcpy((void*)update_property, (void*)property, sizeof(Property)*2); + + return 0; +} diff -r cf64bc1b8062 -r 1089f24bc86a Renderer/Test/spe/universe_move.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/spe/universe_move.h Fri Aug 06 19:59:23 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_TASK_UNIVERSE +#define INCLUDED_TASK_UNIVERSE + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif + + +#endif