Mercurial > hg > Game > Cerium
changeset 751:1666dba6f6d9 draft
rendering, move_coll parallel running
author | hiroki@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 26 Jan 2010 16:18:24 +0900 |
parents | fbcd4ed51549 |
children | 5651114dcfeb |
files | Renderer/Engine/RenderingTasks.h Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/SgChange.cc Renderer/Engine/SgChange.h Renderer/Engine/spe/texture.h Renderer/Engine/task/Draw.cc Renderer/Engine/task/task_init.cc Renderer/Engine/task/texture.h |
diffstat | 8 files changed, 160 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/RenderingTasks.h Mon Jan 25 19:25:40 2010 +0900 +++ b/Renderer/Engine/RenderingTasks.h Tue Jan 26 16:18:24 2010 +0900 @@ -18,6 +18,7 @@ SetTexture, Move, + RunMove, Draw, // Dummy,
--- a/Renderer/Engine/SceneGraphRoot.cc Mon Jan 25 19:25:40 2010 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Tue Jan 26 16:18:24 2010 +0900 @@ -431,40 +431,39 @@ /*removeのflagをもとにtreeを形成*/ while (t) { - SceneGraphPtr c = NULL; - if (!t->isRemoved()) { - c = t->clone(); - addNext(c); - cur_parent->addChild(c); - c->frame = t->frame; - /*親の回転、座標から、子の回転、座標を算出*/ - get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); + SceneGraphPtr c = NULL; + if (!t->isRemoved()) { + c = t->clone(); + addNext(c); + cur_parent->addChild(c); + c->frame = t->frame; + /*親の回転、座標から、子の回転、座標を算出*/ + get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix); /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/ - get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix); - } - - if (t->children != NULL && c != NULL) { - cur_parent = c; - t = t->children; - } else if (t->brother != NULL) { - t = t->brother; + get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix); + } + + if (t->children != NULL && c != NULL) { + cur_parent = c; + t = t->children; + } else if (t->brother != NULL) { + t = t->brother; + } else { + while (t) { + if (t->brother != NULL) { + t = t->brother; + break; } else { - while (t) { - if (t->brother != NULL) { - t = t->brother; - break; - } else { - if (t->parent == NULL) { - t = NULL; - break; - } else { + if (t->parent == NULL) { + t = NULL; + break; + } else { cur_parent = cur_parent->parent; t = t->parent; - - } - } - } + } } + } + } }
--- a/Renderer/Engine/SgChange.cc Mon Jan 25 19:25:40 2010 +0900 +++ b/Renderer/Engine/SgChange.cc Tue Jan 26 16:18:24 2010 +0900 @@ -15,6 +15,7 @@ #include "global_alloc.h" static void post2runLoop(SchedTask *s, void *viewer, void *s1); +static void post2run(SchedTask *s, void *viewer, void *s1); static void post2runDraw(SchedTask *s, void *viewer, void *s1); static void post2runMove(SchedTask *s, void *viewer, void *s1); static void post2rendering(SchedTask *s, void *viewer, void *s1); @@ -55,14 +56,13 @@ { HTaskPtr task_next = initLoop(); - task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL) + //task_next->set_post(&post2runLoop, (void *)this, 0); + task_next->set_post(&post2run, (void *)this, 0); task_next->spawn(); } - - static void -post2runLoop(SchedTask *s, void *sgchange_, void *arg) +post2run(SchedTask *s, void *sgchange_, void *arg) { SgChange *sgchange = (SgChange*)sgchange_; HTaskPtr task_next = sgchange->manager->create_task(Dummy); @@ -71,18 +71,32 @@ psx_sync_n(); } +static void +post2runLoop(SchedTask *s, void *sgchange_, void *arg) +{ + SgChange *sgchange = (SgChange*)sgchange_; + HTaskPtr task_next = sgchange->manager->create_task(Dummy); + sgchange->pass_draw_tree(); + sgchange->run_loop(task_next); + + psx_sync_n(); +} + void -SgChange::exchange_sgroot() +SgChange::pass_draw_tree() { + /* SceneGraphRoot *tmp; tmp = sgroot_A; sgroot_A = sgroot_B; sgroot_B = tmp; + */ + sgroot_B->sg_draw_tree = sgroot_A->sg_exec_tree; } void SgChange::run_loop(HTaskPtr task_next) -{ +{ viewer->dev->clear_screen(); bool quit_flg; @@ -99,35 +113,43 @@ spackList[i-1].reinit(i*split_screen_h); } - //exchange_sgroot(); - + /* sgroot_A->updateControllerState(); sgroot_A->allExecute(viewer->width, viewer->height); viewer->light_xyz_stock = sgroot_A->getLightVector(); + */ HTaskPtr loop_task = manager->create_task(Dummy); loop_task->set_post(post2runLoop, (void *)this, 0); HTaskPtr draw_task = manager->create_task(Dummy); draw_task->set_post(post2rendering, (void *)this, 0); - + +#if 0 HTaskPtr move_task = manager->create_task(Dummy); move_task->set_post(post2runMove, (void *)this, 0); +#else + HTaskPtr move_task = manager->create_task(RunMove); + move_task->set_param(0, (memaddr)this); + move_task->set_param(1, viewer->width); + move_task->set_param(2, viewer->height); +#endif HTaskPtr dummy_task = manager->create_task(Dummy); draw_finish = dummy_task; + loop_task->wait_for(draw_finish); loop_task->wait_for(move_task); + draw_task->spawn(); move_task->spawn(); - draw_task->spawn(); loop_task->spawn(); } static void post2runMove(SchedTask *s, void *viewer_, void *arg) -{ +{ SgChange *viewer = (SgChange *)viewer_; HTaskPtr task_next = viewer->manager->create_task(Dummy); viewer->run_move(task_next); @@ -135,9 +157,10 @@ void SgChange::run_move(HTaskPtr task_next) -{ +{ sgroot_A->updateControllerState(); - sgroot_A->allExecute(viewer->width, viewer->height); + sgroot_A->allExecute(viewer->width, viewer->height); + viewer->light_xyz_stock = sgroot_A->getLightVector(); } static void @@ -152,7 +175,7 @@ void SgChange::rendering(HTaskPtr task_next) { - viewer->common_rendering(task_next, sgroot_A); + viewer->common_rendering(task_next, sgroot_B); task_next->set_post(post2runDraw, (void*)this, 0); task_next->spawn();
--- a/Renderer/Engine/SgChange.h Mon Jan 25 19:25:40 2010 +0900 +++ b/Renderer/Engine/SgChange.h Tue Jan 26 16:18:24 2010 +0900 @@ -41,7 +41,7 @@ void rendering(HTaskPtr task_next); HTaskPtr initLoop(); - virtual void exchange_sgroot(); + void pass_draw_tree(); void mainLoop(); void createFromXMLfile(const char *file)
--- a/Renderer/Engine/spe/texture.h Mon Jan 25 19:25:40 2010 +0900 +++ b/Renderer/Engine/spe/texture.h Tue Jan 26 16:18:24 2010 +0900 @@ -1,2 +1,2 @@ #define MAX_LOAD_SIZE 16384 -#define TEXTURE2_ID 13 +#define TEXTURE_ID 13
--- a/Renderer/Engine/task/Draw.cc Mon Jan 25 19:25:40 2010 +0900 +++ b/Renderer/Engine/task/Draw.cc Tue Jan 26 16:18:24 2010 +0900 @@ -1,13 +1,97 @@ -#include <stdlib.h> -#include <string.h> -#include "Draw.h" -#include "viewer_types.h" +//#include "RunDraw.h" +#include "SchedTask.h" SchedDefineTask(Draw); static int -run(SchedTask *s,void *rbuf, void *wbuf) +run(SchedTask *smanager, void *rbuf, void *wbuf) { +#if 0 + PolygonPack *pp = (PolygonPack*)smanager->get_input(rbuf, 0); + PolygonPack *next_pp = + (PolygonPack*)smanager->allocate(sizeof(PolygonPack)); + PolygonPack *free_pp = next_pp; + PolygonPack *tmp_pp; + + TrianglePackPtr triPack; + VertexPackPtr vMin, vMid, vMax; + VertexPackPtr vMid10 + = (VertexPackPtr)smanager->allocate(sizeof(VertexPack)); + NormalPackPtr normal1,normal2, normal3; + SpanPackPtr *spackList = (SpanPackPtr*)smanager->get_input(rbuf, 1); + spack = (SpanPackPtr)smanager->get_input(rbuf, 2); + send_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); + prev_index = (long)smanager->get_param(0); + + // spack と send_spack は swap しながら DMA を繰り返すので + // 自分で allocate した send_spack を覚えてないといけない + SpanPackPtr free_spack = send_spack; + + int charge_y_top = (long)smanager->get_param(1); + int charge_y_end = (long)smanager->get_param(2); + + do { + if (pp->next != NULL) { + smanager->dma_load(next_pp, (memaddr)pp->next, + sizeof(PolygonPack), POLYGON_PACK_LOAD); + } else { + next_pp = NULL; + } + + for (int i = 0; i < pp->info.size; i++) { + triPack = &pp->tri[i]; + + TriangleTexInfoPtr tri_tex_info = &triPack->tex_info; + + make_vertex(triPack, &vMin, &vMid, &vMax, &normal1, &normal2, &normal3); + make_vMid10(vMid10, vMin, vMid, vMax); + + /** + * ポリゴンを、x軸に水平に分割して二つの三角形を作り、 + * それぞれから Span を求める + * + * vMax + * |\ + * | \ + * | \ + * | \ + * vMid10 ------ vMid + * | / + * | / + * | / + * |/ + * vMin + * + * (vMax, vMid, vMin) という triangle を + * (vMax, vMid, vMid10) (vMin, vMid, vMid10) という + * 二つの Triangle に分けている + */ + half_triangle(smanager, spackList, charge_y_top, charge_y_end, + tri_tex_info, vMin, vMid, vMid10, + normal1,normal2,normal3, + (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y); + half_triangle(smanager, spackList, charge_y_top, charge_y_end, + tri_tex_info, vMax, vMid, vMid10, + normal1,normal2,normal3, + (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y); + } + + smanager->dma_wait(POLYGON_PACK_LOAD); + + tmp_pp = pp; + pp = next_pp; + next_pp = tmp_pp; + } while (pp); + + smanager->dma_wait(SPAN_PACK_STORE); + smanager->dma_store(spack, (memaddr)spackList[prev_index], + sizeof(SpanPack), SPAN_PACK_STORE); + smanager->dma_wait(SPAN_PACK_STORE); + + free(free_pp); + free(free_spack); + free(vMid10); return 0; +#endif }
--- a/Renderer/Engine/task/task_init.cc Mon Jan 25 19:25:40 2010 +0900 +++ b/Renderer/Engine/task/task_init.cc Tue Jan 26 16:18:24 2010 +0900 @@ -28,6 +28,7 @@ SchedExternTask(InitKey); SchedExternTask(Switch); +SchedExternTask(RunMove); /** @@ -62,5 +63,6 @@ // usr SchedRegister( ChainMove); + SchedRegister( RunMove); }