# HG changeset patch # User Shinji KONO # Date 1258218333 -32400 # Node ID 55ed910d13c21b7cc81228ecb0cf2480f49bd947 # Parent 0decff4e867b770000026126a95c75c3dc0b5a6d# Parent 4cfcac2367d54f4b5c92efd046dc973f564d6136 merge diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/ChangeLog --- a/Renderer/Engine/ChangeLog Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/ChangeLog Sun Nov 15 02:05:33 2009 +0900 @@ -1,9 +1,14 @@ +2009-11-14 Shinji Kono + +DrawSpan の dma_write を追放。なんでこんなになっていたかは謎。 + +これで、renew Task を落とせます。 + 2009-08-06 Shinji Kono DrawSpan の reboot/ TASK_DRAW_SPAN2 は、使ってないのね。 - 2009-03-29 Wataru MIYAGUNI * Makefile diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/Func.h --- a/Renderer/Engine/Func.h Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/Func.h Sun Nov 15 02:05:33 2009 +0900 @@ -1,38 +1,38 @@ enum { + INIT, SDL_INIT, FINISH, - VIEWER_RUN_INIT, - VIEWER_RUN_LOOP, - VIEWER_RUN_DRAW, - VIEWER_RUN_FINISH, + + Create_SGP, + Update_SGP, + CreatePolygon, + CreatePolygonFromSceneGraph, + CreateSpan, + + DrawSpan, + DrawBack, + + LoadTexture, + SetTexture, - TASK_INIT_TEXTURE, - TASK_CREATE_SGP, - TASK_UPDATE_SGP, - TASK_CREATE_PP, - TASK_CREATE_PP2, - TASK_CREATE_SPAN, - TASK_CS_START, - TASK_CS_RUN, - TASK_DRAW_SPAN, - TASK_DRAW_SPAN_END, - TASK_DRAW_BACK, - TASK_SET_TEXTURE, - TASK_MOVE, - TASK_DRAW, - TASK_DUMMY, + Move, + Draw, + + Dummy, - CHAINCAL_TASK, - CHAININIT_TASK, + UpdateKey, + InitKey, + + ShowTime, + Switch, + + ChainMove, + + RUN_FINISH, - TASK_SWITCH, - SHOW_TIME, - UPDATE_KEY, - INIT_KEY_TASK, - CHAIN_MOVE, }; #define DATA_ID 0 diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/Makefile.macosx --- a/Renderer/Engine/Makefile.macosx Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/Makefile.macosx Sun Nov 15 02:05:33 2009 +0900 @@ -48,7 +48,6 @@ clean: rm -f $(TARGET) $(OBJS) $(TASK_OBJS) - rm -f *~ \#* - rm -f SGList.h SGList.cc + rm -f *~ \#* *.o -include depend.inc diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/lindaapi.cc --- a/Renderer/Engine/lindaapi.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/lindaapi.cc Sun Nov 15 02:05:33 2009 +0900 @@ -156,7 +156,7 @@ 失敗すると -1 を返す。 /-------------------------------------------------------------------*/ int -open_linda(char * hostname, int port){ +open_linda(const char * hostname, int port){ int fd; struct hostent *hoste; struct sockaddr_in serv_addr; @@ -213,7 +213,7 @@ } int -open_linda_java(char * hostname, int port){ +open_linda_java(const char * hostname, int port){ int fd; struct hostent *hoste; struct sockaddr_in serv_addr; diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/lindaapi.h --- a/Renderer/Engine/lindaapi.h Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/lindaapi.h Sun Nov 15 02:05:33 2009 +0900 @@ -62,8 +62,8 @@ ----------------------------------------------------------------------*/ extern void init_linda(void); -extern int open_linda(char *hostname, int port); -extern int open_linda_java(char *hostname, int port); +extern int open_linda(const char *hostname, int port); +extern int open_linda_java(const char *hostname, int port); extern int close_linda(int tspace_id); extern void psx_free(void*); diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/show_time.cc --- a/Renderer/Engine/show_time.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/show_time.cc Sun Nov 15 02:05:33 2009 +0900 @@ -10,19 +10,19 @@ HTaskPtr pre_show; */ /* - show = manager->create_task(SHOW_TIME); + show = manager->create_task(ShowTime); show->set_cpu(SPE_0); show->spawn(); printf("testですよ\n"); */ /* - pre_show = manager->create_task(SHOW_TIME); + pre_show = manager->create_task(ShowTime); pre_show->set_cpu((CPU_TYPE)((int)SPE_0)); pre_show->spawn(); for (int i = 1; i < 6; i++) { - show = manager->create_task(SHOW_TIME); + show = manager->create_task(ShowTime); show->set_cpu((CPU_TYPE)((int)SPE_0 + i)); show->wait_for(pre_show); show->spawn(); diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/spe/DrawSpan.cc --- a/Renderer/Engine/spe/DrawSpan.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/spe/DrawSpan.cc Sun Nov 15 02:05:33 2009 +0900 @@ -7,24 +7,46 @@ #include "Func.h" #include "sys.h" #include "global_alloc.h" +#include "SchedTask.h" +#include "Tapestry.h" +#include "SpanPack.h" + +#define BIGENDIAN 0 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); - free((void*)((int)g->linebuf*g->doneWrite)); - free(g); - return 0; -} +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 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 のブロックに分割する @@ -92,16 +114,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;hget_output(h); + for (int i = 0; i < width; i++) { + buf[i] = rgb; + } } - - return buf; + return linebuf; } /** @@ -133,18 +156,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 を更新する @@ -162,17 +173,21 @@ float normal_x, float normal_y, float normal_z, TilePtr tile) { - int color = get_rgb(tex_x, tex_y, tile); /*下位4bitを抽出*/ +#if BIGENDIAN + int alpha = color & 0x000000ff; +#else int alpha = color & 0xff000000; +#endif /*完全に透けているか判断*/ int flag = (alpha != 0); 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); } @@ -339,12 +354,6 @@ return ret; } -float -innerProduct(float *v0, float *v1) -{ - return (v0[0]*v1[0] + v0[1]*v1[1] + v0[2]*v1[2]); -} - static int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z) { @@ -357,10 +366,17 @@ float inner_product; // 引数で受け取った color の rgb 情報の抜き出し +#if BIGENDIAN + rgb[0] = (color & 0xff000000) >> 24; + rgb[1] = (color & 0x00ff0000) >> 16; + rgb[2] = (color & 0x0000ff00) >> 8; + rgb[3] = (color & 0x000000ff); +#else rgb[3] = (color & 0xff000000) >> 24; rgb[2] = (color & 0x00ff0000) >> 16; rgb[1] = (color & 0x0000ff00) >> 8; rgb[0] = (color & 0x000000ff); +#endif // 法線ベクトルと光源ベクトルとの内積をとる inner_product = innerProduct(normal_vector,light_vector); @@ -373,7 +389,11 @@ rgb[2] = (unsigned char)(rgb[2]*inner_product*flag); //計算した rgb を light_rgb にまとめる。 +#if BIGENDIAN + light_rgb = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 8) + (rgb[3]); +#else light_rgb = (rgb[3] << 24) + (rgb[2] << 16) + (rgb[1] << 8) + (rgb[0]); +#endif return light_rgb; } @@ -396,8 +416,8 @@ &drawDot1, &drawLine1 }; - uint32 display = smanager->get_param(0); - int screen_width = smanager->get_param(1); + // 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); @@ -409,11 +429,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; @@ -425,7 +442,7 @@ * 次の SpanPack の DMA 転送を行う */ if (spack->next != NULL) { - smanager->dma_load(next_spack, (uint32)spack->next, + smanager->dma_load(next_spack, (memaddr)spack->next, sizeof(SpanPack), SPAN_PACK_LOAD); } else { next_spack = NULL; @@ -470,12 +487,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: /** @@ -485,9 +500,6 @@ free(free_spack); - TaskPtr nextTask = smanager->create_task(TASK_DRAW_SPAN_END); - nextTask->add_param((int)g); - smanager->wait_task(nextTask); return 0; } diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/spe/DrawSpan.h --- a/Renderer/Engine/spe/DrawSpan.h Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/spe/DrawSpan.h Sun Nov 15 02:05:33 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 diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/spe/spe-main.cc --- a/Renderer/Engine/spe/spe-main.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/spe/spe-main.cc Sun Nov 15 02:05:33 2009 +0900 @@ -22,23 +22,23 @@ void task_init(Scheduler *s) { - SchedRegisterTask(TASK_INIT_TEXTURE, LoadTexture); - SchedRegisterTask(TASK_SET_TEXTURE, SetTexture); - SchedRegisterTask(TASK_DRAW_SPAN, DrawSpan); - SchedRegisterTask(TASK_DRAW_SPAN_END, DrawSpanEnd); + SchedRegister( LoadTexture); + SchedRegister( SetTexture); + SchedRegister( DrawSpan); + SchedRegister( DrawSpanEnd); - SchedRegisterTask(CHAINCAL_TASK, ChainCal); - SchedRegisterTask(CHAININIT_TASK, ChainInit); + SchedRegister( ChainCal); + SchedRegister( ChainInit); #if 0 - SchedRegisterTask(TASK_DRAW_SPAN2, DrawSpanRenew); + SchedRegister( DrawSpanRenew); #endif - SchedRegisterTask(TASK_DRAW_BACK, DrawBack); + SchedRegister( DrawBack); - SchedRegisterTask(TASK_CREATE_SPAN, CreateSpan); - //SchedRegisterTask(TASK_CREATE_PP, CreatePolygon); + SchedRegister( CreateSpan); + //SchedRegister( CreatePolygon); - SchedRegisterTask(SHOW_TIME, ShowTime); + SchedRegister( ShowTime); - SchedRegisterTask(INIT_KEY_TASK, InitKey); - SchedRegisterTask(UPDATE_KEY, UpdateKey); + SchedRegister( InitKey); + SchedRegister( UpdateKey); } diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/task/DrawSpan.cc --- a/Renderer/Engine/task/DrawSpan.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/task/DrawSpan.cc Sun Nov 15 02:05:33 2009 +0900 @@ -7,27 +7,46 @@ #include "Func.h" #include "sys.h" #include "global_alloc.h" +#include "SchedTask.h" +#include "Tapestry.h" +#include "SpanPack.h" + +#define BIGENDIAN 1 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 +114,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;hget_output(h); + for (int i = 0; i < width; i++) { + buf[i] = rgb; + } } - - return buf; + return linebuf; } /** @@ -136,18 +156,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 を更新する @@ -167,14 +175,19 @@ int color = get_rgb(tex_x, tex_y, tile); /*下位4bitを抽出*/ +#if BIGENDIAN int alpha = color & 0x000000ff; +#else + int alpha = color & 0xff000000; +#endif /*完全に透けているか判断*/ int flag = (alpha != 0); 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); } @@ -353,10 +366,17 @@ float inner_product; // 引数で受け取った color の rgb 情報の抜き出し +#if BIGENDIAN rgb[0] = (color & 0xff000000) >> 24; rgb[1] = (color & 0x00ff0000) >> 16; rgb[2] = (color & 0x0000ff00) >> 8; rgb[3] = (color & 0x000000ff); +#else + rgb[3] = (color & 0xff000000) >> 24; + rgb[2] = (color & 0x00ff0000) >> 16; + rgb[1] = (color & 0x0000ff00) >> 8; + rgb[0] = (color & 0x000000ff); +#endif // 法線ベクトルと光源ベクトルとの内積をとる inner_product = innerProduct(normal_vector,light_vector); @@ -369,7 +389,11 @@ rgb[2] = (unsigned char)(rgb[2]*inner_product*flag); //計算した rgb を light_rgb にまとめる。 +#if BIGENDIAN light_rgb = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 8) + (rgb[3]); +#else + light_rgb = (rgb[3] << 24) + (rgb[2] << 16) + (rgb[1] << 8) + (rgb[0]); +#endif return light_rgb; } @@ -392,8 +416,8 @@ &drawDot1, &drawLine1 }; - uint32 display = smanager->get_param(0); - int screen_width = smanager->get_param(1); + // 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 +429,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 +487,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: /** @@ -481,9 +500,6 @@ free(free_spack); - TaskPtr nextTask = smanager->create_task(TASK_DRAW_SPAN_END); - nextTask->add_param((memaddr)g); - smanager->wait_task(nextTask); return 0; } diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/task/DrawSpan.h --- a/Renderer/Engine/task/DrawSpan.h Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/task/DrawSpan.h Sun Nov 15 02:05:33 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 diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/task/task_init.cc --- a/Renderer/Engine/task/task_init.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/task/task_init.cc Sun Nov 15 02:05:33 2009 +0900 @@ -8,7 +8,6 @@ SchedExternTask(CreateSpan); SchedExternTask(DrawSpan); -SchedExternTask(DrawSpanEnd); SchedExternTask(DrawSpanRenew); SchedExternTask(DrawBack); @@ -36,31 +35,30 @@ void task_initialize() { - SchedRegisterTask(TASK_CREATE_SGP, Create_SGP); - SchedRegisterTask(TASK_UPDATE_SGP, Update_SGP); - SchedRegisterTask(TASK_CREATE_PP, CreatePolygon); - SchedRegisterTask(TASK_CREATE_PP2, CreatePolygonFromSceneGraph); - SchedRegisterTask(TASK_CREATE_SPAN, CreateSpan); + SchedRegister( Create_SGP); + SchedRegister( Update_SGP); + SchedRegister( CreatePolygon); + SchedRegister(CreatePolygonFromSceneGraph); + SchedRegister( CreateSpan); - SchedRegisterTask(TASK_DRAW_SPAN, DrawSpan); - SchedRegisterTask(TASK_DRAW_SPAN_END, DrawSpanEnd); -// SchedRegisterTask(TASK_DRAW_SPAN2, DrawSpanRenew); - SchedRegisterTask(TASK_DRAW_BACK, DrawBack); + SchedRegister( DrawSpan); + SchedRegister( DrawBack); - SchedRegisterTask(TASK_INIT_TEXTURE, LoadTexture); - SchedRegisterTask(TASK_SET_TEXTURE, SetTexture); + SchedRegister( LoadTexture); + SchedRegister( SetTexture); - SchedRegisterTask(TASK_MOVE, Move); - SchedRegisterTask(TASK_DRAW, Draw); + SchedRegister( Move); + SchedRegister( Draw); - SchedRegisterTask(TASK_DUMMY, Dummy); + SchedRegister( Dummy); - SchedRegisterTask(UPDATE_KEY, UpdateKey); - SchedRegisterTask(INIT_KEY_TASK, InitKey); + SchedRegister( UpdateKey); + SchedRegister( InitKey); - SchedRegisterTask(SHOW_TIME, ShowTime); - SchedRegisterTask(TASK_SWITCH, Switch); + SchedRegister( ShowTime); + SchedRegister( Switch); // usr - SchedRegisterTask(CHAIN_MOVE, ChainMove); + SchedRegister( ChainMove); + } diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Engine/viewer.cc --- a/Renderer/Engine/viewer.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Engine/viewer.cc Sun Nov 15 02:05:33 2009 +0900 @@ -146,10 +146,10 @@ spackList[i-1].init(i*split_screen_h); } - task_next = manager->create_task(TASK_DUMMY); + task_next = manager->create_task(Dummy); for (int i = 0; i < spe_num; i++) { - task_tex = manager->create_task(TASK_INIT_TEXTURE); + task_tex = manager->create_task(LoadTexture); /* * ここはもう少しわかりやすい使い方がいいかもしれぬ。こんなもん? */ @@ -167,7 +167,7 @@ { HTaskPtr task_next = initLoop(); // key の情報を格納する領域を確保する (global_alloc(KEY_STATUS)) - HTaskPtr init_key_task = manager->create_task(INIT_KEY_TASK); + HTaskPtr init_key_task = manager->create_task(InitKey); init_key_task->set_cpu(SPE_0); init_key_task->spawn(); @@ -182,7 +182,7 @@ /* test */ - HTaskPtr task_switch = manager->create_task(TASK_SWITCH); + HTaskPtr task_switch = manager->create_task(Switch); task_switch->wait_for(task_next); task_switch->set_post(post2runMoveDrawLoop, (void*)this, 0); task_switch->spawn(); @@ -239,27 +239,27 @@ Viewer *viewer = (Viewer*)viewer_; // 同じ PPE 上なので sgroot(ポインタ) を add_param で送る。 - //HTaskPtr send_key_task = viewer->manager->create_task(SEND_KEY); + //HTaskPtr send_key_task = viewer->manager->create_task(SendKey); //send_key_task->add_param((int)sgroot); // set input data -> viewer keyPtr viewer->getKey(); - HTaskPtr update_key = viewer->manager->create_task(UPDATE_KEY); + HTaskPtr update_key = viewer->manager->create_task(UpdateKey); update_key->add_inData(viewer->keyPtr, sizeof(key_stat)); update_key->set_cpu(SPE_0); update_key->spawn(); /* TASK_MOVE は外から引数で取ってくるべき */ //HTaskPtr move_task = viewer->manager->create_task(viewer->app->move_taskid); - HTaskPtr move_task = viewer->manager->create_task(TASK_MOVE); + HTaskPtr move_task = viewer->manager->create_task(Move); //move_task->add_param(sgroot); - //HTaskPtr draw_task = viewer->manager->create_task(TASK_DRAW); + //HTaskPtr draw_task = viewer->manager->create_task(Draw); /* rendering task test */ - HTaskPtr draw_task = viewer->manager->create_task(TASK_DUMMY); - HTaskPtr draw_dummy = viewer->manager->create_task(TASK_DUMMY); + HTaskPtr draw_task = viewer->manager->create_task(Dummy); + HTaskPtr draw_dummy = viewer->manager->create_task(Dummy); - HTaskPtr switch_task = viewer->manager->create_task(TASK_SWITCH); + HTaskPtr switch_task = viewer->manager->create_task(Switch); viewer->draw_dummy = draw_dummy; switch_task->wait_for(draw_dummy); draw_task->set_post(post2speRendering, (void*)viewer, 0); @@ -279,7 +279,7 @@ post2speRunLoop(void *viewer_) { Viewer *viewer = (Viewer *)viewer_; - HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); + HTaskPtr task_next = viewer->manager->create_task(Dummy); viewer->run_move(task_next); } #endif @@ -298,7 +298,7 @@ post2runMove(void *viewer_) { Viewer *viewer = (Viewer*)viewer_; - HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); + HTaskPtr task_next = viewer->manager->create_task(Dummy); viewer->run_move(task_next); } #endif @@ -320,7 +320,7 @@ post2rendering(SchedTask *s, void *viewer_, void *arg) { Viewer *viewer = (Viewer *)viewer_; - HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); + HTaskPtr task_next = viewer->manager->create_task(Dummy); viewer->rendering(task_next); } @@ -341,7 +341,7 @@ post2runLoop(SchedTask *s, void *viewer_, void *arg) { Viewer *viewer = (Viewer*)viewer_; - HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); + HTaskPtr task_next = viewer->manager->create_task(Dummy); viewer->run_loop(task_next); psx_sync_n(); @@ -377,7 +377,7 @@ post2runDraw(SchedTask *s, void *viewer_, void *arg) { Viewer *viewer = (Viewer*)viewer_; - HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); + HTaskPtr task_next = viewer->manager->create_task(Dummy); viewer->run_draw(task_next); } @@ -410,7 +410,7 @@ post2speRendering(SchedTask *s, void *viewer_, void *arg) { Viewer *viewer = (Viewer*)viewer_; - HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); + HTaskPtr task_next = viewer->manager->create_task(Dummy); viewer->spe_rendering(task_next); } @@ -429,7 +429,7 @@ post2speDraw(SchedTask *s, void *viewer_, void *arg) { Viewer *viewer = (Viewer*)viewer_; - HTaskPtr task_next = viewer->manager->create_task(TASK_DUMMY); + HTaskPtr task_next = viewer->manager->create_task(Dummy); viewer->spe_draw(task_next); } @@ -448,7 +448,7 @@ void Viewer::common_rendering(HTaskPtr task_next) { - HTaskPtr task_create_pp = manager->create_task(TASK_CREATE_PP2); + HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); // SceneGraph(木構造) -> PolygonPack @@ -466,7 +466,7 @@ int index_end = (index_start + range >= spackList_length) ? spackList_length : index_start + range; - HTaskPtr task_create_sp = manager->create_task(TASK_CREATE_SPAN); + HTaskPtr task_create_sp = manager->create_task(CreateSpan); task_create_sp->add_inData(ppack, sizeof(PolygonPack)); task_create_sp->add_inData(spackList_ptr, sizeof(SpanPack*)*spackList_length_align); @@ -501,7 +501,7 @@ { HTaskPtr task_draw; - //task_next = manager->create_task(TASK_DUMMY); + //task_next = manager->create_task(Dummy); //task_next->set_post(post2runLoop, (void*)this); ppack->clear(); @@ -518,12 +518,18 @@ while (startx < this->width) { if (spack->info.size > 0) { // Draw SpanPack - task_draw = manager->create_task(TASK_DRAW_SPAN); + 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); + + for (int i = 0; i < rangey; i++) { + task_draw->add_outData( + &pixels[(startx-1) + this->width*(starty-1 + i) ], + (endx-startx+1)*sizeof(int)); + } } else { // 7.7.3 SL1 Data Cache Range Set to Zero コマンド // を使って、DMAでclearするべき... ということは、 @@ -533,9 +539,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(); diff -r 4cfcac2367d5 -r 55ed910d13c2 Renderer/Test/writer.c --- a/Renderer/Test/writer.c Sat Nov 14 22:10:31 2009 +0900 +++ b/Renderer/Test/writer.c Sun Nov 15 02:05:33 2009 +0900 @@ -64,7 +64,7 @@ int tspace; int serial; int xml_id; - char *linda_serv = "localhost"; + const char *linda_serv = "localhost"; if (argc > 1) linda_serv = argv[1]; init_linda(); diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/Cell/CellTaskManagerImpl.cc --- a/TaskManager/Cell/CellTaskManagerImpl.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Sun Nov 15 02:05:33 2009 +0900 @@ -53,6 +53,10 @@ ppeManager = new FifoTaskManagerImpl(machineNum); // 大半のTaskQueueInfoは、共有される ppeManager->init(new PpeScheduler, this); + + ppeManager->get_scheduler()->set_manager(this); + schedTaskManager = new SchedTask(); + schedTaskManager->init(0,0,0,ppeManager->get_scheduler()); } void @@ -220,7 +224,9 @@ speThreads->send_mail(id, 2, (memaddr *)alloc_info); } else if (data > MY_SPE_NOP) { //__debug_ppe("[PPE] recv from [SPE %d] : 0x%x\n", id, data); - check_task_finish((HTaskPtr)data); + HTaskPtr task = (HTaskPtr)data; + task->post_func(schedTaskManager, task->post_arg1, task->post_arg2); + check_task_finish(task); } } } diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/Cell/spe/SpeTaskManagerImpl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/spe/SpeTaskManagerImpl.cc Sun Nov 15 02:05:33 2009 +0900 @@ -0,0 +1,57 @@ +#include +#include +#include +#include "FifoTaskManagerImpl.h" +#include "Scheduler.h" +#include "SchedTask.h" +#include "types.h" +#include "error.h" + +FifoTaskManagerImpl::~FifoTaskManagerImpl() +{ + +} + +/** + */ +void +FifoTaskManagerImpl::init() +{ +} + +/** + */ +void +FifoTaskManagerImpl::init(MainScheduler *_sched) +{ + scheduler = _sched; +} + + +void +FifoTaskManagerImpl::run() +{ +} + + +void* +FifoTaskManagerImpl::allocate(int size, int alignment) +{ + void *buff; + posix_memalign(&buff, alignment, size); + return buff; +} + +void* +FifoTaskManagerImpl::allocate(int size) +{ + void *buff; + posix_memalign(&buff, DEFAULT_ALIGNMENT, size); + return buff; +} + +Scheduler* +FifoTaskManagerImpl::get_scheduler() { + return scheduler; +} + diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/Cell/spe/SpeTaskManagerImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/spe/SpeTaskManagerImpl.h Sun Nov 15 02:05:33 2009 +0900 @@ -0,0 +1,30 @@ +#ifndef INCLUDED_FIFO_TASK_MANAGER_IMPL +#define INCLUDED_FIFO_TASK_MANAGER_IMPL + +#include "TaskManagerImpl.h" +#include "MainScheduler.h" +#include "Scheduler.h" + +class SpeTaskManagerImpl : public TaskManagerImpl { +public: + /* constructor */ + SpeTaskManagerImpl(int num = 1) : TaskManagerImpl(num) {} + ~SpeTaskManagerImpl(void); + + /* variables */ + CellScheduler *scheduler; + + /* functions */ + // call by system + void init(void); + void run(void); + + // call by user + int add_data(ListDataPtr, uint32, int); + void* allocate(int size,int align); + void* allocate(int size); + Scheduler* get_scheduler(); +}; + + +#endif /* INCLUDED_FIFO_TASK_MANAGER_IMPL */ diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/Cell/spe/main.cc --- a/TaskManager/Cell/spe/main.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/Cell/spe/main.cc Sun Nov 15 02:05:33 2009 +0900 @@ -23,6 +23,9 @@ manager->init(); manager->id = (int)argc; + TaskManagerImpl *tm = new SpeTaskManagerImpl(manager); + manager->set_manager(tm); + spu_write_decrementer(0x7FFFFFFFU); unsigned int prof = spu_read_decrementer(); manager->run(); diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/ChangeLog --- a/TaskManager/ChangeLog Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/ChangeLog Sun Nov 15 02:05:33 2009 +0900 @@ -1,3 +1,35 @@ +2009-11-14 Shinji KONO + + Scheduler / TaskManger / TaskManagerImpl の区別が不明 + + Scheduler は SchedTask から直接見えないはずだが、SchedTask は、 + Scheduler は知っているが、TaskManager は知らない。これがかなりの + 混乱を生んでいる。 + + SPU上では、TaskManager が存在しないのが原因らしいが、allcoate とかは、 + TaskManager が行うはず。なので、SPU上にもTaskManagerがある方が自然。 + + SchedTask が自分自身で scheduling してしまっているので、Scheduler + には、ほとんど仕事がない。なので、大半の処理を scheduler -> manager + 経由で行うことになる。 + +2009-11-14 Shinji KONO + + 要するに、SPE task 側から addOutData できればよい。 + でも、別に、PPE側から計算してもよいはずだけどね。 + そうすれば、renew task は取り外せる。 + + SchedDefineTask1(DrawSpanEnd,draw_span_end); + で、名前を指定させておいて、さらに、 + SchedExternTask(DrawSpanEnd); + SchedRegisterTask(TASK_DRAW_SPAN_END, DrawSpanEnd); + で、新しく名前を要求するのって、なんとかならんの? 読みづらいんだよ。 + DrawSpanEnd を、そのまま使ってもよさそうだけど? + + せっかく、renew task を外したのに、HD crash で失ってしまいました。 + + add_param が順序を持っているのは見づらい。数字で指定する方が合理的。 + 2009-10-11 Shinji KONO 単純な、rbuf, wbuf + write return size の task のAPI diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/Fifo/FifoTaskManagerImpl.cc --- a/TaskManager/Fifo/FifoTaskManagerImpl.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc Sun Nov 15 02:05:33 2009 +0900 @@ -3,6 +3,7 @@ #include #include "FifoTaskManagerImpl.h" #include "Scheduler.h" +#include "SchedTask.h" #include "types.h" #include "error.h" @@ -32,6 +33,7 @@ scheduler->init(); scheduler->set_mailManager(mailManager); scheduler->id = 0; + scheduler->set_manager(this); taskListImpl = new TaskListInfo; taskQueueImpl = new TaskQueueInfo; @@ -39,6 +41,9 @@ mainTaskList = taskListImpl->create(); + schedTaskManager = new SchedTask(); + schedTaskManager->init(0,0,0,scheduler); + } /** @@ -222,7 +227,11 @@ __debug_ppe("mail_check(): Task List finish\n"); } else if (data > MY_SPE_NOP) { __debug_ppe("mail_check(): recv from 0x%x\n", data); - check_task_finish((HTaskPtr)data); + // post_func を先に実行しないと、systask_finish が active_queue + // 移されてから、wait_for されるという事態が起きることがある。 + HTaskPtr task = (HTaskPtr)data; + task->post_func(schedTaskManager, task->post_arg1, task->post_arg2); + check_task_finish(task); } d = q; diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/ppe/Task.cc --- a/TaskManager/kernel/ppe/Task.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/ppe/Task.cc Sun Nov 15 02:05:33 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 みたいにしたほうがわかりやすいかな。 diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/ppe/Task.h --- a/TaskManager/kernel/ppe/Task.h Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/ppe/Task.h Sun Nov 15 02:05:33 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)); diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/ppe/TaskManager.cc --- a/TaskManager/kernel/ppe/TaskManager.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManager.cc Sun Nov 15 02:05:33 2009 +0900 @@ -1,8 +1,8 @@ #include "TaskManager.h" +#include "Scheduler.h" TaskManager::TaskManager(int num) : machineNum(num) { - gen_random = new Random; } TaskManager::~TaskManager() @@ -83,7 +83,13 @@ int TaskManager::get_random() { - return gen_random->getData(); + return random(); +} + +MemList* +TaskManager::createMemList(int size, int count) +{ + return get_scheduler()->createMemList(size, count); } Scheduler* diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/ppe/TaskManager.h --- a/TaskManager/kernel/ppe/TaskManager.h Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManager.h Sun Nov 15 02:05:33 2009 +0900 @@ -4,9 +4,11 @@ #include "TaskManagerImpl.h" #include "Random.h" #include "MemList.h" -#include "Scheduler.h" #include "HTask.h" +class Scheduler; +class MemList; + class TaskManager { public: /* constructor */ @@ -26,6 +28,7 @@ int get_cpuNum(); int get_random(); Scheduler *get_scheduler(); + MemList* createMemList(int size, int count); /* functions */ void init(); diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/ppe/TaskManagerImpl.cc --- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Sun Nov 15 02:05:33 2009 +0900 @@ -3,9 +3,10 @@ #include "types.h" #include "error.h" #include "SchedTask.h" -#include "SchedTaskManager.h" #include "../sys_task/SysTask.h" +#include "Scheduler.h" + static HTaskPtr systask_start; static HTaskPtr systask_finish; @@ -32,8 +33,6 @@ { systask_register(); - schedTaskManager = new SchedTaskManager(this); - systask_start = create_task(SYSTASK_START); systask_finish = create_task(SYSTASK_FINISH); @@ -125,10 +124,6 @@ void TaskManagerImpl::check_task_finish(HTaskPtr me) { - // post_func を先に実行しないと、systask_finish が active_queue - // 移されてから、wait_for されるという事態が起きることがある。 - - me->post_func(schedTaskManager, me->post_arg1,me->post_arg2); while(TaskQueue *p = me->wait_me->poll()) { HTaskPtr you = p->task; @@ -166,4 +161,5 @@ // done in check_task_finish } + /* end */ diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/ppe/TaskManagerImpl.h --- a/TaskManager/kernel/ppe/TaskManagerImpl.h Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.h Sun Nov 15 02:05:33 2009 +0900 @@ -3,10 +3,11 @@ #include "MailManager.h" #include "ListData.h" -#include "Scheduler.h" #include "TaskListInfo.h" #include "TaskQueueInfo.h" #include "HTaskInfo.h" +class Scheduler; +class MemList; class TaskManagerImpl { @@ -20,6 +21,7 @@ TaskListInfo *taskListImpl; TaskQueueInfo *taskQueueImpl; HTaskInfo *htaskImpl; + SchedTask *schedTaskManager; /* constructor */ @@ -44,8 +46,10 @@ void set_task_depend(HTaskPtr master, HTaskPtr slave); void spawn_task(HTaskPtr); void set_task_cpu(HTaskPtr, CPU_TYPE); + virtual void* allocate(int size) = 0; virtual void* allocate(int size,int align) = 0; virtual Scheduler* get_scheduler() = 0; }; + #endif diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/schedule/SchedNop2Ready.cc --- a/TaskManager/kernel/schedule/SchedNop2Ready.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedNop2Ready.cc Sun Nov 15 02:05:33 2009 +0900 @@ -20,19 +20,8 @@ SchedTaskBase* SchedNop2Ready::next(Scheduler *scheduler,SchedTaskBase *p) { - SchedTaskBase *nextSched; - __debug("[SchedNop2Ready:%s]\n", __FUNCTION__); - // delete p; - - nextSched = scheduler->get_nextRenewTaskList(); - - // RenewTask がある - if (nextSched) { - return nextSched; - } else { - scheduler->mail_write(MY_SPE_STATUS_READY); - return new SchedMail(); - } + scheduler->mail_write(MY_SPE_STATUS_READY); + return new SchedMail(); } diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/schedule/SchedTask.cc --- a/TaskManager/kernel/schedule/SchedTask.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Sun Nov 15 02:05:33 2009 +0900 @@ -10,8 +10,6 @@ extern Scheduler::TaskObject task_list[MAX_TASK_OBJECT]; -//#define NO_PIPELINE - /** Task Object を作る */ @@ -46,19 +44,11 @@ readbuf = NULL; writebuf = NULL; scheduler = NULL; - taskGroup = NULL; - renew_flag = 0; cur_index = 0; - flag_renewTask = SCHED_TASK_NORMAL; this->stdout_ = stdout; this->stderr_ = stderr; this->stdin_ = stdin; - ex_init = &SchedTask::ex_init_normal; - ex_read = &SchedTask::ex_read_normal; - ex_exec = &SchedTask::ex_exec_normal; - ex_write = &SchedTask::ex_write_normal; - ex_next = &SchedTask::ex_next_normal; } @@ -67,35 +57,8 @@ */ SchedTask::~SchedTask() { - if (flag_renewTask == SCHED_TASK_RENEW) { - /** - * list != NULL の場合、 - * この Task が list の最後の Task になるので (SchedTask::next 参照) - * このタイミングで list を解放する - * (free に渡されるアドレスが正しいものとなる)。 - * それ以外の Task では当然解放しない。 - * list == NULL なので、free に渡しても無問題 - */ - free(list); - } - - } -/** - * このタスクを Renew Task とし、それに応じた関数をセットする - */ -void -SchedTask::setRenew() -{ - flag_renewTask = SCHED_TASK_RENEW; - - ex_init = &SchedTask::ex_init_renew; - ex_read = &SchedTask::ex_read_renew; - ex_exec = &SchedTask::ex_exec_renew; - ex_write = &SchedTask::ex_write_renew; - ex_next = &SchedTask::ex_next_renew; -} void SchedTask::init(TaskListPtr _list, TaskPtr _task, int index, @@ -111,56 +74,14 @@ scheduler->mainMem_wait(); - (this->*ex_init)(); } -/** - * PPE 内で生成されたタスクの ex_init() - */ -void -SchedTask::ex_init_normal() -{ -#if 0 - // task list に入れたので既に読んでいる? - // - scheduler->dma_load(inListData, (uint32)&task->inData, - sizeof(ListData), DMA_READ_IN_LIST); - scheduler->dma_load(outListData, (uint32)&task->outData, - sizeof(ListData), DMA_READ_OUT_LIST); -#if defined(NO_PIPELINE) - scheduler->dma_wait(DMA_READ_IN_LIST); - scheduler->dma_wait(DMA_READ_OUT_LIST); -#endif -#endif - - taskGroup = new TaskGroup; - taskGroup->command = (int)task->self; -} - -/** - * SPE 内で生成されたタスクの ex_init() - * 各データは SPE 内の create_task 時に生成もしくは引き継がれているので - * ex_init_normal() と違い、ここでは値を渡すだけ - */ -void -SchedTask::ex_init_renew() -{ - inListData = &task->inData; - outListData = &task->outData; - taskGroup = (TaskGroupPtr)task->self; -} void SchedTask::read() { __debug("[SchedTask:%s]\n", __FUNCTION__); -#if 0 -#if !defined(NO_PIPELINE) - scheduler->dma_wait(DMA_READ_IN_LIST); - scheduler->dma_wait(DMA_READ_OUT_LIST); -#endif -#endif // object creation をSchedTask生成時にやらないので、 // exec の直前のread で十分に間に合う if (cur_index < list->length) { @@ -177,61 +98,24 @@ readbuf = scheduler->allocate(inListData->size); scheduler->dma_loadList(inListData, readbuf, DMA_READ); -#if defined(NO_PIPELINE) - scheduler->dma_wait(DMA_READ); -#endif - (this->*ex_read)(); } -/** - * PPE 内で生成されたタスクの ex_read() - * - * [Todo] - * データの読み込み場所を readbuf ではなく、 - * ユーザ自身で決めれるようになるといいかもしれない。 - * - * # TaskManager が勝手に消すことなく、 - * # ユーザが SPE 上に持ち続けることができるため。 - * # もちろん管理はユーザに任せるわけだ。 - */ -void -SchedTask::ex_read_normal() -{ -} void SchedTask::exec() { __debug("[SchedTask:%s]\n", __FUNCTION__); -#if !defined(NO_PIPELINE) scheduler->dma_wait(DMA_READ); task_list[task->command].wait(scheduler,task->command); -#endif - task_list[task->command].run(this, readbuf, writebuf); - free(readbuf); - if (taskGroup->status() != 0) { - task->self = (int)taskGroup->command; - delete taskGroup; - taskGroup = NULL; - } - - // 書き込む領域がなければ無視 if (outListData->length > 0) { scheduler->dma_storeList(outListData, writebuf, DMA_WRITE); - -#if defined(NO_PIPELINE) - scheduler->dma_wait(DMA_WRITE); - free(writebuf); -#endif } - - (this->*ex_exec)(); } void @@ -239,187 +123,40 @@ { __debug("[SchedTask:%s]\n", __FUNCTION__); -#if !defined(NO_PIPELINE) scheduler->dma_wait(DMA_WRITE); free(writebuf); -#endif - if ((int)task->self == MY_SPE_NOP) return; - - (this->*ex_write)(); -} - - -/** - * SPE 内で生成されたタスクの ex_read() - */ -void -SchedTask::ex_read_renew() -{ - writebuf = scheduler->allocate(outListData->size); -} - -/** - * PPE 内で生成されたタスクの ex_exec() - */ -void -SchedTask::ex_exec_normal() -{ -} - -/** - * SPE 内で生成されたタスクの ex_exec() - */ -void -SchedTask::ex_exec_renew() -{ + scheduler->mail_write((int)task->self); } - -/** - * PPE 内で生成されたタスクの ex_write() - * - * このタスク内で新たにタスクが生成され、 - * 且つそのタスクの終了を待つ必要がある場合、 - * PPE に終了したことは知らせない(command は送信しない) - */ -void -SchedTask::ex_write_normal() -{ - /** - * このタスク内で新たにタスクが生成されなかった - * or 生成されたが、そのタスクの終了を待つ必要は無い - */ - if (renew_flag == 0) { - scheduler->mail_write((int)task->self); - } -} - -/** - * SPE 内で生成されたタスクの ex_write() - * - * A <- 親タスク - * | \ - * B C <- SPE 内で生成されたタスク - * - * A は SPE 内で B, C を生成したとする。 - * B と C が終了したら、A が PPE に送るはずだったコマンドが - * 子タスクに引き継がれているので、最後に実行された子タスクが - * PPE に mail 送信する。 - */ -void -SchedTask::ex_write_renew() -{ - uint32 cmd; - - taskGroup->remove(task); - cmd = taskGroup->status(); - - // タスク内で作られた全てのタスクが終了した - if (cmd != 0) { - delete taskGroup; - scheduler->mail_write(cmd); - } -} - SchedTaskBase* SchedTask::next(Scheduler *scheduler, SchedTaskBase *p) { __debug("[SchedTask:%s]\n", __FUNCTION__); - // delete p; move to Scheduler - - return (this->*ex_next)(); -} - -SchedTaskBase* -SchedTask::ex_next_normal() -{ if (cur_index < list->length) { - SchedTaskBase *nextSched; - - nextSched = scheduler->get_nextRenewTaskList(); + // Task List が残っているので、次を準備 - // RenewTask がある - if (nextSched) { - scheduler->set_backupTaskList(list); - scheduler->set_backupTaskListIndex(cur_index); - return nextSched; - } else { - TaskPtr nextTask = &list->tasks[cur_index++]; - nextSched = createSchedTask(scheduler, nextTask); - ((SchedTask*)nextSched)->init(list, nextTask, cur_index, - // scheduler->get_curReadBuf(), - // scheduler->get_curWriteBuf(), - scheduler); - return nextSched; - } + TaskPtr nextTask = &list->tasks[cur_index++]; + SchedTaskBase *nextSched = createSchedTask(scheduler, nextTask); + // この up cast は汚い... + ((SchedTask*)nextSched)->init(list, nextTask, cur_index, + scheduler); + return nextSched; } else { memaddr nextList = (memaddr)list->next; - if (nextList == 0) { + // もう何もする必要がない return new SchedNop2Ready(scheduler); } else { + // 新しいリストに取り掛かる return createSchedTaskList(nextList, scheduler, SCHED_TASKLIST_NORMAL); } } } -/** - * - */ -SchedTaskBase* -SchedTask::ex_next_renew() -{ - TaskPtr nextTask; - SchedTask *nextSched; - - if (cur_index < list->length) { - nextTask = &list->tasks[cur_index++]; - nextSched = createSchedTask(scheduler, nextTask); - - // RenewTaskList を実行中なので - nextSched->setRenew(); - nextSched->init(list, nextTask, cur_index, - // scheduler->get_curReadBuf(), - // scheduler->get_curWriteBuf(), - scheduler); - - /** - * この理由は SchedTask:~SchedTask() で - */ - list = NULL; - return nextSched; - } else { - SchedTaskBase *nextList; - - nextList = scheduler->get_nextRenewTaskList(); - - if (nextList) { - return nextList; - } else { - TaskListPtr nextList = scheduler->get_backupTaskList(); - - // 中断した TaskList がある - if (nextList) { - cur_index = scheduler->get_backupTaskListIndex(); - - nextTask = &nextList->tasks[cur_index++]; - nextSched = createSchedTask(scheduler, nextTask); - - nextSched->init(nextList, nextTask, cur_index, - // scheduler->get_curReadBuf(), - // scheduler->get_curWriteBuf(), - scheduler); - return nextSched; - } else { - return new SchedNop2Ready(scheduler); - } - } - } -} int SchedTask::get_cpuid() @@ -496,39 +233,6 @@ return task->param[index]; } -TaskPtr -SchedTask::create_task(int cmd) -{ - TaskListPtr taskList = scheduler->get_renewListBuf(); - TaskPtr p = &taskList->tasks[taskList->length++]; - p->command = cmd; - - // already allocated - // p->inData = (ListData*)scheduler->allocate(sizeof(ListData)); - // p->outData = (ListData*)scheduler->allocate(sizeof(ListData)); - - p->inData.clear(); - p->outData.clear(); - - p->self = (int)MY_SPE_NOP; - p->param_size = 0; - - return p; -} - -/** - * - * @param[in] waitTask タスク内で生成したタスクの登録(spawn()に相当) - */ -void -SchedTask::wait_task(TaskPtr waitTask) -{ - waitTask->self = (memaddr)taskGroup; - - scheduler->add_groupTask(taskGroup, waitTask); - - renew_flag++; -} void* SchedTask::global_alloc(int id, int size) { @@ -570,11 +274,6 @@ return scheduler->mainMem_get(id); } -void* -SchedTask::allocate(int size) { - return scheduler->allocate(size); -} - void SchedTask::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) { @@ -608,6 +307,42 @@ scheduler->wait_segment(s); } + +HTaskPtr SchedTask::create_task(int cmd) +{ + return scheduler->create_task(cmd); +} + +void SchedTask::set_task_depend(HTaskPtr master, HTaskPtr slave) +{ + scheduler->set_task_depend(master, slave); +} + +void SchedTask::spawn_task(HTaskPtr t) +{ + scheduler->spawn_task(t); +} + +void SchedTask::set_task_cpu(HTaskPtr t, CPU_TYPE cpu) +{ + scheduler->set_task_cpu(t, cpu); +} + +void* SchedTask::allocate(int size) +{ + return scheduler->allocate(size) ; +} + +void* SchedTask::allocate(int size,int align) +{ + return scheduler->allocate(size,align) ; +} + +Scheduler* SchedTask::get_scheduler() +{ + return scheduler; +} + /* system call */ int diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/schedule/SchedTask.h --- a/TaskManager/kernel/schedule/SchedTask.h Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Sun Nov 15 02:05:33 2009 +0900 @@ -7,7 +7,7 @@ #include "Scheduler.h" #include "SchedTaskBase.h" #include "ListData.h" -#include "TaskGroup.h" +#include "HTask.h" #include "MemList.h" class SchedTask : public SchedTaskBase { @@ -44,25 +44,6 @@ // Task の、Tasklist での位置。(task = &list[cur_index-1]) int cur_index; - // タスク内で生成されたタスクのグループ - TaskGroup *taskGroup; - - // このタスク内で生成されたタスクの数 - int renew_flag; - - // このタスクが SPE 内で生成されたタスクか否か 1: Yes, 0: No - int flag_renewTask; - - // タスクがメインメモリ側で生成されたものか、 - // SPE で生成されたものかによって、データの扱いが変わってくる。 - // そのために if (flag_renewTask) を連発するのはよくないので - // 関数ポインタで持っておく - void (SchedTask::*ex_init)(); - void (SchedTask::*ex_read)(); - void (SchedTask::*ex_exec)(); - void (SchedTask::*ex_write)(); - SchedTaskBase* (SchedTask::*ex_next)(); - /* functions */ // override @@ -76,30 +57,10 @@ //--- System API --- SchedTask* get_nextTask(TaskListPtr list); - /** - * PPE で生成されたタスクに対する - * init, read,exec,write,next の付属(?)処理 - */ - void ex_init_normal(); - void ex_read_normal(); - void ex_exec_normal(); - void ex_write_normal(); - SchedTaskBase* ex_next_normal(); - - /** - * SPE で生成されたタスクに対する - * inti, ead,exec,write,next の付属(?)処理 - */ - void ex_init_renew(); - void ex_read_renew(); - void ex_exec_renew(); - void ex_write_renew(); - SchedTaskBase* ex_next_renew(); public: /* functions */ - void setRenew(); void init(TaskListPtr _list, TaskPtr _task, int index, // ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc); @@ -117,8 +78,6 @@ int get_param(int index); - TaskPtr create_task(int cmd); - void wait_task(TaskPtr waitTask); void* global_alloc(int id, int size); void* global_get(int id); @@ -160,6 +119,14 @@ return get_output(writebuf, index); } + // user + HTaskPtr create_task(int cmd); + void set_task_depend(HTaskPtr master, HTaskPtr slave); + void spawn_task(HTaskPtr); + void set_task_cpu(HTaskPtr, CPU_TYPE); + void* allocate(int size,int align); + Scheduler* get_scheduler(); + /* system call */ FILE *stdout_; diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/schedule/SchedTaskList.cc --- a/TaskManager/kernel/schedule/SchedTaskList.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskList.cc Sun Nov 15 02:05:33 2009 +0900 @@ -54,10 +54,7 @@ __debug("[SchedTaskList:%s]\n", __FUNCTION__); - // delete p; - scheduler->dma_wait(DMA_READ_TASKLIST); - if (list->length < 1) { nextSched = new SchedNop2Ready(scheduler); @@ -68,14 +65,7 @@ } else { TaskPtr nextTask = &list->tasks[0]; nextSched = createSchedTask(scheduler, nextTask); - - if (flag_renewTaskList == SCHED_TASKLIST_RENEW) { - ((SchedTask*)nextSched)->setRenew(); - } - ((SchedTask*)nextSched)->init(list, nextTask, 1, - // scheduler->get_curReadBuf(), - // scheduler->get_curWriteBuf(), scheduler); } diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/schedule/SchedTaskManager.cc --- a/TaskManager/kernel/schedule/SchedTaskManager.cc Sat Nov 14 22:10:31 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ - -#include "TaskManagerImpl.h" -#include "SchedTaskManager.h" - -SchedTaskManager::SchedTaskManager(TaskManagerImpl *m_) -{ - m = m_; -} - -SchedTaskManager::~SchedTaskManager() -{ -} - -HTaskPtr SchedTaskManager::create_task(int cmd) -{ - return m->create_task(cmd); -} - -void SchedTaskManager::set_task_depend(HTaskPtr master, HTaskPtr slave) -{ - m->set_task_depend(master, slave); -} - -void SchedTaskManager::spawn_task(HTaskPtr t) -{ - m->spawn_task(t); -} - -void SchedTaskManager::set_task_cpu(HTaskPtr t, CPU_TYPE cpu) -{ - m->set_task_cpu(t, cpu); -} - -void* SchedTaskManager::allocate(int size) -{ - return m->allocate(size) ; -} - -void* SchedTaskManager::allocate(int size,int align) -{ - return m->allocate(size,align) ; -} - -Scheduler* SchedTaskManager::get_scheduler() -{ - return m->get_scheduler() ; -} - -/* end */ diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/schedule/SchedTaskManager.h --- a/TaskManager/kernel/schedule/SchedTaskManager.h Sat Nov 14 22:10:31 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -#ifndef INCLUDED_SCHED_TASK_MANAGER -#define INCLUDED_SCHED_TASK_MANAGER - -#include -#include -#include "base.h" -#include "SchedTask.h" -#include "TaskManagerImpl.h" - -class SchedTaskManager : public SchedTask { -public: - /* constructor */ - SchedTaskManager(TaskManagerImpl *m); - - virtual ~SchedTaskManager(); - - BASE_NEW_DELETE(SchedTask); - - /* variables */ - - // Task を実行するスケジューラ自身 - TaskManagerImpl *m; - -public: - /* functions */ - - // user - HTaskPtr create_task(int cmd); - void set_task_depend(HTaskPtr master, HTaskPtr slave); - void spawn_task(HTaskPtr); - void set_task_cpu(HTaskPtr, CPU_TYPE); - void* allocate(int size); - void* allocate(int size,int align); - Scheduler* get_scheduler(); -}; -#endif diff -r 4cfcac2367d5 -r 55ed910d13c2 TaskManager/kernel/schedule/Scheduler.cc --- a/TaskManager/kernel/schedule/Scheduler.cc Sat Nov 14 22:10:31 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Sun Nov 15 02:05:33 2009 +0900 @@ -28,14 +28,9 @@ for (int i = 0; i < 2; i++) { buff_taskList[i] = (TaskListPtr)allocate(sizeof(TaskList)); - // buff_inListData[i] = (ListDataPtr)allocate(sizeof(ListData)); - // buff_outListData[i] = (ListDataPtr)allocate(sizeof(ListData)); } buffFlag_taskList = 0; - // buffFlag_inListData = 0; - // buffFlag_outListData = 0; - flag_renewTaskList = 0; // bzero でもいいけど for (int i = 0; i < MAX_GLOBAL_AREA; i++) { @@ -47,10 +42,6 @@ } - taskGroup = new TaskGroup; - renewTop_taskList = NULL; - renewCur_taskList = NULL; - bak_curTaskList = NULL; } void @@ -83,10 +74,6 @@ { free(buff_taskList[0]); free(buff_taskList[1]); - // free(buff_inListData[0]); - // free(buff_inListData[1]); - // free(buff_outListData[0]); - // free(buff_outListData[1]); } /** @@ -102,115 +89,6 @@ } -/** - * Task に inListData, outListData を入れたので、