# HG changeset patch # User yutaka@localhost.localdomain # Date 1276792206 -32400 # Node ID 649e4cb84683af8a1e5a49183fb0c702590e7785 # Parent e39f320c44117ad634f1e59ab3d37b017d0539e8 Still on the way diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/Makefile.def --- a/Renderer/Engine/Makefile.def Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/Makefile.def Fri Jun 18 01:30:06 2010 +0900 @@ -5,7 +5,7 @@ ABIBIT = 32 ABI = -m$(ABIBIT) CC = g++ -OPT = -g #-O2 +OPT = -g -DSPE_CREATE_POLYGON #-O2 CFLAGS = -g -Wall $(ABI) $(OPT) # -DDEBUG INCLUDE = -I$(CERIUM)/include/TaskManager -I. diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/SceneGraph.cc --- a/Renderer/Engine/SceneGraph.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/SceneGraph.cc Fri Jun 18 01:30:06 2010 +0900 @@ -16,7 +16,8 @@ SceneGraphPtr scene_graph_viewer = NULL; static TextureHash texture_hash; -struct texture_list list[TABLE_SIZE]; +texture_list list[TABLE_SIZE]; + extern int decode(char *cont, FILE *outfile); @@ -138,12 +139,38 @@ size = atoi((char *)xmlGetProp(surface,(xmlChar *)"size")); name = (char *)xmlGetProp(surface,(xmlChar *)"name"); parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent"); + texture_info = (texture_list_ptr)manager->allocate(sizeof(texture_list)*TABLE_SIZE); + //data = new float[size*3*3]; - //data = new float[size*3*3]; +#if SPE_CREATE_POLYGON + + /* CreatePolygon を spe 側でやるために。 + size は頂点の数。speに渡す場合には、16の倍数にして + 16Kbyte以上の場合、16Kbyte毎に分割できるようにしなければならない。 + CreatePolygonFromSceneGraphTaskをspeで動かすために、speに渡すのは + TrianglePackでよい。 + polygon_pack 1つには triangle が 128 になってる。polygon_pack の + triangle 数に合わせる方が楽だよね。なんか変な気もするけど、polygon + クラスにもTrianglePackを持たす。SceneGraph は自分の polygon 数が入る + 分だけ、TrianglePackを持つ。CreatePolygonTask にはSceneGraph 側の + TrianglePack を input に、polygon_pack の TriganlePack を output とする + */ + + int tri_pack_size = sizeof(TrianglePack)*(size/3); + tri_pack = (TrianglePackPtr)manager->allocate(tri_pack_size); + texture_info = (texture_list*)manager->allocate(sizeof(texture_list)); + sg_matrix = (float*)manager->allocate(sizeof(float)*32); + matrix = sg_matrix; + real_matrix = sg_matrix + 16; + +#else + coord_xyz = (float*)manager->allocate(sizeof(float)*size*3); coord_tex = (float*)manager->allocate(sizeof(float)*size*3); normal = (float*)manager->allocate(sizeof(float)*size*3); +#endif + get_data(manager, surface->children); finalize = &SceneGraph::finalize_original; @@ -170,10 +197,23 @@ size = 0; //data = NULL; + +#if SPE_CREATE_POLYGON + + tri_pack = NULL; + sg_matrix = NULL; + matrix = NULL; + real_matrix = NULL; + texture_info = NULL; + +#else + coord_xyz = NULL; normal = NULL; coord_tex = NULL; +#endif + texture_id = -1; move = no_move; collision = no_collision; @@ -199,9 +239,23 @@ SceneGraph::finalize_original() { //delete [] data; + +#if SPE_CREATE_POLYGON + + free(tri_pack); + free(sg_matrix); + free(matrix); + free(real_matrix); + free(texture_info); + +#else + free(coord_xyz); free(coord_tex); free(normal); + +#endif + } /** @@ -497,13 +551,29 @@ texture_id = tex_id; } - // こんなことすると list[] のいみあるのかなーと - // 微妙に思う、自分で書き換えた感想 by gongo - texture_info.t_w = list[texture_id].t_w; - texture_info.t_h = list[texture_id].t_h;; - texture_info.pixels_orig = list[texture_id].pixels_orig; - texture_info.pixels = list[texture_id].pixels; - texture_info.scale_max = list[texture_id].scale_max; + +#if SPE_CREATE_POLYGON + + + texture_info->t_w = list[texture_id].t_w; + texture_info->t_h = list[texture_id].t_h;; + texture_info->pixels_orig = list[texture_id].pixels_orig; + texture_info->pixels = list[texture_id].pixels; + texture_info->scale_max = list[texture_id].scale_max; + + +#else + + // こんなことすると list[] のいみあるのかなーと + // 微妙に思う、自分で書き換えた感想 by gongo + texture_info.t_w = list[texture_id].t_w; + texture_info.t_h = list[texture_id].t_h;; + texture_info.pixels_orig = list[texture_id].pixels_orig; + texture_info.pixels = list[texture_id].pixels; + texture_info.scale_max = list[texture_id].scale_max; + +#endif + } diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/SceneGraph.h --- a/Renderer/Engine/SceneGraph.h Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/SceneGraph.h Fri Jun 18 01:30:06 2010 +0900 @@ -33,7 +33,7 @@ // Objectのシーケンス番号(Linda) // とりあえず動かしたいので追加 int seq, seq_rd, resend_flag; - + int property_size; void *propertyptr; //void *property; diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/polygon.cc --- a/Renderer/Engine/polygon.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/polygon.cc Fri Jun 18 01:30:06 2010 +0900 @@ -177,6 +177,36 @@ void Polygon::pickup_coordinate(char *cont) { + +#if SPE_CREATE_POLYGON + + TrianglePackPtr cur = tri_pack; + + for(int n=0; nver1.x); + cont = pickup_float(cont, &cur->ver1.y); + cont = pickup_float(cont, &cur->ver1.z); + + cont = pickup_float(cont, &cur->ver2.x); + cont = pickup_float(cont, &cur->ver2.y); + cont = pickup_float(cont, &cur->ver2.z); + + cont = pickup_float(cont, &cur->ver3.x); + cont = pickup_float(cont, &cur->ver3.y); + cont = pickup_float(cont, &cur->ver3.z); + + cur = cur + 1; + + if (cont == NULL) + { + cout << "Analyzing obj data failed coordinate\n"; + } + } + +#else + for(int n=0; nnormal1.x); + cont = pickup_float(cont, &cur->normal1.y); + cont = pickup_float(cont, &cur->normal1.z); + + cont = pickup_float(cont, &cur->normal2.x); + cont = pickup_float(cont, &cur->normal2.y); + cont = pickup_float(cont, &cur->normal2.z); + + cont = pickup_float(cont, &cur->normal3.x); + cont = pickup_float(cont, &cur->normal3.y); + cont = pickup_float(cont, &cur->normal3.z); + + cur = cur + 1; + + if (cont == NULL) + { + cout << "Analyzing obj data failed coordinate\n"; + } + } + +#else + + for (int n = 0; nver1.tex_x); + cont = pickup_float(cont, &cur->ver1.tex_y); + + cont = pickup_float(cont, &cur->ver2.tex_x); + cont = pickup_float(cont, &cur->ver2.tex_y); + + cont = pickup_float(cont, &cur->ver3.tex_x); + cont = pickup_float(cont, &cur->ver3.tex_y); + + cur = cur + 1; + + if (cont == NULL) + { + cout << "Analyzing obj data failed coordinate\n"; + } + } + +#else + for (int n = 0; n < size*3; n += 3) { cont = pickup_float(cont, coord_tex+n); @@ -230,6 +324,9 @@ cout << "Analyzing obj data failed texture\n"; } } + +#endif + } char *get_pixel(int tx, int ty, SDL_Surface *texture_image) diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/polygon.h --- a/Renderer/Engine/polygon.h Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/polygon.h Fri Jun 18 01:30:06 2010 +0900 @@ -14,17 +14,33 @@ const char *parent_name; //float *data; //"vertex" and "normal" and "texture" + int coord_pack_size; + +#if SPE_CREATE_POLYGON + + TrianglePackPtr tri_pack; + float *sg_matrix; + float *matrix; + float *real_matrix; + texture_list *texture_info; + +#else + + float *coord_pack; //coord_xyz(4*3*size), coord_tex(4*3*size), normal(4*3*size), float *coord_xyz; // vertex coordinate array float *coord_tex; // texture coordinate array float *normal; // normal vector array + float matrix[16]; + float real_matrix[16]; + texture_list texture_info; + +#endif + float xyz[4]; // position float angle[4]; // angle float c_xyz[4]; // center of rotation - float matrix[16]; - float real_matrix[16]; float *anim; int texture_id; //texture id number - struct texture_list texture_info; SDL_Surface* texture_image; diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/polygon_pack.h --- a/Renderer/Engine/polygon_pack.h Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/polygon_pack.h Fri Jun 18 01:30:06 2010 +0900 @@ -27,25 +27,26 @@ } TriangleTexInfo, *TriangleTexInfoPtr; // 16 typedef struct TrianglePack { - TriTexInfo tex_info; - VertexPack ver1; - VertexPack ver2; - VertexPack ver3; - NormalPack normal1; - NormalPack normal2; - NormalPack normal3; -} TrianglePack, *TrianglePackPtr; + TriTexInfo tex_info; // 16 + VertexPack ver1; // 20 + VertexPack ver2; // 20 + VertexPack ver3; // 20 + NormalPack normal1; // 12 + NormalPack normal2; // 12 + NormalPack normal3; // 12 +} TrianglePack, *TrianglePackPtr; // 112 (16 * 7) typedef struct PolygonPack { + + TrianglePack tri[MAX_SIZE_TRIANGLE]; + struct POLYGON_info { int size; int light_pos[3]; int light_rgb[3]; }info; - TrianglePack tri[MAX_SIZE_TRIANGLE]; - PolygonPack* next; void init(void) { @@ -65,7 +66,7 @@ } this->init(); } -} PolygonPack, *PolygonPackPtr; // 4*7 + 76*128 + 4 = 9760 +} PolygonPack, *PolygonPackPtr; // 4*7 + 76*128 + 4 = 9760 なんやかんやで 14368 みたい。 typedef struct PolygonPackList { int size; diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/spe/CreatePolygon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/spe/CreatePolygon.h Fri Jun 18 01:30:06 2010 +0900 @@ -0,0 +1,9 @@ +#ifndef INCLUDED_CREATE_SPAN +#define INCLUDED_CREATE_SPAN + +#include "SchedTask.h" +#include "polygon_pack.h" +#include "SpanPack.h" +#include "texture.h" + +#endif diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/spe/DrawSpan.cc --- a/Renderer/Engine/spe/DrawSpan.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/spe/DrawSpan.cc Fri Jun 18 01:30:06 2010 +0900 @@ -2,7 +2,7 @@ #include #include "DrawSpan.h" #include "polygon_pack.h" -#include "texture.h" +#include "task_texture.h" #include "viewer_types.h" #include "Func.h" #include "sys.h" diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/spe/Load_Texture.cc --- a/Renderer/Engine/spe/Load_Texture.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/spe/Load_Texture.cc Fri Jun 18 01:30:06 2010 +0900 @@ -4,7 +4,7 @@ #include #include #include "Load_Texture.h" -#include "texture.h" +#include "task_texture.h" #include "Func.h" SchedDefineTask(LoadTexture); diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/spe/Makefile --- a/Renderer/Engine/spe/Makefile Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/spe/Makefile Fri Jun 18 01:30:06 2010 +0900 @@ -5,7 +5,7 @@ TOP = ../$(CERIUM) SRCS_TMP = $(wildcard *.cc) -SRCS_EXCLUDE = CreatePolygon.cc +#SRCS_EXCLUDE = CreatePolygon.cc SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) OBJS = $(SRCS:.cc=.o) diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/spe/spe-main.cc --- a/Renderer/Engine/spe/spe-main.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/spe/spe-main.cc Fri Jun 18 01:30:06 2010 +0900 @@ -14,6 +14,7 @@ SchedExternTask(ChainInit); SchedExternTask(CreateSpan); +SchedExternTask(CreatePolygon); //SchedExternTask(CreatePolygonFromSceneGraph); SchedExternTask(ShowTime); @@ -40,6 +41,7 @@ SchedRegister( DrawBack); SchedRegister( CreateSpan); + SchedRegister( CreatePolygon); //SchedRegister( CreatePolygonFromSceneGraph); SchedRegister( ShowTime); diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/task/CreatePolygonFromSceneGraph.cc --- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Fri Jun 18 01:30:06 2010 +0900 @@ -73,6 +73,9 @@ static int run(SchedTask *smanager, void *rbuf, void *wbuf) { + +#if !SPE_CREATE_POLYGON + float xyz1[4], xyz2[4], xyz3[4]; float normal1[4],normal2[4],normal3[4]; @@ -245,4 +248,7 @@ free(send_pp); return 0; + +#endif + } diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/task/DrawSpan.cc --- a/Renderer/Engine/task/DrawSpan.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/task/DrawSpan.cc Fri Jun 18 01:30:06 2010 +0900 @@ -2,7 +2,7 @@ #include #include "DrawSpan.h" #include "polygon_pack.h" -#include "texture.h" +#include "task_texture.h" #include "viewer_types.h" #include "Func.h" #include "sys.h" diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/task/Load_Texture.cc --- a/Renderer/Engine/task/Load_Texture.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/task/Load_Texture.cc Fri Jun 18 01:30:06 2010 +0900 @@ -1,7 +1,7 @@ #include #include #include "Load_Texture.h" -#include "texture.h" +#include "task_texture.h" #include "Func.h" #include "Tapestry.h" diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/task/create_sgp.cc --- a/Renderer/Engine/task/create_sgp.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/task/create_sgp.cc Fri Jun 18 01:30:06 2010 +0900 @@ -17,6 +17,9 @@ //create_sgp(Polygon *sg, SceneGraphPack *sgp) run(SchedTask *smanager, void *rbuf, void *wbuf) { + +#if !SPE_CREATE_POLYGON + //SceneGraph *sg = (SceneGraph*)smanager->get_input(rbuf, 0); SceneGraph *sg = (SceneGraph*)smanager->get_param(0); SceneGraphPack *sgp = (SceneGraphPack*)smanager->get_param(0); @@ -125,5 +128,7 @@ } sgp->info.size = curNumber; +#endif + return 0; } diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/task/task_init.cc --- a/Renderer/Engine/task/task_init.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/task/task_init.cc Fri Jun 18 01:30:06 2010 +0900 @@ -6,6 +6,7 @@ SchedExternTask(Create_SGP); SchedExternTask(Update_SGP); +SchedExternTask(CreatePolygon); SchedExternTask(CreatePolygonFromSceneGraph); SchedExternTask(CreateSpan); @@ -46,6 +47,7 @@ SchedRegister( Create_SGP); SchedRegister( Update_SGP); SchedRegister(CreatePolygonFromSceneGraph); + SchedRegister(CreatePolygon); SchedRegister( CreateSpan); SchedRegister( DrawSpan); diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/texture.h --- a/Renderer/Engine/texture.h Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/texture.h Fri Jun 18 01:30:06 2010 +0900 @@ -7,11 +7,14 @@ GLuint SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord) #endif -struct texture_list { - int t_w, t_h; - Uint32 *pixels_orig; - Uint32 *pixels; +typedef struct texture_list { + int t_w; + int t_h; + uint32 *pixels_orig; + uint32 *pixels; int scale_max; -}; + int pad[3]; // 12 + +} texture_list, *texture_list_ptr ; // 20 + pad(12) = 32 #endif diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/viewer.cc --- a/Renderer/Engine/viewer.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/viewer.cc Fri Jun 18 01:30:06 2010 +0900 @@ -437,8 +437,99 @@ } void +Viewer::create_pp_task(SceneGraphPtr sg, PolygonPackPtr pp_cur, HTaskPtr create_pp_wait, + int &pp_index, int &sg_index, int tri_num) +{ + + HTaskPtr create_pp = manager->create_task(CreatePolygon); + create_pp->set_inData(0, &sg->tri_pack[sg_index], sizeof(TrianglePack)*tri_num); + create_pp->set_inData(1, sg->texture_info, sizeof(texture_list)); + create_pp->set_inData(2, sg->sg_matrix, sizeof(float)*32); //わーい、マジックナンバー + create_pp->set_outData(0, &pp_cur->tri[pp_index], sizeof(TrianglePack)*tri_num); + create_pp->set_param(0, (memaddr)tri_num); + //create_pp->set_cpu(SPE_ANY); + create_pp_wait->wait_for(create_pp); + create_pp->spawn(); + + pp_index += tri_num; + sg_index += tri_num; +} + + +void Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot) { + +#if SPE_CREATE_POLYGON + + SceneGraphPtr sg = sgroot->getDrawSceneGraph(); + PolygonPackPtr pp_cur = ppack; + HTaskPtr create_pp_wait = manager->create_task(Dummy); + int pp_index = 0; + + while (sg) { + + if (sg->flag_drawable) { + + int sum_size = sg->size; + int tri_cur_num = MAX_SIZE_TRIANGLE; + int sg_index = 0; + + while (sum_size) { + + tri_cur_num -= sg->size/3; + + if (tri_cur_num < 0) { + + tri_cur_num = MAX_SIZE_TRIANGLE; + create_pp_task(sg, pp_cur, create_pp_wait, + pp_index, sg_index, tri_cur_num); + + PolygonPackPtr next = (PolygonPackPtr)manager->allocate(sizeof(PolygonPack)); + + pp_cur->next = next; + pp_cur = next; + pp_index = 0; + + } else { + + create_pp_task(sg, pp_cur, create_pp_wait, + pp_index, sg_index, tri_cur_num); + + } + + sum_size -= tri_cur_num*3; + + } + + + } + + + + if (sg->children != NULL) { + sg = sg->children; + } else if (sg->brother != NULL) { + sg = sg->brother; + } else { + while (sg) { + if (sg->brother != NULL) { + sg = sg->brother; + break; + } else { + if (sg->parent == NULL) { + sg = NULL; + break; + } else { + sg = sg->parent; + } + } + } + } + } + +#else + HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); // SceneGraph(木構造) -> PolygonPack @@ -487,8 +578,10 @@ task_create_sp->spawn(); } + task_create_pp->spawn(); - task_create_pp->spawn(); +#endif + } HTaskPtr @@ -568,7 +661,7 @@ int rangey = (starty + split_screen_h - 1 > this->height) ? this->height - starty + 1 : split_screen_h; -#if 1 +#if 0 if(spack->info.size > 0) { diff -r e39f320c4411 -r 649e4cb84683 Renderer/Engine/viewer.h --- a/Renderer/Engine/viewer.h Thu Jun 17 04:46:25 2010 +0900 +++ b/Renderer/Engine/viewer.h Fri Jun 18 01:30:06 2010 +0900 @@ -69,6 +69,8 @@ void run_collision(); void rendering(HTaskPtr task_next); void common_draw(HTaskPtr task_next); + void create_pp_task(SceneGraphPtr sg, PolygonPackPtr pp_cur, HTaskPtr create_pp_wait, + int &pp_index, int &sg_index, int tri_num); void common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot); void spe_rendering(HTaskPtr task_next); diff -r e39f320c4411 -r 649e4cb84683 TaskManager/Cell/CellTaskManagerImpl.cc --- a/TaskManager/Cell/CellTaskManagerImpl.cc Thu Jun 17 04:46:25 2010 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Fri Jun 18 01:30:06 2010 +0900 @@ -172,6 +172,9 @@ TaskListPtr list = (TaskListPtr)data; check_task_list_finish(schedTaskManager, list, waitTaskQueue); #else + + printf("hoge\n"); + // 終了したタスク(PPEにあるのでアドレス) HTaskPtr task = (HTaskPtr)data; task->post_func(schedTaskManager, task->post_arg1, task->post_arg2); diff -r e39f320c4411 -r 649e4cb84683 TaskManager/Makefile.def --- a/TaskManager/Makefile.def Thu Jun 17 04:46:25 2010 +0900 +++ b/TaskManager/Makefile.def Fri Jun 18 01:30:06 2010 +0900 @@ -29,7 +29,7 @@ ABIBIT = 32 -# OPT = -O9 +#OPT = -O9 OPT = -g -DTASK_LIST_MAIL CC = g++