Mercurial > hg > Members > kono > Cerium
changeset 615:f7d78b3c1106
First addOutput rendering try failed.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 14 Nov 2009 18:57:54 +0900 |
parents | 4e44147d78ee |
children | f21603a335aa |
files | Renderer/Engine/task/DrawSpan.cc Renderer/Engine/task/DrawSpan.h Renderer/Engine/task/task_init.cc Renderer/Engine/viewer.cc TaskManager/ChangeLog TaskManager/kernel/ppe/Task.cc TaskManager/kernel/ppe/Task.h |
diffstat | 7 files changed, 72 insertions(+), 121 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/task/DrawSpan.cc Sat Nov 14 18:21:14 2009 +0900 +++ b/Renderer/Engine/task/DrawSpan.cc Sat Nov 14 18:57:54 2009 +0900 @@ -7,27 +7,45 @@ #include "Func.h" #include "sys.h" #include "global_alloc.h" +#include "SchedTask.h" +#include "Tapestry.h" +#include "SpanPack.h" + SchedDefineTask(DrawSpan); -SchedDefineTask1(DrawSpanEnd,draw_span_end); #define TEX_LOAD1 0 #define TEX_LOAD2 1 #define SPAN_PACK_LOAD 2 #define FB_STORE 3 -static int -draw_span_end(SchedTask *s, void *rbuf, void *wbuf) -{ - Gptr g = (Gptr)s->get_param(0); - s->dma_wait(FB_STORE); +typedef struct { + int **linebuf; + float *zRow; + TileListPtr tileList; + int doneWrite; +} G, *Gptr; - if (!g->doneWrite) { - free(g->linebuf); - } - free(g); - return 0; -} +static int** linebuf_init(SchedTask *smanager, int width, int height, int rgb); +static float* zRow_init(SchedTask *smanager, int width, int height); +// static TilePtr set_rgb(memaddr addr, int wait_tag); +// static void set_rgbs(memaddr addr, uint32 *max_addr, int wait_tag); +static uint32 get_rgb(int tx, int ty, TilePtr tile); +// static TilePtr isAvailableTile(memaddr addr); +static memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top); +static int getTexBlock(int tx, int ty, int twidth); +static void updateBuffer(Gptr g, float zpos, int rangex, int x, int y, + int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z, TilePtr tile); + + +// static void reboot(SpanPackPtr spack, int cur_span_x); + +static int drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); +//static void drawDot2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); +static int drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); +// static void drawLine2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); +static int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z); + /** * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する @@ -95,16 +113,17 @@ * @param rgb Initial value of RGB at Buffer * @return Buffer */ -static int* +static int ** linebuf_init(SchedTask *smanager, int width, int height, int rgb) { - int *buf = (int*)smanager->allocate(sizeof(int)*width*height); - - for (int i = 0; i < width*height; i++) { - buf[i] = rgb; + int **linebuf = (int**)smanager->allocate(height*sizeof(int*)); + for(int h = 0;h<height;h++) { + int *buf = linebuf[height] = (int*)smanager->get_output(height); + for (int i = 0; i < width*height; i++) { + buf[i] = rgb; + } } - - return buf; + return linebuf; } /** @@ -136,18 +155,6 @@ } -static void -writebuffer(SchedTask *smanager, Gptr g, unsigned int display, - int buf_width, int height, int screen_width) -{ - for (int i = 0; i < height; i++) { - smanager->dma_store(&g->linebuf[i*buf_width], - display + (sizeof(int)*screen_width*i), - sizeof(int)*buf_width, FB_STORE); - } - - g->doneWrite = 1; -} /** * zRow と Linebuf を更新する @@ -174,7 +181,8 @@ color = infinity_light_calc(color,normal_x,normal_y,normal_z); g->zRow[x + (rangex*y)] = zpos*flag + g->zRow[x + (rangex*y)]*(1-flag); - g->linebuf[x + (rangex*y)] = color*flag + g->linebuf[x + (rangex*y)]*(1-flag); + int *point = &g->linebuf[y][x] ; + *point = color*flag + *point *(1-flag); } @@ -392,7 +400,7 @@ &drawDot1, &drawLine1 }; - uint32 display = smanager->get_param(0); + // uint32 display = smanager->get_param(0); int screen_width = smanager->get_param(1); int rangex_start = smanager->get_param(2); int rangex_end = smanager->get_param(3); @@ -405,11 +413,8 @@ g->tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST); g->zRow = zRow_init(smanager, rangex, rangey); - //linebuf = linebuf_init(rangex, rangey, 0x00ffffff); g->linebuf = linebuf_init(smanager, rangex, rangey, 0); - g->doneWrite = 0; - int tl_tag[2] = {TEX_LOAD1, TEX_LOAD2}; int tl_tag_flg1 = 0; int tl_tag_flg2 = 1; @@ -466,12 +471,10 @@ next_spack = tmp_spack; } while (spack); - writebuffer(smanager, g, display, rangex, rangey, screen_width); - // linebuf は、writebuffer() の dma_store を wait する - // DrawSpan::~DrawSpan() 内で free する。 - //free(linebuf); free(g->zRow); + free(g->linebuf); + free(g); //FINISH: /**
--- a/Renderer/Engine/task/DrawSpan.h Sat Nov 14 18:21:14 2009 +0900 +++ b/Renderer/Engine/task/DrawSpan.h Sat Nov 14 18:57:54 2009 +0900 @@ -1,45 +1,5 @@ #ifndef INCLUDED_TASK_DRAW_SPAN #define INCLUDED_TASK_DRAW_SPAN -#include "SchedTask.h" -#include "Tapestry.h" -#include "SpanPack.h" - -typedef struct { - int *linebuf; - float *zRow; - TileListPtr tileList; - int doneWrite; -} G, *Gptr; - -static int* linebuf_init(SchedTask *smanager, int width, int height, int rgb); -static float* zRow_init(SchedTask *smanager, int width, int height); -// static TilePtr set_rgb(memaddr addr, int wait_tag); -// static void set_rgbs(memaddr addr, uint32 *max_addr, int wait_tag); -static uint32 get_rgb(int tx, int ty, TilePtr tile); -// static TilePtr isAvailableTile(memaddr addr); -static memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top); -static int getTexBlock(int tx, int ty, int twidth); -static void writebuffer(SchedTask *smanager, Gptr g, unsigned int display, - int width, int height, int screen_width); -static void updateBuffer(Gptr g, float zpos, int rangex, int x, int y, - int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z, TilePtr tile); - - -// static void reboot(SpanPackPtr spack, int cur_span_x); - -static int drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); -//static void drawDot2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); -static int drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); -// static void drawLine2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag); -static int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z); - -typedef struct { - uint32 display; - int screen_width; - int rangex_start; - int rangex_end; - int rangey; -} DrawSpanArg, *DrawSpanArgPtr; #endif
--- a/Renderer/Engine/task/task_init.cc Sat Nov 14 18:21:14 2009 +0900 +++ b/Renderer/Engine/task/task_init.cc Sat Nov 14 18:57:54 2009 +0900 @@ -8,7 +8,6 @@ SchedExternTask(CreateSpan); SchedExternTask(DrawSpan); -SchedExternTask(DrawSpanEnd); SchedExternTask(DrawSpanRenew); SchedExternTask(DrawBack); @@ -36,35 +35,6 @@ void task_initialize() { -#if 0 - SchedRegister(TASK_CREATE_SGP, Create_SGP); - SchedRegister(TASK_UPDATE_SGP, Update_SGP); - SchedRegister(TASK_CREATE_PP, CreatePolygon); - SchedRegister(TASK_CREATE_PP2, CreatePolygonFromSceneGraph); - SchedRegister(TASK_CREATE_SPAN, CreateSpan); - - SchedRegister(TASK_DRAW_SPAN, DrawSpan); - SchedRegister(TASK_DRAW_SPAN_END, DrawSpanEnd); -// SchedRegister(TASK_DRAW_SPAN2, DrawSpanRenew); - SchedRegister(TASK_DRAW_BACK, DrawBack); - - SchedRegister(TASK_INIT_TEXTURE, LoadTexture); - SchedRegister(TASK_SET_TEXTURE, SetTexture); - - SchedRegister(TASK_MOVE, Move); - SchedRegister(TASK_DRAW, Draw); - - SchedRegister(TASK_DUMMY, Dummy); - - SchedRegister(UPDATE_KEY, UpdateKey); - SchedRegister(INIT_KEY_TASK, InitKey); - - SchedRegister(SHOW_TIME, ShowTime); - SchedRegister(TASK_SWITCH, Switch); - - // usr - SchedRegister(CHAIN_MOVE, ChainMove); -#else SchedRegister( Create_SGP); SchedRegister( Update_SGP); SchedRegister( CreatePolygon); @@ -72,8 +42,6 @@ SchedRegister( CreateSpan); SchedRegister( DrawSpan); - SchedRegister( DrawSpanEnd); -// SchedRegister(DrawSpanRenew); SchedRegister( DrawBack); SchedRegister( LoadTexture); @@ -92,6 +60,5 @@ // usr SchedRegister( ChainMove); -#endif }
--- a/Renderer/Engine/viewer.cc Sat Nov 14 18:21:14 2009 +0900 +++ b/Renderer/Engine/viewer.cc Sat Nov 14 18:57:54 2009 +0900 @@ -521,9 +521,16 @@ task_draw = manager->create_task(DrawSpan); task_draw->add_inData(spack, sizeof(SpanPack)); - task_draw->add_param( + task_draw->add_param(0, (memaddr)&pixels[(startx-1) + this->width*(starty-1)]); - task_draw->add_param(this->width); + task_draw->add_param(1,this->width); + + int height = rangey; + for (int i = 0; i < height; i++) { + task_draw->add_outData( + &pixels[(startx-1) + this->width*(starty-1)], + this->width*sizeof(int)); + } } else { // 7.7.3 SL1 Data Cache Range Set to Zero コマンド // を使って、DMAでclearするべき... ということは、 @@ -533,9 +540,9 @@ break; } - task_draw->add_param(startx); - task_draw->add_param(endx); - task_draw->add_param(rangey); + task_draw->add_param(2,startx); + task_draw->add_param(3,endx); + task_draw->add_param(4,rangey); task_draw->set_cpu(SPE_ANY); task_next->wait_for(task_draw); task_draw->spawn();
--- a/TaskManager/ChangeLog Sat Nov 14 18:21:14 2009 +0900 +++ b/TaskManager/ChangeLog Sat Nov 14 18:57:54 2009 +0900 @@ -13,6 +13,8 @@ せっかく、renew task を外したのに、HD crash で失ってしまいました。 + add_param が順序を持っているのは見づらい。数字で指定する方が合理的。 + 2009-10-11 Shinji KONO <kono@ie.u-ryukyu.ac.jp> 単純な、rbuf, wbuf + write return size の task のAPI
--- a/TaskManager/kernel/ppe/Task.cc Sat Nov 14 18:21:14 2009 +0900 +++ b/TaskManager/kernel/ppe/Task.cc Sat Nov 14 18:57:54 2009 +0900 @@ -32,10 +32,12 @@ * エラーの時に -1 を返す、ってことするよりは * perror みたいにしたほうがわかりやすいかな。 * - * 現在は 3 個まで。 - * 本当は、3個以上にすると task->param[] には アドレスが入り + * 現在は MAX_PARAMS 個まで。 + * 本当は、MAX_PARAMS個以上にすると task->param[] には アドレスが入り * そのアドレスは メインメモリでアロケートされた int の集合。 */ + +// こちらのAPIは、受け側と出力側での対応を良く見れない。廃止の方向。 int Task::add_param(memaddr _param) { @@ -45,6 +47,15 @@ return 0; } +int +Task::add_param(int index, memaddr _param) +{ + if (index >= MAX_PARAMS) return -1; + + this->param[index] = _param; + return 0; +} + /* * エラーの時に -1 を返す、ってことするよりは * perror みたいにしたほうがわかりやすいかな。
--- a/TaskManager/kernel/ppe/Task.h Sat Nov 14 18:21:14 2009 +0900 +++ b/TaskManager/kernel/ppe/Task.h Sat Nov 14 18:57:54 2009 +0900 @@ -26,7 +26,8 @@ int add_inData_t(memaddr addr, int size); // unsigned int ではなく 64bit int add_outData_t(memaddr addr, int size); // unsigned int ではなく 64bit int add_data(ListData &list, memaddr addr, int size); - int add_param(memaddr param); + int add_param(memaddr param); // obsolete. do not use. + int add_param(int index, memaddr param); #define add_inData(addr, size) \ add_inData_t((memaddr)(addr), (size));