Mercurial > hg > Game > Cerium
changeset 618:58417006268c draft
worked. Cell fix. (not yet tested)
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 14 Nov 2009 21:17:02 +0900 |
parents | df618a956eb9 |
children | 278db3ca751d |
files | Renderer/Engine/ChangeLog Renderer/Engine/spe/DrawSpan.cc Renderer/Engine/spe/DrawSpan.h |
diffstat | 3 files changed, 67 insertions(+), 90 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/ChangeLog Sat Nov 14 20:17:37 2009 +0900 +++ b/Renderer/Engine/ChangeLog Sat Nov 14 21:17:02 2009 +0900 @@ -1,9 +1,14 @@ +2009-11-14 Shinji Kono <kono@ie.u-ryukyu.ac.jp> + +DrawSpan の dma_write を追放。なんでこんなになっていたかは謎。 + +これで、renew Task を落とせます。 + 2009-08-06 Shinji Kono <kono@ie.u-ryukyu.ac.jp> DrawSpan の reboot/ TASK_DRAW_SPAN2 は、使ってないのね。 - 2009-03-29 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> * Makefile
--- a/Renderer/Engine/spe/DrawSpan.cc Sat Nov 14 20:17:37 2009 +0900 +++ b/Renderer/Engine/spe/DrawSpan.cc Sat Nov 14 21:17:02 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;h<height;h++) { + int *buf = linebuf[h] = (int*)smanager->get_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,7 +416,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); @@ -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(DrawSpanEnd); - nextTask->add_param((int)g); - smanager->wait_task(nextTask); return 0; }
--- a/Renderer/Engine/spe/DrawSpan.h Sat Nov 14 20:17:37 2009 +0900 +++ b/Renderer/Engine/spe/DrawSpan.h Sat Nov 14 21:17:02 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